Skip to content

Agent: automate generation of Kotlin bindings #3142

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

Merged
merged 9 commits into from
Feb 14, 2024
Merged

Conversation

olafurpg
Copy link
Member

Until now, we have been manually writing Kotlin bindings for the agent protocol. This worked fine when only a small number of people worked on the protocol and the protocol was small, but has become increasingly problematic as more people are actively working on the JetBrains plugin and the size of the Agent protocol has grown. For example, if you make a mistake in the bindings, you may end up spending a long time debugging why something is not working because the error messages can be cryptic.

This PR adds a new script to automatically generate Kotlin bindings so that we no longer need to rely on manually written bindings. Simplified, the script works like this:

  • Index the codebase with a fork of scip-typescript. This fork uses an extension of SCIP that adds SymbolInformation.signature (more details here Add support for SymbolInformation.signature scip#231).
  • Use the structured type signatures from the SCIP index, translate it into Kotlin code, and report errors if something in the protocol has no clean translation to Kotlin.
  • Add the generated code to the Cody repo so that we can closely track what Cody PRs are influencing the protocol, and how they're influencing it.

Test plan

Green CI

@olafurpg
Copy link
Member Author

Didn't open a draft PR, but I'm going to review this myself tomorrow before tagging for reviews.

olafurpg added a commit to sourcegraph/scip-typescript that referenced this pull request Feb 13, 2024
Companion PRs:

* sourcegraph/scip#231
* sourcegraph/cody#3142

Previously, scip-typescript didn't emit any structured information about
signatures. This PR solves that problem, which unblocks new exciting
use-cases for SCIP.

Keeping this PR open for a while since we are not planning to merge
signature support to SCIP just yet. For now, the Cody repo can use this
branch instead.
olafurpg added a commit to sourcegraph/scip-typescript that referenced this pull request Feb 13, 2024
Companion PRs:

* sourcegraph/scip#231
* sourcegraph/cody#3142

Previously, scip-typescript didn't emit any structured information about
signatures. This PR solves that problem, which unblocks new exciting
use-cases for SCIP.

Keeping this PR open for a while since we are not planning to merge
signature support to SCIP just yet. For now, the Cody repo can use this
branch instead.
olafurpg added a commit to sourcegraph/scip-typescript that referenced this pull request Feb 13, 2024
Companion PRs:

* sourcegraph/scip#231
* sourcegraph/cody#3142

Previously, scip-typescript didn't emit any structured information about
signatures. This PR solves that problem, which unblocks new exciting
use-cases for SCIP.

Keeping this PR open for a while since we are not planning to merge
signature support to SCIP just yet. For now, the Cody repo can use this
branch instead.
Until now, we have been manually writing Kotlin bindings for the agent
protocol. This worked fine when only a small number of people worked on
the protocol and the protocol was small, but has become increasingly
problematic as more people are actively working on the JetBrains plugin
and the size of the Agent protocol has grown. For example, if you make
a mistake in the bindings, you may end up spending a long time debugging
why something is not working because the error messages can be cryptic.

This PR adds a new script to automatically generate Kotlin bindings so
that we no longer need to rely on manually written bindings. Simplified,
the script works like this:

- Index the codebase with a fork of scip-typescript. This fork uses an
  extension of SCIP that adds `SymbolInformation.signature` (more
  details here sourcegraph/scip#231).
- Use the structured type signatures from the SCIP index, translate
  it into Kotlin code, and report errors if something in the protocol
  has no clean translation to Kotlin.
- Add the generated code to the Cody repo so that we can closely track
  what Cody PRs are influencing the protocol, and how they're
  influencing it.
@olafurpg olafurpg requested review from a team and steveyegge February 13, 2024 13:29
Copy link
Contributor

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

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

Great stuff! The changes on the vscode side are minuscule and it's very easy to turn this off if it causes problems but even in its current state this is a huge improvement for the work on the JetBrains extension (even if we don't keep the types updated) so let's go

@olafurpg olafurpg merged commit 501b980 into main Feb 14, 2024
@olafurpg olafurpg deleted the olafurpg/codegen branch February 14, 2024 12:30
mkondratek added a commit to sourcegraph/jetbrains that referenced this pull request Feb 27, 2024
The recent changes to the agent
(sourcegraph/cody#3142) broke the API - this is
a fix.


## Test plan
1. write @ in the chat
2. the files appear
olafurpg added a commit to sourcegraph/scip-typescript that referenced this pull request Jun 12, 2024
Companion PRs:

* sourcegraph/scip#231
* sourcegraph/cody#3142

Previously, scip-typescript didn't emit any structured information about
signatures. This PR solves that problem, which unblocks new exciting
use-cases for SCIP.

Keeping this PR open for a while since we are not planning to merge
signature support to SCIP just yet. For now, the Cody repo can use this
branch instead.
olafurpg added a commit to sourcegraph/scip-typescript that referenced this pull request Jun 17, 2024
Companion PRs:

* sourcegraph/scip#231
* sourcegraph/cody#3142

Previously, scip-typescript didn't emit any structured information about
signatures. This PR solves that problem, which unblocks new exciting
use-cases for SCIP.

Keeping this PR open for a while since we are not planning to merge
signature support to SCIP just yet. For now, the Cody repo can use this
branch instead.
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.

2 participants