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

use rules in auto-edit #6930

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

use rules in auto-edit #6930

wants to merge 2 commits into from

Conversation

sqs
Copy link
Member

@sqs sqs commented Feb 4, 2025

TODO

Rules work well in chat and inline edit but not in auto-edit. I separated out the PR to apply rules in auto-edit so that we can work on improving this later. See @hitesh-1997's comment at https://sourcegraph.slack.com/archives/C085U078XE0/p1738413947012609?thread_ts=1738405616.264529&cid=C085U078XE0 for more pointers.

sqs added a commit that referenced this pull request Feb 5, 2025
For our code review agent (announced in EAP in
https://sourcegraph.com/blog/introducing-enterprise-ai-agents), we're
introducing rules that are `*.rule.md` files placed in `.sourcegraph/`
dirs in your codebase. The code review agent uses these rules to find
and fix issues at code review.

This PR makes it so that Cody in the editor also reads the rules and
uses them in chat and inline edit for higher quality and consistency. It
is behind the `"cody.rules.enabled": true` VS Code user setting, which
is marked as `experimental`.

Docs and blog post coming soon after we've merged this and tested it in
our own dev workflows.

- Closes https://linear.app/sourcegraph/issue/CODY-4829.
- Depends on sourcegraph/sourcegraph#3305.
- Depends on #6932.
- Depends on #6931.
- See related #6930, which makes
rules work in auto-edit.


https://github.com/user-attachments/assets/4d193edc-bdaf-4081-bbf3-c657f91a2bbe


![image](https://github.com/user-attachments/assets/bfee6f0b-1e4d-48d9-8651-8857455f9983)


![image](https://github.com/user-attachments/assets/fb51d77a-4440-4e33-bf3d-55189bc468e3)

## Known issues

- [ ] The `text_content_filters` and `repo_filters` rule fields are not
yet implemented.
- [ ] Editor (not sidebar) chat does not show the rules for the file in
the other pane because it's not active
- [ ] There are Node.js FS errors printed to the debug console when
looking for `.sourcegraph` dirs. These are perhaps not being properly
suppressed.

## Test plan

1. Set `"cody.rules.enabled": true` in your VS Code settings.
1. Clone the https://github.com/sourcegraph/review-agent-sandbox
repository.
1. Open it in VS Code.
1. Open `handler_review.go`.
1. Open Cody chat. Ensure that it shows `N rules` in the chat. Run a
chat and ensure it uses the rules. (It should say so in the response.)
1. Run an inline edit. Ensure that the `Rules` are listed in the inline
edit initially right when you press <kbd>Opt+K</kbd> and then that the
rules apply.
1. Try modifying a rule or creating a new one in
`.sourcegraph/*.rule.md`. Ensure that it starts showing up in chat.

There are no e2e tests yet; this is just being enabled for experimental
dogfooding internally.
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.

1 participant