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

Add support for change sets via tool functions #14715

Merged
merged 4 commits into from
Jan 17, 2025
Merged

Add support for change sets via tool functions #14715

merged 4 commits into from
Jan 17, 2025

Conversation

JonasHelming
Copy link
Contributor

@JonasHelming JonasHelming commented Jan 12, 2025

fixed #14678

What it does

Introduce a set of tool functions, which allow agents to create file based change sets. Change sets collect changes, an agent wants to conduct, the user can review them and then decide to apply them.
ChangeSets are managed in a service that supports generic operations to apply the changes. This allows to implement various strategies, e.g. replace content or to work with diffs. To support a new strategy, you need to:

  • Provide a new ChangeOperation type
  • Provide a corresponding ContentChangeApplier (can apply ChangeOperations on content (strings)). ContentChangeApplier can be registered via a contribution point
  • Provide a set of tool functions to create the new operation type

The current PR contains a simple strategy to replace files completely.
The PR introduces also a new agent 'coder' that uses the new tool functions.
The PR renames the workspace functions and template to 'workspace-'

How to test

Ask something like this in the chat:

@Coder I want to add a property "autostart" to the mcp server preferences (packages/ai-mcp/src/browser/mcp-preferences.ts).
Then ask to apply the changes.

Follow-ups

  • Provide a UI to review and apply the changesets
  • The replace content change applier should have a strategy to correct the file ending break (or we improve the corresponding prompt)
  • When attaching a UI, we need to clarify how to pass the UUID of the current changeset.
  • Extend the replace operation approach with a second function to only replace specific parts of a file (to make it more efficient)
  • Add more strategies, e.g. diff-based
  • We should rename 'ai-workspace' to 'ai-ide' or something similar.

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

fixed #14678

Signed-off-by: Jonas Helming <jhelming@eclipsesource.com>
@JonasHelming JonasHelming requested a review from planger January 12, 2025 23:42
Copy link
Contributor

@planger planger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty powerful and nicely implemented, thank you! While I didn't test this in detail --- just a few smaller changes --- it actually performed pretty well.

I've added a few suggestions below, but they are all very minor things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the file name replace-changeset-functions.ts confusing as it reads like we replace a change set.
While I understand where the replace comes from in this name, I think it isn't so relevant. How about naming this file write-change-to-file-provider.ts (see also my comment below about the name WriteToFileChangeProvider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went for 'replace-content-changeset-functions'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now I'd move the content of this file into replace-changeset-functions.ts as it is only used here and rather local. Not sure if it is intended to be used outside of the scope of the tool function WriteToFileChangeProvider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both files will grow a bit, at least with a "search and replace" function. Therefore and in the spirit of keeping files small to work with this replace provider, I would keep it separate :-)

JonasHelming and others added 3 commits January 17, 2025 21:06
…-service.ts

Co-authored-by: Philip Langer <planger@eclipsesource.com>
Co-authored-by: Philip Langer <planger@eclipsesource.com>
@JonasHelming JonasHelming requested a review from planger January 17, 2025 20:44
@JonasHelming JonasHelming merged commit f9f4fce into master Jan 17, 2025
11 checks passed
@github-actions github-actions bot added this to the 1.58.0 milestone Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Theia AI] Support for change sets
2 participants