Skip to content

fix(agent-core-v2): make host fs stat follow symlinks and add explicit lstat#1843

Open
7Sageer wants to merge 3 commits into
mainfrom
refactor/hostfs-stat-semantics
Open

fix(agent-core-v2): make host fs stat follow symlinks and add explicit lstat#1843
7Sageer wants to merge 3 commits into
mainfrom
refactor/hostfs-stat-semantics

Conversation

@7Sageer

@7Sageer 7Sageer commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

None — follow-up to #1840, supersedes #1842.

Problem

The v2 engine's IHostFileSystem.stat was named like Node's stat but implemented lstat semantics — the opposite of Node, and the opposite of the v1 engine's kaos.stat (which follows symlinks by default). Every stat.isFile / stat.isDirectory call site written with the usual intuition silently mishandled symlinks, and the failure mode was always an invisible skip with no log or warning. This single design flaw has already produced three user-visible bugs in the web backend (a common dotfiles setup installs config/instruction files as symlinks):

Fixing call sites one by one (#1840, #1842) does not stop new ones from re-introducing the bug, so this PR fixes the semantics at the source.

What changed

  • IHostFileSystem.stat now follows symlinks (Node stat / v1 kaos semantics), and a new explicit lstat serves consumers that genuinely need link-level information. The transitional followSymlinks option added in fix(agent-core-v2): follow symlinks when loading AGENTS.md and reading files #1840 is removed again.
  • Consumers migrated according to intent: session-fs entry kinds, the git-diff existence check, and .git discovery use lstat (symlink-aware behavior preserved); everything else — AGENTS.md loading, Read, ReadMediaFile, glob roots, write-parent checks, workspace validation — now follows links, matching the CLI's v1 engine. This also makes the per-call-site fixes from fix(agent-core-v2): follow symlinks in read and media tools #1842 unnecessary (closing it).
  • Symlinked config/instruction paths that exist but cannot be loaded (e.g. a dangling symlink) now surface a warning instead of vanishing silently, and an unreadable AGENTS.md no longer throws during system-prompt assembly.

Skill discovery and MCP config loading were audited and are not affected: they use node:fs directly, which already follows symlinks.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • 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 Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 33a4128

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

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

commit: 33a4128

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