Skip to content

Instantly share code, notes, and snippets.

@RomneyDa
Last active January 12, 2025 13:23
Show Gist options
  • Save RomneyDa/3907e04e577ac560dedf34278fc2f23d to your computer and use it in GitHub Desktop.
Save RomneyDa/3907e04e577ac560dedf34278fc2f23d to your computer and use it in GitHub Desktop.
A look into each part of Continue's code 2024-10-5

Continue codebase deep dive

Intro

This is a deep dive into the Continue code base, folder by folder and file by file where relevant.

Code changes fast, like winds in the past
This guide's not meant to forever last
It's here for me, to ease my way
A developer's friend, if just for today
Long inline comments abound
So get your wide screen out

Assembled with lots of help from Continue!

Deep dive

Summary

  • Continue is an open-source AI code assistant.
  • The current main end user products are IDE extensions for VS Code and Jetbrains
  • Continue integrates AI-powered chat and code autocomplete into the IDE in powerful, interactive ways, along with a sidebar interface
  • It works with a wide variety of models (local and remote/API) for each task, and models are highly configurable and interchangeable
  • It implements powerful codebase retreival and ranking techniques to provide AI with the most relevant context, and introduces customizable *Context Providers as ways to efficiently inject relevant context manually
  • It introduces Powerful actions in the form of Slash Commands and .prompt files, which provide preconfigured ways to execute specific prompts, edits, and other common actions on specific pieces of context
  • It uses keyboard shortcuts, single-click actions, right click menu actions, and a smooth sidebar GUI to maximize developer experience
  • See amplified.dev for more on the why

Tech

Continue is open source and hosted at https://github.com/continuedev/continue

It's comprised of

  • GUI: A React application that gives the user control over Continue. It displays the current chat history, allows the user to ask questions, invoke slash commands, and use context providers. The GUI also handles most state and holds as much of the logic as possible so that it can be reused between IDEs
  • Continue Extension: A plugin for the IDE which implements the IDE interface to allow the GUI to request information and take actions.

The VS Code extension, primarily written in Typescript, is in Beta testing
The Jetbrains IDE Extension, written primarily in Kotlin, is in Alpha testing
Typescript Code that can be shared by the gui and extensions is maintained in a core directory which is also compiled to binary

Some other tech includes:

Notes

The following common files found throughout the codebase are mostly ignored from further analysis

  • node_modules: directories into which node packages are installed
  • package.json: node project information, script definitions (e.g. npm run script-name), and dependencies at the cwd
  • package-lock.json: used to store resolved installation plans and ensure replicable node package installation
  • tsconfig.json: typescript configuration for current directory - compiler options, filepaths, etc.
  • .gitignore: specifies files that should not be tracked by git
  • .npmignore: specifies files that should be ignored when publishing an npm package
  • .gitkeep: a placeholder for git to track potentially empty directories
  • jest.config.js/mjs and jest.config.d.ts: used to specify config for how to tests with Jest, e.g. environment settings, filepath configs, which file extensions to skip, compiler settings, etc.
  • .continueignore: used by the Continue extension itself to specify files to be ignored by a @CodeBase context provider. That is, wherever you see this file, you see Continue devs using Continue to develop Continue!
  • index.ts - some simple entry points are not considered here
  • .css files - stylesheets are usually self explanatory in context

<brackets> are used to denote fill-in values to make this shorter. For example, could be replaced by: darwin-arm64, darwin-x64, linux-arm64, linux-x64, , win32-arm64, win32-x64, etc.

Directories

Root files

Continue uses prettier for code formatting. Enable format on save.

The CONTRIBUTING.md guide describes:

  • How to report bugs and create issues
  • How to contribute ideas to the This GitHub project board
  • How to suggest enhancements through the Continue Discord or an issue
  • How to update or improve the docs, including running a local documentation server
  • How to contribute code, including environment setup, debugging, formatting, and the Git workflow
  • Writing slash commands and context providers
  • Adding LLM providers, models, and pre-indexed documentation
  • The architecture of Continue, focusing on the GUI and IDE extensions (VS Code and JetBrains)

See comments below for other files

.nvmrc                  # Specifies node version
CHANGELOG.md            # Redirects users to extension-specific changelogs generated by Changie
CODE_OF_CONDUCT.md      # Establishes expectations for conduct in the community and how misconduct will be reported and handled
CONTRIBUTING.md         # A guide for contributing to Continue
LICENSE                 # The code is currently licensed with Apache 2.0
README.md               # The main high-level readme introducing Continue
.prettierignore         # Specifies which files to ignore for formatting - https://prettier.io/docs/en/ignore.html
.prettierrc             # Prettier config
.changie.yaml           # Defines changie changelog generation config

.changes

Continue uses changie for extension changelogs

Changie config is managed in ./changie.yaml

  • VS Code and Jetbrains projects are set up
  • labels like 'Added' and 'Changed' are specified to enable corresponding auto-incrementation of semver
  • formatting and relevant filepaths/directories are specified

To use,

  1. Things that will show up in the next changie version are added using changie new ...
  2. changie new walks through adding a change - kind, projects, etc. (can also specify e.g. --projects flag manually) and creates a change file in the unreleased directory
  3. changie batch batches all the unreleased change files for a project into a version changelog within the specified project
  4. Finally, changie merge merges the version changes into one complete changelog within the project directory

This appears to be a somewhat manual process right now, presumably to keep the changelog clean and simple

.changie
├── extensions                 # projects
│   ├── intellij               # Jetbrains project
│   │   ├── <semver>.md        # versioned change files
│   ├── vscode                 # VS Code project
│   │   ├── <semver>.md        # versioned change files
├── header.tpl.md              # data to add to the top of a merged changelog
├── unreleased                 # unreleased changes from changie new
│   ├── <Type-timestamp>.yaml  # unreleased change files

.github

