Skip to content

feat: include gitignored files in file suggestions - #4752

Merged
sailist merged 8 commits into
mainfrom
feat-340-11-05-mention-gitignored-files
Nov 10, 2026
Merged

sailist merged 8 commits into
mainfrom
feat-340-11-05-mention-gitignored-files

Conversation

@sailist

@sailist sailist commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Kimi Code CLI 的 @ 文件补全和 kap-server 文件搜索调用方需要引用被 .gitignore 排除的构建产物、临时目录等文件。当前这些候选默认被过滤,即使显式纳入,也可能因排序和 limit 截断而找不到精确匹配;本 PR 让本地/远程补全与搜索能够返回这些文件,并保持高相关结果优先。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路是在候选选取阶段区分普通文件与忽略文件,而不是在最终响应上重排。各搜索路径先扫描普通候选,仅在启用忽略文件且现有结果仍可能包含更优匹配时补充 no-ignore 扫描,再去重并执行 Top-N;匹配质量始终是第一排序键,ignored 只是同一匹配质量内的次级键,因此精确的忽略目录不会被大量普通弱匹配挤出结果。

flowchart LR
    A[文件搜索或 @ 补全] --> B[普通候选扫描]
    B --> C{包含忽略文件且仍需补充?}
    C -- 否 --> F[排序并截取 Top-N]
    C -- 是 --> D[no-ignore 补充扫描]
    D --> E[去重并标记 ignored]
    E --> F
    F --> G[匹配质量优先,同质量普通文件优先]
Loading

补充扫描复用原 deadline 和 abort signal。显式要求遵守 .gitignore 的调用不会增加第二次扫描,响应结构也没有新增字段。

  • 服务端搜索:fs:search 与 fs:suggest 省略 follow_gitignore 时默认包含忽略文件,显式 true 仍过滤。ripgrep、Node fallback、空查询和多 root 共用相同的分组语义;非空搜索按 exact / prefix / weak 分层,点开头的 suggest 查询自动启用隐藏项匹配。
  • Kimi @ 补全:本地 fd 路径通过默认关闭的 includeGitignoredFiles 扩展点补扫,Kimi 入口显式开启;无 fd 时在 Git 工作树内批量调用 git check-ignore --no-index 分类,失败时保留原有补全可用性。远程 TUI 显式请求包含忽略文件并保留服务端顺序,.git 始终排除。
  • Node SDK:SuggestFilesInput 新增可选 followGitignore。SDK 调用方省略时仍默认 true,只有显式传 false 才包含忽略文件,避免扩大服务端默认值变化的影响面。
  • 输入调度:pi-tui 增加可选的 provider debounce 与预览钩子。Kimi @ 连续输入使用 80ms debounce,严格追加查询时先筛选上一轮权威结果,尾随搜索始终执行并替换预览;首次 @ 和显式 Tab 仍立即请求,其他 provider 保持 20ms 和无预览行为。
  • 配套说明:补充 pi-tui UPSTREAM intent cards、CLI 与 pi-tui changesets,并同步中英文文件引用和 Server API 文档。

建议先读 packages/agent-core-v2/src/workspace/workspaceFs/fsService.ts 理解两阶段选取,再读 packages/pi-tui/src/autocomplete.ts 和 apps/kimi-code/src/tui/components/editor/file-mention-provider.ts 看本地补全如何复用同一排序原则;packages/pi-tui/src/components/editor.ts 只负责调度与预览。SDK 参数透传、中英文文档和测试可随后阅读。

Screenshots / Recordings

在本机 fd 路径上,对同一个中性 Git fixture 分别运行基线与 PR 代码。以下是真实输出:基线只返回普通弱匹配,PR 将精确的忽略目录 @.tmp/ 排在首位。

