Skip to content

feat(config): move acp.json under agent dir with legacy fallback - #232

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-08-26_config-location-migration
Open

feat(config): move acp.json under agent dir with legacy fallback#232
ranxianglei wants to merge 1 commit into
masterfrom
2026-08-26_config-location-migration

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #231

配置文件位置迁移至 agent 目录(与绝大多数 pi 插件一致),保留历史路径兼容回退。

  • 全局: ~/.pi/agent/acp.json(原 ~/.pi/acp.json 自动回退读取)
  • 项目级: <project>/.pi/agent/acp.json
  • 迁移逻辑带 legacy fallback + 测试覆盖(tests/user-config.test.ts +132)

由沙箱 AI(qwen3.8-27b)完成,宿主机代为推送(VM 暂无 push 凭证)。
11 files, +207/−29

 #231)

Global config now lives at <agentDir>/acp.json (~/.pi/agent/acp.json) and
project config at <cwd>/.pi/agent/acp.json, matching where most pi plugin
configs live (and where config-sync plugins look). Legacy locations
(~/.pi/acp.json, <cwd>/.pi/acp.json) are still read when the new location is
absent, so existing setups keep working unchanged; the new location wins when
both are present. No files are written automatically — moving an existing
config is a manual copy.

- src/user-config.ts: resolve per-scope fresh/legacy path (fresh wins)
- tests: new-location read, legacy backward-compat, precedence, hot-reload
- e2e harness + docs (CONFIGURATION/README, en+zh) updated to new paths
@github-actions

Copy link
Copy Markdown

📦 Built Extension Artifact

Branch: 2026-08-26_config-location-migration (9a98313)

Option A — Install from npm PR tag (recommended)

pi install npm:billion-context-pi@pr-232

Each push to this PR publishes a new version under the pr-232 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pi-pr232.tgz
pi install ./package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

这个pr review下 是否有回归风险

@ranxianglei

Copy link
Copy Markdown
Owner Author

(运维测试,非任务)请用 reply 工具回复一句 ok。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(运维重发,插件故障已修复)继续处理之前 @ranxianglei 的请求:review 这个 PR 是否有回归风险,用 reply 给出结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(运维重发·第2次)review PR #232 回归风险。正确姿势:在 workdir 执行 git fetch origin pull/232/head && git diff origin/master...FETCH_HEAD 拿 diff(不要访问 127.0.0.1:3002,它不是 git/API 服务器)。结论用 reply 工具发出:风险点带 文件:行号 + verdict。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(运维重发·第3次,全新会话)review PR #232 回归风险。diff 获取:git fetch origin pull/232/head && git diff origin/master...FETCH_HEAD。结论用 reply 工具发出(风险点带文件:行号 + verdict)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

[bot] PR #232 回归风险 review 结论

验证方式:在 workdir 检出 PR head 9a98313(= origin/2026-08-26_config-location-migration,与 issue 描述一致),本地跑通全套 CI 检查:

  • npm run typecheck
  • npm test ✅ 428/428 通过(含 tests/user-config.test.ts 新增 7 个用例、tests/integration.test.ts 改名后的 legacy 热加载用例)
  • npm run build ✅ dist/index.js 正确以 external 方式从宿主包导入 getAgentDir(未误打包)

风险点

  1. getAgentDir 导入安全性(最大风险,已排除)src/user-config.ts:4 新增从 @earendil-works/pi-coding-agent 导入 getAgentDir。已核实 0.83.0(devDependency 固定版本,也是 AGENTS.md 声明的最低宿主版本)已导出该符号(dist/config.d.ts:76),老宿主不会 import 失败。

  2. ⚠️ 新位置存在但 JSON 损坏时,legacy 文件被静默忽略(低)— src/user-config.ts:79-83 resolveConfigFile 只要 fresh 文件存在就完全不读 legacy。场景:用户把 ~/.pi/acp.json 复制到新位置但 JSON 写错 → 旧的有效配置不再生效(仅 logWarn)。与文档"新位置优先"语义一致、有告警日志,属可接受边界行为,建议知晓即可。

  3. ⚠️ PI_CODING_AGENT_DIR 环境变量分叉(低,文档/一致性问题)— getAgentDir() 尊重 PI_CODING_AGENT_DIR(宿主 dist/config.js:412-418),但:CONFIGURATION.md 只写了 ~/.pi/agent/acp.json;legacy 回退硬编码 homedir()/.pi/acp.jsonsrc/user-config.ts:45);包内其他路径硬编码 homedir()/.pi/agent 不读该 env(src/update.ts:20src/setup-subagent-tools.ts:46)。设了该 env 时全局配置会跟着走,行为合理但未文档化且与包内其他路径不一致。

  4. ⚠️ 测试对环境变量不免疫(低)— tests/user-config.test.ts:39-45setHome/snapshotHome 只伪造 HOME/USERPROFILE,未清理 PI_CODING_AGENT_DIR;若测试环境设了该变量,global 相关用例会读错目录。当前 CI/沙箱未设(428 全绿),非阻塞。

  5. 向后兼容与热加载 — legacy-only 用户读取路径与优先级(project > global)与迁移前完全一致;不自动写文件(有测试断言);src/runtime.ts:344-361 reloadConfig 委托 loadUserConfig,基于内容 key 的变更检测能正确处理 fresh/legacy 路径切换;ISSUE-9 热加载用例现显式覆盖 legacy 项目路径。

  6. 无遗漏引用 — 全仓 grep 无残留功能性旧路径引用;README/CONFIGURATION(中英)/e2e 脚本(scripts/e2e/run-e2e.mjs)均已同步。仅 docs/token-calibration-plan.md:355 一处历史规划文档提到旧路径,属 cosmetic。

Verdict:低风险,可合并。 向后兼容完整、测试覆盖到位、本地 CI 三项全绿;上述 3 个 ⚠️ 均为低severity(边界行为/文档一致性/测试健壮性),不构成阻塞,可后续跟进。

HangxiangMa pushed a commit to HangxiangMa/billion-context-pi that referenced this pull request Sep 10, 2026
coreOutToAgentMessages now consumes kernel-rewritten tool-call text
(hide-consumed dead-range filtering + summary stubbing, acp-kernel
ranxianglei#230/ranxianglei#232) and syncs the compacted JSON back into toolCall.arguments
for both projection paths (plain-id single-call and base#callId
multi-call). Fail-safe: unparseable/absent kernel text keeps originals;
string-form content (non-strict providers) keeps its shape.

Bumps acp-kernel pin 0.0.56 -> 0.0.60 (published).

Fixes ranxianglei#340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

配置文件位置迁移

1 participant