.github contains files that define github CICD/workflows and various github codebase settings. Key takeaways:

  • When a contributor opens an issue, they fill out a form based on the options in ISSUE_TEMPLATE
  • Issues are autoassigned (currently randomly to Patrick or Nate) using pozil/auto-assign-issue
  • pull_request_template.md defines what a contributor will see when opening a pull request
  • Dependabot is run daily to manage automated pull requests that help update dependencies with known vulnerabilities
    • Set up in dependabot.yml - very simple, basically run daily on /, ignore one package
  • dev, preview, and main are protected with workflows (ts_check, dev_pr) than check/compile typescript
  • prerelease/release workflows are defined to publish prerelease/release versions of vscode and jetbrains extensions when pushed to main/preview with tags [prereleased]/[released]

Jetbrains flow:

  1. Trigger: Runs on prereleased GitHub releases.
  2. Jobs:
    • Check Release Name: Verifies if the release tag follows the expected pattern (v0.0.*-jetbrains).
    • Build Plugin: Sets up Java, Gradle, Node.js, imports Apple certificates, builds the plugin, signs binaries, and publishes to JetBrains Marketplace (EAP and stable channels).
    • Test Binaries: Tests built binaries on Windows, Linux, and macOS.
    • Run Tests: Runs Gradle tests on the plugin and collects results if any fail.
  3. Secrets: Requires secrets like PUBLISH_TOKEN, CERTIFICATE_CHAIN, and Apple certificate details for publishing and signing.

VS Code flow:

  1. Trigger: Runs on a released GitHub release.
  2. Jobs:
    • Check Release Name: Validates if the release tag matches the expected pattern (v0.8.*-vscode).
    • Build: Installs dependencies, packages the VS Code extension for different platforms (Windows, Linux, macOS), and uploads .vsix artifacts.
    • Release: Downloads the packaged .vsix files and creates a GitHub release with them.
    • Publish: Publishes the extension to the VS Code Marketplace and the Open VSX Registry.
.github
├ ISSUE_TEMPLATE                 # Templates for opening an issue
│ ├ bug_report.yml 
│ ├ config.yml
│ ├ improvement_suggestion.yml
├ dependabot.yml                  # Dependabot config
├ pull_request_template.md        # Form contributors see when opening pull request
├ workflows
│ ├ README.md                     # Some notes on future extension workflow changes
│ ├ auto-assign.yaml              # Auto-assign new issues to a dev listed here via pozil/auto-assign-issue
│ ├ dev_pr.yaml                   # Run typescript/compile checks on dev pr
│ ├ jetbrains-release.yaml        # Publish prerelease JetBrains extension on [prereleased]
│ ├ main.yaml                     # Publish release VS Code extension on push to main
│ ├ preview.yaml                  # Publish prerelease VS Code extension on push to preview
│ └ ts-check.yaml                 # Run typescript checks on preview/main pr

.idea

The .idea directory is used to set and store Jetbrains project metadata.

Specifically for Continue, it:

├ .name                  # Sets a project name
├ compiler.xml           # Configure bytecode compilation
├ gradle.xml             # Gradle build tool config
├ jarRepositories.xml    # Configure remote Maven repositories for resolving dependencies
├ Kotlinc.xml            # Specifies the Kotlin version
├ misc.xml               # Configures various settings, e.g. allowing external storage config
└ vcs.xml                # Specifies that Git is used as version control

.vscode

.vscode contains project-level configuration for Continue in the forms of:

  • Debugger launch configurations in launch.json
    • Defines the debugging options that show up in the "Run and Debug" sidebar
    • Includes configurations for debugging the VS Code extension, the core binary, Node Jest tests, the GUI in chrome, and some specific test situations
  • Workspace settings in settings.json
    • configures some python, rust, and terminal/bash settings
    • excludes specific directories (mostly builds and packages) from file searches to avoid unecessary files showing up
  • Automated Tasks in tasks.json
    • Adds convenient tasks you can run from the command pallete (cmd/ctrl+shift+P) -> Run Task, which are relevant to the Continue codebase
    • for example the "install all dependencies" task mentioned in Contributing.md
    • Especially helps avoid having to move around in directories from the terminal, e.g. cd gui to npm run dev the gui
    • Tasks include vscode-extension:build, install-all-dependencies, gui:dev, binary:esbuild, docs:start, clean, and other more targeted vscode build tasks
.vscode
├ launch.json   # Defines debugging configurations
├ settings.json # Defines workspace settings for Continue that override user settings
└ tasks.json    # Defines some convenient automated tasks for building, debugging, etc. that can be run from the VS Code command pallete

binary

binary is what packages the core as a binary and provides Ipc/Tcp messengers for the extensions/IDE based on the Core Protocols

build.js is the main build script for the core binary

  • cleans up build directories
  • installs proper lancedb build based on target
  • copies tree-sitter-wasm and model-token-related utils
  • bundles to out/index.js using esbuild
  • builds binaries with pkg
  • inserts prebuilt sqlite3 and esbuild binaries for the target

src/index.ts is the entry point for the core binary; it initializes communication with and logging for the core binary

The bread and butter of communication is in the core protocols ToCoreProtocol and FromCoreProtocol; the IpcMessenger and TcpMessenger are lightweight and only establish the connection with those data types. Tcp seems to mostly be used for a Jetbrains development case and can be enabled with a useTcp config setting as described in binary/README.md.

binary
├ build.js              # Main binary build script - see above
├ importMetaUrl.js      # workaround to fix a filepath issue for transformers.js
├ pkgJson               # Package dependencies are defined for each platform to reduce bloat
│ ├ <platform-name>
│ │ ├ package.json
├ src
│ ├ index.ts            # ENTRY POINT - intializes and establishes communication with core binary
│ ├ IpcIde.ts           # minor extension of MessageIde - communication between core binary and IDE
│ ├ IpcMessenger.ts     # Ipc/socket communication with the core binary (and Tcp variant)
│ ├ TcpMessenger.ts     # Possibly duplicate
│ ├ logging.ts          # Core logging to replace console functionality with write to log file ~/.continue/logs/core.logtest
│ ├ binary.test.ts      # Tests on the global directory (e.g. ~/.continue) and CoreBinaryMessenger (gets config/history, adds/deletes models, and makes llm completions)
├ out/                  # untracked, contains binary files output from build process
├ bin/                  # untracked, contains compiled binaries or executable files that are generated during the build process
├ build                 # untracked, contains .node file output from build process
│ ├ node_sqlite3.node   # downloaded/precompiled sqlite3 binary package
├ tmp                   # untracked, temp modules, lancedb related

