Repository navigation
refactor(agent-core-v2): run both ripgrep paths of the fs service through one process runner - #5527
Conversation
…ough one process runner File suggestions and content search each carried their own copy of the ripgrep process lifecycle: spawn under an environment lease, kill on abort, split stdout into lines while tolerating the premature close a kill causes, wait for stderr and the exit code, then release the process and the lease. The copies had drifted apart, and a fix to that lifecycle had to be made twice. Move the lifecycle into runRgLines. Each caller now passes only its line handler; the runner skips empty lines, which the suggest handler already ignored, and hands back the exit code and whether it killed rg. The differences between the callers stay where they were: search still stops rg once its accumulator is capped (the stop callback no longer fires for the trailing partial line, as before) and still ignores the exit code, and suggest still fails on an exit code other than 0 or 1 unless it killed rg. Behaviour is otherwise unchanged, including the lease not being released when the spawn itself fails. Two cases pin that an expired grep or suggest deadline kills rg, which no existing case covered: a runner that ignored the abort signal passed all 234 fs tests. They pass on the code before this change too.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
Requirement or Bug
packages/agent-core-v2/src/project/projectFs/fsService.ts里,文件建议(suggestWithRg)和内容搜索(grepWithRg)各自带着一份几乎相同的 ripgrep 进程生命周期代码。两份已经开始走样,生命周期上的修复也要改两遍:接下来要修的「启动失败时泄漏环境租约」,就是两份里各有一处。这个 PR 只做合并,不改行为。它是那个修复的前置:合并之后,修复只需要改一处,CI 的新增重复检查也不会再因为改到这段重复代码而报错。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
新增私有方法
runRgLines(binary, args, signal, onLine),统一负责:onLine;被自己强杀时,容忍 stdout 的提前关闭;两个调用方只保留各自的逐行处理和收尾逻辑。
旧路径的功能清单,以及每项在新代码里的位置
runRgLinesrunRgLines\n切分,结尾不完整的一行最后再处理runRgLinesrunRgLineswait出错按-1处理)runRgLinesrunRgLinesrunRgLines。文件建议的handleLine本来就会在去掉\r和开头的./之后丢掉空行,所以对它没有影响onLine调用stop()runRgLines在 stdout 读完后让stop()失效runRgLines返回的值判断runRgLines,原样保留,由后续的修复 PR 处理内容搜索的累加器
RgJsonAccumulator现在在启动 rg 之前创建。它的构造函数只保存参数,没有副作用。Behavior Changes and Affected Users
None。上面的清单逐项说明了原有行为的去处,没有改动配置、契约文件或提示词。
没有 changeset:没有可感知的行为变化。
验证
只在 macOS 上验证过,Linux 和 Windows 交给 CI。改动不涉及路径处理或平台分支。
packages/agent-core-v2/test/project/projectFs、kap-server 的fs.test.ts和workspaceFs.test.ts、node-sdk 的sdk-rpc-client-v2.test.ts、app-core 的daemon-client.test.ts:共 536 条通过。pnpm run check:duplication:没有新增重复。fsService.ts内部的重复从 4 处降到 3 处,两条 ripgrep 路径之间那段 19 行的重复没有了。pnpm lint通过,agent-core-v2 类型检查通过。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.