continue-custom/core/indexing
Nate Sesti 3bd9c8996c
💫 Preview (#996)
* feat: add fixed version of the nodejs

* revert accidentally committed files

* add: unified version of the Node.js that is used locally and on Github Actions

* Set itemType for querySubmenuItem

This is necessary before calling props.command the same way we do it for non-query item types. Otherwise we receive an 'Unknow provider...' error message in the 'getContextItems' case in the 'panel.webview.onDidReceiveMessage, callback.

* include @vscode node module folder

we need the @vscode folder containing ripgrep in the distribution.

* Amended path for ripgrep executable

We have to preprend the 'out' folder in order to find the ripgrep executable in the distribution.
Prepending 'out' during development is not necessary. We need a way to distinguish in 'ideProtocol'?

* implemented locals context provider

* normal to submenu(select thread) for the locals provider

* added code context from the call stack

* use parameter for callstack retrieving

* added thread filtering and handle a edge case

* revert accidentally committed file

* temporary fix to use refreshSubmenuItems

* added updateSubmenuItems request

* refactor: changed the interface of threads

* polished format and file reading

* added a little doc

* typo

* revert accidentally committed file

* ✨ UI for JetBrains autocomplete

* 🎨 decouple autocomplete from VS Code extension

* ✨ autocomplete in core protocol

* 🚧 jetbrains autocomplete fixes

* 🐛 successfully get responses for jetbrains autocomplete

* Refactored web crawling code for document indexing. The updated code uses a breadth-first search, filters out specific paths, and ensures that websites are not downloaded twice.

* update hasDocs to use new pattern

* feat: add gitlab context class

* feat: update to work as normal context provider

* fix: add context provider

* feat: add code that comment is based on

* docs: add documentation

* feat: enable comment filtering

* 🐛 fix autocomplete with azure

* ✨ jetbrains multiline completions

* 🐛 fix file reading in autocomplete

* ✨ option to disable jetbrains autocomplete

* 📌 update package-lock files

* 🐛 fix localhost ollama bug with jetbrains binary

* 🔥 disable apply to file in jetbrains for now

* 🚸 fix constant re-rendering of code vision in jetbrains

* 🔖 update package.json versiojn

* 🐛 don't override user temperature value for tab autocomplete model

* Fix chat msg formatting in Output for image models (#971)

* 📝 tweak docs for "locals" ctx provider

* 🩹 small tweak to link filtering logic

* Add more C++ extensions for AST parser (#972)

* 🔥 remove ruby example file

* add claude3 to free trial

* 🐛 fix codelens in tutorial

* 🧱 change server url

* 🐛 don't send image_url if not image type

* 🔧 update config schemas

* 📌 update npm version to v20.11.0

* 📈 Locally track tokens generated and show stats (#987)

* ✨ log tokens generated locally

* 💄 UI for usage stats

* 🔥 delete unused test file

* 🚚 rename core package for publishing on npm

* Remove duplicate itemType property (#986)

* 🔒️ add .env to .gitignore for npm package

* Add SystemContextProvider to context providers so that users can use … (#988)

* Add SystemContextProvider to context providers so that users can use their own system cpu and os for a resource

* change to OSContextProvider

* update descriptor

* 🎨 export transformers.js

* 🐛 fix /edit for anthropic

* 🚑 fix autocomplete by binding function

---------

Co-authored-by: my8bit <mail@my8bit.name>
Co-authored-by: Ihor Pavlenko <my8bit@users.noreply.github.com>
Co-authored-by: Lars Pagh <lp@airsupport.dk>
Co-authored-by: commandblock2 <tony_hu@live.com>
Co-authored-by: Jason Jacobs <nerfnerd@gmail.com>
Co-authored-by: Ben Force <benforce@gmail.com>
Co-authored-by: Peter Zaback <pzaback@gmail.com>
Co-authored-by: SR_team <sr_team@sr.team>
2024-03-19 10:35:28 -07:00
..
chunk Merge branch 'preview' into nate/code-context-provider 2024-03-09 13:54:28 -08:00
docs 💫 Preview (#996) 2024-03-19 10:35:28 -07:00
embeddings 💫 Preview (#996) 2024-03-19 10:35:28 -07:00
CodeSnippetsIndex.ts ✨ polish code context provider 2024-03-12 01:17:06 -07:00
FullTextSearch.ts 🚧 full draft of code context provider 2024-03-09 13:54:19 -08:00
indexCodebase.ts 🚸 show indexing progress immediately 2024-03-13 13:07:57 -07:00
LanceDbIndex.ts 🚧 full draft of code context provider 2024-03-09 13:54:19 -08:00
README.md 🚧 full draft of code context provider 2024-03-09 13:54:19 -08:00
refreshIndex.ts 🚧 full draft of code context provider 2024-03-09 13:54:19 -08:00
types.ts 🚧 full draft of code context provider 2024-03-09 13:54:19 -08:00

Indexing

Continue uses a tagging system along with content addressing to ensure that nothing needs to be indexed twice. When you change branches, Continue will only re-index the files that are newly modified and that we don't already have a copy of. This system can be used across many different "artifacts" just by implementing the CodebaseIndex class.

artifact: something that is generated by indexing and then saved to be used later (e.g. emeddings, full-text search index, or a table of top-level code snippets in each file)

cacheKey: a key that determines whether two files can be considered the same to avoid re-indexing (always hash of file contents at this point)

CodebaseIndex: a class that makes it easy to use the indexing system to help you generate a new artifact

The indexing process does the following:

  1. Check the modified timestamps of all files in the repo (this may seem extreme, but checking timestamps is significantly faster than actually reading a file. Git does the same thing.)
  2. Compare these to a "catalog" (stored in SQLite) of the last time that we indexed each of these files to get a list of files to "add" or "remove". If the file exists in the repo but not in the catalog, then we must "add" the file. If it exists in the catalog but not the repo, we must "remove" the file. If it exists in both and was modified after last indexed, then we must update the file. In this case we also add it to the "add" list.
  3. For each file to "add", check whether it was indexed on another branch. Here we use a SQLite table that acts as a cache for indexed files. If we find an entry in this table for a file with the same cacheKey, then we only need to add a tag to this entry for the current branch ("addTag"). Otherwise, we must "compute" the artifact.
  4. For each file in "remove", check whether it was indexed on another branch. If we find only one entry with the same cacheKey (presumably this should be the entry for the current branch, or something has gone wrong), then this entry should be removed and there will be no more branches that need the artifact, so we want to "delete" it. If there is more than one tag on this artifact, then we should just remove the tag for this branch ("removeTag").
  5. After having calculated these four lists of files ("compute", "delete", "addTag", "removeTag"), we pass them to the CodebaseIndex so that it can update whatever index-specific storage it might have. Many of them use SQLite and/or LanceDB. The CodebaseIndex implements a method called "update" that accepts the four lists and yields progress updates as it iterates over the lists. These progress updates are used to officially mark a file as having been indexed, so that if the extension is closed mid-indexing we don't falsely record progress.

Existing CodebaseIndexes

All indexes must be returned by getIndexesToBuild in indexCodebase.ts if they are to be used.

CodeSnippetsCodebaseIndex: uses tree-sitter queries to get a list of functions, classes, and other top-level code objects in each file FullTextSearchCodebaseIndex: creates a full-text search index using SQLite FTS5 ChunkCodebaseIndex: chunks files recursively by code structure, for use in other embeddings providers like LanceDbCodebaseIndex LanceDbCodebaseIndex: calculates embeddings for each chunk and adds them to the LanceDB vector database, with metadata going into SQLite

Known problems:

  • FullTextSearchCodebaseIndex doesn't differentiate between tags (branch, repo), so results may come from any branch/repo. LanceDB does this by creating separate tables for each tag (see tableNameForTag). The chunk index does this with a second table