cody icon indicating copy to clipboard operation
cody copied to clipboard

Add OpenCtx annotations to the chat's context

Open bevzzz opened this issue 1 year ago • 3 comments

Context

OpenCtx providers may return additional AssistantInfo to be consumed by code AI. At the moment the VSCode extension does not include these annotations in Cody's prompt.

Here we will fetch annotations from the enabled OpenCtx providers for each file that's added to the chat's context and provide them to Cody.

Check this out!

Screenshot 2024-07-22 at 20 22 54

Haven't done any sanity checks on the suggestions yet, I expect not all of them are accurate. I want to see if Cody will find the optimizations described in the article I linked below. Secondary to the PR's goal though.

Setup

I have pprof provider configured, which is how Cody is able to access information about the functions' CPU time:

// .vscode/settings.json
"openctx.providers": {
	"file:///Users/d.solovei/src/github.com/bevzzz/openctx/provider/pprof/dist/bundle.js": {
		"reportGlob": "**/*.pprof",
		"rootDirectoryMarkers": ["go.mod"],
		"top": {
			"sort": "flat"
		}
	}
}

Checkout https://github.com/sourcegraph/openctx/pull/133 for the source code.

The Go code in the example comes from Profiling Go Programs.

Test plan

TBD

TODO / Open questions:

  • Toggle for this feature. Context menu on the MentionComponent for type === 'file' items?
  • Reflect added token count in ContextItem.size. Users can't really control the amount of content a provider puts into an annotation. What would be a good strategy here? Should there be some threshold until which annotations are "for free"?
  • How well does the current template accommodate other providers?

bevzzz avatar Jul 22 '24 18:07 bevzzz