Merge branch 'main' of https://github.com/continuedev/continue into nate/retry-llm-tests
This commit is contained in:
commit
1c328b0974
265 changed files with 5848 additions and 3200 deletions
|
|
@ -1,8 +0,0 @@
|
|||
## 0.0.34 - 2024-03-03
|
||||
### Added
|
||||
* diff context provider
|
||||
### Changed
|
||||
* Allow LLM servers to handle templating
|
||||
### Fixed
|
||||
* Fix a few context providers / slash commands
|
||||
* Fixed issues preventing proper extension startup
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
## 0.0.38 - 2024-03-15
|
||||
### Added
|
||||
* Remote config server support
|
||||
* Autocomplete support in JetBrains
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
## 0.0.42 - 2024-04-12
|
||||
### Added
|
||||
* Inline cmd/ctrl+I in JetBrains
|
||||
### Fixed
|
||||
* Fixed character encoding error causing display issues
|
||||
* Fixed error causing input to constantly demand focus
|
||||
* Fixed automatic reloading of config.json
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
## 0.0.53 - 2024-07-10
|
||||
### Added
|
||||
* Support for .prompt files
|
||||
* New onboarding experience
|
||||
### Fixed
|
||||
* Indexing fixes from VS Code versions merged into IntelliJ
|
||||
* Improved codebase indexing reliability and testing
|
||||
* Fixes for autocomplete text positioning and timing
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
## 0.0.54 - 2024-07-13
|
||||
### Added
|
||||
* Partial autocomplete acceptance
|
||||
* Autocomplete status bar spinner
|
||||
### Fixed
|
||||
* Fixed duplicate completion bug and others
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
## 0.0.69 - 2024-09-22
|
||||
### Added
|
||||
* Support for the "search" context provider
|
||||
### Fixed
|
||||
* Fixed bug where only first module would be recognized
|
||||
* Improved concurrency handling to avoid freezes
|
||||
* Made compatible with latest JetBrains versions
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
## 0.0.72 - 2024-10-04
|
||||
### Added
|
||||
* Listen for changes to Intellij settings without requiring window reload
|
||||
### Changed
|
||||
* Updated tutorial file
|
||||
### Fixed
|
||||
* Fix ability to load config.ts in JetBrains IDEs
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
## 0.0.92 - 2025-02-26
|
||||
### Fixed
|
||||
* Off-screen rendering to solve white flash on load and lack of changing cursor type
|
||||
* OSR-related fixes for non-Mac users
|
||||
* Fixes for inline edit in JetBrains
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
## 1.0.0 - 2025-02-26
|
||||
### Added
|
||||
* Introduces hub.continue.dev
|
||||
* Improved theme matching
|
||||
### Fixed
|
||||
* Fixes interference between SonarQube and Continue autocomplete
|
||||
* Numerous reliability improvements
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
## v0.0.1 - 2023-09-01
|
||||
|
||||
### Added
|
||||
|
||||
- Initial scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template)
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
## v0.0.19 - 2023-11-19
|
||||
|
||||
### Changed
|
||||
|
||||
- migrated to .json config file format
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
## v0.0.21 - 2023-12-05
|
||||
|
||||
### Added
|
||||
|
||||
- updated to match latest VS Code updates
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
## v0.0.25 - 2023-12-25
|
||||
|
||||
### Changed
|
||||
|
||||
- Intellij extension no longer relies on the Continue Python server
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
## v0.0.26 - 2023-12-28
|
||||
### Added
|
||||
* auto-reloading of config on save
|
||||
### Fixed
|
||||
* Fixed /edit bug for versions without Python server
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
## 0.8.14 - 2024-03-03
|
||||
### Added
|
||||
* Image support
|
||||
* Full-text search index for retrieval
|
||||
* Docs context provider
|
||||
* CodeLlama-70b support
|
||||
### Changed
|
||||
* config.ts only runs in NodeJS, not browser
|
||||
### Fixed
|
||||
* Fixed proxy setting in config.json
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
## 0.8.15 - 2024-03-05
|
||||
### Added
|
||||
* Tab-autocomplete in beta
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
## 0.8.24 - 2024-04-12
|
||||
### Added
|
||||
* Support for improved retrieval models (Voyage embeddings/reranking)
|
||||
* New @code context provider
|
||||
* Personal usage analytics
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
## 0.8.42 - 2024-07-02
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Gemini 1.5 Pro
|
||||
- Link to code in the sidebar when using codebase retrieval
|
||||
- Smoother onboarding experience
|
||||
- .prompt files, a way of saving and sharing slash commands
|
||||
- Support for Claude 3.5 Sonnet, Deepseek Coder v2, and other new models
|
||||
- Support for comments in config.json
|
||||
- Specify multiple autocomplete models and switch between them
|
||||
- Improved bracket matching strategy reduces noisy completions
|
||||
|
||||
### Fixed
|
||||
|
||||
- Numerous reliability upgrades to codebase indexing
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
## 0.8.43 - 2024-07-08
|
||||
### Added
|
||||
* Improved indexing reliability and testing
|
||||
* Quick Actions: use CodeLens to quickly take common actions like adding docstrings
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
## 0.8.45 - 2024-08-05
|
||||
### Added
|
||||
* Support for Llama 3.1 and gpt-4o-mini
|
||||
* Support for WatsonX+Granite models
|
||||
### Changed
|
||||
* Significant improvements to indexing performance
|
||||
* Improved @codebase quality by more accurately searching over file names and paths
|
||||
* Improved @codebase accuracy
|
||||
* Further improvements to indexing performance
|
||||
### Fixed
|
||||
* Improved docs indexing and management
|
||||
* Fixed Gemini embeddings provider
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
## 0.8.46 - 2024-08-11
|
||||
### Added
|
||||
* new /onboard slash command
|
||||
### Fixed
|
||||
* Fixed problem loading config.ts
|
||||
* Fixed bug causing duplicate indexing work
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
## 0.8.47 - 2024-08-27
|
||||
### Added
|
||||
* Use headless browser for crawling to get better results
|
||||
* TTS support in the chat window
|
||||
### Changed
|
||||
* Improved support for WatsonX models
|
||||
### Fixed
|
||||
* Fixed several small indexing bugs
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
## 0.8.48 - 2024-09-01
|
||||
### Added
|
||||
* Improved indexing progress UI
|
||||
* Improved @codebase using repomap
|
||||
* Repo map context provider
|
||||
### Fixed
|
||||
* Many small UI improvements
|
||||
* Fixes db.search not a function
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
## 0.8.49 - 2024-09-01
|
||||
### Fixed
|
||||
* Hotfix: submenu context providers
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
## 0.8.50 - 2024-09-02
|
||||
### Fixed
|
||||
* Hotfix for ability to use more than one inline context provider
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
## 0.8.51 - 2024-09-05
|
||||
### Fixed
|
||||
* Fixed CRLF bug causing diff streams to treat every line as changed on Windows
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
## 0.8.52 - 2024-09-16
|
||||
### Changed
|
||||
* Use Chromium only as a fallback after asking user
|
||||
* Redesigned onboarding flow
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
## 0.8.53 - 2024-10-11
|
||||
### Added
|
||||
* Improved loading/accept/reject UI for apply
|
||||
* Polished chat sidebar, especially context dropdown
|
||||
* Further prompt caching with Anthropic
|
||||
### Changed
|
||||
* Updated tutorial file
|
||||
* Improved styling on "More" page
|
||||
### Fixed
|
||||
* Continue for teams auth bug fix
|
||||
* Fixed a number of apply bugs
|
||||
* Fixed autoscrolling behavior
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
## 0.8.54 - 2024-10-15
|
||||
### Fixed
|
||||
* Hotfix: throttle transformers.js embeddings provider
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
## 0.8.55 - 2024-10-25
|
||||
### Added
|
||||
* Web context provider
|
||||
* Cerebras inference provider
|
||||
* Automatic descriptions for previous chats
|
||||
* Discord context provider
|
||||
* Improved full screen UI
|
||||
### Changed
|
||||
* Easier way to accept/reject/re-prompt after cmd/ctrl+I
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
## 0.8.56 - 2024-11-08
|
||||
### Added
|
||||
* New Edit mode in sidebar (cmd/ctrl+I)
|
||||
* Significantly faster and more accurate docs crawler by default
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
## 0.8.58 - 2024-11-22
|
||||
### Added
|
||||
* OpenAI predicted outputs support
|
||||
* Improve codebase retrieval with BM25
|
||||
* Support for Grok from xAI
|
||||
* Chat enhancements including sticking input to bottom
|
||||
* New UI for cmd+I in sidebar
|
||||
* Support for Nebius LLM provider
|
||||
* Support for Ask Sage LLM provider
|
||||
* Improved reference for config.json
|
||||
* New @web context provider
|
||||
* Updates for llama3.2
|
||||
* .continuerules file to set system prompt
|
||||
* .prompt files v2
|
||||
* Dedicated UI for docs indexing
|
||||
* Clickable code symbols in chat
|
||||
* Use clipboard content as autocomplete context
|
||||
### Changed
|
||||
* Improved @docs crawler
|
||||
* Many improvements to make autocomplete more eager
|
||||
* Near complete type definition retrieval for TypeScript autocomplete
|
||||
* Remove footer from chat sidebar
|
||||
### Fixed
|
||||
* Brought back the Apply button for all code blocks
|
||||
* Automatically update codebase index on removed files
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
## 0.8.59 - 2024-11-25
|
||||
### Fixed
|
||||
* Hotfix for Ollama onboarding
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
## 0.8.62 - 2024-12-10
|
||||
### Added
|
||||
* Tool use
|
||||
* Support for Model Context Protocol
|
||||
### Fixed
|
||||
* hotfix: context providers no longer hidden when not in edit mode
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
## 0.8.66 - 2024-12-20
|
||||
### Changed
|
||||
* Improved autocomplete in untitled files
|
||||
### Fixed
|
||||
* Display more mid-line completions
|
||||
* Restored syntax highlighting
|
||||
* Fix tool use bug for models that don't support tools
|
||||
* Autodetect mistral API key type
|
||||
* Fixes Azure OpenAI regressions
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
## 1.0.0 - 2025-02-26
|
||||
### Added
|
||||
* Introduces hub.continue.dev
|
||||
* Improved apply quality
|
||||
### Fixed
|
||||
* Numerous reliability improvements
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
## v0.5.0 - 2023-11-09
|
||||
|
||||
### Added
|
||||
|
||||
- Codebase Retrieval: Use /codebase or cmd+enter and Continue will automatically gather the most important context
|
||||
|
||||
### Changed
|
||||
|
||||
- Switch from Websockets to Socket.io
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
## v0.6.0 - 2023-11-10
|
||||
|
||||
### Added
|
||||
|
||||
- Full screen mode
|
||||
- StackOverflow slash command to augment with web search
|
||||
- VS Code context menus: right click to add code to context, debug the terminal, or share your Continue session
|
||||
|
||||
### Fixed
|
||||
|
||||
- Reliability improvements to JetBrains by bringing up-to-date with the socket.io refactor
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
## v0.6.16 - 2023-12-25
|
||||
|
||||
### Changed
|
||||
|
||||
- Context items are now kept around as a part of past messages, instead of staying at the main input
|
||||
- No more Python server - Continue runs entirely in Typescript
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
## v0.6.19 - 2024-01-05
|
||||
|
||||
### Added
|
||||
|
||||
- support for .continuerc.json in root of workspace to override config.json
|
||||
- Inline context providers
|
||||
- cmd+shift+L with new diff streaming UI for edits
|
||||
|
||||
### Changed
|
||||
|
||||
- Allow certain LLM servers to handle templating
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
## v0.6.4 - 2023-11-19
|
||||
|
||||
### Changed
|
||||
|
||||
- migrated to .json config file format
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
## v0.8.1 - 2024-01-08
|
||||
|
||||
### Added
|
||||
|
||||
- disableSessionTitles option in config.json
|
||||
|
||||
### Changed
|
||||
|
||||
- Use Ollama /chat endpoint instead of raw completions by default, and /show endpoint to gather model parameters like context length and stop tokens
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
## v0.8.2 - 2024-01-23
|
||||
### Added
|
||||
* Add codellama and gemini to free trial, using new server
|
||||
* Local codebase syncing and embeddings using LanceDB
|
||||
* Improved VS Code theme matching
|
||||
### Changed
|
||||
* Updates to packaging to download native modules for current platform (lancedb, sqlite, onnxruntime, tree-sitter wasms)
|
||||
* Context providers now run from the extension side (in Node.js instead of browser javascript)
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
||||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
changesDir: .changes
|
||||
unreleasedDir: unreleased
|
||||
headerPath: header.tpl.md
|
||||
changelogPath: CHANGELOG.md
|
||||
versionExt: md
|
||||
versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}'
|
||||
kindFormat: "### {{.Kind}}"
|
||||
changeFormat: "* {{.Body}}"
|
||||
kinds:
|
||||
- label: Added
|
||||
auto: minor
|
||||
- label: Changed
|
||||
auto: major
|
||||
- label: Deprecated
|
||||
auto: minor
|
||||
- label: Removed
|
||||
auto: major
|
||||
- label: Fixed
|
||||
auto: patch
|
||||
- label: Security
|
||||
auto: patch
|
||||
newlines:
|
||||
afterChangelogHeader: 1
|
||||
beforeChangelogVersion: 1
|
||||
endOfVersion: 1
|
||||
envPrefix: CHANGIE_
|
||||
|
||||
projects:
|
||||
- label: extensions/intellij
|
||||
key: extensions/intellij
|
||||
changelog: extensions/intellij/CHANGELOG.md
|
||||
|
||||
- label: extensions/vscode
|
||||
key: extensions/vscode
|
||||
changelog: extensions/vscode/CHANGELOG.md
|
||||
15
.continue/rules/intellij-plugin-test-execution.yaml
Normal file
15
.continue/rules/intellij-plugin-test-execution.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
name: IntelliJ Plugin Test Execution
|
||||
version: 0.0.1
|
||||
schema: v1
|
||||
rules:
|
||||
- name: IntelliJ Plugin Test Execution
|
||||
rule: |-
|
||||
Run IntelliJ plugin tests using Gradle with the fully qualified test class or method name:
|
||||
```bash
|
||||
# Run test class
|
||||
./gradlew test --tests "com.github.continuedev.continueintellijextension.unit.ApplyToFileHandlerTest"
|
||||
|
||||
# Run specific test method
|
||||
./gradlew test --tests "com.github.continuedev.continueintellijextension.unit.ApplyToFileHandlerTest.should*"
|
||||
```
|
||||
globs: extensions/intellij/**/*Test.kt
|
||||
10
.continue/rules/intellij-test-standards.yaml
Normal file
10
.continue/rules/intellij-test-standards.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
name: IntelliJ Test Standards
|
||||
version: 0.0.1
|
||||
schema: v1
|
||||
rules:
|
||||
- name: IntelliJ Test Standards
|
||||
rule: When writing tests for the IntelliJ plugin, use the mockk library for
|
||||
mocking. Prefer mockk's idiomatic syntax for creating and verifying mocks.
|
||||
Always structure tests with clear Arrange-Act-Assert patterns and use
|
||||
descriptive test names that indicate the scenario being tested.
|
||||
globs: "**/test/**/*.kt"
|
||||
30
.continue/rules/unit-testing-rules.yaml
Normal file
30
.continue/rules/unit-testing-rules.yaml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
name: unit-testing-rules
|
||||
version: 0.0.1
|
||||
schema: v1
|
||||
rules:
|
||||
- name: unit-testing-rules
|
||||
rule: >-
|
||||
For unit testing in this project:
|
||||
|
||||
|
||||
1. The project uses Jest as the testing framework
|
||||
|
||||
2. Run tests using `npm test` from within the specific package/module
|
||||
directory
|
||||
|
||||
3. Command structure: `cd [directory] && npm test -- [test file path]`
|
||||
|
||||
4. The test script uses experimental VM modules via NODE_OPTIONS flag
|
||||
|
||||
5. Test files follow the pattern `*.test.ts`
|
||||
|
||||
6. Tests must import Jest with `import { jest } from "@jest/globals";`
|
||||
|
||||
7. Run tests from within the specific package directory (e.g., `cd core`
|
||||
for core module tests)
|
||||
|
||||
8. Write tests as top-level `test()` functions - DO NOT use `describe()`
|
||||
blocks
|
||||
|
||||
9. Include the function name being tested in the test description for
|
||||
clarity
|
||||
4
.github/pull_request_template.md
vendored
4
.github/pull_request_template.md
vendored
|
|
@ -12,6 +12,6 @@
|
|||
|
||||
[ For visual changes, include screenshots. Screen recordings are particularly helpful, and appreciated! ]
|
||||
|
||||
## Testing instructions
|
||||
## Tests
|
||||
|
||||
[ For new or modified features, provide step-by-step testing instructions to validate the intended behavior of the change, including any relevant tests to run. ]
|
||||
[ What tests were added or updated to ensure the changes work as expected? ]
|
||||
|
|
|
|||
29
.github/workflows/cla.yaml
vendored
Normal file
29
.github/workflows/cla.yaml
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
name: "CLA Assistant"
|
||||
on:
|
||||
issue_comment:
|
||||
types: [ created ]
|
||||
pull_request_target:
|
||||
types: [ opened, closed, synchronize ]
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
|
||||
jobs:
|
||||
CLAAssistant:
|
||||
runs-on: ubuntu-latest
|
||||
# Only run this workflow on the main repository (continuedev/continue)
|
||||
if: github.repository == 'continuedev/continue'
|
||||
steps:
|
||||
- name: "CLA Assistant"
|
||||
if: (contains(github.event.comment.body, 'recheck') || contains(github.event.comment.body, 'I have read the CLA Document and I hereby sign the CLA')) || github.event_name == 'pull_request_target'
|
||||
uses: contributor-assistant/github-action@v2.6.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
path-to-signatures: "signatures/version1/cla.json"
|
||||
path-to-document: "https://github.com/continuedev/continue/blob/main/docs/docs/CLA.md"
|
||||
branch: cla-signatures
|
||||
allowlist: dependabot[bot]
|
||||
4
.github/workflows/jetbrains-release.yaml
vendored
4
.github/workflows/jetbrains-release.yaml
vendored
|
|
@ -63,7 +63,7 @@ jobs:
|
|||
|
||||
- name: Bump version in gradle.properties
|
||||
run: |
|
||||
cd extensions/intelllij
|
||||
cd extensions/intellij
|
||||
awk '/pluginVersion=/{split($0,a,"="); split(a[2],b,"."); b[3]+=1; printf "%s=%s.%s.%s\n",a[1],b[1],b[2],b[3];next}1' gradle.properties > tmp && mv tmp gradle.properties
|
||||
rm -rf tmp
|
||||
NEW_VERSION=$(grep 'pluginVersion=' gradle.properties | cut -d'=' -f2)
|
||||
|
|
@ -481,7 +481,7 @@ jobs:
|
|||
|
||||
# Run Qodana inspections
|
||||
- name: Qodana - Code Inspection
|
||||
uses: JetBrains/qodana-action@v2025.1.0
|
||||
uses: JetBrains/qodana-action@v2025.1.1
|
||||
with:
|
||||
cache-default-branch-only: true
|
||||
|
||||
|
|
|
|||
2
.github/workflows/main.yaml
vendored
2
.github/workflows/main.yaml
vendored
|
|
@ -235,7 +235,7 @@ jobs:
|
|||
- name: Publish to VS Code Marketplace
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
npx vsce publish --packagePath ../../vsix-artifacts/*.vsix
|
||||
npx @vscode/vsce publish --packagePath ../../vsix-artifacts/*.vsix
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
|
||||
|
||||
|
|
|
|||
17
.github/workflows/pr_checks.yaml
vendored
17
.github/workflows/pr_checks.yaml
vendored
|
|
@ -235,10 +235,11 @@ jobs:
|
|||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Type check
|
||||
- name: Type check and lint
|
||||
run: |
|
||||
cd gui
|
||||
npx tsc --noEmit
|
||||
npm run lint
|
||||
|
||||
binary-checks:
|
||||
needs: [install-root, install-core, install-config-yaml]
|
||||
|
|
@ -670,13 +671,6 @@ jobs:
|
|||
cd extensions/vscode
|
||||
rm -rf e2e/.test-extensions/continue*
|
||||
|
||||
- name: Upload e2e test screenshots
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-failure-screenshots
|
||||
path: extensions/vscode/e2e/storage/screenshots
|
||||
|
||||
- name: Sanitize test file name
|
||||
id: sanitize_filename
|
||||
if: always()
|
||||
|
|
@ -685,6 +679,13 @@ jobs:
|
|||
SANITIZED_FILENAME="${FILENAME//\//-}" # Replace / with - using bash parameter expansion
|
||||
echo "sanitized_test_file=${SANITIZED_FILENAME}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload e2e test screenshots
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-failure-screenshots-${{ steps.sanitize_filename.outputs.sanitized_test_file || 'unknown' }}-${{ matrix.command == 'e2e:ci:run-yaml' && 'yaml' || 'json' }}
|
||||
path: extensions/vscode/e2e/storage/screenshots
|
||||
|
||||
- name: Find e2e log file
|
||||
if: always()
|
||||
run: |
|
||||
|
|
|
|||
2
.github/workflows/preview.yaml
vendored
2
.github/workflows/preview.yaml
vendored
|
|
@ -232,7 +232,7 @@ jobs:
|
|||
- name: Publish to VS Code Marketplace
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
npx vsce publish --pre-release --packagePath ../../vsix-artifacts/*.vsix
|
||||
npx @vscode/vsce publish --pre-release --packagePath ../../vsix-artifacts/*.vsix
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
|
||||
|
||||
|
|
|
|||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -162,5 +162,8 @@ extensions/.continue-debug/
|
|||
|
||||
*.vsix
|
||||
|
||||
# intellij module library files
|
||||
*.iml
|
||||
|
||||
.continuerules
|
||||
**/.continue/assistants/
|
||||
6
.idea/jsLinters/eslint.xml
generated
Normal file
6
.idea/jsLinters/eslint.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EslintConfiguration">
|
||||
<option name="fix-on-save" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
1
.idea/prettier.xml
generated
1
.idea/prettier.xml
generated
|
|
@ -2,5 +2,6 @@
|
|||
<project version="4">
|
||||
<component name="PrettierConfiguration">
|
||||
<option name="myConfigurationMode" value="AUTOMATIC" />
|
||||
<option name="myRunOnSave" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
22
.idea/runConfigurations/config_yaml_tests.xml
generated
Normal file
22
.idea/runConfigurations/config_yaml_tests.xml
generated
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="config-yaml tests" type="JavaScriptTestRunnerJest">
|
||||
<config-file value="$PROJECT_DIR$/packages/config-yaml/jest.config.mjs" />
|
||||
<node-interpreter value="project" />
|
||||
<node-options value="--experimental-vm-modules" />
|
||||
<jest-package value="$PROJECT_DIR$/binary/node_modules/jest" />
|
||||
<working-dir value="$PROJECT_DIR$/packages/config-yaml" />
|
||||
<envs />
|
||||
<scope-kind value="ALL" />
|
||||
<method v="2">
|
||||
<option name="NpmBeforeRunTask" enabled="true">
|
||||
<package-json value="$PROJECT_DIR$/packages/config-yaml/package.json" />
|
||||
<command value="run" />
|
||||
<scripts>
|
||||
<script value="build" />
|
||||
</scripts>
|
||||
<node-interpreter value="project" />
|
||||
<envs />
|
||||
</option>
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
12
.idea/runConfigurations/core_tests.xml
generated
Normal file
12
.idea/runConfigurations/core_tests.xml
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="core tests" type="JavaScriptTestRunnerJest">
|
||||
<config-file value="$PROJECT_DIR$/core/jest.config.js" />
|
||||
<node-interpreter value="project" />
|
||||
<node-options value="--experimental-vm-modules" />
|
||||
<jest-package value="$PROJECT_DIR$/binary/node_modules/jest" />
|
||||
<working-dir value="$PROJECT_DIR$/core" />
|
||||
<envs />
|
||||
<scope-kind value="ALL" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
25
.idea/runConfigurations/openai_adapters_configuration.xml
generated
Normal file
25
.idea/runConfigurations/openai_adapters_configuration.xml
generated
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="openai-adapters configuration" type="JavaScriptTestRunnerJest">
|
||||
<node-interpreter value="project" />
|
||||
<node-options value="--experimental-vm-modules" />
|
||||
<jest-package value="$PROJECT_DIR$/binary/node_modules/jest" />
|
||||
<working-dir value="$PROJECT_DIR$/packages/openai-adapters" />
|
||||
<envs />
|
||||
<scope-kind value="SUITE" />
|
||||
<test-file value="$PROJECT_DIR$/packages/openai-adapters/src/test/main.test.ts" />
|
||||
<test-names>
|
||||
<test-name value="openai configuration" />
|
||||
</test-names>
|
||||
<method v="2">
|
||||
<option name="NpmBeforeRunTask" enabled="true">
|
||||
<package-json value="$PROJECT_DIR$/packages/openai-adapters/package.json" />
|
||||
<command value="run" />
|
||||
<scripts>
|
||||
<script value="build" />
|
||||
</scripts>
|
||||
<node-interpreter value="project" />
|
||||
<envs />
|
||||
</option>
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
|
|
@ -1,5 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CommitMessageInspectionProfile">
|
||||
<profile version="1.0">
|
||||
<inspection_tool class="CommitFormat" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="CommitNamingConvention" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
|
|
|
|||
11
.vscode/extensions.json
vendored
Normal file
11
.vscode/extensions.json
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"Continue.continue",
|
||||
"vivaxy.vscode-conventional-commits",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"YoavBls.pretty-ts-errors",
|
||||
"github.vscode-github-actions"
|
||||
]
|
||||
}
|
||||
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
|
|
@ -46,5 +46,10 @@
|
|||
// "sync/**": true
|
||||
},
|
||||
"eslint.workingDirectories": ["./core"],
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"conventionalCommits.showNewVersionNotes": false,
|
||||
"conventionalCommits.promptBody": false,
|
||||
"conventionalCommits.promptFooter": false,
|
||||
"conventionalCommits.promptScopes": true,
|
||||
"conventionalCommits.scopes": ["reg"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
# Changelog
|
||||
|
||||
Separate changelogs are kept for each extension:
|
||||
|
||||
- [VS Code Extension](./extensions/vscode/CHANGELOG.md)
|
||||
- [JetBrains Extension](./extensions/intellij/CHANGELOG.md)
|
||||
213
CONTRIBUTING.md
213
CONTRIBUTING.md
|
|
@ -3,44 +3,49 @@
|
|||
## Table of Contents
|
||||
|
||||
- [Contributing to Continue](#contributing-to-continue)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [❤️ Ways to Contribute](#️-ways-to-contribute)
|
||||
- [👋 Continue Contribution Ideas](#-continue-contribution-ideas)
|
||||
- [🐛 Report Bugs](#-report-bugs)
|
||||
- [✨ Suggest Enhancements](#-suggest-enhancements)
|
||||
- [📖 Updating / Improving Documentation](#-updating--improving-documentation)
|
||||
- [Running the Documentation Server Locally](#running-the-documentation-server-locally)
|
||||
- [Method 1: NPM Script](#method-1-npm-script)
|
||||
- [Method 2: VS Code Task](#method-2-vs-code-task)
|
||||
- [🧑💻 Contributing Code](#-contributing-code)
|
||||
- [Environment Setup](#environment-setup)
|
||||
- [Pre-requisites](#pre-requisites)
|
||||
- [Fork the Continue Repository](#fork-the-continue-repository)
|
||||
- [VS Code](#vs-code)
|
||||
- [Debugging](#debugging)
|
||||
- [JetBrains](#jetbrains)
|
||||
- [Our Git Workflow](#our-git-workflow)
|
||||
- [Development workflow](#development-workflow)
|
||||
- [Formatting](#formatting)
|
||||
- [Testing](#testing)
|
||||
- [Review Process](#review-process)
|
||||
- [Getting help](#getting-help)
|
||||
- [Contribtuing new LLM Providers/Models](#contribtuing-new-llm-providersmodels)
|
||||
- [Adding an LLM Provider](#adding-an-llm-provider)
|
||||
- [Adding Models](#adding-models)
|
||||
- [📐 Continue Architecture](#-continue-architecture)
|
||||
- [Continue VS Code Extension](#continue-vs-code-extension)
|
||||
- [Continue JetBrains Extension](#continue-jetbrains-extension)
|
||||
- [👋 Continue Contribution Ideas](#-continue-contribution-ideas)
|
||||
- [🐛 Report Bugs](#-report-bugs)
|
||||
- [✨ Suggest Enhancements](#-suggest-enhancements)
|
||||
- [📖 Updating / Improving Documentation](#-updating--improving-documentation)
|
||||
- [Running the Documentation Server Locally](#running-the-documentation-server-locally)
|
||||
- [Method 1: NPM Script](#method-1-npm-script)
|
||||
- [Method 2: VS Code Task](#method-2-vs-code-task)
|
||||
- [🧑💻 Contributing Code](#-contributing-code)
|
||||
- [Environment Setup](#environment-setup)
|
||||
- [Pre-requisites](#pre-requisites)
|
||||
- [Fork the Continue Repository](#fork-the-continue-repository)
|
||||
- [VS Code](#vs-code)
|
||||
- [Debugging](#debugging)
|
||||
- [JetBrains](#jetbrains)
|
||||
- [Our Git Workflow](#our-git-workflow)
|
||||
- [Development workflow](#development-workflow)
|
||||
- [Formatting](#formatting)
|
||||
- [Testing](#testing)
|
||||
- [Review Process](#review-process)
|
||||
- [Getting help](#getting-help)
|
||||
- [Contribtuing new LLM Providers/Models](#contribtuing-new-llm-providersmodels)
|
||||
- [Adding an LLM Provider](#adding-an-llm-provider)
|
||||
- [Adding Models](#adding-models)
|
||||
- [📐 Continue Architecture](#-continue-architecture)
|
||||
- [Continue VS Code Extension](#continue-vs-code-extension)
|
||||
- [Continue JetBrains Extension](#continue-jetbrains-extension)
|
||||
- [Contibutor License Agreement](#contributor-license-agreement-cla)
|
||||
|
||||
# ❤️ Ways to Contribute
|
||||
|
||||
## 👋 Continue Contribution Ideas
|
||||
|
||||
[This GitHub project board](https://github.com/orgs/continuedev/projects/2) is a list of ideas for how you can contribute to Continue. These aren't the only ways, but are a great starting point if you are new to the project.
|
||||
[This GitHub project board](https://github.com/orgs/continuedev/projects/2) is a list of ideas for how you can
|
||||
contribute to Continue. These aren't the only ways, but are a great starting point if you are new to the project. You
|
||||
can also browse the list
|
||||
of [good first issues](https://github.com/continuedev/continue/issues?q=is:issue%20state:open%20label:good-first-issue).
|
||||
|
||||
## 🐛 Report Bugs
|
||||
|
||||
If you find a bug, please [create an issue](https://github.com/continuedev/continue/issues) to report it! A great bug report includes:
|
||||
If you find a bug, please [create an issue](https://github.com/continuedev/continue/issues) to report it! A great bug
|
||||
report includes:
|
||||
|
||||
- A description of the bug
|
||||
- Steps to reproduce
|
||||
|
|
@ -50,19 +55,22 @@ If you find a bug, please [create an issue](https://github.com/continuedev/conti
|
|||
|
||||
## ✨ Suggest Enhancements
|
||||
|
||||
Continue is quickly adding features, and we'd love to hear which are the most important to you. The best ways to suggest an enhancement are:
|
||||
Continue is quickly adding features, and we'd love to hear which are the most important to you. The best ways to suggest
|
||||
an enhancement are:
|
||||
|
||||
- Create an issue
|
||||
|
||||
- First, check whether a similar proposal has already been made
|
||||
- If not, [create an issue](https://github.com/continuedev/continue/issues)
|
||||
- Please describe the enhancement in as much detail as you can, and why it would be useful
|
||||
- First, check whether a similar proposal has already been made
|
||||
- If not, [create an issue](https://github.com/continuedev/continue/issues)
|
||||
- Please describe the enhancement in as much detail as you can, and why it would be useful
|
||||
|
||||
- Join the [Continue Discord](https://discord.gg/NWtdYexhMs) and tell us about your idea in the `#feedback` channel
|
||||
|
||||
## 📖 Updating / Improving Documentation
|
||||
|
||||
Continue is continuously improving, but a feature isn't complete until it is reflected in the documentation! If you see something out-of-date or missing, you can help by clicking "Edit this page" at the bottom of any page on [docs.continue.dev](https://docs.continue.dev).
|
||||
Continue is continuously improving, but a feature isn't complete until it is reflected in the documentation! If you see
|
||||
something out-of-date or missing, you can help by clicking "Edit this page" at the bottom of any page
|
||||
on [docs.continue.dev](https://docs.continue.dev).
|
||||
|
||||
### Running the Documentation Server Locally
|
||||
|
||||
|
|
@ -70,7 +78,8 @@ You can run the documentation server locally using either of the following metho
|
|||
|
||||
#### Method 1: NPM Script
|
||||
|
||||
1. Open your terminal and navigate to the `docs` subdirectory of the project. The `docusaurus.config.js` file you'll see there is a sign you're in the right place.
|
||||
1. Open your terminal and navigate to the `docs` subdirectory of the project. The `docusaurus.config.js` file you'll see
|
||||
there is a sign you're in the right place.
|
||||
|
||||
2. Run the following command to install the necessary dependencies for the documentation server:
|
||||
|
||||
|
|
@ -92,17 +101,22 @@ You can run the documentation server locally using either of the following metho
|
|||
|
||||
3. Look for the `docs:start` task and select it.
|
||||
|
||||
This will start a local server and you can see the documentation rendered in your default browser, typically accessible at `http://localhost:3000`.
|
||||
This will start a local server and you can see the documentation rendered in your default browser, typically accessible
|
||||
at `http://localhost:3000`.
|
||||
|
||||
## 🧑💻 Contributing Code
|
||||
|
||||
We welcome contributions from developers of all experience levels - from first-time contributors to seasoned open source maintainers. While we aim to maintain high standards for reliability and maintainability, our goal is to keep the process as welcoming and straightforward as possible.
|
||||
We welcome contributions from developers of all experience levels - from first-time contributors to seasoned open source
|
||||
maintainers. While we aim to maintain high standards for reliability and maintainability, our goal is to keep the
|
||||
process as welcoming and straightforward as possible.
|
||||
|
||||
### Environment Setup
|
||||
|
||||
#### Pre-requisites
|
||||
|
||||
You should have Node.js version 20.19.0 (LTS) or higher installed. You can get it on [nodejs.org](https://nodejs.org/en/download) or, if you are using NVM (Node Version Manager), you can set the correct version of Node.js for this project by running the following command in the root of the project:
|
||||
You should have Node.js version 20.19.0 (LTS) or higher installed. You can get it
|
||||
on [nodejs.org](https://nodejs.org/en/download) or, if you are using NVM (Node Version Manager), you can set the correct
|
||||
version of Node.js for this project by running the following command in the root of the project:
|
||||
|
||||
```bash
|
||||
nvm use
|
||||
|
|
@ -114,32 +128,39 @@ nvm use
|
|||
|
||||
2. Clone your forked repository to your local machine. Use: `git clone https://github.com/YOUR_USERNAME/continue.git`
|
||||
|
||||
3. Navigate to the cloned directory and make sure you are on the main branch. Create your feature/fix branch from there, like so: `git checkout -b 123-my-feature-branch`
|
||||
3. Navigate to the cloned directory and make sure you are on the main branch. Create your feature/fix branch from there,
|
||||
like so: `git checkout -b 123-my-feature-branch`
|
||||
|
||||
4. Send your pull request to the main branch.
|
||||
|
||||
#### VS Code
|
||||
|
||||
1. Open the VS Code command pallet (`cmd/ctrl+shift+p`) and select `Tasks: Run Task` and then select `install-all-dependencies`
|
||||
1. Open the VS Code command pallet (`cmd/ctrl+shift+p`) and select `Tasks: Run Task` and then select
|
||||
`install-all-dependencies`
|
||||
|
||||
2. Start debugging:
|
||||
|
||||
1. Switch to Run and Debug view
|
||||
2. Select `Launch extension` from drop down
|
||||
3. Hit play button
|
||||
4. This will start the extension in debug mode and open a new VS Code window with it installed
|
||||
1. The new VS Code window with the extension is referred to as the _Host VS Code_
|
||||
2. The window you started debugging from is referred to as the _Main VS Code_
|
||||
1. Switch to Run and Debug view
|
||||
2. Select `Launch extension` from drop down
|
||||
3. Hit play button
|
||||
4. This will start the extension in debug mode and open a new VS Code window with it installed
|
||||
1. The new VS Code window with the extension is referred to as the _Host VS Code_
|
||||
2. The window you started debugging from is referred to as the _Main VS Code_
|
||||
|
||||
3. To package the extension, run `npm run package` in the `extensions/vscode` directory, select `Tasks: Run Task` and then select `vscode-extension:package`. This will generate `extensions/vscode/build/continue-{VERSION}.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX".
|
||||
3. To package the extension, run `npm run package` in the `extensions/vscode` directory, select `Tasks: Run Task` and
|
||||
then select `vscode-extension:package`. This will generate `extensions/vscode/build/continue-{VERSION}.vsix`, which
|
||||
you can install by right-clicking and selecting "Install Extension VSIX".
|
||||
|
||||
##### Debugging
|
||||
|
||||
**Breakpoints** can be used in both the `core` and `extensions/vscode` folders while debugging, but are not currently supported inside of `gui` code.
|
||||
**Breakpoints** can be used in both the `core` and `extensions/vscode` folders while debugging, but are not currently
|
||||
supported inside of `gui` code.
|
||||
|
||||
**Hot-reloading** is enabled with Vite, so if you make any changes to the `gui`, they should be automatically reflected without rebuilding. In some cases, you may need to refresh the _Host VS Code_ window to see the changes.
|
||||
**Hot-reloading** is enabled with Vite, so if you make any changes to the `gui`, they should be automatically reflected
|
||||
without rebuilding. In some cases, you may need to refresh the _Host VS Code_ window to see the changes.
|
||||
|
||||
Similarly, any changes to `core` or `extensions/vscode` will be automatically included by just reloading the _Host VS Code_ window with cmd/ctrl+shift+p "Reload Window".
|
||||
Similarly, any changes to `core` or `extensions/vscode` will be automatically included by just reloading the _Host VS
|
||||
Code_ window with cmd/ctrl+shift+p "Reload Window".
|
||||
|
||||
#### JetBrains
|
||||
|
||||
|
|
@ -147,11 +168,20 @@ See [`intellij/CONTRIBUTING.md`](./extensions/intellij/CONTRIBUTING.md) for the
|
|||
|
||||
### Our Git Workflow
|
||||
|
||||
We keep a single permanent branch: `main`. When we are ready to create a "pre-release" version, we create a tag on the `main` branch titled `v0.9.x-vscode`, which automatically triggers the workflow in [preview.yaml](./.github/workflows/preview.yaml), which builds and releases a version of the VS Code extension. When a release has been sufficiently tested, we will create a new release titled `v0.8.x-vscode`, triggering a similar workflow in [main.yaml](./.github/workflows/main.yaml), which will build and release a main release of the VS Code extension. Any hotfixes can be made by creating a feature branch from the tag for the release in question. This workflow is well explained by <http://releaseflow.org>.
|
||||
We keep a single permanent branch: `main`. When we are ready to create a "pre-release" version, we create a tag on the
|
||||
`main` branch titled `v1.1.x-vscode`, which automatically triggers the workflow
|
||||
in [preview.yaml](./.github/workflows/preview.yaml), which builds and releases a version of the VS Code extension. When
|
||||
a release has been sufficiently tested, we will create a new release titled `v1.0x-vscode`, triggering a similar
|
||||
workflow in [main.yaml](./.github/workflows/main.yaml), which will build and release a main release of the VS Code
|
||||
extension. Any hotfixes can be made by creating a feature branch from the tag for the release in question. This workflow
|
||||
is well explained by <http://releaseflow.org>.
|
||||
|
||||
### Development workflow
|
||||
### What makes a good PR?
|
||||
|
||||
- Open a new issue or comment on an existing one before writing code. This ensures your proposed changes are aligned with the project direction.
|
||||
To keep the Continue codebase clean and maintainable, we expect the following from our own team and all contributors:
|
||||
|
||||
- Open a new issue or comment on an existing one before writing code. This ensures your proposed changes are aligned
|
||||
with the project direction
|
||||
- Keep changes focused. Multiple unrelated fixes should be opened as separate PRs
|
||||
- Write or update tests for new functionality
|
||||
- Update relevant documentation in the `docs` folder
|
||||
|
|
@ -159,18 +189,22 @@ We keep a single permanent branch: `main`. When we are ready to create a "pre-re
|
|||
|
||||
### Formatting
|
||||
|
||||
Continue uses [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) to format JavaScript/TypeScript. Please install the Prettier extension in VS Code and enable "Format on Save" in your settings.
|
||||
Continue uses [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) to format
|
||||
JavaScript/TypeScript. Please install the Prettier extension in VS Code and enable "Format on Save" in your settings.
|
||||
|
||||
### Testing
|
||||
|
||||
We have a mix of unit, functional, and e2e test suites, with a primary focus on functional testing. These tests run on each pull request. If your PR causes one of these tests to fail, we will ask that you to resolve the issue before we merge.
|
||||
We have a mix of unit, functional, and e2e test suites, with a primary focus on functional testing. These tests run on
|
||||
each pull request. If your PR causes one of these tests to fail, we will ask that you to resolve the issue before we
|
||||
merge.
|
||||
|
||||
When contributing, please update or create the appropriate tests to help verify the correctness of your implementaiton.
|
||||
|
||||
### Review Process
|
||||
|
||||
- **Initial Review** - A maintainer will be assigned as primary reviewer
|
||||
- **Feedback Loop** - The reviewer may request changes. We value your work, but also want to ensure the code is maintainable and follows our patterns.
|
||||
- **Feedback Loop** - The reviewer may request changes. We value your work, but also want to ensure the code is
|
||||
maintainable and follows our patterns.
|
||||
- **Approval & Merge** - Once the PR is approved, it will be merged into the `main` branch.
|
||||
|
||||
### Getting help
|
||||
|
|
@ -181,42 +215,53 @@ Join [#contribute on Discord](https://discord.gg/vapESyrFmJ) to engage with main
|
|||
|
||||
### Adding an LLM Provider
|
||||
|
||||
Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps:
|
||||
|
||||
1. Create a new file in the `core/llm/llms` directory. The name of the file should be the name of the provider, and it should export a class that extends `BaseLLM`. This class should contain the following minimal implementation. We recommend viewing pre-existing providers for more details. The [LlamaCpp Provider](./core/llm/llms/LlamaCpp.ts) is a good simple example.
|
||||
|
||||
- `providerName` - the identifier for your provider.
|
||||
- At least one of `_streamComplete` or `_streamChat` - This is the function that makes the request to the API and returns the streamed response. You only need to implement one because Continue can automatically convert between "chat" and "raw completion".
|
||||
Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI,
|
||||
Ollama, Together, LM Studio, Msty, and more. You can find all of the existing
|
||||
providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can
|
||||
add it with the following steps:
|
||||
|
||||
1. Create a new file in the `core/llm/llms` directory. The name of the file should be the name of the provider, and it
|
||||
should export a class that extends `BaseLLM`. This class should contain the following minimal implementation. We
|
||||
recommend viewing pre-existing providers for more details. The [LlamaCpp Provider](./core/llm/llms/LlamaCpp.ts) is a
|
||||
good simple example.
|
||||
2. Add your provider to the `LLMs` array in [core/llm/llms/index.ts](./core/llm/llms/index.ts).
|
||||
3. If your provider supports images, add it to the `PROVIDER_SUPPORTS_IMAGES` array in [core/llm/autodetect.ts](./core/llm/autodetect.ts).
|
||||
4. Add the necessary JSON Schema types to [`config_schema.json`](./extensions/vscode/config_schema.json). This makes sure that Intellisense shows users what options are available for your provider when they are editing `config.json`.
|
||||
5. Add a documentation page for your provider in [`docs/docs/customize/model-providers`](./docs/docs/customize/model-providers). This should show an example of configuring your provider in `config.json` and explain what options are available.
|
||||
3. If your provider supports images, add it to the `PROVIDER_SUPPORTS_IMAGES` array
|
||||
in [core/llm/autodetect.ts](./core/llm/autodetect.ts).
|
||||
4. Add a documentation page for your provider in [
|
||||
`docs/docs/customize/model-providers/more`](./docs/docs/customize/model-providers/more). This should show an example
|
||||
of configuring your provider in `config.yaml` and explain what options are available.
|
||||
|
||||
### Adding Models
|
||||
|
||||
While any model that works with a supported provider can be used with Continue, we keep a list of recommended models that can be automatically configured from the UI or `config.json`. The following files should be updated when adding a model:
|
||||
While any model that works with a supported provider can be used with Continue, we keep a list of recommended models
|
||||
that can be automatically configured from the UI or `config.json`. The following files should be updated when adding a
|
||||
model:
|
||||
|
||||
- [config_schema.json](./extensions/vscode/config_schema.json) - This is the JSON Schema definition that is used to validate `config.json`. You'll notice a number of rules defined in "definitions.ModelDescription.allOf". Here is where you write rules that can specify something like "for the provider 'anthropic', only models 'claude-2' and 'claude-instant-1' are allowed. Look through all of these rules and make sure that your model is included for providers that support it.
|
||||
- [AddNewModel page](./gui/src/pages/AddNewModel) - This directory defines which model options are shown in the side bar model selection UI. To add a new model:
|
||||
1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts), following the lead of the many examples near the top of the file
|
||||
2. Add the model within its provider's array to [AddNewModel.tsx](./gui/src/pages/AddNewModel/AddNewModel.tsx) (add provider if needed)
|
||||
- [index.d.ts](./core/index.d.ts) - This file defines the TypeScript types used throughout Continue. You'll find a `ModelName` type. Be sure to add the name of your model to this.
|
||||
- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models).
|
||||
- [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates.
|
||||
- [AddNewModel page](./gui/src/pages/AddNewModel/configs/) - This directory defines which model options are shown in the
|
||||
side bar model selection UI. To add a new model:
|
||||
1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts),
|
||||
following the lead of the many examples near the top of the file
|
||||
2. Add the model within its provider's array
|
||||
to [configs/providers.ts](./gui/src/pages/AddNewModel/configs/providers.ts) (add provider if needed)
|
||||
- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the
|
||||
translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these
|
||||
providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts),
|
||||
and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists
|
||||
here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models).
|
||||
- [Prompt Templates](./core/llm/autodetect.ts) - In this file you'll find the `autodetectTemplateType` function. Make
|
||||
sure that for the model name you just added, this function returns the correct template type. This is assuming that
|
||||
the chat template for that model is already built in Continue. If not, you will have to add the template type and
|
||||
corresponding edit and chat templates.
|
||||
|
||||
## 📐 Continue Architecture
|
||||
## Contributor License Agreement (CLA)
|
||||
|
||||
Continue consists of 2 parts that are split so that it can be extended to work in other IDEs as easily as possible:
|
||||
We require all contributors to accept the CLA and have made it as easy as commenting on your PR:
|
||||
|
||||
1. **Continue GUI** - The Continue GUI is a React application that gives the user control over Continue. It displays the current chat history, allows the user to ask questions, invoke slash commands, and use context providers. The GUI also handles most state and holds as much of the logic as possible so that it can be reused between IDEs.
|
||||
1. Open your pull request.
|
||||
2. Paste the following comment (or reply `recheck` if you’ve signed before):
|
||||
|
||||
2. **Continue Extension** - The Continue Extension is a plugin for the IDE which implements the [IDE Interface](./core/index.d.ts#L229). This allows the GUI to request information from or actions to be taken within the IDE. This same interface is used regardless of IDE. The first Continue extensions we have built are for VS Code and JetBrains, but we plan to build clients for other IDEs in the future. The IDE Client must 1. implement IDE Interface, as is done [here](./extensions/vscode/src/VsCodeIde.ts) for VS Code and 2. display the Continue GUI in a sidebar, like [here](./extensions/vscode/src/ContinueGUIWebviewViewProvider.ts).
|
||||
```text
|
||||
I have read the CLA Document and I hereby sign the CLA
|
||||
```
|
||||
|
||||
### Continue VS Code Extension
|
||||
|
||||
The starting point for the VS Code extension is [activate.ts](./extensions/vscode/src/activation/activate.ts). The `activateExtension` function here will register all commands and load the Continue GUI in the sidebar of the IDE as a webview.
|
||||
|
||||
### Continue JetBrains Extension
|
||||
|
||||
The JetBrains extension is currently in alpha testing. Please reach out on [Discord](https://discord.gg/vapESyrFmJ) if you are interested in contributing to its development.
|
||||
3. The CLA‑Assistant bot records your signature in the repo and marks the status check as passed.
|
||||
28
README.md
28
README.md
|
|
@ -8,7 +8,10 @@
|
|||
|
||||
<div align="center">
|
||||
|
||||
**[Continue](https://docs.continue.dev) enables developers to create, share, and use custom AI code assistants with our open-source [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension) extensions and [hub of models, rules, prompts, docs, and other building blocks](https://hub.continue.dev)**
|
||||
**[Continue](https://docs.continue.dev) enables developers to create, share, and use custom AI code assistants with our
|
||||
open-source [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue)
|
||||
and [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension) extensions
|
||||
and [hub of models, rules, prompts, docs, and other building blocks](https://hub.continue.dev)**
|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -20,15 +23,25 @@
|
|||
<a target="_blank" href="https://docs.continue.dev" style="background:none">
|
||||
<img src="https://img.shields.io/badge/continue_docs-%23BE1B55" style="height: 22px;" />
|
||||
</a>
|
||||
<a target="_blank" href="https://changelog.continue.dev" style="background:none">
|
||||
<img src="https://img.shields.io/badge/changelog-%96EFF3" style="height: 22px;" />
|
||||
</a>
|
||||
<a target="_blank" href="https://discord.gg/vapESyrFmJ" style="background:none">
|
||||
<img src="https://img.shields.io/badge/discord-join-continue.svg?labelColor=191937&color=6F6FF7&logo=discord" style="height: 22px;" />
|
||||
</a>
|
||||
|
||||
<p></p>
|
||||
|
||||
## Agent
|
||||
|
||||
[Agent](https://continue.dev/docs/agent/how-to-use-it) enables you to make more substantial changes to your codebase
|
||||
|
||||

|
||||
|
||||
## Chat
|
||||
|
||||
[Chat](https://continue.dev/docs/chat/how-to-use-it) makes it easy to ask for help from an LLM without needing to leave the IDE
|
||||
[Chat](https://continue.dev/docs/chat/how-to-use-it) makes it easy to ask for help from an LLM without needing to leave
|
||||
the IDE
|
||||
|
||||

|
||||
|
||||
|
|
@ -40,15 +53,11 @@
|
|||
|
||||
## Edit
|
||||
|
||||
[Edit](https://continue.dev/docs/edit/how-to-use-it) is a convenient way to modify code without leaving your current file
|
||||
[Edit](https://continue.dev/docs/edit/how-to-use-it) is a convenient way to modify code without leaving your current
|
||||
file
|
||||
|
||||

|
||||
|
||||
## Agent
|
||||
|
||||
[Agent](https://continue.dev/docs/agent/how-to-use-it) enables you to make more substantial changes to your codebase
|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -58,7 +67,8 @@ Learn about how to install and use Continue in the docs [here](https://continue.
|
|||
|
||||
## Contributing
|
||||
|
||||
Read the [contributing guide](https://github.com/continuedev/continue/blob/main/CONTRIBUTING.md), and join [#contribute on Discord](https://discord.gg/vapESyrFmJ).
|
||||
Read the [contributing guide](https://github.com/continuedev/continue/blob/main/CONTRIBUTING.md), and
|
||||
join [#contribute on Discord](https://discord.gg/vapESyrFmJ).
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,15 @@ const {
|
|||
execCmdSync,
|
||||
autodetectPlatformAndArch,
|
||||
} = require("../scripts/util");
|
||||
const { downloadRipgrep } = require("./utils/ripgrep");
|
||||
const { ALL_TARGETS, TARGET_TO_LANCEDB } = require("./utils/targets");
|
||||
|
||||
const bin = path.join(__dirname, "bin");
|
||||
const out = path.join(__dirname, "out");
|
||||
const build = path.join(__dirname, "build");
|
||||
|
||||
function cleanSlate() {
|
||||
// Clean slate
|
||||
// Clean slate
|
||||
rimrafSync(bin);
|
||||
rimrafSync(out);
|
||||
rimrafSync(build);
|
||||
|
|
@ -25,13 +27,7 @@ function cleanSlate() {
|
|||
}
|
||||
|
||||
const esbuildOutputFile = "out/index.js";
|
||||
let targets = [
|
||||
"darwin-x64",
|
||||
"darwin-arm64",
|
||||
"linux-x64",
|
||||
"linux-arm64",
|
||||
"win32-x64",
|
||||
];
|
||||
let targets = [...ALL_TARGETS];
|
||||
|
||||
const [currentPlatform, currentArch] = autodetectPlatformAndArch();
|
||||
|
||||
|
|
@ -50,15 +46,6 @@ for (let i = 2; i < process.argv.length; i++) {
|
|||
}
|
||||
}
|
||||
|
||||
const targetToLanceDb = {
|
||||
"darwin-arm64": "@lancedb/vectordb-darwin-arm64",
|
||||
"darwin-x64": "@lancedb/vectordb-darwin-x64",
|
||||
"linux-arm64": "@lancedb/vectordb-linux-arm64-gnu",
|
||||
"linux-x64": "@lancedb/vectordb-linux-x64-gnu",
|
||||
"win32-x64": "@lancedb/vectordb-win32-x64-msvc",
|
||||
"win32-arm64": "@lancedb/vectordb-win32-arm64-msvc",
|
||||
};
|
||||
|
||||
// Bundles the extension into one file
|
||||
async function buildWithEsbuild() {
|
||||
console.log("[info] Building with esbuild...");
|
||||
|
|
@ -77,7 +64,7 @@ async function buildWithEsbuild() {
|
|||
format: "cjs",
|
||||
platform: "node",
|
||||
sourcemap: true,
|
||||
minify: true,
|
||||
minify: !esbuildOnly,
|
||||
treeShaking: true,
|
||||
loader: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
|
|
@ -89,7 +76,6 @@ async function buildWithEsbuild() {
|
|||
inject: ["./importMetaUrl.js"],
|
||||
define: { "import.meta.url": "importMetaUrl" },
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
||||
|
|
@ -153,13 +139,31 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and installs ripgrep binaries for the specified target
|
||||
*
|
||||
* @param {string} target - Target platform-arch (e.g., 'darwin-x64')
|
||||
* @param {string} targetDir - Directory to install ripgrep to
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function downloadRipgrepForTarget(target, targetDir) {
|
||||
console.log(`[info] Downloading ripgrep for ${target}...`);
|
||||
try {
|
||||
await downloadRipgrep(target, targetDir);
|
||||
console.log(`[info] Successfully installed ripgrep for ${target}`);
|
||||
} catch (error) {
|
||||
console.error(`[error] Failed to download ripgrep for ${target}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
if (esbuildOnly) {
|
||||
await buildWithEsbuild();
|
||||
return;
|
||||
}
|
||||
|
||||
cleanSlate()
|
||||
cleanSlate();
|
||||
|
||||
// Informs of where to look for node_sqlite3.node https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found
|
||||
// This is only needed for our `pkg` command at build time
|
||||
|
|
@ -179,10 +183,10 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
|
||||
console.log("[info] Downloading prebuilt lancedb...");
|
||||
for (const target of targets) {
|
||||
if (targetToLanceDb[target]) {
|
||||
if (TARGET_TO_LANCEDB[target]) {
|
||||
console.log(`[info] Downloading for ${target}...`);
|
||||
await installNodeModuleInTempDirAndCopyToCurrent(
|
||||
targetToLanceDb[target],
|
||||
TARGET_TO_LANCEDB[target],
|
||||
"@lancedb",
|
||||
);
|
||||
}
|
||||
|
|
@ -290,10 +294,13 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
// copy @lancedb to bin folders
|
||||
console.log("[info] Copying @lancedb files to bin");
|
||||
fs.copyFileSync(
|
||||
`node_modules/${targetToLanceDb[target]}/index.node`,
|
||||
`node_modules/${TARGET_TO_LANCEDB[target]}/index.node`,
|
||||
`${targetDir}/index.node`,
|
||||
);
|
||||
|
||||
// Download and install ripgrep for the target
|
||||
await downloadRipgrepForTarget(target, targetDir);
|
||||
|
||||
// Informs the `continue-binary` of where to look for node_sqlite3.node
|
||||
// https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found
|
||||
fs.writeFileSync(`${targetDir}/package.json`, "");
|
||||
|
|
@ -310,6 +317,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
`${targetDir}/continue-binary${exe}`,
|
||||
`${targetDir}/index.node`, // @lancedb
|
||||
`${targetDir}/build/Release/node_sqlite3.node`,
|
||||
`${targetDir}/rg${exe}`, // ripgrep binary
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
117
binary/package-lock.json
generated
117
binary/package-lock.json
generated
|
|
@ -10,6 +10,7 @@
|
|||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"adm-zip": "^0.5.16",
|
||||
"commander": "^12.0.0",
|
||||
"core": "file:../core",
|
||||
"follow-redirects": "^1.15.5",
|
||||
|
|
@ -18,6 +19,7 @@
|
|||
"node-fetch": "^3.3.2",
|
||||
"posthog-node": "^3.6.3",
|
||||
"system-ca": "^1.0.2",
|
||||
"tar": "^7.4.3",
|
||||
"uuid": "^9.0.1",
|
||||
"vectordb": "^0.4.20",
|
||||
"win-ca": "^3.5.1"
|
||||
|
|
@ -31,6 +33,7 @@
|
|||
"@types/jest": "^29.5.12",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild": "0.19.11",
|
||||
"jest": "^29.7.0",
|
||||
"pkg": "^5.8.1",
|
||||
|
|
@ -49,7 +52,7 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/fetch": "^1.0.6",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.19",
|
||||
"@modelcontextprotocol/sdk": "^1.5.0",
|
||||
|
|
@ -74,6 +77,7 @@
|
|||
"http-proxy-agent": "^7.0.1",
|
||||
"https-proxy-agent": "^7.0.3",
|
||||
"ignore": "^5.3.1",
|
||||
"is-localhost-ip": "^2.0.0",
|
||||
"jinja-js": "0.1.8",
|
||||
"js-tiktoken": "^1.0.8",
|
||||
"jsdom": "^24.0.0",
|
||||
|
|
@ -1525,6 +1529,18 @@
|
|||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@isaacs/fs-minipass": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz",
|
||||
"integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"minipass": "^7.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
|
|
@ -2433,6 +2449,15 @@
|
|||
"ncc": "dist/ncc/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/adm-zip": {
|
||||
"version": "0.5.16",
|
||||
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.16.tgz",
|
||||
"integrity": "sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||
|
|
@ -3172,6 +3197,25 @@
|
|||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-env": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
|
||||
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cross-spawn": "^7.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"cross-env": "src/bin/cross-env.js",
|
||||
"cross-env-shell": "src/bin/cross-env-shell.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.14",
|
||||
"npm": ">=6",
|
||||
"yarn": ">=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
|
|
@ -5221,14 +5265,41 @@
|
|||
}
|
||||
},
|
||||
"node_modules/minipass": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.1.tgz",
|
||||
"integrity": "sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==",
|
||||
"dev": true,
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
||||
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/minizlib": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.2.tgz",
|
||||
"integrity": "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minipass": "^7.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/mkdirp": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
|
||||
"integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mkdirp": "dist/cjs/src/bin.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/mkdirp-classic": {
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
||||
|
|
@ -5339,6 +5410,7 @@
|
|||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
||||
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
|
|
@ -6409,6 +6481,23 @@
|
|||
"node": ">=12.17"
|
||||
}
|
||||
},
|
||||
"node_modules/tar": {
|
||||
"version": "7.4.3",
|
||||
"resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz",
|
||||
"integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@isaacs/fs-minipass": "^4.0.0",
|
||||
"chownr": "^3.0.0",
|
||||
"minipass": "^7.1.2",
|
||||
"minizlib": "^3.0.1",
|
||||
"mkdirp": "^3.0.1",
|
||||
"yallist": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/tar-fs": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.2.tgz",
|
||||
|
|
@ -6452,6 +6541,24 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/tar/node_modules/chownr": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
|
||||
"integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==",
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/tar/node_modules/yallist": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",
|
||||
"integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==",
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/test-exclude": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
"@types/jest": "^29.5.12",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild": "0.19.11",
|
||||
"jest": "^29.7.0",
|
||||
"pkg": "^5.8.1",
|
||||
|
|
@ -42,6 +43,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"adm-zip": "^0.5.16",
|
||||
"commander": "^12.0.0",
|
||||
"core": "file:../core",
|
||||
"follow-redirects": "^1.15.5",
|
||||
|
|
@ -50,6 +52,7 @@
|
|||
"node-fetch": "^3.3.2",
|
||||
"posthog-node": "^3.6.3",
|
||||
"system-ca": "^1.0.2",
|
||||
"tar": "^7.4.3",
|
||||
"uuid": "^9.0.1",
|
||||
"vectordb": "^0.4.20",
|
||||
"win-ca": "^3.5.1"
|
||||
|
|
|
|||
|
|
@ -4,17 +4,35 @@ const path = require('path');
|
|||
const logDirPath = path.join(__dirname, '..', 'extensions', '.continue-debug', 'logs');
|
||||
const logFilePath = path.join(logDirPath, "prompt.log");
|
||||
|
||||
// Ensure the log directory exists
|
||||
if (!fs.existsSync(logDirPath)) {
|
||||
fs.mkdirSync(logDirPath, { recursive: true });
|
||||
console.log("Created log directory at " + logDirPath);
|
||||
}
|
||||
|
||||
// Create the log file if it doesn't exist
|
||||
if (!fs.existsSync(logFilePath)) {
|
||||
fs.createWriteStream(logFilePath).end();
|
||||
fs.writeFileSync(logFilePath, ''); // Create an empty file synchronously
|
||||
console.log("Created empty log file at " + logFilePath);
|
||||
}
|
||||
|
||||
console.log("Watching logs at " + logFilePath)
|
||||
console.log("Watching logs at " + logFilePath);
|
||||
|
||||
fs.watch(logFilePath, () => {
|
||||
// console.clear();
|
||||
fs.createReadStream(logFilePath).pipe(process.stdout);
|
||||
});
|
||||
// Set up the file watcher
|
||||
try {
|
||||
fs.watch(logFilePath, () => {
|
||||
try {
|
||||
// console.clear();
|
||||
const stream = fs.createReadStream(logFilePath);
|
||||
stream.pipe(process.stdout);
|
||||
stream.on('error', (err) => {
|
||||
console.error('Error reading log file:', err.message);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error while handling file change:', err.message);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error setting up file watcher:', err.message);
|
||||
console.log('You may need to restart the script after the extension generates the first log entry.');
|
||||
}
|
||||
120
binary/utils/ripgrep.js
Normal file
120
binary/utils/ripgrep.js
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { rimrafSync } = require("rimraf");
|
||||
const tar = require("tar");
|
||||
const { RIPGREP_VERSION, TARGET_TO_RIPGREP_RELEASE } = require("./targets");
|
||||
const AdmZip = require("adm-zip");
|
||||
|
||||
const RIPGREP_BASE_URL = `https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}`;
|
||||
|
||||
/**
|
||||
* Downloads a file from a URL to a specified path
|
||||
*
|
||||
* @param {string} url - The URL to download from
|
||||
* @param {string} destPath - The destination path for the downloaded file
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function downloadFile(url, destPath) {
|
||||
// Use the built-in fetch API instead of node-fetch
|
||||
const response = await fetch(url, {
|
||||
redirect: "follow", // Automatically follow redirects
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download file, status code: ${response.status}`);
|
||||
}
|
||||
|
||||
// Get the response as an array buffer and write it to the file
|
||||
const buffer = await response.arrayBuffer();
|
||||
fs.writeFileSync(destPath, Buffer.from(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts an archive to a specified directory
|
||||
*
|
||||
* @param {string} archivePath - Path to the archive file
|
||||
* @param {string} targetDir - Directory to extract the archive to
|
||||
* @param {string} platform - Platform identifier (e.g., 'darwin', 'linux', 'win32')
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function extractArchive(archivePath, targetDir, platform) {
|
||||
if (platform === "win32" || archivePath.endsWith(".zip")) {
|
||||
// Simple zip extraction for Windows - extract rg.exe
|
||||
const zip = new AdmZip(archivePath);
|
||||
|
||||
const rgEntry = zip
|
||||
.getEntries()
|
||||
.find((entry) => entry.entryName.endsWith("rg.exe"));
|
||||
|
||||
if (!rgEntry) {
|
||||
throw new Error("Could not find rg.exe in the downloaded archive");
|
||||
}
|
||||
|
||||
// Extract the found rg.exe file to the target directory
|
||||
const entryData = rgEntry.getData();
|
||||
fs.writeFileSync(path.join(targetDir, "rg.exe"), entryData);
|
||||
} else {
|
||||
await tar.extract({
|
||||
file: archivePath,
|
||||
cwd: targetDir,
|
||||
strip: 1, // Strip the top-level directory
|
||||
filter: (path) => path.endsWith("/rg"),
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Downloads and installs ripgrep for the specified target
|
||||
*
|
||||
* @param {string} target - Target platform-arch (e.g., 'darwin-x64')
|
||||
* @param {string} targetDir - Directory to install ripgrep to
|
||||
* @returns {Promise<string>} - Path to the installed ripgrep binary
|
||||
*/
|
||||
async function downloadRipgrep(target, targetDir) {
|
||||
// Get the ripgrep release file name for the target
|
||||
const releaseFile = TARGET_TO_RIPGREP_RELEASE[target];
|
||||
if (!releaseFile) {
|
||||
throw new Error(`Unsupported target: ${target}`);
|
||||
}
|
||||
|
||||
const platform = target.split("-")[0];
|
||||
const downloadUrl = `${RIPGREP_BASE_URL}/${releaseFile}`;
|
||||
const tempDir = path.join(targetDir, "temp");
|
||||
|
||||
// Create temp directory
|
||||
fs.mkdirSync(tempDir, { recursive: true });
|
||||
|
||||
const archivePath = path.join(tempDir, releaseFile);
|
||||
|
||||
try {
|
||||
// Download the ripgrep release
|
||||
console.log(`[info] Downloading ripgrep from ${downloadUrl}`);
|
||||
await downloadFile(downloadUrl, archivePath);
|
||||
|
||||
// Extract the archive
|
||||
console.log(`[info] Extracting ripgrep to ${targetDir}`);
|
||||
await extractArchive(archivePath, targetDir, platform);
|
||||
|
||||
// Make the binary executable on Unix-like systems
|
||||
if (platform !== "win32") {
|
||||
const rgPath = path.join(targetDir, "rg");
|
||||
fs.chmodSync(rgPath, 0o755);
|
||||
}
|
||||
|
||||
// Clean up
|
||||
rimrafSync(tempDir);
|
||||
|
||||
// Return the path to the ripgrep binary
|
||||
const binName = platform === "win32" ? "rg.exe" : "rg";
|
||||
return path.join(targetDir, binName);
|
||||
} catch (error) {
|
||||
console.error(`[error] Failed to download ripgrep for ${target}:`, error);
|
||||
// Clean up temp directory on error
|
||||
rimrafSync(tempDir);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
downloadRipgrep,
|
||||
RIPGREP_VERSION,
|
||||
};
|
||||
42
binary/utils/targets.js
Normal file
42
binary/utils/targets.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
const RIPGREP_VERSION = "14.1.1";
|
||||
|
||||
/**
|
||||
* All supported platform-architecture targets
|
||||
*/
|
||||
const ALL_TARGETS = [
|
||||
"darwin-x64",
|
||||
"darwin-arm64",
|
||||
"linux-x64",
|
||||
"linux-arm64",
|
||||
"win32-x64",
|
||||
];
|
||||
|
||||
/**
|
||||
* Mapping from target triplets to ripgrep release file names
|
||||
*/
|
||||
const TARGET_TO_RIPGREP_RELEASE = {
|
||||
"darwin-x64": `ripgrep-${RIPGREP_VERSION}-x86_64-apple-darwin.tar.gz`,
|
||||
"darwin-arm64": `ripgrep-${RIPGREP_VERSION}-aarch64-apple-darwin.tar.gz`,
|
||||
"linux-x64": `ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl.tar.gz`,
|
||||
"linux-arm64": `ripgrep-${RIPGREP_VERSION}-aarch64-unknown-linux-gnu.tar.gz`,
|
||||
"win32-x64": `ripgrep-${RIPGREP_VERSION}-x86_64-pc-windows-msvc.zip`,
|
||||
};
|
||||
|
||||
/**
|
||||
* Mapping from target triplets to LanceDB package names
|
||||
*/
|
||||
const TARGET_TO_LANCEDB = {
|
||||
"darwin-arm64": "@lancedb/vectordb-darwin-arm64",
|
||||
"darwin-x64": "@lancedb/vectordb-darwin-x64",
|
||||
"linux-arm64": "@lancedb/vectordb-linux-arm64-gnu",
|
||||
"linux-x64": "@lancedb/vectordb-linux-x64-gnu",
|
||||
"win32-x64": "@lancedb/vectordb-win32-x64-msvc",
|
||||
"win32-arm64": "@lancedb/vectordb-win32-arm64-msvc",
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
ALL_TARGETS,
|
||||
TARGET_TO_RIPGREP_RELEASE,
|
||||
TARGET_TO_LANCEDB,
|
||||
RIPGREP_VERSION,
|
||||
};
|
||||
|
|
@ -72,7 +72,8 @@ export class StreamTransformPipeline {
|
|||
fullStop,
|
||||
);
|
||||
|
||||
const timeoutValue = helper.options.showWhateverWeHaveAtXMs;
|
||||
const timeoutValue = helper.options.modelTimeout;
|
||||
|
||||
|
||||
lineGenerator = showWhateverWeHaveAtXMs(lineGenerator, timeoutValue!);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { jest } from "@jest/globals";
|
|||
|
||||
import * as lineStream from "./lineStream";
|
||||
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
describe("lineStream", () => {
|
||||
let mockFullStop: jest.Mock;
|
||||
|
||||
|
|
@ -204,6 +205,33 @@ describe("lineStream", () => {
|
|||
});
|
||||
|
||||
describe("filterCodeBlockLines", () => {
|
||||
it("should handle unfenced code", async () => {
|
||||
const linesGenerator = await getLineGenerator(["const x = 5;"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;"]);
|
||||
});
|
||||
|
||||
it("should handle unfenced code with a code block", async () => {
|
||||
const linesGenerator = await getLineGenerator(["const x = 5;","```bash","ls -al","```"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;","```bash","ls -al","```"]);
|
||||
});
|
||||
|
||||
it("should handle unfenced code with two code blocks", async () => {
|
||||
const linesGenerator = await getLineGenerator(["const x = 5;","```bash","ls -al","```","```bash","ls -al","```"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;","```bash","ls -al","```","```bash","ls -al","```"]);
|
||||
});
|
||||
|
||||
it("should remove lines before the first valid line", async () => {
|
||||
const linesGenerator = await getLineGenerator(["```ts", "const x = 5;"]);
|
||||
|
||||
|
|
@ -213,7 +241,59 @@ describe("lineStream", () => {
|
|||
expect(filteredLines).toEqual(["const x = 5;"]);
|
||||
});
|
||||
|
||||
it.todo("Need some sample inputs to properly test this");
|
||||
it("should remove outer blocks", async () => {
|
||||
const linesGenerator = await getLineGenerator(["```ts", "const x = 5;","```"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;"]);
|
||||
});
|
||||
|
||||
it("should leave inner blocks intact", async () => {
|
||||
const linesGenerator = await getLineGenerator(["```md", "const x = 5;", "```bash","ls -al","```","```"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;","```bash","ls -al","```"]);
|
||||
});
|
||||
|
||||
it("should handle included inner ticks", async () => {
|
||||
const linesGenerator = await getLineGenerator(["```md", "const x = 5;", "```bash","echo ```test```","```","```"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;","```bash","echo ```test```","```"]);
|
||||
});
|
||||
|
||||
it("should leave single inner blocks intact but not return trailing text", async () => {
|
||||
const linesGenerator = await getLineGenerator(["```md", "const x = 5;", "```bash","ls -al","```","```","trailing text"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;","```bash","ls -al","```"]);
|
||||
});
|
||||
|
||||
it("should leave double inner blocks intact but not return trailing text", async () => {
|
||||
const linesGenerator = await getLineGenerator(["```md", "const x = 5;", "```bash","ls -al","```","const y = 10;","```sh","echo `hello world`","```","```","trailing text"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;","```bash","ls -al","```","const y = 10;","```sh","echo `hello world`","```"]);
|
||||
});
|
||||
|
||||
it("should leave inner blocks intact but not return trailing or leading text", async () => {
|
||||
const linesGenerator = await getLineGenerator(["[CODE]", "const x = 5;", "```bash","ls -al","```","[/CODE]","trailing text"]);
|
||||
|
||||
const result = lineStream.filterCodeBlockLines(linesGenerator);
|
||||
const filteredLines = await getFilteredLines(result);
|
||||
|
||||
expect(filteredLines).toEqual(["const x = 5;","```bash","ls -al","```"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("filterEnglishLinesAtStart", () => {
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ function shouldChangeLineAndStop(line: string): string | undefined {
|
|||
return line;
|
||||
}
|
||||
|
||||
if (line.includes(CODE_START_BLOCK)) {
|
||||
return line.split(CODE_START_BLOCK)[0].trimEnd();
|
||||
if (line.includes(CODE_STOP_BLOCK)) {
|
||||
return line.split(CODE_STOP_BLOCK)[0].trimEnd();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
|
@ -71,9 +71,9 @@ function isUselessLine(line: string): boolean {
|
|||
return hasUselessLine || trimmed.startsWith("// end");
|
||||
}
|
||||
|
||||
export const USELESS_LINES = ["", "```"];
|
||||
export const USELESS_LINES = [""];
|
||||
export const CODE_KEYWORDS_ENDING_IN_SEMICOLON = ["def"];
|
||||
export const CODE_START_BLOCK = "[/CODE]";
|
||||
export const CODE_STOP_BLOCK = "[/CODE]";
|
||||
export const BRACKET_ENDING_CHARS = [")", "]", "}", ";"];
|
||||
export const PREFIXES_TO_SKIP = ["<COMPLETION>"];
|
||||
export const LINES_TO_STOP_AT = ["# End of file.", "<STOP EDITING HERE"];
|
||||
|
|
@ -343,34 +343,48 @@ export async function* removeTrailingWhitespace(
|
|||
* 4. Yields processed lines that are part of the actual code block content.
|
||||
*/
|
||||
export async function* filterCodeBlockLines(rawLines: LineStream): LineStream {
|
||||
let seenValidLine = false;
|
||||
let waitingToSeeIfLineIsLast = undefined;
|
||||
let seenFirstFence = false;
|
||||
// nestCount is set to 1 when the entire code block is wrapped with ``` or START blocks. It's then incremented
|
||||
// when an inner code block is discovered to avoid exiting the function prematurly. The function will exit early
|
||||
// when all blocks are matched. When no outer fence is discovered the function will always continue to the end.
|
||||
let nestCount = 0;
|
||||
|
||||
for await (const line of rawLines) {
|
||||
// Filter out starting ```
|
||||
if (!seenValidLine) {
|
||||
|
||||
|
||||
if (!seenFirstFence) {
|
||||
if (shouldRemoveLineBeforeStart(line)) {
|
||||
continue;
|
||||
// Filter out starting ``` or START block
|
||||
continue
|
||||
}
|
||||
seenValidLine = true;
|
||||
// Regardless of a fence or START block start tracking the nesting level
|
||||
seenFirstFence = true;
|
||||
nestCount = 1;
|
||||
}
|
||||
|
||||
// Filter out ending ```
|
||||
if (typeof waitingToSeeIfLineIsLast !== "undefined") {
|
||||
yield waitingToSeeIfLineIsLast;
|
||||
waitingToSeeIfLineIsLast = undefined;
|
||||
}
|
||||
|
||||
const changedEndLine = shouldChangeLineAndStop(line);
|
||||
if (typeof changedEndLine === "string") {
|
||||
yield changedEndLine;
|
||||
return;
|
||||
}
|
||||
|
||||
if (line.startsWith("```")) {
|
||||
waitingToSeeIfLineIsLast = line;
|
||||
} else {
|
||||
yield line;
|
||||
if (nestCount > 0) {
|
||||
// Inside a block including the outer block
|
||||
const changedEndLine = shouldChangeLineAndStop(line);
|
||||
if (typeof changedEndLine === "string") {
|
||||
// Ending a block with just backticks (```) or STOP
|
||||
nestCount--;
|
||||
if (nestCount === 0) {
|
||||
// if we are closing the outer block then exit early
|
||||
// only exit early if the outer block was started with a block
|
||||
// it it was text, we will never exit early
|
||||
return;
|
||||
} else {
|
||||
// otherwise just yield the line
|
||||
yield line;
|
||||
}
|
||||
} else if (line.startsWith("```")) {
|
||||
// Going into a nested codeblock
|
||||
nestCount++;
|
||||
yield line;
|
||||
} else {
|
||||
// otherwise just yield the line
|
||||
yield line;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,21 @@ const qwenCoderFimTemplate: AutocompleteTemplate = {
|
|||
},
|
||||
};
|
||||
|
||||
const seedCoderFimTemplate: AutocompleteTemplate = {
|
||||
template: "<[fim-prefix]>{{{prefix}}}<[fim-suffix]>{{{suffix}}}<[fim-middle]>",
|
||||
completionOptions: {
|
||||
stop: [
|
||||
"<[end▁of▁sentence]>",
|
||||
"<[fim-prefix]>",
|
||||
"<[fim-middle]>",
|
||||
"<[fim-suffix]>",
|
||||
"<[PAD▁TOKEN]>",
|
||||
"<[SEP▁TOKEN]>",
|
||||
"<[begin▁of▁sentence]>",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const codestralFimTemplate: AutocompleteTemplate = {
|
||||
template: "[SUFFIX]{{{suffix}}}[PREFIX]{{{prefix}}}",
|
||||
completionOptions: {
|
||||
|
|
@ -426,6 +441,10 @@ export function getTemplateForModel(model: string): AutocompleteTemplate {
|
|||
return qwenCoderFimTemplate;
|
||||
}
|
||||
|
||||
if (lowerCaseModel.includes("seed") && lowerCaseModel.includes("coder")) {
|
||||
return seedCoderFimTemplate;
|
||||
}
|
||||
|
||||
if (
|
||||
lowerCaseModel.includes("starcoder") ||
|
||||
lowerCaseModel.includes("star-coder") ||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
export class AutocompleteDebouncer {
|
||||
private debounceTimeout: NodeJS.Timeout | undefined = undefined;
|
||||
private debouncing = false;
|
||||
private lastUUID: string | undefined = undefined;
|
||||
private currentRequestId: string | undefined = undefined;
|
||||
|
||||
async delayAndShouldDebounce(debounceDelay: number): Promise<boolean> {
|
||||
// Debounce
|
||||
const uuid = uuidv4();
|
||||
this.lastUUID = uuid;
|
||||
|
||||
// Debounce
|
||||
if (this.debouncing) {
|
||||
this.debounceTimeout?.refresh();
|
||||
const lastUUID = await new Promise((resolve) =>
|
||||
setTimeout(() => {
|
||||
resolve(this.lastUUID);
|
||||
}, debounceDelay),
|
||||
);
|
||||
if (uuid !== lastUUID) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
this.debouncing = true;
|
||||
this.debounceTimeout = setTimeout(async () => {
|
||||
this.debouncing = false;
|
||||
}, debounceDelay);
|
||||
// Generate a unique ID for this request
|
||||
const requestId = uuidv4();
|
||||
this.currentRequestId = requestId;
|
||||
|
||||
// Clear any existing timeout
|
||||
if (this.debounceTimeout) {
|
||||
clearTimeout(this.debounceTimeout);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
// Create a new promise that resolves after the debounce delay
|
||||
return new Promise<boolean>((resolve) => {
|
||||
this.debounceTimeout = setTimeout(() => {
|
||||
// When the timeout completes, check if this is still the most recent request
|
||||
const shouldDebounce = this.currentRequestId !== requestId;
|
||||
|
||||
// If this is the most recent request, it shouldn't be debounced
|
||||
if (!shouldDebounce) {
|
||||
this.currentRequestId = undefined;
|
||||
}
|
||||
|
||||
resolve(shouldDebounce);
|
||||
}, debounceDelay);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ export class ConfigHandler {
|
|||
if (currentProfile) {
|
||||
this.globalContext.update("lastSelectedProfileForWorkspace", {
|
||||
...selectedProfiles,
|
||||
[profileKey]: selectedProfiles.id ?? null,
|
||||
[profileKey]: currentProfile.profileDescription.id,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -279,10 +279,7 @@ export class ConfigHandler {
|
|||
if (options.includeWorkspace) {
|
||||
const assistantFiles = await getAllDotContinueYamlFiles(
|
||||
this.ide,
|
||||
{
|
||||
...options,
|
||||
includeGlobal: false, // Because the global comes from above
|
||||
},
|
||||
options,
|
||||
ASSISTANTS,
|
||||
);
|
||||
const profiles = assistantFiles.map((assistant) => {
|
||||
|
|
|
|||
|
|
@ -173,6 +173,13 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void {
|
|||
effected = true;
|
||||
}
|
||||
|
||||
const { autoAcceptEditToolDiffs, ...withoutAutoApply } = migratedUI;
|
||||
if (autoAcceptEditToolDiffs !== undefined) {
|
||||
shareConfigUpdates.autoAcceptEditToolDiffs = autoAcceptEditToolDiffs;
|
||||
migratedUI = withoutAutoApply;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { showChatScrollbar, ...withoutShowChatScrollbar } = migratedUI;
|
||||
if (showChatScrollbar !== undefined) {
|
||||
shareConfigUpdates.showChatScrollbar = showChatScrollbar;
|
||||
|
|
|
|||
|
|
@ -26,11 +26,14 @@ export const sharedConfigSchema = z
|
|||
codeWrap: z.boolean(),
|
||||
displayRawMarkdown: z.boolean(),
|
||||
showChatScrollbar: z.boolean(),
|
||||
autoAcceptEditToolDiffs: z.boolean(),
|
||||
|
||||
// `tabAutocompleteOptions` in `ContinueConfig`
|
||||
useAutocompleteCache: z.boolean(),
|
||||
useAutocompleteMultilineCompletions: z.enum(["always", "never", "auto"]),
|
||||
disableAutocompleteInFiles: z.array(z.string()),
|
||||
modelTimeout: z.number(),
|
||||
debounceDelay: z.number(),
|
||||
})
|
||||
.partial();
|
||||
|
||||
|
|
@ -103,6 +106,13 @@ export function modifyAnyConfigWithSharedConfig<
|
|||
configCopy.tabAutocompleteOptions.disableInFiles =
|
||||
sharedConfig.disableAutocompleteInFiles;
|
||||
}
|
||||
if (sharedConfig.modelTimeout !== undefined) {
|
||||
configCopy.tabAutocompleteOptions.modelTimeout = sharedConfig.modelTimeout;
|
||||
}
|
||||
if (sharedConfig.debounceDelay !== undefined) {
|
||||
configCopy.tabAutocompleteOptions.debounceDelay =
|
||||
sharedConfig.debounceDelay;
|
||||
}
|
||||
|
||||
configCopy.ui = {
|
||||
...configCopy.ui,
|
||||
|
|
@ -124,6 +134,10 @@ export function modifyAnyConfigWithSharedConfig<
|
|||
if (sharedConfig.showChatScrollbar !== undefined) {
|
||||
configCopy.ui.showChatScrollbar = sharedConfig.showChatScrollbar;
|
||||
}
|
||||
if (sharedConfig.autoAcceptEditToolDiffs !== undefined) {
|
||||
configCopy.ui.autoAcceptEditToolDiffs =
|
||||
sharedConfig.autoAcceptEditToolDiffs;
|
||||
}
|
||||
|
||||
if (sharedConfig.allowAnonymousTelemetry !== undefined) {
|
||||
configCopy.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry;
|
||||
|
|
|
|||
|
|
@ -835,7 +835,8 @@ declare global {
|
|||
| "llava"
|
||||
| "gemma"
|
||||
| "granite"
|
||||
| "llama3";
|
||||
| "llama3"
|
||||
| "codestral";
|
||||
|
||||
export interface RequestOptions {
|
||||
timeout?: number;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export function addModel(
|
|||
(prev, curr) => (curr.title.startsWith(model.title) ? prev + 1 : prev),
|
||||
0,
|
||||
);
|
||||
if (numMatches !== 0) {
|
||||
if (numMatches !== undefined && numMatches > 0) {
|
||||
model.title = `${model.title} (${numMatches})`;
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ export function addModel(
|
|||
"name" in curr && curr.name.startsWith(model.title) ? prev + 1 : prev,
|
||||
0,
|
||||
);
|
||||
if (numMatches !== 0) {
|
||||
if (numMatches !== undefined && numMatches > 0) {
|
||||
model.title = `${model.title} (${numMatches})`;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
PackageIdentifier,
|
||||
RegistryClient,
|
||||
Rule,
|
||||
TEMPLATE_VAR_REGEX,
|
||||
unrollAssistant,
|
||||
validateConfigYaml,
|
||||
} from "@continuedev/config-yaml";
|
||||
|
|
@ -72,7 +73,7 @@ function convertYamlMcpToContinueMcp(
|
|||
args: server.args ?? [],
|
||||
env: server.env,
|
||||
},
|
||||
timeout: server.connectionTimeout
|
||||
timeout: server.connectionTimeout,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -241,6 +242,21 @@ async function configYamlToContinueConfig(options: {
|
|||
rootUrl: doc.rootUrl,
|
||||
faviconUrl: doc.faviconUrl,
|
||||
}));
|
||||
|
||||
config.mcpServers?.forEach((mcpServer) => {
|
||||
const mcpArgVariables =
|
||||
mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? [];
|
||||
|
||||
if (mcpArgVariables.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
localErrors.push({
|
||||
fatal: false,
|
||||
message: `MCP server "${mcpServer.name}" has unsubstituted variables in args: ${mcpArgVariables.join(", ")}. Please refer to https://docs.continue.dev/hub/secrets/secret-types for managing hub secrets.`,
|
||||
});
|
||||
});
|
||||
|
||||
continueConfig.experimental = {
|
||||
modelContextProtocolServers: config.mcpServers?.map(
|
||||
convertYamlMcpToContinueMcp,
|
||||
|
|
@ -445,7 +461,7 @@ async function configYamlToContinueConfig(options: {
|
|||
args: [],
|
||||
...server,
|
||||
},
|
||||
timeout: server.connectionTimeout
|
||||
timeout: server.connectionTimeout,
|
||||
})),
|
||||
false,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,27 @@ describe("MCPConnection", () => {
|
|||
expect(conn.status).toBe("not-connected");
|
||||
});
|
||||
|
||||
it("should create instance with SSE transport and custom headers", () => {
|
||||
const options = {
|
||||
name: "test-mcp",
|
||||
id: "test-id",
|
||||
transport: {
|
||||
type: "sse" as const,
|
||||
url: "http://test.com/events",
|
||||
requestOptions: {
|
||||
headers: {
|
||||
Authorization: "Bearer token123",
|
||||
"X-Custom-Header": "custom-value",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const conn = new MCPConnection(options);
|
||||
expect(conn).toBeInstanceOf(MCPConnection);
|
||||
expect(conn.status).toBe("not-connected");
|
||||
});
|
||||
|
||||
it("should throw on invalid transport type", () => {
|
||||
const options = {
|
||||
name: "test-mcp",
|
||||
|
|
@ -151,7 +172,7 @@ describe("MCPConnection", () => {
|
|||
expect(mockConnect).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should handle custom connection timeout', async () => {
|
||||
it("should handle custom connection timeout", async () => {
|
||||
const conn = new MCPConnection({ ...options, timeout: 11 });
|
||||
const mockConnect = jest
|
||||
.spyOn(Client.prototype, "connect")
|
||||
|
|
@ -178,7 +199,7 @@ describe("MCPConnection", () => {
|
|||
await conn.connectClient(false, abortController.signal);
|
||||
|
||||
expect(conn.status).toBe("error");
|
||||
expect(conn.errors[0]).toContain("Failed to connect to MCP server");
|
||||
expect(conn.errors[0]).toContain("Failed to connect");
|
||||
expect(mockConnect).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,17 @@ import {
|
|||
|
||||
const DEFAULT_MCP_TIMEOUT = 20_000; // 20 seconds
|
||||
|
||||
// Commands that are batch scripts on Windows and need cmd.exe to execute
|
||||
const WINDOWS_BATCH_COMMANDS = [
|
||||
"npx",
|
||||
"uv",
|
||||
"uvx",
|
||||
"pnpx",
|
||||
"dlx",
|
||||
"nx",
|
||||
"bunx",
|
||||
];
|
||||
|
||||
class MCPConnection {
|
||||
public client: Client;
|
||||
private transport: Transport;
|
||||
|
|
@ -52,24 +63,73 @@ class MCPConnection {
|
|||
await this.transport.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the command and arguments for the current platform
|
||||
* On Windows, batch script commands need to be executed via cmd.exe
|
||||
* @param originalCommand The original command
|
||||
* @param originalArgs The original command arguments
|
||||
* @returns An object with the resolved command and arguments
|
||||
*/
|
||||
private resolveCommandForPlatform(
|
||||
originalCommand: string,
|
||||
originalArgs: string[],
|
||||
): { command: string; args: string[] } {
|
||||
// If not on Windows or not a batch command, return as-is
|
||||
if (
|
||||
process.platform !== "win32" ||
|
||||
!WINDOWS_BATCH_COMMANDS.includes(originalCommand)
|
||||
) {
|
||||
return { command: originalCommand, args: originalArgs };
|
||||
}
|
||||
|
||||
// On Windows, we need to execute batch commands via cmd.exe
|
||||
// Format: cmd.exe /c command [args]
|
||||
return {
|
||||
command: "cmd.exe",
|
||||
args: ["/c", originalCommand, ...originalArgs],
|
||||
};
|
||||
}
|
||||
|
||||
private constructTransport(options: MCPOptions): Transport {
|
||||
switch (options.transport.type) {
|
||||
case "stdio":
|
||||
const env: Record<string, string> = options.transport.env
|
||||
? { ...options.transport.env }
|
||||
: {};
|
||||
|
||||
if (process.env.PATH !== undefined) {
|
||||
env.PATH = process.env.PATH;
|
||||
}
|
||||
|
||||
// Resolve the command and args for the current platform
|
||||
const { command, args } = this.resolveCommandForPlatform(
|
||||
options.transport.command,
|
||||
options.transport.args || [],
|
||||
);
|
||||
|
||||
return new StdioClientTransport({
|
||||
command: options.transport.command,
|
||||
args: options.transport.args,
|
||||
command,
|
||||
args,
|
||||
env,
|
||||
});
|
||||
case "websocket":
|
||||
return new WebSocketClientTransport(new URL(options.transport.url));
|
||||
case "sse":
|
||||
return new SSEClientTransport(new URL(options.transport.url));
|
||||
return new SSEClientTransport(new URL(options.transport.url), {
|
||||
eventSourceInit: {
|
||||
fetch: (input, init) =>
|
||||
fetch(input, {
|
||||
...init,
|
||||
headers: {
|
||||
...init?.headers,
|
||||
...(options.transport.requestOptions?.headers as
|
||||
| Record<string, string>
|
||||
| undefined),
|
||||
},
|
||||
}),
|
||||
},
|
||||
requestInit: { headers: options.transport.requestOptions?.headers },
|
||||
});
|
||||
default:
|
||||
throw new Error(
|
||||
`Unsupported transport type: ${(options.transport as any).type}`,
|
||||
|
|
@ -220,14 +280,14 @@ class MCPConnection {
|
|||
]);
|
||||
} catch (error) {
|
||||
// Otherwise it's a connection error
|
||||
let errorMessage = `Failed to connect to MCP server ${this.options.name}`;
|
||||
let errorMessage = `Failed to connect to "${this.options.name}"\n`;
|
||||
if (error instanceof Error) {
|
||||
const msg = error.message.toLowerCase();
|
||||
if (msg.includes("spawn") && msg.includes("enoent")) {
|
||||
const command = msg.split(" ")[1];
|
||||
errorMessage += `command "${command}" not found. To use this MCP server, install the ${command} CLI.`;
|
||||
errorMessage += `Error: command "${command}" not found. To use this MCP server, install the ${command} CLI.`;
|
||||
} else {
|
||||
errorMessage += ": " + error.message;
|
||||
errorMessage += "Error: " + error.message;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ const modelDescriptionSchema = z.object({
|
|||
"llava",
|
||||
"gemma",
|
||||
"llama3",
|
||||
"codestral",
|
||||
])
|
||||
.optional(),
|
||||
completionOptions: z
|
||||
|
|
|
|||
192
core/data/log.test.ts
Normal file
192
core/data/log.test.ts
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
import { DevDataLogEvent } from "@continuedev/config-yaml";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { IdeInfo, IdeSettings } from "..";
|
||||
import { Core } from "../core";
|
||||
import { getDevDataFilePath } from "../util/paths";
|
||||
import { DataLogger } from "./log";
|
||||
|
||||
// Only mock fetch, not fs
|
||||
jest.mock("@continuedev/fetch");
|
||||
|
||||
const TEST_EVENT: DevDataLogEvent = {
|
||||
name: "tokensGenerated",
|
||||
data: {
|
||||
generatedTokens: 100,
|
||||
model: "gpt-4",
|
||||
promptTokens: 50,
|
||||
provider: "openai",
|
||||
},
|
||||
};
|
||||
const SCHEMA = "0.2.0";
|
||||
|
||||
describe("DataLogger", () => {
|
||||
let dataLogger: DataLogger;
|
||||
const tempDir = path.join(process.cwd(), "temp-test-data");
|
||||
const testFilePath = path.join(tempDir, "tokensGenerated-test.jsonl");
|
||||
|
||||
// Create temp directory for test files
|
||||
beforeAll(() => {
|
||||
if (!fs.existsSync(tempDir)) {
|
||||
fs.mkdirSync(tempDir, { recursive: true });
|
||||
}
|
||||
});
|
||||
|
||||
// Clean up temp directory after tests
|
||||
afterAll(() => {
|
||||
if (fs.existsSync(tempDir)) {
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Reset mocks
|
||||
jest.clearAllMocks();
|
||||
|
||||
// Remove test file if it exists
|
||||
if (fs.existsSync(testFilePath)) {
|
||||
fs.unlinkSync(testFilePath);
|
||||
}
|
||||
|
||||
// Get singleton instance
|
||||
dataLogger = DataLogger.getInstance();
|
||||
|
||||
// Mock core and required promises
|
||||
dataLogger.core = {
|
||||
configHandler: {
|
||||
loadConfig: jest.fn().mockResolvedValue({
|
||||
config: {
|
||||
data: [],
|
||||
},
|
||||
}),
|
||||
currentProfile: {
|
||||
profileDescription: {
|
||||
id: "test-profile-id",
|
||||
},
|
||||
},
|
||||
controlPlaneClient: {
|
||||
getAccessToken: jest.fn().mockResolvedValue("test-access-token"),
|
||||
},
|
||||
},
|
||||
} as unknown as Core;
|
||||
|
||||
dataLogger.ideSettingsPromise = Promise.resolve({
|
||||
userToken: "test-user-token",
|
||||
} as IdeSettings);
|
||||
|
||||
dataLogger.ideInfoPromise = Promise.resolve({
|
||||
name: "VSCode",
|
||||
version: "1.0.0",
|
||||
extensionVersion: "0.1.0",
|
||||
} as IdeInfo);
|
||||
});
|
||||
|
||||
describe("getInstance", () => {
|
||||
it("should return the same instance when called multiple times", () => {
|
||||
const instance1 = DataLogger.getInstance();
|
||||
const instance2 = DataLogger.getInstance();
|
||||
expect(instance1).toBe(instance2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("addBaseValues", () => {
|
||||
it("should add base values to event data based on schema", async () => {
|
||||
const mockZodSchema = {
|
||||
shape: {
|
||||
eventName: true,
|
||||
timestamp: true,
|
||||
schema: true,
|
||||
userAgent: true,
|
||||
selectedProfileId: true,
|
||||
userId: true,
|
||||
},
|
||||
};
|
||||
|
||||
const result = await dataLogger.addBaseValues(
|
||||
{ customField: "value" },
|
||||
"testEvent",
|
||||
SCHEMA,
|
||||
mockZodSchema as any,
|
||||
);
|
||||
|
||||
expect(result).toEqual({
|
||||
customField: "value",
|
||||
eventName: "testEvent",
|
||||
timestamp: expect.any(String),
|
||||
schema: SCHEMA,
|
||||
userAgent: "VSCode/1.0.0 (Continue/0.1.0)",
|
||||
selectedProfileId: "test-profile-id",
|
||||
userId: "test-user-token",
|
||||
});
|
||||
});
|
||||
|
||||
it("should not add fields not present in schema shape", async () => {
|
||||
const mockZodSchema = {
|
||||
shape: {
|
||||
eventName: true,
|
||||
// No other fields
|
||||
},
|
||||
};
|
||||
|
||||
const result = await dataLogger.addBaseValues(
|
||||
{ customField: "value" },
|
||||
"testEvent",
|
||||
SCHEMA,
|
||||
mockZodSchema as any,
|
||||
);
|
||||
|
||||
expect(result).toEqual({
|
||||
customField: "value",
|
||||
eventName: "testEvent",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("logLocalData", () => {
|
||||
it("should actually write data to the local file", async () => {
|
||||
// Call the method to log data locally
|
||||
await dataLogger.logLocalData(TEST_EVENT);
|
||||
|
||||
// Verify the file was created
|
||||
const filepath = getDevDataFilePath(TEST_EVENT.name, SCHEMA);
|
||||
expect(fs.existsSync(filepath)).toBe(true);
|
||||
|
||||
// Read file contents and verify
|
||||
const fileContent = fs.readFileSync(filepath, "utf8");
|
||||
expect(fileContent).toContain('"generatedTokens":100');
|
||||
expect(fileContent).toContain('"model":"gpt-4"');
|
||||
expect(fileContent).toContain('"eventName":"tokensGenerated"');
|
||||
});
|
||||
});
|
||||
|
||||
describe("logDevData", () => {
|
||||
it("should log data locally and to configured destinations", async () => {
|
||||
// Spy on logLocalData and logToOneDestination
|
||||
const logLocalDataSpy = jest
|
||||
.spyOn(dataLogger, "logLocalData")
|
||||
.mockResolvedValue();
|
||||
const logToOneDestinationSpy = jest
|
||||
.spyOn(dataLogger, "logToOneDestination")
|
||||
.mockResolvedValue();
|
||||
|
||||
// Mock config with multiple data destinations
|
||||
const mockConfig = {
|
||||
config: {
|
||||
data: [
|
||||
{ destination: "https://example.com/logs", schema: SCHEMA },
|
||||
{ destination: "file:///logs", schema: SCHEMA },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
dataLogger.core!.configHandler.loadConfig = jest
|
||||
.fn()
|
||||
.mockResolvedValue(mockConfig);
|
||||
|
||||
await dataLogger.logDevData(TEST_EVENT);
|
||||
|
||||
expect(logLocalDataSpy).toHaveBeenCalledWith(TEST_EVENT);
|
||||
expect(logToOneDestinationSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
237
core/data/log.ts
237
core/data/log.ts
|
|
@ -12,7 +12,7 @@ import * as URI from "uri-js";
|
|||
import { fileURLToPath } from "url";
|
||||
import { AnyZodObject } from "zod";
|
||||
import { Core } from "../core.js";
|
||||
import { IdeInfo, IdeSettings } from "../index.js";
|
||||
import { ContinueConfig, IdeInfo, IdeSettings } from "../index.js";
|
||||
import { getDevDataFilePath } from "../util/paths.js";
|
||||
import { joinPathsToUri } from "../util/uri.js";
|
||||
|
||||
|
|
@ -68,8 +68,7 @@ export class DataLogger {
|
|||
return newBody;
|
||||
}
|
||||
|
||||
async logDevData(event: DevDataLogEvent) {
|
||||
// Local logs (always on for all levels)
|
||||
async logLocalData(event: DevDataLogEvent) {
|
||||
try {
|
||||
const filepath: string = getDevDataFilePath(
|
||||
event.name,
|
||||
|
|
@ -100,126 +99,144 @@ export class DataLogger {
|
|||
} catch (error) {
|
||||
console.error("Error logging local dev data:", error);
|
||||
}
|
||||
}
|
||||
|
||||
async logDevData(event: DevDataLogEvent) {
|
||||
// Local logs (always on for all levels)
|
||||
await this.logLocalData(event);
|
||||
|
||||
// Remote logs
|
||||
const config = (await this.core?.configHandler.loadConfig())?.config;
|
||||
if (config?.data?.length) {
|
||||
await Promise.allSettled(
|
||||
config.data.map(async (dataConfig) => {
|
||||
try {
|
||||
// First extract the data schema based on the version and level
|
||||
const { schema } = dataConfig;
|
||||
config.data.map((dataConfig) =>
|
||||
this.logToOneDestination(dataConfig, event),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const level = dataConfig.level ?? DEFAULT_DEV_DATA_LEVEL;
|
||||
async parseEventData(
|
||||
event: DevDataLogEvent,
|
||||
schema: string,
|
||||
level: "all" | "noCode",
|
||||
) {
|
||||
const versionSchemas = devDataVersionedSchemas[schema];
|
||||
if (!versionSchemas) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data to non-existent version ${schema}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Skip event if `events` is specified and does not include the event
|
||||
const events = dataConfig.events ?? allDevEventNames;
|
||||
if (!events.includes(event.name)) {
|
||||
return;
|
||||
}
|
||||
const levelSchemas = versionSchemas[level];
|
||||
if (!levelSchemas) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data at level ${level} for version ${schema} which does not exist`,
|
||||
);
|
||||
}
|
||||
|
||||
const versionSchemas = devDataVersionedSchemas[schema];
|
||||
if (!versionSchemas) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data to non-existent version ${schema}`,
|
||||
);
|
||||
}
|
||||
const zodSchema = levelSchemas[event.name];
|
||||
if (!zodSchema) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data for event ${event.name} at level ${level} for version ${schema}: no schema found`,
|
||||
);
|
||||
}
|
||||
|
||||
const levelSchemas = versionSchemas[level];
|
||||
if (!levelSchemas) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data at level ${level} for version ${schema} which does not exist`,
|
||||
);
|
||||
}
|
||||
const eventDataWithBaseValues = await this.addBaseValues(
|
||||
event.data,
|
||||
event.name,
|
||||
schema,
|
||||
zodSchema,
|
||||
);
|
||||
|
||||
const zodSchema = levelSchemas[event.name];
|
||||
if (!zodSchema) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data for event ${event.name} at level ${level} for version ${schema}: no schema found`,
|
||||
);
|
||||
}
|
||||
const parsed = zodSchema.safeParse(eventDataWithBaseValues);
|
||||
if (!parsed.success) {
|
||||
throw new Error(
|
||||
`Failed to parse event data for event ${event.name} and schema ${schema}\n:${parsed.error.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
const eventDataWithBaseValues = await this.addBaseValues(
|
||||
event.data,
|
||||
event.name,
|
||||
return parsed.data;
|
||||
}
|
||||
|
||||
async logToOneDestination(
|
||||
dataConfig: NonNullable<ContinueConfig["data"]>[number],
|
||||
event: DevDataLogEvent,
|
||||
) {
|
||||
try {
|
||||
if (!dataConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First extract the data schema based on the version and level
|
||||
const { schema } = dataConfig;
|
||||
const level = dataConfig.level ?? DEFAULT_DEV_DATA_LEVEL;
|
||||
|
||||
// Skip event if `events` is specified and does not include the event
|
||||
const events = dataConfig.events ?? allDevEventNames;
|
||||
if (!events.includes(event.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse the event data, throwing if it fails
|
||||
const parsed = await this.parseEventData(event, schema, level);
|
||||
|
||||
const uriComponents = URI.parse(dataConfig.destination);
|
||||
|
||||
// Send to remote server
|
||||
if (uriComponents.scheme === "https" || uriComponents.scheme === "http") {
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
|
||||
// If an API key is provided, use it, otherwise use the Continue access token
|
||||
if (dataConfig.apiKey) {
|
||||
headers["Authorization"] = `Bearer ${dataConfig.apiKey}`;
|
||||
} else {
|
||||
const accessToken =
|
||||
await this.core?.configHandler.controlPlaneClient.getAccessToken();
|
||||
headers["Authorization"] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
const profileId =
|
||||
this.core?.configHandler.currentProfile?.profileDescription.id ?? "";
|
||||
const response = await fetchwithRequestOptions(
|
||||
dataConfig.destination,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
name: event.name,
|
||||
data: parsed,
|
||||
schema,
|
||||
zodSchema,
|
||||
);
|
||||
level,
|
||||
profileId,
|
||||
}),
|
||||
},
|
||||
dataConfig.requestOptions,
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Post request failed. ${response.status}: ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
} else if (uriComponents.scheme === "file") {
|
||||
// Write to jsonc file for local file URIs
|
||||
const dirUri = joinPathsToUri(dataConfig.destination, schema);
|
||||
const dirPath = fileURLToPath(dirUri);
|
||||
|
||||
const parsed = zodSchema.safeParse(eventDataWithBaseValues);
|
||||
if (!parsed.success) {
|
||||
throw new Error(
|
||||
`Failed to parse event data for event ${event.name} and schema ${schema}\n:${parsed.error.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
const uriComponents = URI.parse(dataConfig.destination);
|
||||
|
||||
// Send to remote server
|
||||
if (
|
||||
uriComponents.scheme === "https" ||
|
||||
uriComponents.scheme === "http"
|
||||
) {
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
if (dataConfig.apiKey) {
|
||||
headers["Authorization"] = `Bearer ${dataConfig.apiKey}`;
|
||||
}
|
||||
|
||||
// For events going to Continue, overwrite the access token
|
||||
if (
|
||||
uriComponents.host?.endsWith(".continue.dev") ||
|
||||
uriComponents.host === "continue.dev"
|
||||
) {
|
||||
//
|
||||
const accessToken =
|
||||
await this.core?.configHandler.controlPlaneClient.getAccessToken();
|
||||
headers["Authorization"] = `Bearer ${accessToken}`;
|
||||
}
|
||||
const profileId =
|
||||
this.core?.configHandler.currentProfile?.profileDescription
|
||||
.id ?? "";
|
||||
const response = await fetchwithRequestOptions(
|
||||
dataConfig.destination,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
name: event.name,
|
||||
data: parsed.data,
|
||||
schema,
|
||||
level,
|
||||
profileId,
|
||||
}),
|
||||
},
|
||||
dataConfig.requestOptions,
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Post request failed. ${response.status}: ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
} else if (uriComponents.scheme === "file") {
|
||||
// Write to jsonc file for local file URIs
|
||||
const dirUri = joinPathsToUri(dataConfig.destination, schema);
|
||||
const dirPath = fileURLToPath(dirUri);
|
||||
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
fs.mkdirSync(dirPath, { recursive: true });
|
||||
}
|
||||
const filepath = path.join(dirPath, `${event.name}.jsonl`);
|
||||
const jsonLine = JSON.stringify(event.data);
|
||||
fs.writeFileSync(filepath, `${jsonLine}\n`, { flag: "a" });
|
||||
} else {
|
||||
throw new Error(`Unsupported URI scheme ${uriComponents.scheme}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Error logging data to ${dataConfig.destination}: ${error instanceof Error ? error.message : error}`,
|
||||
);
|
||||
}
|
||||
}),
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
fs.mkdirSync(dirPath, { recursive: true });
|
||||
}
|
||||
const filepath = path.join(dirPath, `${event.name}.jsonl`);
|
||||
const jsonLine = JSON.stringify(event.data);
|
||||
fs.writeFileSync(filepath, `${jsonLine}\n`, { flag: "a" });
|
||||
} else {
|
||||
throw new Error(`Unsupported URI scheme ${uriComponents.scheme}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Error logging data to ${dataConfig.destination}: ${error instanceof Error ? error.message : error}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
58
core/index.d.ts
vendored
58
core/index.d.ts
vendored
|
|
@ -197,15 +197,14 @@ export interface CustomContextProvider {
|
|||
description?: string;
|
||||
renderInlineAs?: string;
|
||||
type?: ContextProviderType;
|
||||
loadSubmenuItems?: (
|
||||
args: LoadSubmenuItemsArgs,
|
||||
) => Promise<ContextSubmenuItem[]>;
|
||||
|
||||
getContextItems(
|
||||
query: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]>;
|
||||
|
||||
loadSubmenuItems?: (
|
||||
args: LoadSubmenuItemsArgs,
|
||||
) => Promise<ContextSubmenuItem[]>;
|
||||
}
|
||||
|
||||
export interface ContextSubmenuItem {
|
||||
|
|
@ -459,6 +458,7 @@ export interface ChatHistoryItem {
|
|||
toolCallState?: ToolCallState;
|
||||
isGatheringContext?: boolean;
|
||||
reasoning?: Reasoning;
|
||||
appliedRules?: RuleWithSource[];
|
||||
}
|
||||
|
||||
export interface LLMFullCompletionOptions extends BaseCompletionOptions {
|
||||
|
|
@ -842,6 +842,7 @@ export interface SlashCommand {
|
|||
description: string;
|
||||
prompt?: string;
|
||||
params?: { [key: string]: any };
|
||||
promptFile?: string
|
||||
run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
|
||||
}
|
||||
|
||||
|
|
@ -910,7 +911,8 @@ export type TemplateType =
|
|||
| "llava"
|
||||
| "gemma"
|
||||
| "granite"
|
||||
| "llama3";
|
||||
| "llama3"
|
||||
| "codestral";
|
||||
|
||||
export interface RequestOptions {
|
||||
timeout?: number;
|
||||
|
|
@ -1022,6 +1024,7 @@ export interface BaseCompletionOptions {
|
|||
toolChoice?: ToolChoice;
|
||||
reasoning?: boolean;
|
||||
reasoningBudgetTokens?: number;
|
||||
promptCaching?: boolean;
|
||||
}
|
||||
|
||||
export interface ModelCapability {
|
||||
|
|
@ -1089,6 +1092,7 @@ export interface TabAutocompleteOptions {
|
|||
disable: boolean;
|
||||
maxPromptTokens: number;
|
||||
debounceDelay: number;
|
||||
modelTimeout: number;
|
||||
maxSuffixPercentage: number;
|
||||
prefixPercentage: number;
|
||||
transform?: boolean;
|
||||
|
|
@ -1114,16 +1118,19 @@ export interface StdioOptions {
|
|||
command: string;
|
||||
args: string[];
|
||||
env?: Record<string, string>;
|
||||
requestOptions?: RequestOptions;
|
||||
}
|
||||
|
||||
export interface WebSocketOptions {
|
||||
type: "websocket";
|
||||
url: string;
|
||||
requestOptions?: RequestOptions;
|
||||
}
|
||||
|
||||
export interface SSEOptions {
|
||||
type: "sse";
|
||||
url: string;
|
||||
requestOptions?: RequestOptions;
|
||||
}
|
||||
|
||||
export type TransportOptions = StdioOptions | WebSocketOptions | SSEOptions;
|
||||
|
|
@ -1161,6 +1168,7 @@ export interface MCPResource {
|
|||
description?: string;
|
||||
mimeType?: string;
|
||||
}
|
||||
|
||||
export interface MCPTool {
|
||||
name: string;
|
||||
description?: string;
|
||||
|
|
@ -1186,6 +1194,7 @@ export interface ContinueUIConfig {
|
|||
showChatScrollbar?: boolean;
|
||||
codeWrap?: boolean;
|
||||
showSessionTabs?: boolean;
|
||||
autoAcceptEditToolDiffs?: boolean;
|
||||
}
|
||||
|
||||
export interface ContextMenuConfig {
|
||||
|
|
@ -1223,6 +1232,27 @@ export interface ApplyState {
|
|||
toolCallId?: string;
|
||||
}
|
||||
|
||||
export interface StreamDiffLinesPayload {
|
||||
prefix: string;
|
||||
highlighted: string;
|
||||
suffix: string;
|
||||
input: string;
|
||||
language: string | undefined;
|
||||
modelTitle: string | undefined;
|
||||
includeRulesInSystemMessage: boolean;
|
||||
}
|
||||
|
||||
export interface HighlightedCodePayload {
|
||||
rangeInFileWithContents: RangeInFileWithContents;
|
||||
prompt?: string;
|
||||
shouldRun?: boolean;
|
||||
}
|
||||
|
||||
export interface AcceptOrRejectDiffPayload {
|
||||
filepath: string;
|
||||
streamId?: string;
|
||||
}
|
||||
|
||||
export interface RangeInFileWithContents {
|
||||
filepath: string;
|
||||
range: {
|
||||
|
|
@ -1232,7 +1262,7 @@ export interface RangeInFileWithContents {
|
|||
contents: string;
|
||||
}
|
||||
|
||||
export type CodeToEdit = RangeInFileWithContents | FileWithContents;
|
||||
export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents;
|
||||
|
||||
/**
|
||||
* Represents the configuration for a quick action in the Code Lens.
|
||||
|
|
@ -1491,15 +1521,19 @@ export interface TerminalOptions {
|
|||
waitForCompletion?: boolean;
|
||||
}
|
||||
|
||||
export type RuleSource =
|
||||
| "default-chat"
|
||||
| "default-agent"
|
||||
| "model-chat-options"
|
||||
| "model-agent-options"
|
||||
| "rules-block"
|
||||
| "json-systemMessage"
|
||||
| ".continuerules";
|
||||
|
||||
export interface RuleWithSource {
|
||||
name?: string;
|
||||
slug?: string;
|
||||
source:
|
||||
| "default"
|
||||
| "model-chat-options"
|
||||
| "rules-block"
|
||||
| "json-systemMessage"
|
||||
| ".continuerules";
|
||||
source: RuleSource;
|
||||
globs?: string | string[];
|
||||
rule: string;
|
||||
description?: string;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
getQueryForFile,
|
||||
} from "../util/treeSitter";
|
||||
|
||||
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex";
|
||||
import { DatabaseConnection, SqliteDb } from "./refreshIndex";
|
||||
import {
|
||||
IndexResultType,
|
||||
MarkCompleteCallback,
|
||||
|
|
@ -29,6 +29,7 @@ import {
|
|||
getLastNUriRelativePathParts,
|
||||
getUriPathBasename,
|
||||
} from "../util/uri";
|
||||
import { tagToString } from "./utils";
|
||||
|
||||
type SnippetChunk = ChunkWithoutID & { title: string; signature: string };
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@ import { RETRIEVAL_PARAMS } from "../util/parameters";
|
|||
import { getUriPathBasename } from "../util/uri";
|
||||
|
||||
import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex";
|
||||
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex";
|
||||
import { DatabaseConnection, SqliteDb } from "./refreshIndex";
|
||||
import {
|
||||
IndexResultType,
|
||||
MarkCompleteCallback,
|
||||
RefreshIndexResults,
|
||||
type CodebaseIndex,
|
||||
} from "./types";
|
||||
import { tagToString } from "./utils";
|
||||
|
||||
export interface RetrieveConfig {
|
||||
tags: BranchAndDir[];
|
||||
|
|
@ -97,11 +98,14 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex {
|
|||
|
||||
// Delete
|
||||
for (const item of results.del) {
|
||||
await db.run(`
|
||||
await db.run(
|
||||
`
|
||||
DELETE FROM fts WHERE rowid IN (
|
||||
SELECT id FROM fts_metadata WHERE path = ? AND cacheKey = ?
|
||||
)
|
||||
`,[item.path, item.cacheKey]);
|
||||
`,
|
||||
[item.path, item.cacheKey],
|
||||
);
|
||||
await db.run("DELETE FROM fts_metadata WHERE path = ? AND cacheKey = ?", [
|
||||
item.path,
|
||||
item.cacheKey,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { getUriPathBasename } from "../util/uri";
|
|||
|
||||
import { basicChunker } from "./chunk/basic.js";
|
||||
import { chunkDocument, shouldChunk } from "./chunk/chunk.js";
|
||||
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex.js";
|
||||
import { DatabaseConnection, SqliteDb } from "./refreshIndex.js";
|
||||
import {
|
||||
CodebaseIndex,
|
||||
IndexResultType,
|
||||
|
|
@ -24,6 +24,7 @@ import {
|
|||
} from "./types";
|
||||
|
||||
import type * as LanceType from "vectordb";
|
||||
import { tagToString } from "./utils";
|
||||
|
||||
interface LanceDbRow {
|
||||
uuid: string;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { RunResult } from "sqlite3";
|
|||
|
||||
import { IContinueServerClient } from "../../continueServer/interface.js";
|
||||
import { Chunk, IndexTag, IndexingProgressUpdate } from "../../index.js";
|
||||
import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex.js";
|
||||
import { DatabaseConnection, SqliteDb } from "../refreshIndex.js";
|
||||
import {
|
||||
IndexResultType,
|
||||
MarkCompleteCallback,
|
||||
|
|
@ -13,8 +13,9 @@ import {
|
|||
type CodebaseIndex,
|
||||
} from "../types.js";
|
||||
|
||||
import { chunkDocument, shouldChunk } from "./chunk.js";
|
||||
import { getUriPathBasename } from "../../util/uri.js";
|
||||
import { tagToString } from "../utils.js";
|
||||
import { chunkDocument, shouldChunk } from "./chunk.js";
|
||||
|
||||
export class ChunkCodebaseIndex implements CodebaseIndex {
|
||||
relativeExpectedTime: number = 1;
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@ import {
|
|||
|
||||
export type DatabaseConnection = Database<sqlite3.Database>;
|
||||
|
||||
export function tagToString(tag: IndexTag): string {
|
||||
return `${tag.directory}::${tag.branch}::${tag.artifactId}`;
|
||||
}
|
||||
|
||||
export class SqliteDb {
|
||||
static db: DatabaseConnection | null = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ import { jest } from "@jest/globals";
|
|||
import { IndexTag } from "../..";
|
||||
import { IContinueServerClient } from "../../continueServer/interface";
|
||||
import { ChunkCodebaseIndex } from "../chunk/ChunkCodebaseIndex";
|
||||
import { tagToString } from "../refreshIndex";
|
||||
import { CodebaseIndex, RefreshIndexResults } from "../types";
|
||||
|
||||
import { testIde } from "../../test/fixtures";
|
||||
import { addToTestDir, TEST_DIR } from "../../test/testDir";
|
||||
import { tagToString } from "../utils";
|
||||
|
||||
export const mockFilename = "test.py";
|
||||
export const mockPathAndCacheKey = {
|
||||
|
|
|
|||
58
core/indexing/utils.test.ts
Normal file
58
core/indexing/utils.test.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import { IndexTag } from "..";
|
||||
import { tagToString } from "./utils";
|
||||
|
||||
test("tagToString returns full tag string when under length limit", () => {
|
||||
const tag: IndexTag = {
|
||||
directory: "/normal/path/to/repo",
|
||||
branch: "main",
|
||||
artifactId: "12345",
|
||||
};
|
||||
|
||||
expect(tagToString(tag)).toBe("/normal/path/to/repo::main::12345");
|
||||
});
|
||||
|
||||
test("tagToString truncates beginning of directory when path is too long", () => {
|
||||
// Create a very long directory path that exceeds MAX_DIR_LENGTH (200)
|
||||
const longPrefix = "/very/long/path/that/will/be/truncated/";
|
||||
const importantSuffix = "/user/important-project/src/feature";
|
||||
const longPath = longPrefix + "x".repeat(200) + importantSuffix;
|
||||
|
||||
const tag: IndexTag = {
|
||||
directory: longPath,
|
||||
branch: "feature-branch",
|
||||
artifactId: "67890",
|
||||
};
|
||||
|
||||
const result = tagToString(tag);
|
||||
|
||||
// The result should keep the important suffix part
|
||||
expect(result).toContain(importantSuffix);
|
||||
// The result should NOT contain the beginning of the path
|
||||
expect(result).not.toContain(longPrefix);
|
||||
// The result should include the branch and artifactId
|
||||
expect(result).toContain("::feature-branch::67890");
|
||||
// The result should be within the MAX_TABLE_NAME_LENGTH limit (240)
|
||||
expect(result.length).toBeLessThanOrEqual(240);
|
||||
});
|
||||
|
||||
test("tagToString preserves branch and artifactId exactly, even when truncating", () => {
|
||||
const longPath = "/a".repeat(300); // Much longer than MAX_DIR_LENGTH
|
||||
const tag: IndexTag = {
|
||||
directory: longPath,
|
||||
branch: "release-v2.0",
|
||||
artifactId: "build-123",
|
||||
};
|
||||
|
||||
const result = tagToString(tag);
|
||||
|
||||
// Should contain the exact branch and artifactId
|
||||
expect(result).toContain("::release-v2.0::build-123");
|
||||
// Should contain the end of the path
|
||||
expect(result).toContain("/a/a/a");
|
||||
// Should not contain the full original path (it should be truncated)
|
||||
expect(result.length).toBeLessThan(
|
||||
longPath.length + "::release-v2.0::build-123".length,
|
||||
);
|
||||
// The result should be within the MAX_TABLE_NAME_LENGTH limit
|
||||
expect(result.length).toBeLessThanOrEqual(240);
|
||||
});
|
||||
45
core/indexing/utils.ts
Normal file
45
core/indexing/utils.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { IndexTag } from "..";
|
||||
|
||||
// Maximum length for table names to stay under OS filename limits
|
||||
const MAX_TABLE_NAME_LENGTH = 240;
|
||||
|
||||
// Leave room for branch and artifactId
|
||||
const MAX_DIR_LENGTH = 200;
|
||||
|
||||
/**
|
||||
* Converts an IndexTag to a string representation, safely handling long paths.
|
||||
*
|
||||
* The string is used as a table name and identifier in various places, so it needs
|
||||
* to stay under OS filename length limits (typically 255 chars). This is especially
|
||||
* important for dev containers where the directory path can be very long due to
|
||||
* containing container configuration.
|
||||
*
|
||||
* The format is: "{directory}::{branch}::{artifactId}"
|
||||
*
|
||||
* To handle long paths:
|
||||
* 1. First tries the full string - most backwards compatible
|
||||
* 2. If too long, truncates directory from the beginning to maintain uniqueness
|
||||
* (since final parts of paths are more unique than prefixes)
|
||||
* 3. Finally ensures entire string stays under MAX_TABLE_NAME_LENGTH for OS compatibility
|
||||
*
|
||||
* @param tag The tag containing directory, branch, and artifactId
|
||||
* @returns A string representation safe for use as a table name
|
||||
*/
|
||||
export function tagToString(tag: IndexTag): string {
|
||||
const result = `${tag.directory}::${tag.branch}::${tag.artifactId}`;
|
||||
|
||||
if (result.length <= MAX_TABLE_NAME_LENGTH) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Truncate from the beginning of directory path to preserve the more unique end parts
|
||||
const dir =
|
||||
tag.directory.length > MAX_DIR_LENGTH
|
||||
? tag.directory.slice(tag.directory.length - MAX_DIR_LENGTH)
|
||||
: tag.directory;
|
||||
|
||||
return `${dir}::${tag.branch}::${tag.artifactId}`.slice(
|
||||
0,
|
||||
MAX_TABLE_NAME_LENGTH,
|
||||
);
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import {
|
|||
anthropicTemplateMessages,
|
||||
chatmlTemplateMessages,
|
||||
codeLlama70bTemplateMessages,
|
||||
codestralTemplateMessages,
|
||||
deepseekTemplateMessages,
|
||||
gemmaTemplateMessage,
|
||||
graniteTemplateMessages,
|
||||
|
|
@ -78,7 +79,8 @@ const PROVIDER_SUPPORTS_IMAGES: string[] = [
|
|||
"azure",
|
||||
"scaleway",
|
||||
"nebius",
|
||||
"ovhcloud"
|
||||
"ovhcloud",
|
||||
"watsonx",
|
||||
];
|
||||
|
||||
const MODEL_SUPPORTS_IMAGES: string[] = [
|
||||
|
|
@ -98,6 +100,7 @@ const MODEL_SUPPORTS_IMAGES: string[] = [
|
|||
"llama3.2",
|
||||
"llama-3.2",
|
||||
"llama4",
|
||||
"granite-vision",
|
||||
];
|
||||
|
||||
function modelSupportsTools(modelDescription: ModelDescription) {
|
||||
|
|
@ -295,6 +298,7 @@ function autodetectTemplateFunction(
|
|||
gemma: gemmaTemplateMessage,
|
||||
granite: graniteTemplateMessages,
|
||||
llama3: llama3TemplateMessages,
|
||||
codestral: codestralTemplateMessages,
|
||||
none: null,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ import { getSystemMessageWithRules } from "./rules/getSystemMessageWithRules";
|
|||
export const DEFAULT_CHAT_SYSTEM_MESSAGE_URL =
|
||||
"https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts";
|
||||
|
||||
export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\
|
||||
<important_rules>
|
||||
Always include the language and file name in the info string when you write code blocks.
|
||||
export const DEFAULT_AGENT_SYSTEM_MESSAGE_URL =
|
||||
"https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts";
|
||||
|
||||
const EDIT_MESSAGE = `\
|
||||
Always include the language and file name in the info string when you write code blocks.
|
||||
If you are editing "src/main.py" for example, your code block should start with '\`\`\`python src/main.py'
|
||||
|
||||
When addressing code modification requests, present a concise code snippet that
|
||||
|
|
@ -39,15 +41,15 @@ export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\
|
|||
|
||||
\`\`\`language /path/to/file
|
||||
// ... existing code ...
|
||||
|
||||
|
||||
function exampleFunction() {
|
||||
// ... existing code ...
|
||||
|
||||
|
||||
{{ modified code here }}
|
||||
|
||||
|
||||
// ... rest of function ...
|
||||
}
|
||||
|
||||
|
||||
// ... rest of code ...
|
||||
\`\`\`
|
||||
|
||||
|
|
@ -56,9 +58,27 @@ export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\
|
|||
at the beginning, middle, or end of files using these "lazy" comments. Only
|
||||
provide the complete file when explicitly requested. Include a concise explanation
|
||||
of changes unless the user specifically asks for code only.
|
||||
`
|
||||
|
||||
export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\
|
||||
<important_rules>
|
||||
You are in chat mode.
|
||||
|
||||
If the user asks to make changes to files offer that they can use the Apply Button on the code block, or switch to Agent Mode to make the suggested updates automatically.
|
||||
If needed consisely explain to the user they can switch to agent mode using the Mode Selector dropdown and provide no other details.
|
||||
|
||||
${EDIT_MESSAGE}
|
||||
</important_rules>`;
|
||||
|
||||
export const DEFAULT_AGENT_SYSTEM_MESSAGE = `\
|
||||
<important_rules>
|
||||
You are in agent mode.
|
||||
|
||||
${EDIT_MESSAGE}
|
||||
</important_rules>`;
|
||||
|
||||
export function constructMessages(
|
||||
messageMode: string,
|
||||
history: ChatHistoryItem[],
|
||||
baseChatOrAgentSystemMessage: string | undefined,
|
||||
rules: RuleWithSource[],
|
||||
|
|
@ -71,6 +91,14 @@ export function constructMessages(
|
|||
for (let i = 0; i < filteredHistory.length; i++) {
|
||||
const historyItem = filteredHistory[i];
|
||||
|
||||
if (messageMode === "chat") {
|
||||
const toolMessage: ToolResultChatMessage = historyItem.message as ToolResultChatMessage;
|
||||
if (historyItem.toolCallState?.toolCallId || toolMessage.toolCallId) {
|
||||
// remove all tool calls from the history
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (historyItem.message.role === "user") {
|
||||
// Gather context items for user messages
|
||||
let content = normalizeToMessageParts(historyItem.message);
|
||||
|
|
@ -100,8 +128,7 @@ export function constructMessages(
|
|||
| undefined;
|
||||
|
||||
const systemMessage = getSystemMessageWithRules({
|
||||
baseSystemMessage:
|
||||
baseChatOrAgentSystemMessage ?? DEFAULT_CHAT_SYSTEM_MESSAGE,
|
||||
baseSystemMessage: baseChatOrAgentSystemMessage,
|
||||
rules,
|
||||
userMessage: lastUserMsg,
|
||||
});
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue