Merge branch 'main' of https://github.com/continuedev/continue into pe/rule-tool-update
This commit is contained in:
commit
8fab79e5fc
163 changed files with 3430 additions and 2251 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
|
||||
8
.github/workflows/cla.yaml
vendored
8
.github/workflows/cla.yaml
vendored
|
|
@ -1,9 +1,9 @@
|
|||
name: "CLA Assistant"
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
types: [ created ]
|
||||
pull_request_target:
|
||||
types: [opened, closed, synchronize]
|
||||
types: [ opened, closed, synchronize ]
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
|
|
@ -18,7 +18,7 @@ jobs:
|
|||
if: github.repository == 'continuedev/continue'
|
||||
steps:
|
||||
- name: "CLA Assistant"
|
||||
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
|
||||
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 }}
|
||||
|
|
@ -26,4 +26,4 @@ jobs:
|
|||
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]
|
||||
allowlist: dependabot[bot]
|
||||
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>
|
||||
|
|
@ -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)
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -64,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
|
||||
|
|
|
|||
20
binary/package-lock.json
generated
20
binary/package-lock.json
generated
|
|
@ -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",
|
||||
|
|
@ -3196,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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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") ||
|
||||
|
|
|
|||
|
|
@ -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,6 +26,7 @@ export const sharedConfigSchema = z
|
|||
codeWrap: z.boolean(),
|
||||
displayRawMarkdown: z.boolean(),
|
||||
showChatScrollbar: z.boolean(),
|
||||
autoAcceptEditToolDiffs: z.boolean(),
|
||||
|
||||
// `tabAutocompleteOptions` in `ContinueConfig`
|
||||
useAutocompleteCache: z.boolean(),
|
||||
|
|
@ -106,8 +107,7 @@ export function modifyAnyConfigWithSharedConfig<
|
|||
sharedConfig.disableAutocompleteInFiles;
|
||||
}
|
||||
if (sharedConfig.modelTimeout !== undefined) {
|
||||
configCopy.tabAutocompleteOptions.modelTimeout =
|
||||
sharedConfig.modelTimeout;
|
||||
configCopy.tabAutocompleteOptions.modelTimeout = sharedConfig.modelTimeout;
|
||||
}
|
||||
if (sharedConfig.debounceDelay !== undefined) {
|
||||
configCopy.tabAutocompleteOptions.debounceDelay =
|
||||
|
|
@ -134,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;
|
||||
|
|
|
|||
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}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
52
core/index.d.ts
vendored
52
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>;
|
||||
}
|
||||
|
||||
|
|
@ -1167,6 +1168,7 @@ export interface MCPResource {
|
|||
description?: string;
|
||||
mimeType?: string;
|
||||
}
|
||||
|
||||
export interface MCPTool {
|
||||
name: string;
|
||||
description?: string;
|
||||
|
|
@ -1192,6 +1194,7 @@ export interface ContinueUIConfig {
|
|||
showChatScrollbar?: boolean;
|
||||
codeWrap?: boolean;
|
||||
showSessionTabs?: boolean;
|
||||
autoAcceptEditToolDiffs?: boolean;
|
||||
}
|
||||
|
||||
export interface ContextMenuConfig {
|
||||
|
|
@ -1229,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: {
|
||||
|
|
@ -1238,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.
|
||||
|
|
@ -1497,17 +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-chat"
|
||||
| "default-agent"
|
||||
| "model-chat-options"
|
||||
| "model-agent-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,
|
||||
);
|
||||
}
|
||||
|
|
@ -230,6 +230,7 @@ describe("LLM", () => {
|
|||
testFim: true,
|
||||
skip: false,
|
||||
testToolCall: true,
|
||||
timeout: 60000,
|
||||
},
|
||||
);
|
||||
testLLM(
|
||||
|
|
|
|||
|
|
@ -23,6 +23,29 @@ const matchesGlobs = (
|
|||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Filters rules that apply to the given message
|
||||
*/
|
||||
export const getApplicableRules = (
|
||||
userMessage: UserChatMessage | ToolResultChatMessage | undefined,
|
||||
rules: RuleWithSource[],
|
||||
): RuleWithSource[] => {
|
||||
const filePathsFromMessage = userMessage
|
||||
? extractPathsFromCodeBlocks(renderChatMessage(userMessage))
|
||||
: [];
|
||||
|
||||
return rules.filter((rule) => {
|
||||
// A rule is active if it has no globs (applies to all files)
|
||||
// or if at least one file path matches its globs
|
||||
const hasNoGlobs = !rule.globs;
|
||||
const matchesAnyFilePath = filePathsFromMessage.some((path) =>
|
||||
matchesGlobs(path, rule.globs),
|
||||
);
|
||||
|
||||
return hasNoGlobs || matchesAnyFilePath;
|
||||
});
|
||||
};
|
||||
|
||||
export const getSystemMessageWithRules = ({
|
||||
baseSystemMessage,
|
||||
userMessage,
|
||||
|
|
@ -32,23 +55,11 @@ export const getSystemMessageWithRules = ({
|
|||
userMessage: UserChatMessage | ToolResultChatMessage | undefined;
|
||||
rules: RuleWithSource[];
|
||||
}) => {
|
||||
const filePathsFromMessage = userMessage
|
||||
? extractPathsFromCodeBlocks(renderChatMessage(userMessage))
|
||||
: [];
|
||||
|
||||
const applicableRules = getApplicableRules(userMessage, rules);
|
||||
let systemMessage = baseSystemMessage ?? "";
|
||||
|
||||
for (const rule of rules) {
|
||||
// A rule is active if it has no globs (applies to all files)
|
||||
// or if at least one file path matches its globs
|
||||
const hasNoGlobs = !rule.globs;
|
||||
const matchesAnyFilePath = filePathsFromMessage.some((path) =>
|
||||
matchesGlobs(path, rule.globs),
|
||||
);
|
||||
|
||||
if (hasNoGlobs || matchesAnyFilePath) {
|
||||
systemMessage += `\n\n${rule.rule}`;
|
||||
}
|
||||
for (const rule of applicableRules) {
|
||||
systemMessage += `\n\n${rule.rule}`;
|
||||
}
|
||||
|
||||
return systemMessage;
|
||||
|
|
|
|||
72
core/llm/stream.test.ts
Normal file
72
core/llm/stream.test.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { Readable } from "stream";
|
||||
import { streamSse } from "./stream";
|
||||
|
||||
function createMockResponse(sseLines: string[]): Response {
|
||||
// Create a Readable stream that emits the SSE lines
|
||||
const stream = new Readable({
|
||||
read() {
|
||||
for (const line of sseLines) {
|
||||
this.push(line + "\n\n");
|
||||
}
|
||||
this.push(null); // End of stream
|
||||
}
|
||||
}) as any;
|
||||
|
||||
// Minimal Response mock
|
||||
return {
|
||||
status: 200,
|
||||
body: stream,
|
||||
text: async () => "",
|
||||
} as unknown as Response;
|
||||
}
|
||||
|
||||
describe("streamSse", () => {
|
||||
it("yields parsed SSE data objects that ends with `data:[DONE]`", async () => {
|
||||
const sseLines = [
|
||||
'data: {"foo": "bar"}',
|
||||
'data: {"baz": 42}',
|
||||
'data:[DONE]'
|
||||
];
|
||||
const response = createMockResponse(sseLines);
|
||||
|
||||
const results = [];
|
||||
for await (const data of streamSse(response)) {
|
||||
results.push(data);
|
||||
}
|
||||
|
||||
expect(results).toEqual([
|
||||
{ foo: "bar" },
|
||||
{ baz: 42 }
|
||||
]);
|
||||
});
|
||||
|
||||
it("yields parsed SSE data objects that ends with `data: [DONE]` (with a space before [DONE]", async () => {
|
||||
const sseLines = [
|
||||
'data: {"foo": "bar"}',
|
||||
'data: {"baz": 42}',
|
||||
'data: [DONE]'
|
||||
];
|
||||
const response = createMockResponse(sseLines);
|
||||
|
||||
const results = [];
|
||||
for await (const data of streamSse(response)) {
|
||||
results.push(data);
|
||||
}
|
||||
|
||||
expect(results).toEqual([
|
||||
{ foo: "bar" },
|
||||
{ baz: 42 }
|
||||
]);
|
||||
});
|
||||
|
||||
it("throws on malformed JSON", async () => {
|
||||
const sseLines = [
|
||||
'data: {"foo": "bar"',
|
||||
'data:[DONE]'
|
||||
];
|
||||
const response = createMockResponse(sseLines);
|
||||
|
||||
const iterator = streamSse(response)[Symbol.asyncIterator]();
|
||||
await expect(iterator.next()).rejects.toThrow(/Malformed JSON/);
|
||||
});
|
||||
});
|
||||
|
|
@ -58,7 +58,7 @@ function parseDataLine(line: string): any {
|
|||
}
|
||||
|
||||
function parseSseLine(line: string): { done: boolean; data: any } {
|
||||
if (line.startsWith("data: [DONE]")) {
|
||||
if (line.startsWith("data:[DONE]") || line.startsWith("data: [DONE]")) {
|
||||
return { done: true, data: undefined };
|
||||
}
|
||||
if (line.startsWith("data:")) {
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ export const gptEditPrompt: PromptTemplateFunction = (history, otherData) => {
|
|||
\`\`\`
|
||||
|
||||
The user's request is: "${otherData.userInput}"
|
||||
|
||||
DO NOT output any natural language, only output the code changes.
|
||||
|
||||
Here is the rewritten code:`);
|
||||
|
||||
|
|
|
|||
6
core/package-lock.json
generated
6
core/package-lock.json
generated
|
|
@ -15266,9 +15266,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "6.21.1",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz",
|
||||
"integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==",
|
||||
"version": "6.21.3",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz",
|
||||
"integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.17"
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ export function slashCommandFromPromptFileV1(
|
|||
name,
|
||||
description,
|
||||
prompt,
|
||||
promptFile: path,
|
||||
run: async function* (context) {
|
||||
const userInput = extractUserInput(context.input, name);
|
||||
const [_, renderedPrompt] = await renderPromptFileV2(prompt, {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { AutocompleteInput } from "../autocomplete/util/types";
|
|||
import { SharedConfigSchema } from "../config/sharedConfig";
|
||||
import { GlobalContextModelSelections } from "../util/GlobalContext";
|
||||
|
||||
import type {
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ChatMessage,
|
||||
ContextItem,
|
||||
|
|
@ -29,6 +29,7 @@ import type {
|
|||
SessionMetadata,
|
||||
SiteIndexingConfig,
|
||||
SlashCommandDescription,
|
||||
StreamDiffLinesPayload,
|
||||
ToolCall,
|
||||
} from "../";
|
||||
import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager";
|
||||
|
|
@ -142,18 +143,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
},
|
||||
AsyncGenerator<ChatMessage, PromptLog>,
|
||||
];
|
||||
streamDiffLines: [
|
||||
{
|
||||
prefix: string;
|
||||
highlighted: string;
|
||||
suffix: string;
|
||||
input: string;
|
||||
language: string | undefined;
|
||||
modelTitle: string | undefined;
|
||||
includeRulesInSystemMessage: boolean;
|
||||
},
|
||||
AsyncGenerator<DiffLine>,
|
||||
];
|
||||
streamDiffLines: [StreamDiffLinesPayload, AsyncGenerator<DiffLine>];
|
||||
"chatDescriber/describe": [
|
||||
{
|
||||
text: string;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import { ToIdeFromWebviewOrCoreProtocol } from "./ide";
|
||||
import { ToWebviewFromIdeOrCoreProtocol } from "./webview";
|
||||
|
||||
import type {
|
||||
import {
|
||||
ApplyState,
|
||||
CodeToEdit,
|
||||
SetCodeToEditPayload,
|
||||
HighlightedCodePayload,
|
||||
MessageContent,
|
||||
RangeInFileWithContents,
|
||||
AcceptOrRejectDiffPayload,
|
||||
} from "../";
|
||||
|
||||
export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
||||
|
|
@ -42,8 +44,8 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
"jetbrains/getColors": [undefined, Record<string, string>];
|
||||
"vscode/openMoveRightMarkdown": [undefined, void];
|
||||
setGitHubAuthToken: [{ token: string }, void];
|
||||
acceptDiff: [{ filepath: string; streamId?: string }, void];
|
||||
rejectDiff: [{ filepath: string; streamId?: string }, void];
|
||||
acceptDiff: [AcceptOrRejectDiffPayload, void];
|
||||
rejectDiff: [AcceptOrRejectDiffPayload, void];
|
||||
"edit/sendPrompt": [
|
||||
{
|
||||
prompt: MessageContent;
|
||||
|
|
@ -63,15 +65,8 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
focusContinueInput: [undefined, void];
|
||||
focusContinueInputWithoutClear: [undefined, void];
|
||||
focusContinueInputWithNewSession: [undefined, void];
|
||||
highlightedCode: [
|
||||
{
|
||||
rangeInFileWithContents: RangeInFileWithContents;
|
||||
prompt?: string;
|
||||
shouldRun?: boolean;
|
||||
},
|
||||
void,
|
||||
];
|
||||
setCodeToEdit: [CodeToEdit, void];
|
||||
highlightedCode: [HighlightedCodePayload, void];
|
||||
setCodeToEdit: [SetCodeToEditPayload, void];
|
||||
navigateTo: [{ path: string; toggle?: boolean }, void];
|
||||
addModel: [undefined, void];
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@ async function callHttpTool(
|
|||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to call tool: ${url}`);
|
||||
throw new Error(`Failed to call tool at ${url}:\n${JSON.stringify(data)}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.output;
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ async function callToolFromUri(
|
|||
});
|
||||
|
||||
if (response.isError === true) {
|
||||
throw new Error(`Failed to call tool: ${toolName}`);
|
||||
throw new Error(JSON.stringify(response.content));
|
||||
}
|
||||
|
||||
const contextItems: ContextItem[] = [];
|
||||
|
|
@ -130,6 +131,37 @@ async function callToolFromUri(
|
|||
}
|
||||
}
|
||||
|
||||
async function callBuiltInTool(
|
||||
functionName: string,
|
||||
args: any,
|
||||
extras: ToolExtras,
|
||||
): Promise<ContextItem[]> {
|
||||
switch (functionName) {
|
||||
case BuiltInToolNames.ReadFile:
|
||||
return await readFileImpl(args, extras);
|
||||
case BuiltInToolNames.CreateNewFile:
|
||||
return await createNewFileImpl(args, extras);
|
||||
case BuiltInToolNames.GrepSearch:
|
||||
return await grepSearchImpl(args, extras);
|
||||
case BuiltInToolNames.FileGlobSearch:
|
||||
return await fileGlobSearchImpl(args, extras);
|
||||
case BuiltInToolNames.RunTerminalCommand:
|
||||
return await runTerminalCommandImpl(args, extras);
|
||||
case BuiltInToolNames.SearchWeb:
|
||||
return await searchWebImpl(args, extras);
|
||||
case BuiltInToolNames.ViewDiff:
|
||||
return await viewDiffImpl(args, extras);
|
||||
case BuiltInToolNames.LSTool:
|
||||
return await lsToolImpl(args, extras);
|
||||
case BuiltInToolNames.ReadCurrentlyOpenFile:
|
||||
return await readCurrentlyOpenFileImpl(args, extras);
|
||||
case BuiltInToolNames.CreateRuleBlock:
|
||||
return await createRuleBlockImpl(args, extras);
|
||||
default:
|
||||
throw new Error(`Tool "${functionName}" not found`);
|
||||
}
|
||||
}
|
||||
|
||||
// Handles calls for core/non-client tools
|
||||
// Returns an error context item if the tool call fails
|
||||
// Note: Edit tool is handled on client
|
||||
|
|
@ -141,44 +173,11 @@ export async function callTool(
|
|||
contextItems: ContextItem[];
|
||||
errorMessage: string | undefined;
|
||||
}> {
|
||||
const args = JSON.parse(callArgs || "{}");
|
||||
const uri = tool.uri ?? tool.function.name;
|
||||
try {
|
||||
let contextItems: ContextItem[] = [];
|
||||
switch (uri) {
|
||||
case BuiltInToolNames.ReadFile:
|
||||
contextItems = await readFileImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.CreateNewFile:
|
||||
contextItems = await createNewFileImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.GrepSearch:
|
||||
contextItems = await grepSearchImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.FileGlobSearch:
|
||||
contextItems = await fileGlobSearchImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.RunTerminalCommand:
|
||||
contextItems = await runTerminalCommandImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.SearchWeb:
|
||||
contextItems = await searchWebImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.ViewDiff:
|
||||
contextItems = await viewDiffImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.LSTool:
|
||||
contextItems = await lsToolImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.ReadCurrentlyOpenFile:
|
||||
contextItems = await readCurrentlyOpenFileImpl(args, extras);
|
||||
break;
|
||||
case BuiltInToolNames.CreateRuleBlock:
|
||||
contextItems = await createRuleBlockImpl(args, extras);
|
||||
break;
|
||||
default:
|
||||
contextItems = await callToolFromUri(uri, args, extras);
|
||||
}
|
||||
const args = JSON.parse(callArgs || "{}");
|
||||
const contextItems = tool.uri
|
||||
? await callToolFromUri(tool.uri, args, extras)
|
||||
: await callBuiltInTool(tool.function.name, args, extras);
|
||||
if (tool.faviconUrl) {
|
||||
contextItems.forEach((item) => {
|
||||
item.icon = tool.faviconUrl;
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
# Changelog
|
||||
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).
|
||||
|
||||
|
|
@ -17,6 +17,13 @@ past and future “Contributions” submitted to **Continue (the “Project”)*
|
|||
|
||||
## 2. Copyright License
|
||||
|
||||
You grant **Continue Dev, Inc.** and all recipients of software distributed by the
|
||||
Project a perpetual, worldwide, non‑exclusive, royalty‑free, irrevocable
|
||||
license to reproduce, prepare derivative works of, publicly display, publicly
|
||||
perform, sublicense, and distribute Your Contributions and derivative works.
|
||||
|
||||
## 3. Patent License
|
||||
|
||||
You grant **Continue Dev, Inc.** and all recipients of the Project a perpetual,
|
||||
worldwide, non‑exclusive, royalty‑free, irrevocable (except as below) patent
|
||||
license to make, have made, use, sell, offer to sell, import, and otherwise
|
||||
|
|
@ -38,4 +45,4 @@ entity under this CLA terminate.
|
|||
|
||||
This Agreement is governed by the laws of the **State of California**, USA,
|
||||
excluding its conflict‑of‑laws rules. If any provision is held unenforceable,
|
||||
the remaining provisions remain in force.
|
||||
the remaining provisions remain in force.
|
||||
|
|
|
|||
13
docs/docs/customize/changelog.md
Normal file
13
docs/docs/customize/changelog.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: Continue Changelog
|
||||
description: Redirecting to our Changelog
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
# Redirecting to Changelog
|
||||
|
||||
If you are not redirected automatically, follow this [link to the changelog](https://changelog.continue.dev).
|
||||
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;url=https://changelog.continue.dev" />
|
||||
</head>
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
---
|
||||
title: Changelog
|
||||
description: Changelogs for the latest releases of the VSCode and JetBrains extensions
|
||||
keywords: [changelog]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
import VSCodeChangelog from "../../../extensions/vscode/CHANGELOG.md";
|
||||
import JetBrainsChangelog from "../../../extensions/intellij/CHANGELOG.md";
|
||||
|
||||
Below are the changelogs for the latest releases of the VSCode and JetBrains extensions. Prior to 2024-07-02, the changelogs do not reflect all updates.
|
||||
|
||||
import TOCInline from "@theme/TOCInline";
|
||||
|
||||
<TOCInline
|
||||
toc={toc.filter(
|
||||
(node) =>
|
||||
node.value === "VSCode Changelog" || node.value === "JetBrains Changelog",
|
||||
)}
|
||||
/>
|
||||
|
||||
<hr />
|
||||
|
||||
## VSCode Changelog
|
||||
|
||||
<VSCodeChangelog />
|
||||
|
||||
## JetBrains Changelog
|
||||
|
||||
<JetBrainsChangelog />
|
||||
|
|
@ -6,11 +6,11 @@ keywords: [config, settings, configuration, customize, customization, sidebar]
|
|||
|
||||
# The User Settings Page
|
||||
|
||||
The **User Settings page** can be accessed by clicking the gear icon in the header of the Continue sidebar.
|
||||
The **User Settings page** can be accessed by clicking the gear icon in the header of the Continue sidebar and then selecting the "Settings" tab.
|
||||
|
||||

|
||||

|
||||
|
||||
Which takes you to this page:
|
||||
Which takes you to this page (select the "Settings" tab):
|
||||
|
||||

|
||||
|
||||
|
|
@ -26,7 +26,15 @@ Below that, the following settings which are not part of a configuration file ar
|
|||
- `Enable Indexing`: Enables indexing of the codebase for the @codebase and @code context providers. **On** by default.
|
||||
- `Font Size`: Specifies base font size for UI elements
|
||||
- `Multiline Autocompletions`: Controls multiline completions for autocomplete. Can be set to `always`, `never`, or `auto`. Defaults to `auto`
|
||||
- `Disable autocomplete in files`: List of comma-separated glob pattern to disable autocomplete in matching files. E.g., "\_/.md, \*/.txt"
|
||||
- `Autocomplete timeout`: Maximum time in milliseconds for autocomplete request/retreival. Defaults to 150
|
||||
- `Autocomplete debounce`: Minimum time in milliseconds to trigger an autocomplete request after a change. Defaults to 250
|
||||
- `Disable autocomplete in files`: List of comma-separated glob pattern to disable autocomplete in matching files. E.g., `**/*.{txt,md}`
|
||||
|
||||
### Experimental settings
|
||||
|
||||
At the bottom of the User Settings page there is an "Experimental Settings" section which contains new or otherwise experimental settings, including:
|
||||
|
||||
- `Auto-Accept Agent Edits`: **CAUTION: Be very careful with this setting. When turned on, Agent mode's edit tool can make changes to files with no manual review or guaranteed stopping point. If on, diffs generated by the edit tool are automatically accepted and Agent proceeds with the next conversational turn.** Off by default.
|
||||
|
||||
<!-- - `Use autocomplete cache`: If on, caches completions. -->
|
||||
<!-- - `Use Chromium for Docs Crawling`: Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to ~/.continue/.utils. Off by default -->
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ keywords: [reload, delete, manually, logs, server, console]
|
|||
import TabItem from "@theme/TabItem";
|
||||
import Tabs from "@theme/Tabs";
|
||||
|
||||
The Continue VS Code extension is currently in beta, and the JetBrains extension is in Alpha. If you are having trouble, please follow the steps below.
|
||||
|
||||
1. [Check the logs](#check-the-logs)
|
||||
2. [Try the latest pre-release](#download-the-latest-pre-release)
|
||||
3. [Download an older version](#download-an-older-version)
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ const config = {
|
|||
],
|
||||
],
|
||||
|
||||
scripts: [
|
||||
'!function(){var e,t,n;e="7aa28ed11570734",t=function(){Reo.init({clientID:"7aa28ed11570734"})},(n=document.createElement("script")).src="https://static.reo.dev/"+e+"/reo.js",n.defer=!0,n.onload=t,document.head.appendChild(n)}();',
|
||||
],
|
||||
|
||||
themeConfig:
|
||||
/** @type {import("@docusaurus/preset-classic").ThemeConfig} */
|
||||
({
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
---
|
||||
title: 变更日志
|
||||
description: VSCode 和 JetBrains 扩展最新版本的变更日志
|
||||
keywords: [变更日志]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
import VSCodeChangelog from "../../../../../../extensions/vscode/CHANGELOG.md";
|
||||
import JetBrainsChangelog from "../../../../../../extensions/intellij/CHANGELOG.md";
|
||||
|
||||
以下是 VSCode 和 JetBrains 扩展最新版本的变更日志。在 2024-07-02 之前,变更日志没有反映所有更新。
|
||||
|
||||
import TOCInline from "@theme/TOCInline";
|
||||
|
||||
<TOCInline
|
||||
toc={toc.filter(
|
||||
(node) =>
|
||||
node.value === "VSCode Changelog" || node.value === "JetBrains Changelog",
|
||||
)}
|
||||
/>
|
||||
|
||||
<hr />
|
||||
|
||||
## VSCode 变更日志
|
||||
|
||||
<VSCodeChangelog />
|
||||
|
||||
## JetBrains 变更日志
|
||||
|
||||
<JetBrainsChangelog />
|
||||
BIN
docs/static/img/header-buttons.png
vendored
BIN
docs/static/img/header-buttons.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 6.2 KiB |
BIN
docs/static/img/settings-header.png
vendored
Normal file
BIN
docs/static/img/settings-header.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Start Core Dev Server (CE)" type="ShConfigurationType">
|
||||
<option name="SCRIPT_TEXT" value="cross-env 'PROJECT_DIR="$PROJECT_DIR$"' node core-dev-server.js" />
|
||||
<option name="SCRIPT_TEXT" value="npx cross-env 'PROJECT_DIR="$PROJECT_DIR$"' node core-dev-server.js" />
|
||||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
||||
<option name="SCRIPT_PATH" value="" />
|
||||
<option name="SCRIPT_OPTIONS" value="" />
|
||||
|
|
|
|||
|
|
@ -1,104 +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.0.0 - 2025-02-26
|
||||
### Added
|
||||
* Introduces hub.continue.dev
|
||||
* Improved theme matching
|
||||
### Fixed
|
||||
* Fixes interference between SonarQube and Continue autocomplete
|
||||
* Numerous reliability improvements
|
||||
|
||||
## 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
|
||||
|
||||
## 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
|
||||
|
||||
## 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
|
||||
|
||||
## 0.0.54 - 2024-07-13
|
||||
### Added
|
||||
* Partial autocomplete acceptance
|
||||
* Autocomplete status bar spinner
|
||||
### Fixed
|
||||
* Fixed duplicate completion bug and others
|
||||
|
||||
## 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
|
||||
|
||||
## 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
|
||||
|
||||
## 0.0.38 - 2024-03-15
|
||||
### Added
|
||||
* Remote config server support
|
||||
* Autocomplete support in JetBrains
|
||||
|
||||
## 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
|
||||
|
||||
## v0.0.26 - 2023-12-28
|
||||
### Added
|
||||
* auto-reloading of config on save
|
||||
### Fixed
|
||||
* Fixed /edit bug for versions without Python server
|
||||
|
||||
## v0.0.25 - 2023-12-25
|
||||
|
||||
### Changed
|
||||
|
||||
- Intellij extension no longer relies on the Continue Python server
|
||||
|
||||
## v0.0.21 - 2023-12-05
|
||||
|
||||
### Added
|
||||
|
||||
- updated to match latest VS Code updates
|
||||
|
||||
## v0.0.19 - 2023-11-19
|
||||
|
||||
### Changed
|
||||
|
||||
- migrated to .json config file format
|
||||
|
||||
## v0.0.1 - 2023-09-01
|
||||
|
||||
### Added
|
||||
|
||||
- Initial scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template)
|
||||
|
|
@ -173,6 +173,12 @@ to run.
|
|||
./gradlew test
|
||||
```
|
||||
|
||||
Run a single test
|
||||
|
||||
```sh
|
||||
./gradlew test --tests "com.github.continuedev.continueintellijextension.e2e.TESTNAME"
|
||||
```
|
||||
|
||||
#### Identifying selectors
|
||||
|
||||
While the `runIdeForUiTests` task is running, you can visit the following URL
|
||||
|
|
|
|||
|
|
@ -42,10 +42,12 @@ dependencies {
|
|||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
|
||||
testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion")
|
||||
testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
|
||||
testImplementation("io.mockk:mockk:1.14.2")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
|
||||
testImplementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
|
||||
implementation("com.automation-remarks:video-recorder-junit5:2.0")
|
||||
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
|
||||
|
||||
|
||||
// Exclude vulnerable Log4j from all dependencies
|
||||
|
|
@ -62,6 +64,7 @@ dependencies {
|
|||
// Add Log4j 2.x explicitly
|
||||
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
|
||||
implementation("org.apache.logging.log4j:log4j-api:2.20.0")
|
||||
testImplementation(kotlin("test"))
|
||||
}
|
||||
|
||||
// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for
|
||||
|
|
@ -162,6 +165,7 @@ tasks {
|
|||
// This is to ensure we load the GUI with OSR enabled. We have logic that
|
||||
// renders with OSR disabled below a particular IDE version.
|
||||
// See ContinueExtensionSettingsService.kt for more info.
|
||||
// Currently commented out however since test fail in CI with this version
|
||||
// intellij {
|
||||
// version.set("2024.1")
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ pluginSinceBuild=223
|
|||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
platformType=IC
|
||||
platformVersion=2022.3.3
|
||||
#org.gradle.java.home=/opt/homebrew/opt/openjdk@17
|
||||
# org.gradle.java.home=/opt/homebrew/opt/openjdk@17
|
||||
#platformVersion = LATEST-EAP-SNAPSHOT
|
||||
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
|
||||
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.github.continuedev.continueintellijextension.activities
|
||||
|
||||
import IntelliJIDE
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener
|
||||
import com.github.continuedev.continueintellijextension.auth.AuthListener
|
||||
import com.github.continuedev.continueintellijextension.auth.ContinueAuthService
|
||||
|
|
|
|||
|
|
@ -0,0 +1,187 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.github.continuedev.continueintellijextension.ApplyState
|
||||
import com.github.continuedev.continueintellijextension.ApplyStateStatus
|
||||
import com.github.continuedev.continueintellijextension.IDE
|
||||
import com.github.continuedev.continueintellijextension.ToastType
|
||||
import com.github.continuedev.continueintellijextension.editor.DiffStreamHandler
|
||||
import com.github.continuedev.continueintellijextension.editor.DiffStreamService
|
||||
import com.github.continuedev.continueintellijextension.editor.EditorUtils
|
||||
import com.github.continuedev.continueintellijextension.protocol.ApplyToFileParams
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.github.continuedev.continueintellijextension.utils.castNestedOrNull
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
/**
|
||||
* Handles applying text to a file with streaming diff preview
|
||||
*/
|
||||
class ApplyToFileHandler(
|
||||
private val project: Project,
|
||||
private val continuePluginService: ContinuePluginService,
|
||||
private val ide: IDE,
|
||||
private val params: ApplyToFileParams,
|
||||
private val editorUtils: EditorUtils?,
|
||||
private val diffStreamService: DiffStreamService
|
||||
) {
|
||||
|
||||
suspend fun handleApplyToFile() {
|
||||
// Notify webview that we're starting to stream
|
||||
notifyStreamStarted()
|
||||
|
||||
if (editorUtils == null) {
|
||||
ide.showToast(ToastType.ERROR, "No active editor to apply edits to")
|
||||
notifyStreamClosed()
|
||||
return
|
||||
}
|
||||
|
||||
if (editorUtils.isDocumentEmpty()) {
|
||||
editorUtils.insertTextIntoEmptyDocument(params.text)
|
||||
notifyStreamClosed()
|
||||
return
|
||||
}
|
||||
|
||||
// Get the LLM configuration for applying edits
|
||||
val llm = fetchApplyLLMConfig() ?: run {
|
||||
ide.showToast(ToastType.ERROR, "Failed to fetch model configuration")
|
||||
notifyStreamClosed()
|
||||
return
|
||||
}
|
||||
|
||||
setupAndStreamDiffs(editorUtils, llm)
|
||||
}
|
||||
|
||||
private fun notifyStreamStarted() {
|
||||
sendApplyStateUpdate(ApplyStateStatus.STREAMING)
|
||||
}
|
||||
|
||||
private fun notifyStreamClosed(numDiffs: Int? = 0) {
|
||||
sendApplyStateUpdate(ApplyStateStatus.CLOSED, numDiffs)
|
||||
}
|
||||
|
||||
private fun sendApplyStateUpdate(
|
||||
status: ApplyStateStatus,
|
||||
numDiffs: Int? = null
|
||||
) {
|
||||
val payload = ApplyState(
|
||||
streamId = params.streamId,
|
||||
status = status.status,
|
||||
numDiffs = numDiffs,
|
||||
filepath = params.filepath,
|
||||
fileContent = params.text,
|
||||
toolCallId = params.toolCallId.toString()
|
||||
)
|
||||
|
||||
continuePluginService.sendToWebview("updateApplyState", payload)
|
||||
}
|
||||
|
||||
private suspend fun fetchApplyLLMConfig(): Any? {
|
||||
return try {
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
continuePluginService.coreMessenger?.request(
|
||||
"config/getSerializedProfileInfo",
|
||||
null,
|
||||
null
|
||||
) { response ->
|
||||
try {
|
||||
val selectedModels = response.castNestedOrNull<Map<String, Any>>(
|
||||
"content",
|
||||
"result",
|
||||
"config",
|
||||
"selectedModelByRole"
|
||||
)
|
||||
|
||||
// If "apply" role model is not found, try "chat" role
|
||||
val applyCodeBlockModel = selectedModels?.get("apply") ?: selectedModels?.get("chat")
|
||||
|
||||
if (applyCodeBlockModel != null) {
|
||||
continuation.resume(applyCodeBlockModel)
|
||||
} else {
|
||||
// If neither "apply" nor "chat" models are available, return with exception
|
||||
continuation.resumeWithException(IllegalStateException("No 'apply' or 'chat' model found in configuration."))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
continuation.resumeWithException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAndStreamDiffs(editorUtils: EditorUtils, llm: Any) {
|
||||
// Clear all diff blocks before running the diff stream
|
||||
diffStreamService.reject(editorUtils.editor)
|
||||
|
||||
val llmTitle = (llm as? Map<*, *>)?.get("title") as? String ?: ""
|
||||
val prompt = buildApplyPrompt()
|
||||
|
||||
// Extract the code ranges (highlighted or full document)
|
||||
val (prefix, highlighted, suffix) = editorUtils.extractCodeRanges()
|
||||
|
||||
// Get the line range for the diff stream
|
||||
val rif = editorUtils.getHighlightedCode()
|
||||
val startLine = rif?.range?.start?.line ?: 0
|
||||
val endLine = rif?.range?.end?.line ?: (editorUtils.getLineCount() - 1)
|
||||
|
||||
// Create and register the diff stream handler
|
||||
val diffStreamHandler = createDiffStreamHandler(editorUtils.editor, startLine, endLine)
|
||||
diffStreamService.register(diffStreamHandler, editorUtils.editor)
|
||||
|
||||
// Stream the diffs
|
||||
diffStreamHandler.streamDiffLinesToEditor(
|
||||
prompt, prefix, highlighted, suffix, llmTitle, false
|
||||
)
|
||||
}
|
||||
|
||||
private fun buildApplyPrompt(): String {
|
||||
return "The following code was suggested as an edit:\n```\n${params.text}\n```\nPlease apply it to the previous code."
|
||||
}
|
||||
|
||||
private fun createDiffStreamHandler(
|
||||
editor: Editor,
|
||||
startLine: Int,
|
||||
endLine: Int
|
||||
): DiffStreamHandler {
|
||||
return DiffStreamHandler(
|
||||
project,
|
||||
editor,
|
||||
startLine,
|
||||
endLine,
|
||||
{},
|
||||
{},
|
||||
params.streamId,
|
||||
params.toolCallId.toString()
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Factory method to create and execute a new handler for a single apply-to-file operation
|
||||
*/
|
||||
suspend fun apply(
|
||||
project: Project,
|
||||
continuePluginService: ContinuePluginService,
|
||||
ide: IDE,
|
||||
params: ApplyToFileParams
|
||||
) {
|
||||
val editorUtils = EditorUtils.getOrOpenEditor(project, params.filepath)
|
||||
val diffStreamService = project.getService(DiffStreamService::class.java)
|
||||
|
||||
val handler = ApplyToFileHandler(
|
||||
project,
|
||||
continuePluginService,
|
||||
ide,
|
||||
params,
|
||||
editorUtils,
|
||||
diffStreamService
|
||||
)
|
||||
|
||||
handler.handleApplyToFile()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ class DiffManager(private val project: Project) : DumbAware {
|
|||
file.createNewFile()
|
||||
}
|
||||
file.writeText(replacement)
|
||||
openDiffWindow(URI(filepath).toString(), file.toURI().toString(), stepIndex)
|
||||
openDiffWindow(UriUtils.parseUri(filepath).toString(), file.toURI().toString(), stepIndex)
|
||||
}
|
||||
|
||||
private fun cleanUpFile(file2: String) {
|
||||
|
|
@ -80,7 +80,8 @@ class DiffManager(private val project: Project) : DumbAware {
|
|||
val diffInfo = diffInfoMap[file] ?: return
|
||||
|
||||
// Write contents to original file
|
||||
val virtualFile = LocalFileSystem.getInstance().findFileByPath(URI(diffInfo.originalFilepath).path) ?: return
|
||||
val virtualFile =
|
||||
LocalFileSystem.getInstance().findFileByPath(UriUtils.parseUri(diffInfo.originalFilepath).path) ?: return
|
||||
val document = FileDocumentManager.getInstance().getDocument(virtualFile) ?: return
|
||||
WriteCommandAction.runWriteCommandAction(project) {
|
||||
document.setText(File(file).readText())
|
||||
|
|
@ -119,8 +120,8 @@ class DiffManager(private val project: Project) : DumbAware {
|
|||
lastFile2 = file2
|
||||
|
||||
// Create a DiffContent for each of the texts you want to compare
|
||||
val content1: DiffContent = DiffContentFactory.getInstance().create(File(URI(file1)).readText())
|
||||
val content2: DiffContent = DiffContentFactory.getInstance().create(File(URI(file2)).readText())
|
||||
val content1: DiffContent = DiffContentFactory.getInstance().create(UriUtils.uriToFile(file1).readText())
|
||||
val content2: DiffContent = DiffContentFactory.getInstance().create(UriUtils.uriToFile(file2).readText())
|
||||
|
||||
// Create a SimpleDiffRequest and populate it with the DiffContents and titles
|
||||
val diffRequest = SimpleDiffRequest("Continue Diff", content1, content2, "Old", "New")
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue