Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support absolute path in "include" #368

Open
rockmandash opened this issue Feb 23, 2025 · 3 comments
Open

Support absolute path in "include" #368

rockmandash opened this issue Feb 23, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@rockmandash
Copy link

Sometimes I need to reference files or directory outside current project, if I do this:

{
  "include": [
    "/Users/joseph/Work/company/company-components/src/Inputs/Checkbox/"
  ]
}

it outputs error:

Error filtering files: path should be a `path.relative()`d string, but got
@yamadashy yamadashy added the enhancement New feature or request label Feb 24, 2025
@yamadashy
Copy link
Owner

Thanks for the suggestion @rockmandash!

You're right - using absolute paths would be a simpler way to reference files outside the current directory.
Let me look into implementing this feature.

@yamadashy yamadashy self-assigned this Feb 24, 2025
@yamadashy
Copy link
Owner

After some consideration, I think we can handle this case better by adding rootDirs to the config.

The include option is specifically designed for pattern matching within the root directories - it defines what files to include from each root directory (like **/*.ts to match TypeScript files).

Currently, you can specify root directories through CLI:

repomix /path/to/dir1 /path/to/dir2

What if we add support for the same functionality in the config file?

{
  "rootDirs": [
    "/Users/joseph/Work/company/company-components/src/Inputs/Checkbox/",
    "./src",
    "../shared-lib"
  ],
  "include": [
    "**/*.ts",
    "**/*.js"
  ]
}

Would this approach work for you?

@rockmandash
Copy link
Author

I understand what you’re getting at. Instead of using **dirname as the base name directly, you rely on the **dirname defined in repomix.config.json. That part makes sense.

However, I’m a bit confused about how the new rootDirs works—specifically, if I include something like "**/*.ts", wouldn’t it end up pulling in TypeScript files from all three projects when I only want those from Project 1?

One workaround might look like this:

{
  "include": [
    {
      "basePath": "/Users/joseph/Work/project1",
      "include": ["**/*.ts"]
    },
    {
      "basePath": "/Users/joseph/Work/project2",
      "include": ["**/*.js"]
    }
  ]
}

This way, I can isolate which directories and file types I’m including from each project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants