Skip to content

feat(kap-server): add allow_ignored_globs to fs:list for un-ignoring named paths - #4058

Merged
liruifengv merged 16 commits into
mainfrom
feat/fs-list-include-globs
Oct 8, 2026
Merged

liruifengv merged 16 commits into
mainfrom
feat/fs-list-include-globs

Conversation

@liruifengv

@liruifengv liruifengv commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

让 fs:list 的调用方能点名放行个别被 gitignore 的路径(例如 .tmp),同时保持其余 gitignore 过滤不变。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

fs:list 新增可选请求字段 allow_ignored_globs: string[]:被 gitignore 命中的条目,在命中该字段(或其某个被忽略祖先目录命中有匹配后代)时保留。

  • schema:packages/agent-core-v2/src/workspace/workspaceFs/fs.ts 的 fsListRequestSchema 加 allow_ignored_globs。
  • 过滤:fsService.list 的子项过滤循环按上述逻辑放行;只作为「可能祖先」保留的目录会先做一次有界探测(深度 ≤ 6、条目 ≤ 500,超限 fail-open),没有匹配后代的目录不返回。
  • glob 匹配:删除手写的 glob→正则编译器,matchesAnyGlob 与前缀匹配统一走 picomatch(本包既有依赖),祖先探测保留迭代式逐段 DP。
  • 测试:packages/kap-server/test/fs.test.ts(逐层祖先遍历、通配符段、无匹配后代不显示、文件前缀不显示)与 packages/agent-core-v2/test/workspace/workspaceFs/fsSearch.test.ts(段边界、深 glob 防栈溢出)新增用例。
  • 文档:docs/{en,zh}/reference/server-api.md 的 fs:list 参数表同步加该字段,并注明点开头路径需同时传 show_hidden: true。
  • changeset:两条 @moonshot-ai/agent-core-v2 条目(minor:新字段;patch:glob 引擎切换的行为变化)。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
fs:list 请求体字段 不接受 allow_ignored_globs 接受该可选字段;不传时行为与之前完全一致 不传该字段的既有客户端(desktop、web、SDK)——行为不变 不需要
fs glob 匹配引擎(include_globs / exclude_globs / allow_ignored_globs,覆盖 fs:list / fs:search / fs:suggest / fs:grep) 手写编译器:a/**/b 可匹配 a/xxb;a/** 不匹配 a 本身;foo** 可跨段匹配 picomatch(标准 bash glob):a/**/b 不再匹配 a/xxb;a/** 也匹配 a 本身;foo** 不再跨段 依赖非标准匹配结果的调用方(desktop、web、SDK 中使用这些 glob 字段的请求) 无(对齐标准语义;行为变化已在 changeset 中声明)
通配符放行的祖先目录可见性 命中通配符段(如 ignored-*)的被忽略目录一律显示 仅当其子树内确有匹配后代时才显示 无(该字段随本 PR 引入,无既有调用方) 不需要
  • 受影响模块:fs:list 端点(session 级)与所有使用 fs glob 字段的端点;list_many 等其他端点未变。
  • 测试覆盖:packages/kap-server/test/fs.test.ts 55 个用例、packages/agent-core-v2/test/workspace/workspaceFs/ 100 个用例全部通过;pnpm lint 0 错误、pnpm typecheck 通过。
  • changeset:CLI 用户对该 server 字段无直接感知,且面向用户的更新记录由 kimi-code-app 侧承载,故 CLI 不加条目(维护者决定);两条内部包条目见 .changeset/fs-list-allow-ignored-globs.md、.changeset/fs-glob-segment-boundary.md。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

…named paths

The list filter keeps gitignored entries hidden unless they match the
new allow_ignored_globs request field, letting callers surface
specific ignored paths (e.g. .tmp) while the rest of gitignore still
applies.
Copilot AI balanced review requested due to automatic review settings September 28, 2026 06:57

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@changeset-bot

changeset-bot Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c97fd65

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

This PR includes changesets to release 6 packages
Name Type
@moonshot-ai/agent-core-v2 Minor
@moonshot-ai/acp-server Patch
@moonshot-ai/kap-server Patch
@moonshot-ai/klient Patch
@moonshot-ai/migration-legacy Patch
@moonshot-ai/remote-control 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 Sep 28, 2026 •

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

commit: c97fd65

@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T10:14:49.178249Z c97fd65 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: a3318e4f23

ℹ️ 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 docs/en/reference/server-api.md Outdated
Comment thread packages/agent-core-v2/src/workspace/workspaceFs/fsService.ts Outdated
…ches

A nested allow glob such as ignored-dir/keep.txt or ignored-dir/** used
to be unreachable in recursive listings because the ignored parent was
skipped before any child could match. Keep an ignored entry when it is a
literal-prefix ancestor of an allowed glob (directories only), and
document that dot-path allowances additionally require show_hidden.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@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: f3a7736c7a

ℹ️ 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/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: f3a7736c7a

ℹ️ 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".

The literal-prefix check still dropped ancestors when a directory
segment of an allow glob contained a wildcard, e.g. ignored-*/keep.txt
or ignored-dir/**/keep.txt. Decide reachability by consuming the
candidate path segment-wise against a prefix of the glob instead.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@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: 7b44ce4004