Before After
Input: @.tmp
@weak-one.tmp.ts
@weak-two.tmp.ts
@weak-three.tmp.ts
Input: @.tmp
@.tmp/
@weak-one.tmp.ts
@weak-two.tmp.ts
@weak-three.tmp.ts

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
kap-server fs:search / fs:suggest 省略 follow_gitignore 默认 true,过滤忽略文件 默认 false,包含忽略文件并可能执行一次补充扫描 直接调用 kap-server HTTP 且省略该字段的客户端 显式传 follow_gitignore: true,保留单次过滤扫描
包含忽略文件时的搜索排序 忽略候选与普通候选混排,普通弱匹配可能挤掉精确忽略匹配 先比较匹配质量,再在同质量内让普通候选优先;空查询同样分组 显式传 false 的 HTTP 调用方,以及远程 Kimi @ 补全 无;响应字段和 truncated 形状不变
点开头的 suggest 查询 需要显式 show_hidden: true 才能匹配隐藏路径 自动启用隐藏项匹配;其他查询的 show_hidden 默认值不变 使用 .tmp 等点开头查询的 HTTP 与补全用户 无;只改变点开头查询
Node SDK suggestFiles 忽略状态硬编码为 follow_gitignore: true 新增 followGitignore?: boolean;省略仍为 true,显式 false 才包含 所有 Node SDK 调用方 省略参数或显式传 true 即保持旧行为
Kimi 本地与远程 @ 文件补全 被 Git 忽略的文件不出现在候选中 包含忽略文件,同一匹配质量内后置;多 root 去重,.git 仍排除 Kimi Code CLI TUI 用户 无单独开关;fd 仍尊重 .ignore 与 .fdignore
无 fd 的 filesystem fallback 基础扫描后不区分 ignored Git 工作树内批量标记并分组;非 Git 目录或 Git 调用失败时保持原行为 没有 fd 的本地 TUI 环境 自动降级,无需配置
pi-tui 自动补全调度 所有 provider 使用既有 20ms debounce,无旧结果预览 provider 可配置 debounce 与预览;Kimi @ 为 80ms,其他 provider 默认不变 其他 pi-tui provider 与普通路径补全 不配置新增可选能力即保持旧行为

受影响模块与覆盖:

  • agent-core-v2 / kap-server:覆盖 ripgrep 与 Node fallback、空查询、多 root、默认包含、显式过滤、精确忽略候选、隐藏查询、limit / truncated 和补扫跳过条件。
  • Node SDK / TUI:覆盖 SDK 默认过滤与显式包含、远程参数、fd 与 filesystem fallback、多 root、同分排序、无 fd 降级和 .git 排除。
  • pi-tui Editor:覆盖首次立即请求、80ms debounce、追加查询预览、删除不 narrowing、空预览、尾随权威搜索以及旧请求晚到不覆盖新结果。
  • 公开内容:完整 diff 已通过敏感信息扫描和独立只读审计,没有真实内部标识或临时文件。
验证结果与未覆盖范围
  • rebase 到 main@origin 后,在 m0-dev 运行 5 个相关 Vitest 文件:487 passed / 3 skipped。
  • rebase 后在 m0-dev 运行 pi-tui 全包 node --test:1149 passed / 2 skipped。
  • 在本机 macOS 使用真实 fd 对同一 fixture 运行基线与 PR,得到上面的前后输出。
  • kimi-code-docs 的 VitePress 构建通过;仅有既有的 ES2024 target 与 chunk 大小警告。
  • 未运行 Windows 专项或全仓全量测试;远程 HTTP/SDK 取消接线仍是既有边界,本 PR 的 debounce 与预览不宣称解决该问题。

Checklist

  • I have read the CONTRIBUTING document.
  • Related issue: N/A (internal feature request, not an external PR).
  • 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.

@changeset-bot

changeset-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a8cd5f4

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

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/pi-tui Minor
@moonshot-ai/kimi-code Minor

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T07:18:52.593834Z ab0999a 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.

@pkg-pr-new

pkg-pr-new Bot commented Nov 9, 2026 •

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

commit: a8cd5f4

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

ℹ️ 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 on lines +943 to +946
100,
options.signal,
undefined,
true,

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 Avoid capping the ignored fd pass before exact matches

When more than 100 ordinary paths match the query, this supplemental fd invocation can exhaust --max-results 100 before emitting an exact gitignored file, so the feature still omits the best ignored match. For example, with 150 tracked weak-zzz-*.ts files and an ignored file named zzz, the no-ignore invocation returns 100 weak files and never returns zzz; deduplication then adds nothing. The ignored pass needs to avoid being consumed by already-seen ordinary results or search deeply enough to select the global top 20.

