-
Notifications
You must be signed in to change notification settings - Fork 209
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
feat: filter context with .cody/.ignore #1382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff! Left some early comments but feel free to ignore
Co-authored-by: Philipp Spiess <hello@philippspiess.com>
@DanTup Thank you so much for reviewing this PR! Updated the PR to address your very helpful feedback, especially the point regarding handling relative file paths in isCodyIgnoredFile:
I haven't looked into passing the entire ignore file which seems to make things a lot easier, will continue the discussion with you on Slack! |
--------- Co-authored-by: Beatrix <68532117+abeatrix@users.noreply.github.com>
Q:
What's the motivation behind this vs. making the existence of a |
/** | ||
* The Cody ignore file path in POSIX style (always forward slashes). | ||
*/ | ||
export const CODY_IGNORE_FILENAME_POSIX_GLOB = path.posix.join('**', '.cody', '.ignore') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice the PR title and description mentions .codyignore
, while the code here seems to suggest .cody/.ignore
. (not commenting on the awkwardness of two .
files..)
which one is right / expected to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be .cody/.ignore! Will attach the RFC to the issue to clarify! RFC 852 File Exclusion Patterns for Cody
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite useful to us on the Cody strat team, thank you for working on this!
I wanted to emphasize on the fact that this feature is still in experimental and unstable (not throughly tested so users must manually enable this feature to confirm before they can test it out. I'm thinking once we have tested this internally and have .Cody/.ignore working for embedding jobs, we can have it enabled by default. Do you think this is a good idea, or am I overthinking 😂? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a few minor comments (although I'm less familiar with some of this code so you may want another reviewer too).
} | ||
} | ||
|
||
await extension?.activate().then(() => init()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to worry about any exceptions here (for example if you disable the Git extension does it throw?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh i added try catch to this for cases where Git extension is disabled. we probably will need to do some follow up works on UX improvement but I think what we have is a good start. I am going to do some final testings before I merge it but consider this is currently behind the cody.internal.unstable
config flag, i think we should be good 🙏
Thank you so much for your help and your throughout review 🙇♀️
CLOSE #1049
For details, please see RFC 852 File Exclusion Patterns for Cody
feat: filter context from ignored files
isCodyIgnoreFile
utility to check if file is defined in .cody/.ignore (at workspace level).env
files / path by defaultAll clients should provide file content from the .cody/.ignore file at start up, and update the ignoreList when the file is changed.
Note
This PR includes update to the VS Code clients so that the ignore list is set at Editor start up, and whenever the .cody/.ignore file is updated, the ignore list will be updated accordingly.
This does not make any changes to the current embedding steps or BFG, which will be a feature to be implemented in the future as listed by Dom in the discussion below.
.cody/.ignore
nameTest plan
Prep:
cody
repositoryChat
Ask cody about fixup in Chat View: "what is fixup?"
You should see Cody did not read any files from the
vscode
directory to answer your question:Autocomplete
Go to any of the file inside the
vscode
directory, you should not get any autocomplete suggestions.Command
Go to lib/shared/src/utils.ts file, and then select some code, right click and select
![image](https://private-user-images.githubusercontent.com/68532117/274679069-37f2626e-4aeb-4fe7-af56-1bc6ba16ef8a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkxNjg4MzcsIm5iZiI6MTcxOTE2ODUzNywicGF0aCI6Ii82ODUzMjExNy8yNzQ2NzkwNjktMzdmMjYyNmUtNGFlYi00ZmU3LWFmNTYtMWJjNmJhMTZlZjhhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjIzVDE4NDg1N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE5NDVhODZjMzkzYmRmYTM1MjdjNmZkYTVmYTUxOWRlMjdkZjA2MDNiN2ZkMWRmZDY5ZGRkMWE0YmMzODM0ZTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.C4GUDcEZ-TpjrfdxLZI2B0q96UwQ6gOPNSqrlAkPzyo)
Explain Code
:You should see cody explain a random code (hallucinating because we didn't provide any code as context) that is not your selected code.
You can check the output channel to confirm no context was sent to the LLM:
Demo
DEMO_.cody_.ignore.file.mp4
Update
Here is a loom video of codyignore working in Simple chat panel:
https://www.loom.com/share/83fe3e0b0728449385d130d45c317cfa