Files
my-pi/tests/web-search.test.ts
T
云服务部-叶林立andDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> 56cbc83296 refactor: 移除 context-mode,Chrome 快照改为直接返回
context-mode 的 ctx_execute 系工具以真实 shell 执行且权限为 allow,绕过了
bash 策略与 protectedWrites;其每轮注入、独立 MCP 子进程与 skills 也与组合包
提示词单一所有权冲突。大输出职责已由 pi-overflow(入口截断)与
pi-compaction(压力遮蔽)承担:
- 删除 context-mode 依赖、wrapper/过滤器、skills,以及 ctx_* 的权限、
  tools.jsonc、路由规则、tool-search 常驻与 4 个分组
- better-sqlite3@12 仅为 context-mode 传递依赖,随之移除根 allowScripts
- pi-chrome:按用户决定移除快照隐私规则与 .pi/chrome-context 临时文件机制,
  快照 JSON 直接作为工具结果返回、details 只留小型元数据,超长由 pi-overflow
  截断并用 overflow_query 提取;授权生命周期不变

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 20:45:33 -07:00

52 lines
2.3 KiB
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
const packageJson = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8")) as {
dependencies: Record<string, string>;
files: string[];
pi: { extensions: string[]; skills?: string[] };
};
const filesIncludePackageDir = (files: string[], packageDir: string): boolean =>
files.some((entry) => entry === packageDir || entry.startsWith(`${packageDir}/`));
test("pi-web-search is the single search surface and reads credentials from auth.json", () => {
const entries = packageJson.pi.extensions;
assert.ok(entries.includes("./pi-web-search/index.ts"), "the bundle must load pi-web-search");
assert.equal(
entries.includes("./extensions/search-config.ts"),
false,
"search keys come from auth.json — the env loader extension is retired",
);
for (const retired of [
"./extensions/mcp.ts",
"./extensions/tavily-override.ts",
"./node_modules/@keenable/pi-search/src/index.ts",
]) {
assert.equal(entries.includes(retired), false, `${retired} must no longer be loaded`);
}
});
test("pi-web-search ships as a maintained file: dependency without upstream search packages", () => {
assert.equal(packageJson.dependencies["pi-web-search"], "file:./pi-web-search");
assert.ok(filesIncludePackageDir(packageJson.files, "pi-web-search"));
assert.equal(packageJson.dependencies["@tavily/pi-extension"], undefined);
assert.equal(packageJson.dependencies["@keenable/pi-search"], undefined);
assert.equal(packageJson.dependencies["pi-mcp-adapter"], undefined, "Exa is a direct client now — no MCP adapter");
});
test("no extension in the bundle loads the MCP adapter or upstream search extensions", async () => {
for (const entry of packageJson.pi.extensions.filter((e) => !e.startsWith("./node_modules/"))) {
const source = await readFile(new URL(`../${entry.slice(2)}`, import.meta.url), "utf8");
assert.equal(source.includes("pi-mcp-adapter"), false, `${entry} must not import pi-mcp-adapter`);
assert.equal(source.includes("@tavily/pi-extension"), false, `${entry} must not import @tavily/pi-extension`);
}
});
test("the keenable skill path is gone with the upstream package", () => {
for (const skillPath of packageJson.pi.skills ?? []) {
assert.equal(skillPath.includes("@keenable"), false);
}
});