ℹ️ 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/src/workspace/workspaceFs/fs.ts
Comment thread packages/agent-core-v2/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
Comment thread packages/agent-core-v2/src/workspace/workspaceFs/fsService.ts
Compile **/ to (?:[^/]+/)* so recursive wildcards preserve path
segment boundaries; a/**/b no longer matches a/xxb. This affects
include_globs, exclude_globs, and allow_ignored_globs across
fs:list / fs:search / fs:suggest / fs:grep.

Match glob prefixes iteratively in globCanMatchBelow so deeply
segmented globs cannot exhaust the call stack.

@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: 4e5d155ffb

ℹ️ 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 .changeset/fs-list-allow-ignored-globs.md
Comment thread packages/agent-core-v2/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
foo**/keep.txt regressed when **/ gained segment-boundary semantics:
the stars sat mid-segment but were expanded as a whole-segment
globstar. Only expand **/ when the stars open a path segment, treat
mid-segment stars as an ordinary within-segment wildcard, and keep a
trailing ** matching across segments as before.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@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: 211b2933d6

ℹ️ 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/src/workspace/workspaceFs/fsService.ts
Comment thread packages/agent-core-v2/src/workspace/workspaceFs/fsService.ts
…cestors

Replace the hand-rolled glob compiler with picomatch, the standard
engine already used elsewhere in the package, which settles segment
boundary, mid-segment globstar, and deep-pattern complexity edge
cases for good. An ignored directory kept only as a possible ancestor
of an allow glob is now probed (depth and entry capped, fail-open) and
withheld when no descendant actually matches.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@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: da7280837d

ℹ️ 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/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
Comment thread packages/agent-core-v2/src/workspace/workspaceFs/fsService.ts
wbxl2000
wbxl2000 previously approved these changes Oct 8, 2026
Splitting allow globs on '/' corrupts brace and extglob constructs
that contain slashes; take path segments from picomatch.scan instead
and fall back to a conservative answer for opaque single-token globs,
letting the descendant probe decide visibility with whole-pattern
matching.

Probe budgets are now shared across one fs:list request instead of
resetting per candidate directory, so a tree full of speculative
ancestors cannot multiply filesystem operations.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@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: 6f93b02315

ℹ️ 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/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
Comment thread packages/agent-core-v2/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
picomatch throws on empty patterns where the old compiler simply
never matched, turning previously valid requests into server errors;
filter them out up front. Brace and extglob alternatives that embed
a slash inside one scanned part now fall back to the conservative
ancestor answer as well, leaving visibility to the whole-pattern
descendant probe.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@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: 0f2b2b8fd3

ℹ️ 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/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
A leading exclamation mark was a literal character in the old
matcher, so exclude_globs like !foo only matched a path literally
named !foo; as a picomatch negation the same request would exclude
everything except foo. Pin the prior semantics with nonegate.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@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: c49ff4645b

ℹ️ 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/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
Comment thread packages/agent-core-v2/src/workspace/workspaceFs/internal/fsSearch.ts Outdated
The scan call still used default negation, stripping a literal
leading bang from allowance prefixes like !foo/keep.txt. Consecutive
separators produced empty scanned segments that made picomatch throw
during prefix compilation; empty segments now simply match nothing.

@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: c97fd65f27

ℹ️ 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/src/workspace/workspaceFs/fsService.ts
@liruifengv
liruifengv merged commit 5b93669 into main Oct 8, 2026
25 of 26 checks passed
@liruifengv
liruifengv deleted the feat/fs-list-include-globs branch October 8, 2026 10:21
@github-actions github-actions Bot mentioned this pull request Oct 8, 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.

3 participants