mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
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>
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import {
|
|
CHROME_TOOL_NAMES,
|
|
formatActionResultText,
|
|
formatChromeFindMatches,
|
|
snapshotStats,
|
|
} from "../extensions/chrome-profile-bridge/index.ts";
|
|
|
|
test("formatActionResultText appends the inline snapshot JSON", () => {
|
|
const snapshot = { elements: [{ uid: "el-1", role: "button", label: "Save" }], matches: [] };
|
|
const text = formatActionResultText("Clicked el-1", snapshot);
|
|
const [summary, json] = text.split("\n\n");
|
|
assert.equal(summary, "Clicked el-1");
|
|
assert.deepEqual(JSON.parse(json), snapshot);
|
|
});
|
|
|
|
test("formatActionResultText returns the summary alone without a snapshot", () => {
|
|
assert.equal(formatActionResultText("Clicked el-1", undefined), "Clicked el-1");
|
|
});
|
|
|
|
test("snapshotStats stays small: only element and match counts", () => {
|
|
assert.deepEqual(
|
|
snapshotStats({ elements: [{ uid: "a" }, { uid: "b" }], matches: [{ uid: "a" }] }),
|
|
{ elementCount: 2, matchCount: 1 },
|
|
);
|
|
assert.deepEqual(snapshotStats({ elements: "nope" }), { elementCount: 0, matchCount: 0 });
|
|
assert.deepEqual(snapshotStats(undefined), { elementCount: 0, matchCount: 0 });
|
|
assert.deepEqual(snapshotStats([1, 2, 3]), { elementCount: 0, matchCount: 0 });
|
|
});
|
|
|
|
test("chrome_find formatting is capped and authorization tracks all 21 tools", () => {
|
|
const matches = Array.from({ length: 25 }, (_, index) => ({
|
|
kind: "element",
|
|
uid: `el-${index}`,
|
|
role: "button",
|
|
label: `Button ${index}`,
|
|
rect: { x: index, y: index, width: 10, height: 10 },
|
|
}));
|
|
const text = formatChromeFindMatches({ query: "button", matches });
|
|
|
|
assert.match(text, /el-0/);
|
|
assert.match(text, /el-19/);
|
|
assert.doesNotMatch(text, /el-20/);
|
|
assert.equal(CHROME_TOOL_NAMES.length, 21);
|
|
assert.ok(CHROME_TOOL_NAMES.includes("chrome_find"));
|
|
assert.ok(CHROME_TOOL_NAMES.includes("chrome_inspect"));
|
|
});
|