AGENTS.md reference: packages/pi-tui/AGENTS.md:L3-L5

Useful? React with 👍 / 👎.

Comment on lines +1057 to +1058
if (!query.followGitignore && (matched <= cap || top.worst?.tier !== 3) && !signal.aborted && Date.now() < deadline) {
await runPass(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve time for the ignored fallback scan

In an environment without ripgrep, a large or slow workspace can consume the entire 10-second deadline during the ordinary first pass, making this condition false and preventing the no-ignore pass from running at all. This regresses explicit follow_gitignore: false callers: the old single no-ignore walk could return an ignored entry encountered early, while the new path always spends the budget excluding it first. Split or interleave the budget so ignored candidates remain reachable before the shared deadline.

AGENTS.md reference: AGENTS.md:L125-L127

Useful? React with 👍 / 👎.

Comment on lines +2487 to +2489
if (preview.items.length === 0) {
this.autocompleteList = undefined;
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep autocomplete controls active for an empty preview

When appended text filters the preview to zero items, this removes the list but leaves autocompleteState active until the trailing request completes. During that interval, the input handler skips both the list-control branch and the !autocompleteState Tab branch, so Tab is silently ignored and Escape cannot cancel the picker; for a slow remote request this can last seconds rather than only the 80 ms debounce. Clear the autocomplete state with the list or teach the no-list pending state to handle these controls.

AGENTS.md reference: packages/pi-tui/AGENTS.md:L11-L15

Useful? React with 👍 / 👎.

if (signal.aborted) break;
const git = resolveCommandPath('git', root);
if (git === undefined) continue;
const result = spawnSync(git, ['check-ignore', '--no-index', '--stdin', '-z'], {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not block the TUI while classifying ignored files

Whenever fd is unavailable, every authoritative @ completion now runs git check-ignore through spawnSync on the editor's event-loop thread. The call can block for its full one-second timeout for each workspace root, cannot react to the autocomplete abort signal, and the initial bare @ request runs immediately, so a slow repository or several additional roots freeze input and rendering for multiple seconds. Use an asynchronous child process or cached classification instead.

Useful? React with 👍 / 👎.

Comment on lines 937 to 940
if (!seenDirs.has(dirKey)) {
seenDirs.add(dirKey);
const candidate = evaluateSuggestCandidate(dir, 'directory', query);
const candidate = evaluateSuggestCandidate(dir, 'directory', query, ignored);
if (candidate !== null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Classify derived directories independently from ignored children

In the ripgrep path, every directory derived during the supplemental pass inherits ignored: true from the child file, even when only the contents are ignored. For example, with .gitignore containing build/* and only build/generated.js present, the ordinary pass emits nothing under build, while the no-ignore pass derives build here and ranks it as ignored although the directory itself is not ignored. Under a tight result cap, ordinary exact matches can therefore displace this directory; before the change, the single no-ignore pass ranked it normally. Determine the directory's own ignore status rather than inheriting the pass label.

AGENTS.md reference: AGENTS.md:L125-L127

Useful? React with 👍 / 👎.

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

ℹ️ 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 on lines +831 to +832
if (!(await this.hostFs.stat(candidate)).isDirectory) continue;
scoped.push({ ...root, baseDir: root.dir, dir: candidate, scanBase, scoped: true });

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 Reject external symlinks before narrowing search roots

When a slash-containing query names a symlink to a directory outside the workspace, stat() follows the link and this code promotes it to a search root. Both the explicit ripgrep path and the Node walk then enumerate the external target; for example, link/secret can reveal filenames under an out-of-workspace directory even though normal filesystem operations reject external symlinks unless explicitly allowed. Validate the candidate's real path against the configured roots before scoping to it.

AGENTS.md reference: AGENTS.md:L125-L127

Useful? React with 👍 / 👎.

const candidate = this.path.resolve(root.dir, scanBase);
try {
if (!(await this.hostFs.stat(candidate)).isDirectory) continue;
scoped.push({ ...root, baseDir: root.dir, dir: candidate, scanBase, scoped: true });

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 Preserve parent ignore rules in scoped fallback scans

When ripgrep is unavailable or fails, a slash query that resolves to an existing subdirectory changes the Node walk root here, so the later walkIgnoreFor(root.dir) reads only that subdirectory's .gitignore. With a root rule such as build/**, follow_gitignore: true plus query build/generated now returns build/generated.js, whereas the previous root-level walk filtered it; keep ignore matching anchored to baseDir while scanning the narrower directory.

AGENTS.md reference: AGENTS.md:L125-L127

Useful? React with 👍 / 👎.

const candidate = this.path.resolve(root.dir, scanBase);
try {
if (!(await this.hostFs.stat(candidate)).isDirectory) continue;
scoped.push({ ...root, baseDir: root.dir, dir: candidate, scanBase, scoped: true });

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 Preserve workspace-wide fuzzy path matching

When the first query segment happens to name an existing directory, this scopes the scan to that directory even though path queries are fuzzy subsequence matches rather than anchored prefixes. For example, if apps/ exists but the valid match is examples/apps/demo.ts, querying apps/de previously found that file through matchSuggestPath; the scoped scan now searches only apps/ and can return nothing. Keep the workspace-wide fallback or merge it with scoped results so an optimization does not narrow the accepted query semantics.

AGENTS.md reference: AGENTS.md:L125-L127

Useful? React with 👍 / 👎.

Comment on lines +827 to +831
for (let length = segments.length; length >= 1; length -= 1) {
const scanBase = segments.slice(0, length).join('/');
const candidate = this.path.resolve(root.dir, scanBase);
try {
if (!(await this.hostFs.stat(candidate)).isDirectory) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bound prefix probing by the suggestion deadline

For a slash-containing query with many nonexistent suffix segments, this loop performs one awaited stat per progressively shorter prefix and per workspace root, while the 10-second deadline is not created until after scopeSuggestRoots returns. On remote filesystems each probe is an RPC, so a long pasted or API-supplied path can keep fs:suggest running far beyond its advertised timeout. Start the deadline before probing and abort or cap these sequential lookups.

Useful? React with 👍 / 👎.

@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: 5c477e35d1

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

let capped = false;
for (const root of roots) {
const matcher = req.follow_gitignore ? await this.matcherFor(root.dir) : undefined;
const matcher = await this.matcherFor(root.dir);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid caching ignore rules during unignored requests

When a long-lived workspace first makes a request with follow_gitignore: false, this unconditional matcher lookup now populates gitignoreCache; if .gitignore is then edited, a subsequent explicit follow_gitignore: true request reuses the stale rules and silently returns newly ignored paths. Before this change, unignored requests used WALK_DEFAULT_IGNORE without populating that cache. The same new behavior occurs in the non-empty search and Node suggestion passes, so either invalidate/version the cache when .gitignore changes or avoid caching rules merely to classify an unfiltered scan.

AGENTS.md reference: AGENTS.md:L109-L111

Useful? React with 👍 / 👎.

if (signal.aborted) break;
const git = resolveCommandPath('git', root);
if (git === undefined) continue;
const result = spawnSync(git, ['check-ignore', '--no-index', '--stdin', '-z'], {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Classify ignored files outside Git repositories

When fd is unavailable in a non-Git workspace that still has a .gitignore, git check-ignore --no-index exits 128 because it requires a repository, and this branch consequently leaves every candidate marked as non-ignored. Equal-quality ignored paths are then ordered alphabetically with ordinary paths and can displace them from the 50-item fallback result, contradicting the newly documented behavior for non-Git directories. Use an ignore classifier that can read .gitignore without requiring a .git directory.

Useful? React with 👍 / 👎.

}) || inventoryTruncated;
const runPass = async (ignored: boolean): Promise<void> => {
for (const root of roots) {
const ignoreRules = ignored ? WALK_DEFAULT_IGNORE : await this.walkIgnoreFor(root.dir);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply nested ignore files in Node fallback ordering

When an ignored file is covered by a descendant rule such as a/.gitignore rather than the workspace-root .gitignore, this ordinary pass still emits and labels it as non-ignored because walkIgnoreFor(root.dir) only loads the root file. For example, equal-quality a/foo.ts (ignored by a/.gitignore) and z/foo.ts are sorted with a/foo.ts first, contrary to the new ordinary-before-ignored contract; this affects every fs:search request and fs:suggest when ripgrep is unavailable. Compose per-directory ignore rules or use an authoritative ignore-aware scanner for classification.

Useful? React with 👍 / 👎.

Comment on lines +780 to +781
if (VCS_METADATA_DIRS.has(queryLower.replace(/\/+$/, ''))) {
return { items: [], truncated: false };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve fuzzy matches for VCS-like query names

When the fuzzy query is exactly .git (or another configured VCS directory name), this new query-level short circuit returns no results at all, suppressing legitimate candidates such as .gitignore, .gitattributes, .gitkeep, and .github; remote TUI users therefore get an empty picker for @.git. Candidate-level filtering already excludes paths whose segment is actually .git, so retain that filtering without rejecting the entire fuzzy query. The same regression is present in search().

AGENTS.md reference: AGENTS.md:L109-L111

Useful? React with 👍 / 👎.

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

ℹ️ 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 on lines +214 to +215
if (target.fdQuery.includes('/')) args.push('--full-path');
if (target.fdQuery) args.push(fdPathQuery(target.fdQuery));

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 Preserve fuzzy matching before filtering with fd

When fd is available, passing fdPathQuery(target.fdQuery) to fd filters the inventory using a contiguous regex before the existing fuzzy scorer sees it. An established subsequence query such as rdm previously matched README.md through evaluateSuggestCandidate, but fd emits no candidate for that query, so the same fs:suggest request now silently returns no result depending on whether fd is installed. Translate each query segment into the same subsequence semantics or avoid using the query to prefilter fd output.

AGENTS.md reference: AGENTS.md:L109-L111

Useful? React with 👍 / 👎.

Comment on lines +118 to +120
for (const binary of ['fd', 'fdfind']) {
const result = await probe.exec([binary, '--version']).catch(() => ({ exitCode: -1 }));
if (result.exitCode === 0) return { path: binary, source: 'system-path' };

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 Resolve fd probes outside the workspace on Windows

On Windows, when the requested workspace contains an fd.exe or fdfind.exe, probing these bare command names with the workspace as cwd can execute that file before falling back to the managed binary. This is reachable from the new fs:suggest path, including its absolute-root endpoint, so merely requesting suggestions for an untrusted checkout can run repository-controlled code. Resolve PATH hits to trusted absolute paths, or run the probe from a directory that cannot be controlled by the workspace.

Useful? React with 👍 / 👎.

Comment on lines +203 to +207
'--base-directory', target.baseDir,
'--max-results', '100',
'--type', 'f',
'--type', 'd',
'--hidden',

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 Honor show_hidden in fd-backed suggestions

When fd is available, this unconditional --hidden makes show_hidden: false ineffective for every non-dot query, so a request such as query: "env", show_hidden: false can now return .env or files below hidden directories even though the same request still filters them in the ripgrep and Node paths. Because managed fd availability determines which behavior callers receive, preserve the existing option by passing the effective hidden setting into this backend rather than always enabling it.

AGENTS.md reference: AGENTS.md:L109-L111

Useful? React with 👍 / 👎.

Comment on lines +220 to +222
if (result.exitCode !== 0 || result.stdout.length === 0 || options.signal.aborted) {
return { target, entries: [], capped: false };
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fall back when fd exits with an error

If an installed fd exits nonzero—for example because the selected root is unreadable or the installed version rejects one of these flags—this converts the error into an empty group, and suggestWithFdEvents then emits a successful empty final response. The surrounding suggest() fallback only runs when the fd path throws, so affected users silently lose all suggestions instead of reaching the existing ripgrep/Node implementation; propagate nonzero exits while retaining the empty-success handling for a genuine zero-exit no-match.

AGENTS.md reference: AGENTS.md:L125-L127

Useful? React with 👍 / 👎.

Comment on lines +533 to +537
if (stream) {
await sendSuggestStream(environmentFs, suggestRequest, reply, req.id);
} else {
const data = await environmentFs.fs.suggest(suggestRequest);
reply.send(okEnvelope(data, req.id));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Describe the NDJSON response in the route contract

For stream: true, this branch hijacks the reply and returns application/x-ndjson, but the route still declares only success: { data: fsSuggestResponseSchema }, so /openapi.json advertises the ordinary JSON envelope for the newly exposed streaming input. External desktop/web clients generated or validated from that contract can consequently try to parse the multi-record body as one JSON response; expose the streaming media type and event schema in the route contract, or use a separately described streaming endpoint.

AGENTS.md reference: AGENTS.md:L121-L123

Useful? React with 👍 / 👎.

Comment on lines +895 to 897
}
yield { phase: 'final', response: await this.suggest(req, externalSignal) };
} finally {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse the original timeout in streamed fallback

When fd is unavailable or fails before the outer 10-second timer expires, this calls suggest() with externalSignal rather than the already deadline-bound signal; suggest() then starts a fresh 10-second timer. On a slow remote environment, the initial fd probes can therefore consume several seconds and the ripgrep/Node fallback can consume another full timeout, making a streamed suggestion request run well beyond the intended shared budget. Pass the combined outer signal or the original absolute deadline into the fallback.

Useful? React with 👍 / 👎.

"@moonshot-ai/kimi-code": minor
---

Align `fs:suggest` with local fd completion, using bounded scans and at most 20 results with optional streamed previews, while including hidden and gitignored paths by default and placing regular files first at equal match quality.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Name the fs:search default loss in the changeset

HTTP clients that omit follow_gitignore from fs:search previously filtered ignored paths and now include them, with explicit follow_gitignore: true as the escape hatch, but this changeset only names fs:suggest. As a result the release changelog gives existing search clients no warning that their default result set expands; update the user-facing sentence to name the lost filtering behavior and its explicit-true escape hatch.

AGENTS.md reference: AGENTS.md:L113-L115

Useful? React with 👍 / 👎.

Grapedge
Grapedge previously approved these changes Nov 10, 2026
- default file-search requests to include gitignored files while preserving explicit filtering
- prioritize exact and prefix matches and reveal dot-prefixed queries
- add release notes for the CLI and autocomplete changes
Short-circuit exact VCS queries and scope path searches to existing prefixes with fuzzy fallback.
Push subsequence globs into ignored ripgrep passes while preserving hidden paths and ignore semantics.
@sailist
sailist force-pushed the feat-340-11-05-mention-gitignored-files branch from e1c8fe1 to ab0999a Compare November 10, 2026 07:12

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

ℹ️ 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 on lines +201 to +208
const args = [
options.fdBinary,
'--base-directory', target.baseDir,
'--max-results', '100',
'--type', 'f',
'--type', 'd',
'--hidden',
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Enable fd gitignore filtering outside Git repositories

When fs:suggest runs in a non-Git directory that still has a .gitignore, this ordinary fd pass includes the ignored paths because it never passes --no-require-git; they are then recorded as ordinary candidates, so follow_gitignore: true does not filter them and false cannot rank them after regular files. Checked fdfind --help, which documents --no-require-git as the mode that respects Git ignore rules regardless of whether the search is inside a repository; the fd invocation in packages/pi-tui/src/autocomplete.ts has the same omission. Preserve the old Node-backed behavior by enabling that mode for the ordinary pass.

AGENTS.md reference: AGENTS.md:L125-L127

Useful? React with 👍 / 👎.

Comment on lines +205 to +207
'--type', 'f',
'--type', 'd',
'--hidden',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include symlinks in fd-backed suggestions

When fd is available, these filters request only files and directories, so symlinks disappear from suggestions; this is especially visible for an empty query, which previously used suggestTopLevel() and returned top-level entries with kind: 'symlink'. Checked fdfind --help, which documents symlinks as a separate --type symlink category, so neither --type file nor --type directory includes them. Add the symlink type and preserve its kind so bare @ completion does not silently lose existing links.

AGENTS.md reference: AGENTS.md:L125-L127

Useful? React with 👍 / 👎.

@sailist
sailist merged commit 5aa81c5 into main Nov 10, 2026
16 checks passed
@sailist
sailist deleted the feat-340-11-05-mention-gitignored-files branch November 10, 2026 09:30
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