Skip to content

Reverse engineered RPC client for Cursor.sh's cloud services

Notifications You must be signed in to change notification settings

everestmz/cursor-rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cursor-rpc

Here's how I reverse engineered Cursor.

Protos and go library to communicate with Cursor's backend, without using Cursor. Useful if you're only allowed to run proprietary code through the Cursor servers/have a paid Cursor license, but want to use your own editor (Vim, Helix, etc) or build other features on top of Cursor.

Works by reverse-engineering the minified, obfuscated JS in Cursor's VSCode fork and acting like a bootleg module loader to stand up only the relevant modules needed to get the Protobuf typing info.

NOTE: To use a Cursor account with Vim or Helix, check out sage.

Usage

Generating client libraries

Use the .proto files in ./cursor/aiserver/v1 to generate an RPC client library for your language.

Go library

For detailed usage, check out the basic example.

// Get default credentials for Cursor:
// NOTE: you will need to open Cursor and log in at least once. You may need to re-login to
// refresh these credentials, or use the RefreshToken to get a new AccessToken.
creds, err := cursor.GetDefaultCredentials()
if err != nil {
	log.Fatal(err)
}

// Set up a service:
aiService := cursor.NewAiServiceClient()

// Get completions!
model := "gpt-4"
resp, err := aiService.StreamChat(context.TODO(), cursor.NewRequest(creds, &aiserverv1.GetChatRequest{
	ModelDetails: &aiserverv1.ModelDetails{
		ModelName: &model,
	},
	Conversation: []*aiserverv1.ConversationMessage{
		{
			Text: "Hello, who are you?",
			Type: aiserverv1.ConversationMessage_MESSAGE_TYPE_HUMAN,
		},
	},
}))
if err != nil {
	log.Fatal(err)
}

for resp.Receive() {
	next := resp.Msg()
	fmt.Printf(next.Text)
}

Updating the schema

To update the schema, run

make extract-schema

This command assumes you have a Cursor.app in your /Applications directory.

Then, run

make generate

To use buf to generate updated Go bindings for cursor-rpc.

Todos

  • auto-generate the cursor_version.txt (currently manually set)
  • auto-updating when Cursor has new releases
  • more testing & examples

About

Reverse engineered RPC client for Cursor.sh's cloud services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published