feat: 组合包配置集中到 my-pi/ 目录并改为整体重建

- 组合包拥有、可随时重建的配置、日志与缓存统一放在
  <agentDir>/my-pi/:permission-system/(policy.jsonc、hard-guards.jsonc、
  logs/)、rtk-optimizer/config.json、tool-search/(config.json、
  catalog-v1.json)与 system-prompt-cover.md。hashline.json、lsp.json
  由外部扩展读取固定路径,是唯一例外。
- 新增 config/bundle-manifest.json 与 scripts/rebuild-bundle-config.mjs:
  先校验全部来源与目标,在临时目录构建完整树,再整体删除旧 my-pi/
  (符号链接只删链接)并原子替换,不备份。install.sh / update.sh 每次
  运行都调用它;扩展自身不再播种或迁移配置。
- update.sh 删除 pi update 失败后的 git clean 恢复逻辑:Pi 1.3.0 会在
  下一次 pi update 时依据中断标记自行恢复。同时删除 Tool Search
  settings.json 快照迁移与封面部署脚本。
- Tool Search 改为读取 my-pi/tool-search/config.json(源为
  config/tool-search.json,须与 BUNDLE_TOOL_SEARCH_DEFAULTS 一致),
  不再读写 settings.json 的 toolSearch 段,移除 bundleDefaultsVersion。
- 默认权限策略开启 debugLog。
- 旧位置的残留文件不迁移、不清理;AGENTS.md / README 同步新约束。

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-19 02:26:57 -07:00
co-authored by Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent 7e6a8faae1
commit 2682bd7fa7
40 changed files with 711 additions and 1339 deletions
+26 -33
View File
@@ -14,7 +14,7 @@ Generated metadata never replaces executable schemas. Exact names, parameter typ
2. Hidden tool definitions are hashed with the grouping constraints.
3. Every tool exposed by the standard `my-pi` bundle is matched against the checked-in catalog in `extensions/bundle-groups.ts`. If all tools are recognized, no model call and no user cache are needed.
4. User `groupOverrides` take priority over checked-in assignments. Optional or unavailable bundle tools are simply filtered out of their predefined groups.
5. Additional user or third-party tools receive deterministic prefix/source groups immediately. A matching private model-enriched cache at `<agent-dir>/tool-search/catalog-v1.json` is reused when present.
5. Additional user or third-party tools receive deterministic prefix/source groups immediately. A matching private model-enriched cache at `<agent-dir>/my-pi/tool-search/catalog-v1.json` is reused when present.
6. Only when unrecognized tools exist and the call does not name an exact existing group may `tool_search` ask the current authenticated model to enrich the complete catalog. Exact group activation always uses the current deterministic catalog immediately. Validation requires all checked-in bundle tools to remain in their predefined groups before a `0600` cache is accepted.
7. Missing authentication, invalid JSON, timeout, cancellation, changed bundle assignments, or cache errors leave the checked-in plus deterministic hybrid catalog usable.
@@ -74,33 +74,29 @@ The first loads are purely additive and retain Pi's native deferred-loading prop
## Configuration
Pi reads this configuration from `<agent-dir>/settings.json` (normally `~/.pi/agent/settings.json`). The bundle adds fields only when missing and never replaces explicit user choices:
Pi reads this configuration from `<agent-dir>/my-pi/tool-search/config.json` (normally `~/.pi/agent/my-pi/tool-search/config.json`), deployed by the bundle's `install.sh` / `update.sh` from `config/tool-search.json`. A missing, unreadable, or invalid file falls back to the built-in `BUNDLE_TOOL_SEARCH_DEFAULTS`; the extension never writes the file:
```json
{
"toolSearch": {
"alwaysEnabled": [
"codegraph_explore",
"lsp_diagnostics",
"ctx_execute",
"ctx_execute_file",
"ctx_batch_execute",
"memory_search",
"session_search",
"memory_add",
"memory_replace",
"memory_remove",
"skill_manage",
"context_tree_query"
],
],
"showToolSearchFooterStatus": false,
"maxActiveGroups": 5,
"maxToolsPerGroup": 8,
"maxDynamicTools": 28,
"groupOverrides": {},
"bundleDefaultsVersion": 4
}
"alwaysEnabled": [
"codegraph_explore",
"lsp_diagnostics",
"ctx_execute",
"ctx_execute_file",
"ctx_batch_execute",
"memory_search",
"session_search",
"memory_add",
"memory_replace",
"memory_remove",
"skill_manage",
"context_tree_query"
],
"showToolSearchFooterStatus": false,
"maxActiveGroups": 5,
"maxToolsPerGroup": 8,
"maxDynamicTools": 28,
"groupOverrides": {}
}
```
@@ -112,22 +108,19 @@ Pi reads this configuration from `<agent-dir>/settings.json` (normally `~/.pi/ag
| `maxToolsPerGroup` | `8` | Maximum size accepted from model-generated groups |
| `maxDynamicTools` | `28` | Hard cap across active dynamic group tools |
| `groupOverrides` | `{}` | Exact tool lists that override checked-in, generated, or fallback assignments |
| `bundleDefaultsVersion` | `4` on a newly created default section | Bundle provenance for controlled default migrations; ignored by runtime routing |
Example override:
```json
{
"toolSearch": {
"groupOverrides": {
"web-tavily": ["tavily_web_search", "tavily_web_fetch"],
"lsp": ["lsp_definition", "lsp_references", "lsp_hover", "lsp_symbols", "lsp_diagnostics"]
}
"groupOverrides": {
"web-tavily": ["tavily_web_search", "tavily_web_fetch"],
"lsp": ["lsp_definition", "lsp_references", "lsp_hover", "lsp_symbols", "lsp_diagnostics"]
}
}
```
An explicit override larger than `maxDynamicTools` remains visible but cannot be activated until the limit or override is corrected. Normal extension loading preserves existing values and writes owner-only settings through a unique same-directory temporary file. When the user explicitly runs the bundle's updated `update.sh`, its post-update migration helper changes only the complete former `3`/`20` default snapshot: it creates an owner-only timestamped backup, atomically writes the current defaults, and records `bundleDefaultsVersion: 2`. Customized or invalid settings are preserved, and a content change detected immediately before commit aborts the migration.
An explicit override larger than `maxDynamicTools` remains visible but cannot be activated until the limit or override is corrected. Every `install.sh` / `update.sh` run rebuilds the file together with the rest of the `my-pi/` tree, so hand edits are overwritten — change `config/tool-search.json` in the bundle repository for durable customization.
## Current host integration
@@ -138,7 +131,7 @@ This version directly targets `@earendil-works/pi-coding-agent`, current `typebo
- `extensions/index.ts` — Pi lifecycle, model call, activation, and group LRU
- `extensions/catalog.ts` — hashing, strict catalog validation, fallback grouping, cache, and ranking
- `extensions/bundle-groups.ts` — checked-in authoritative groups for tools exposed by `my-pi`
- `extensions/config.ts` — safe bundle-default deployment and config parsing
- `extensions/config.ts` — bundle-deployed config path and config parsing
- `test/` — catalog, config, model-generation, and active-set tests
- `docs/dynamic-tool-loading.md` — current Pi propagation and replacement behavior
- `UPSTREAM.md` — imported snapshot and local divergence