✨ merge preview to main (#575)
* Strong typing (#533) * refactor: ♻️ get rid of continuedev.src.continuedev structure * refactor: ♻️ switching back to server folder * feat: ✨ make config.py imports shorter * feat: 🔖 publish as pre-release vscode extension * refactor: ♻️ refactor and add more completion params to ui * build: 🏗️ download from preview S3 * fix: 🐛 fix paths * fix: 💚 package:pre-release * ci: 💚 more time for tests * fix: 💚 fix build scripts * fix: 🐛 fix import in run.py * fix: 🔖 update version to try again * ci: 💚 Update package.json version [skip ci] * refactor: 🔥 don't check for old extensions version * fix: 🐛 small bug fixes * fix: 🐛 fix config.py import paths * ci: 💚 Update package.json version [skip ci] * ci: 💚 platform-specific builds test #1 * feat: 💚 ship with binary * fix: 💚 fix copy statement to include.exe for windows * fix: 💚 cd extension before packaging * chore: 🔊 count tokens generated * fix: 💚 remove npm_config_arch * fix: 💚 publish as pre-release! * chore: 🔖 update version * perf: 💚 hardcode distro paths * fix: 🐛 fix yaml syntax error * chore: 🔖 update version * fix: 💚 update permissions and version * feat: 🐛 kill old server if needed * feat: 💄 update marketplace icon for pre-release * ci: 💚 Update package.json version [skip ci] * feat: ✨ auto-reload for config.py * feat: 🔧 update default config.py imports * feat: ✨ codelens in config.py * feat: ✨ select model param count from UI * ci: 💚 Update package.json version [skip ci] * feat: ✨ more model options, ollama error handling * perf: ⚡ don't show server loading immediately * fix: 🐛 fixing small UI details * ci: 💚 Update package.json version [skip ci] * feat: 🚀 headers param on LLM class * fix: 🐛 fix headers for openai.;y * feat: ✨ highlight code on cmd+shift+L * ci: 💚 Update package.json version [skip ci] * feat: 💄 sticky top bar in gui.tsx * fix: 🔊 websocket logging and horizontal scrollbar * ci: 💚 Update package.json version [skip ci] * feat: ✨ allow AzureOpenAI Service through GGML * ci: 💚 Update package.json version [skip ci] * fix: 🐛 fix automigration * ci: 💚 Update package.json version [skip ci] * ci: 💚 upload binaries in ci, download apple silicon * chore: 🔥 remove notes * fix: 💚 use curl to download binary * fix: 💚 set permissions on apple silicon binary * fix: 💚 testing * fix: 💚 cleanup file * fix: 💚 fix preview.yaml * fix: 💚 only upload once per binary * fix: 💚 install rosetta * ci: 💚 download binary after tests * ci: 💚 Update package.json version [skip ci] * ci: 💚 prepare ci for merge to main * feat: ✨ improved edit prompts for OS models * feat: ✨ add edit templates to model packages * feat: 👔 allow timeout param for OpenAI LLM class * ci: 💚 Update package.json version [skip ci] * feat: 💄 add textgenwebui as official option in Ui * fix: 🐛 fix for --meilisearch-url flag * fix: 🐛 meilisearch fixes * feat: ✨ display model params for previous prompts * fix: 🐛 fix overriding of system message * ci: 💚 Update package.json version [skip ci] * fix: ⚡ update count_tokens method * feat: ⚡ reduce default max_tokens * fix: 🐛 fix set_system_message * ✨ Codebase Embeddings (#547) * feat: ✨ basic codebase embeddings * feat: 🚧 reranking after chroma retrieval * refactor: 🚚 rename binary: run to continue_server * ci: 💚 only do pypi step in github workflow * ci: 🏷 Update PyPI version [skip ci] * feat: 🐛 add openai_api_key param for chroma steps * ci: 🏷 Update PyPI version [skip ci] * build: 💚 update pypi package * ci: 🏷 Update PyPI version [skip ci] * fix: 🐛 rename run.spec * ci: 🏷 Update PyPI version [skip ci] * feat: ✨ params to control embeddings search * ci: 🏷 Update PyPI version [skip ci] * rename run.py * feat: 🚧 improvements in progress for embeddings * feat: 🎨 last bit of cleaning for chunked embeddings * ci: 💚 add back pypi deployment in main.yam * ci: 🏷 Update PyPI version [skip ci] * fix: 🐛 error handling for chroma index in non-git folder * ci: 🏷 Update PyPI version [skip ci] * fix: 🐛 don't log reranking prompt * ci: 🏷 Update PyPI version [skip ci] * feat: ✨ add option to select embeddings model * ci: 🏷 Update PyPI version [skip ci] * move path decode/encode functions * ci: 🏷 Update PyPI version [skip ci] * update spec file * Preview (#541) * Strong typing (#533) * refactor: ♻️ get rid of continuedev.src.continuedev structure * refactor: ♻️ switching back to server folder * feat: ✨ make config.py imports shorter * feat: 🔖 publish as pre-release vscode extension * refactor: ♻️ refactor and add more completion params to ui * build: 🏗️ download from preview S3 * fix: 🐛 fix paths * fix: 💚 package:pre-release * ci: 💚 more time for tests * fix: 💚 fix build scripts * fix: 🐛 fix import in run.py * fix: 🔖 update version to try again * ci: 💚 Update package.json version [skip ci] * refactor: 🔥 don't check for old extensions version * fix: 🐛 small bug fixes * fix: 🐛 fix config.py import paths * ci: 💚 Update package.json version [skip ci] * ci: 💚 platform-specific builds test #1 * feat: 💚 ship with binary * fix: 💚 fix copy statement to include.exe for windows * fix: 💚 cd extension before packaging * chore: 🔊 count tokens generated * fix: 💚 remove npm_config_arch * fix: 💚 publish as pre-release! * chore: 🔖 update version * perf: 💚 hardcode distro paths * fix: 🐛 fix yaml syntax error * chore: 🔖 update version * fix: 💚 update permissions and version * feat: 🐛 kill old server if needed * feat: 💄 update marketplace icon for pre-release * ci: 💚 Update package.json version [skip ci] * feat: ✨ auto-reload for config.py * feat: 🔧 update default config.py imports * feat: ✨ codelens in config.py * feat: ✨ select model param count from UI * ci: 💚 Update package.json version [skip ci] * feat: ✨ more model options, ollama error handling * perf: ⚡ don't show server loading immediately * fix: 🐛 fixing small UI details * ci: 💚 Update package.json version [skip ci] * feat: 🚀 headers param on LLM class * fix: 🐛 fix headers for openai.;y * feat: ✨ highlight code on cmd+shift+L * ci: 💚 Update package.json version [skip ci] * feat: 💄 sticky top bar in gui.tsx * fix: 🔊 websocket logging and horizontal scrollbar * ci: 💚 Update package.json version [skip ci] * feat: ✨ allow AzureOpenAI Service through GGML * ci: 💚 Update package.json version [skip ci] * fix: 🐛 fix automigration * ci: 💚 Update package.json version [skip ci] * ci: 💚 upload binaries in ci, download apple silicon * chore: 🔥 remove notes * fix: 💚 use curl to download binary * fix: 💚 set permissions on apple silicon binary * fix: 💚 testing * fix: 💚 cleanup file * fix: 💚 fix preview.yaml * fix: 💚 only upload once per binary * fix: 💚 install rosetta * ci: 💚 download binary after tests * ci: 💚 Update package.json version [skip ci] * ci: 💚 prepare ci for merge to main --------- Co-authored-by: GitHub Action <action@github.com> * fix: 📝 fix deployent readme * chore: 🔖 update package.json version * fix: 🐛 fix ci to only upload from linux x64, not alpine * ci: 💚 Update package.json version [skip ci] * fix: 🐛 fixing up * refactor: 🔥 remove sentence_transformers_model option * ci: 💚 run preview.yaml * refactor: ♻️ rename to continue_server * ci: 💚 update python version in continue_server.spec * ci: 💚 checking paths * ci: 💚 find path of site-packages * fix * ci: 💚 deploy to pre-release * ci: 💚 change branch to pull from in ci * perf: 👷 build with tiktoken vocab * chore: 🔖 upgrade version * ci: 💚 Update package.json version [skip ci] * fix: ⚡ update count_tokens method * ci: 💚 download continue_server, not run * ci: 💚 Update package.json version [skip ci] * feat: ⚡ reduce default max_tokens * fix: 🐛 fix set_system_message * ci: 💚 update ci for preview branch * build: 💚 update pypi package --------- Co-authored-by: GitHub Action <action@github.com> * ci: 💚 publish to pypi in seperate step * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * feat: 🎨 small changes to /codebase ui * 📌 update pydantic version * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 🐛 check for DISCONNECTED before closing ws * 🐛 check for disconnected before sending ws msg * 🚸 add python path to global vscode settings * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 💄 stop button * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 🚑 solve ssl file not found error * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 🔒️ trust_env=True for proxy env var * ⚡️ always use custom aiohttp session for openai * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * ⚡️ flatten messages * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 🐛 migrate away from legacy completions endpoint * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 🚑 fix delta undefined * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * ⚡️ retry for readfile in index generation * 💄 inserting at cursor above input box * ⚡️ debouncing /edit streaming * Initial intelliJ plugin changes to support webview (#457) * Initial intelliJ plugin changes to support webview * connect webview websockets * Starting work on downloading server binary from S3 * fix color theme in intellij * refactor name to continuedev * correctly set important variables for onLoad * highlighted code now working * keyboard shortcuts (Actions) * fix: 🐛 hf_tgi fix, proxy support for ggml * fix: 🐛 remove unecessary logging * Sync the changes * Clean up code * updating how continue works * ci: 🏷 Update PyPI version [skip ci] * docs: 📝 docs for customizing chat / edit templates * docs: 📝 headless mode docs (start) * docs: 📝 updated setup docs * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * fix: 🐛 compatibility with python 3.8 * feat: ✨ verify_ssl option for all LLMs * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * fix: 🐛 verify_ssl and ssl_context mutual exclusivity * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * feat: 🩹 ca_bundle_path for maybeproxyopenai * fix: 🐛 a few minor fixes * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * fix: 🐛 custom escaping instead of URI for diff paths * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * fix: 🐛 fix huggingface tgi * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * docs: 📝 small docs update on how continue works * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * Clarifying `logs` instructions in troubleshooting.md (#476) * fix: 🐛 fixes to templating messages * fix: some typos (#478) * fix: 🐛 fix for lmstudio defaults * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * Implement design patterns for better extensibility * Fix: Ensure read operations in ContinuePluginSelectionListener are run within the correct context using runReadAction. * feat: ✨ implement most other ideProtocolClient methods * wait until server is running to connect * remove unnecessary imports, update version * reformat code and optimize the imports * fix: 🐛 fix serialization bug * fix: 🐛 attempt to fix error from jetbrains marketplace * a few updates * fix: 🐛 bringing jetbrains up to par * feat: ✨ highlighted code updates in intellij * fix: 🚑 fix freezing issue * fix: 🐛 fix icons, bump version * feat: ✨ /edit support, other fixes * quick input, keyboard shortcuts * fix: 🐛 fix /edit and keyboard shortcuts and lagging on scroll * feat: 💄 welcome panel * chore: 🔖 update version * ide endpoint for websockets * fix: 🚑 fix freezing problem * quick input * fix: 🐛 small jetbrains fixes * fix: 💄 nicer dropdown that can "drop up" * fix: 🐛 fix font size for dropdown * fix: 💄 fix textarea for quickinput * Preview (#541) * Strong typing (#533) * refactor: ♻️ get rid of continuedev.src.continuedev structure * refactor: ♻️ switching back to server folder * feat: ✨ make config.py imports shorter * feat: 🔖 publish as pre-release vscode extension * refactor: ♻️ refactor and add more completion params to ui * build: 🏗️ download from preview S3 * fix: 🐛 fix paths * fix: 💚 package:pre-release * ci: 💚 more time for tests * fix: 💚 fix build scripts * fix: 🐛 fix import in run.py * fix: 🔖 update version to try again * ci: 💚 Update package.json version [skip ci] * refactor: 🔥 don't check for old extensions version * fix: 🐛 small bug fixes * fix: 🐛 fix config.py import paths * ci: 💚 Update package.json version [skip ci] * ci: 💚 platform-specific builds test #1 * feat: 💚 ship with binary * fix: 💚 fix copy statement to include.exe for windows * fix: 💚 cd extension before packaging * chore: 🔊 count tokens generated * fix: 💚 remove npm_config_arch * fix: 💚 publish as pre-release! * chore: 🔖 update version * perf: 💚 hardcode distro paths * fix: 🐛 fix yaml syntax error * chore: 🔖 update version * fix: 💚 update permissions and version * feat: 🐛 kill old server if needed * feat: 💄 update marketplace icon for pre-release * ci: 💚 Update package.json version [skip ci] * feat: ✨ auto-reload for config.py * feat: 🔧 update default config.py imports * feat: ✨ codelens in config.py * feat: ✨ select model param count from UI * ci: 💚 Update package.json version [skip ci] * feat: ✨ more model options, ollama error handling * perf: ⚡ don't show server loading immediately * fix: 🐛 fixing small UI details * ci: 💚 Update package.json version [skip ci] * feat: 🚀 headers param on LLM class * fix: 🐛 fix headers for openai.;y * feat: ✨ highlight code on cmd+shift+L * ci: 💚 Update package.json version [skip ci] * feat: 💄 sticky top bar in gui.tsx * fix: 🔊 websocket logging and horizontal scrollbar * ci: 💚 Update package.json version [skip ci] * feat: ✨ allow AzureOpenAI Service through GGML * ci: 💚 Update package.json version [skip ci] * fix: 🐛 fix automigration * ci: 💚 Update package.json version [skip ci] * ci: 💚 upload binaries in ci, download apple silicon * chore: 🔥 remove notes * fix: 💚 use curl to download binary * fix: 💚 set permissions on apple silicon binary * fix: 💚 testing * fix: 💚 cleanup file * fix: 💚 fix preview.yaml * fix: 💚 only upload once per binary * fix: 💚 install rosetta * ci: 💚 download binary after tests * ci: 💚 Update package.json version [skip ci] * ci: 💚 prepare ci for merge to main --------- Co-authored-by: GitHub Action <action@github.com> * fix: 📝 fix deployent readme * fix: 🐛 do read operation in readAction * chore: 🔖 update version * 🐛 small jetbrains fixes * ⚡️ exponential backoff jetbrains * 🐛 fix history loading bug * 💄 many small ui fixes * 🐛 fixes freezing problem (actually) * 🥅 catch errors, other stuff * 🐛 many jetbrains fixes * 💄 when no context items found, say in dropdown * 🎉 VS Code tutorial * ✨ jetbrains tutorial file * ⚡️ exponential backoff for ide websockets * 🎉 unused work on intellij editor inlay * ✨ server loading progress messages * ✨ additional progress update * 💄 fix /edit flickering, keyboard interactions --------- Co-authored-by: Nate Sesti <sestinj@gmail.com> Co-authored-by: Ty Dunn <ty@tydunn.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Aaron Mihalik <amihalik@users.noreply.github.com> Co-authored-by: LangLangBart <92653266+LangLangBart@users.noreply.github.com> Co-authored-by: Nate Sesti <33237525+sestinj@users.noreply.github.com> * 💚 update binaries in preview workflow * ci: 🏷 Update PyPI version [skip ci] * 💚 log prepackaging error * 💚 remove ci steps for testing * 💚 make npm run build work on windows * 🔥 remove codebase embeddings from default config * 🐛 fix jetbrains input key handling * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 🔊 add vscMachineId to user interest form * 💄 focus continue input box after quick input * ✨ Show VS Code Tutorial * ✨ chatml template_messages * 🐛 fix gh action s3 bucket name, handle ollama err * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * ✏️ automatically remove trailing / from serverUrl * Nate/better embeddings (#564) * ♻️ refactoring codebase index folder * ➕ tree_sitter dependency * 🐛 solve a few indexing bugs * ⚡️ code chunker * ✏️ automatically remove trailing / from serverUrl * 🎨 introduce Chunk class * 🎨 finish chunking refactor * 🐛 call format_exception so that 3.8-compatible * ci: 🏷 Update PyPI version [skip ci] * register/unregister shortcuts instead of unregistering the commands themselves (#568) * 💚 fix tree_sitter_languages build for windows * 🚸 allow toggling telemetry from vscode settings * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 🔊 update logging * ♻️ refactor extension folders and react-app * fix: hotkey for new session (#572) * 💄 file icons, preview context items * 💄 toggle to show context items * 💄 nicer preview dropdown * ci: 🏷 Update PyPI version [skip ci] * 💚 fix path in yaml * ci: 🏷 Update PyPI version [skip ci] * 💚 one more path fix to GH workflows * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 💄 inline keyboard shortcut suggestions * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 👷 parameterize .spec file * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 🐛 use platform-specific keyboard shortcut icons * ci: 🏷 Update PyPI version [skip ci] * ci: 💚 Update package.json version [skip ci] * 📝 fix sidebars.js --------- Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Bishwendu Kundu <bishwenduk029@gmail.com> Co-authored-by: Ty Dunn <ty@tydunn.com> Co-authored-by: Aaron Mihalik <amihalik@users.noreply.github.com> Co-authored-by: LangLangBart <92653266+LangLangBart@users.noreply.github.com> Co-authored-by: James Vogel <jim.m.vogel@gmail.com>
117
.github/workflows/main.yaml
vendored
|
|
@ -48,7 +48,6 @@ jobs:
|
|||
npm_config_arch: arm64
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
||||
# 1. Build the Pyinstaller binary
|
||||
- name: Check-out repository
|
||||
uses: actions/checkout@v3
|
||||
|
|
@ -58,54 +57,63 @@ jobs:
|
|||
with:
|
||||
python-version: "3.10.8"
|
||||
|
||||
- name: Install Pyinstaller
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install pyinstaller
|
||||
python -m pip install --upgrade pip
|
||||
pip install poetry
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
pip install -r server/requirements.txt
|
||||
|
||||
- name: Build PyInstaller Executable
|
||||
run: pyinstaller run.spec
|
||||
# 1.25 Publish to PyPI
|
||||
|
||||
# 1.5 Place the binary in extension/exe directory
|
||||
- name: Make sure extension/exe directory exists
|
||||
- name: Configure Poetry Token
|
||||
run: cd server && poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
|
||||
|
||||
- name: Bump the version
|
||||
run: cd server && poetry version patch
|
||||
|
||||
- name: Build and publish the package
|
||||
run: cd server && poetry publish --build
|
||||
|
||||
# 1.5 Place the binary in extensions/vscode/exe directory
|
||||
- name: Make sure extensions/vscode/exe directory exists
|
||||
run: |
|
||||
mkdir -p extension/exe
|
||||
mkdir -p extensions/vscode/exe
|
||||
|
||||
- name: Copy binary to extension (non-Windows)
|
||||
run: |
|
||||
cp dist/run extension/exe/run
|
||||
cp dist/run extensions/vscode/exe/run
|
||||
if: matrix.os != 'windows-latest'
|
||||
|
||||
- name: Copy binary to extension (Windows)
|
||||
run: |
|
||||
cp dist/run.exe extension/exe/run.exe
|
||||
cp dist/run.exe extensions/vscode/exe/run.exe
|
||||
if: matrix.os == 'windows-latest'
|
||||
|
||||
# 1.8 Set permissions and upload binary
|
||||
- name: Set permissions
|
||||
run: |
|
||||
chmod 777 extension/exe/run
|
||||
chmod 777 extensions/vscode/exe/run
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: matrix.os == 'macos-latest' && matrix.arch == 'x64'
|
||||
with:
|
||||
name: macOSBinary
|
||||
path: extension/exe/run
|
||||
|
||||
path: extensions/vscode/exe/run
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: matrix.os == 'ubuntu-20.04' && matrix.arch == 'x64' && matrix.platform == 'linux'
|
||||
with:
|
||||
name: LinuxBinary
|
||||
path: extension/exe/run
|
||||
|
||||
path: extensions/vscode/exe/run
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: matrix.os == 'windows-latest' && matrix.arch == 'x64'
|
||||
with:
|
||||
name: WindowsBinary
|
||||
path: extension/exe/run.exe
|
||||
path: extensions/vscode/exe/run.exe
|
||||
|
||||
# 2. Install npm dependencies
|
||||
- name: Use Node.js 19.0.0
|
||||
|
|
@ -116,34 +124,34 @@ jobs:
|
|||
- name: Cache extension node_modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: extension/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('extension/package-lock.json') }}
|
||||
path: extensions/vscode/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
|
||||
|
||||
- name: Cache react-app node_modules
|
||||
- name: Cache gui node_modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: extension/react-app/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('extension/react-app/package-lock.json') }}
|
||||
path: gui/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
|
||||
|
||||
- name: Install extension Dependencies
|
||||
run: |
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm ci
|
||||
|
||||
- name: Add a copy of continuedev to the extension
|
||||
run: |
|
||||
cd extension
|
||||
cp -r ../server/continuedev continuedev
|
||||
cd extensions/vscode
|
||||
cp -r ../../server/continuedev continuedev
|
||||
|
||||
- name: Install react-app Dependencies
|
||||
- name: Install gui Dependencies
|
||||
run: |
|
||||
cd extension/react-app
|
||||
cd gui
|
||||
npm ci --legacy-peer-deps
|
||||
|
||||
# 3. Run tests for the extension
|
||||
- name: Prepare the extension
|
||||
run: |
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm run prepackage
|
||||
|
||||
- name: Install Xvfb for Linux and run tests
|
||||
|
|
@ -151,39 +159,39 @@ jobs:
|
|||
sudo apt-get install -y xvfb # Install Xvfb
|
||||
Xvfb :99 & # Start Xvfb
|
||||
export DISPLAY=:99 # Export the display number to the environment
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm run test
|
||||
if: matrix.os == 'ubuntu-20.04'
|
||||
|
||||
- name: Run extension tests
|
||||
run: |
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm run test
|
||||
if: matrix.os != 'ubuntu-20.04'
|
||||
|
||||
# 3.5 If on Apple Silicon, download the binary from S3 bucket
|
||||
- name: Remove existing binary
|
||||
if: matrix.os == 'macos-latest' && matrix.arch == 'arm64'
|
||||
run: rm extension/exe/run
|
||||
run: rm extensions/vscode/exe/run
|
||||
|
||||
- name: Download Apple Silicon Binary
|
||||
if: matrix.os == 'macos-latest' && matrix.arch == 'arm64'
|
||||
run: curl -o extension/exe/run https://continue-server-binaries.s3.us-west-1.amazonaws.com/apple-silicon/run
|
||||
run: curl -o extensions/vscode/exe/run https://continue-server-binaries.s3.us-west-1.amazonaws.com/apple-silicon/run
|
||||
|
||||
- name: Set permissions
|
||||
run: |
|
||||
chmod -R 777 extension/exe/run
|
||||
chmod -R 777 extensions/vscode/exe/run
|
||||
|
||||
# 4. Package the extension
|
||||
- shell: pwsh
|
||||
run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
|
||||
- run: cd extension && npx vsce package --target ${{ env.target }}
|
||||
- run: cd extensions/vscode && npx vsce package --target ${{ env.target }}
|
||||
|
||||
# 5. Upload the .vsix as an artifact
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ env.target }}
|
||||
path: "extension/*.vsix"
|
||||
path: "extensions/vscode/*.vsix"
|
||||
|
||||
# 6. Upload continue.log as an artifact for debugging of the workflow
|
||||
- name: Upload continue.log
|
||||
|
|
@ -199,7 +207,6 @@ jobs:
|
|||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
|
||||
# 0. Setup git
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
|
@ -217,28 +224,28 @@ jobs:
|
|||
|
||||
# 2. Publish the extension to VS Code Marketplace
|
||||
- run: |
|
||||
cd extension
|
||||
npx vsce publish --packagePath ../alpine-x64/*.vsix ../darwin-arm64/*.vsix ../darwin-x64/*.vsix ../linux-arm64/*.vsix ../linux-armhf/*.vsix ../linux-x64/*.vsix ../win32-ia32/*.vsix ../win32-x64/*.vsix ../win32-arm64/*.vsix
|
||||
cd extensions/vscode
|
||||
npx vsce publish --packagePath ../../alpine-x64/*.vsix ../../darwin-arm64/*.vsix ../../darwin-x64/*.vsix ../../linux-arm64/*.vsix ../../linux-armhf/*.vsix ../../linux-x64/*.vsix ../../win32-ia32/*.vsix ../../win32-x64/*.vsix ../../win32-arm64/*.vsix
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
|
||||
|
||||
# 3. Publish the extension to Open VSX Registry
|
||||
- name: Publish (Open VSX Registry)
|
||||
run: |
|
||||
cd extension
|
||||
npx ovsx publish -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../alpine-x64/*.vsix ../darwin-arm64/*.vsix ../darwin-x64/*.vsix ../linux-arm64/*.vsix ../linux-armhf/*.vsix ../linux-x64/*.vsix ../win32-ia32/*.vsix ../win32-x64/*.vsix ../win32-arm64/*.vsix
|
||||
cd extensions/vscode
|
||||
npx ovsx publish -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../alpine-x64/*.vsix ../../darwin-arm64/*.vsix ../../darwin-x64/*.vsix ../../linux-arm64/*.vsix ../../linux-armhf/*.vsix ../../linux-x64/*.vsix ../../win32-ia32/*.vsix ../../win32-x64/*.vsix ../../win32-arm64/*.vsix
|
||||
|
||||
# 4. Update the package.json version and push changes
|
||||
- name: Update version in package.json
|
||||
run: |
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm version patch
|
||||
|
||||
- name: Commit changes
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git commit -am "ci: 💚 Update package.json version [skip ci]"
|
||||
git commit -am "ci: 🏷 Update PyPI version [skip ci]"
|
||||
|
||||
- name: Push changes
|
||||
uses: ad-m/github-push-action@master
|
||||
|
|
@ -265,24 +272,6 @@ jobs:
|
|||
name: WindowsBinary
|
||||
path: exe/windows
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: us-west-1
|
||||
|
||||
- name: Upload binaries to S3 (continue-server-binaries)
|
||||
uses: jakejarvis/s3-sync-action@master
|
||||
with:
|
||||
args: --acl public-read --follow-symlinks
|
||||
env:
|
||||
AWS_S3_BUCKET: continue-server-binaries
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_REGION: "us-west-1"
|
||||
SOURCE_DIR: "exe"
|
||||
|
||||
- name: Upload binaries to S3 (s3.continue.dev)
|
||||
uses: jakejarvis/s3-sync-action@master
|
||||
with:
|
||||
|
|
@ -294,3 +283,13 @@ jobs:
|
|||
AWS_REGION: "us-west-1"
|
||||
SOURCE_DIR: "exe"
|
||||
|
||||
- name: Upload binaries to S3 (continue-server-binaries)
|
||||
uses: jakejarvis/s3-sync-action@master
|
||||
with:
|
||||
args: --acl public-read --follow-symlinks
|
||||
env:
|
||||
AWS_S3_BUCKET: continue-server-binaries
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_REGION: "us-west-1"
|
||||
SOURCE_DIR: "exe"
|
||||
|
|
|
|||
164
.github/workflows/preview.yaml
vendored
|
|
@ -6,6 +6,48 @@ on:
|
|||
- preview
|
||||
|
||||
jobs:
|
||||
pypi-deployment:
|
||||
runs-on: ubuntu-20.04
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.10.8"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install poetry
|
||||
|
||||
- name: Install project dependencies
|
||||
run: cd server && poetry install
|
||||
|
||||
- name: Configure Poetry Token
|
||||
run: cd server && poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
|
||||
|
||||
- name: Bump the version
|
||||
run: cd server && poetry version patch
|
||||
|
||||
- name: Build and publish the package
|
||||
run: cd server && poetry publish --build
|
||||
|
||||
- name: Commit changes
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git commit -am "ci: 🏷 Update PyPI version [skip ci]"
|
||||
|
||||
- name: Push changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ github.ref }}
|
||||
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
|
|
@ -65,46 +107,51 @@ jobs:
|
|||
run: |
|
||||
pip install -r server/requirements.txt
|
||||
|
||||
- name: Build PyInstaller Executable
|
||||
run: pyinstaller run.spec
|
||||
|
||||
# 1.5 Place the binary in extension/exe directory
|
||||
- name: Make sure extension/exe directory exists
|
||||
- name: Install tiktoken vocab file
|
||||
run: |
|
||||
mkdir -p extension/exe
|
||||
mkdir .tiktoken_cache
|
||||
curl -o .tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4 https://s3.us-west-1.amazonaws.com/s3.continue.dev/tiktoken/9b5ad71b2ce5302211f9c61530b329a4922fc6a4
|
||||
|
||||
- name: Build PyInstaller Executable
|
||||
run: pyinstaller continue_server.spec
|
||||
|
||||
# 1.5 Place the binary in extensions/vscode/exe directory
|
||||
- name: Make sure extensions/vscode/exe directory exists
|
||||
run: |
|
||||
mkdir -p extensions/vscode/exe
|
||||
|
||||
- name: Copy binary to extension (non-Windows)
|
||||
run: |
|
||||
cp dist/run extension/exe/run
|
||||
cp dist/continue_server extensions/vscode/exe/continue_server
|
||||
if: matrix.os != 'windows-latest'
|
||||
|
||||
- name: Copy binary to extension (Windows)
|
||||
run: |
|
||||
cp dist/run.exe extension/exe/run.exe
|
||||
cp dist/continue_server.exe extensions/vscode/exe/continue_server.exe
|
||||
if: matrix.os == 'windows-latest'
|
||||
|
||||
# 1.8 Set permissions and upload binary
|
||||
- name: Set permissions
|
||||
run: |
|
||||
chmod 777 extension/exe/run
|
||||
chmod 777 extensions/vscode/exe/continue_server
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: matrix.os == 'macos-latest' && matrix.arch == 'x64'
|
||||
with:
|
||||
name: macOSBinary
|
||||
path: extension/exe/run
|
||||
|
||||
path: extensions/vscode/exe/continue_server
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: matrix.os == 'ubuntu-20.04' && matrix.arch == 'x64' && matrix.platform == 'linux'
|
||||
with:
|
||||
name: LinuxBinary
|
||||
path: extension/exe/run
|
||||
|
||||
path: extensions/vscode/exe/continue_server
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: matrix.os == 'windows-latest' && matrix.arch == 'x64'
|
||||
with:
|
||||
name: WindowsBinary
|
||||
path: extension/exe/run.exe
|
||||
path: extensions/vscode/exe/continue_server.exe
|
||||
|
||||
# 2. Install npm dependencies
|
||||
- name: Use Node.js 19.0.0
|
||||
|
|
@ -115,34 +162,34 @@ jobs:
|
|||
- name: Cache extension node_modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: extension/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('extension/package-lock.json') }}
|
||||
path: extensions/vscode/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
|
||||
|
||||
- name: Cache react-app node_modules
|
||||
- name: Cache gui node_modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: extension/react-app/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('extension/react-app/package-lock.json') }}
|
||||
path: gui/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
|
||||
|
||||
- name: Install extension Dependencies
|
||||
run: |
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm ci
|
||||
|
||||
- name: Add a copy of continuedev to the extension
|
||||
run: |
|
||||
cd extension
|
||||
cp -r ../server/continuedev continuedev
|
||||
cd extensions/vscode
|
||||
cp -r ../../server/continuedev continuedev
|
||||
|
||||
- name: Install react-app Dependencies
|
||||
- name: Install gui Dependencies
|
||||
run: |
|
||||
cd extension/react-app
|
||||
cd gui
|
||||
npm ci --legacy-peer-deps
|
||||
|
||||
# 3. Run tests for the extension
|
||||
- name: Prepare the extension
|
||||
run: |
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm run prepackage
|
||||
|
||||
- name: Install Xvfb for Linux and run tests
|
||||
|
|
@ -150,39 +197,39 @@ jobs:
|
|||
sudo apt-get install -y xvfb # Install Xvfb
|
||||
Xvfb :99 & # Start Xvfb
|
||||
export DISPLAY=:99 # Export the display number to the environment
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm run test
|
||||
if: matrix.os == 'ubuntu-20.04'
|
||||
|
||||
- name: Run extension tests
|
||||
run: |
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm run test
|
||||
if: matrix.os != 'ubuntu-20.04'
|
||||
|
||||
# 3.5 If on Apple Silicon, download the binary from S3 bucket
|
||||
- name: Remove existing binary
|
||||
if: matrix.os == 'macos-latest' && matrix.arch == 'arm64'
|
||||
run: rm extension/exe/run
|
||||
run: rm extensions/vscode/exe/continue_server
|
||||
|
||||
- name: Download Apple Silicon Binary
|
||||
if: matrix.os == 'macos-latest' && matrix.arch == 'arm64'
|
||||
run: curl -o extension/exe/run https://continue-server-binaries.s3.us-west-1.amazonaws.com/apple-silicon/run
|
||||
run: curl -o extensions/vscode/exe/continue_server https://continue-server-binaries.s3.us-west-1.amazonaws.com/apple-silicon/continue_server
|
||||
|
||||
- name: Set permissions
|
||||
run: |
|
||||
chmod -R 777 extension/exe/run
|
||||
chmod -R 777 extensions/vscode/exe/continue_server
|
||||
|
||||
# 4. Package the extension
|
||||
- shell: pwsh
|
||||
run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
|
||||
- run: cd extension && npx vsce package --pre-release --target ${{ env.target }}
|
||||
- run: cd extensions/vscode && npx vsce package --pre-release --target ${{ env.target }}
|
||||
|
||||
# 5. Upload the .vsix as an artifact
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ env.target }}
|
||||
path: "extension/*.vsix"
|
||||
path: "extensions/vscode/*.vsix"
|
||||
|
||||
# 6. Upload continue.log as an artifact for debugging of the workflow
|
||||
- name: Upload continue.log
|
||||
|
|
@ -215,21 +262,21 @@ jobs:
|
|||
|
||||
# 2. Publish the extension to VS Code Marketplace
|
||||
- run: |
|
||||
cd extension
|
||||
npx vsce publish --pre-release --packagePath ../alpine-x64/*.vsix ../darwin-arm64/*.vsix ../darwin-x64/*.vsix ../linux-arm64/*.vsix ../linux-armhf/*.vsix ../linux-x64/*.vsix ../win32-ia32/*.vsix ../win32-x64/*.vsix ../win32-arm64/*.vsix
|
||||
cd extensions/vscode
|
||||
npx vsce publish --pre-release --packagePath ../../alpine-x64/*.vsix ../../darwin-arm64/*.vsix ../../darwin-x64/*.vsix ../../linux-arm64/*.vsix ../../linux-armhf/*.vsix ../../linux-x64/*.vsix ../../win32-ia32/*.vsix ../../win32-x64/*.vsix ../../win32-arm64/*.vsix
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
|
||||
|
||||
# 3. Publish the extension to Open VSX Registry
|
||||
- name: Publish (Open VSX Registry)
|
||||
run: |
|
||||
cd extension
|
||||
npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../alpine-x64/*.vsix ../darwin-arm64/*.vsix ../darwin-x64/*.vsix ../linux-arm64/*.vsix ../linux-armhf/*.vsix ../linux-x64/*.vsix ../win32-ia32/*.vsix ../win32-x64/*.vsix ../win32-arm64/*.vsix
|
||||
cd extensions/vscode
|
||||
npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../alpine-x64/*.vsix ../../darwin-arm64/*.vsix ../../darwin-x64/*.vsix ../../linux-arm64/*.vsix ../../linux-armhf/*.vsix ../../linux-x64/*.vsix ../../win32-ia32/*.vsix ../../win32-x64/*.vsix ../../win32-arm64/*.vsix
|
||||
|
||||
# 4. Update the package.json version and push changes
|
||||
- name: Update version in package.json
|
||||
run: |
|
||||
cd extension
|
||||
cd extensions/vscode
|
||||
npm version patch
|
||||
|
||||
- name: Commit changes
|
||||
|
|
@ -242,4 +289,45 @@ jobs:
|
|||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ github.ref }}
|
||||
branch: ${{ github.ref }}
|
||||
|
||||
# 5. Download binaries and upload to S3
|
||||
- name: Download Linux build
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: LinuxBinary
|
||||
path: exe/linux
|
||||
|
||||
- name: Download macOS build
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: macOSBinary
|
||||
path: exe/mac
|
||||
|
||||
- name: Download Windows build
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: WindowsBinary
|
||||
path: exe/windows
|
||||
|
||||
- name: Upload binaries to S3 (s3.continue.dev)
|
||||
uses: jakejarvis/s3-sync-action@master
|
||||
with:
|
||||
args: --acl public-read --follow-symlinks
|
||||
env:
|
||||
AWS_S3_BUCKET: s3.continue.dev
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_REGION: "us-west-1"
|
||||
SOURCE_DIR: "exe"
|
||||
|
||||
- name: Upload binaries to S3 (continue-server-binaries)
|
||||
uses: jakejarvis/s3-sync-action@master
|
||||
with:
|
||||
args: --acl public-read --follow-symlinks
|
||||
env:
|
||||
AWS_S3_BUCKET: continue-server-binaries
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_REGION: "us-west-1"
|
||||
SOURCE_DIR: "exe"
|
||||
|
|
|
|||
8
.gitignore
vendored
|
|
@ -141,5 +141,9 @@ codeql
|
|||
.test
|
||||
.tiktoken_cache
|
||||
|
||||
.idea
|
||||
intellij-extension/.gradle
|
||||
|
||||
# IntelliJ Plugin
|
||||
**/**/.gradle
|
||||
**/**/.idea
|
||||
**/**/.qodana
|
||||
**/**/build
|
||||
|
|
|
|||
41
.vscode/launch.json
vendored
|
|
@ -13,9 +13,28 @@
|
|||
"name": "Server + Tests (VSCode)",
|
||||
"stopAll": true,
|
||||
"configurations": ["Server", "Tests (VSCode)"]
|
||||
},
|
||||
{
|
||||
"name": "Server + React App",
|
||||
"stopAll": true,
|
||||
"configurations": ["Server", "Vite"]
|
||||
}
|
||||
],
|
||||
"configurations": [
|
||||
{
|
||||
"type": "chrome",
|
||||
"request": "attach",
|
||||
"name": "Vite",
|
||||
"url": "http://localhost:5173",
|
||||
"webRoot": "${workspaceFolder}/gui/src",
|
||||
"sourceMapPathOverrides": {
|
||||
"webpack:///./src/*": "${webRoot}/*"
|
||||
},
|
||||
"port": 9222,
|
||||
// "runtimeArgs": ["--remote-debugging-port=9222"],
|
||||
"sourceMaps": true,
|
||||
"preLaunchTask": "gui:dev"
|
||||
},
|
||||
{
|
||||
"name": "Pytest",
|
||||
"type": "python",
|
||||
|
|
@ -61,14 +80,14 @@
|
|||
"name": "Extension (VSCode)",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}/extension",
|
||||
"cwd": "${workspaceFolder}/extensions/vscode",
|
||||
"args": [
|
||||
// Pass a directory to manually test in
|
||||
"${workspaceFolder}/extension/manual-testing-sandbox",
|
||||
"${workspaceFolder}/extension/manual-testing-sandbox/example.ts",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/extension"
|
||||
"${workspaceFolder}/extensions/vscode/manual-testing-sandbox",
|
||||
"${workspaceFolder}/extensions/vscode/manual-testing-sandbox/example.ts",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode"
|
||||
],
|
||||
"outFiles": ["${workspaceFolder}/extension/out/**/*.js"],
|
||||
"outFiles": ["${workspaceFolder}/extensions/vscode/out/**/*.js"],
|
||||
"preLaunchTask": "vscode-extension:build",
|
||||
"env": {
|
||||
"CONTINUE_SERVER_URL": "http://localhost:8001"
|
||||
|
|
@ -79,19 +98,19 @@
|
|||
"name": "Tests (VSCode)",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}/extension",
|
||||
"cwd": "${workspaceFolder}/extensions/vscode",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
// Pass a directory to run tests in
|
||||
"${workspaceFolder}/extension/manual-testing-sandbox",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/extension",
|
||||
"--extensionTestsPath=${workspaceFolder}/extension/out/test-runner/mochaRunner"
|
||||
"${workspaceFolder}/extensions/vscode/manual-testing-sandbox",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode",
|
||||
"--extensionTestsPath=${workspaceFolder}/extensions/vscode/out/test-runner/mochaRunner"
|
||||
],
|
||||
"outFiles": [
|
||||
// Allows setting breakpoints in test suites across the /src folder
|
||||
"${workspaceFolder}/extension/out/test-suites/**/*.js",
|
||||
"${workspaceFolder}/extensions/vscode/out/test-suites/**/*.js",
|
||||
// Allows setting breakpoints in mocha test runner file
|
||||
"${workspaceFolder}/extension/out/test-runner/**/*.js"
|
||||
"${workspaceFolder}/extensions/vscode/out/test-runner/**/*.js"
|
||||
],
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"preLaunchTask": "vscode-extension:tests:build",
|
||||
|
|
|
|||
220
.vscode/tasks.json
vendored
|
|
@ -1,110 +1,118 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
// Compile and bundle the extension
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
// Compile and bundle the extension
|
||||
{
|
||||
"label": "vscode-extension:build",
|
||||
"dependsOn": [
|
||||
// To detect compile errors
|
||||
"vscode-extension:tsc",
|
||||
// To build the React app that is used in the extension
|
||||
"vscode-extension:continue-ui:build",
|
||||
// To bundle the code the same way we do for publishing
|
||||
"vscode-extension:esbuild"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "vscode-extension:esbuild",
|
||||
"type": "npm",
|
||||
"script": "esbuild",
|
||||
"path": "extensions/vscode",
|
||||
"problemMatcher": [
|
||||
{
|
||||
"label": "vscode-extension:build",
|
||||
"dependsOn": [
|
||||
// To detect compile errors
|
||||
"vscode-extension:tsc",
|
||||
// To build the react-app that is used in the extension
|
||||
"vscode-extension:continue-ui:build",
|
||||
// To bundle the code the same way we do for publishing
|
||||
"vscode-extension:esbuild"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"severity": 4,
|
||||
"message": 5
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
// Tsc currently errors out due to testing setup issues, will be resolved in a different PR
|
||||
// This will be useful for preventing debugging if there are compile errors
|
||||
{
|
||||
"label": "vscode-extension:tsc",
|
||||
"type": "npm",
|
||||
"script": "tsc",
|
||||
"path": "extensions/vscode",
|
||||
"problemMatcher": ["$tsc"],
|
||||
"presentation": {
|
||||
"revealProblems": "onProblem",
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
// Build the React app. It gets bundled into the extension as a file resource and has a seprate build step
|
||||
{
|
||||
"label": "vscode-extension:continue-ui:build",
|
||||
"type": "shell",
|
||||
"command": "node",
|
||||
"args": ["${workspaceFolder}/extensions/vscode/scripts/prepackage.js"],
|
||||
"problemMatcher": ["$tsc"],
|
||||
"presentation": {
|
||||
"revealProblems": "onProblem",
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
//
|
||||
// Compile and bundle tests
|
||||
{
|
||||
"label": "vscode-extension:tests:build",
|
||||
"dependsOn": [
|
||||
// Build the extension
|
||||
"vscode-extension:build",
|
||||
// To detect compile errors - this type checks both the extension and the tests
|
||||
"vscode-extension:tsc",
|
||||
"vscode-extension:tests:esbuild"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "vscode-extension:tests:esbuild",
|
||||
"type": "npm",
|
||||
"script": "build-test",
|
||||
"path": "extensions/vscode",
|
||||
"problemMatcher": [
|
||||
{
|
||||
"label": "vscode-extension:esbuild",
|
||||
"type": "npm",
|
||||
"script": "esbuild",
|
||||
"path": "extension",
|
||||
"problemMatcher": [
|
||||
{
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"severity": 4,
|
||||
"message": 5
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
},
|
||||
// Tsc currently errors out due to testing setup issues, will be resolved in a different PR
|
||||
// This will be useful for preventing debugging if there are compile errors
|
||||
{
|
||||
"label": "vscode-extension:tsc",
|
||||
"type": "npm",
|
||||
"script": "tsc",
|
||||
"path": "extension",
|
||||
"problemMatcher": [
|
||||
"$tsc"
|
||||
],
|
||||
"presentation": {
|
||||
"revealProblems": "onProblem",
|
||||
"clear": true,
|
||||
},
|
||||
},
|
||||
// Build the react-app. It gets bundled into the extension as a file resource and has a seprate build step
|
||||
{
|
||||
"label": "vscode-extension:continue-ui:build",
|
||||
"type": "npm",
|
||||
"script": "build",
|
||||
"path": "extension/react-app",
|
||||
"problemMatcher": [
|
||||
"$tsc"
|
||||
],
|
||||
"presentation": {
|
||||
"revealProblems": "onProblem",
|
||||
"clear": true,
|
||||
},
|
||||
},
|
||||
//
|
||||
// Compile and bundle tests
|
||||
{
|
||||
"label": "vscode-extension:tests:build",
|
||||
"dependsOn": [
|
||||
// Build the extension
|
||||
"vscode-extension:build",
|
||||
// To detect compile errors - this type checks both the extension and the tests
|
||||
"vscode-extension:tsc",
|
||||
"vscode-extension:tests:esbuild"
|
||||
],
|
||||
},
|
||||
{
|
||||
"label": "vscode-extension:tests:esbuild",
|
||||
"type": "npm",
|
||||
"script": "build-test",
|
||||
"path": "extension",
|
||||
"problemMatcher": [
|
||||
{
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"severity": 4,
|
||||
"message": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
//
|
||||
// Install or update all dependencies for all projects in the monrepo
|
||||
{
|
||||
"label": "install-all-dependencies",
|
||||
"type": "shell",
|
||||
"command": "./install-dependencies.sh",
|
||||
"problemMatcher": [], // Empty so users are not promted to select progress reporting
|
||||
},
|
||||
]
|
||||
}
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"severity": 4,
|
||||
"message": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
//
|
||||
// Install or update all dependencies for all projects in the monrepo
|
||||
{
|
||||
"label": "install-all-dependencies",
|
||||
"type": "shell",
|
||||
"command": "./install-dependencies.sh",
|
||||
"problemMatcher": [] // Empty so users are not promted to select progress reporting
|
||||
},
|
||||
//
|
||||
// Start the React App for debugging with Vite
|
||||
{
|
||||
"label": "gui:dev",
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"options": {
|
||||
"cwd": "gui"
|
||||
},
|
||||
"args": ["run", "dev"],
|
||||
"isBackground": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ Continue consists of 3 components, designed so that Continue can easily be exten
|
|||
|
||||
1. **Continue Server** - The Continue Server is responsible for keeping state, running the autopilot loop which takes actions, and communicating between the IDE and GUI.
|
||||
|
||||
2. **Continue IDE Client** - The Continue IDE Client is a plugin for the IDE which implements the Continue IDE Protocol. This allows the server to request actions to be taken within the IDE, for example if `sdk.ide.setFileOpen("main.py")` is called on the server, it will communicate over websocketes with the IDE, which will open the file `main.py`. The first IDE Client we have built is for VS Code, but we plan to build clients for other IDEs in the future. The IDE Client must 1. implement the websockets protocol, as is done [here](./extension/src/continueIdeClient.ts) for VS Code and 2. launch the Continue Server, like [here](./extension/src/activation/environmentSetup.ts), and 3. display the Continue GUI in a sidebar, like [here](./extension/src/debugPanel.ts).
|
||||
2. **Continue IDE Client** - The Continue IDE Client is a plugin for the IDE which implements the Continue IDE Protocol. This allows the server to request actions to be taken within the IDE, for example if `sdk.ide.setFileOpen("main.py")` is called on the server, it will communicate over websocketes with the IDE, which will open the file `main.py`. The first IDE Client we have built is for VS Code, but we plan to build clients for other IDEs in the future. The IDE Client must 1. implement the websockets protocol, as is done [here](./extensions/vscode/src/continueIdeClient.ts) for VS Code and 2. launch the Continue Server, like [here](./extensions/vscode/src/activation/environmentSetup.ts), and 3. display the Continue GUI in a sidebar, like [here](./extensions/vscode/src/debugPanel.ts).
|
||||
|
||||
3. **Continue GUI** - The Continue GUI is a React application that gives the user control over Continue. It displays the history of Steps, shows what context is included in the current Step, and lets the users enter natural language or slash commands to initiate new Steps. The GUI communicates with the Continue Server over its own websocket connection
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ It is important that the IDE Client and GUI never communicate except when the ID
|
|||
|
||||
### Continue VS Code Client
|
||||
|
||||
The starting point for the VS Code extension is [activate.ts](./extension/src/activation/activate.ts). The `activateExtension` function here will:
|
||||
The starting point for the VS Code extension is [activate.ts](./extensions/vscode/src/activation/activate.ts). The `activateExtension` function here will:
|
||||
|
||||
1. Check whether the current version of the extension is up-to-date and, if not, display a notification
|
||||
|
||||
|
|
@ -119,11 +119,11 @@ The JetBrains extension is currently in alpha testing. Please reach out on [Disc
|
|||
|
||||
### Continue IDE Websockets Protocol
|
||||
|
||||
On the IDE side, this is implemented in [continueIdeClient.ts](./extension/src/continueIdeClient.ts). On the server side, this is implemented in [ide.py](./server/continuedev/server/ide.py). You can see [ide_protocol.py](./server/continuedev/server/ide_protocol.py) for the protocol definition.
|
||||
On the IDE side, this is implemented in [continueIdeClient.ts](./extensions/vscode/src/continueIdeClient.ts). On the server side, this is implemented in [ide.py](./continuedev/src/continuedev/server/ide.py). You can see [ide_protocol.py](./continuedev/src/continuedev/server/ide_protocol.py) for the protocol definition.
|
||||
|
||||
### Continue GUI Websockets Protocol
|
||||
|
||||
On the GUI side, this is implemented in [ContinueGUIClientProtocol.ts](./extension/react-app/src/hooks/ContinueGUIClientProtocol.ts). On the server side, this is implemented in [gui.py](./continuedev/src/continuedev/server/gui.py). You can see [AbstractContinueGUIClientProtocol.ts](./extension/react-app/src/hooks/AbstractContinueGUIClientProtocol.ts) for the protocol definition.
|
||||
On the GUI side, this is implemented in [ContinueGUIClientProtocol.ts](./gui/src/hooks/ContinueGUIClientProtocol.ts). On the server side, this is implemented in [gui.py](./continuedev/src/continuedev/server/gui.py). You can see [gui_protocol.py](./continuedev/src/continuedev/server/gui_protocol.py) or [AbstractContinueGUIClientProtocol.ts](./gui/src/hooks/AbstractContinueGUIClientProtocol.ts) for the protocol definition.
|
||||
|
||||
When state is updated on the server, we currently send the entirety of the object over websockets to the GUI. This will of course have to be improved soon. The state object, `FullState`, is defined in [core/main.py](./server/continuedev/core/main.py) and includes:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
> 🎁 **New! [Try out the new JetBrains extension (Alpha)](https://plugins.jetbrains.com/plugin/22707-continue-extension)**
|
||||
|
||||
Interested in a 1-on-1, 15-minute introduction to Continue? Fill out [this form](https://forms.gle/rfpDfqcUtUPDQkiu9) and we'll help you get set up.
|
||||
|
||||

|
||||

|
||||
|
||||
<h1 align="center">Continue</h1>
|
||||
|
||||
|
|
@ -26,7 +24,7 @@ Interested in a 1-on-1, 15-minute introduction to Continue? Fill out [this form]
|
|||
|
||||
<p></p>
|
||||
|
||||

|
||||

|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
from collections import defaultdict
|
||||
|
||||
# Initialize a dictionary to store the sizes of the folders
|
||||
folder_sizes = defaultdict(int)
|
||||
|
||||
# Parse the file
|
||||
with open(
|
||||
"archive_contents.txt", "r"
|
||||
) as f: # replace 'file.txt' with your file name
|
||||
for line in f:
|
||||
parts = line.split(",")
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
size = int(parts[1].strip()) # get the size
|
||||
path = parts[-1].strip() # get the path
|
||||
|
||||
# Split the path into its components and accumulate the sizes for each folder
|
||||
path_parts = path.split("/")
|
||||
top_level = path_parts[0]
|
||||
folder_sizes[top_level] += size
|
||||
|
||||
# Sort the folders by size in descending order
|
||||
sorted_folders = sorted(folder_sizes.items(), key=lambda x: x[1], reverse=True)
|
||||
|
||||
# Print the sorted folders and their sizes
|
||||
for folder, size in sorted_folders:
|
||||
print(f"{folder}: {size}")
|
||||
|
|
@ -16,7 +16,7 @@ pip install -r server\requirements.txt
|
|||
pip install pyinstaller
|
||||
|
||||
REM 4. Call PyInstaller from within the virtual environment
|
||||
env\Scripts\pyinstaller run.spec
|
||||
env\Scripts\pyinstaller continue_server.spec
|
||||
|
||||
REM 5. Deactivate the virtual environment
|
||||
call env\Scripts\deactivate.bat
|
||||
|
|
|
|||
13
build.sh
|
|
@ -15,27 +15,26 @@ pip install -r server/requirements.txt
|
|||
pip install pyinstaller
|
||||
|
||||
# 4. Detect M1 architecture or allow manual override
|
||||
USE_ARCH="intel"
|
||||
if [ "$1" = "m1" ]; then
|
||||
echo "Building for M1 architecture"
|
||||
SPEC_FILE="run.m1.spec"
|
||||
USE_ARCH="m1"
|
||||
elif [ "$1" = "regular" ]; then
|
||||
echo "Building for regular architecture"
|
||||
SPEC_FILE="run.spec"
|
||||
USE_ARCH="intel"
|
||||
else
|
||||
ARCH=$(uname -m)
|
||||
if [ "$ARCH" = "arm64" ]; then
|
||||
echo "$ARCH architecture detected, using M1 spec file"
|
||||
SPEC_FILE="run.m1.spec"
|
||||
USE_ARCH="m1"
|
||||
else
|
||||
echo "$ARCH architecture detected, using regular spec file"
|
||||
SPEC_FILE="run.spec"
|
||||
USE_ARCH="intel"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Using $SPEC_FILE"
|
||||
|
||||
# 5. Call PyInstaller from within the virtual environment
|
||||
env/bin/pyinstaller $SPEC_FILE
|
||||
env/bin/pyinstaller continue_server.spec -- --arch $USE_ARCH
|
||||
|
||||
# 6. Deactivate the virtual environment
|
||||
deactivate
|
||||
|
|
|
|||
125
continue_server.spec
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
# -*- mode: python ; coding: utf-8 -*-
|
||||
import certifi
|
||||
import os
|
||||
import sys
|
||||
from PyInstaller.utils.hooks import copy_metadata
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--arch", type=str)
|
||||
parser.add_argument("--dir", type=bool, default=False)
|
||||
options = parser.parse_args()
|
||||
|
||||
block_cipher = None
|
||||
|
||||
import subprocess
|
||||
def find_package_location(package_name):
|
||||
try:
|
||||
# Run the 'pip show' command and capture its output
|
||||
result = subprocess.run(['pip', 'show', package_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
|
||||
output = result.stdout
|
||||
|
||||
# Split the output into lines and find the 'Location' field
|
||||
for line in output.splitlines():
|
||||
if line.startswith('Location:'):
|
||||
# Extract the path after the 'Location:' prefix
|
||||
location = line.split(':', 1)[1].strip()
|
||||
return location
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error: {e.stderr}")
|
||||
|
||||
return None
|
||||
|
||||
chroma_path = find_package_location('chromadb')
|
||||
chroma_toc = list(map(lambda x: (x[1], os.path.dirname(x[0])), Tree(f'{chroma_path}/chromadb/migrations', prefix="chromadb/migrations")))
|
||||
|
||||
tsl_path = find_package_location('tree_sitter_languages')
|
||||
tsl_filename = "languages.dll" if sys.platform == "win32" else "languages.so"
|
||||
|
||||
a = Analysis(
|
||||
['continue_server.py'],
|
||||
pathex=[],
|
||||
binaries=[(os.path.join(tsl_path, 'tree_sitter_languages', tsl_filename), "tree_sitter_languages")],
|
||||
datas=[
|
||||
('server/continuedev', 'continuedev'),
|
||||
(certifi.where(), 'ca_bundle'),
|
||||
('.tiktoken_cache', 'tiktoken_cache'),
|
||||
] + copy_metadata('replicate') + chroma_toc,
|
||||
hiddenimports=[
|
||||
'anthropic', 'github', 'ripgrepy', 'bs4', 'redbaron', 'tree_sitter', 'tree_sitter_languages',
|
||||
'chromadb', 'onnxruntime',
|
||||
'chromadb.telemetry.posthog',
|
||||
'chromadb.api.segment', 'chromadb.db.impl',
|
||||
'chromadb.db.impl.sqlite', 'chromadb.migrations',
|
||||
'chromadb.migrations.embeddings_queue', 'chromadb.migrations.sysdb',
|
||||
'chromadb.migrations.metadb', 'chromadb.segment.impl',
|
||||
'chromadb.segment.impl.manager', 'chromadb.segment.impl.manager.local',
|
||||
'chromadb.segment.impl.metadata', 'chromadb.segment.impl.metadata.sqlite'
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
|
||||
target_arch = "arm64" if options.arch == "m1" else None
|
||||
print("Using target arch", target_arch)
|
||||
|
||||
if options.dir:
|
||||
print("Using directory")
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
exclude_binaries=True,
|
||||
name='continue_server',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=target_arch,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
name='continue_server',
|
||||
)
|
||||
|
||||
else:
|
||||
print("Using one file")
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='continue_server',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
|
@ -37,9 +37,9 @@ You can install it from the JetBrains Marketplace [here](https://plugins.jetbrai
|
|||
Here is how you can get started with adding Continue to a new IDE:
|
||||
|
||||
1. Let us know that you would like to add Continue to a new IDE by opening an issue [here](https://github.com/continuedev/continue/issues/new/choose)
|
||||
2. Implement a class that maps each of the actions like "read file" to the API provided by that IDE like [here](https://github.com/continuedev/continue/blob/main/extension/src/continueIdeClient.ts)
|
||||
2. Implement a class that maps each of the actions like "read file" to the API provided by that IDE like [here](https://github.com/continuedev/continue/blob/main/extensions/vscode/src/continueIdeClient.ts)
|
||||
3. Learn more about what you might also do by looking at this pull request that added initial support for JetBrains [here](https://github.com/continuedev/continue/pull/457)
|
||||
|
||||
## Running the server manually
|
||||
|
||||
If you would like to run the Continue server manually, rather than allowing the IDE to automatically set it up, you can follow the short tutorial for [Manually Running Continue](./walkthroughs/manually-run-continue.md).
|
||||
If you would like to run the Continue server manually, rather than allowing the IDE to automatically set it up, you can follow the short tutorial for [Manually Running Continue](./walkthroughs/manually-run-continue.md).
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ Type '@diff' to reference all of the changes you've made to your current branch.
|
|||
|
||||
<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "description": "The workspace directory in which to run `git diff`", "type": "string"}' required={false} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "default": "diff", "type": "string"}' required={false} default="diff"/>
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ The FileContextProvider is a ContextProvider that allows you to search files in
|
|||
|
||||
## Properties
|
||||
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "default": "file", "type": "string"}' required={false} default="file"/>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ Type '@tree' to reference the contents of your current workspace. The LLM will b
|
|||
|
||||
<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "description": "The workspace directory to display", "type": "string"}' required={false} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "default": "tree", "type": "string"}' required={false} default="tree"/>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ The GitHubIssuesContextProvider is a ContextProvider that allows you to search G
|
|||
<ClassPropertyRef name='repo_name' details='{"title": "Repo Name", "description": "The name of the GitHub repo from which to pull issues", "type": "string"}' required={true} default=""/>
|
||||
<ClassPropertyRef name='auth_token' details='{"title": "Auth Token", "description": "The GitHub auth token to use to authenticate with the GitHub API", "type": "string"}' required={true} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "default": "issues", "type": "string"}' required={false} default="issues"/>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ Type '@google' to reference the results of a Google search. For example, type "@
|
|||
|
||||
<ClassPropertyRef name='serper_api_key' details='{"title": "Serper Api Key", "description": "Your SerpAPI key, used to programmatically make Google searches. You can get a key at https://serper.dev.", "type": "string"}' required={true} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "default": "google", "type": "string"}' required={false} default="google"/>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ Type '@search' to reference the results of codebase search, just like the result
|
|||
|
||||
<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "description": "The workspace directory to search", "type": "string"}' required={false} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "default": "search", "type": "string"}' required={false} default="search"/>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ Type '@terminal' to reference the contents of your IDE's terminal.
|
|||
|
||||
<ClassPropertyRef name='get_last_n_commands' details='{"title": "Get Last N Commands", "description": "The number of previous commands to reference", "default": 3, "type": "integer"}' required={false} default="3"/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "default": "terminal", "type": "string"}' required={false} default="terminal"/>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ Type '@url' to reference the contents of a URL. You can either reference preset
|
|||
<ClassPropertyRef name='preset_urls' details='{"title": "Preset Urls", "description": "A list of preset URLs that you will be able to quickly reference by typing '@url'", "default": [], "type": "array", "items": {"type": "string"}}' required={false} default="[]"/>
|
||||
<ClassPropertyRef name='static_url_context_items' details='{"title": "Static Url Context Items", "default": [], "type": "array", "items": {"$ref": "#/definitions/ContextItem"}}' required={false} default="[]"/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "default": "url", "type": "string"}' required={false} default="url"/>
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ Claude 2 is not yet publicly released. You can request early access [here](https
|
|||
|
||||
## Properties
|
||||
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='api_key' details='{"title": "Api Key", "description": "The API key for the LLM provider.", "type": "string"}' required={true} default=""/>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ config = ContinueConfig(
|
|||
<ClassPropertyRef name='api_version' details='{"title": "Api Version", "description": "OpenAI API version. For use with Azure OpenAI Service.", "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='engine' details='{"title": "Engine", "description": "OpenAI engine. For use with Azure OpenAI Service.", "type": "string"}' required={false} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "description": "A title that will identify this model in the model selection dropdown", "type": "string"}' required={false} default=""/>
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ config = ContinueConfig(
|
|||
|
||||
## Properties
|
||||
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='api_key' details='{"title": "Api Key", "description": "Google PaLM API key", "type": "string"}' required={true} default=""/>
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ config = ContinueConfig(
|
|||
...
|
||||
models=Models(
|
||||
default=HuggingFaceInferenceAPI(
|
||||
endpoint_url: "<INFERENCE_API_ENDPOINT_URL>",
|
||||
hf_token: "<HUGGING_FACE_TOKEN>",
|
||||
endpoint_url="<INFERENCE_API_ENDPOINT_URL>",
|
||||
hf_token="<HUGGING_FACE_TOKEN>",
|
||||
)
|
||||
)
|
||||
```
|
||||
|
|
@ -25,7 +25,6 @@ config = ContinueConfig(
|
|||
<ClassPropertyRef name='hf_token' details='{"title": "Hf Token", "description": "Your Hugging Face API token", "type": "string"}' required={true} default=""/>
|
||||
<ClassPropertyRef name='endpoint_url' details='{"title": "Endpoint Url", "description": "Your Hugging Face Inference API endpoint URL", "type": "string"}' required={false} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "description": "A title that will identify this model in the model selection dropdown", "type": "string"}' required={false} default=""/>
|
||||
|
|
|
|||
|
|
@ -2,15 +2,12 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx';
|
|||
|
||||
# HuggingFaceTGI
|
||||
|
||||
|
||||
|
||||
[View the source](https://github.com/continuedev/continue/tree/main/server/continuedev/libs/llm/hf_tgi.py)
|
||||
|
||||
## Properties
|
||||
|
||||
<ClassPropertyRef name='server_url' details='{"title": "Server Url", "description": "URL of your TGI server", "default": "http://localhost:8080", "type": "string"}' required={false} default="http://localhost:8080"/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "description": "A title that will identify this model in the model selection dropdown", "type": "string"}' required={false} default=""/>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ config = ContinueConfig(
|
|||
<ClassPropertyRef name='server_url' details='{"title": "Server Url", "description": "URL of the server", "default": "http://localhost:8080", "type": "string"}' required={false} default="http://localhost:8080"/>
|
||||
<ClassPropertyRef name='llama_cpp_args' details='{"title": "Llama Cpp Args", "description": "A list of additional arguments to pass to llama.cpp. See [here](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#api-endpoints) for the complete catalog of options.", "default": {"stop": ["[INST]"]}, "type": "object"}' required={false} default="{'stop': ['[INST]']}"/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "description": "A title that will identify this model in the model selection dropdown", "type": "string"}' required={false} default=""/>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ config = ContinueConfig(
|
|||
|
||||
<ClassPropertyRef name='server_url' details='{"title": "Server Url", "description": "URL of the Ollama server", "default": "http://localhost:11434", "type": "string"}' required={false} default="http://localhost:11434"/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "description": "A title that will identify this model in the model selection dropdown", "type": "string"}' required={false} default=""/>
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ Options for serving models locally with an OpenAI-compatible server include:
|
|||
<ClassPropertyRef name='api_base' details='{"title": "Api Base", "description": "OpenAI API base URL.", "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='api_type' details='{"title": "Api Type", "description": "OpenAI API type.", "enum": ["azure", "openai"], "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='api_version' details='{"title": "Api Version", "description": "OpenAI API version. For use with Azure OpenAI Service.", "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='use_legacy_completions_endpoint' details='{"title": "Use Legacy Completions Endpoint", "description": "Manually specify to use the legacy completions endpoint instead of chat completions.", "default": false, "type": "boolean"}' required={false} default="False"/>
|
||||
<ClassPropertyRef name='engine' details='{"title": "Engine", "description": "OpenAI engine. For use with Azure OpenAI Service.", "type": "string"}' required={false} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='model' details='{"title": "Model", "description": "The name of the model to be used (e.g. gpt-4, codellama)", "type": "string"}' required={true} default=""/>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ These classes support any models available through the OpenAI API, assuming your
|
|||
|
||||
<ClassPropertyRef name='llm' details='{"$ref": "#/definitions/LLM"}' required={false} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='model' details='{"title": "Model", "description": "The name of the model to be used (e.g. gpt-4, codellama)", "type": "string"}' required={true} default=""/>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ config = ContinueConfig(
|
|||
|
||||
<ClassPropertyRef name='llm' details='{"title": "Llm", "description": "The LLM to wrap with a lock", "allOf": [{"$ref": "#/definitions/LLM"}]}' required={true} default=""/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "description": "A title that will identify this model in the model selection dropdown", "type": "string"}' required={false} default=""/>
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ If you don't specify the `model` parameter, it will default to `replicate/llama-
|
|||
|
||||
## Properties
|
||||
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='api_key' details='{"title": "Api Key", "description": "Replicate API key", "type": "string"}' required={true} default=""/>
|
||||
|
|
|
|||
52
docs/docs/reference/Models/textgenwebui.md
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx';
|
||||
|
||||
# TextGenWebUI
|
||||
|
||||
TextGenWebUI is a comprehensive, open-source language model UI and local server. You can set it up with an OpenAI-compatible server plugin, but if for some reason that doesn't work, you can use this class like so:
|
||||
|
||||
```python title="~/.continue/config.py"
|
||||
<<<<<<<< HEAD:server/continuedev/libs/llm/text_gen_interface.py
|
||||
from continuedev.libs.llm.text_gen_interface import TextGenUI
|
||||
========
|
||||
from continuedev.libs.llm.text_gen_webui import TextGenWebUI
|
||||
>>>>>>>> 16b0a48035350d350e05ae5fe17478ae78042904:server/continuedev/libs/llm/text_gen_webui.py
|
||||
|
||||
config = ContinueConfig(
|
||||
...
|
||||
models=Models(
|
||||
default=TextGenWebUI(
|
||||
model="<MODEL_NAME>",
|
||||
)
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/text_gen_webui.py)
|
||||
|
||||
## Properties
|
||||
|
||||
<ClassPropertyRef name='server_url' details='{"title": "Server Url", "description": "URL of your TextGenWebUI server", "default": "http://localhost:5000", "type": "string"}' required={false} default="http://localhost:5000"/>
|
||||
<ClassPropertyRef name='streaming_url' details='{"title": "Streaming Url", "description": "URL of your TextGenWebUI streaming server (separate from main server URL)", "default": "http://localhost:5005", "type": "string"}' required={false} default="http://localhost:5005"/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='title' details='{"title": "Title", "description": "A title that will identify this model in the model selection dropdown", "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "description": "The unique ID of the user.", "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='model' details='{"title": "Model", "description": "The name of the model to be used (e.g. gpt-4, codellama)", "default": "text-gen-webui", "type": "string"}' required={false} default="text-gen-webui"/>
|
||||
<ClassPropertyRef name='system_message' details='{"title": "System Message", "description": "A system message that will always be followed by the LLM", "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='context_length' details='{"title": "Context Length", "description": "The maximum context length of the LLM in tokens, as counted by count_tokens.", "default": 2048, "type": "integer"}' required={false} default="2048"/>
|
||||
<ClassPropertyRef name='stop_tokens' details='{"title": "Stop Tokens", "description": "Tokens that will stop the completion.", "type": "array", "items": {"type": "string"}}' required={false} default=""/>
|
||||
<ClassPropertyRef name='temperature' details='{"title": "Temperature", "description": "The temperature of the completion.", "type": "number"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='top_p' details='{"title": "Top P", "description": "The top_p of the completion.", "type": "number"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='top_k' details='{"title": "Top K", "description": "The top_k of the completion.", "type": "integer"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='presence_penalty' details='{"title": "Presence Penalty", "description": "The presence penalty Aof the completion.", "type": "number"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='frequency_penalty' details='{"title": "Frequency Penalty", "description": "The frequency penalty of the completion.", "type": "number"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='timeout' details='{"title": "Timeout", "description": "Set the timeout for each request to the LLM. If you are running a local LLM that takes a while to respond, you might want to set this to avoid timeouts.", "default": 300, "type": "integer"}' required={false} default="300"/>
|
||||
<ClassPropertyRef name='verify_ssl' details='{"title": "Verify Ssl", "description": "Whether to verify SSL certificates for requests.", "type": "boolean"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='ca_bundle_path' details='{"title": "Ca Bundle Path", "description": "Path to a custom CA bundle to use when making the HTTP request", "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='proxy' details='{"title": "Proxy", "description": "Proxy URL to use when making the HTTP request", "type": "string"}' required={false} default=""/>
|
||||
<ClassPropertyRef name='headers' details='{"title": "Headers", "description": "Headers to use when making the HTTP request", "type": "object", "additionalProperties": {"type": "string"}}' required={false} default=""/>
|
||||
<ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "description": "A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the \"edit\" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation OR an instance of the PromptTemplate class if you want to control other parameters. See the documentation for more information.", "default": {"edit": "Here is the code before editing:\n```\n{{{code_to_edit}}}\n```\n\nHere is the edit requested:\n\"{{{user_input}}}\"\n\nHere is the code after editing:"}, "type": "object"}' required={false} default="{'edit': 'Here is the code before editing:\n```\n{{{code_to_edit}}}\n```\n\nHere is the edit requested:\n"{{{user_input}}}"\n\nHere is the code after editing:'}"/>
|
||||
<ClassPropertyRef name='api_key' details='{"title": "Api Key", "description": "The API key for the LLM provider.", "type": "string"}' required={false} default=""/>
|
||||
|
|
@ -25,7 +25,6 @@ config = ContinueConfig(
|
|||
|
||||
<ClassPropertyRef name='base_url' details='{"title": "Base Url", "description": "The base URL for your Together API instance", "default": "https://api.together.xyz", "type": "string"}' required={false} default="https://api.together.xyz"/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
<ClassPropertyRef name='api_key' details='{"title": "Api Key", "description": "Together API key", "type": "string"}' required={true} default=""/>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,4 @@ Continue can be deeply customized by editing the `ContinueConfig` object in `~/.
|
|||
<ClassPropertyRef name='data_server_url' details='{"title": "Data Server Url", "description": "The URL of the server where development data is sent. No data is sent unless a valid user token is provided.", "default": "https://us-west1-autodebug.cloudfunctions.net", "type": "string"}' required={false} default="https://us-west1-autodebug.cloudfunctions.net"/>
|
||||
<ClassPropertyRef name='disable_summaries' details='{"title": "Disable Summaries", "description": "If set to `True`, Continue will not generate summaries for each Step. This can be useful if you want to save on compute.", "default": false, "type": "boolean"}' required={false} default="False"/>
|
||||
|
||||
|
||||
### Inherited Properties
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,15 @@ keywords: [reload, delete, manually, logs, server, console]
|
|||
|
||||
# ❓ Troubleshooting
|
||||
|
||||
The Continue VS Code extension is currently in beta. It will attempt to start the Continue Python server locally for you, but sometimes this will fail, causing the "Starting Continue server..." not to disappear, or other hangups. While we are working on fixes to all of these problems, there are a few things you can do to temporarily troubleshoot:
|
||||
The Continue VS Code extension is currently in beta, and the Intellij extension is in Alpha. They will attempt to start the Continue Python server locally for you, but sometimes this will fail, causing the "Starting Continue server..." not to disappear, or other hangups. While we are working on fixes to all of these problems, there are a few things you can do to temporarily troubleshoot:
|
||||
|
||||
## Reload VS Code
|
||||
## Reload your editor
|
||||
|
||||
#### Intellij
|
||||
|
||||
Close out the window and re-open the project. This will give Continue another chance to start the server.
|
||||
|
||||
#### VS Code
|
||||
|
||||
Open the command palette with cmd+shift+p, then type "Reload Window" and select it. This will give Continue another chance to start the server.
|
||||
|
||||
|
|
@ -18,7 +24,7 @@ If the above doesn't work, you can try to kill the server manually before reload
|
|||
|
||||
1. Open any terminal
|
||||
2. Enter `lsof -i :65432 | grep "(LISTEN)" | awk '{print $2}' | xargs kill -9` to kill the server running on port 65432.
|
||||
3. Restart VS Code, and Continue will attempt to start a fresh server.
|
||||
3. Restart your IDE and Continue will attempt to start a fresh server.
|
||||
|
||||
## Delete `~/.continue`
|
||||
|
||||
|
|
@ -32,11 +38,17 @@ This may be necessary if you have a firewall blocking the server from downloadin
|
|||
|
||||
## Check the server logs
|
||||
|
||||
#### Intellij
|
||||
|
||||
Open the file `~/.continue/continue.log` where you can view the latest logs at the bottom.
|
||||
|
||||
#### VS Code
|
||||
|
||||
1. `cmd+shift+p` (MacOS) / `ctrl+shift+p` (Windows)
|
||||
2. Search for and then select "Continue: View Continue Server Logs"
|
||||
3. Read the `continue.log` file that has opened
|
||||
|
||||
## Check the console logs
|
||||
## Check the console logs (VS Code)
|
||||
|
||||
If your Continue server is not setting up, try checking the console logs:
|
||||
|
||||
|
|
@ -50,7 +62,7 @@ If your Continue server is not setting up, try checking the console logs:
|
|||
|
||||
If you have checked the logs and the problem seems related to Meilisearch, or if context providers aren't working, you can try to manually setup Meilisearch with their instructions [here](https://www.meilisearch.com/docs/learn/getting_started/installation). Once downloaded, you should place the Meilisearch binary at `~/.continue/server/meilisearch` and start it. Once it is running on port 7700, Continue will be able to automatically connect.
|
||||
|
||||
## Download an Older Version
|
||||
## Download an Older Version (VS Code)
|
||||
|
||||
If you've tried everything, reported an error, and are waiting to hear back, you can try downloading an older version of the extension. All versions are hosted on the Open VSX Registry [here](https://open-vsx.org/extension/Continue/continue). Once you've downloaded the extension, which will be a .vsix file, you can install it manually by following the instructions [here](https://code.visualstudio.com/docs/editor/extension-gallery#_install-from-a-vsix).
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ config=ContinueConfig(
|
|||
params={
|
||||
"n_retrieve": 20,
|
||||
"n_final": 10,
|
||||
"use_reranking": True
|
||||
"use_reranking": True,
|
||||
"openai_api_key": "<API_KEY>"
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
@ -52,3 +53,5 @@ config=ContinueConfig(
|
|||
## Parameters
|
||||
|
||||
After retrieving the top `n_retrieve` results from the vector database, an additional re-reranking step uses 2 LLM calls to select the top `n_final` results to use to answer the question. If you want to increase the speed of the query at the cost of relevancy, you can skip the re-ranking step by setting `use_reranking` to `False`. Then the top `n_final` results will just be directly calculated from the vector database.
|
||||
|
||||
It is optional to set your `openai_api_key` parameter. If you do, we will use their Ada embeddings. Otherwise, a sentence transformers model will be run locally to calculate the embeddings.
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ If you'd like to use a pre-built binary, you can download manually from our S3 b
|
|||
- [Windows](https://continue-server-binaries.s3.us-west-1.amazonaws.com/windows/run.exe)
|
||||
- [Linux](https://continue-server-binaries.s3.us-west-1.amazonaws.com/linux/run)
|
||||
|
||||
Once downloaded, start the binary by running `./run` (MacOS/Linux) or `./run.exe` (Windows) in the directory where you downloaded it. You should see that it begins listening on port 65432.
|
||||
Once downloaded, start the binary by running `./continue_server` (MacOS/Linux) or `./continue_server.exe` (Windows) in the directory where you downloaded it. You should see that it begins listening on port 65432.
|
||||
|
||||
## Build the server binary from source
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ If you don't want to use the PyPI package, but need a version of Continue that w
|
|||
1. Clone the [Continue repo](https://github.com/continuedev/continue)
|
||||
2. Change directories into the repo: `cd continue`
|
||||
3. Run the build script: `sh build.sh` (or `sh build.sh m1` if building for an M1 Mac, or `build.cmd` if on Windows without WSL)
|
||||
4. Now that the binary is outputted in the `./dist` folder, start the server by running `./dist/run`. You should see that it begins listening on port 65432.
|
||||
4. Now that the binary is outputted in the `./dist` folder, start the server by running `./dist/continue_server`. You should see that it begins listening on port 65432.
|
||||
|
||||
## Run the server from source
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ keywords: [no internet, air-gapped, local model]
|
|||
|
||||
Continue can be run even on an air-gapped computer if you use a local model. You'll have to make a few adjustments for this to work.
|
||||
|
||||
1. Download the latest .vsix file from the [Open VSX Registry](https://open-vsx.org/extension/Continue/continue) and [install it to VS Code](https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix).
|
||||
1. Download the latest .vsix file from the [Open VSX Registry](https://open-vsx.org/extensions/vscode/Continue/continue) and [install it to VS Code](https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix).
|
||||
2. In VS Code settings, search "continue" and check the box that says "Manually Running Server". This will stop Continue from trying to kill and redownload the server binary.
|
||||
3. Follow instructions to [run Continue manually](./manually-run-continue.md).
|
||||
4. Open `~/.continue/config.py` and set `allow_anonymous_telemetry=False`. This will stop Continue from attempting requests to PostHog.
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"API_URL": "http://localhost:65432"
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"API_URL": "http://localhost:65432"
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"API_URL": "https://basin.dev"
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" ?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg fill="#fff" width="800px" height="800px" viewBox="0 0 32 32" id="Camada_1" version="1.1" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M5,19.5c0-4.6,2.3-9.4,5-9.4c1.5,0,2.7,0.9,4.6,3.6c-1.8,2.8-2.9,4.5-2.9,4.5c-2.4,3.8-3.2,4.6-4.5,4.6 C5.9,22.9,5,21.7,5,19.5 M20.7,17.8L19,15c-0.4-0.7-0.9-1.4-1.3-2c1.5-2.3,2.7-3.5,4.2-3.5c3,0,5.4,4.5,5.4,10.1 c0,2.1-0.7,3.3-2.1,3.3S23.3,22,20.7,17.8 M16.4,11c-2.2-2.9-4.1-4-6.3-4C5.5,7,2,13.1,2,19.5c0,4,1.9,6.5,5.1,6.5 c2.3,0,3.9-1.1,6.9-6.3c0,0,1.2-2.2,2.1-3.7c0.3,0.5,0.6,1,0.9,1.6l1.4,2.4c2.7,4.6,4.2,6.1,6.9,6.1c3.1,0,4.8-2.6,4.8-6.7 C30,12.6,26.4,7,22.1,7C19.8,7,18,8.8,16.4,11"/></svg>
|
||||
|
Before Width: | Height: | Size: 801 B |
|
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg fill="#fff" width="800px" height="800px" viewBox="0 0 24 24" role="img" xmlns="http://www.w3.org/2000/svg"><title>OpenAI icon</title><path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.7 KiB |
|
|
@ -1,237 +0,0 @@
|
|||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
secondaryDark,
|
||||
vscBackground,
|
||||
vscForeground,
|
||||
} from ".";
|
||||
import { useContext } from "react";
|
||||
import { GUIClientContext } from "../App";
|
||||
import { RootStore } from "../redux/store";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { ArrowLeftIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiStateSlice";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
const MODEL_INFO: { title: string; class: string; args: any }[] = [
|
||||
{
|
||||
title: "OpenAI",
|
||||
class: "OpenAI",
|
||||
args: {
|
||||
model: "gpt-4",
|
||||
api_key: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Anthropic",
|
||||
class: "AnthropicLLM",
|
||||
args: {
|
||||
model: "claude-2",
|
||||
api_key: "<ANTHROPIC_API_KEY>",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Ollama",
|
||||
class: "Ollama",
|
||||
args: {
|
||||
model: "codellama",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "TogetherAI",
|
||||
class: "TogetherLLM",
|
||||
args: {
|
||||
model: "togethercomputer/CodeLlama-13b-Instruct",
|
||||
api_key: "<TOGETHER_API_KEY>",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Replicate",
|
||||
class: "ReplicateLLM",
|
||||
args: {
|
||||
model:
|
||||
"replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781",
|
||||
api_key: "<REPLICATE_API_KEY>",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "llama.cpp",
|
||||
class: "LlamaCpp",
|
||||
args: {},
|
||||
},
|
||||
{
|
||||
title: "HuggingFace Inference API",
|
||||
class: "HuggingFaceInferenceAPI",
|
||||
args: {
|
||||
endpoint_url: "<INFERENCE_API_ENDPOINT_URL>",
|
||||
hf_token: "<HUGGING_FACE_TOKEN>",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Google PaLM API",
|
||||
class: "GooglePaLMAPI",
|
||||
args: {
|
||||
model: "chat-bison-001",
|
||||
api_key: "<MAKERSUITE_API_KEY>",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "LM Studio",
|
||||
class: "GGML",
|
||||
args: {
|
||||
server_url: "http://localhost:1234",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Other OpenAI-compatible API",
|
||||
class: "GGML",
|
||||
args: {
|
||||
server_url: "<SERVER_URL>",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "GPT-4 limited free trial",
|
||||
class: "OpenAIFreeTrial",
|
||||
args: {
|
||||
model: "gpt-4",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
border: 0.5px solid ${lightGray};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
const Select = styled.select`
|
||||
border: none;
|
||||
max-width: 50vw; //changed the width
|
||||
background-color: ${vscBackground};
|
||||
color: ${vscForeground};
|
||||
padding: 6px;
|
||||
max-height: 35vh;
|
||||
overflow: scroll;
|
||||
cursor: pointer;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
&:hover {
|
||||
background-color: ${secondaryDark};
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledPlusIcon = styled(PlusIcon)`
|
||||
cursor: pointer;
|
||||
margin: 0px;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
height: 100%;
|
||||
|
||||
&:hover {
|
||||
background-color: ${secondaryDark};
|
||||
}
|
||||
border-left: 0.5px solid ${lightGray};
|
||||
`;
|
||||
|
||||
const NewProviderDiv = styled.div`
|
||||
cursor: pointer;
|
||||
padding: 8px;
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
border-top: 0.5px solid ${lightGray};
|
||||
|
||||
&:hover {
|
||||
background-color: ${secondaryDark};
|
||||
}
|
||||
`;
|
||||
|
||||
function modelSelectTitle(model: any): string {
|
||||
if (model?.title) return model?.title;
|
||||
if (model?.model !== undefined && model?.model.trim() !== "") {
|
||||
if (model?.class_name) {
|
||||
return `${model?.class_name} - ${model?.model}`;
|
||||
}
|
||||
return model?.model;
|
||||
}
|
||||
return model?.class_name;
|
||||
}
|
||||
|
||||
function ModelSelect(props: {}) {
|
||||
const dispatch = useDispatch();
|
||||
const client = useContext(GUIClientContext);
|
||||
const defaultModel = useSelector(
|
||||
(state: RootStore) => (state.serverState.config as any)?.models?.default
|
||||
);
|
||||
const savedModels = useSelector(
|
||||
(state: RootStore) => (state.serverState.config as any)?.models?.saved
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<GridDiv>
|
||||
<Select
|
||||
value={JSON.stringify({
|
||||
t: "default",
|
||||
idx: -1,
|
||||
})}
|
||||
defaultValue={0}
|
||||
onChange={(e) => {
|
||||
const value = JSON.parse(e.target.value);
|
||||
if (value.t === "saved") {
|
||||
client?.setModelForRoleFromIndex("*", value.idx);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{!defaultModel && !savedModels && (
|
||||
<option
|
||||
value={JSON.stringify({
|
||||
t: "default",
|
||||
idx: -1,
|
||||
})}
|
||||
>
|
||||
OpenAIFreeTrial - gpt-4
|
||||
</option>
|
||||
)}
|
||||
{defaultModel && (
|
||||
<option
|
||||
value={JSON.stringify({
|
||||
t: "default",
|
||||
idx: -1,
|
||||
})}
|
||||
>
|
||||
{modelSelectTitle(defaultModel)}
|
||||
</option>
|
||||
)}
|
||||
{savedModels?.map((model: any, idx: number) => {
|
||||
return (
|
||||
<option
|
||||
value={JSON.stringify({
|
||||
t: "saved",
|
||||
idx,
|
||||
})}
|
||||
>
|
||||
{modelSelectTitle(model)}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
|
||||
<StyledPlusIcon
|
||||
width="1.3em"
|
||||
height="1.3em"
|
||||
onClick={() => {
|
||||
navigate("/models");
|
||||
}}
|
||||
/>
|
||||
</GridDiv>
|
||||
);
|
||||
}
|
||||
|
||||
export default ModelSelect;
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
const { exec } = require("child_process");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
exec("npm install", (error) => {
|
||||
if (error) throw error;
|
||||
console.log("npm install completed");
|
||||
|
||||
exec("npm run typegen", (error) => {
|
||||
if (error) throw error;
|
||||
console.log("npm run typegen completed");
|
||||
|
||||
process.chdir("react-app");
|
||||
|
||||
exec("npm install", (error) => {
|
||||
if (error) throw error;
|
||||
console.log("npm install in react-app completed");
|
||||
|
||||
exec("npm run build", (error) => {
|
||||
if (error) throw error;
|
||||
if (!fs.existsSync(path.join("dist", "assets", "index.js"))) {
|
||||
throw new Error("react-app build did not produce index.js");
|
||||
}
|
||||
if (!fs.existsSync(path.join("dist", "assets", "index.css"))) {
|
||||
throw new Error("react-app build did not produce index.css");
|
||||
}
|
||||
console.log("npm run build in react-app completed");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
1
extensions/intellij/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
src/main/resources/webview
|
||||
25
extensions/intellij/.run/Run IDE for UI Tests.run.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run IDE for UI Tests" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<log_file alias="idea.log" path="$PROJECT_DIR$/build/idea-sandbox/system/log/idea.log" />
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="runIdeForUiTests" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
24
extensions/intellij/.run/Run Plugin.run.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Plugin" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<log_file alias="idea.log" path="$PROJECT_DIR$/extensions/intellij/build/idea-sandbox/system/log/idea.log" />
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/extensions/intellij" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="runIde" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" value="" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
30
extensions/intellij/.run/Run Qodana.run.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Qodana" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="env">
|
||||
<map>
|
||||
<entry key="QODANA_SHOW_REPORT" value="true" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="cleanInspections" />
|
||||
<option value="runInspections" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
24
extensions/intellij/.run/Run Tests.run.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Tests" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<log_file alias="idea.log" path="$PROJECT_DIR$/extensions/intellij/build/idea-sandbox/system/log/idea.log" />
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/extensions/intellij" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="check" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" value="" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
26
extensions/intellij/.run/Run Verifications.run.xml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Verifications" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<log_file alias="idea.log" path="$PROJECT_DIR$/build/idea-sandbox/system/log/idea.log" />
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="runPluginVerifier" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" value="" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<method v="2">
|
||||
<option name="Gradle.BeforeRunTask" enabled="true" tasks="clean" externalProjectPath="$PROJECT_DIR$" vmOptions="" scriptParameters="" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
7
extensions/intellij/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<!-- Keep a Changelog guide -> https://keepachangelog.com -->
|
||||
|
||||
# continue-intellij-extension Changelog
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Initial scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template)
|
||||
43
extensions/intellij/README.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<!-- Plugin description -->
|
||||
|
||||
**[Continue](https://continue.dev/docs) is the open-source autopilot for software development—an extension that brings the power of ChatGPT to your IDE**
|
||||
|
||||
### Get possible explainations
|
||||
|
||||
Ask Continue about a part of your code to get another perspective
|
||||
|
||||
- “how can I set up a Prisma schema that cascades deletes?”
|
||||
- “where in the page should I be making this request to the backend?”
|
||||
- “how can I communicate between these iframes?”
|
||||
|
||||
### Edit in natural language
|
||||
|
||||
Highlight a section of code and instruct Continue to refactor it
|
||||
|
||||
- “/edit migrate this digital ocean terraform file into one that works for GCP”
|
||||
- “/edit change this plot into a bar chart in this dashboard component”
|
||||
- “/edit rewrite this function to be async”
|
||||
|
||||
### Generate files from scratch
|
||||
|
||||
Open a blank file and let Continue start new Python scripts, React components, etc.
|
||||
|
||||
- “/edit here is a connector for postgres, now write one for kafka”
|
||||
- “/edit make an IAM policy that creates a user with read-only access to S3”
|
||||
- “/edit use this schema to write me a SQL query that gets recently churned users”
|
||||
|
||||
## Getting Started
|
||||
|
||||
By default, Continue uses GPT-4 and GPT-3.5-turbo via the OpenAI API.
|
||||
|
||||
You can adjust the config to use different LLMs, including local, private models. Read more [here](https://continue.dev/docs/customization#change-the-default-llm).
|
||||
|
||||
To see the keyboard shortcuts offered by Continue, see the "Feature Contributions" tab above.
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
The Continue JetBrains extension is currently in alpha. It will attempt to start the Continue Python server locally for you, but sometimes this will fail, causing the "Starting Continue server..." not to disappear, or other hangups. While we are working on fixes to all of these problems, read here for common solutions:
|
||||
|
||||
> [Troubleshooting Continue](https://continue.dev/docs/troubleshooting)
|
||||
|
||||
<!-- Plugin description end -->
|
||||
130
extensions/intellij/build.gradle.kts
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
import org.jetbrains.changelog.Changelog
|
||||
import org.jetbrains.changelog.markdownToHTML
|
||||
|
||||
fun properties(key: String) = providers.gradleProperty(key)
|
||||
fun environment(key: String) = providers.environmentVariable(key)
|
||||
|
||||
plugins {
|
||||
id("java") // Java support
|
||||
alias(libs.plugins.kotlin) // Kotlin support
|
||||
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
|
||||
alias(libs.plugins.changelog) // Gradle Changelog Plugin
|
||||
alias(libs.plugins.qodana) // Gradle Qodana Plugin
|
||||
alias(libs.plugins.kover) // Gradle Kover Plugin
|
||||
}
|
||||
|
||||
group = properties("pluginGroup").get()
|
||||
version = properties("pluginVersion").get()
|
||||
|
||||
// Configure project's dependencies
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
|
||||
dependencies {
|
||||
// implementation(libs.annotations)
|
||||
implementation("com.squareup.okhttp3:okhttp:4.9.1")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.32")
|
||||
|
||||
}
|
||||
|
||||
// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
}
|
||||
|
||||
// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
|
||||
intellij {
|
||||
pluginName = properties("pluginName")
|
||||
version = properties("platformVersion")
|
||||
type = properties("platformType")
|
||||
|
||||
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
|
||||
plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
|
||||
}
|
||||
|
||||
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
|
||||
changelog {
|
||||
groups.empty()
|
||||
repositoryUrl = properties("pluginRepositoryUrl")
|
||||
}
|
||||
|
||||
// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
|
||||
qodana {
|
||||
cachePath = provider { file(".qodana").canonicalPath }
|
||||
reportPath = provider { file("build/reports/inspections").canonicalPath }
|
||||
saveReport = true
|
||||
showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false)
|
||||
}
|
||||
|
||||
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
|
||||
koverReport {
|
||||
defaults {
|
||||
xml {
|
||||
onCheck = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
wrapper {
|
||||
gradleVersion = properties("gradleVersion").get()
|
||||
}
|
||||
|
||||
patchPluginXml {
|
||||
version = properties("pluginVersion")
|
||||
sinceBuild = properties("pluginSinceBuild")
|
||||
untilBuild = properties("pluginUntilBuild")
|
||||
|
||||
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
|
||||
pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
|
||||
val start = "<!-- Plugin description -->"
|
||||
val end = "<!-- Plugin description end -->"
|
||||
|
||||
with (it.lines()) {
|
||||
if (!containsAll(listOf(start, end))) {
|
||||
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
|
||||
}
|
||||
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
|
||||
}
|
||||
}
|
||||
|
||||
val changelog = project.changelog // local variable for configuration cache compatibility
|
||||
// Get the latest available change notes from the changelog file
|
||||
changeNotes = properties("pluginVersion").map { pluginVersion ->
|
||||
with(changelog) {
|
||||
renderItem(
|
||||
(getOrNull(pluginVersion) ?: getUnreleased())
|
||||
.withHeader(false)
|
||||
.withEmptySections(false),
|
||||
Changelog.OutputType.HTML,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Configure UI tests plugin
|
||||
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
|
||||
runIdeForUiTests {
|
||||
systemProperty("robot-server.port", "8082")
|
||||
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
|
||||
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
|
||||
systemProperty("jb.consents.confirmation.enabled", "false")
|
||||
}
|
||||
|
||||
signPlugin {
|
||||
certificateChain = environment("CERTIFICATE_CHAIN")
|
||||
privateKey = environment("PRIVATE_KEY")
|
||||
password = environment("PRIVATE_KEY_PASSWORD")
|
||||
}
|
||||
|
||||
publishPlugin {
|
||||
dependsOn("patchChangelog")
|
||||
token = environment("PUBLISH_TOKEN")
|
||||
// The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
|
||||
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
|
||||
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
|
||||
channels = properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) }
|
||||
}
|
||||
}
|
||||
34
extensions/intellij/gradle.properties
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
|
||||
|
||||
pluginGroup = com.github.continuedev.continueintellijextension
|
||||
pluginName = continue-intellij-extension
|
||||
pluginRepositoryUrl = https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion = 0.0.13
|
||||
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild = 223
|
||||
pluginUntilBuild = 232.*
|
||||
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
platformType = IC
|
||||
platformVersion = 2022.3.3
|
||||
|
||||
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
|
||||
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
|
||||
platformPlugins =
|
||||
|
||||
# Gradle Releases -> https://github.com/gradle/gradle/releases
|
||||
gradleVersion = 8.3
|
||||
|
||||
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
|
||||
kotlin.stdlib.default.dependency = false
|
||||
|
||||
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
|
||||
org.gradle.configuration-cache = true
|
||||
|
||||
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
|
||||
org.gradle.caching = true
|
||||
|
||||
# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
|
||||
systemProp.org.gradle.unsafe.kotlin.assignment = true
|
||||
20
extensions/intellij/gradle/libs.versions.toml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
[versions]
|
||||
# libraries
|
||||
annotations = "24.0.1"
|
||||
|
||||
# plugins
|
||||
kotlin = "1.9.0"
|
||||
changelog = "2.1.2"
|
||||
gradleIntelliJPlugin = "1.15.0"
|
||||
qodana = "0.1.13"
|
||||
kover = "0.7.3"
|
||||
|
||||
[libraries]
|
||||
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
|
||||
|
||||
[plugins]
|
||||
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
|
||||
gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" }
|
||||
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
|
||||
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
|
||||
BIN
extensions/intellij/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
7
extensions/intellij/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
249
extensions/intellij/gradlew
vendored
Executable file
|
|
@ -0,0 +1,249 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
92
extensions/intellij/gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
12
extensions/intellij/qodana.yml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Qodana configuration:
|
||||
# https://www.jetbrains.com/help/qodana/qodana-yaml.html
|
||||
|
||||
version: 1.0
|
||||
linter: jetbrains/qodana-jvm-community:latest
|
||||
projectJDK: 17
|
||||
profile:
|
||||
name: qodana.recommended
|
||||
exclude:
|
||||
- name: All
|
||||
paths:
|
||||
- .qodana
|
||||
1
extensions/intellij/server/requirements.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
continuedev
|
||||
4
extensions/intellij/server/run_server.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from continuedev.server.main import run_server
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_server()
|
||||
1
extensions/intellij/settings.gradle.kts
Normal file
|
|
@ -0,0 +1 @@
|
|||
rootProject.name = "continue-intellij-extension"
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.github.continuedev.continueintellijextension
|
||||
|
||||
import com.intellij.DynamicBundle
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
|
||||
@NonNls
|
||||
private const val BUNDLE = "messages.MyBundle"
|
||||
|
||||
object MyBundle : DynamicBundle(BUNDLE) {
|
||||
|
||||
@JvmStatic
|
||||
fun message(
|
||||
@PropertyKey(resourceBundle = BUNDLE) key: String,
|
||||
vararg params: Any
|
||||
) =
|
||||
getMessage(key, *params)
|
||||
|
||||
@Suppress("unused")
|
||||
@JvmStatic
|
||||
fun messagePointer(
|
||||
@PropertyKey(resourceBundle = BUNDLE) key: String,
|
||||
vararg params: Any
|
||||
) =
|
||||
getLazyMessage(key, *params)
|
||||
}
|
||||
|
|
@ -0,0 +1,229 @@
|
|||
package com.github.continuedev.continueintellijextension.actions
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.wm.ToolWindowManager
|
||||
import java.awt.Dimension
|
||||
import java.awt.GridLayout
|
||||
import javax.swing.*
|
||||
import javax.swing.event.DocumentEvent
|
||||
import javax.swing.event.DocumentListener
|
||||
import com.intellij.ui.components.JBScrollPane
|
||||
import java.awt.BorderLayout
|
||||
|
||||
fun pluginServiceFromActionEvent(e: AnActionEvent): ContinuePluginService? {
|
||||
val project = e.project ?: return null
|
||||
return ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
}
|
||||
|
||||
class AcceptDiffAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val continuePluginService = pluginServiceFromActionEvent(e) ?: return
|
||||
continuePluginService.ideProtocolClient?.diffManager?.acceptDiff(null)
|
||||
}
|
||||
}
|
||||
|
||||
class RejectDiffAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val continuePluginService = pluginServiceFromActionEvent(e) ?: return
|
||||
continuePluginService.ideProtocolClient?.diffManager?.rejectDiff(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class QuickInputDialogWrapper : DialogWrapper(true) {
|
||||
private var panel: JPanel? = null
|
||||
private var textArea: JTextArea? = null
|
||||
init {
|
||||
init()
|
||||
title = "Continue Quick Input"
|
||||
}
|
||||
|
||||
override fun getPreferredFocusedComponent(): JComponent? {
|
||||
return textArea
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent? {
|
||||
panel = JPanel(BorderLayout())
|
||||
textArea = JTextArea(3, 60)
|
||||
textArea?.lineWrap = true
|
||||
textArea?.wrapStyleWord = true
|
||||
|
||||
// Add a DocumentListener to the JTextArea
|
||||
textArea?.document?.addDocumentListener(object : DocumentListener {
|
||||
override fun insertUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
override fun removeUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
override fun changedUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
private fun updateSize() {
|
||||
val text = textArea?.text ?: ""
|
||||
val lines = text.count { it == '\n' } + 1
|
||||
val metrics = textArea?.getFontMetrics(textArea?.font)
|
||||
val lineHeight = metrics?.height ?: 0
|
||||
textArea?.preferredSize = Dimension(textArea?.width ?: 0, lines * lineHeight)
|
||||
|
||||
// Revalidate the JPanel to reflect the changes
|
||||
panel?.revalidate()
|
||||
}
|
||||
})
|
||||
|
||||
val scrollPane = JBScrollPane(textArea)
|
||||
scrollPane.verticalScrollBarPolicy = JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
|
||||
panel?.add(scrollPane, BorderLayout.CENTER)
|
||||
|
||||
return panel
|
||||
}
|
||||
|
||||
|
||||
fun showDialogAndGetText(): String? {
|
||||
show()
|
||||
return if (this.exitCode == OK_EXIT_CODE) {
|
||||
textArea!!.text
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class QuickTextEntryAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val continuePluginService = pluginServiceFromActionEvent(e) ?: return
|
||||
continuePluginService.ideProtocolClient?.sendHighlightedCode()
|
||||
|
||||
// Create and show the dialog
|
||||
val dialog = QuickInputDialogWrapper()
|
||||
val text: String? = dialog.showDialogAndGetText()
|
||||
|
||||
// Show the text entered by the user
|
||||
if (text != null) {
|
||||
val service = pluginServiceFromActionEvent(e)
|
||||
service?.ideProtocolClient?.sendMainUserInput(text)
|
||||
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.dispatchCustomEvent("message", mutableMapOf("type" to "focusContinueInput"))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ViewLogsAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
Messages.showMessageDialog(
|
||||
"This action is not yet implemented",
|
||||
"Continue Action not Implemented",
|
||||
Messages.getInformationIcon()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class ToggleAuxiliaryBarAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (toolWindow.isVisible) {
|
||||
toolWindow.component.transferFocus()
|
||||
toolWindow.hide(null)
|
||||
} else {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FocusContinueInputWithEditAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val continuePluginService = pluginServiceFromActionEvent(e) ?: return
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.dispatchCustomEvent("message", mutableMapOf("type" to "focusContinueInputWithEdit"))
|
||||
|
||||
continuePluginService.ideProtocolClient?.sendHighlightedCode()
|
||||
}
|
||||
}
|
||||
|
||||
class FocusContinueInputAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val continuePluginService = pluginServiceFromActionEvent(e) ?: return
|
||||
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.dispatchCustomEvent("message", mutableMapOf("type" to "focusContinueInput"))
|
||||
|
||||
continuePluginService.ideProtocolClient?.sendHighlightedCode()
|
||||
}
|
||||
}
|
||||
|
||||
class NewContinueSessionAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val continuePluginService = pluginServiceFromActionEvent(e) ?: return
|
||||
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.dispatchCustomEvent("message", mutableMapOf("type" to "focusContinueInputWithNewSession"))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,578 @@
|
|||
package com.github.continuedev.continueintellijextension.activities
|
||||
|
||||
import com.github.continuedev.continueintellijextension.constants.CONTINUE_PYTHON_SERVER_URL
|
||||
import com.github.continuedev.continueintellijextension.constants.CONTINUE_SERVER_WEBSOCKET_PORT
|
||||
import com.github.continuedev.continueintellijextension.`continue`.DefaultTextSelectionStrategy
|
||||
import com.github.continuedev.continueintellijextension.`continue`.IdeProtocolClient
|
||||
import com.github.continuedev.continueintellijextension.`continue`.getMachineUniqueID
|
||||
import com.github.continuedev.continueintellijextension.listeners.ContinuePluginSelectionListener
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.google.gson.Gson
|
||||
import com.intellij.ide.plugins.PluginManagerCore
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.editor.EditorFactory
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.StartupActivity
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.util.io.StreamUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.wm.ToolWindowManager
|
||||
import com.intellij.ui.jcef.executeJavaScriptAsync
|
||||
import kotlinx.coroutines.*
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.awt.Dimension
|
||||
import java.awt.Font
|
||||
import java.awt.GridLayout
|
||||
import java.io.*
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.attribute.PosixFilePermission
|
||||
import javax.swing.*
|
||||
|
||||
|
||||
fun getContinueGlobalPath(): String {
|
||||
val continuePath = Paths.get(System.getProperty("user.home"), ".continue")
|
||||
if (Files.notExists(continuePath)) {
|
||||
Files.createDirectories(continuePath)
|
||||
}
|
||||
return continuePath.toString()
|
||||
}
|
||||
|
||||
fun serverPath(): String {
|
||||
val sPath = Paths.get(getContinueGlobalPath(), "server").toString()
|
||||
val directory = File(sPath)
|
||||
if (!directory.exists()) {
|
||||
directory.mkdir()
|
||||
}
|
||||
return sPath
|
||||
}
|
||||
|
||||
fun serverVersionPath(): String {
|
||||
return Paths.get(serverPath(), "server_version.txt").toString()
|
||||
}
|
||||
|
||||
fun serverBinaryPath(): String {
|
||||
val exeFile = if (System.getProperty("os.name").toLowerCase()
|
||||
.contains("win")
|
||||
) "run.exe" else "run"
|
||||
return Paths.get(serverPath(), "exe", exeFile).toString()
|
||||
}
|
||||
|
||||
fun downloadFromS3(
|
||||
bucket: String,
|
||||
filename: String,
|
||||
destination: String,
|
||||
region: String,
|
||||
useBackupUrl: Boolean = false
|
||||
|
||||
) {
|
||||
val client = OkHttpClient()
|
||||
val url = if (useBackupUrl)
|
||||
"https://s3.continue.dev/$filename"
|
||||
else
|
||||
"https://$bucket.s3.$region.amazonaws.com/$filename"
|
||||
|
||||
val request = Request.Builder()
|
||||
.url(url)
|
||||
.build()
|
||||
|
||||
// Create the necessary folders
|
||||
val directory = File(destination).parentFile
|
||||
if (!directory.exists()) {
|
||||
directory.mkdirs()
|
||||
}
|
||||
|
||||
client.newCall(request).execute().use { response ->
|
||||
if (!response.isSuccessful) {
|
||||
Files.deleteIfExists(Paths.get(destination))
|
||||
throw IOException("No body returned when downloading from S3 bucket")
|
||||
}
|
||||
|
||||
val fos = FileOutputStream(File(destination))
|
||||
val body = response.body!!.byteStream()
|
||||
|
||||
fos.use {
|
||||
body.copyTo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set permissions on the binary
|
||||
fun setPermissions(destination: String) {
|
||||
val osName = System.getProperty("os.name").toLowerCase()
|
||||
if (osName.contains("mac") || osName.contains("darwin")) {
|
||||
ProcessBuilder(
|
||||
"xattr",
|
||||
"-dr",
|
||||
"com.apple.quarantine",
|
||||
destination
|
||||
).start()
|
||||
setFilePermissions(destination, "rwxr-xr-x")
|
||||
} else if (osName.contains("nix") || osName.contains("nux") || osName.contains(
|
||||
"mac"
|
||||
)
|
||||
) {
|
||||
setFilePermissions(destination, "rwxr-xr-x")
|
||||
}
|
||||
}
|
||||
|
||||
fun setFilePermissions(path: String, posixPermissions: String) {
|
||||
val perms = HashSet<PosixFilePermission>()
|
||||
if (posixPermissions.contains("r")) perms.add(PosixFilePermission.OWNER_READ)
|
||||
if (posixPermissions.contains("w")) perms.add(PosixFilePermission.OWNER_WRITE)
|
||||
if (posixPermissions.contains("x")) perms.add(PosixFilePermission.OWNER_EXECUTE)
|
||||
Files.setPosixFilePermissions(Paths.get(path), perms)
|
||||
}
|
||||
|
||||
fun getProcessId(port: Int): String? {
|
||||
val os = System.getProperty("os.name").toLowerCase()
|
||||
|
||||
val command = when {
|
||||
os.contains("win") -> listOf(
|
||||
"cmd.exe",
|
||||
"/c",
|
||||
"netstat -ano | findstr :$port"
|
||||
)
|
||||
os.contains("nix") || os.contains("mac") || os.contains("nux") -> listOf(
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"lsof -t -i tcp:$port"
|
||||
)
|
||||
else -> throw UnsupportedOperationException("Unsupported operating system: $os")
|
||||
}
|
||||
|
||||
val process = ProcessBuilder(command).start()
|
||||
val reader = BufferedReader(InputStreamReader(process.inputStream))
|
||||
|
||||
return reader.readLine()?.trim()
|
||||
}
|
||||
|
||||
|
||||
fun killProcess(pid: String) {
|
||||
val os = System.getProperty("os.name").toLowerCase()
|
||||
val command = when {
|
||||
os.contains("win") -> listOf("taskkill", "/F", "/PID", pid)
|
||||
else -> listOf(
|
||||
"kill",
|
||||
"-9",
|
||||
pid
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
val process = ProcessBuilder(command).start()
|
||||
process.waitFor()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun checkServerRunning(): Boolean {
|
||||
val processId = getProcessId(CONTINUE_SERVER_WEBSOCKET_PORT)
|
||||
return processId != null
|
||||
}
|
||||
|
||||
fun getExtensionVersion(): String {
|
||||
val pluginId =
|
||||
PluginId.getId("com.github.continuedev.continueintellijextension")
|
||||
val pluginDescriptor = PluginManagerCore.getPlugin(pluginId)
|
||||
return pluginDescriptor?.version ?: ""
|
||||
}
|
||||
|
||||
fun checkOrKillRunningServer(project: Project): Boolean {
|
||||
val continuePluginService = ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
val serverRunning: Boolean = checkServerRunning()
|
||||
var shouldKillAndReplace = true
|
||||
|
||||
val serverVersionPath = serverVersionPath()
|
||||
if (File(serverVersionPath).exists()) {
|
||||
val serverVersion = File(serverVersionPath).readText()
|
||||
if (serverVersion == getExtensionVersion() && serverRunning) {
|
||||
println("Continue server of correct version already running")
|
||||
shouldKillAndReplace = false
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldKillAndReplace) {
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "Stopping Outdated Server"
|
||||
))
|
||||
println("Killing server from old version of Continue")
|
||||
val pid = getProcessId(CONTINUE_SERVER_WEBSOCKET_PORT)
|
||||
pid?.let { killProcess(it) }
|
||||
|
||||
if (File(serverVersionPath).exists()) {
|
||||
File(serverVersionPath).delete()
|
||||
}
|
||||
|
||||
val serverBinary = serverBinaryPath()
|
||||
if (File(serverBinary).exists()) {
|
||||
File(serverBinary).delete()
|
||||
}
|
||||
|
||||
}
|
||||
return serverRunning && !shouldKillAndReplace
|
||||
}
|
||||
|
||||
fun runBinary(path: String) {
|
||||
try {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("win")) {
|
||||
// Windows approach
|
||||
val script = """
|
||||
Set WshShell = CreateObject("WScript.Shell")
|
||||
WshShell.Run "$path", 0
|
||||
Set WshShell = Nothing
|
||||
""".trimIndent()
|
||||
val scriptPath = Paths.get("startProcess.vbs")
|
||||
Files.writeString(scriptPath, script)
|
||||
val processBuilder = ProcessBuilder("cmd", "/c", "start", "cscript", scriptPath.toString())
|
||||
processBuilder.start()
|
||||
} else {
|
||||
// Unix-like approach
|
||||
val processBuilder = ProcessBuilder("sh", "-c", "nohup $path > /dev/null 2>&1 &")
|
||||
processBuilder.start()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
suspend fun startBinaryWithRetry(path: String) {
|
||||
var attempts = 0
|
||||
while (attempts < 5) {
|
||||
try {
|
||||
// Your suspend function call here
|
||||
runBinary(path)
|
||||
break // If the function call is successful, break the loop
|
||||
} catch (e: Exception) {
|
||||
attempts++
|
||||
delay(500)
|
||||
if (attempts == 5) throw e // If this was the last attempt, rethrow the exception
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getContinueServerUrl(): String {
|
||||
val settings =
|
||||
ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
return settings.continueState.serverUrl
|
||||
}
|
||||
|
||||
suspend fun startContinuePythonServer(project: Project) {
|
||||
println("server starting")
|
||||
val continuePluginService = ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
|
||||
val settings =
|
||||
ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
val serverUrl = getContinueServerUrl()
|
||||
|
||||
if ((serverUrl != CONTINUE_PYTHON_SERVER_URL && serverUrl != "http://127.0.0.1:65432") || settings.continueState.manuallyRunningServer) {
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "Connecting to Continue Server"
|
||||
))
|
||||
|
||||
println("Continue server being run manually, skipping start")
|
||||
return
|
||||
}
|
||||
|
||||
if (checkOrKillRunningServer(project)) {
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "Connecting to Continue Server"
|
||||
))
|
||||
println("Continue server already running")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Determine from OS details which file to download
|
||||
val filename = when {
|
||||
System.getProperty("os.name")
|
||||
.toLowerCase().contains("win") -> "windows/run.exe"
|
||||
System.getProperty("os.name").startsWith("Mac", ignoreCase = true) ->
|
||||
if (System.getProperty("os.arch") == "arm64") "apple-silicon/run" else "mac/run"
|
||||
else -> "linux/run"
|
||||
}
|
||||
|
||||
val destination = serverBinaryPath()
|
||||
|
||||
// Check whether the binary needs to be downloaded
|
||||
var shouldDownload = true
|
||||
if (File(destination).exists()) {
|
||||
if (File(serverVersionPath()).exists()) {
|
||||
val serverVersion = File(serverVersionPath()).readText()
|
||||
if (serverVersion == getExtensionVersion()) {
|
||||
println("Continue server already downloaded")
|
||||
shouldDownload = false
|
||||
} else {
|
||||
println("Old version of the server downloaded, removing")
|
||||
File(destination).delete()
|
||||
}
|
||||
} else {
|
||||
println("Old version of the server downloaded, removing")
|
||||
File(destination).delete()
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldDownload) {
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "Downloading Continue server binary"
|
||||
))
|
||||
|
||||
println("Downloading Continue Server Binary")
|
||||
// Download the binary from S3
|
||||
try {
|
||||
downloadFromS3(
|
||||
"continue-server-binaries",
|
||||
filename,
|
||||
destination,
|
||||
"us-west-1",
|
||||
false
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "First download failed, attempting backup"
|
||||
))
|
||||
try {
|
||||
downloadFromS3(
|
||||
"continue-server-binaries",
|
||||
filename,
|
||||
destination,
|
||||
"us-west-1",
|
||||
true
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "Failed to download Continue server binary: ${e.message}"
|
||||
))
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set permissions on the binary
|
||||
setPermissions(destination)
|
||||
}
|
||||
|
||||
// Validate that the binary exists
|
||||
if (!File(destination).exists()) {
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "Failed to download Continue server binary"
|
||||
))
|
||||
|
||||
throw Error("Failed to download Continue server binary")
|
||||
}
|
||||
|
||||
// Spawn server process
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "Launching Continue Server"
|
||||
))
|
||||
println("Starting Continue server binary")
|
||||
startBinaryWithRetry(destination)
|
||||
|
||||
// Write the server version to server_version.txt
|
||||
File(serverVersionPath()).writeText(getExtensionVersion())
|
||||
|
||||
// Wait for the server process to start
|
||||
println("Waiting for Continue server to start...")
|
||||
var i = 1
|
||||
while (getProcessId(CONTINUE_SERVER_WEBSOCKET_PORT) == null) {
|
||||
delay(1000)
|
||||
continuePluginService.dispatchCustomEvent("serverStatus", mutableMapOf(
|
||||
"type" to "serverStatus",
|
||||
"message" to "Launching Continue Server" + ".".repeat(i % 4)
|
||||
))
|
||||
i++
|
||||
}
|
||||
println("Continue server started")
|
||||
}
|
||||
|
||||
class WelcomeDialogWrapper(val project: Project) : DialogWrapper(true) {
|
||||
private var panel: JPanel? = null
|
||||
private var paragraph: JTextArea? = null
|
||||
|
||||
init {
|
||||
init()
|
||||
title = "Welcome to Continue"
|
||||
}
|
||||
|
||||
override fun doOKAction() {
|
||||
super.doOKAction()
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow =
|
||||
toolWindowManager.getToolWindow("Continue")
|
||||
toolWindow?.show()
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent? {
|
||||
panel = JPanel(GridLayout(0, 1))
|
||||
panel!!.preferredSize = Dimension(500, panel!!.preferredSize.height)
|
||||
val paragraph = JLabel()
|
||||
val shortcutKey = if (System.getProperty("os.name").toLowerCase().contains("mac")) "⌘" else "⌃"
|
||||
paragraph.text = """
|
||||
<html>Welcome! You can access Continue from the right side panel by clicking on the logo.<br><br>
|
||||
|
||||
To <b>ask a question</b> about a piece of code: highlight it, use <b>$shortcutKey J</b> to select the code and focus the input box, then ask your question.<br><br>
|
||||
To generate an <b>inline edit</b>: highlight the code you want to edit, use <b>$shortcutKey ⇧ J</b>, then type your requested edit.</html>""".trimIndent()
|
||||
|
||||
paragraph.font = Font("Arial", Font.PLAIN, 16)
|
||||
|
||||
panel!!.add(paragraph)
|
||||
|
||||
return panel
|
||||
}
|
||||
|
||||
override fun createActions(): Array<Action> {
|
||||
val okAction = getOKAction()
|
||||
okAction.putValue(Action.NAME, "Open Continue")
|
||||
|
||||
val cancelAction = getCancelAction()
|
||||
cancelAction.putValue(Action.NAME, "Cancel")
|
||||
|
||||
return arrayOf(okAction, cancelAction)
|
||||
}
|
||||
}
|
||||
|
||||
class ContinuePluginStartupActivity : StartupActivity, Disposable {
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
|
||||
override fun runActivity(project: Project) {
|
||||
|
||||
removeShortcutFromAction(getPlatformSpecificKeyStroke("J"))
|
||||
removeShortcutFromAction(getPlatformSpecificKeyStroke("shift J"))
|
||||
|
||||
ApplicationManager.getApplication().executeOnPooledThread {
|
||||
initializePlugin(project)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPlatformSpecificKeyStroke(key: String): String {
|
||||
val osName = System.getProperty("os.name").lowercase()
|
||||
val modifier = if (osName.contains("mac")) "meta" else "control"
|
||||
return "$modifier $key"
|
||||
}
|
||||
|
||||
private fun removeShortcutFromAction(shortcut: String) {
|
||||
val actionManager = ActionManager.getInstance()
|
||||
val keyStroke = KeyStroke.getKeyStroke(shortcut)
|
||||
val actionIds = actionManager.getActionIds(keyStroke)
|
||||
|
||||
for (actionId in actionIds) {
|
||||
val action = actionManager.getAction(actionId)
|
||||
val shortcuts = action.shortcutSet.shortcuts.filterNot { it is KeyboardShortcut && it.firstKeyStroke == keyStroke }.toTypedArray()
|
||||
|
||||
action.registerCustomShortcutSet(Shortcut { shortcuts }, null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initializePlugin(project: Project) {
|
||||
val continuePluginService = ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
|
||||
val defaultStrategy = DefaultTextSelectionStrategy()
|
||||
|
||||
coroutineScope.launch {
|
||||
val settings =
|
||||
ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
if (!settings.continueState.shownWelcomeDialog) {
|
||||
// Open continue_tutorial.py
|
||||
ContinuePluginStartupActivity::class.java.getClassLoader().getResourceAsStream("continue_tutorial.py").use { `is` ->
|
||||
if (`is` == null) {
|
||||
throw IOException("Resource not found: continue_tutorial.py")
|
||||
}
|
||||
var content = StreamUtil.readText(`is`, StandardCharsets.UTF_8)
|
||||
if (!System.getProperty("os.name").toLowerCase().contains("mac")) {
|
||||
content = content.replace("⌘", "⌃")
|
||||
}
|
||||
val filepath = Paths.get(getContinueGlobalPath(), "continue_tutorial.py").toString()
|
||||
File(filepath).writeText(content)
|
||||
val virtualFile = LocalFileSystem.getInstance().findFileByPath(filepath)
|
||||
|
||||
if (virtualFile != null) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
FileEditorManager.getInstance(project).openFile(virtualFile, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show the welcome dialog
|
||||
withContext(Dispatchers.Main) {
|
||||
val dialog = WelcomeDialogWrapper(project)
|
||||
dialog.show()
|
||||
}
|
||||
settings.continueState.shownWelcomeDialog = true
|
||||
}
|
||||
|
||||
GlobalScope.async(Dispatchers.IO) {
|
||||
startContinuePythonServer(project)
|
||||
|
||||
val wsUrl = getContinueServerUrl().replace("http://", "ws://").replace("https://", "wss://")
|
||||
val ideProtocolClient = IdeProtocolClient(
|
||||
"$wsUrl/ide/ws",
|
||||
continuePluginService,
|
||||
defaultStrategy,
|
||||
coroutineScope,
|
||||
project.basePath ?: "/",
|
||||
project
|
||||
)
|
||||
|
||||
continuePluginService.ideProtocolClient = ideProtocolClient
|
||||
|
||||
val listener =
|
||||
ContinuePluginSelectionListener(
|
||||
ideProtocolClient,
|
||||
coroutineScope
|
||||
)
|
||||
|
||||
val newSessionId = ideProtocolClient.getSessionIdAsync().await()
|
||||
val sessionId = newSessionId ?: ""
|
||||
|
||||
// Reload the WebView
|
||||
continuePluginService?.let {
|
||||
val workspacePaths =
|
||||
if (project.basePath != null) arrayOf(project.basePath) else emptyList<String>()
|
||||
|
||||
continuePluginService.worksapcePaths = workspacePaths as Array<String>
|
||||
continuePluginService.sessionId = sessionId
|
||||
}
|
||||
|
||||
EditorFactory.getInstance().eventMulticaster.addSelectionListener(
|
||||
listener,
|
||||
this@ContinuePluginStartupActivity
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
// Cleanup resources here
|
||||
coroutineScope.cancel()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package com.github.continuedev.continueintellijextension.constants
|
||||
|
||||
const val CONTINUE_PYTHON_SERVER_URL = "http://localhost:65432"
|
||||
const val CONTINUE_SERVER_WEBSOCKET_PORT = 65432
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.intellij.diff.DiffContentFactory
|
||||
import com.intellij.diff.DiffManager
|
||||
import com.intellij.diff.DiffRequestPanel
|
||||
import com.intellij.diff.contents.DiffContent
|
||||
import com.intellij.diff.contents.DocumentContent
|
||||
import com.intellij.diff.requests.DiffRequest
|
||||
import com.intellij.diff.requests.SimpleDiffRequest
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.ui.content.ContentFactory
|
||||
import java.awt.Toolkit
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
import javax.swing.Action
|
||||
import javax.swing.JComponent
|
||||
|
||||
|
||||
fun getDiffDirectory(): File {
|
||||
val homeDirectory = System.getProperty("user.home")
|
||||
val diffDirPath = Paths.get(homeDirectory).resolve(".continue").resolve("diffs").toString()
|
||||
val diffDir = File(diffDirPath)
|
||||
if (!diffDir.exists()) {
|
||||
diffDir.mkdirs()
|
||||
diffDir.setWritable(true)
|
||||
}
|
||||
return diffDir
|
||||
}
|
||||
fun escapeFilepath(filepath: String): String {
|
||||
return filepath.replace("/", "\$f\$").replace("\\", "\$b\$")
|
||||
}
|
||||
|
||||
interface DiffInfo {
|
||||
val originalFilepath: String
|
||||
val newFilepath: String
|
||||
var diffRequestPanel: DiffRequestPanel?
|
||||
val stepIndex: Int
|
||||
var dialog: DialogWrapper?
|
||||
}
|
||||
|
||||
class DiffManager(private val project: Project) {
|
||||
|
||||
private val diffContentFactory = DiffContentFactory.getInstance()
|
||||
|
||||
// Mapping from file2 to relevant info
|
||||
private val diffInfoMap: MutableMap<String, DiffInfo> = mutableMapOf()
|
||||
|
||||
fun showDiff(filepath: String, replacement: String, stepIndex: Int) {
|
||||
val diffDir = getDiffDirectory()
|
||||
val escapedPath = escapeFilepath(filepath)
|
||||
val file = diffDir.resolve(escapedPath)
|
||||
|
||||
if (!file.exists()) {
|
||||
file.createNewFile()
|
||||
}
|
||||
file.writeText(replacement)
|
||||
openDiffWindow(filepath, file.path, stepIndex)
|
||||
}
|
||||
|
||||
fun cleanUpFile(file2: String) {
|
||||
diffInfoMap[file2]?.dialog?.close(0)
|
||||
diffInfoMap.remove(file2)
|
||||
File(file2).delete()
|
||||
if (lastFile2 == file2) {
|
||||
lastFile2 = null
|
||||
}
|
||||
}
|
||||
|
||||
private var lastFile2: String? = null
|
||||
|
||||
fun acceptDiff(file2: String?) {
|
||||
val file = (file2 ?: lastFile2) ?: return
|
||||
val diffInfo = diffInfoMap[file] ?: return
|
||||
|
||||
// Write contents to original file
|
||||
val virtualFile = LocalFileSystem.getInstance().findFileByPath(diffInfo.originalFilepath) ?: return
|
||||
val document = FileDocumentManager.getInstance().getDocument(virtualFile) ?: return
|
||||
WriteCommandAction.runWriteCommandAction(project) {
|
||||
document.setText(File(file).readText())
|
||||
}
|
||||
FileDocumentManager.getInstance().saveDocument(document)
|
||||
|
||||
// Notify server of acceptance
|
||||
val continuePluginService = ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
continuePluginService.ideProtocolClient?.sendAcceptRejectDiff(true, diffInfo.stepIndex)
|
||||
|
||||
// Clean up state
|
||||
cleanUpFile(file)
|
||||
}
|
||||
|
||||
fun rejectDiff(file2: String?) {
|
||||
val file = (file2 ?: lastFile2) ?: return
|
||||
val diffInfo = diffInfoMap[file] ?: return
|
||||
val continuePluginService = ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
continuePluginService.ideProtocolClient?.deleteAtIndex(diffInfo.stepIndex)
|
||||
continuePluginService.ideProtocolClient?.sendAcceptRejectDiff(false, diffInfo.stepIndex)
|
||||
|
||||
cleanUpFile(file)
|
||||
}
|
||||
|
||||
fun openDiffWindow(
|
||||
file1: String,
|
||||
file2: String,
|
||||
stepIndex: Int
|
||||
) {
|
||||
lastFile2 = file2
|
||||
|
||||
// Create a DiffContent for each of the texts you want to compare
|
||||
val content1: DiffContent = DiffContentFactory.getInstance().create(File(file1).readText())
|
||||
val content2: DiffContent = DiffContentFactory.getInstance().create(File(file2).readText())
|
||||
|
||||
// Create a SimpleDiffRequest and populate it with the DiffContents and titles
|
||||
val diffRequest = SimpleDiffRequest("Continue Diff", content1, content2, "Old", "New")
|
||||
|
||||
// Get a DiffRequestPanel from the DiffManager and set the DiffRequest to it
|
||||
val diffInfo = diffInfoMap[file2]
|
||||
|
||||
var shouldShowDialog = false
|
||||
if (diffInfo == null) {
|
||||
diffInfoMap[file2] = object : DiffInfo {
|
||||
override var dialog: DialogWrapper? = null
|
||||
override var diffRequestPanel: DiffRequestPanel? = null
|
||||
override val stepIndex: Int = stepIndex
|
||||
override val newFilepath: String = file2
|
||||
override val originalFilepath: String = file1
|
||||
}
|
||||
shouldShowDialog = true
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
val diffPanel: DiffRequestPanel = diffInfo?.diffRequestPanel ?: DiffManager.getInstance().createRequestPanel(project, Disposer.newDisposable(), null)
|
||||
diffPanel.setRequest(diffRequest)
|
||||
|
||||
diffPanel.component.revalidate()
|
||||
diffPanel.component.repaint()
|
||||
|
||||
if (shouldShowDialog) {
|
||||
// Create a dialog and add the DiffRequestPanel to it
|
||||
val dialog: DialogWrapper = diffInfo?.dialog
|
||||
?: object : DialogWrapper(project, true, IdeModalityType.MODELESS) {
|
||||
init {
|
||||
init()
|
||||
title = "Continue Diff"
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent? {
|
||||
return diffPanel.component
|
||||
}
|
||||
|
||||
override fun doOKAction() {
|
||||
super.doOKAction()
|
||||
acceptDiff(file2)
|
||||
}
|
||||
|
||||
override fun doCancelAction() {
|
||||
super.doCancelAction()
|
||||
rejectDiff(file2)
|
||||
}
|
||||
|
||||
override fun createActions(): Array<Action> {
|
||||
val okAction = getOKAction()
|
||||
val cmdCtrl = if (System.getProperty("os.name").toLowerCase().contains("mac")) "⌘" else "⌃"
|
||||
okAction.putValue(Action.NAME, "Accept ($cmdCtrl ⇧ ↵)")
|
||||
|
||||
val cancelAction = getCancelAction()
|
||||
cancelAction.putValue(Action.NAME, "Reject ($cmdCtrl ⇧ ⌫)")
|
||||
|
||||
return arrayOf(okAction, cancelAction)
|
||||
}
|
||||
}
|
||||
|
||||
dialog.rootPane.isDoubleBuffered = true
|
||||
val screenSize = Toolkit.getDefaultToolkit().screenSize
|
||||
dialog.setSize(screenSize.width, screenSize.height)
|
||||
dialog.show()
|
||||
diffInfoMap[file2]?.dialog = dialog
|
||||
diffInfoMap[file2]?.diffRequestPanel = diffPanel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,634 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.intellij.openapi.application.ApplicationInfo
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.SelectionModel
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.TextEditor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.MessageType
|
||||
import com.intellij.openapi.ui.popup.Balloon
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.openapi.util.Computable
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
import com.intellij.testFramework.LightVirtualFile
|
||||
import com.intellij.ui.awt.RelativePoint
|
||||
import kotlinx.coroutines.*
|
||||
import okhttp3.*
|
||||
import java.io.File
|
||||
import java.net.NetworkInterface
|
||||
|
||||
|
||||
data class WebSocketMessage<T>(val messageType: String, val data: T)
|
||||
data class WorkspaceDirectory(val workspaceDirectory: String)
|
||||
data class UniqueId(val uniqueId: String)
|
||||
data class ReadFile(val contents: String)
|
||||
data class VisibleFiles(val visibleFiles: List<String>)
|
||||
data class Position(val line: Int, val character: Int)
|
||||
data class Range(val start: Position, val end: Position)
|
||||
data class RangeInFile(val filepath: String, val range: Range)
|
||||
data class GetTerminalContents(val contents: String)
|
||||
data class ListDirectoryContents(val contents: List<String>)
|
||||
data class RangeInFileWithContents(val filepath: String, val range: Range, val contents: String)
|
||||
data class HighlightedCodeUpdate(val highlightedCode: List<RangeInFileWithContents>, val edit: Boolean)
|
||||
data class HighlightedCode(val highlightedCode: List<RangeInFile>)
|
||||
data class AcceptRejectDiff(val accepted: Boolean, val stepIndex: Int)
|
||||
data class DeleteAtIndex(val index: Int)
|
||||
data class MainUserInput(val input: String)
|
||||
data class IdeInfo(val name: String, val version: String?, val remoteName: String?)
|
||||
|
||||
fun getMachineUniqueID(): String {
|
||||
val sb = StringBuilder()
|
||||
val networkInterfaces = NetworkInterface.getNetworkInterfaces()
|
||||
|
||||
while (networkInterfaces.hasMoreElements()) {
|
||||
val networkInterface = networkInterfaces.nextElement()
|
||||
val mac = networkInterface.hardwareAddress
|
||||
|
||||
if (mac != null) {
|
||||
for (i in mac.indices) {
|
||||
sb.append(
|
||||
String.format(
|
||||
"%02X%s",
|
||||
mac[i],
|
||||
if (i < mac.size - 1) "-" else ""
|
||||
)
|
||||
)
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
}
|
||||
|
||||
return "No MAC Address Found"
|
||||
}
|
||||
|
||||
class IdeProtocolClient(
|
||||
private val serverUrl: String = "ws://localhost:65432/ide/ws",
|
||||
private val continuePluginService: ContinuePluginService,
|
||||
private val textSelectionStrategy: TextSelectionStrategy,
|
||||
private val coroutineScope: CoroutineScope,
|
||||
private val workspacePath: String,
|
||||
private val project: Project
|
||||
) {
|
||||
private val eventListeners = mutableListOf<WebSocketEventListener>()
|
||||
private var webSocket: WebSocket? = null
|
||||
private val okHttpClient = OkHttpClient()
|
||||
|
||||
val diffManager = DiffManager(project)
|
||||
|
||||
init {
|
||||
initWebSocket()
|
||||
}
|
||||
|
||||
var sessionId: String? = null
|
||||
|
||||
fun getSessionIdAsync(): Deferred<String?> = coroutineScope.async {
|
||||
withTimeoutOrNull(10000) {
|
||||
while ((webSocket?.queueSize() ?: 0) > 0) {
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
println("Getting session ID")
|
||||
val respDeferred = sendAndReceive("getSessionId", mapOf())
|
||||
val resp = respDeferred.await() // Awaiting the deferred response
|
||||
println(resp)
|
||||
val data = (resp as? Map<*, *>)?.get("data") as? Map<*, *>
|
||||
sessionId = data?.get("sessionId").toString()
|
||||
println("New Continue session with ID: $sessionId")
|
||||
sessionId
|
||||
}
|
||||
|
||||
private val pendingResponses: MutableMap<String, CompletableDeferred<Any>> =
|
||||
mutableMapOf()
|
||||
|
||||
fun sendAndReceive(
|
||||
messageType: String,
|
||||
data: Map<String, Any>
|
||||
): CompletableDeferred<Any> {
|
||||
val deferred = CompletableDeferred<Any>()
|
||||
pendingResponses[messageType] =
|
||||
deferred // Store the deferred object for later resolution
|
||||
|
||||
sendMessage(messageType, data)
|
||||
return deferred
|
||||
}
|
||||
|
||||
private fun serializeMessage(data: Map<String, Any>): String {
|
||||
val gson = Gson()
|
||||
return gson.toJson(data)
|
||||
}
|
||||
|
||||
private fun handleWebsocketMessage(webSocket: WebSocket, text: String) {
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
val parsedMessage: Map<String, Any> = Gson().fromJson(
|
||||
text,
|
||||
object : TypeToken<Map<String, Any>>() {}.type
|
||||
)
|
||||
val messageType = parsedMessage["messageType"] as? String
|
||||
val data = parsedMessage["data"] as Map<String, Any>
|
||||
|
||||
try {
|
||||
when (messageType) {
|
||||
"workspaceDirectory" -> {
|
||||
webSocket.send(
|
||||
Gson().toJson(
|
||||
WebSocketMessage(
|
||||
"workspaceDirectory",
|
||||
WorkspaceDirectory(workspaceDirectory())
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"uniqueId" -> webSocket.send(
|
||||
Gson().toJson(
|
||||
WebSocketMessage(
|
||||
"uniqueId",
|
||||
UniqueId(uniqueId())
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
"ide" -> {
|
||||
val applicationInfo = ApplicationInfo.getInstance()
|
||||
val ideName: String = applicationInfo.fullApplicationName
|
||||
val ideVersion = applicationInfo.fullVersion
|
||||
val sshClient = System.getenv("SSH_CLIENT")
|
||||
val sshTty = System.getenv("SSH_TTY")
|
||||
|
||||
var remoteName: String? = null
|
||||
if (sshClient != null || sshTty != null) {
|
||||
remoteName = "ssh"
|
||||
}
|
||||
webSocket.send(
|
||||
Gson().toJson(
|
||||
WebSocketMessage(
|
||||
"ide",
|
||||
IdeInfo(
|
||||
ideName, ideVersion, remoteName
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"showDiff" -> {
|
||||
diffManager.showDiff(
|
||||
data["filepath"] as String,
|
||||
data["replacement"] as String,
|
||||
(data["step_index"] as Double).toInt()
|
||||
)
|
||||
}
|
||||
|
||||
"readFile" -> {
|
||||
val msg =
|
||||
ReadFile(readFile(data["filepath"] as String))
|
||||
webSocket.send(
|
||||
Gson().toJson(
|
||||
WebSocketMessage(
|
||||
"readFile",
|
||||
msg
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"listDirectoryContents" -> {
|
||||
webSocket.send(
|
||||
Gson().toJson(
|
||||
WebSocketMessage(
|
||||
"listDirectoryContents",
|
||||
ListDirectoryContents(listDirectoryContents())
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"getTerminalContents" -> {
|
||||
webSocket.send(
|
||||
Gson().toJson(
|
||||
WebSocketMessage(
|
||||
"getTerminalContents",
|
||||
GetTerminalContents("Terminal cannot be accessed in JetBrains IDE")
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"visibleFiles" -> {
|
||||
val msg = VisibleFiles(visibleFiles())
|
||||
webSocket.send(
|
||||
Gson().toJson(
|
||||
WebSocketMessage(
|
||||
"visibleFiles",
|
||||
msg
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"saveFile" -> saveFile(data["filepath"] as String)
|
||||
"showVirtualFile" -> showVirtualFile(
|
||||
data["name"] as String,
|
||||
data["contents"] as String
|
||||
)
|
||||
|
||||
"connected" -> {}
|
||||
"showMessage" -> showMessage(data["message"] as String)
|
||||
"setFileOpen" -> setFileOpen(
|
||||
data["filepath"] as String,
|
||||
data["open"] as Boolean
|
||||
)
|
||||
|
||||
"highlightCode" -> {
|
||||
val gson = Gson()
|
||||
val json = gson.toJson(data["rangeInFile"])
|
||||
val type = object : TypeToken<RangeInFile>() {}.type
|
||||
val rangeInFile =
|
||||
gson.fromJson<RangeInFile>(json, type)
|
||||
highlightCode(rangeInFile, data["color"] as String)
|
||||
}
|
||||
|
||||
"setSuggestionsLocked" -> {}
|
||||
"getSessionId" -> {}
|
||||
"highlightedCode" -> {
|
||||
val rifWithContents = getHighlightedCode()
|
||||
val rifs: MutableList<RangeInFile> = mutableListOf()
|
||||
if (rifWithContents != null) {
|
||||
val rif = RangeInFile(rifWithContents.filepath, rifWithContents.range)
|
||||
rifs += rif
|
||||
}
|
||||
webSocket.send(
|
||||
Gson().toJson(
|
||||
WebSocketMessage(
|
||||
"highlightedCode",
|
||||
HighlightedCode(rifs)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
println("Unknown messageType: $messageType")
|
||||
}
|
||||
}
|
||||
} catch (error: Exception) {
|
||||
showMessage("Error handling message of type $messageType: $error")
|
||||
}
|
||||
|
||||
|
||||
if (messageType != null) {
|
||||
pendingResponses[messageType]?.complete(parsedMessage)
|
||||
pendingResponses.remove(messageType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var backoff: Int = 100 // ms
|
||||
|
||||
private fun initWebSocket() {
|
||||
val webSocketListener = object : WebSocketListener() {
|
||||
|
||||
override fun onOpen(webSocket: WebSocket, response: Response) {
|
||||
// handle onOpen
|
||||
backoff = 100 // reset backoff
|
||||
}
|
||||
|
||||
override fun onMessage(webSocket: WebSocket, text: String) {
|
||||
handleWebsocketMessage(webSocket, text)
|
||||
}
|
||||
|
||||
override fun onFailure(
|
||||
webSocket: WebSocket,
|
||||
t: Throwable,
|
||||
response: Response?
|
||||
) {
|
||||
eventListeners.forEach { it.onErrorOccurred(t) }
|
||||
// handle failure
|
||||
backoff *= 2
|
||||
if (backoff > 10000000) return
|
||||
Thread.sleep(backoff.toLong())
|
||||
initWebSocket()
|
||||
}
|
||||
|
||||
override fun onClosed(webSocket: WebSocket, code: Int, reason: String) {
|
||||
super.onClosed(webSocket, code, reason)
|
||||
println("Closing Continue IDE websocket")
|
||||
// handle closure
|
||||
backoff *= 2
|
||||
if (backoff > 10000000) return
|
||||
Thread.sleep(backoff.toLong())
|
||||
initWebSocket()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val request = Request.Builder()
|
||||
.url("${serverUrl}${if (sessionId != null) "?session_id=$sessionId" else ""}")
|
||||
.build()
|
||||
|
||||
webSocket = okHttpClient.newWebSocket(request, webSocketListener)
|
||||
}
|
||||
|
||||
fun addEventListener(listener: WebSocketEventListener) {
|
||||
eventListeners.add(listener)
|
||||
}
|
||||
|
||||
fun connect() {
|
||||
// Connection is handled automatically by OkHttp
|
||||
}
|
||||
|
||||
fun disconnect() {
|
||||
webSocket?.close(1000, null)
|
||||
}
|
||||
|
||||
private fun sendMessage(messageType: String, message: Map<String, Any>) {
|
||||
val sendData = mapOf("messageType" to messageType, "data" to message)
|
||||
val jsonMessage = serializeMessage(sendData)
|
||||
webSocket?.send(jsonMessage)
|
||||
}
|
||||
|
||||
fun workspaceDirectory(): String {
|
||||
return this.workspacePath
|
||||
}
|
||||
|
||||
fun uniqueId(): String {
|
||||
return getMachineUniqueID()
|
||||
}
|
||||
|
||||
fun onTextSelected(
|
||||
selectedText: String,
|
||||
filepath: String,
|
||||
startLine: Int,
|
||||
startCharacter: Int,
|
||||
endLine: Int,
|
||||
endCharacter: Int
|
||||
) = coroutineScope.launch {
|
||||
// val jsonMessage = textSelectionStrategy.handleTextSelection(
|
||||
// selectedText,
|
||||
// filepath,
|
||||
// startLine,
|
||||
// startCharacter,
|
||||
// endLine,
|
||||
// endCharacter
|
||||
// )
|
||||
// sendMessage("highlightedCodePush", jsonMessage)
|
||||
// dispatchEventToWebview(
|
||||
// "highlightedCode",
|
||||
// jsonMessage,
|
||||
// continuePluginService.continuePluginWindow.webView
|
||||
// )
|
||||
}
|
||||
|
||||
fun readFile(filepath: String): String {
|
||||
val file =
|
||||
LocalFileSystem.getInstance().findFileByPath(filepath) ?: return ""
|
||||
val documentManager = FileDocumentManager.getInstance()
|
||||
val document = ApplicationManager.getApplication().runReadAction(Computable {
|
||||
documentManager.getDocument(file)
|
||||
})
|
||||
return document?.text ?: ""
|
||||
}
|
||||
|
||||
fun getHighlightedCode(): RangeInFileWithContents? {
|
||||
val result = ApplicationManager.getApplication().runReadAction<RangeInFileWithContents?> {
|
||||
// Get the editor instance for the currently active editor window
|
||||
val editor = FileEditorManager.getInstance(project).selectedTextEditor ?: return@runReadAction null
|
||||
val virtualFile = editor.let { FileDocumentManager.getInstance().getFile(it.document) } ?: return@runReadAction null
|
||||
|
||||
// Get the selection range and content
|
||||
val selectionModel: SelectionModel = editor.selectionModel
|
||||
val selectedText = selectionModel.selectedText ?: ""
|
||||
|
||||
val document = editor.document
|
||||
val startOffset = selectionModel.selectionStart
|
||||
val endOffset = selectionModel.selectionEnd
|
||||
|
||||
if (startOffset == endOffset) {
|
||||
return@runReadAction null
|
||||
}
|
||||
|
||||
val startLine = document.getLineNumber(startOffset)
|
||||
val endLine = document.getLineNumber(endOffset)
|
||||
|
||||
val startChar = startOffset - document.getLineStartOffset(startLine)
|
||||
val endChar = endOffset - document.getLineStartOffset(endLine)
|
||||
|
||||
return@runReadAction RangeInFileWithContents(virtualFile.path, Range(
|
||||
Position(startLine, startChar),
|
||||
Position(endLine, endChar)
|
||||
), selectedText)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private fun<T> sendWebSocketMessage(messageType: String, data: T) {
|
||||
webSocket?.send(Gson().toJson(
|
||||
WebSocketMessage(messageType, data)
|
||||
))
|
||||
}
|
||||
|
||||
fun sendHighlightedCode(edit: Boolean = false) {
|
||||
val rif = getHighlightedCode() ?: return
|
||||
|
||||
sendWebSocketMessage("highlightedCodePush", HighlightedCodeUpdate(
|
||||
listOf(rif),
|
||||
edit
|
||||
))
|
||||
}
|
||||
|
||||
fun sendMainUserInput(input: String) {
|
||||
sendWebSocketMessage("mainUserInput", MainUserInput(input))
|
||||
}
|
||||
|
||||
fun sendAcceptRejectDiff(accepted: Boolean, stepIndex: Int) {
|
||||
sendWebSocketMessage("acceptRejectDiff", AcceptRejectDiff(accepted, stepIndex))
|
||||
}
|
||||
|
||||
fun deleteAtIndex(index: Int) {
|
||||
sendWebSocketMessage("deleteAtIndex", DeleteAtIndex(index))
|
||||
}
|
||||
|
||||
private val DEFAULT_IGNORE_DIRS = listOf(
|
||||
".git",
|
||||
".vscode",
|
||||
".idea",
|
||||
".vs",
|
||||
".venv",
|
||||
"env",
|
||||
".env",
|
||||
"node_modules",
|
||||
"dist",
|
||||
"build",
|
||||
"target",
|
||||
"out",
|
||||
"bin",
|
||||
".pytest_cache",
|
||||
".vscode-test",
|
||||
".continue",
|
||||
"__pycache__"
|
||||
)
|
||||
private fun shouldIgnoreDirectory(name: String): Boolean {
|
||||
val components = File(name).path.split(File.separator)
|
||||
return DEFAULT_IGNORE_DIRS.any { dir ->
|
||||
components.contains(dir)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun listDirectoryContents(): List<String> {
|
||||
val workspacePath = File(workspaceDirectory())
|
||||
val workspaceDir = VirtualFileManager.getInstance().findFileByUrl("file://$workspacePath")
|
||||
|
||||
val contents = ArrayList<String>()
|
||||
|
||||
if (workspaceDir != null) {
|
||||
VfsUtil.iterateChildrenRecursively(workspaceDir, null) { virtualFile: VirtualFile ->
|
||||
if (!virtualFile.isDirectory) {
|
||||
val filePath = virtualFile.path
|
||||
if (!shouldIgnoreDirectory(filePath)) {
|
||||
contents.add(filePath)
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
return contents
|
||||
}
|
||||
|
||||
fun saveFile(filepath: String) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
val file = LocalFileSystem.getInstance().findFileByPath(filepath) ?: return@invokeLater
|
||||
val fileDocumentManager = FileDocumentManager.getInstance()
|
||||
val document = fileDocumentManager.getDocument(file)
|
||||
|
||||
document?.let {
|
||||
fileDocumentManager.saveDocument(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setFileOpen(filepath: String, open: Boolean = true) {
|
||||
val file = LocalFileSystem.getInstance().findFileByPath(filepath)
|
||||
|
||||
file?.let {
|
||||
if (open) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
FileEditorManager.getInstance(project).openFile(it, true)
|
||||
}
|
||||
} else {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
FileEditorManager.getInstance(project).closeFile(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun showVirtualFile(name: String, contents: String) {
|
||||
val virtualFile = LightVirtualFile(name, contents)
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
FileEditorManager.getInstance(project).openFile(virtualFile, true)
|
||||
}
|
||||
}
|
||||
|
||||
fun visibleFiles(): List<String> {
|
||||
val fileEditorManager = FileEditorManager.getInstance(project)
|
||||
return fileEditorManager.openFiles.toList().map { it.path }
|
||||
}
|
||||
|
||||
fun showMessage(msg: String) {
|
||||
val statusBar = WindowManager.getInstance().getStatusBar(project)
|
||||
|
||||
JBPopupFactory.getInstance()
|
||||
.createHtmlTextBalloonBuilder(msg, MessageType.INFO, null)
|
||||
.setFadeoutTime(5000)
|
||||
.createBalloon()
|
||||
.show(
|
||||
RelativePoint.getSouthEastOf(statusBar.component),
|
||||
Balloon.Position.atRight
|
||||
)
|
||||
}
|
||||
|
||||
fun highlightCode(rangeInFile: RangeInFile, color: String) {
|
||||
val file =
|
||||
LocalFileSystem.getInstance().findFileByPath(rangeInFile.filepath)
|
||||
|
||||
setFileOpen(rangeInFile.filepath, true)
|
||||
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
val editor = file?.let {
|
||||
val fileEditor =
|
||||
FileEditorManager.getInstance(project).getSelectedEditor(it)
|
||||
(fileEditor as? TextEditor)?.editor
|
||||
}
|
||||
|
||||
val virtualFile = LocalFileSystem.getInstance()
|
||||
.findFileByIoFile(File(rangeInFile.filepath))
|
||||
val document =
|
||||
FileDocumentManager.getInstance().getDocument(virtualFile!!)
|
||||
val startIdx =
|
||||
document!!.getLineStartOffset(rangeInFile.range.start.line) + rangeInFile.range.start.character
|
||||
val endIdx =
|
||||
document.getLineEndOffset(rangeInFile.range.end.line) + rangeInFile.range.end.character
|
||||
|
||||
val markupModel = editor!!.markupModel
|
||||
// val textAttributes = TextAttributes(Color.decode(color.drop(1).toInt(color)), null, null, null, 0)
|
||||
|
||||
// markupModel.addRangeHighlighter(startIdx, endIdx, 0, textAttributes, HighlighterTargetArea.EXACT_RANGE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface TextSelectionStrategy {
|
||||
fun handleTextSelection(
|
||||
selectedText: String,
|
||||
filepath: String,
|
||||
startLine: Int,
|
||||
startCharacter: Int,
|
||||
endLine: Int,
|
||||
endCharacter: Int
|
||||
): Map<String, Any>
|
||||
}
|
||||
|
||||
class DefaultTextSelectionStrategy : TextSelectionStrategy {
|
||||
|
||||
override fun handleTextSelection(
|
||||
selectedText: String,
|
||||
filepath: String,
|
||||
startLine: Int,
|
||||
startCharacter: Int,
|
||||
endLine: Int,
|
||||
endCharacter: Int
|
||||
): Map<String, Any> {
|
||||
|
||||
return mapOf(
|
||||
"edit" to false,
|
||||
"highlightedCode" to arrayOf(
|
||||
mapOf(
|
||||
"filepath" to filepath,
|
||||
"contents" to selectedText,
|
||||
"range" to mapOf(
|
||||
"start" to mapOf(
|
||||
"line" to startLine,
|
||||
"character" to startCharacter
|
||||
),
|
||||
"end" to mapOf(
|
||||
"line" to endLine,
|
||||
"character" to endCharacter
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.intellij.codeInsight.hints.presentation.BasePresentation
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.markup.TextAttributes
|
||||
import java.awt.*
|
||||
|
||||
internal class InlineBoxPresentation(private val editor: Editor): BasePresentation() {
|
||||
override val height: Int = 50
|
||||
override val width: Int = 200
|
||||
|
||||
override fun paint(g: Graphics2D, attributes: TextAttributes) {
|
||||
val color = attributes.foregroundColor
|
||||
val text = "Hello World!"
|
||||
g.color = color
|
||||
g.drawString(text, 0, 0)
|
||||
}
|
||||
|
||||
override fun toString(): String = "InlineBoxPresentation"
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.intellij.codeInsight.codeVision.*
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
|
||||
class InputBoxCodeVision: CodeVisionProvider<Unit> {
|
||||
companion object {
|
||||
const val id: String = "continue.code.vision"
|
||||
}
|
||||
|
||||
override val name: String
|
||||
get() = "Hello World!"
|
||||
override val relativeOrderings: List<CodeVisionRelativeOrdering>
|
||||
get() = emptyList()
|
||||
|
||||
override val defaultAnchor: CodeVisionAnchorKind
|
||||
get() = CodeVisionAnchorKind.Default
|
||||
override val id: String
|
||||
get() = Companion.id
|
||||
|
||||
override fun precomputeOnUiThread(editor: Editor) {}
|
||||
|
||||
override fun computeCodeVision(editor: Editor, uiData: Unit): CodeVisionState {
|
||||
val lenses: List<Pair<TextRange, CodeVisionEntry>> = emptyList()
|
||||
// val range = TextRange(0, 1)
|
||||
// lenses.add(range to )
|
||||
return CodeVisionState.Ready(lenses)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.intellij.codeInsight.hints.*
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JTextArea
|
||||
|
||||
class InputBoxInlayProvider: InlayHintsProvider<NoSettings> {
|
||||
override val key: SettingsKey<NoSettings>
|
||||
get() = SettingsKey<NoSettings>("InputBoxInlayProviderSettingsKey")
|
||||
override val name: String
|
||||
get() = "Continue Quick Input"
|
||||
|
||||
override val previewText: String?
|
||||
get() = "Continue Quick Input"
|
||||
|
||||
override fun createSettings() = NoSettings()
|
||||
|
||||
override fun getCollectorFor(file: PsiFile, editor: Editor, settings: NoSettings, sink: InlayHintsSink): InlayHintsCollector? {
|
||||
return Collector(editor)
|
||||
}
|
||||
|
||||
private class Collector(editor: Editor): FactoryInlayHintsCollector(editor) {
|
||||
override fun collect(element: PsiElement, editor: Editor, sink: InlayHintsSink): Boolean {
|
||||
if (element.text == "continue") {
|
||||
// val presentation = HorizontalBarPresentation.create(factory, editor, element)
|
||||
// sink.addInlineElement(element.textOffset, true, presentation)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun createConfigurable(settings: NoSettings): ImmediateConfigurable {
|
||||
return object : ImmediateConfigurable {
|
||||
override fun createComponent(listener: ChangeListener): JComponent {
|
||||
return JTextArea("Hello World!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
interface WebSocketEventListener {
|
||||
fun onMessageReceived(message: String)
|
||||
fun onErrorOccurred(error: Throwable)
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
package com.github.continuedev.continueintellijextension.factories
|
||||
|
||||
import org.cef.browser.CefBrowser
|
||||
import org.cef.browser.CefFrame
|
||||
import org.cef.callback.CefCallback
|
||||
import org.cef.callback.CefSchemeHandlerFactory
|
||||
import org.cef.handler.CefLoadHandler
|
||||
import org.cef.handler.CefResourceHandler
|
||||
import org.cef.misc.IntRef
|
||||
import org.cef.misc.StringRef
|
||||
import org.cef.network.CefRequest
|
||||
import org.cef.network.CefResponse
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.net.URLConnection
|
||||
|
||||
class CustomSchemeHandlerFactory : CefSchemeHandlerFactory {
|
||||
override fun create(
|
||||
browser: CefBrowser?,
|
||||
frame: CefFrame?,
|
||||
schemeName: String,
|
||||
request: CefRequest
|
||||
): CefResourceHandler {
|
||||
return CustomResourceHandler()
|
||||
}
|
||||
}
|
||||
|
||||
class CustomResourceHandler : CefResourceHandler {
|
||||
private var state: ResourceHandlerState = ClosedConnection
|
||||
override fun processRequest(
|
||||
cefRequest: CefRequest,
|
||||
cefCallback: CefCallback
|
||||
): Boolean {
|
||||
val url = cefRequest.url
|
||||
return if (url != null) {
|
||||
val pathToResource = url.replace("http://continue", "webview/")
|
||||
val newUrl = javaClass.classLoader.getResource(pathToResource)
|
||||
state = OpenedConnection(newUrl?.openConnection())
|
||||
cefCallback.Continue()
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun getResponseHeaders(
|
||||
cefResponse: CefResponse,
|
||||
responseLength: IntRef,
|
||||
redirectUrl: StringRef
|
||||
) {
|
||||
state.getResponseHeaders(cefResponse, responseLength, redirectUrl)
|
||||
}
|
||||
|
||||
override fun readResponse(
|
||||
dataOut: ByteArray,
|
||||
bytesToRead: Int,
|
||||
bytesRead: IntRef,
|
||||
callback: CefCallback
|
||||
): Boolean {
|
||||
return state.readResponse(dataOut, bytesToRead, bytesRead, callback)
|
||||
}
|
||||
|
||||
override fun cancel() {
|
||||
state.close()
|
||||
state = ClosedConnection
|
||||
}
|
||||
}
|
||||
|
||||
sealed class ResourceHandlerState {
|
||||
open fun getResponseHeaders(
|
||||
cefResponse: CefResponse,
|
||||
responseLength: IntRef,
|
||||
redirectUrl: StringRef
|
||||
) {
|
||||
}
|
||||
|
||||
open fun readResponse(
|
||||
dataOut: ByteArray,
|
||||
bytesToRead: Int,
|
||||
bytesRead: IntRef,
|
||||
callback: CefCallback
|
||||
): Boolean = false
|
||||
|
||||
open fun close() {}
|
||||
}
|
||||
|
||||
|
||||
class OpenedConnection(private val connection: URLConnection?) :
|
||||
ResourceHandlerState() {
|
||||
|
||||
private val inputStream: InputStream? by lazy {
|
||||
connection?.inputStream
|
||||
}
|
||||
|
||||
override fun getResponseHeaders(
|
||||
cefResponse: CefResponse,
|
||||
responseLength: IntRef,
|
||||
redirectUrl: StringRef
|
||||
) {
|
||||
try {
|
||||
if (connection != null) {
|
||||
val url = connection.url.toString()
|
||||
when {
|
||||
url.contains("css") -> cefResponse.mimeType = "text/css"
|
||||
url.contains("js") -> cefResponse.mimeType = "text/javascript"
|
||||
url.contains("html") -> cefResponse.mimeType = "text/html"
|
||||
else -> cefResponse.mimeType = connection.contentType
|
||||
}
|
||||
responseLength.set(inputStream?.available() ?: 0)
|
||||
cefResponse.status = 200
|
||||
} else {
|
||||
// Handle the case where connection is null
|
||||
cefResponse.error = CefLoadHandler.ErrorCode.ERR_FAILED
|
||||
cefResponse.statusText = "Connection is null"
|
||||
cefResponse.status = 500
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
cefResponse.error = CefLoadHandler.ErrorCode.ERR_FILE_NOT_FOUND
|
||||
cefResponse.statusText = e.localizedMessage
|
||||
cefResponse.status = 404
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun readResponse(
|
||||
dataOut: ByteArray,
|
||||
bytesToRead: Int,
|
||||
bytesRead: IntRef,
|
||||
callback: CefCallback
|
||||
): Boolean {
|
||||
return inputStream?.let {inputStream ->
|
||||
val availableSize = inputStream.available()
|
||||
return if (availableSize > 0) {
|
||||
val maxBytesToRead = minOf(availableSize, bytesToRead)
|
||||
val realBytesRead = inputStream.read(dataOut, 0, maxBytesToRead)
|
||||
bytesRead.set(realBytesRead)
|
||||
true
|
||||
} else {
|
||||
inputStream.close()
|
||||
false
|
||||
}
|
||||
} ?: false
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
inputStream?.close()
|
||||
}
|
||||
}
|
||||
|
||||
object ClosedConnection : ResourceHandlerState() {
|
||||
override fun getResponseHeaders(
|
||||
cefResponse: CefResponse,
|
||||
responseLength: IntRef,
|
||||
redirectUrl: StringRef
|
||||
) {
|
||||
cefResponse.status = 404
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.github.continuedev.continueintellijextension.listeners
|
||||
|
||||
import com.github.continuedev.continueintellijextension.`continue`.IdeProtocolClient
|
||||
import com.github.continuedev.continueintellijextension.utils.Debouncer
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.SelectionModel
|
||||
import com.intellij.openapi.editor.event.SelectionEvent
|
||||
import com.intellij.openapi.editor.event.SelectionListener
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
class ContinuePluginSelectionListener(
|
||||
private val ideProtocolClient: IdeProtocolClient,
|
||||
private val coroutineScope: CoroutineScope
|
||||
) : SelectionListener {
|
||||
private val debouncer = Debouncer(100L, coroutineScope)
|
||||
override fun selectionChanged(e: SelectionEvent) {
|
||||
debouncer.debounce { handleSelection(e) }
|
||||
}
|
||||
|
||||
private fun handleSelection(e: SelectionEvent) {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
val editor = e.editor
|
||||
val model: SelectionModel = editor.selectionModel
|
||||
val selectedText = model.selectedText ?: return@runReadAction
|
||||
|
||||
val document = editor.document
|
||||
val startOffset = model.selectionStart
|
||||
val endOffset = model.selectionEnd
|
||||
val startLine = document.getLineNumber(startOffset)
|
||||
val endLine = document.getLineNumber(endOffset)
|
||||
val startCharacter =
|
||||
startOffset - document.getLineStartOffset(startLine)
|
||||
val endCharacter = endOffset - document.getLineStartOffset(endLine)
|
||||
|
||||
val virtualFile: VirtualFile? =
|
||||
FileDocumentManager.getInstance().getFile(document)
|
||||
val filepath = virtualFile?.path ?: "Unknown path"
|
||||
|
||||
ideProtocolClient.onTextSelected(
|
||||
selectedText,
|
||||
filepath,
|
||||
startLine,
|
||||
startCharacter,
|
||||
endLine,
|
||||
endCharacter
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package com.github.continuedev.continueintellijextension.services
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.options.Configurable
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.awt.GridBagConstraints
|
||||
import java.awt.GridBagLayout
|
||||
import javax.annotation.Nullable
|
||||
import javax.swing.JCheckBox
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JLabel
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.JTextField
|
||||
|
||||
class ContinueSettingsComponent {
|
||||
val panel: JPanel = JPanel(GridBagLayout())
|
||||
private val myTextField: JTextField = JTextField()
|
||||
private val myCheckBox: JCheckBox =
|
||||
JCheckBox("Manually Running Continue Server")
|
||||
|
||||
init {
|
||||
val constraints = GridBagConstraints()
|
||||
|
||||
constraints.fill = GridBagConstraints.HORIZONTAL
|
||||
constraints.weightx = 1.0
|
||||
constraints.weighty = 0.0
|
||||
constraints.gridx = 0
|
||||
constraints.gridy = GridBagConstraints.RELATIVE
|
||||
|
||||
val serverURLLabel = JLabel("Server URL")
|
||||
panel.add(serverURLLabel, constraints)
|
||||
|
||||
panel.add(myTextField, constraints)
|
||||
|
||||
val runningServerLabel = JLabel("Manually Running Server")
|
||||
panel.add(runningServerLabel, constraints)
|
||||
|
||||
panel.add(myCheckBox, constraints)
|
||||
|
||||
// Add a "filler" component that takes up all remaining vertical space
|
||||
constraints.weighty = 1.0
|
||||
val filler = JPanel()
|
||||
panel.add(filler, constraints)
|
||||
|
||||
}
|
||||
|
||||
var serverUrl: String?
|
||||
get() = myTextField.text
|
||||
set(newText) {
|
||||
myTextField.text = newText
|
||||
}
|
||||
|
||||
var manuallyRunningServer: Boolean
|
||||
get() = myCheckBox.isSelected
|
||||
set(value) {
|
||||
myCheckBox.isSelected = value
|
||||
}
|
||||
}
|
||||
|
||||
@State(
|
||||
name = "com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings",
|
||||
storages = [Storage("ContinueExtensionSettings.xml")]
|
||||
)
|
||||
open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensionSettings.ContinueState> {
|
||||
|
||||
class ContinueState {
|
||||
var serverUrl: String = "http://localhost:65432"
|
||||
var manuallyRunningServer: Boolean = false
|
||||
var shownWelcomeDialog: Boolean = false
|
||||
}
|
||||
|
||||
var continueState: ContinueState = ContinueState()
|
||||
|
||||
override fun getState(): ContinueState {
|
||||
return continueState
|
||||
}
|
||||
|
||||
override fun loadState(state: ContinueState) {
|
||||
continueState = state
|
||||
}
|
||||
|
||||
companion object {
|
||||
val instance: ContinueExtensionSettings
|
||||
get() = ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
class ContinueExtensionConfigurable : Configurable {
|
||||
private var mySettingsComponent: ContinueSettingsComponent? = null
|
||||
|
||||
override fun createComponent(): JComponent {
|
||||
mySettingsComponent = ContinueSettingsComponent()
|
||||
return mySettingsComponent!!.panel
|
||||
}
|
||||
|
||||
override fun isModified(): Boolean {
|
||||
val settings = ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
return mySettingsComponent!!.serverUrl != settings.continueState.serverUrl || mySettingsComponent!!.manuallyRunningServer != settings.continueState.manuallyRunningServer
|
||||
}
|
||||
|
||||
override fun apply() {
|
||||
val settings =
|
||||
ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
settings.continueState.serverUrl =
|
||||
mySettingsComponent?.serverUrl ?: "http://localhost:65432"
|
||||
settings.continueState.manuallyRunningServer =
|
||||
mySettingsComponent!!.manuallyRunningServer
|
||||
}
|
||||
|
||||
override fun reset() {
|
||||
val settings =
|
||||
ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
mySettingsComponent!!.serverUrl = settings.continueState.serverUrl
|
||||
mySettingsComponent!!.manuallyRunningServer =
|
||||
settings.continueState.manuallyRunningServer
|
||||
}
|
||||
|
||||
override fun disposeUIResources() {
|
||||
mySettingsComponent = null
|
||||
}
|
||||
|
||||
override fun getDisplayName(): String {
|
||||
return "Continue Extension Settings"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.github.continuedev.continueintellijextension.services
|
||||
|
||||
import com.github.continuedev.continueintellijextension.`continue`.IdeProtocolClient
|
||||
import com.github.continuedev.continueintellijextension.toolWindow.ContinuePluginToolWindowFactory
|
||||
import com.google.gson.Gson
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.ui.jcef.executeJavaScriptAsync
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Service(Service.Level.PROJECT)
|
||||
class ContinuePluginService(project: Project) : Disposable {
|
||||
val coroutineScope = CoroutineScope(Dispatchers.Main)
|
||||
var continuePluginWindow: ContinuePluginToolWindowFactory.ContinuePluginWindow? = null
|
||||
|
||||
var ideProtocolClient: IdeProtocolClient? = null
|
||||
var sessionId: String? = null
|
||||
var worksapcePaths: Array<String>? = null
|
||||
|
||||
override fun dispose() {
|
||||
coroutineScope.cancel()
|
||||
}
|
||||
|
||||
fun launchInScope(block: suspend CoroutineScope.() -> Unit) {
|
||||
coroutineScope.launch {
|
||||
block()
|
||||
}
|
||||
}
|
||||
|
||||
fun dispatchCustomEvent(
|
||||
type: String,
|
||||
data: Map<String, Any>
|
||||
) {
|
||||
val gson = Gson()
|
||||
val jsonData = gson.toJson(data)
|
||||
val jsCode = buildJavaScript(type, jsonData)
|
||||
|
||||
try {
|
||||
continuePluginWindow?.webView?.executeJavaScriptAsync(jsCode)
|
||||
} catch (error: IllegalStateException) {
|
||||
println("Webview not initialized yet $error")
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildJavaScript(type: String, jsonData: String): String {
|
||||
return """window.postMessage($jsonData, "*");"""
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
package com.github.continuedev.continueintellijextension.toolWindow
|
||||
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.ui.components.JBPanel
|
||||
import com.intellij.ui.content.ContentFactory
|
||||
import com.intellij.ui.jcef.JBCefJSQuery
|
||||
import javax.swing.*
|
||||
import com.github.continuedev.continueintellijextension.activities.getContinueServerUrl
|
||||
import com.github.continuedev.continueintellijextension.`continue`.getMachineUniqueID
|
||||
import com.github.continuedev.continueintellijextension.factories.CustomSchemeHandlerFactory
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.github.continuedev.continueintellijextension.utils.runJsInWebview
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonParser
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.wm.ToolWindow
|
||||
import com.intellij.openapi.wm.ToolWindowFactory
|
||||
import com.intellij.ui.jcef.*
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.cef.CefApp
|
||||
import org.cef.browser.CefBrowser
|
||||
import org.cef.handler.CefLoadHandlerAdapter
|
||||
import javax.swing.JComponent
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
const val JS_QUERY_POOL_SIZE = "200"
|
||||
|
||||
class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware {
|
||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||
val continueToolWindow = ContinuePluginWindow(toolWindow, project)
|
||||
val content = ContentFactory.getInstance().createContent(continueToolWindow.content, null, false)
|
||||
toolWindow.contentManager.addContent(content)
|
||||
}
|
||||
|
||||
override fun shouldBeAvailable(project: Project) = true
|
||||
|
||||
|
||||
class ContinuePluginWindow(toolWindow: ToolWindow, project: Project) {
|
||||
|
||||
init {
|
||||
System.setProperty("ide.browser.jcef.jsQueryPoolSize", JS_QUERY_POOL_SIZE)
|
||||
}
|
||||
|
||||
suspend fun waitForSessionId(pluginService: ContinuePluginService) {
|
||||
while (pluginService.sessionId == null) {
|
||||
delay(200)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val webView: JBCefBrowser by lazy {
|
||||
val browser = JBCefBrowser()
|
||||
browser.jbCefClient.setProperty(
|
||||
JBCefClient.Properties.JS_QUERY_POOL_SIZE,
|
||||
JS_QUERY_POOL_SIZE
|
||||
)
|
||||
registerAppSchemeHandler()
|
||||
|
||||
browser.loadURL("http://continue/index.html")
|
||||
Disposer.register(project, browser)
|
||||
|
||||
val continuePluginService = ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
continuePluginService.continuePluginWindow = this
|
||||
|
||||
// Listen for events sent from browser
|
||||
val myJSQueryOpenInBrowser = JBCefJSQuery.create((browser as JBCefBrowserBase?)!!)
|
||||
myJSQueryOpenInBrowser.addHandler { msg: String? ->
|
||||
val parser = JsonParser()
|
||||
val json: JsonObject = parser.parse(msg).asJsonObject
|
||||
val type = json.get("type").asString
|
||||
when (type) {
|
||||
"onLoad" -> {
|
||||
GlobalScope.launch {
|
||||
// Set the colors to match Intellij theme
|
||||
val globalScheme = EditorColorsManager.getInstance().globalScheme
|
||||
val defaultBackground = globalScheme.defaultBackground
|
||||
val defaultForeground = globalScheme.defaultForeground
|
||||
val defaultBackgroundHex = String.format("#%02x%02x%02x", defaultBackground.red, defaultBackground.green, defaultBackground.blue)
|
||||
val defaultForegroundHex = String.format("#%02x%02x%02x", defaultForeground.red, defaultForeground.green, defaultForeground.blue)
|
||||
|
||||
val grayscale = (defaultBackground.red * 0.3 + defaultBackground.green * 0.59 + defaultBackground.blue * 0.11).toInt()
|
||||
|
||||
val adjustedRed: Int
|
||||
val adjustedGreen: Int
|
||||
val adjustedBlue: Int
|
||||
|
||||
val tint: Int = 20
|
||||
if (grayscale > 128) { // if closer to white
|
||||
adjustedRed = max(0, defaultBackground.red - tint)
|
||||
adjustedGreen = max(0, defaultBackground.green - tint)
|
||||
adjustedBlue = max(0, defaultBackground.blue - tint)
|
||||
} else { // if closer to black
|
||||
adjustedRed = min(255, defaultBackground.red + tint)
|
||||
adjustedGreen = min(255, defaultBackground.green + tint)
|
||||
adjustedBlue = min(255, defaultBackground.blue + tint)
|
||||
}
|
||||
|
||||
val secondaryDarkHex = String.format("#%02x%02x%02x", adjustedRed, adjustedGreen, adjustedBlue)
|
||||
|
||||
browser.executeJavaScriptAsync("document.body.style.setProperty(\"--vscode-editor-foreground\", \"$defaultForegroundHex\");")
|
||||
browser.executeJavaScriptAsync("document.body.style.setProperty(\"--vscode-editor-background\", \"$defaultBackgroundHex\");")
|
||||
browser.executeJavaScriptAsync("document.body.style.setProperty(\"--vscode-list-hoverBackground\", \"$secondaryDarkHex\");")
|
||||
|
||||
// Wait for session ID, then pass the onLoad information
|
||||
waitForSessionId(continuePluginService)
|
||||
|
||||
val sessionId = continuePluginService.sessionId
|
||||
val workspacePaths = continuePluginService.worksapcePaths
|
||||
|
||||
val jsonData = mutableMapOf(
|
||||
"type" to "onLoad",
|
||||
"sessionId" to sessionId,
|
||||
"apiUrl" to getContinueServerUrl(),
|
||||
"workspacePaths" to workspacePaths,
|
||||
"vscMachineId" to getMachineUniqueID(),
|
||||
"vscMediaUrl" to "http://continue",
|
||||
"dataSwitchOn" to true
|
||||
)
|
||||
val jsonString = Gson().toJson(jsonData)
|
||||
browser.executeJavaScriptAsync("""window.postMessage($jsonString, "*");""")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
null
|
||||
}
|
||||
|
||||
// Listen for the page load event
|
||||
browser.jbCefClient.addLoadHandler(object : CefLoadHandlerAdapter() {
|
||||
override fun onLoadingStateChange(
|
||||
browser: CefBrowser?,
|
||||
isLoading: Boolean,
|
||||
canGoBack: Boolean,
|
||||
canGoForward: Boolean
|
||||
) {
|
||||
if (!isLoading) {
|
||||
// The page has finished loading
|
||||
executeJavaScript(browser, myJSQueryOpenInBrowser)
|
||||
}
|
||||
}
|
||||
}, browser.cefBrowser)
|
||||
|
||||
browser
|
||||
}
|
||||
|
||||
fun executeJavaScript(browser: CefBrowser?, myJSQueryOpenInBrowser: JBCefJSQuery) {
|
||||
// Execute JavaScript - you might want to handle potential exceptions here
|
||||
val script = """window.postIntellijMessage = function(type, data) {
|
||||
const msg = JSON.stringify({type, data});
|
||||
${myJSQueryOpenInBrowser.inject("msg")}
|
||||
}""".trimIndent()
|
||||
|
||||
browser?.executeJavaScript(script, browser.url, 0)
|
||||
}
|
||||
|
||||
val content: JComponent
|
||||
get() = webView.component
|
||||
|
||||
private fun registerAppSchemeHandler() {
|
||||
CefApp.getInstance().registerSchemeHandlerFactory(
|
||||
"http",
|
||||
"continue",
|
||||
CustomSchemeHandlerFactory()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.github.continuedev.continueintellijextension.utils
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class Debouncer(
|
||||
private val interval: Long,
|
||||
private val coroutineScope: CoroutineScope
|
||||
) {
|
||||
private var debounceJob: Job? = null
|
||||
|
||||
fun debounce(action: suspend () -> Unit) {
|
||||
debounceJob?.cancel()
|
||||
debounceJob = coroutineScope.launch {
|
||||
delay(interval)
|
||||
action()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.github.continuedev.continueintellijextension.utils
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.intellij.ui.jcef.JBCefBrowser
|
||||
import com.intellij.ui.jcef.executeJavaScriptAsync
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
fun CoroutineScope.dispatchEventToWebview(
|
||||
type: String,
|
||||
data: Map<String, Any>,
|
||||
webView: JBCefBrowser?
|
||||
) {
|
||||
if (webView == null) return
|
||||
val gson = Gson()
|
||||
val jsonData = gson.toJson(data)
|
||||
val jsCode = buildJavaScript(type, jsonData)
|
||||
|
||||
launch(CoroutineExceptionHandler { _, exception ->
|
||||
println("Failed to dispatch custom event: ${exception.message}")
|
||||
}) {
|
||||
while (true) {
|
||||
try {
|
||||
webView.executeJavaScriptAsync(jsCode)
|
||||
break // If the JS execution is successful, break the loop
|
||||
} catch (e: IllegalStateException) {
|
||||
delay(1000) // If an error occurs, wait for 1 second and then retry
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun CoroutineScope.runJsInWebview(
|
||||
jsCode: String,
|
||||
webView: JBCefBrowser?
|
||||
) {
|
||||
if (webView == null) return
|
||||
launch(CoroutineExceptionHandler { _, exception ->
|
||||
println("Failed to dispatch custom event: ${exception.message}")
|
||||
}) {
|
||||
while (true) {
|
||||
try {
|
||||
webView.executeJavaScriptAsync(jsCode)
|
||||
break // If the JS execution is successful, break the loop
|
||||
} catch (e: IllegalStateException) {
|
||||
delay(1000) // If an error occurs, wait for 1 second and then retry
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildJavaScript(type: String, jsonData: String): String {
|
||||
return """window.postMessage($jsonData, "*");"""
|
||||
}
|
||||
102
extensions/intellij/src/main/resources/META-INF/plugin.xml
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
|
||||
<idea-plugin>
|
||||
<id>com.github.continuedev.continueintellijextension</id>
|
||||
<name>Continue</name>
|
||||
<vendor>continue-dev</vendor>
|
||||
|
||||
<depends>com.intellij.modules.platform</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<toolWindow id="Continue" anchor="right" icon="/tool-window-icon.png"
|
||||
factoryClass="com.github.continuedev.continueintellijextension.toolWindow.ContinuePluginToolWindowFactory"/>
|
||||
<projectService id="ContinuePluginService"
|
||||
serviceImplementation="com.github.continuedev.continueintellijextension.services.ContinuePluginService"/>
|
||||
</extensions>
|
||||
|
||||
<resource-bundle>messages.MyBundle</resource-bundle>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<postStartupActivity
|
||||
implementation="com.github.continuedev.continueintellijextension.activities.ContinuePluginStartupActivity"/>
|
||||
<applicationConfigurable
|
||||
parentId="tools"
|
||||
instance="com.github.continuedev.continueintellijextension.services.ContinueExtensionConfigurable"
|
||||
id="com.github.continuedev.continueintellijextension.services.ContinueExtensionConfigurable"
|
||||
displayName="Continue"/>
|
||||
<applicationService
|
||||
serviceImplementation="com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<action id="continue.acceptDiff"
|
||||
class="com.github.continuedev.continueintellijextension.actions.AcceptDiffAction"
|
||||
text="Accept Diff" description="Accept Diff">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="shift ctrl ENTER"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="shift meta ENTER"/>
|
||||
</action>
|
||||
<action id="continue.rejectDiff"
|
||||
class="com.github.continuedev.continueintellijextension.actions.RejectDiffAction"
|
||||
text="Reject Diff" description="Reject Diff">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="shift ctrl BACK_SPACE"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="shift meta BACK_SPACE"/>
|
||||
</action>
|
||||
<action id="continue.quickTextEntry"
|
||||
class="com.github.continuedev.continueintellijextension.actions.QuickTextEntryAction"
|
||||
text="Quick Text Entry" description="Quick Text Entry">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="alt shift J"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="alt shift J"/>
|
||||
</action>
|
||||
<action id="continue.viewLogs"
|
||||
class="com.github.continuedev.continueintellijextension.actions.ViewLogsAction"
|
||||
text="View Continue Server Logs"
|
||||
description="View Continue Server Logs">
|
||||
<!-- No shortcut defined -->
|
||||
</action>
|
||||
<action id="continue.toggleAuxiliaryBar"
|
||||
class="com.github.continuedev.continueintellijextension.actions.ToggleAuxiliaryBarAction"
|
||||
text="Toggle Right Sidebar" description="Toggle Right Sidebar">
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="alt ctrl J"/>
|
||||
<keyboard-shortcut keymap="Mac OS X" first-keystroke="alt meta J"/>
|
||||
</action>
|
||||
<action id="continue.focusContinueInputWithEdit"
|
||||
class="com.github.continuedev.continueintellijextension.actions.FocusContinueInputWithEditAction"
|
||||
text="Focus Continue Input With Edit"
|
||||
description="Focus Continue Input With Edit">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="ctrl shift J"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="meta shift J"/>
|
||||
</action>
|
||||
|
||||
<!-- <action id="InsertLiveTemplate" class="com.intellij.openapi.actionSystem.EmptyAction" />-->
|
||||
<!-- <action id="SurroundWithLiveTemplate" class="com.intellij.openapi.actionSystem.EmptyAction"/>-->
|
||||
|
||||
<action id="continue.newContinueSession"
|
||||
class="com.github.continuedev.continueintellijextension.actions.NewContinueSessionAction"
|
||||
text="Start New Continue Session"
|
||||
description="Start New Continue Session">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="alt ctrl N"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="alt meta N"/>
|
||||
</action>
|
||||
|
||||
<action id="continue.focusContinueInput"
|
||||
class="com.github.continuedev.continueintellijextension.actions.FocusContinueInputAction"
|
||||
text="Focus Continue Input"
|
||||
description="Focus Continue Input">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="ctrl J"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="meta J"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
|
||||
</idea-plugin>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<svg width="168" height="168" viewBox="0 0 168 168" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13.875 70.625V61.25H23.25V51.875H32.625V42.5H42V33.125H32.625V23.75H23.25V14.375H13.875V5H32.625V14.375H42V23.75H51.375V33.125H60.75V42.5H51.375V51.875H42V61.25H32.625V70.625H13.875Z" fill="black"/>
|
||||
<path d="M4.5 154.625V89H51.375V98.375H60.75V107.75H70.125V135.875H60.75V145.25H51.375V154.625H4.5ZM23.25 145.25H42V135.875H51.375V107.75H42V98.375H23.25V145.25Z" fill="black"/>
|
||||
<path d="M107.25 70.625V61.25H97.875V51.875H88.5V23.75H97.875V14.375H107.25V5H144.75V14.375H154.125V23.75H135.375V14.375H116.625V23.75H107.25V51.875H116.625V61.25H135.375V51.875H154.125V61.25H144.75V70.625H107.25Z" fill="black"/>
|
||||
<path d="M88.5 164V154.625H154.125V164H88.5Z" fill="black"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 801 B |
|
|
@ -0,0 +1,6 @@
|
|||
<svg width="168" height="168" viewBox="0 0 168 168" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13.875 70.625V61.25H23.25V51.875H32.625V42.5H42V33.125H32.625V23.75H23.25V14.375H13.875V5H32.625V14.375H42V23.75H51.375V33.125H60.75V42.5H51.375V51.875H42V61.25H32.625V70.625H13.875Z" fill="white"/>
|
||||
<path d="M4.5 154.625V89H51.375V98.375H60.75V107.75H70.125V135.875H60.75V145.25H51.375V154.625H4.5ZM23.25 145.25H42V135.875H51.375V107.75H42V98.375H23.25V145.25Z" fill="white"/>
|
||||
<path d="M107.25 70.625V61.25H97.875V51.875H88.5V23.75H97.875V14.375H107.25V5H144.75V14.375H154.125V23.75H135.375V14.375H116.625V23.75H107.25V51.875H116.625V61.25H135.375V51.875H154.125V61.25H144.75V70.625H107.25Z" fill="white"/>
|
||||
<path d="M88.5 164V154.625H154.125V164H88.5Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 801 B |
|
|
@ -0,0 +1,14 @@
|
|||
private fun CoroutineScope.dispatchCustomEvent(
|
||||
type: String,
|
||||
data: Map<String, Any>,
|
||||
webView: JBCefBrowser
|
||||
) {
|
||||
launch(CoroutineExceptionHandler { _, exception ->
|
||||
println("Failed to dispatch custom event: ${exception.message}")
|
||||
}) {
|
||||
val gson = Gson()
|
||||
val jsonData = gson.toJson(data)
|
||||
val jsCode = buildJavaScript(type, jsonData)
|
||||
webView.executeJavaScriptAsync(jsCode)
|
||||
}
|
||||
}
|
||||
56
extensions/intellij/src/main/resources/continue_tutorial.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
"""
|
||||
Welcome to Continue!
|
||||
|
||||
This is a 2 minute tutorial.
|
||||
|
||||
It will walk you through two basic features:
|
||||
1. Ask a question
|
||||
2. Edit code
|
||||
"""
|
||||
|
||||
# region —————————————————————————— Part 1: Ask a question about code [⌘ J] ——————————————————————————
|
||||
|
||||
|
||||
"""Step 1: Highlight the function below"""
|
||||
def mysterious_function(x):
|
||||
for i in range(len(x)):
|
||||
for j in range(len(x) - 1):
|
||||
if x[j] > x[j + 1]:
|
||||
x[j], x[j + 1] = x[j + 1], x[j]
|
||||
|
||||
return x
|
||||
|
||||
|
||||
"""Step 2: Use the keyboard shortcut [⌘ J] to
|
||||
select the code and toggle the Continue input box"""
|
||||
|
||||
"""Step 3: Ask a question and press enter"""
|
||||
# e.g.) what does this function do?
|
||||
# e.g.) what should I call this function?
|
||||
|
||||
# endregion
|
||||
|
||||
|
||||
# region ————————————————————————————————— Part 2: Edit code [⌘ ⇧ J] —————————————————————————————————
|
||||
|
||||
|
||||
"""Step 1: Highlight this code"""
|
||||
def bubble_sort(x):
|
||||
for i in range(len(x)):
|
||||
for j in range(len(x) - 1):
|
||||
if x[j] > x[j + 1]:
|
||||
x[j], x[j + 1] = x[j + 1], x[j]
|
||||
|
||||
return x
|
||||
|
||||
"""Step 2: Use the keyboard shortcut [⌘ ⇧ J] to
|
||||
select the code and toggle the /edit slash command"""
|
||||
|
||||
"""Step 3: Request an edit and press enter"""
|
||||
# e.g.) optimize this function
|
||||
# e.g.) write comments
|
||||
|
||||
"""Step 4: Use keyboard shortcuts to
|
||||
accept [⌘ ⇧ ↵] or reject [⌘ ⇧ ⌫] the edit"""
|
||||
|
||||
# endregion
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
projectService=Project service: {0}
|
||||
randomLabel=The random number is: {0}
|
||||
shuffle=Shuffle
|
||||
BIN
extensions/intellij/src/main/resources/tool-window-icon.png
Normal file
|
After Width: | Height: | Size: 168 B |
1267
extensions/intellij/src/main/resources/webview/assets/index.js
Normal file
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
29
extensions/intellij/src/main/resources/webview/index.html
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/play_button.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Continue</title>
|
||||
<script type="module" crossorigin src="/assets/index.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index.css" />
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Lexend:wght@300&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
<script>
|
||||
localStorage.setItem("ide", "jetbrains");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 181 KiB After Width: | Height: | Size: 181 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
BIN
extensions/intellij/src/main/resources/webview/logos/meta.png
Normal file
|
After Width: | Height: | Size: 57 KiB |