Repository navigation
feat: support symlinked directories in file tree - #4457
Conversation
🦋 Changeset detectedLatest commit: b8be4f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
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 |
Codex Review SummaryThis 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: |
There was a problem hiding this comment.
🟡 Changes recommended
Recursive alias traversal lacks a request-wide budget, and ignored-descendant probing can hide explicitly allowed external-symlink content.
2 open issues
What changed in this PR
This PR adds filesystem API support for expanding symlinked directories, including opt-in access to targets outside the workspace, and introduces session-less workspace listing.
Changes:
- Add symlink-directory metadata, recursive traversal, cycle detection, and directory-first sorting.
- Add optional external-symlink access for listing and reading, preserving default confinement.
- Extend route coverage, API snapshots, bilingual documentation, and release metadata.
| File | Description |
|---|---|
packages/kap-server/test/fs.test.ts |
Test session and workspace symlink listing and external access. |
packages/kap-server/test/__snapshots__/apiSurface.snapshot.test.ts.snap |
Record the workspace listing endpoint. |
packages/kap-server/src/routes/fs.ts |
Register session-less workspace listing. |
packages/agent-core-v2/test/workspace/workspaceFs/fsService.test.ts |
Extend filesystem mocks and symlink regression coverage. |
packages/agent-core-v2/src/workspace/workspaceFs/fsService.ts |
Implement symlink traversal, cycle checks, and optional external reads. |
packages/agent-core-v2/src/workspace/workspaceFs/fs.ts |
Extend request and response schemas. |
docs/zh/reference/server-api.md |
Document the API additions in Chinese. |
docs/en/reference/server-api.md |
Document the API additions in English. |
.changeset/file-tree-symlink-directories.md |
Add release metadata for symlink support. |
Review effort: Balanced
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce85ce5b51
ℹ️ 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".
| @@ -31,6 +31,7 @@ export const fsEntrySchema = z.object({ | |||
| mime: z.string().optional(), | |||
| language_id: z.string().optional(), | |||
| is_binary: z.boolean().optional(), | |||
| is_directory: z.boolean().optional(), | |||
There was a problem hiding this comment.
Ship client support for the symlink directory marker
The committed web bundle still maps filesystem entries in QH without is_directory, and its file-tree component only expands entries whose kind === "directory"; listDirectory also has no way to send allow_external_symlinks. Consequently the shipped CLI/web file tree discards this new marker and continues treating every kind: "symlink" entry as a leaf, so the feature described by this change is unavailable to its primary users. Update the code-app client and sync the resulting dist-web bundle in this change.
AGENTS.md reference: AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Intentionally out of scope for this PR per product decision; the client change is tracked in MoonshotAI/kimi-code-app#997.
|
Addressed the review findings in f734dc9:
The |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f734dc9714
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f243f2057
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58787f7ff7
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e34b5bf54
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9036fae06
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c964d120a9
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Engine slice of upstream MoonshotAI/kimi-code e2ad1dc (MoonshotAI#4457). A symlinked directory appeared as an inert `symlink` entry: the walk never descended into it, so a project whose folders are links listed as empty. Listing now resolves a symlink's target, marks the entry with `is_directory`, and queues it with its real path as an ancestor so a cycle stops instead of recursing. Entries reached through a symlink share a 10,000-record budget; a symlink whose target is outside the workspace is still not followed unless the caller passes `allow_external_symlinks`, which `resolveWithin` now honours. Three cases pin it: an in-workspace link expands and carries the flag, an external target does not expand by default, and the same target does expand with the flag. Removing either the marking or the external guard turns them red. Test fixtures needed two additions to model a real filesystem: `readdir` follows a symlinked path, and `lstat` rewrites a symlinked parent prefix before the lookup. Not yet ported from the same commit: the REST `allow_external_symlinks` flag on the fs routes, the workspace `fs:list` documentation, and the download route's flag.
REST slice of upstream MoonshotAI/kimi-code e2ad1dc (MoonshotAI#4457). `fs:read` and the download route now accept `allow_external_symlinks`, so a caller that deliberately points at a link outside the workspace can read it, while the default still refuses. The entry documentation gains `is_directory` and the 10,000-record budget for symlink-expanded entries, in both locales. The route case extends the existing escape test: the same path that is refused by default now reads and downloads with the flag. Dropping the flag from the download route turns it red.


Requirement or Bug
The file tree should expand symlinked directories, including links whose targets are outside the workspace.
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
allow_external_symlinksis opt-in and defaults to off, so existing callers keep the current confinement behavior.is_directoryentry field is additive;kind: "symlink"is unchanged.Behavior Changes and Affected Users
fs:listkind: "symlink", never recursedis_directory: trueand recurse when requestedkindonlykindare unchanged41304allow_external_symlinks: truetype_firstsemanticsPOST /api/v1/workspace/fs:listAffected modules:
agent-core-v2filesystem service: unit coverage infsService.test.tsfor internal, external, broken and cyclic symlinks, including read and recursion behavior.kap-serverfilesystem routes: route coverage infs.test.tsfor session and session-less listing, external access, and default rejection; API surface snapshot updated for the new endpoint.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.