@lincoln504/pi-research 1.7.19 → 1.7.21
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 +12 -31
- package/agent-skill/pi-research/SKILL.md +1 -1
- package/agent-skill/pi-research/scripts/run.mjs +32 -15
- package/dist/host-roots.mjs +42 -13
- package/docs/AGENT-SKILL.md +6 -14
- package/docs/ARCHITECTURE.md +7 -6
- package/docs/CHANGELOG.md +34 -0
- package/docs/CONFIGURATION.md +6 -4
- package/docs/PI-EXTENSION.md +1 -1
- package/docs/SDK.md +6 -18
- package/docs/TROUBLESHOOTING.md +78 -0
- package/package.json +3 -2
- package/scripts/bare-imports.cjs +19 -6
- package/src/host-roots.mjs +42 -13
package/README.md
CHANGED
|
@@ -49,42 +49,31 @@ npm install -g @lincoln504/pi-research
|
|
|
49
49
|
pi-research skill install
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
No extra setup is needed. The package ships ready-made bindings for every platform and declares no build step
|
|
53
|
-
|
|
54
|
-
The `@earendil-works/pi-*` host packages are **peer dependencies**. pi supplies its own copies when it loads this as an extension, and npm ≥7 installs them automatically for a standalone (global or project) install. An install that skips peers does not get them: `npm install --legacy-peer-deps`, yarn classic, and `pi install` itself (it passes that flag on purpose) are all in that group. The standalone engine and the agent-skill launcher look for the host's copies where pi or a global npm install puts them (the global npm root of the running Node, the directory behind the `pi` command, bun's global root, or a directory named by `PI_RESEARCH_HOST_DIR`) and use them when they are not installed beside the engine, so a `pi install` plus a global pi works for agents with no extra step. When nothing is found they stop with a message naming the missing packages and the commands that fix it:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
# into the tree pi-research is installed in (for pi: ~/.pi/agent/npm); kept across `pi update`
|
|
58
|
-
npm install --prefix ~/.pi/agent/npm --legacy-peer-deps @earendil-works/pi-ai @earendil-works/pi-coding-agent @earendil-works/pi-tui typebox
|
|
59
|
-
# or a global install, which is found automatically
|
|
60
|
-
npm install -g @earendil-works/pi-coding-agent
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
`PI_RESEARCH_NO_HOST_FALLBACK=1` turns the lookup off. Inside pi nothing is needed: the host's own copy is aliased in for the extension, and the browser worker bundle carries the one peer it needs (`typebox`) itself.
|
|
52
|
+
No extra setup is needed. The package ships ready-made bindings for every platform and declares no build step. The stealth browser (about 1 GB) is downloaded once, at install or on the first scrape depending on your npm version (see [Troubleshooting](docs/TROUBLESHOOTING.md#the-first-scrape-takes-minutes-or-install-downloads-over-a-gigabyte)).
|
|
64
53
|
|
|
65
54
|
In pi, the extension works out of the box on the session's model and pi's configuration. Standalone use ([agent skill](docs/AGENT-SKILL.md) or [SDK](docs/SDK.md)) needs a model configured. See [Configuration](docs/CONFIGURATION.md).
|
|
66
55
|
|
|
56
|
+
If something does not work, start with [Troubleshooting](docs/TROUBLESHOOTING.md).
|
|
57
|
+
|
|
67
58
|
### Update
|
|
68
59
|
|
|
69
|
-
`pi update --extensions` moves every installed extension to its newest published version; `pi update npm:@lincoln504/pi-research` targets only this one. A versioned source (`npm:@lincoln504/pi-research@1.7.9`) is pinned and never updates
|
|
60
|
+
`pi update --extensions` moves every installed extension to its newest published version; `pi update npm:@lincoln504/pi-research` targets only this one. A versioned source (`npm:@lincoln504/pi-research@1.7.9`) is pinned and never updates; remove and reinstall it to move versions. Restart open pi sessions afterwards.
|
|
70
61
|
|
|
71
62
|
### Uninstall
|
|
72
63
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
`pi remove npm:@lincoln504/pi-research` removes the extension. `npm uninstall -g @lincoln504/pi-research` removes the standalone engine. npm 7+ no longer runs `preuninstall`, so nothing else is removed on its own: skill links into other agents (Claude Code, Codex, …), the state directory (`~/.pi/research/state`), and the cache (`~/.cache/pi-research`, including any downloaded embedding models) stay in place. Remove the skill links first with `pi-research skill uninstall` (or `/research-config` → Remove from External Agents), then remove the rest with `pi-research cleanup`: The shared stealth-browser cache (`~/.cache/camoufox`) is preserved unless `PI_RESEARCH_PURGE_BROWSERS=1`. See [AGENT-SKILL.md](docs/AGENT-SKILL.md#installation-flow) for the full picture.
|
|
64
|
+
`pi remove npm:@lincoln504/pi-research` removes the extension; `npm uninstall -g @lincoln504/pi-research` removes the standalone engine. Neither removes skill links, the state directory (`~/.pi/research/state`), or the cache (`~/.cache/pi-research`): run `pi-research skill uninstall`, then `pi-research cleanup` ([AGENT-SKILL.md](docs/AGENT-SKILL.md#installation-flow)).
|
|
76
65
|
|
|
77
66
|
### How it works
|
|
78
67
|
|
|
79
68
|
A research run works in rounds. A coordinator plans each round and starts the first search, researcher agents scrape and read pages in parallel, and a research lead then either starts another round or writes the final report from everything collected. The result is one cited Markdown report, optionally saved to the knowledge store.
|
|
80
69
|
|
|
81
|
-
Three depth levels (normal, deep, ultra) set the team size and number of rounds. Just describe what you need in plain language, and the tool picks the right one:
|
|
70
|
+
Three depth levels (normal, deep, ultra) set the team size and number of rounds; an opt-in quick mode (depth 0) answers a simple question in one pass with no team. Just describe what you need in plain language, and the tool picks the right one:
|
|
82
71
|
|
|
83
72
|

|
|
84
73
|
|
|
85
74
|
### Use cases
|
|
86
75
|
|
|
87
|
-
- Researching inside pi.
|
|
76
|
+
- Researching inside pi.
|
|
88
77
|
- Researching from Claude Code, Codex, or another coding agent while a cheaper or local model drives the run. The main agent's budget stays untouched.
|
|
89
78
|
- Saving findings to a persistent, searchable knowledge store, scoped globally or per project.
|
|
90
79
|
- Building agent systems that find and read web content, or collecting a dataset of web sources.
|
|
@@ -101,23 +90,15 @@ Three depth levels (normal, deep, ultra) set the team size and number of rounds.
|
|
|
101
90
|
- Node.js >= 22.22.2
|
|
102
91
|
- An LLM with a 100k+ context window (an API key or a local model)
|
|
103
92
|
- Internet access on a residential IP, since search, scraping, and YouTube transcripts get bot-blocked from datacenter/VPS/cloud IPs
|
|
104
|
-
- pi (`@earendil-works/pi-coding-agent`) 0.99.0 or newer, including the 1.x line.
|
|
105
|
-
- Local knowledge-store embeddings need `@huggingface/transformers`, an optional dependency. If its native image chain (sharp) cannot install, npm skips it with a warning and the install still succeeds
|
|
106
|
-
-
|
|
93
|
+
- pi (`@earendil-works/pi-coding-agent`) 0.99.0 or newer, including the 1.x line. A host newer than this release's tested ceiling still runs, with a one-line notice. The standalone CLI and skill use the host packages as peer dependencies (see [Troubleshooting](docs/TROUBLESHOOTING.md#the-agent-skill-or-cli-says-cannot-start--missing-required-runtime-dependencies)).
|
|
94
|
+
- Local knowledge-store embeddings need `@huggingface/transformers`, an optional dependency. If its native image chain (sharp) cannot install, npm skips it with a warning and the install still succeeds; everything works except local embeddings, and the store tells you how to restore them.
|
|
95
|
+
- To run the knowledge store with no embedding model at all, set `PI_RESEARCH_KNOWLEDGE_STORE_RETRIEVAL=bm25` for a pure lexical (BM25) store. See [KNOWLEDGE-STORE.md](docs/KNOWLEDGE-STORE.md).
|
|
107
96
|
- Cloudflare Turnstile and similar systems block scraping on some sites. A run compensates with a wide pool of search results to scrape.
|
|
108
97
|
|
|
109
|
-
### Channels
|
|
110
|
-
|
|
111
|
-
npm (`npm:@lincoln504/pi-research`) is the stable channel and is kept current with breaking pi changes. A git install is the development channel. It has the latest commits and receives breaking changes first.
|
|
112
|
-
|
|
113
98
|
### License
|
|
114
99
|
|
|
115
100
|
MIT. Bundled third-party licenses are listed in [docs/THIRD-PARTY-NOTICES.md](docs/THIRD-PARTY-NOTICES.md).
|
|
116
101
|
|
|
117
|
-
###
|
|
118
|
-
|
|
119
|
-
This project is always `@lincoln504/pi-research` on npm. The `pi-research` (unscoped) package is unrelated and deprecated.
|
|
120
|
-
|
|
121
|
-
### Versioning
|
|
102
|
+
### Notes
|
|
122
103
|
|
|
123
|
-
pi-research typically follows the latest pi version and is not actively backwards compatible.
|
|
104
|
+
The package is always `@lincoln504/pi-research` on npm; the unscoped `pi-research` package is unrelated and deprecated. npm is the stable channel; a git install has the latest commits and receives breaking changes first. pi-research typically follows the latest pi version and is not actively backwards compatible.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: pi-research
|
|
3
3
|
description: "Multi-agent web research for any coding agent. Use for anything requiring current information from the internet — news, trends, product/service/company facts, statistics, people, places, events, APIs, library behavior, or 'what is X / how does X work' questions. Also use to search a local knowledge store of previously researched findings before doing live research. Powered by the pi-research engine (search, stealth scraping, security databases, Stack Exchange). Not for reading local files, running project commands, or analyzing this repository's own source."
|
|
4
4
|
license: MIT
|
|
5
|
-
metadata: { "author": "Lincoln Deen", "version": "1.7.
|
|
5
|
+
metadata: { "author": "Lincoln Deen", "version": "1.7.21", "package": "@lincoln504/pi-research", "engine": "pi-research-sdk", "openclaw": { "requires": { "bins": ["node"] } } }
|
|
6
6
|
allowed-tools: Bash(node:*)
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
// agent-skill/pi-research/scripts/run.ts
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { existsSync as existsSync2, readFileSync, realpathSync as realpathSync2 } from "node:fs";
|
|
5
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
6
6
|
import { homedir as homedir2, constants as osConstants } from "node:os";
|
|
7
7
|
import { dirname as dirname2, join as join2, resolve } from "node:path";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
|
|
10
10
|
// src/host-roots.mjs
|
|
11
|
-
import { existsSync, realpathSync } from "node:fs";
|
|
11
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
12
12
|
import { homedir } from "node:os";
|
|
13
|
-
import { delimiter, dirname, join } from "node:path";
|
|
13
|
+
import { delimiter, dirname, isAbsolute, join } from "node:path";
|
|
14
14
|
import { spawnSync } from "node:child_process";
|
|
15
15
|
var HOST_PACKAGES = [
|
|
16
16
|
"@earendil-works/pi-ai",
|
|
@@ -23,7 +23,7 @@ function binsOnPath(name) {
|
|
|
23
23
|
const exts = process.platform === "win32" ? (process.env["PATHEXT"] ?? ".EXE;.CMD").split(";") : [""];
|
|
24
24
|
const out = [];
|
|
25
25
|
for (const dir of (process.env["PATH"] ?? "").split(delimiter)) {
|
|
26
|
-
if (!dir) continue;
|
|
26
|
+
if (!dir || !isAbsolute(dir)) continue;
|
|
27
27
|
for (const ext of exts) {
|
|
28
28
|
const candidate = join(dir, name + ext);
|
|
29
29
|
if (existsSync(candidate)) out.push(candidate);
|
|
@@ -31,6 +31,22 @@ function binsOnPath(name) {
|
|
|
31
31
|
}
|
|
32
32
|
return out;
|
|
33
33
|
}
|
|
34
|
+
function npmGlobalRoot() {
|
|
35
|
+
try {
|
|
36
|
+
let command = "npm";
|
|
37
|
+
let args = ["root", "-g"];
|
|
38
|
+
if (process.platform === "win32") {
|
|
39
|
+
const cli = join(dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
|
|
40
|
+
if (!existsSync(cli)) return null;
|
|
41
|
+
command = process.execPath;
|
|
42
|
+
args = [cli, "root", "-g"];
|
|
43
|
+
}
|
|
44
|
+
const r = spawnSync(command, args, { encoding: "utf8", timeout: 8e3, cwd: homedir() });
|
|
45
|
+
return r.status === 0 && r.stdout.trim() ? r.stdout.trim() : null;
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
34
50
|
function candidateNodeModulesDirs({ spawnNpm = false } = {}) {
|
|
35
51
|
const dirs = /* @__PURE__ */ new Set();
|
|
36
52
|
const explicit = process.env["PI_RESEARCH_HOST_DIR"];
|
|
@@ -45,19 +61,20 @@ function candidateNodeModulesDirs({ spawnNpm = false } = {}) {
|
|
|
45
61
|
} catch {
|
|
46
62
|
}
|
|
47
63
|
}
|
|
64
|
+
try {
|
|
65
|
+
const agentDir = process.env["PI_CODING_AGENT_DIR"] || join(homedir(), ".pi", "agent");
|
|
66
|
+
const current = readFileSync(join(agentDir, "install", "current-version"), "utf8").trim();
|
|
67
|
+
if (/^[A-Za-z0-9._+-]+$/.test(current) && current !== "." && current !== "..") {
|
|
68
|
+
dirs.add(join(agentDir, "install", "releases", current, "node_modules"));
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
48
72
|
dirs.add(join(dirname(process.execPath), "..", "lib", "node_modules"));
|
|
49
73
|
dirs.add(join(dirname(process.execPath), "node_modules"));
|
|
50
74
|
dirs.add(join(homedir(), ".bun", "install", "global", "node_modules"));
|
|
51
75
|
if (spawnNpm) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
encoding: "utf8",
|
|
55
|
-
timeout: 8e3,
|
|
56
|
-
shell: process.platform === "win32"
|
|
57
|
-
});
|
|
58
|
-
if (r.status === 0 && r.stdout.trim()) dirs.add(r.stdout.trim());
|
|
59
|
-
} catch {
|
|
60
|
-
}
|
|
76
|
+
const root = npmGlobalRoot();
|
|
77
|
+
if (root) dirs.add(root);
|
|
61
78
|
}
|
|
62
79
|
return [...dirs];
|
|
63
80
|
}
|
|
@@ -183,7 +200,7 @@ function packageAnchorFor(binPath) {
|
|
|
183
200
|
}
|
|
184
201
|
function engineFromPackageDir(pkgDir) {
|
|
185
202
|
try {
|
|
186
|
-
const pkg = JSON.parse(
|
|
203
|
+
const pkg = JSON.parse(readFileSync2(join2(pkgDir, "package.json"), "utf-8"));
|
|
187
204
|
const binField = typeof pkg?.bin === "string" ? pkg.bin : pkg?.bin?.["pi-research"];
|
|
188
205
|
if (binField) {
|
|
189
206
|
const binPath = join2(pkgDir, binField);
|
|
@@ -280,7 +297,7 @@ function resolveWinShimToNode(shimPath) {
|
|
|
280
297
|
const fromLayout = engineFromPackageDir(join2(dirname2(shimPath), "node_modules", ...PKG.split("/")));
|
|
281
298
|
if (fromLayout && fromLayout.argv[0] === process.execPath) return fromLayout;
|
|
282
299
|
try {
|
|
283
|
-
const content =
|
|
300
|
+
const content = readFileSync2(shimPath, "utf-8");
|
|
284
301
|
const m = content.match(/node_modules[\\/][^"\r\n]*?\.(?:mjs|cjs|js)\b/i);
|
|
285
302
|
if (m) {
|
|
286
303
|
const abs = resolve(dirname2(shimPath), m[0]);
|
package/dist/host-roots.mjs
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* into the agent-skill launcher.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { existsSync, realpathSync } from 'node:fs';
|
|
20
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
21
21
|
import { homedir } from 'node:os';
|
|
22
|
-
import { delimiter, dirname, join } from 'node:path';
|
|
22
|
+
import { delimiter, dirname, isAbsolute, join } from 'node:path';
|
|
23
23
|
import { spawnSync } from 'node:child_process';
|
|
24
24
|
|
|
25
25
|
/** The peer dependencies the engine imports at startup. */
|
|
@@ -36,7 +36,9 @@ function binsOnPath(name) {
|
|
|
36
36
|
const exts = process.platform === 'win32' ? (process.env['PATHEXT'] ?? '.EXE;.CMD').split(';') : [''];
|
|
37
37
|
const out = [];
|
|
38
38
|
for (const dir of (process.env['PATH'] ?? '').split(delimiter)) {
|
|
39
|
-
|
|
39
|
+
// Absolute entries only: a relative one (`node_modules/.bin`, `.`) resolves against the
|
|
40
|
+
// cwd, and a hostile checkout could plant a `pi` there that leads to ITS node_modules.
|
|
41
|
+
if (!dir || !isAbsolute(dir)) continue;
|
|
40
42
|
for (const ext of exts) {
|
|
41
43
|
const candidate = join(dir, name + ext);
|
|
42
44
|
if (existsSync(candidate)) out.push(candidate);
|
|
@@ -45,6 +47,29 @@ function binsOnPath(name) {
|
|
|
45
47
|
return out;
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
/**
|
|
51
|
+
* `npm root -g`, run from the home directory — never the cwd, which may be an untrusted
|
|
52
|
+
* checkout. On Windows npm is a .cmd shim, and running it through cmd.exe would search the
|
|
53
|
+
* cwd first (a planted npm.cmd would run); instead run npm's own script with the Node that is
|
|
54
|
+
* already running us, no shell involved.
|
|
55
|
+
*/
|
|
56
|
+
function npmGlobalRoot() {
|
|
57
|
+
try {
|
|
58
|
+
let command = 'npm';
|
|
59
|
+
let args = ['root', '-g'];
|
|
60
|
+
if (process.platform === 'win32') {
|
|
61
|
+
const cli = join(dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js');
|
|
62
|
+
if (!existsSync(cli)) return null;
|
|
63
|
+
command = process.execPath;
|
|
64
|
+
args = [cli, 'root', '-g'];
|
|
65
|
+
}
|
|
66
|
+
const r = spawnSync(command, args, { encoding: 'utf8', timeout: 8000, cwd: homedir() });
|
|
67
|
+
return r.status === 0 && r.stdout.trim() ? r.stdout.trim() : null;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
48
73
|
/**
|
|
49
74
|
* node_modules directories that may hold the host's packages, most specific first.
|
|
50
75
|
* `spawnNpm` additionally asks npm for its global root (a process spawn, so it is only
|
|
@@ -66,21 +91,25 @@ export function candidateNodeModulesDirs({ spawnNpm = false } = {}) {
|
|
|
66
91
|
/* dangling link: skip */
|
|
67
92
|
}
|
|
68
93
|
}
|
|
94
|
+
// pi's own managed install (pi 1.x): ~/.pi/agent/install/releases/<current-version>/node_modules.
|
|
95
|
+
// The `pi` on PATH is then a shell script, not a link into node_modules, so the lookup above
|
|
96
|
+
// cannot see it.
|
|
97
|
+
try {
|
|
98
|
+
const agentDir = process.env['PI_CODING_AGENT_DIR'] || join(homedir(), '.pi', 'agent');
|
|
99
|
+
const current = readFileSync(join(agentDir, 'install', 'current-version'), 'utf8').trim();
|
|
100
|
+
if (/^[A-Za-z0-9._+-]+$/.test(current) && current !== '.' && current !== '..') {
|
|
101
|
+
dirs.add(join(agentDir, 'install', 'releases', current, 'node_modules'));
|
|
102
|
+
}
|
|
103
|
+
} catch {
|
|
104
|
+
/* no managed install */
|
|
105
|
+
}
|
|
69
106
|
// The global root of the Node that is running us, without spawning npm.
|
|
70
107
|
dirs.add(join(dirname(process.execPath), '..', 'lib', 'node_modules'));
|
|
71
108
|
dirs.add(join(dirname(process.execPath), 'node_modules'));
|
|
72
109
|
dirs.add(join(homedir(), '.bun', 'install', 'global', 'node_modules'));
|
|
73
110
|
if (spawnNpm) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
encoding: 'utf8',
|
|
77
|
-
timeout: 8000,
|
|
78
|
-
shell: process.platform === 'win32',
|
|
79
|
-
});
|
|
80
|
-
if (r.status === 0 && r.stdout.trim()) dirs.add(r.stdout.trim());
|
|
81
|
-
} catch {
|
|
82
|
-
/* npm not on PATH */
|
|
83
|
-
}
|
|
111
|
+
const root = npmGlobalRoot();
|
|
112
|
+
if (root) dirs.add(root);
|
|
84
113
|
}
|
|
85
114
|
return [...dirs];
|
|
86
115
|
}
|
package/docs/AGENT-SKILL.md
CHANGED
|
@@ -21,21 +21,13 @@ npm install -g @lincoln504/pi-research # the engine (puts `pi-research` on PAT
|
|
|
21
21
|
pi-research skill install # link the skill into every detected agent
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
prebuilt binaries, and the stealth browser self-provisions on its first use (the first
|
|
27
|
-
scrape takes a few minutes). On npm 10 through 11.19 the `postinstall` fetch runs
|
|
28
|
-
during install instead; that is the npm bundled with Node 24/25 (11.19.0) and with
|
|
29
|
-
the Node 22.22.2 floor (10.9.7). No approval is required (see the [README](../README.md#install)).
|
|
30
|
-
|
|
31
|
-
The global install also brings the `@earendil-works/pi-*` host packages in as peer
|
|
32
|
-
dependencies (npm ≥7 resolves them). If your install skips peers
|
|
33
|
-
(`--legacy-peer-deps`, yarn classic), the engine cannot import its model registry —
|
|
34
|
-
the launcher says so and exits 78. Add the package it needs directly:
|
|
24
|
+
The stealth browser (about 1 GB) downloads once, at install or on the first scrape depending
|
|
25
|
+
on your npm version; nothing needs approving (see [Troubleshooting](TROUBLESHOOTING.md#the-first-scrape-takes-minutes-or-install-downloads-over-a-gigabyte)).
|
|
35
26
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
The `@earendil-works/pi-*` host packages and `typebox` are peer dependencies. A global install
|
|
28
|
+
brings them in; an install that skips peers (`pi install`, `--legacy-peer-deps`, yarn classic) has the
|
|
29
|
+
launcher look for pi's own copies, and if it finds none it exits 78 naming the fix. See
|
|
30
|
+
[Troubleshooting](TROUBLESHOOTING.md#the-agent-skill-or-cli-says-cannot-start--missing-required-runtime-dependencies).
|
|
39
31
|
|
|
40
32
|
`skill install` targets only agents already set up under `$HOME`, never overwrites a
|
|
41
33
|
different skill in the slot, and records what it created so `pi-research skill uninstall`
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -26,7 +26,7 @@ pi CLI
|
|
|
26
26
|
task's complexity, guided by the tool's usage prompt (`src/prompts/research-tool-usage.md`).
|
|
27
27
|
CLI and SDK callers pass the depth explicitly.
|
|
28
28
|
2. Depth 0 takes the quick path; depth 1–3 takes the deep path (below). The pi extension's
|
|
29
|
-
tool and the TUI
|
|
29
|
+
tool and the TUI offer levels 1–3 unless `PI_RESEARCH_QUICK_RESEARCH=true` opts in to depth 0; the CLI, SDK, and agent skill can pass 0 (the CLI gates it on the same setting).
|
|
30
30
|
3. On the deep path the coordinator plans the research tracks and runs one initial
|
|
31
31
|
search burst, then hands each researcher a set of result URLs to start from.
|
|
32
32
|
4. Researchers scrape and read those pages through the scrape tooling and return cited
|
|
@@ -44,9 +44,9 @@ point. It dispatches on depth.
|
|
|
44
44
|
|
|
45
45
|
Depth 0 — quick (`QuickResearchOrchestrator`): a single researcher runs directly with
|
|
46
46
|
all tools; there is no coordinator, no planning phase, and no rounds. Depth 0 is
|
|
47
|
-
reachable
|
|
48
|
-
agent skill can pass). The pi extension's `research` tool has a minimum depth of 1
|
|
49
|
-
an in-session agent
|
|
47
|
+
reachable through the SDK (`runQuickResearch`) or the CLI (`--depth 0`, which the
|
|
48
|
+
agent skill can pass). The pi extension's `research` tool has a minimum depth of 1 unless
|
|
49
|
+
`PI_RESEARCH_QUICK_RESEARCH=true`, so an in-session agent cannot request quick mode by default.
|
|
50
50
|
|
|
51
51
|
Depth 1–3 — deep (`DeepResearchOrchestrator`): the run proceeds in **rounds**. A round
|
|
52
52
|
is one coordinate → research → route cycle — the round's agenda is planned (by the
|
|
@@ -321,7 +321,8 @@ why floating ranges are not trusted here. Rationale in full:
|
|
|
321
321
|
`src/infrastructure/browser/thread-worker-browser.ts`.
|
|
322
322
|
|
|
323
323
|
The launcher replacement (2026-10-05). `camoufox-js` `0.12.0` was replaced by
|
|
324
|
-
`@camoufox/camoufox` `0.5.7` after the former broke every fresh install
|
|
324
|
+
`@camoufox/camoufox` `0.5.7` after the former broke every fresh install; that package was
|
|
325
|
+
later renamed on npm, and the launcher is now `camoufox` `0.5.8`. On 2026-10-03
|
|
325
326
|
`v156.0.1-beta.34` was published to the `daijro/camoufox` releases WITHOUT the prerelease
|
|
326
327
|
flag, and the 156-series browser schema had dropped `navigator.product` (with
|
|
327
328
|
`appName`/`appCodeName`). `camoufox-js` `0.12.0` still sent those properties, and its
|
|
@@ -390,7 +391,7 @@ Validation library — `typebox` (TypeBox 1.x, unscoped package name) is a PEER
|
|
|
390
391
|
warns on every startup when a host-provided package (`typebox`, `@sinclair/typebox`, the
|
|
391
392
|
`@earendil-works/pi-*` packages) sits in `dependencies`, because an installed copy can bypass the
|
|
392
393
|
loader and create a second live module instance (`resource-loader.js`,
|
|
393
|
-
`collectExtensionPackageWarnings`;
|
|
394
|
+
`collectExtensionPackageWarnings`; `docs/packages.md` in the pi repository). Under pi the host's own copy is used,
|
|
394
395
|
so the two agree on `Value.Check`/`Convert` by construction. `@earendil-works/pi-ai` and
|
|
395
396
|
`@earendil-works/pi-coding-agent` 1.0.0 through 1.4.0 all pin `1.3.27` (re-checked 2026-10-21 in
|
|
396
397
|
the published 1.4.0 packages' `package.json`, previously 2026-10-17 in 1.3.0), which is why the devDependency, and so every test run and
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,40 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.7.21] - 2026-10-24
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **CodeQL `js/file-system-race` (CWE-367) in the LanceDB prepack script.** `scripts/prepack-lancedb.cjs` gated its two `fs.writeFileSync` calls on `node_modules/@lancedb/lancedb/package.json` with conditions derived from that file's own on-disk state (check-then-write). The transform is a fixed point (running it twice yields identical bytes), so the write is now unconditional and the absence checks are folded into the reads' error handling. Behavior is unchanged: idempotent, identical shipped manifest, identical fail gates.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **impit 0.14.6 to 0.14.7.** 0.14.7 bumps apify/rustls to verify ML-DSA signatures with rustls-webpki's real verifiers instead of an Ed25519 placeholder (apify/impit#574). Patch bump within camoufox 0.5.8's `^0.14.1` range.
|
|
17
|
+
|
|
18
|
+
### Documentation
|
|
19
|
+
|
|
20
|
+
- **Tightened the README.** Uninstall is one causal line, the pi requirement drops a developer-facing detail (the tested-ceiling file reference), the knowledge-store bullet splits into the transformers fallback and the BM25 opt-out, and a use-case item redundant with "Why" is removed.
|
|
21
|
+
|
|
22
|
+
## [1.7.20] - 2026-10-23
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **The host-package lookup finds pi 1.x's managed install.** On a real machine (a user's `~/.local/bin/pi` is a shell script that runs `~/.pi/agent/install/releases/<version>/node_modules/.bin/pi`) nothing was found, so the agent skill and CLI still stopped with "missing required runtime dependencies" after 1.7.19 although pi's own copies were on disk. `src/host-roots.mjs` now also searches `<agent dir>/install/releases/<current-version>/node_modules` (`~/.pi/agent`, or `PI_CODING_AGENT_DIR`); the version string is validated so it cannot point outside the releases directory.
|
|
27
|
+
|
|
28
|
+
### Security
|
|
29
|
+
|
|
30
|
+
- **Hardening of that lookup, from review of 1.7.19.** Relative `PATH` entries are ignored (a `pi` planted at `./node_modules/.bin/pi` in an untrusted checkout could nominate that checkout's `node_modules`); `npm root -g` runs from the home directory instead of the current directory; on Windows it runs `npm-cli.js` with the running Node, with no shell, so a planted `npm.cmd` in the current directory can no longer be executed by cmd.exe's current-directory-first search.
|
|
31
|
+
|
|
32
|
+
### CI
|
|
33
|
+
|
|
34
|
+
- **`scripts/bare-imports.cjs` sees minified `import{a}from"x"`, `import"x"` and `require("x")` forms**, not only whitespace-separated `import ... from "x"` (a build with minification would have slipped past the gate). Specifiers must look like package names, so string fragments no longer match.
|
|
35
|
+
|
|
36
|
+
### Documentation
|
|
37
|
+
|
|
38
|
+
- **New `docs/TROUBLESHOOTING.md`** holds what used to be spread over the README and three other docs: the worker-start failure of 1.7.9-1.7.18, a `pi update` that errors because of a malformed source, the host-package lookup order and its fixes, the one-time browser download, and the old `sharp` audit finding. The README keeps one line and a link for each (10.2 KB to 6.9 KB), drops audit and install-script history, no longer says the standalone CLI "installs it as a dependency" (the host packages are peers), and mentions quick mode (depth 0).
|
|
39
|
+
- **Corrected:** `docs/ARCHITECTURE.md` said an in-session agent can never request quick mode and named the replaced `@camoufox/camoufox` launcher as current; `SECURITY.md` described a consumer override as still needed; `docs/PI-EXTENSION.md` omitted depth 0; `docs/SDK.md` and `docs/AGENT-SKILL.md` named one peer where four are needed and carried changelog narrative; `docs/CONFIGURATION.md` and `.env.example` now list `PI_RESEARCH_HOST_DIR` and `PI_RESEARCH_NO_HOST_FALLBACK` and no longer call `.env.example` exhaustive.
|
|
40
|
+
- **The ES, JA and ZH documents** had in-page links to anchors GitHub does not create (`{#id}` heading suffixes) and carried the stale `approve-scripts`/`better-sqlite3` and one-peer install text; the suffixes are gone, the links point at the real headings, and the install text matches the English docs.
|
|
41
|
+
|
|
8
42
|
## [1.7.19] - 2026-10-23
|
|
9
43
|
|
|
10
44
|
### Fixed
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -58,7 +58,7 @@ CPU/RAM-sensitive and set only via `PI_RESEARCH_WORKER_THREADS`.
|
|
|
58
58
|
|
|
59
59
|
Every setting is also an environment variable. The repo's
|
|
60
60
|
[`.env.example`](https://github.com/Lincoln504/pi-research/blob/main/.env.example)
|
|
61
|
-
is
|
|
61
|
+
is a commented template with inline notes; this section is the reference, grouping the
|
|
62
62
|
variables with their defaults and valid ranges.
|
|
63
63
|
Out-of-range numeric values are clamped (with a warning); an invalid enum value
|
|
64
64
|
falls back to the default (with a warning).
|
|
@@ -75,12 +75,12 @@ Research
|
|
|
75
75
|
| `PI_RESEARCH_MAX_RESEARCHERS` (TUI) | `3` | 1–5 | Parallel researchers. |
|
|
76
76
|
| `PI_RESEARCH_DEFAULT_RESEARCH_DEPTH` (TUI) `[project]` | `1` | 0–3 | Depth for `/research` and the CLI when `--depth` is omitted (0=quick single-pass — requires `PI_RESEARCH_QUICK_RESEARCH` —, 1=normal, 2=deep, 3=ultra). The agent-facing `research` tool-usage prompt renders its depth guidance relative to this setting too: when quick is the configured default, depth 0 is the ordinary choice; a user who keeps the default (1) gets byte-identical guidance. |
|
|
77
77
|
| `PI_RESEARCH_QUICK_RESEARCH` (TUI) `[project]` | `false` | `true` · `false` | Opt-in gate for depth-0 (quick) research. When `false` (default), the agent-facing `research` tool keeps its upstream `minimum: 1` schema — agents can neither see nor send depth 0 — and a `DEFAULT_RESEARCH_DEPTH` of 0 resolves to 1. Toggling applies on the next session. |
|
|
78
|
-
| `PI_RESEARCH_QUICK_MAX_QUERIES` | `3` | 1–10 | Max queries per `search` call in quick (depth 0) research. Applies to every quick run — the pi extension tool, the CLI, and the SDK's `--depth 0` — since they share the same researcher session factory. Deliberately below deep research's 30-query cap; the ceiling
|
|
78
|
+
| `PI_RESEARCH_QUICK_MAX_QUERIES` | `3` | 1–10 | Max queries per `search` call in quick (depth 0) research. Applies to every quick run — the pi extension tool, the CLI, and the SDK's `--depth 0` — since they share the same researcher session factory. Deliberately below deep research's 30-query cap; the ceiling is 10. |
|
|
79
79
|
| `PI_RESEARCH_QUICK_MAX_SCRAPE_URLS` | `5` | 1–20 | Max URLs fetched per scrape batch in quick (depth 0) research. Separate from `PI_RESEARCH_MAX_SCRAPE_URLS` (deep, `8`) because quick mode answers a single-fact question and the deep budget pulls in pages that question does not need; `PI_RESEARCH_MAX_SCRAPE_BATCHES` still caps how many batches a quick run may use. Applies to every quick run (pi extension tool, CLI, SDK `--depth 0`). |
|
|
80
80
|
| `PI_RESEARCH_MAX_SCRAPE_BATCHES` (TUI) | `2` | 0–99 | Scrape batches per researcher (0 = unlimited). When prompt caching is known to be active for the resolved research model (Anthropic API models, or a provider route explicitly configured for Anthropic-style cache control), the effective limit is this value plus one — the cached prompt prefix makes the extra batch cheap. |
|
|
81
81
|
| `PI_RESEARCH_MAX_GATHERING_CALLS` | `12` | 1–100 | Shared web-gathering calls per researcher (`search` + `security_search` + `stackexchange` + `youtube_transcript`). |
|
|
82
82
|
| `PI_RESEARCH_MAX_CONCURRENT_SCRAPES` | `3` | 1–20 | Concurrent URLs fetched per scrape batch. |
|
|
83
|
-
| `PI_RESEARCH_MAX_SCRAPE_URLS` | `8` | 1–20 | Maximum URLs fetched per scrape batch. URLs past the cap are listed under "Not Fetched — Over Batch Cap" and must be requested in a later batch.
|
|
83
|
+
| `PI_RESEARCH_MAX_SCRAPE_URLS` | `8` | 1–20 | Maximum URLs fetched per scrape batch. URLs past the cap are listed under "Not Fetched — Over Batch Cap" and must be requested in a later batch. |
|
|
84
84
|
| `PI_RESEARCH_SCRAPE_SECOND_PAGE` | `false` | true/false | Also fetch DuckDuckGo results page 2 for every search query, roughly doubling the candidate links each query contributes. Each query's page-2 fetch degrades gracefully — if page 2 fails or does not exist, the page-1 results are kept. |
|
|
85
85
|
| `PI_RESEARCH_MAX_RETRIES` | `2` | 0–5 | Retries per researcher request. |
|
|
86
86
|
| `PI_RESEARCH_RETRY_DELAY_MS` | `2000` | 100–10000 | Base delay between retries. |
|
|
@@ -164,7 +164,9 @@ Diagnostics & platform
|
|
|
164
164
|
| `PI_RESEARCH_STATE_DIR` | `~/.pi/research/state` | Override the state directory (active sessions, browser status, project registry). |
|
|
165
165
|
| `PI_RESEARCH_TUI_REFRESH_DEBOUNCE_MS` | `100` | TUI refresh debounce (0–1000 ms). |
|
|
166
166
|
| `PI_RESEARCH_SKIP_HEALTHCHECK` | _(unset)_ | Set `1`/`true` to skip the pre-flight browser/embedding health check and rely on per-task timeouts. **Depth 0 (quick) only** — depth 1-3 runs have no such pre-flight check, so this has no effect on them. |
|
|
167
|
-
| `
|
|
167
|
+
| `PI_RESEARCH_HOST_DIR` | _(unset)_ | A `node_modules` directory (or its parent) holding pi's copies of the peer dependencies (`@earendil-works/pi-*`, `typebox`). Searched first when the standalone engine cannot find them beside itself. See [Troubleshooting](TROUBLESHOOTING.md#the-agent-skill-or-cli-says-cannot-start--missing-required-runtime-dependencies). |
|
|
168
|
+
| `PI_RESEARCH_NO_HOST_FALLBACK` | _(unset)_ | Set `1` to turn the host-package lookup off and require peers installed beside the engine. |
|
|
169
|
+
| `PI_RESEARCH_PDF_WORKER` | _(unset)_ | Set `off` to force PDF parsing onto the main thread (in-process, no worker), bypassing the worker-threads offload. Kill-switch for worker or bundling issues; the default runs the parse in a worker when its bundle is present. |
|
|
168
170
|
| `PI_RESEARCH_USE_XVFB` | _(unset)_ | Linux only. Bare-TTY runs are true-headless and need no X server; set `true` to opt into a virtual framebuffer (`sudo apt install xvfb`). |
|
|
169
171
|
| `PI_RESEARCH_SKILL_DIR` | _(auto)_ | Override the bundled research-skill source directory used by the skill installer. |
|
|
170
172
|
| `PI_RESEARCH_PURGE_BROWSERS` | _(unset)_ | Read by the bundled `scripts/cleanup.cjs`: set `1` to also delete the shared camoufox browser cache (kept by default because other installs may use it). Note npm ≥7 does not run `preuninstall`, so that script does not fire on `npm uninstall` — see [AGENT-SKILL.md](AGENT-SKILL.md). |
|
package/docs/PI-EXTENSION.md
CHANGED
|
@@ -7,7 +7,7 @@ TUI registered directly in the pi process.
|
|
|
7
7
|
### Usage
|
|
8
8
|
|
|
9
9
|
The `research` tool is auto-registered, so the model invokes it
|
|
10
|
-
from natural language, and the tool understands the depth needed (1–3) from the query.
|
|
10
|
+
from natural language, and the tool understands the depth needed (1–3, or 0 when quick mode is enabled) from the query.
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
13
|
pi -p "research the latest developments in WebAssembly"
|
package/docs/SDK.md
CHANGED
|
@@ -13,24 +13,12 @@ run the `pi` extension, which keeps its own private copy your scripts can't impo
|
|
|
13
13
|
npm install @lincoln504/pi-research
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
The `@earendil-works/pi-*` host packages are peer dependencies, so npm ≥7 installs them
|
|
17
|
-
with the command above. If your install skips peers
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
npm
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
npm 12, the current npm, blocks dependency install scripts by default. Nothing
|
|
25
|
-
here needs them: the only native piece on the launch path is `impit`, which ships
|
|
26
|
-
prebuilt binaries, and the stealth browser self-provisions on its first use. On npm 10
|
|
27
|
-
through 11.19 the `postinstall` fetch runs during install instead; that is the npm
|
|
28
|
-
bundled with Node 24/25 (11.19.0) and with the Node 22.22.2 floor (10.9.7). (The
|
|
29
|
-
`npm approve-scripts better-sqlite3` + `npm rebuild` pair documented by earlier
|
|
30
|
-
releases repaired the old `camoufox-js` launcher, whose `better-sqlite3` binding came
|
|
31
|
-
from an install script — the 2026-10-05 move to `@camoufox/camoufox` removed that
|
|
32
|
-
dependency entirely, and on npm 12.0.2 an approval does not make a skipped script run
|
|
33
|
-
anyway.)
|
|
16
|
+
The `@earendil-works/pi-*` host packages and `typebox` are peer dependencies, so npm ≥7 installs them
|
|
17
|
+
with the command above. If your install skips peers (`--legacy-peer-deps`, yarn classic), add the
|
|
18
|
+
four it needs (`@earendil-works/pi-ai`, `@earendil-works/pi-coding-agent`, `@earendil-works/pi-tui`,
|
|
19
|
+
`typebox`) or see [Troubleshooting](TROUBLESHOOTING.md#the-agent-skill-or-cli-says-cannot-start--missing-required-runtime-dependencies).
|
|
20
|
+
The stealth browser (about 1 GB) downloads once, at install or on the first scrape depending on your
|
|
21
|
+
npm version ([details](TROUBLESHOOTING.md#the-first-scrape-takes-minutes-or-install-downloads-over-a-gigabyte)).
|
|
34
22
|
|
|
35
23
|
Then pick the model: pass `model` to `initResearchSDK`, or set `PI_RESEARCH_MODEL`
|
|
36
24
|
(env or `~/.pi/research/config.env`). The SDK never follows the model selected
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
## Searches fail with "Worker exited before completing the task"
|
|
4
|
+
|
|
5
|
+
Releases **1.7.9 through 1.7.18** broke every search for installs made with `pi install`: the
|
|
6
|
+
browser worker imported a package that `pi install` never installs, so each worker exited at
|
|
7
|
+
start-up. Update to **1.7.19 or newer**:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi update npm:@lincoln504/pi-research
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then restart open pi sessions; a running session keeps the code it already loaded. To see which
|
|
14
|
+
version is installed, read `~/.pi/agent/npm/node_modules/@lincoln504/pi-research/package.json`.
|
|
15
|
+
|
|
16
|
+
For any other failure, set `PI_RESEARCH_DEBUG=true` and read the debug log (`$TMPDIR/pi-research.log`,
|
|
17
|
+
or `PI_RESEARCH_LOG_PATH`). Repeated `Worker exited with code 1` lines mean the browser worker is not
|
|
18
|
+
starting; the first error above the first exit says why. See [Configuration](CONFIGURATION.md#where-files-live).
|
|
19
|
+
|
|
20
|
+
## `pi update` prints errors for this extension
|
|
21
|
+
|
|
22
|
+
Check `~/.pi/agent/settings.json` (or run `pi list`) for a source spelled
|
|
23
|
+
`npm:lincoln504/pi-research`, without the `@`. npm reads `lincoln504/pi-research` as a GitHub
|
|
24
|
+
`user/repo`, so pi installs the repository's main branch instead of the published release (building
|
|
25
|
+
it, and registering the extension a second time). Remove the wrong entry and keep the right one:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pi remove npm:lincoln504/pi-research
|
|
29
|
+
pi list # should show npm:@lincoln504/pi-research once
|
|
30
|
+
pi update npm:@lincoln504/pi-research
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
A source with a version (`npm:@lincoln504/pi-research@1.7.9`) is pinned and never updates; remove and
|
|
34
|
+
reinstall it to move versions. A bare `pi update` updates pi itself; use `pi update --extensions` for
|
|
35
|
+
every extension or name the source for just this one.
|
|
36
|
+
|
|
37
|
+
## The agent skill or CLI says "cannot start — missing required runtime dependencies"
|
|
38
|
+
|
|
39
|
+
The `@earendil-works/pi-*` packages and `typebox` are **peer dependencies**. Inside pi nothing is
|
|
40
|
+
needed: pi supplies them to the extension. The standalone engine (the CLI, the agent skill and the
|
|
41
|
+
SDK) runs as a plain Node process, and an install that skips peers (`pi install` always does, as do
|
|
42
|
+
`npm install --legacy-peer-deps`, yarn classic and pnpm with `auto-install-peers=false`) has none
|
|
43
|
+
beside it.
|
|
44
|
+
|
|
45
|
+
The engine looks for pi's own copies, in this order, and uses them when it finds them:
|
|
46
|
+
|
|
47
|
+
1. the directory named by `PI_RESEARCH_HOST_DIR` (a `node_modules` directory, or its parent)
|
|
48
|
+
2. the directory behind the `pi` command on `PATH` (absolute `PATH` entries only)
|
|
49
|
+
3. pi's managed install, `<agent dir>/install/releases/<current version>/node_modules`
|
|
50
|
+
(`~/.pi/agent` unless `PI_CODING_AGENT_DIR` is set)
|
|
51
|
+
4. the global npm root of the Node that is running, bun's global root, then `npm root -g`
|
|
52
|
+
|
|
53
|
+
`PI_RESEARCH_NO_HOST_FALLBACK=1` turns the lookup off. If nothing is found, the message names the
|
|
54
|
+
missing packages and these fixes; any one is enough:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# into the tree pi-research is installed in (for pi: ~/.pi/agent/npm); kept across `pi update`
|
|
58
|
+
npm install --prefix ~/.pi/agent/npm --legacy-peer-deps @earendil-works/pi-ai @earendil-works/pi-coding-agent @earendil-works/pi-tui typebox
|
|
59
|
+
# or globally; a global install is found automatically
|
|
60
|
+
npm install -g @earendil-works/pi-coding-agent
|
|
61
|
+
# or a standalone engine that brings its peers in with it
|
|
62
|
+
npm install -g @lincoln504/pi-research
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## The first scrape takes minutes, or install downloads over a gigabyte
|
|
66
|
+
|
|
67
|
+
The stealth browser (about 1 GB installed) is fetched by the `postinstall` script on npm 10 through
|
|
68
|
+
11.19, which includes the npm bundled with the Node 22.22.2 floor (10.9.7) and with Node 24/25
|
|
69
|
+
(11.19.0). npm 12 blocks dependency install scripts by default, so there the browser is fetched on the
|
|
70
|
+
first scrape instead. Either way it is a one-time download. Set `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1`
|
|
71
|
+
to defer it deliberately.
|
|
72
|
+
|
|
73
|
+
## `npm audit` reports a high-severity `sharp` chain under `@lancedb/lancedb`
|
|
74
|
+
|
|
75
|
+
This affects releases before **1.7.18** only. LanceDB pins an old `@huggingface/transformers` as an
|
|
76
|
+
optional dependency and npm ignores a dependency's `overrides`. From 1.7.18 the package ships LanceDB
|
|
77
|
+
bundled with those optional edges removed, so nothing needs overriding; update instead. On an older
|
|
78
|
+
release the consumer-side override is in [AUDIT-GATE.md](AUDIT-GATE.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincoln504/pi-research",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.21",
|
|
4
4
|
"description": "Web research for your agents with smart and safe tooling + knowledge store",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"docs/CONFIGURATION.md",
|
|
35
35
|
"docs/KNOWLEDGE-STORE.md",
|
|
36
36
|
"docs/AGENT-SKILL.md",
|
|
37
|
+
"docs/TROUBLESHOOTING.md",
|
|
37
38
|
"docs/ARCHITECTURE.md",
|
|
38
39
|
"scripts/setup.cjs",
|
|
39
40
|
"scripts/cleanup.cjs",
|
|
@@ -130,7 +131,7 @@
|
|
|
130
131
|
"bgutils-js": "^4.0.3",
|
|
131
132
|
"camoufox": "0.5.8",
|
|
132
133
|
"esbuild": "^0.28.2",
|
|
133
|
-
"impit": "0.14.
|
|
134
|
+
"impit": "0.14.7",
|
|
134
135
|
"jsdom": "^30.1.0",
|
|
135
136
|
"node-html-markdown": "^2.0.0",
|
|
136
137
|
"pdf-oxide-wasm": "^0.3.77",
|
package/scripts/bare-imports.cjs
CHANGED
|
@@ -27,14 +27,27 @@ function packageName(spec) {
|
|
|
27
27
|
return spec.startsWith('@') ? spec.split('/').slice(0, 2).join('/') : spec.split('/')[0];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Bare package names a bundle imports, in every form esbuild emits or a hand-written file may
|
|
32
|
+
* use: `import x from "p"` / `import{x}from"p"` (minified, no whitespace), `import "p"`,
|
|
33
|
+
* `export … from "p"`, `import("p")` and `require("p")` / `createRequire(...)("p")`.
|
|
34
|
+
* Text that merely MENTIONS an import inside a string is matched too; that fails closed (a
|
|
35
|
+
* false alarm to look at, never a missed import).
|
|
36
|
+
*/
|
|
31
37
|
function bareImports(source) {
|
|
32
38
|
const out = new Set();
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const patterns = [
|
|
40
|
+
/\bfrom\s*["']([@A-Za-z0-9_][^"'\s]*)["']/g,
|
|
41
|
+
/\bimport\s*["']([@A-Za-z0-9_][^"'\s]*)["']/g,
|
|
42
|
+
/\bimport\s*\(\s*["']([@A-Za-z0-9_][^"'\s]*)["']\s*\)/g,
|
|
43
|
+
/\brequire\s*\(\s*["']([@A-Za-z0-9_][^"'\s]*)["']\s*\)/g,
|
|
44
|
+
];
|
|
45
|
+
for (const re of patterns) {
|
|
46
|
+
for (const m of source.matchAll(re)) {
|
|
47
|
+
const spec = m[1];
|
|
48
|
+
if (spec.startsWith('node:') || builtinModules.includes(spec.split('/')[0])) continue;
|
|
49
|
+
out.add(packageName(spec));
|
|
50
|
+
}
|
|
38
51
|
}
|
|
39
52
|
return out;
|
|
40
53
|
}
|
package/src/host-roots.mjs
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* into the agent-skill launcher.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { existsSync, realpathSync } from 'node:fs';
|
|
20
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
21
21
|
import { homedir } from 'node:os';
|
|
22
|
-
import { delimiter, dirname, join } from 'node:path';
|
|
22
|
+
import { delimiter, dirname, isAbsolute, join } from 'node:path';
|
|
23
23
|
import { spawnSync } from 'node:child_process';
|
|
24
24
|
|
|
25
25
|
/** The peer dependencies the engine imports at startup. */
|
|
@@ -36,7 +36,9 @@ function binsOnPath(name) {
|
|
|
36
36
|
const exts = process.platform === 'win32' ? (process.env['PATHEXT'] ?? '.EXE;.CMD').split(';') : [''];
|
|
37
37
|
const out = [];
|
|
38
38
|
for (const dir of (process.env['PATH'] ?? '').split(delimiter)) {
|
|
39
|
-
|
|
39
|
+
// Absolute entries only: a relative one (`node_modules/.bin`, `.`) resolves against the
|
|
40
|
+
// cwd, and a hostile checkout could plant a `pi` there that leads to ITS node_modules.
|
|
41
|
+
if (!dir || !isAbsolute(dir)) continue;
|
|
40
42
|
for (const ext of exts) {
|
|
41
43
|
const candidate = join(dir, name + ext);
|
|
42
44
|
if (existsSync(candidate)) out.push(candidate);
|
|
@@ -45,6 +47,29 @@ function binsOnPath(name) {
|
|
|
45
47
|
return out;
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
/**
|
|
51
|
+
* `npm root -g`, run from the home directory — never the cwd, which may be an untrusted
|
|
52
|
+
* checkout. On Windows npm is a .cmd shim, and running it through cmd.exe would search the
|
|
53
|
+
* cwd first (a planted npm.cmd would run); instead run npm's own script with the Node that is
|
|
54
|
+
* already running us, no shell involved.
|
|
55
|
+
*/
|
|
56
|
+
function npmGlobalRoot() {
|
|
57
|
+
try {
|
|
58
|
+
let command = 'npm';
|
|
59
|
+
let args = ['root', '-g'];
|
|
60
|
+
if (process.platform === 'win32') {
|
|
61
|
+
const cli = join(dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js');
|
|
62
|
+
if (!existsSync(cli)) return null;
|
|
63
|
+
command = process.execPath;
|
|
64
|
+
args = [cli, 'root', '-g'];
|
|
65
|
+
}
|
|
66
|
+
const r = spawnSync(command, args, { encoding: 'utf8', timeout: 8000, cwd: homedir() });
|
|
67
|
+
return r.status === 0 && r.stdout.trim() ? r.stdout.trim() : null;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
48
73
|
/**
|
|
49
74
|
* node_modules directories that may hold the host's packages, most specific first.
|
|
50
75
|
* `spawnNpm` additionally asks npm for its global root (a process spawn, so it is only
|
|
@@ -66,21 +91,25 @@ export function candidateNodeModulesDirs({ spawnNpm = false } = {}) {
|
|
|
66
91
|
/* dangling link: skip */
|
|
67
92
|
}
|
|
68
93
|
}
|
|
94
|
+
// pi's own managed install (pi 1.x): ~/.pi/agent/install/releases/<current-version>/node_modules.
|
|
95
|
+
// The `pi` on PATH is then a shell script, not a link into node_modules, so the lookup above
|
|
96
|
+
// cannot see it.
|
|
97
|
+
try {
|
|
98
|
+
const agentDir = process.env['PI_CODING_AGENT_DIR'] || join(homedir(), '.pi', 'agent');
|
|
99
|
+
const current = readFileSync(join(agentDir, 'install', 'current-version'), 'utf8').trim();
|
|
100
|
+
if (/^[A-Za-z0-9._+-]+$/.test(current) && current !== '.' && current !== '..') {
|
|
101
|
+
dirs.add(join(agentDir, 'install', 'releases', current, 'node_modules'));
|
|
102
|
+
}
|
|
103
|
+
} catch {
|
|
104
|
+
/* no managed install */
|
|
105
|
+
}
|
|
69
106
|
// The global root of the Node that is running us, without spawning npm.
|
|
70
107
|
dirs.add(join(dirname(process.execPath), '..', 'lib', 'node_modules'));
|
|
71
108
|
dirs.add(join(dirname(process.execPath), 'node_modules'));
|
|
72
109
|
dirs.add(join(homedir(), '.bun', 'install', 'global', 'node_modules'));
|
|
73
110
|
if (spawnNpm) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
encoding: 'utf8',
|
|
77
|
-
timeout: 8000,
|
|
78
|
-
shell: process.platform === 'win32',
|
|
79
|
-
});
|
|
80
|
-
if (r.status === 0 && r.stdout.trim()) dirs.add(r.stdout.trim());
|
|
81
|
-
} catch {
|
|
82
|
-
/* npm not on PATH */
|
|
83
|
-
}
|
|
111
|
+
const root = npmGlobalRoot();
|
|
112
|
+
if (root) dirs.add(root);
|
|
84
113
|
}
|
|
85
114
|
return [...dirs];
|
|
86
115
|
}
|