Skip to content

list silently drops files three or more directories deep on Windows #762

Closed

Description

What happened?

list builds its file tree by splitting each directory on /:

const dir = path.dirname(file)              // platform-aware
const parts = dir === "." ? [] : dir.split("/")   // POSIX only

Ripgrep.files passes no --path-separator, so ripgrep prints the host
separator: \ on Windows. The split is POSIX-only while the parent lookup in
renderDir is path.dirname, so on Windows the intermediate directories of a
deep path are never added to dirs and become unreachable.

The result is worse than a formatting difference: the files are collected and
counted, then dropped from the output
. metadata.count reports every file
ripgrep found, while output shows only the root-level ones.

Depth matters, which is why this went unnoticed. On 3e94875c with a workspace
holding root.txt, src/evidence.txt, src/lib/two.txt and a/b/c/deep.txt,
Windows list returns:

<workspace>/
  src/
    lib/
      two.txt
    evidence.txt
  root.txt

a/b/c/deep.txt is silently missing — three or more directories deep is where
the POSIX-only split first breaks. Nothing errors; the model is simply told a
file count it cannot see.

The tree is model-facing text, so cutting it on either separator and always
rendering with / fixes this and makes a listing read the same on every
platform.

Steps to reproduce

  1. In a project, create a file at least three directories deep, e.g.
    mkdir -p a/b/c && echo x > a/b/c/deep.txt.
  2. Ask the agent to list the project on Windows.
  3. Read the tool output: the deep file is absent, and the reported count is
    higher than the number of files shown.

The focused regression in test/tool/ls-tree.test.ts fails on 3e94875c and
passes with the fix: the separator cases are hermetic (they render a backslash
path on any platform), and the integration case drives the real listing.

How did you install OpenScience?

From source (bun dev).

OpenScience version

Source commit 3e94875c.

Provider and model

Not applicable; the defect is in the tool's file listing, before any model call.

Operating system

Windows is where it reproduces, because path.sep is \ there. The same code
renders correctly on macOS and Linux, where ripgrep already prints /.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions