feat(agent-core-v2): add depth option to host fs watch - #3502
Conversation
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f29952f8bf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| "optionalDependencies": { | ||
| "@parcel/watcher-darwin-arm64": "2.5.1", | ||
| "@parcel/watcher-darwin-x64": "2.5.1", | ||
| "@parcel/watcher-linux-arm64-glibc": "2.5.1", |
There was a problem hiding this comment.
Install Parcel bindings with the published CLI
For users installing @moonshot-ai/kimi-code from npm, these optional dependencies are never installed: agent-core-v2 is private and bundled into apps/kimi-code/dist/main.mjs, while the published package contains only the app's own dependency manifest. The computed runtime require('@parcel/watcher-…') therefore fails and every recursive Linux watch falls back to chokidar, leaving the advertised single-inotify fix unavailable outside the SEA build. Declare or ship the platform bindings from the published CLI package as well.
Useful? React with 👍 / 👎.
| const ignorePaths = resolveIgnorePaths(root, options?.ignorePaths); | ||
| this.subscribeOptions = { | ||
| backend: 'inotify', | ||
| ...(ignorePaths.length > 0 ? { ignorePaths } : {}), |
There was a problem hiding this comment.
Pass the optional ignore path property directly
This conditional spread violates the repository rule for optional object properties. Assign ignorePaths directly, using undefined when it should be absent, rather than conditionally spreading a temporary object.
AGENTS.md reference: AGENTS.md:L52-L54
Useful? React with 👍 / 👎.
| "@moonshot-ai/kimi-code": patch | ||
| --- | ||
|
|
||
| On Linux, recursive directory watching now uses the native @parcel/watcher binding — one inotify instance for the whole tree instead of one watcher per directory — so watching large workspaces no longer fails with `EMFILE: too many open files`. Heavy generated directories (`.git`, `node_modules`, `.tower`, `.worktrees`, `.jj`) are now pruned at the OS watch level. When the native binding is unavailable, watching falls back to the previous behavior. |
There was a problem hiding this comment.
Rewrite the changeset as one short sentence
The changeset body contains three detailed sentences, but repository policy requires exactly one short user-facing sentence stating only what changed. Condense this entry before release.
AGENTS.md reference: AGENTS.md:L85-L87
Useful? React with 👍 / 👎.
1ac5007 to
4afae8a
Compare
HostFsWatchOptions gains a depth field, passed through to chokidar's depth option, so watchers can bound recursion (0 = only the directory itself) instead of always watching whole trees.
4afae8a to
ad86368
Compare
Related Issue
No linked issue — internal hardening for
EMFILE: too many open filesreports when running in large Linux workspaces.Problem
In workspaces with tens of thousands of directories, recursive file watching can become heavy: chokidar walks the whole tree and registers an inotify watch per directory, so inotify watch-descriptor usage (
max_user_watches) scales with directory count, and on fd-constrained machines the watch setup itself can surfaceEMFILE: too many open files, watch '<workspace>'.Most watchers in the codebase don't actually need whole-tree recursion — they care about a few known files or shallow subtrees — but the watch API offers no way to bound recursion depth.
What changed
HostFsWatchOptionsgains adepth?: numberfield, passed through to chokidar'sdepthoption. Watchers can now bound recursion (0= only the target directory itself, one inotify watch) instead of always watching whole trees. Unset means full recursion, identical to current behavior.No new dependencies, no behavior change for existing watchers,
HostFsChangeprotocol unchanged.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.