core

core contains platform-independent code which can be used by the gui and extensions, and is also compiled to a binary that is messaged by the extension. This shared code contains the technical bread and butter of Continue AI.

I will be quite a bit less thorough on core than other directories because much of the code is dense and technical

Some interesting/important directories and files include:

  • protocol defines the message names and associated types for data to be passed between the core binary, extensions, and GUI
  • types.d.ts defines core global types
  • autocomplete contains the tools for code autocomplete model with streaming, retrieval services, ranking, etc.
  • commands contains support for slash commands and custom commands and defines built in commands
  • context contains support for various methods of context retrieval and context optimization, including manual context providers, retrieval, rerankers, etc.
  • config handles watching, loading, validating, editing, config
  • llm has support for chatting with llms + streaming, tokenization, etc.
  • indexing contains tools for codebase indexing with chunking, snippets, text search, embeddings, etc.
├ .eslintrc.json             # Typescript eslint settings
├ .vscode
│ ├ launch.json              # Core binary debug launch script
├ core.ts                    # Class used by VSCode extension to access core and handle messages from IDE
├ index.d.ts                 # CORE GLOBAL TYPES
├ autocomplete/              # Code to enable autocomplete model with streaming, retrieval services, ranking, etc.
├ commands
│ ├ slash
│ │ ├ <command-name>.ts      # Built-in SlashCommand
│ │ ├ edit.ts                # Especially interesting slash command that edits files in place
│ │ ├ index.ts               # Assemble slash commands
│ ├ index.ts                 # Convert config custom command to slash command
│ ├ util.ts                  # Convert context data to range in file with contents
├ config
│ ├ ConfigHandler.ts         # Handles changes to config files, reloads, serializes, notifies listeners
│ ├ default.ts               # Default config values
│ ├ load.ts                  # Loading, validating, processing, and merging config files
│ ├ onboarding.ts            # Update config based on if Best/Quickstart/Local onboarding was performed
│ ├ promptFile.ts            # Loads and converts .prompt files and customCommands to slash commands
│ ├ types.ts                 # String version of ../index.d.ts written to ~/.continue/types/core/index.d.ts
│ ├ util.ts                  # Utils to edit config.json
│ ├ profile                  # Abstractions around loading config profiles
├ context
│ ├ index.ts                 # Base context provider
│ ├ providers                # Manual context providers for injecting text and assets into context
│ ├ rerankers                # Tools to find most relevant code using reranking models
│ ├ retrieval                # Codebase retrieval, pipelines with and without reranking for efficiency
├ continueServer             # Indexing/embeddings server/cache
├ control-plane              # Analytics and auth for Continue for Teams (?)
├ deploy                     # Proxy server deployment constants
├ diff
│ ├ myers.ts                 # Myers diff collection implementation
│ ├ myers.test.ts            # Myers diff function tests
│ ├ streamDiff.ts            # Stream diff collection implementation
│ ├ streamDiff.test.ts       # Stream diff function tests
│ ├ util.ts                  # Utils for stream diff function
│ ├ test-examples            # Stream diff test files
│ │ ├ README.md              # Notes on how test files are formatted
│ │ ├ <test-name>.ext.diff
├ edit                       # Enables edit suggestions - prompts and diff calculation/streaming
├ indexing                   # Indexing tools: chunking, codebase, snippets, lancedb, full-text search, embeddings
├ llm                        # Tools to send data to LLMs, message construction, tokenization, streaming, etc.
├ promptFiles                # Support for .prompts files - parsing, defaults, conversion to slash commands
├ protocol                   # Definitions for communication between Webview, Core, IDE, and more
├ tag-qry                    # Tree-sitter tag queries per language used by context providerstest                       # Tests for utils, LLMs, context providers, etc.
├ util
│ ├ GlobalContext.ts         # Method for globally persisting context at ~/continue/index/globalContext.json
│ ├ LruCache.ts              # Simple Least-Recently-Used cache for definitions
│ ├ ca.ts                    # Add certificates to global agent (used by vscode extension)
│ ├ dedent.test.ts           # Test removal of common leading whitespace from all lines
│ ├ devdata.ts               # Dev data logging: JSON
│ ├ devdataSqlite.ts         # Dev data logging: SQLite
│ ├ extractMinimalStackTraceInfo.ts # Remove sensitive absolute file paths from stack traces
│ ├ fetchFavicon.ts          # Fetches icon, used by URL context provider and docs crawler
│ ├ fetchWithOptions.ts      # Custom fetch implementation, accepts requestOptions
│ ├ filesystem.ts            # IDE implementation with file utils, mostly used as test dummy
│ ├ generateRepoMap.ts       # Generates repo map to be used by RepoMapContextProvider
│ ├ history.ts               # Persist chat session history in ~/.continue
│ ├ ideUtils.ts              # Resolve relative path in workspace
│ ├ index.ts                 # Core text and filepath utils, getMarkdownLanguageTagForFile
│ ├ lcs.ts                   # Longest common subsequence finder - filters out extreme repetition in autocomplete
│ ├ merge.ts                 # Utility function for merging two JSON objects
│ ├ messageIde.ts            # Exposes methods for communicating with IDE through message protocols
│ ├ reverseMessageIde.ts     # UNUSED alternative implementation of ^
│ ├ messenger.ts             # In-process messenger for Core to IDE messages
│ ├ parameters.ts            # Default tab autocomplete options and retrieval params
│ ├ paths.ts                 # Utility functions to get various extensions of the ~/.continue path
│ ├ posthog.ts               # PostHog telemetry class for sending analytics
│ ├ ranges.ts                # Range (within a file) utils
│ ├ treeSitter.ts            # Tree-sitter language processing
│ ├ tts.ts                   # Text-to-speech support
│ ├ withExponentialBackoff.ts # Perform exponential backoff retries on any callback
├ vendor/                     # as described in `/vendor/README.md`, node modules "vendored" (copied directly rather than downloaded from npm etc.) for transformers.js to avoid the `sharp` dependency, which isn't used and has native dependencies

