feat: 接入 Pi 内置 codemode,并修复全面审查发现的问题

- codemode:Tool Search 常驻(alwaysEnabled)、权限 allow(嵌套调用仍逐个过权限门)、
  tools.jsonc 登记使用规则;RTK 跳过 parentToolCallId 嵌套调用,避免丢失 bash
  structuredContent;Tool Search 目录过滤 hidden / codemode(script-only)exposure;
  扩展加载测试加载 builtin:codemode 并断言其常驻激活
- 搜索 key 不再经命令行参数传递:search-auth.mjs 改为 --set-stdin(先读校验再加锁),
  configure.sh 交互输入经管道、非交互用 --<provider> -
- CodeGraph 客户端监听子进程 stdin error,避免 EPIPE 未处理导致崩溃
- 移除 PI_TOOL_SEARCH/HERMES_MEMORY/RTK_CONFIG_PATH 环境变量入口,测试改用工厂 configPath 注入
- pi-subagents 固定 vitest / coverage-istanbul 4.1.10,修复 npm ls 版本冲突
- 补 pi-web-search / pi-worktree UPSTREAM.md 与 pi-minimal-footer AGENTS.md,
  files 白名单补齐并加测试;.codegraph/.gitignore 移出跟踪
- detect_kitty 优先识别官方安装目录

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
云服务部-叶林立
2026-10-21 23:18:34 -07:00
co-authored by Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent 56cbc83296
commit f9a7f743dd
46 changed files with 585 additions and 198 deletions
+15 -14
View File
@@ -5,7 +5,7 @@
* writes atomically with a lock directory, and keeps the file mode 600.
*
* Usage:
* node search-auth.mjs --set tavily=KEY [--set exa=KEY] [--set keenable=KEY]
* node search-auth.mjs --set-stdin tavily (reads the key from stdin)
* node search-auth.mjs --unset tavily [--unset exa]
* node search-auth.mjs --migrate [search.env path]
* node search-auth.mjs --list
@@ -47,7 +47,7 @@ function die(message) {
function usage() {
console.log(`用法:
node search-auth.mjs --set <provider>=<key> [--set ...]
node search-auth.mjs --set-stdin <provider> (从标准输入读取 key,每次只能配置一个 provider)
node search-auth.mjs --unset <provider> [--unset ...]
node search-auth.mjs --migrate [search.env 路径]
node search-auth.mjs --list
@@ -69,17 +69,16 @@ function defaultSearchEnvPath(env = process.env) {
}
function parseArgs(argv) {
const result = { sets: {}, unsets: new Set(), migrate: undefined, list: false, has: undefined, authPath: undefined };
const result = { setStdin: undefined, unsets: new Set(), migrate: undefined, list: false, has: undefined, authPath: undefined };
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
if (arg === "--set") {
const spec = argv[++i];
const separator = spec ? spec.indexOf("=") : -1;
if (separator < 1) die("--set 需要 <provider>=<key>");
const provider = spec.slice(0, separator);
const value = spec.slice(separator + 1);
die("--set 已移除:key 不得出现在命令行参数中;请改用 --set-stdin 从标准输入提供。");
} else if (arg === "--set-stdin") {
const provider = argv[++i];
if (!PROVIDERS.includes(provider)) die(`未知 provider:${provider}(支持 ${PROVIDERS.join("/")})`);
result.sets[provider] = value;
if (result.setStdin) die("每次调用最多一个 --set-stdin。");
result.setStdin = provider;
} else if (arg === "--unset") {
const provider = argv[++i];
if (!PROVIDERS.includes(provider)) die(`未知 provider:${provider}(支持 ${PROVIDERS.join("/")})`);
@@ -208,12 +207,15 @@ if (args.has) {
process.exit(hasKey(readAuthData(authPath), args.has) ? 0 : 1);
}
const mutations = Object.keys(args.sets).length + args.unsets.size + (args.migrate ? 1 : 0);
const mutations = (args.setStdin ? 1 : 0) + args.unsets.size + (args.migrate ? 1 : 0);
if (mutations === 0) {
usage();
process.exit(2);
}
const stdinKey = args.setStdin ? readFileSync(0, "utf8").trim() : undefined;
if (args.setStdin) validateKey(args.setStdin, stdinKey);
const release = acquireLock(authPath);
try {
const data = readAuthData(authPath);
@@ -225,10 +227,9 @@ try {
changed.push(`已移除 ${provider}`);
}
}
for (const [provider, key] of Object.entries(args.sets)) {
validateKey(provider, key);
setKey(data, provider, key);
changed.push(`已写入 ${provider}`);
if (args.setStdin) {
setKey(data, args.setStdin, stdinKey);
changed.push(`已写入 ${args.setStdin}`);
}
if (args.migrate) {
const source = args.migrate === true ? defaultSearchEnvPath() : args.migrate;