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 Language Server Protocol (LSP) to re-implement all code editing #1934

Open
5 tasks
xingyaoww opened this issue May 21, 2024 · 11 comments
Open
5 tasks

Use Language Server Protocol (LSP) to re-implement all code editing #1934

xingyaoww opened this issue May 21, 2024 · 11 comments
Labels
agent framework Strategies for prompting, agent, etc architecture Related to architecture, including frontend and backend enhancement New feature or request large effort Estimated large effort

Comments

@xingyaoww
Copy link
Contributor

xingyaoww commented May 21, 2024

What problem or use case are you trying to solve?

OpenDevin now sometimes suffers with edit command (concrete example: #1928).

Describe the UX of the solution you'd like

As suggested by a friend @ganler, maybe it is more like a fundamental solution if we can gradually replace all the swe-agent tools to interface with a Language Server Protocol:

image

It gives us the ability to:

  1. Open file
  2. Change/edit file
  3. Go to the definition of a symbol
  4. More importantly, this is actually scale to multiple programming languages!

Do you have thoughts on the technical implementation?

  • Starts with translating the existing bash command's implementation to an API call to the language server (e.g., open, edit, etc)
  • Figure out a better interface for editing -- current HEREDOC + bash causes many weird issues. Can we potentially use IPython capability for editing, write these file operation functions in Python, and have the model write and execute Python cells to perform file operations? -- can directly wrap around https://github.com/microsoft/monitors4codegen?tab=readme-ov-file#4-multilspy
  • Support more advanced features, like going to the definition
  • Automatically supports multiple language servers for most existing programming languages.
  • Show VSCode warning / problems

Describe alternatives you've considered

Additional context

@xingyaoww xingyaoww added enhancement New feature or request architecture Related to architecture, including frontend and backend agent framework Strategies for prompting, agent, etc labels May 21, 2024
@xingyaoww xingyaoww added this to the 2024-07 milestone May 21, 2024
@li-boxuan
Copy link
Collaborator

li-boxuan commented May 21, 2024

Oh nice! I have worked with LSP before! I could probably contribute to this.

@ganler
Copy link

ganler commented May 21, 2024

LSP has a general interface to interact with. But if we want to start with some very easy, Jedi can be a great starter in my experience. :)

https://jedi.readthedocs.io/en/latest/docs/api.html#examples

@ganler
Copy link

ganler commented May 21, 2024

For more general cases of interactions, monitors4codegen has some examples using multilspy to interact with some LSP implementations.

https://github.com/microsoft/monitors4codegen#4-multilspy

@casper-hansen
Copy link

FYI, Devin (the closed one) is fully integrated with VS Code. That means it has access to all the extensions, linting, and debugging tools. I think this is something to consider

@frankxu2004
Copy link
Collaborator

frankxu2004 commented May 21, 2024

I wonder if LSP can also actually edit the files, in addition to just monitoring file changes (usually user-triggered) and provide completion suggestions, etc.

For the VSCode solution, maybe incorporating the full VScode is heavy, but the underlying editor of vscode, monaco, could be a good option. Alternatively, CodeMirror is also quite minimalist. These editors usually maintain editor state, including undo stack as well so that if the agent is doing something wrong, we can let it call "undo" function.

For the edit command replacement, the closest might be: https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.ICodeEditor.html#executeEdits , or https://codemirror.net/examples/change/

@ramsey-coding
Copy link

Is it a good idea to incorporate complex LSP protocol with agent?

@ganler
Copy link

ganler commented May 22, 2024

I wonder if LSP can also actually edit the files, in addition to just monitoring file changes (usually user-triggered) and provide completion suggestions, etc.

For the VSCode solution, maybe incorporating the full VScode is heavy, but the underlying editor of vscode, monaco, could be a good option. Alternatively, CodeMirror is also quite minimalist. These editors usually maintain editor state, including undo stack as well so that if the agent is doing something wrong, we can let it call "undo" function.

For the edit command replacement, the closest might be: https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.ICodeEditor.html#executeEdits , or https://codemirror.net/examples/change/

LSP models cursors and code locations & ranges. And knowing the locations it's easy to insert code, isn't it ;).

@frankxu2004
Copy link
Collaborator

Good point. @ganler I wonder who maintains the cursor and code location states? (the editor states). For a real editor there's actual editor states, but it seems like we still have to maintain an "headless" editor in the backend

@0xdevalias
Copy link

This may also be another alternative/useful exploration:

@xingyaoww xingyaoww removed this from the 2024-07 milestone Jul 5, 2024
@xingyaoww xingyaoww removed their assignment Jul 5, 2024
@mamoodi mamoodi added the large effort Estimated large effort label Jul 6, 2024
Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Inactive for 30 days label Aug 11, 2024
@xingyaoww xingyaoww removed the Stale Inactive for 30 days label Aug 13, 2024
Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Inactive for 30 days label Sep 20, 2024
@enyst enyst removed the Stale Inactive for 30 days label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent framework Strategies for prompting, agent, etc architecture Related to architecture, including frontend and backend enhancement New feature or request large effort Estimated large effort
Projects
None yet
Development

No branches or pull requests

9 participants