docs

Continue uses docusaurus for docs Important takeaways:

  • docusaurus.config.js is where overall site settings are defined, including
    • site title, logo, description, keywords, and other metadata
    • docs navbar and footer customization
    • custom redirects, including
      • from deprecated page links to their new counterparts, and
      • pages that should skip to one of their subpages
  • docs/ is the Bread and Butter of the docs, it contains a tree-like structure of the actual docs pages and associated assets. Can support react, etc. files but Continue is mostly using .md/markup files
  • sidebars.js is where custom navigation groups and hierarchies can be defined (see the file for how, it's not too bad) and then added to the docusaurus.config.js's config.themeConfig.navbar.items
  • src/css/custom.css contains custom global styling for both light and dark mode
  • [static/schemas/config.json] might look a lot more confusing that it is; It's just a JSONSchema definition for the docusaurus.config.json format above, and the only way it is used it that it's imported into /customize/config.mdx and then displayed as a reference for configuring the docs themselves
  • Finally, src/theme/NotFound/Content handles not-found URLs - currently, it just redirects to the docs home

Note the docs:start VS Code task to jumpstart the dev server

docs
├ .docusaurus/          # contains installation and plugin files for docusaurus - do not edit
├ CHANGELOG.md          # Changelog managed by changie (at least will be in the future) - see .changie notes above
├ README.md             # Brief notes
├ babel.config.js       # Bundler plugin setup
├ docs                  # Tree of docs pages and associated assets
│ ├ <docs-category>
│ │ ├ <docs-page>.md
│ │ ├ assets/
│ │ ├ <docs sub-category>
│ │ │ ├ <docs-page>.md
│ │ │ ├ assets/
│ │ │ ├ <docs sub-sub-category>
│ │ │ │ ├ assets/
│ │ │ │ ├ <docs-page>.md
├ docusaurus.config.js  # Main site settings
├ netlify.toml          # Netlify config for hosting - empty for now?
├ sidebars.js           # Doc page custom sidebar navigation definitions
├ src
│ ├ css
│ │ ├ custom.css        # Light and dark mode custom css is defined here
│ ├ theme
│ │ ├ NotFound
│ │ │ ├ Content
│ │ │ │ ├ index.js      # Page for not-found handling - currently just redirects to the docs home
├ static
│ ├ .nojekyll           # don't process these static assets with Jekyll static site generator (mostly for Github Pages)
│ ├ img                 # contains image assets used throughout the docs
│ │ ├ <asset-name>.gif/.png
│ ├ schemas
│ │ └ config.json       # reference JSONSchema for docusaurus.config.js

eval

The eval directory seems to intended as the future home of code that will benchmark the accuracy of codebase retreival.

extensions

Continue has two IDE extensions:

extensions-vscode

extensions/vscode contains source code for the VS Code extension.

  • Embeds the gui React app in a side panel
  • Communication protocols: sends and handles messages from the GUI and core binary, and makes IDE features accessible to the GUI and core
  • Integrates a variety of IDE features like autocomplete, diff edits, suggestions, codelens, quick picks, auth, etc.

Notable files/directories include:

  • continue_rc_schema.json and cconfig_schema.json: JSONSchema files defining the structure of Continue's config.json and .continuerc.json files
  • src/autocomplete: integration of Autocomplete model output into the VSCode IDE
  • src/extension.ts and src/activation/activate.ts: Entry point(s) handling the activation and installation of the extension
  • src/extension: main extension class, which registers commands and providers with the IDE and handles communication with the GUI and core
  • src/ContinueGUIWebviewViewProvider.ts: gui webview wrapper for vscode
  • src/VsCodeIde.ts: VSCode specific implementation of core IDE type, exposes tons of IDE functionality, especially related to files/paths
  • scripts contains scripts used to build the extensions
├ .continuerc.json               # Custom continue config settings for developing this extension
├ .eslintrc.json                 # Typescript eslint config
├ .npmrc                         # Node version
├ .prompts                       # Some continue prompts to use as slash commands while developing the vscode extension
│   ├ review.prompt
│   ├ test.prompt
├ vsc-extension-quickstart.md    # Quickstart guide for developing extensions
├ .vscodeignore                  # Files to ignore when building extension
├ CHANGELOG.md                   # Changelog generated by changie
├ CONTRIBUTING.md                # Contribution guide
├ LICENSE.txt                    # Apache license 
├ README.md                      # Readme that shows up in the VS Code extensions marketplace
├ builtin-themes                 # VSCode theme files retrieved 
│   ├ <theme-name>.json
├ config_schema.json             # Defines JSONSchema for a user's ~/.continue/config.json
├ continue_rc_schema.json        # Defines JSONSchema for a workspace's .continuerc.json
├ continue_tutorial.py           # File to open when showTutorial event is sent from the GUI
├ esbuild.test.mjs               # Script to bundle tests to be testable on child dev extension window
├ gui                            # Build output (not listed here) and other static asset files (TRACKED!)
│   ├ index.html                 # GUI entry point
│   ├ logos/                     # Model and provider images
│   ├ onigasm.wasm               # Syntax highlighting module
├ media                          # Images/assets used by the main README.md file
├ models                         # Models to be shipped with extension
│   ├ README.md
│   ├ all-MiniLM-L6-v2/          # This model is shipped with the extension as the default for locally generated embeddings
├ out/                           # UNTRACKED - contains extension files output from build process
├ bin/                           # UNTRACKED - contains compiled binaries or executable files that are generated during the build process
├ build                          # UNTRACKED - contains .vsix vscode extension file output from build process
│   ├ continue-<semver>.vsix
├ scripts
│   ├ esbuild.js                          # Main esbuild config and script, builds to ../out
│   ├ importMetaUrl.js                    # Workaround to fix a filepath issue for transformers.js
│   ├ package.js                          # Script to package for a specific platform
│   ├ package-all.js                      # Script that runs ^ for each supported platform
│   ├ prepackage.js                       # Copies config_schema.json/continue_rc_schema.json, handles platform-specific binary package needs, and verifies needed files are present
│   ├ prepackage-cross-platform.js        # Cross-platform version of ^
│   ├ utils.js                            # Build utils for installing packages/binaries, copying static assets and packages, and building the GUI for the extension
│   ├ versionCheck.js                     # Prevents odd-numbered VS Code release
├ src
│   ├ ContinueGUIWebviewViewProvider.ts   # Extends vscode.WebviewViewProvider to host the sidebar GUI. Handles logs, returns text html that links to react application js entry file (dev -> localhost, prod -> installed GUI)
│   ├ VsCodeIde.ts                        # VSCode specific implementation of core IDE type, exposes tons of IDE functionality, especially related to files, directories, and repo/github
│   ├ commands.ts                         # Add highlighted code / current file to context, stream inline file edit to context, register these commands with vscode
│   ├ decorations.ts                      # Custom test decoration manager for lint messages and highlighted code. Pushes custom decoration types to decoration options for block
│   ├ extension.ts                        # ENTRY POINT FOR EXTENSION - activate extension
│   ├ suggestions.ts                      # Actions and utils for decorating file edit suggestions
│   ├ webviewProtocol.ts                  # Messenger to handle messages within webview - from webview to webview protocol
│   ├ activation
│   │   ├ activate.ts                     # ENTRY POINT (function called by extension.ts to activate) - instantiates extension and creates and registers custom context / public continue API
│   │   ├ api.ts                          # Public API type
│   │   ├ inlineTips.ts                   # Decorations for inline view tips
│   │   ├ languageClient.ts               # UNUSED example of starting another language server from the extension
│   │   ├ proxy.ts                        # UNUSED cors proxy express.js server
│   ├ autocomplete                        # TAB AUTOCOMPLETE INTEGRATION
│   │   ├ completionProvider.ts           # Continue implementation of vscode.InlineCompletionItemProvider which manages the actual insertion of autocomplete suggestions, etc. Registered in construction of VsCodeExtension
│   │   ├ lsp.ts                          # Get relevant function declarations to be provided to autocomplete model as snippets
│   │   ├ recentlyEdited.ts               # Tracks last 10 edited documents along with edited range/contents, used on ContinueCompletionProvider
│   │   ├ statusBar.ts                    # Defines the text and icons shown in the vs code statusbar, and the menu options listed when Continue is clicked in the status bar. Currently toggles autocomplete
│   ├ debug
│   │   ├ debug.ts                        # Registers debug tracker for VsCodeExtension constructor, currently disabled for performance issues
│   ├ diff/                               # Decorations and actions for vscode diff editor, horizontal and vertical
│   ├ extension
│   │   ├ VsCodeExtension.ts              # MAIN EXTENSION CLASS - handles config updates, registers commands and providers, and establishes communication with core/webview
│   │   ├ VsCodeMessenger.ts              # Handle messages from core and webview. Combines handling for cases where both core and webview request
│   │   ├ autocomplete.ts                 # Empty
│   │   ├ indexing.ts                     # Empty
│   ├ lang-server
│   │   ├ codeActions.ts                  # Quick fix code action provider and registration
│   │   ├ codeLens                        # Code lens providers and registration
│   │   │   ├ providers
│   │   │   │   ├ <codelensprovider-name>.ts     # A code lens provider, e.g. QuickActionsCodeLensProvider, diff, suggestions, tutorial, vertical
│   │   │   ├ registerAllCodeLensProviders.ts    # Disposes of any existing CodeLens providers and registers relevant new ones - called by VsCodeExtension on continue config update
│   ├ otherExtensions
│   │   ├ git.d.ts                        # Types for git
│   ├ quickEdit/                          # Quick Edit quick pick action handlers - https://code.visualstudio.com/api/ux-guidelines/quick-picks
│   ├ stubs
│   │   ├ SecretStorage.ts                # Util class to encrypt data and store it in vscode.SecretStorage, for WorkOsAuthProvider
│   │   ├ WorkOsAuthProvider.ts           # Class for connecting to WorkOS (continue for teams?) - for now, not used, just instantiated on VsCodeExtension
│   │   ├ activation.ts                   # Activates remote config sync based on config remoteConfigServerUrl param
│   │   ├ auth.ts                         # Get GitHub session auth token for remote config
│   │   ├ promiseUtils.ts                 # Promise utils for WorkOsAuthProvider
│   │   ├ remoteConfig.ts                 # Remote config sync handler to allow use of config on GitHub
│   ├ terminal/                           # UNUSED terminal emulator
│   ├ test/                               # Mocha tests for the extension, runs on the dev VS Code host window
│   ├ util
│   │   ├ arePathsEqual.ts                # Simple path comparison util to account for capitalization in windows
│   │   ├ battery.ts                      # Tracks system battery level and AC connected. Used to enable pauseTabAutocompleteOnBattery config setting
│   │   ├ cleanSlate.ts                   # Unused util to simulate brand new user
│   │   ├ constants.ts                    # Random constants
│   │   ├ expandSnippet.ts                # UNUSED potential additional processing for snippets for core reranker retrieval pipeline
│   │   ├ getTheme.ts                     # Load theme - check other extensions, use builtin-themes if needed
│   │   ├ ideUtils.ts                     # VS Code utils that go further than the IDE class. Added to VsCodeIde implementation of IDE
│   │   ├ loadAutocompleteModel.ts        # Get default or global context tab autocomplete model
│   │   ├ messages.ts                     # showFreeTrialLoginMessage
│   │   ├ util.ts                         # Random version, platform, json utils
│   │   ├ vscode.ts                       # Various range/column/row, path, and id utils for vscode
│   │   ├ workspaceConfig.ts              # Get config that can be found in vscode settings, like enableQuickActions
├ tag-qry                                 # Tree sitter tag queries per language used by @outline and @highlights context providers
├ textmate-syntaxes/                      # Static syntax highlighting (plist, tmLanguage, json, and tmLanguage.json formats)
├ tree-sitter/                            # Tree syntax parsing for different languages, used in getQueryForFile function by ImportDefinitionsService, RootPathContextService, and CodeSnippetsIndex

extensions-intellij

extensions/intellij contains Jetbrains extension code

I'm not an expert in Kotlin, so this section will be much more summarized. Assuming some extension patterns are similar, see extensions/vscode

qodana is configured as a code analyzer

extensions/intellij
├ .idea/                                   # JetBrains project config for the extension project itself - see root .idea notes above
├ .run/                                    # Contains scripts for some predefined tasks similar to VSCode tasks
├ CHANGELOG.md                             # Extension changelog generated by Changie
├ README.md
├ gradle/                                  # This directory and other ...gradle... files are related to build config
├ qodana.yml                               # Configure Qodana code analyzer
├ src
│ ├ main
│ │ ├ Kotlin/com/github/continuedev/continueintellijextension
│ │ │ ├ actions/                           # Edit, quick input, quick text entry, and other IDE actions
│ │ │ ├ activities/                        # Plugin start/initialization
│ │ │ ├ auth/                              # Continue for teams auth handling
│ │ │ ├ autocomplete/                      # Tab autocomplete actions
│ │ │ ├ constants/                         # Some path and config constants
│ │ │ ├ continue/                          # Core messaging with binary and GUI, custom input boxes, styles
│ │ │ ├ editor/                            # Inline edit/diff components
│ │ │ ├ factories/                         # Custom resource and URL handling (e.g. "continue://")
│ │ │ ├ listeners/                         # Handle code selection event, clear tooltips
│ │ │ ├ services/                          # Plugin services for extension settings, Core messaging, and Posthog telemetry
│ │ │ ├ toolWindow/                        # Tool window = the dockable view, core messaging types and event handling
│ │ │ ├ utils/                             # Various utilities
│ ├ resources/                             # Metadata, assets/images, tutorial, static html entry point, and bundle output
└ test/                                    # Dummy extension tests and data

gui

gui contains a react application which is the primary user interface for the extensions. It handles most state and holds as much of the logic as possible so that it can be reused between IDEs.

The entry point is index.html, which contains src/main.tsx (most state etc providers), which contains src/App.tsx (routing, styling providers)

The GUI uses Redux for state management, and the state is persisted to local storage / hydrated on reload.

Components can watch store state or listen to webview message events (`useWebviewListener) for data.

Some more interesting/complex components include:

  • src/pages/
    • src/mainInput is the main chat input with a TipTap editor for search, commands, context, etc.
    • src/hooks/useSubmenuContextProviders is used by the TipTapEditor to get search results for context provider
  • src/components/OnboardingCard: walks through initial setup with 3 options: best, local and quick
  • src/pages/AddNewModel: page that walks through adding providers and models with a bunch of preset options
  • src/pages/more/IndexingProgress: can be used to trigger codebase reindexing by core binary and communicates with binary to show progress
  • src/pages/history: ordered, searchable session history
  • src/context/IdeMessenger: implements communication with the IDE extension

Some other tech used:

  • Vite is used as the frontend tooling and enables hotloading
  • Tailwind is used for styling.
  • Posthog is used for data collection
gui
├ index.html                              # Entry point for the react app
├ tailwind.config.cjs                     # Tailwind styling config - https://tailwindcss.com/docs/configuration
├ postcss.config.cjs                      # Postcss styles config (more or less a tailwind peer dependency)
└ vite.config.ts                          # Vite config - https://vitejs.dev/config/
├ dist/                                   # GUI build output - /assets.js is entry point - untracked
├ editorInset                             # UNUSED? alternative editor inset index entry point + config
│ ├ index.html
│ ├ vite.config.ts
├ public
│ ├ jetbrains_index.html                  # UNUSED alternative JetBrains inset index
│ ├ jetbrains_editorInset_index.html      # UNUSED alternative JetBrains inset index
│ ├ logos                                 # Public logo assets used throughout GUI, models, etc.
│ │ ├ <model/provider/etc.>.png
├ src
│ ├ main.tsx                              # Entry component used in index.html - most state etc. providers
│ ├ App.tsx                               # Router used in main.tsx - Routing + theme/subtext providers
│ ├ index.css                             # Some root styles
│ ├ components
│ │ ├ index.ts                            # Main styling - basically component library entry point
│ │ ├ Layout.tsx                          # Layout wrapper that wraps router to add dialog, tooltip, footer, etc. 
│ │ ├ AddModelButtonSubtext.tsx           # A note to let user know action will update config, for add model form
│ │ ├ ButtonWithTooltip.tsx               # Standard button used all over
│ │ ├ ChatScrollAnchor.tsx                # Uses react-intersection-observer to anchor chat to bottom when scrolled
│ │ ├ CheckDiv.tsx                        # Checkbox, unused
│ │ ├ ContinueLogo.tsx                    # Continue svg logo component
│ │ ├ FileIcon.tsx                        # Simple file icon
│ │ ├ Footer.tsx                          # GUI footer - more + settings buttons, free trial loader
│ │ ├ InfoHover.tsx                       # Tooltip with an Info icon
│ │ ├ OnboardingCard
│ │ │ ├ OnboardingCard.tsx                # Renders onboarding tabs
│ │ │ ├ components/                       # Forms and buttons used by the onboarding tabs
│ │ │ ├ hooks
│ │ │ │ ├ useOnboardingCard.ts            # Manages onboarding state/session and if it should show onboarding
│ │ │ │ ├ useSubmitOnboarding.ts          # Provides functionality to submit onboarding data to posthog
│ │ │ ├ tabs                              # The three onboarding tabs: best, local, quickstart
│ │ │ │ ├ OnboardingBestTab.tsx           # Best experience: Anthropic chat + Mistral autocomplete setup
│ │ │ │ ├ OnboardingLocalTab.tsx          # Walkthrough for downloading chat and autocomplete models with Ollama
│ │ │ │ ├ OnboardingQuickstartTab.tsx     # Quickstart - use Continue free trial
│ │ │ ├ utils.ts                          # Onboarding utils - onboardingComplete state, etc.
│ ├ PosthogPageView.ts                    # Sends a page view event to posthog on initial render
│ ├ ProfileSwitcher.tsx                   # Footer component that allows switching Continue with Teams profiles
│ ├ SafeImg.tsx                           # Image component with caching
│ ├ dialogs
│ │ ├ AddDocsDialog.tsx                   # Form that pops up when "Add Docs" is clicked at bottom of @Docs menu
│ │ ├ ConfirmationDialog.tsx              # Generic confirmation popup dialog
│ │ ├ index.tsx                           # Generic popup dialog
│ ├ gui
│ │ ├ Alert.tsx                           # Generic alert popup with info, success, warning, and error modes
│ │ ├ ErrorStepContainer.tsx              # Renders if there was an error with a chat response
│ │ ├ StepContainer.tsx                   # Shows chat response and delete/copy/helpful/unhelpful buttons
│ │ ├ TimelineItem.tsx                    # Displays a chat interaction and associated components in the timeline
│ │ ├ Tooltip.tsx                         # Styled react-tooltip wrapper
│ ├ loaders/                              # Simple loader components, e.g., FreeTrialProgressBar shown in footer
│ ├ mainInput
│ │ ├ CodeBlockExtension.tsx              # Tiptap extension for displaying code block
│ │ ├ CodeBlockComponent.tsx              # Used by code block extension to display code block
│ │ ├ CommandsExtension.ts                # Tiptap extension for displaying commands
│ │ ├ ContextItemsPeek.tsx                # List of context items under the chat input when a ContextProvider is used
│ │ ├ ContinueButton.tsx                  # Button for continue/stop streaming functionality
│ │ ├ ContinueInputBox.tsx                # Main chat input
│ │ ├ InputToolbar.tsx                    # The input toolbar component
│ │ ├ MentionExtension.ts                 # Customizations around the @tiptap/core text editor
│ │ ├ MentionList.tsx                     # List of items in the tiptap editor
│ │ ├ TipTapEditor.tsx                    # Submenu that shows suggestions/search results for actions
│ │ ├ TutorialCard.tsx                    # Card with simple usage instructions/examples, can be hidden
│ │ ├ getSuggestion.ts                    # Get lists of suggested slash commands and context providers
│ │ ├ inputModifiers.ts                   # Default input modifiers (useCodebase and noContext)
│ │ ├ resolveInput.ts                     # Converts input to string, concatenating prompts, text, input items, etc.
│ │ ├ types.d.ts                          # Combobox types
│ ├ markdown/                             # Components and styles for viewing, copying, and editing code in chat
│ ├ modelSelection/                       # Components for listing/selection in AddNewModel and ConfigureProvider 
│ ├ context
│ │ ├ IdeMessenger.ts                     # Context implementation for communication with the Extension
│ │ ├ SubmenuContextProviders.ts          # Provider shell for submenu, used in TipTapEditor
│ │ ├ VscTheme.ts                         # Simple context for the VscThemeProvider
│ ├ editorInset/                          # UNUSED alternative editor inset components
│ ├ forms
│ │ ├ AddModelForm.tsx                    # Form that shows when Add model is clicked in dropdown
│ ├ hooks
│ │ ├ CustomPostHogProvider.tsx           # Provider for data collection using posthog
│ │ ├ useAppendedString.ts                # Unused hook for custom multiline string state
│ │ ├ useArrayState.ts                    # Hook with utils for state of array of generic type (unused)
│ │ ├ useAuth.tsx                         # Auth for Continue for Teams (not live), used by profile switcher
│ │ ├ useChatHandler.ts                   # Exposes a streamResponse function to send chats and commands to IDE
│ │ ├ useHistory.tsx                      # Exposes functions for history- and session-related communications
│ │ ├ useInputHistory.ts                  # Exposes functions to get/save input history (from local storage)
│ │ ├ useNavigationListener.tsx           # Hook for handling navigation-related webview message events
│ │ ├ useSetup.ts                         # Handles initial config setup - onLoad, initial values, webview listeners
│ │ ├ useSubmenuContextProviders.tsx      # Used by the TipTapEditor to get search results for context provider
│ │ ├ useTutorialCard.ts                  # Manages local storage state for tutorial card show/closed
│ │ ├ useUIConfig.ts                      # Selector on state.config.ui
│ │ ├ useUpdatingRef.tsx                  # Hook to add dependencies that update a ref value
│ │ ├ useVscTheme.ts                      # Use styling from current VS code theme, built-in classes like .hljs-attribute
│ │ ├ useWebviewListener.ts               # React to a window message event
│ ├ pages
│ │ ├ AddNewModel
│ │ │ ├ AddNewModel.tsx                   # Form to add models, by selecting from a provider or adding local models
│ │ │ ├ ConfigureProvider.tsx             # Form to configure access to a provider, usually by entering an API key
│ │ │ ├ configs
│ │ │ │ ├ completionParamsInputs.ts       # Attributes for Input elements in the AddNewModel forms
│ │ │ │ ├ models.ts                       # Contains information to add models, like name, context length, providers
│ │ │ │ ├ providers.ts                    # Information for displaying and connecting to providers, like API key
│ │ ├ More
│ │ │ ├ More.tsx                          # The "More" page accessed from dots icon in footer
│ │ │ ├ IndexingProgress/                 # Components for showing indexing progress on More page
│ │ │ ├ KeyboardShortcuts.tsx             # Lists **default** keyboard shortcuts
│ │ │ ├ MoreHelpRow.tsx                   # Link component for help section of More page
│ │ ├ error.tsx                           # Global route error page, simple error message
│ │ ├ gui.tsx                             # MAIN CHAT GUI - chat input, scrollable chat, etc.
│ │ ├ history.tsx                         # Page that shows ordered, searchable chat history
│ │ ├ migration.tsx                       # Explaining new config.json settings migration
│ │ ├ monaco.tsx                          # Experimental multi-file editing
│ │ ├ settings.tsx                        # Page showing config settings, model temperature, font size, etc.
│ │ ├ stats.tsx                           # Page showing token usage
│ ├ redux                                 # STATE MANAGEMENT
│ │ ├ selectors
│ │ │ ├ index.ts                          # Specific state selectors for context providers, slash commands, active file
│ │ │ ├ modelSelectors.ts                 # Specific state selectors for default model, context length
│ │ ├ slices
│ │ │ ├ configSlice.ts                    # Machine ID
│ │ │ ├ miscSlice.ts                      # Server action/status message
│ │ │ ├ serverStateReducer.ts             # Config, slash commands, context providers, indexing progress
│ │ │ ├ stateSlice.ts                     # MAIN GUI STATE - Chat history, context items, session, active, profile ID
│ │ │ ├ uiStateSlice.ts                   # UI state for dialogs, onboarding cards, etc.
│ │ ├ store.ts                            # Main redux store entry point, Persist setup
│ ├ util
│ │ ├ freeTrial.ts                        # Function to limit free trial to 50 requests (stored in local storage)
│ │ ├ index.ts                            # Various keyboard, platform, environment, and object manipulation utils
│ │ ├ localStorage.ts                     # Types for values stored in local storage, and utils for setting/getting
│ ├ vite-env.d.ts                         # Enables intellisense for vite env variables - https://vite.dev/guide/env

manual-testing-sandbox

This folder of random test files is what is opened by default when debugging the vscode extension in a child window. This is achieved simply by passing the filepath "${workspaceFolder}/manual-testing-sandbox" as an arg to the "Launch Extension" launch configuration in .vscode/launch.json It has no other purpose.

├ example.ipynb
├ nested-folder
│ ├ helloNested.py
├ readme.md
├ test.css
├ test.csv
├ test.js
└ test.rs

media

The ./media directory contains media (gif, png, etc.) used by the root README.md

packages

packages contains some custom Typescript packages that are maintained within Continue and used in the codebase but operate as independent node packages. That is, they are maintained and used here but still included like any normal dependency and downloaded from package servers.

These packages include:

  { // an instance of the LlmInfo interface
    model: "claude-3-opus-20240229",
    displayName: "Claude 3 Opus",
    contextLength: 200_000,
    maxCompletionTokens: 4096,
    description:
      "Powerful model for highly complex tasks with top-level performance, intelligence, fluency, and understanding.",
    regex: /claude-3-opus/i,
  }
  • @continuedev/openai-adapters: Functions that adapt the functionality of several APIs to interchange with OpenAI data structures/patterns. Currently not used throughout codebase, but note there is a debugging extension
  • @continuedev/fetch: a custom fetch library that accepts requestOptions as defined in @continuedev/config-types and has additional streaming functionality. Seems to only be used by @continuedev/openai-adapters for now, and is redundant of core/util/fetchWithOptions
├ config-types
│ ├ src
│ │ ├ index.ts            # The zod types for continue's config.json
├ fetch
│ ├ src
│ │ ├ fetch.ts            # Custom fetch implementation that accepts config-types requestOptions
│ │ ├ index.ts            # Package entry point
│ │ ├ stream.ts           # Custom fetch streaming functionality
├ llm-info
│ ├ src
│ │ ├ index.ts            # Package entry point
│ │ ├ models              # LlmInfo data for a bunch of models from each company
│ │ │ ├ <company-name>.ts
│ │ ├ types.ts            # Defines LlmInfo and MediaType types
├ openai-adapters
│ ├ src
│ │ ├ apis
│ │ │ ├ <ApiName>.ts      # Implementation of adapter for each API (Anthropic, Gemini, etc.)
│ │ │ ├ base.ts           # Base class + parameter types for Rerank, FIM, etc. calls
│ │ ├ index.ts            # Entry point and package constructor
│ ├ test
│ │ ├ main.test.ts        # Completion, embedding, rerank, FIM tests for each adapter

scripts

scripts contains a few scripts used for VS Code tasks and VS Code Extension packaging

├ install-dependencies.sh  # script specifically used for the "install-all-dependency" VS Code tasks; installs for core, gui, extensions/vscode, binary, and docs
├ install-dependencies.ps1 # Windows powershell version of ^
├ uninstall.js             # specifically used for the "clean" task, which deletes the dependencies installed ^ as well as build directories (out/bin/dist/build/etc.)
├ util
│ └ index.js               # utils to autodetect platform and validate files post packaging. Only used within extensions/vscode

sync

NOT CURRENTLY USED

This has been replaced by e.g. extensions/vscode/src/util/indexCodebase.ts

The rust crate can index a codebase, by

  • generating Merkle trees when a file is added/modified/deleted
  • comparing to existing Merkle trees to identify which files need to be reindexed
  • updating tags for those files

A Merkle Tree is a hierarchical data structure used to represent a directory. Essentially, it's a tree of nodes, with files represented by their hashed contents

In this implementation the trees are stored in a sqlite database and the tags are stored in a JSON mapping

├ .vscode
│ ├ settings.json  # disables rust-analyzer autodiscovery https://rust-analyzer.github.io/manual.html
├ src
│ ├ README.md      
│ ├ db 
│ │ ├ mod.rs       # functions for storing the merkle trees in local sqlite db at ~/.continue/index/sync.db
│ ├ gitignore.rs   # enables the merkle implementation to ignore files like a normal gitignore
│ ├ lib.rs         # Python bindings
│ ├ sync.rs        # Sync the tags
│ ├ sync
│ │ ├ merkle.rs    # Merkle tree construction implementation
│ │ ├ mod.rs       # duplicate of sync.rs
│ ├ sync_db.rs     # Essentially runs the sync function
│ ├ utils.rs       # for creating temporary directory
│ ├ utils
│ │ └ mod.rs       # Duplicate of utils.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment