Skip to content

feat(agent-core-v2): add depth option to host fs watch - #3502

Open
sailist wants to merge 1 commit into
MoonshotAI:mainfrom
sailist:feat-143-09-03-linux-parcel-watcher
Open

feat(agent-core-v2): add depth option to host fs watch#3502
sailist wants to merge 1 commit into
MoonshotAI:mainfrom
sailist:feat-143-09-03-linux-parcel-watcher

Conversation

@sailist

@sailist sailist commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — internal hardening for EMFILE: too many open files reports 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 surface EMFILE: 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

  • HostFsWatchOptions gains a depth?: number field, passed through to chokidar's depth option. 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 watcher changes behavior in this PR; the option is available for consumers to adopt on demand.

No new dependencies, no behavior change for existing watchers, HostFsChange protocol unchanged.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ad86368

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@ad86368
npx https://pkg.pr.new/@moonshot-ai/kimi-code@ad86368

commit: ad86368

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/agent-core-v2/package.json Outdated
Comment on lines +92 to +95
"optionalDependencies": {
"@parcel/watcher-darwin-arm64": "2.5.1",
"@parcel/watcher-darwin-x64": "2.5.1",
"@parcel/watcher-linux-arm64-glibc": "2.5.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread .changeset/linux-parcel-watcher.md Outdated
"@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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@sailist
sailist force-pushed the feat-143-09-03-linux-parcel-watcher branch 3 times, most recently from 1ac5007 to 4afae8a Compare September 3, 2026 07:12
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.
@sailist
sailist force-pushed the feat-143-09-03-linux-parcel-watcher branch from 4afae8a to ad86368 Compare September 3, 2026 13:06
@sailist sailist changed the title feat(agent-core-v2): watch linux directories with @parcel/watcher feat(agent-core-v2): add depth option to host fs watch Sep 3, 2026
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