Repository navigation
[1403] 让 tps.scm 扩展全局生效:统一 agent 目录到 ~/.gf 并在 TUI worker 会话加载用户扩展 - #12
Merged
Merged
Conversation
根因:内置扩展先经 registry initializer 加载,TUI 主线程与 worker 再补加载 用户层同名副本;discovery 的名称仲裁只决定返回路径,管不到已挂载的内置副本, listeners / prompt-injectors / validators / augmenters 等 append 型注册随之 重复(事件双发、注入双份)。tps.scm 因一次性时间戳守卫恰好只出一行, 无守卫扩展则双发。 修复:消除两批加载,统一加载入口。 - cli/args.scm:ensure-builtin-extensions! 改为 ensure-extensions-loaded!, 经 pi-discover-extensions 全层级仲裁(内置 → gf 配置 → agent → 项目) 一次性加载,同名只加载胜出副本 - tui/cli.scm:%ensure-extensions-loaded! 删除用户层补加载,只触发 initializer - tui/interactive/worker.scm:同样只触发 initializer(仍早于 parse-pi-args, 扩展 flag 参与解析的顺序不变) - 新增回归测试:内置/用户同名探针扩展,断言 listener/injector 各恰好 1 个 且用户副本胜出 验证:真实 go worker 会话(独立 s7)单行 TPS 且为用户副本内容; 全仓测试 code 593 / tui 518 / ai 427 / agent 120 / web-search 34 / review 22 / simplify 17 全部通过;gf check / gf fix 通过。
CI 中 code/tests/liii/pi/code/cli/args/parse-pi-args-user-override-test.scm 未按 gf fmt 规则格式化,导致 Check on Debian trixie 失败。 运行 gf fmt code 重新格式化以恢复 CI。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
tps 扩展(
extensions/tps.scm)在 agent 运行结束时输出一行 token 吞吐量统计。实际使用中发现它在一次性模式(gf pi -p)能正常输出 TPS 行,而在 TUI 交互模式下完全静默——聊天区回复后从不出现 TPS 状态行。根因
pi-get-agent-dir仍默认~/.pi/agent,与 JSON 配置目录~/.gf/agent分离,保留了为 node 版 pi 兼容的旧约定。go起的 worker 是后台线程的独立 s7 会话(liii go的go-call在新会话恢复*load-path*与主会话活动库后求值procedure-source),主线程在cli.scm通过%ensure-extensions-loaded!加载的扩展注册表对 worker 不可见,因此 tps 的agent_end监听器在 TUI 下从未注册,扩展状态行(经ctx.ui.notify→tps_report事件 →pi-app-add-status-message!渲染)自然不显示。改动
pi-get-agent-dir默认值从~/.pi/agent改为~/.gf/agent;gf-get-config-dir定义下沉至(liii pi code core tools read)(与pi-get-agent-dir同模块,打破 config→discovery→args→config 循环导入,仍经 config.scm re-export)。sessions/ 与 extensions/ 自然落到同一目录,~/.pi/agent不再被读取。pi-tui-agent-worker入口、augment-pi-config之前,调用pi-load-extensions (pi-discover-extensions :include-builtin? #f) (default-extension-registry)把用户级扩展装入本 worker 会话的注册表。内置扩展由args.scm在主线程提前加载,此处用include-builtin? #f不重复。extensions/discovery.scm、skills/discovery.scm、cli/help.scm、web-search/config.scm删除所有~/.pi/agent兼容说法。resolve-pi-config-dir-test.scm:agent-dir 与 sessions 断言改为~/.gf/agentpi-get-agent-dir-test.scm:从空占位补全为完整断言(默认~/.gf/agent、env 覆盖、显式参数、绝对路径)gf-get-config-dir-test.scm随定义下沉迁移至core/tools/read/pi-discover-extensions-test.scm覆盖扩展发现的多层级合并与覆盖语义验收
gf pi -p:输出 TPS 行 ✓~/.gf/agent/sessions/✓已知限制
~/.pi/agent/sessions/,不自动迁移;如需保留可手动mv ~/.pi/agent/sessions/* ~/.gf/agent/sessions/。.pi/extensions与.pi/skills(仓库当前目录下的.pi/)属上游 node 版 pi 的项目级配置概念,与家目录~/.pi/agent无关,保留不动。PI_CODING_AGENT_DIR环境变量仍可覆盖 agent-dir,仅默认值改变。任务文档:dev-agent2 仓库
devel/1403.stem。