Dev (#1740)
* Nate/control plane client (#1691) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * fix(gui): ctx rendering w/ renderInlineAs: "" (#1541) * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * fix codeqwen autocomplete leading space * add voyage rerank-1 * feat: `--noEmit` for tsc checks in CI (#1559) * docs: update CustomContextProvider docs (#1557) * add stop tokens to qwen prompt * update docs to reflect 3.5 sonnet being best * docs: comment out unused providers (#1561) * import Handlebars * feat: toast notification for config updates (#1560) * feat: toast notification for config updates * feat: only trigger toast on config.json save * displayRawMarkdown option * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * update to reflect 16 stop words limit for deepseek * feat: only trigger config update toast in vscode (#1571) * docs(prompt-files): fix typos + clarify (#1575) * doc: prompt file typo + clarifications * fix: add back correct docs * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * docs(telemetry): add pageviews to tracking list (#1581) * Add reranker configuration options to codebase embedding docs (#1584) - Introduce reranker concept - List available reranker options - Provide configuration instructions - Update keywords to include "reranker" * chore: update pr template with screenshots (#1590) * Refactor ConfirmationDialog to use SecondaryButton for cancel action (#1586) * Added instructions for running docs server locally (#1578) - Added NPM script method - Added VS Code task method - Update contributing guidelines * Update branch policy (#1577) - Change PR target to `dev` branch - Update `CONTRIBUTING.md` instructions * Consolidate example configurations into the main configuration guide (#1579) - Moved examples to configuration.md - Deleted the separate examples.md file - Updated sidebar order and links - Improved readability and structure in configuration.md * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * Update completionProvider.ts (warning tab-autocomplete models) (#1566) * feat: enhanced IndexingProgressBar with blinking dot feature - Integrated BlinkingDot component - Added STATUS_COLORS for various states - Replaced CircleDiv with BlinkingDot in UI - Updated status messages and layout * small UI tweaks * feat(gui): enhance ModelCard, ModelProviderTag, and Toggle components (#1595) - add styling and adjustments to ModelCard - update ModelProviderTag font size - remove box shadow from Toggle component - tweak icon styles in ModelCard - improve alignment and spacing * media query * feat: add best experience onboarding * fix: file rename * stop movement on button hover by keeping same border thickness * fix mistake in setting cursor: pointer * fix when free trial option is shown * Support Node.js versions below 20 for streaming response handling (#1591) - Add fallback for Node < 20 - Implement toAsyncIterable for streaming - Use TextDecoder for manual decoding - Maintain existing streaming for Node 20+ * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * fix hasPassedFTL * fix /edit cancellation from UI * feat: add `applyCodeBlock` experimental prop (#1601) * feat: add new model styling improvements (#1609) * feat: add new model styling improvements * better gap size * feat: update bug_report.yml (#1610) * chore: update bug_report.yml * typo fix * feat: add labels to "Add docs" dialog (#1612) * feat: add labels to "Add docs" dialog * remove autofocus * don't double load config * small fixes * speed up directory traversal, and use correct native path module * option not to show config update toast * merge air-gapped and recommended setup pages * chore: add telemetry for full screen toggle (#1618) * Fix headings in codebase-embeddings.md (#1617) * mention jetbrains * docs: update changie (#1619) * feat: updated changie config * hide toc and autogenerate * Update changelog.mdx * link to deeper explanation of embeddings models * ensure target="_blank" for all links in sidebar * fix gif links in intellij README.md * don't require rust in dependency installation * chore: fix padding on gh button (#1620) * chore: adjust button padding * Update tasks.json * escape colons in diff path * smoother lancedb indexing reporting * smooth progress updates for indexing * fix tsc err * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * docs: add docs and schema for "OS" provider (#1536) * ignore .env * 🚑 fix constant warnings when onboarding with Ollama * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * team analytics * apply control plane settings * workos auth * ide protocol get session info * UI for auth * profile switching * small fixes * updates * refresh tokens * updates * fix tsc errs * model select in toolbar to make room for profile selector * prod client id * link to prod URL * internal beta option * profiles change listener --------- Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com> Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu <ddascalescu+github@gmail.com> * temporary patch for type errs * Dev (#1689) * Fix an issue where CMD+K does not clear the terminal when the terminal has focus (#1671) On MacOS, ⌘+K is bound, by default, to Terminal:Clear. Without this change ⌘+K does not clear the terminal but instead iniates a chord sequence and waits for the next stroke of the chord. Co-authored-by: Rob Leidle <rleidle@tesla.com> * Change treeSitter to cache the Language objects it loads from wasm (#1672) Without this change, for a repository with 600 typescript files, the indexer would fail to finish correctly and there would be many of the following errors in the webview console log: 'Unable to load language for file ${path} RuntimeError: table index is out of bounds' The following bash will create a repo that reproduces the problem: current_path="." for ((i=1; i<=20; i++)); do new_folder="folder-$i" mkdir -p "$current_path/$new_folder" current_path="$current_path/$new_folder" for ((a=1; a<=30; a++)); do head -c 10000 /dev/urandom | base64 > "$current_path/file-$a.ts" done done Co-authored-by: Rob Leidle <rleidle@tesla.com> * acknowledge sourcemap flag in esbuild.js * don't run jetbrains-release.yaml on vscode releases * further testing for walkDir * chore: add telemetry to commands (#1673) * test: Add basic unit test to baseLLM (#1668) * update version * test: Add basic unit test to baseLLM --------- Co-authored-by: Nate Sesti <sestinj@gmail.com> Co-authored-by: inimaz <imaz@ai-verse.com> * feat: add Quick Actions CodeLens feature (#1674) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * add voyage rerank-1 * import Handlebars * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * small UI tweaks * media query * feat: add best experience onboarding * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * chore: add telemetry for full screen toggle (#1618) * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * manually implement stop tokens for hf inference api * chore: onboarding metrics (#1626) * fix: pageview tracking * feat: add onboarding telemetry * create single `onboardingStatus` type * improved var naming * remove console logs * fix windows performance issue * rename vscodeExtension.ts * migration of onboarding variables * "stash" instead of "delete" in indexing progress * fix preview.yaml * also fix main.yaml * Update troubleshooting.md (#1637) * feat: add quick actions * Update index.d.ts * quick actions mvp * update docs * subscribe to vscode change settings * Update commands.ts * cleanup * Update quick-actions.md * Update VerticalPerLineCodeLensProvider.ts * resolve feedback --------- Co-authored-by: Nate Sesti <sestinj@gmail.com> Co-authored-by: Nate Sesti <33237525+sestinj@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> * chore: add `isCommandEvent` to command telemetry (#1675) * chore: add `isCommandEvent` to command telemetry * Update commands.ts * Nate/better retrieval (#1677) * deduplicatearray tests * break out separate retrieval pipelines * IConfigHandler * tests for codebase indexer * better .continueignore for continue * indexing fixes * ignore .gitignore and .continueignore when indexing * retrieval pipeline improvements * fix formatting err in out .continueignore * add necessary filter to lance_db_cache * update package.json version * skip unused tests * don't ignore .prompt files * update version * Update pull_request_template.md * don't use multi-media format when there are multiple text items * add free trial experience (#1685) * fix: add code range for quick actions/fixes (#1687) * fix: add code range for quick actions/fixes * Update test.js * add pathSep message type * docs improvements * jetbrains fix * update package.json version --------- Co-authored-by: Rob Leidle <rleidle@gmail.com> Co-authored-by: Rob Leidle <rleidle@tesla.com> Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com> Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com> Co-authored-by: inimaz <imaz@ai-verse.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> * update package.json version * skip extension tests * update package.json version * handlebars import * don't push package.json version change from CI * fix: scroll issues w/ code blocks (#1688) * fix: scroll issues w/ code blocks * chore: name offset * chore: remove docs start * chore: update headings on troubleshooting.md (#1696) * ignore .svn folder for indexing (#1699) * chore: clearer naming for `useSuffix` (#1702) * chore: clearer naming for `useSuffix` * schema updates * fix: cmd+shft+l closes sidebar if focused (#1638) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * add voyage rerank-1 * import Handlebars * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * small UI tweaks * media query * feat: add best experience onboarding * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * chore: add telemetry for full screen toggle (#1618) * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * manually implement stop tokens for hf inference api * chore: onboarding metrics (#1626) * fix: pageview tracking * feat: add onboarding telemetry * create single `onboardingStatus` type * improved var naming * remove console logs * fix windows performance issue * rename vscodeExtension.ts * migration of onboarding variables * "stash" instead of "delete" in indexing progress * fix preview.yaml * also fix main.yaml * Update troubleshooting.md (#1637) * feat: close panel if main input is focused * add skip param * Update TipTapEditor.tsx * merge dev * Update commands.ts --------- Co-authored-by: Nate Sesti <sestinj@gmail.com> Co-authored-by: Nate Sesti <33237525+sestinj@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> * bugfix: quick actions undefined array (#1704) * feat: add rich quick pick for quick edit (#1706) * feat: multistep quick pick * fix: multi step for context provider * Update test.js * Create deepseek.md (#1708) * style: add max height to model selector (#1712) * update styling * remove testing code * remove comments * feat: add tutorial card (#1716) * feat: create tutorial card * Update TutorialCard.tsx * feat: add file search to quick edit (#1714) * feat: multistep quick pick * fix: multi step for context provider * Update test.js * add file search * complete file search * remove unused import * add comments * Update utils.ts * update naming * chore: move quick pick instantiation (#1723) * Break out into NPM modules (#1726) * config.json types * export all schemas * break out request logic into packages * update openai adapters to export body types * update packaging of npm modules * update packages * continue proxy * mistral * Fix typo in documentation (#1722) In set-up-codestral.md "Trobleshooting" -> "Troubleshooting" * update package.json version * 🪄 model dropdown, control plane (#1692) * Nate/control plane client (#1691) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * fix(gui): ctx rendering w/ renderInlineAs: "" (#1541) * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * fix codeqwen autocomplete leading space * add voyage rerank-1 * feat: `--noEmit` for tsc checks in CI (#1559) * docs: update CustomContextProvider docs (#1557) * add stop tokens to qwen prompt * update docs to reflect 3.5 sonnet being best * docs: comment out unused providers (#1561) * import Handlebars * feat: toast notification for config updates (#1560) * feat: toast notification for config updates * feat: only trigger toast on config.json save * displayRawMarkdown option * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * update to reflect 16 stop words limit for deepseek * feat: only trigger config update toast in vscode (#1571) * docs(prompt-files): fix typos + clarify (#1575) * doc: prompt file typo + clarifications * fix: add back correct docs * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * docs(telemetry): add pageviews to tracking list (#1581) * Add reranker configuration options to codebase embedding docs (#1584) - Introduce reranker concept - List available reranker options - Provide configuration instructions - Update keywords to include "reranker" * chore: update pr template with screenshots (#1590) * Refactor ConfirmationDialog to use SecondaryButton for cancel action (#1586) * Added instructions for running docs server locally (#1578) - Added NPM script method - Added VS Code task method - Update contributing guidelines * Update branch policy (#1577) - Change PR target to `dev` branch - Update `CONTRIBUTING.md` instructions * Consolidate example configurations into the main configuration guide (#1579) - Moved examples to configuration.md - Deleted the separate examples.md file - Updated sidebar order and links - Improved readability and structure in configuration.md * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * Update completionProvider.ts (warning tab-autocomplete models) (#1566) * feat: enhanced IndexingProgressBar with blinking dot feature - Integrated BlinkingDot component - Added STATUS_COLORS for various states - Replaced CircleDiv with BlinkingDot in UI - Updated status messages and layout * small UI tweaks * feat(gui): enhance ModelCard, ModelProviderTag, and Toggle components (#1595) - add styling and adjustments to ModelCard - update ModelProviderTag font size - remove box shadow from Toggle component - tweak icon styles in ModelCard - improve alignment and spacing * media query * feat: add best experience onboarding * fix: file rename * stop movement on button hover by keeping same border thickness * fix mistake in setting cursor: pointer * fix when free trial option is shown * Support Node.js versions below 20 for streaming response handling (#1591) - Add fallback for Node < 20 - Implement toAsyncIterable for streaming - Use TextDecoder for manual decoding - Maintain existing streaming for Node 20+ * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * fix hasPassedFTL * fix /edit cancellation from UI * feat: add `applyCodeBlock` experimental prop (#1601) * feat: add new model styling improvements (#1609) * feat: add new model styling improvements * better gap size * feat: update bug_report.yml (#1610) * chore: update bug_report.yml * typo fix * feat: add labels to "Add docs" dialog (#1612) * feat: add labels to "Add docs" dialog * remove autofocus * don't double load config * small fixes * speed up directory traversal, and use correct native path module * option not to show config update toast * merge air-gapped and recommended setup pages * chore: add telemetry for full screen toggle (#1618) * Fix headings in codebase-embeddings.md (#1617) * mention jetbrains * docs: update changie (#1619) * feat: updated changie config * hide toc and autogenerate * Update changelog.mdx * link to deeper explanation of embeddings models * ensure target="_blank" for all links in sidebar * fix gif links in intellij README.md * don't require rust in dependency installation * chore: fix padding on gh button (#1620) * chore: adjust button padding * Update tasks.json * escape colons in diff path * smoother lancedb indexing reporting * smooth progress updates for indexing * fix tsc err * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * docs: add docs and schema for "OS" provider (#1536) * ignore .env * 🚑 fix constant warnings when onboarding with Ollama * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * team analytics * apply control plane settings * workos auth * ide protocol get session info * UI for auth * profile switching * small fixes * updates * refresh tokens * updates * fix tsc errs * model select in toolbar to make room for profile selector * prod client id * link to prod URL * internal beta option * profiles change listener --------- Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com> Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu <ddascalescu+github@gmail.com> * temporary patch for type errs --------- Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com> Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu <ddascalescu+github@gmail.com> * skip extension tests * JetBrains status bar spinner for autocomplete * Remove unused images * partial accept jetbrains * fix double-rendering of jetbrains completions * fix offset of multi-line jetbrains completions * enable/disable actions * upgrade to version 0.0.54 * fix: wrap editor buttons when out of space (#1727) * Add .continuerc file to config directory on activation to prevent it's indexing. (#1733) * Updated the content links that were deprecated in the document (#1709) Co-authored-by: Ihe Fan <ih.fan.1027@gmail.com> * Nate/dev (#1739) * JetBrains status bar spinner for autocomplete * Remove unused images * partial accept jetbrains * fix double-rendering of jetbrains completions * fix offset of multi-line jetbrains completions * enable/disable actions * upgrade to version 0.0.54 * llm-info package * small profile switching improvements * instruct cmd+I not to leave placeholders * @ files in context-providers docs * onboarding fix * update jetbrains ci to build gui * feat: single default quick pick to edit (#1743) * feat: single default quick pick to edit * Update quick-actions.md * Update quick-actions.md * use defaultQuickAction * quick fixes * fix: handle line removal diff (#1744) * fix: handle line removal diff * remove comments * Configurable `maxChunkSize` for embedding providers (#1746) * Add `maxChunkSize` to `EmbeddingsProvider` * Add `maxChunkSize` to schema * add support for docs via config (#1594) * mistral mamba (#1748) * 🐍 mistral mamba * autoscale retrieval based on context length * autoscale retrieval based on context length * fix input box movement * update jetbrains build --------- Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com> Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu <ddascalescu+github@gmail.com> Co-authored-by: Rob Leidle <rleidle@gmail.com> Co-authored-by: Rob Leidle <rleidle@tesla.com> Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com> Co-authored-by: inimaz <imaz@ai-verse.com> Co-authored-by: Anaël Bonnafous <71386173+AnaelBonnafous@users.noreply.github.com> Co-authored-by: Huy Tran <119860259+tranquochuy645@users.noreply.github.com> Co-authored-by: Gabriel Gordbegli <ggordbegli@gmail.com> Co-authored-by: Raven-1027 <83693755+Raven-1027@users.noreply.github.com> Co-authored-by: Ihe Fan <ih.fan.1027@gmail.com> Co-authored-by: Lukas Kreussel <65088241+LLukas22@users.noreply.github.com>
This commit is contained in:
parent
ed37dcfb7a
commit
ec2aa19a43
94 changed files with 1487 additions and 746 deletions
20
.github/workflows/jetbrains-build.yaml
vendored
20
.github/workflows/jetbrains-build.yaml
vendored
|
|
@ -16,7 +16,7 @@ name: Build
|
|||
on:
|
||||
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests)
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [main, preview]
|
||||
# Trigger the workflow on any pull request
|
||||
# pull_request:
|
||||
|
||||
|
|
@ -97,6 +97,12 @@ jobs:
|
|||
path: binary/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }}
|
||||
|
||||
- name: Cache gui node_modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: gui/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
|
||||
|
||||
# npm install core
|
||||
- name: Install core node_modules
|
||||
run: |
|
||||
|
|
@ -109,6 +115,18 @@ jobs:
|
|||
cd ../../binary
|
||||
npm ci
|
||||
|
||||
# npm install gui
|
||||
- name: Install gui node_modules
|
||||
run: |
|
||||
cd ../../gui
|
||||
npm ci
|
||||
|
||||
# build gui
|
||||
- name: Build gui
|
||||
run: |
|
||||
cd ../../gui
|
||||
npm run build
|
||||
|
||||
# Run prepackage.js script
|
||||
- name: Run prepackage script
|
||||
run: |
|
||||
|
|
|
|||
30
.github/workflows/jetbrains-release.yaml
vendored
30
.github/workflows/jetbrains-release.yaml
vendored
|
|
@ -87,6 +87,12 @@ jobs:
|
|||
path: binary/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }}
|
||||
|
||||
- name: Cache gui node_modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: gui/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
|
||||
|
||||
# npm install core
|
||||
- name: Install core node_modules
|
||||
run: |
|
||||
|
|
@ -99,6 +105,18 @@ jobs:
|
|||
cd ../../binary
|
||||
npm ci
|
||||
|
||||
# npm install gui
|
||||
- name: Install gui node_modules
|
||||
run: |
|
||||
cd ../../gui
|
||||
npm ci
|
||||
|
||||
# build gui
|
||||
- name: Build gui
|
||||
run: |
|
||||
cd ../../gui
|
||||
npm run build
|
||||
|
||||
# Run prepackage.js script
|
||||
- name: Run prepackage script
|
||||
run: |
|
||||
|
|
@ -120,6 +138,12 @@ jobs:
|
|||
run: |
|
||||
./gradlew patchChangelog --release-note="$CHANGELOG"
|
||||
|
||||
# Upload artifact as a release asset
|
||||
- name: Upload Release Asset
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
|
||||
|
||||
# Publish the plugin to JetBrains Marketplace
|
||||
- name: Publish Plugin
|
||||
env:
|
||||
|
|
@ -129,12 +153,6 @@ jobs:
|
|||
PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}
|
||||
run: ./gradlew publishPlugin
|
||||
|
||||
# Upload artifact as a release asset
|
||||
- name: Upload Release Asset
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
|
||||
|
||||
# Create a pull request
|
||||
- name: Create Pull Request
|
||||
if: ${{ steps.properties.outputs.changelog != '' }}
|
||||
|
|
|
|||
16
.vscode/launch.json
vendored
16
.vscode/launch.json
vendored
|
|
@ -95,6 +95,22 @@
|
|||
// Avoid timing out when stopping on breakpoints during debugging in VSCode
|
||||
"MOCHA_TIMEOUT": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "[Core] Jest Test Debugger, Current Open File",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeArgs": [
|
||||
"--inspect-brk",
|
||||
"${workspaceRoot}/core/node_modules/jest/bin/jest.js",
|
||||
"--runInBand",
|
||||
"--config",
|
||||
"${workspaceRoot}/core/jest.config.js",
|
||||
"${relativeFile}"
|
||||
],
|
||||
"cwd": "${workspaceRoot}/core",
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
|
|
@ -12,9 +12,7 @@
|
|||
// To bundle the code the same way we do for publishing
|
||||
"vscode-extension:esbuild",
|
||||
// Start the React app that is used in the extension
|
||||
"gui:dev",
|
||||
// Start the docs site, without opening the browser
|
||||
"docs:start"
|
||||
"gui:dev"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
|
|
|
|||
7
binary/package-lock.json
generated
7
binary/package-lock.json
generated
|
|
@ -46,6 +46,8 @@
|
|||
"dependencies": {
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.574.0",
|
||||
"@aws-sdk/credential-providers": "^3.596.0",
|
||||
"@continuedev/config-types": "^1.0.6",
|
||||
"@continuedev/llm-info": "^1.0.1",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@types/jsdom": "^21.1.6",
|
||||
|
|
@ -61,7 +63,7 @@
|
|||
"commander": "^12.0.0",
|
||||
"comment-json": "^4.2.3",
|
||||
"dbinfoz": "^0.1.4",
|
||||
"dotenv": "^16.3.1",
|
||||
"dotenv": "^16.4.5",
|
||||
"fastest-levenshtein": "^1.0.16",
|
||||
"follow-redirects": "^1.15.5",
|
||||
"handlebars": "^4.7.8",
|
||||
|
|
@ -91,7 +93,8 @@
|
|||
"vectordb": "^0.4.20",
|
||||
"web-tree-sitter": "^0.21.0",
|
||||
"win-ca": "^3.5.1",
|
||||
"yaml": "^2.4.2"
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.24.7",
|
||||
|
|
|
|||
|
|
@ -188,6 +188,13 @@ export class ConfigHandler {
|
|||
this.selectedProfileId = profileId;
|
||||
const newConfig = await this.loadConfig();
|
||||
this.notifyConfigListerners(newConfig);
|
||||
const selectedProfiles =
|
||||
this.globalContext.get("lastSelectedProfileForWorkspace") ?? {};
|
||||
selectedProfiles[await this.getWorkspaceId()] = profileId;
|
||||
this.globalContext.update(
|
||||
"lastSelectedProfileForWorkspace",
|
||||
selectedProfiles,
|
||||
);
|
||||
}
|
||||
|
||||
// A unique ID for the current workspace, built from folder names
|
||||
|
|
|
|||
|
|
@ -10,11 +10,6 @@ export function setupApiKeysMode(
|
|||
return {
|
||||
...config,
|
||||
models: config.models.filter((model) => model.provider !== "free-trial"),
|
||||
tabAutocompleteModel: {
|
||||
title: "Tab Autocomplete",
|
||||
provider: "free-trial",
|
||||
model: TRIAL_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "free-trial",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { IProfileLoader } from "./IProfileLoader";
|
|||
export default class LocalProfileLoader implements IProfileLoader {
|
||||
static ID = "local";
|
||||
profileId = LocalProfileLoader.ID;
|
||||
profileTitle = "config.json";
|
||||
profileTitle = "Local Config";
|
||||
|
||||
constructor(
|
||||
private ide: IDE,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
ContextProviderExtras,
|
||||
ContextSubmenuItem,
|
||||
LoadSubmenuItemsArgs,
|
||||
SiteIndexingConfig,
|
||||
} from "../../index.js";
|
||||
import { DocsService } from "../../indexing/docs/DocsService.js";
|
||||
import configs from "../../indexing/docs/preIndexedDocs.js";
|
||||
|
|
@ -108,40 +109,44 @@ class DocsContextProvider extends BaseContextProvider {
|
|||
];
|
||||
}
|
||||
|
||||
async loadSubmenuItems(
|
||||
args: LoadSubmenuItemsArgs,
|
||||
): Promise<ContextSubmenuItem[]> {
|
||||
const docs = await this.docsService.list();
|
||||
const submenuItems: ContextSubmenuItem[] = docs.map((doc) => ({
|
||||
// Get combined site configs from preIndexedDocs and options.sites.
|
||||
private _getDocsSitesConfig(): SiteIndexingConfig[] {
|
||||
return [...configs, ...(this.options?.sites || [])];
|
||||
}
|
||||
|
||||
// Get indexed docs as ContextSubmenuItems from database.
|
||||
private async _getIndexedDocsContextSubmenuItems(): Promise<ContextSubmenuItem[]> {
|
||||
return (await this.docsService.list()).map((doc) => ({
|
||||
title: doc.title,
|
||||
description: new URL(doc.baseUrl).hostname,
|
||||
id: doc.baseUrl,
|
||||
metadata: {
|
||||
preIndexed: !!configs.find((config) => config.title === doc.title),
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
submenuItems.push(
|
||||
...configs
|
||||
// After it's actually downloaded, we don't want to show twice
|
||||
.filter(
|
||||
(config) => !submenuItems.some((item) => item.id === config.startUrl),
|
||||
)
|
||||
.map((config) => ({
|
||||
title: config.title,
|
||||
description: new URL(config.startUrl).hostname,
|
||||
id: config.startUrl,
|
||||
metadata: {
|
||||
preIndexed: true,
|
||||
},
|
||||
// iconUrl: config.faviconUrl,
|
||||
})),
|
||||
);
|
||||
async loadSubmenuItems(
|
||||
args: LoadSubmenuItemsArgs,
|
||||
): Promise<ContextSubmenuItem[]> {
|
||||
const submenuItemsMap = new Map<string, ContextSubmenuItem>();
|
||||
|
||||
for (const item of await this._getIndexedDocsContextSubmenuItems()) {
|
||||
submenuItemsMap.set(item.id, item);
|
||||
}
|
||||
|
||||
for (const config of this._getDocsSitesConfig()) {
|
||||
submenuItemsMap.set(config.startUrl, {
|
||||
id: config.startUrl,
|
||||
title: config.title,
|
||||
description: new URL(config.startUrl).hostname,
|
||||
metadata: { preIndexed: !!configs.find((cnf) => cnf.title === config.title), },
|
||||
});
|
||||
}
|
||||
|
||||
const submenuItems = Array.from(submenuItemsMap.values());
|
||||
|
||||
// Sort submenuItems such that the objects with titles which don't occur in configs occur first, and alphabetized
|
||||
submenuItems.sort((a, b) => {
|
||||
const aTitleInConfigs = a.metadata?.preIndexed;
|
||||
const bTitleInConfigs = b.metadata?.preIndexed;
|
||||
const aTitleInConfigs = a.metadata?.preIndexed ?? false;
|
||||
const bTitleInConfigs = b.metadata?.preIndexed ?? false;
|
||||
|
||||
// Primary criterion: Items not in configs come first
|
||||
if (!aTitleInConfigs && bTitleInConfigs) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import {
|
|||
} from "../../index.js";
|
||||
|
||||
import { getRelativePath } from "../../util/index.js";
|
||||
import { RETRIEVAL_PARAMS } from "../../util/parameters.js";
|
||||
import { RetrievalPipelineOptions } from "./pipelines/BaseRetrievalPipeline.js";
|
||||
import NoRerankerRetrievalPipeline from "./pipelines/NoRerankerRetrievalPipeline.js";
|
||||
import RerankerRetrievalPipeline from "./pipelines/RerankerRetrievalPipeline.js";
|
||||
|
|
@ -29,12 +28,14 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
);
|
||||
}
|
||||
|
||||
const nFinal = options?.nFinal || RETRIEVAL_PARAMS.nFinal;
|
||||
// Fill half of the context length, up to a max of 100 snippets
|
||||
const contextLength = extras.llm.contextLength;
|
||||
const tokensPerSnippet = 512;
|
||||
const nFinal =
|
||||
options?.nFinal ?? Math.min(50, contextLength / tokensPerSnippet / 2);
|
||||
const useReranking = extras.reranker !== undefined;
|
||||
const nRetrieve =
|
||||
useReranking === false
|
||||
? nFinal
|
||||
: options?.nRetrieve || RETRIEVAL_PARAMS.nRetrieve;
|
||||
useReranking === false ? nFinal : options?.nRetrieve || 2 * nFinal;
|
||||
|
||||
// Get tags to retrieve for
|
||||
const workspaceDirs = await extras.ide.getWorkspaceDirs();
|
||||
|
|
|
|||
25
core/core.ts
25
core/core.ts
|
|
@ -242,6 +242,19 @@ export class Core {
|
|||
await this.docsService.delete(baseUrl);
|
||||
this.messenger.send("refreshSubmenuItems", undefined);
|
||||
});
|
||||
on("context/indexDocs", async (msg) => {
|
||||
const config = await this.config();
|
||||
const provider: any = config.contextProviders?.find(
|
||||
(provider) => provider.description.title === "docs",
|
||||
);
|
||||
|
||||
const siteIndexingOptions: SiteIndexingConfig[] = provider ?
|
||||
(mProvider => mProvider?.options?.sites || [])({ ...provider }) :
|
||||
[];
|
||||
|
||||
await this.indexDocs(siteIndexingOptions, msg.data.reIndex);
|
||||
this.ide.infoPopup("Docs indexing completed");
|
||||
});
|
||||
on("context/loadSubmenuItems", async (msg) => {
|
||||
const config = await this.config();
|
||||
const items = config.contextProviders
|
||||
|
|
@ -623,4 +636,16 @@ export class Core {
|
|||
this.indexingState = update;
|
||||
}
|
||||
}
|
||||
|
||||
private async indexDocs(sites: SiteIndexingConfig[], reIndex: boolean): Promise<void> {
|
||||
for (const site of sites) {
|
||||
for await (const update of this.docsService.indexAndAdd(site, new TransformersJsEmbeddingsProvider(), reIndex)) {
|
||||
// Temporary disabled posting progress updates to the UI due to
|
||||
// possible collision with code indexing progress updates.
|
||||
|
||||
// this.messenger.request("indexProgress", update);
|
||||
// this.indexingState = update;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,46 +13,69 @@ export async function* streamDiff(
|
|||
oldLines: string[],
|
||||
newLines: LineStream,
|
||||
): AsyncGenerator<DiffLine> {
|
||||
const mutatedOldLines = [...oldLines]; // be careful
|
||||
|
||||
// If one indentation mistake is made, others are likely. So we are more permissive about matching
|
||||
let seenIndentationMistake = false;
|
||||
|
||||
let newLineResult = await newLines.next();
|
||||
|
||||
while (oldLines.length > 0 && !newLineResult.done) {
|
||||
const [matchIndex, isPerfectMatch, newLine] = matchLine(
|
||||
const { matchIndex, isPerfectMatch, newLine } = matchLine(
|
||||
newLineResult.value,
|
||||
oldLines,
|
||||
seenIndentationMistake,
|
||||
);
|
||||
|
||||
if (!seenIndentationMistake && newLineResult.value !== newLine) {
|
||||
seenIndentationMistake = true;
|
||||
}
|
||||
|
||||
if (matchIndex < 0) {
|
||||
// Insert new line
|
||||
yield { type: "new", line: newLine };
|
||||
let type: DiffLine["type"];
|
||||
|
||||
let isLineRemoval = false;
|
||||
const isNewLine = matchIndex === -1;
|
||||
|
||||
if (isNewLine) {
|
||||
type = "new";
|
||||
} else {
|
||||
// Insert all deleted lines before match
|
||||
for (let i = 0; i < matchIndex; i++) {
|
||||
yield { type: "old", line: oldLines.shift()! };
|
||||
}
|
||||
|
||||
if (isPerfectMatch) {
|
||||
// Same
|
||||
yield { type: "same", line: oldLines.shift()! };
|
||||
} else {
|
||||
// Delete old line and insert the new
|
||||
yield { type: "old", line: oldLines.shift()! };
|
||||
yield { type: "new", line: newLine };
|
||||
}
|
||||
type = isPerfectMatch ? "same" : "old";
|
||||
}
|
||||
|
||||
newLineResult = await newLines.next();
|
||||
switch (type) {
|
||||
case "new":
|
||||
yield { type, line: newLine };
|
||||
break;
|
||||
|
||||
case "same":
|
||||
yield { type, line: oldLines.shift()! };
|
||||
break;
|
||||
|
||||
case "old":
|
||||
yield { type, line: oldLines.shift()! };
|
||||
|
||||
if (oldLines[0] !== newLine) {
|
||||
yield { type: "new", line: newLine };
|
||||
} else {
|
||||
isLineRemoval = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error(`Error streaming diff, unrecognized diff type: ${type}`);
|
||||
}
|
||||
|
||||
if (!isLineRemoval) {
|
||||
newLineResult = await newLines.next();
|
||||
}
|
||||
}
|
||||
|
||||
// Once at the edge, only one choice
|
||||
if (newLineResult.done === true && oldLines.length > 0) {
|
||||
if (newLineResult.done && oldLines.length > 0) {
|
||||
for (const oldLine of oldLines) {
|
||||
yield { type: "old", line: oldLine };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,16 @@ import { stripImages } from "../llm/countTokens.js";
|
|||
|
||||
export type LineStream = AsyncGenerator<string>;
|
||||
|
||||
export type MatchLineResult = {
|
||||
/**
|
||||
* -1 if it's a new line, otherwise the index of the first match
|
||||
* in the old lines.
|
||||
*/
|
||||
matchIndex: number;
|
||||
isPerfectMatch: boolean;
|
||||
newLine: string;
|
||||
};
|
||||
|
||||
function linesMatchPerfectly(lineA: string, lineB: string): boolean {
|
||||
return lineA === lineB && lineA !== "";
|
||||
}
|
||||
|
|
@ -18,6 +28,7 @@ function linesMatch(lineA: string, lineB: string, linesBetween = 0): boolean {
|
|||
}
|
||||
|
||||
const d = distance(lineA, lineB);
|
||||
|
||||
return (
|
||||
// Should be more unlikely for lines to fuzzy match if they are further away
|
||||
(d / Math.max(lineA.length, lineB.length) < 0.5 - linesBetween * 0.05 ||
|
||||
|
|
@ -34,21 +45,26 @@ export function matchLine(
|
|||
newLine: string,
|
||||
oldLines: string[],
|
||||
permissiveAboutIndentation = false,
|
||||
): [number, boolean, string] {
|
||||
): MatchLineResult {
|
||||
// Only match empty lines if it's the next one:
|
||||
if (newLine.trim() === "" && oldLines[0]?.trim() === "") {
|
||||
return [0, true, newLine.trim()];
|
||||
return {
|
||||
matchIndex: 0,
|
||||
isPerfectMatch: true,
|
||||
newLine: newLine.trim(),
|
||||
};
|
||||
}
|
||||
|
||||
const isEndBracket = END_BRACKETS.includes(newLine.trim());
|
||||
|
||||
for (let i = 0; i < oldLines.length; i++) {
|
||||
// Don't match end bracket lines if too far away
|
||||
if (i > 4 && isEndBracket) {
|
||||
return [-1, false, newLine];
|
||||
return { matchIndex: -1, isPerfectMatch: false, newLine };
|
||||
}
|
||||
|
||||
if (linesMatchPerfectly(newLine, oldLines[i])) {
|
||||
return [i, true, newLine];
|
||||
return { matchIndex: i, isPerfectMatch: true, newLine };
|
||||
}
|
||||
if (linesMatch(newLine, oldLines[i], i)) {
|
||||
// This is a way to fix indentation, but only for sufficiently long lines to avoid matching whitespace or short lines
|
||||
|
|
@ -56,13 +72,17 @@ export function matchLine(
|
|||
newLine.trimStart() === oldLines[i].trimStart() &&
|
||||
(permissiveAboutIndentation || newLine.trim().length > 8)
|
||||
) {
|
||||
return [i, true, oldLines[i]];
|
||||
return {
|
||||
matchIndex: i,
|
||||
isPerfectMatch: true,
|
||||
newLine: oldLines[i],
|
||||
};
|
||||
}
|
||||
return [i, false, newLine];
|
||||
return { matchIndex: i, isPerfectMatch: false, newLine };
|
||||
}
|
||||
}
|
||||
|
||||
return [-1, false, newLine];
|
||||
return { matchIndex: -1, isPerfectMatch: false, newLine };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -743,6 +743,7 @@ export interface EmbedOptions {
|
|||
apiType?: string;
|
||||
apiVersion?: string;
|
||||
requestOptions?: RequestOptions;
|
||||
maxChunkSize?: number;
|
||||
}
|
||||
|
||||
export interface EmbeddingsProviderDescription extends EmbedOptions {
|
||||
|
|
@ -751,6 +752,7 @@ export interface EmbeddingsProviderDescription extends EmbedOptions {
|
|||
|
||||
export interface EmbeddingsProvider {
|
||||
id: string;
|
||||
maxChunkSize: number;
|
||||
embed(chunks: string[]): Promise<number[][]>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export class CodebaseIndexer {
|
|||
new ChunkCodebaseIndex(
|
||||
this.ide.readFile.bind(this.ide),
|
||||
this.continueServerClient,
|
||||
config.embeddingsProvider.maxChunkSize,
|
||||
), // Chunking must come first
|
||||
new LanceDbIndex(
|
||||
config.embeddingsProvider,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import {
|
|||
IndexTag,
|
||||
IndexingProgressUpdate,
|
||||
} from "../index.js";
|
||||
import { MAX_CHUNK_SIZE } from "../llm/constants.js";
|
||||
import { getBasename } from "../util/index.js";
|
||||
import { getLanceDbPath, migrate } from "../util/paths.js";
|
||||
import { chunkDocument } from "./chunk/chunk.js";
|
||||
|
|
@ -36,8 +35,6 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
return `vectordb::${this.embeddingsProvider.id}`;
|
||||
}
|
||||
|
||||
static MAX_CHUNK_SIZE = MAX_CHUNK_SIZE;
|
||||
|
||||
constructor(
|
||||
private readonly embeddingsProvider: EmbeddingsProvider,
|
||||
private readonly readFile: (filepath: string) => Promise<string>,
|
||||
|
|
@ -64,10 +61,13 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
migrate(
|
||||
"lancedb_sqlite_artifact_id_column",
|
||||
async () => {
|
||||
await db.exec(
|
||||
"ALTER TABLE lance_db_cache ADD COLUMN artifact_id TEXT NOT NULL DEFAULT 'UNDEFINED'",
|
||||
);
|
||||
resolve(undefined);
|
||||
try {
|
||||
await db.exec(
|
||||
"ALTER TABLE lance_db_cache ADD COLUMN artifact_id TEXT NOT NULL DEFAULT 'UNDEFINED'",
|
||||
);
|
||||
} finally {
|
||||
resolve(undefined);
|
||||
}
|
||||
},
|
||||
() => resolve(undefined),
|
||||
),
|
||||
|
|
@ -99,7 +99,7 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
for await (const chunk of chunkDocument(
|
||||
items[i].path,
|
||||
content,
|
||||
LanceDbIndex.MAX_CHUNK_SIZE,
|
||||
this.embeddingsProvider.maxChunkSize,
|
||||
items[i].cacheKey,
|
||||
)) {
|
||||
if (chunk.content.length == 0) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { IContinueServerClient } from "../../continueServer/interface.js";
|
||||
import { Chunk, IndexTag, IndexingProgressUpdate } from "../../index.js";
|
||||
import { MAX_CHUNK_SIZE } from "../../llm/constants.js";
|
||||
import { getBasename } from "../../util/index.js";
|
||||
import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex.js";
|
||||
import {
|
||||
|
|
@ -19,6 +18,7 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
|
|||
constructor(
|
||||
private readonly readFile: (filepath: string) => Promise<string>,
|
||||
private readonly continueServerClient: IContinueServerClient,
|
||||
private readonly maxChunkSize: number
|
||||
) {
|
||||
this.readFile = readFile;
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
|
|||
for await (const chunk of chunkDocument(
|
||||
item.path,
|
||||
contents[i],
|
||||
MAX_CHUNK_SIZE,
|
||||
this.maxChunkSize,
|
||||
item.cacheKey,
|
||||
)) {
|
||||
handleChunk(chunk);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { Chunk, ChunkWithoutID } from "../../index.js";
|
||||
import { MAX_CHUNK_SIZE } from "../../llm/constants.js";
|
||||
import { countTokens } from "../../llm/countTokens.js";
|
||||
import { supportedLanguages } from "../../util/treeSitter.js";
|
||||
import { basicChunker } from "./basic.js";
|
||||
|
|
@ -43,7 +42,7 @@ export async function* chunkDocument(
|
|||
contents,
|
||||
maxChunkSize,
|
||||
)) {
|
||||
if (countTokens(chunkWithoutId.content) > MAX_CHUNK_SIZE) {
|
||||
if (countTokens(chunkWithoutId.content) > maxChunkSize) {
|
||||
console.warn(
|
||||
`Chunk with more than ${maxChunkSize} tokens constructed: `,
|
||||
filepath,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ export class DocsService {
|
|||
private static instance: DocsService;
|
||||
private static DOCS_TABLE_NAME = "docs";
|
||||
private _sqliteTable: Database | undefined;
|
||||
private docsIndexingQueue: Set<string> = new Set();
|
||||
|
||||
public static getInstance(): DocsService {
|
||||
if (!DocsService.instance) {
|
||||
|
|
@ -204,10 +205,16 @@ export class DocsService {
|
|||
async *indexAndAdd(
|
||||
siteIndexingConfig: SiteIndexingConfig,
|
||||
embeddingsProvider: EmbeddingsProvider,
|
||||
reIndex: boolean = false,
|
||||
): AsyncGenerator<IndexingProgressUpdate> {
|
||||
const startUrl = new URL(siteIndexingConfig.startUrl);
|
||||
const startUrl = new URL(siteIndexingConfig.startUrl.toString());
|
||||
|
||||
if (await this.has(siteIndexingConfig.startUrl.toString())) {
|
||||
if (this.docsIndexingQueue.has(startUrl.toString())) {
|
||||
console.log("Already in queue");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!reIndex && await this.has(startUrl.toString())) {
|
||||
yield {
|
||||
progress: 1,
|
||||
desc: "Already indexed",
|
||||
|
|
@ -216,6 +223,9 @@ export class DocsService {
|
|||
return;
|
||||
}
|
||||
|
||||
// Mark the site as currently being indexed
|
||||
this.docsIndexingQueue.add(startUrl.toString());
|
||||
|
||||
yield {
|
||||
progress: 0,
|
||||
desc: "Finding subpages",
|
||||
|
|
@ -223,20 +233,31 @@ export class DocsService {
|
|||
};
|
||||
|
||||
const articles: Article[] = [];
|
||||
let processedPages = 0;
|
||||
let maxKnownPages = 1;
|
||||
|
||||
// Crawl pages and retrieve info as articles
|
||||
for await (const page of crawlPage(startUrl, siteIndexingConfig.maxDepth)) {
|
||||
processedPages++;
|
||||
const article = pageToArticle(page);
|
||||
if (!article) {
|
||||
continue;
|
||||
}
|
||||
articles.push(article);
|
||||
|
||||
// Use a heuristic approach for progress calculation
|
||||
const progress = Math.min(processedPages / maxKnownPages, 1);
|
||||
|
||||
yield {
|
||||
progress: 0,
|
||||
progress, // Yield the heuristic progress
|
||||
desc: `Finding subpages (${page.path})`,
|
||||
status: "indexing",
|
||||
};
|
||||
|
||||
// Increase maxKnownPages to delay progress reaching 100% too soon
|
||||
if (processedPages === maxKnownPages) {
|
||||
maxKnownPages *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
const chunks: Chunk[] = [];
|
||||
|
|
@ -244,16 +265,17 @@ export class DocsService {
|
|||
|
||||
// Create embeddings of retrieved articles
|
||||
console.log("Creating Embeddings for ", articles.length, " articles");
|
||||
for (const article of articles) {
|
||||
for (let i = 0; i < articles.length; i++) {
|
||||
const article = articles[i];
|
||||
yield {
|
||||
progress: Math.max(1, Math.floor(100 / (articles.length + 1))),
|
||||
desc: `${article.subpath}`,
|
||||
progress: i / articles.length,
|
||||
desc: `Creating Embeddings: ${article.subpath}`,
|
||||
status: "indexing",
|
||||
};
|
||||
|
||||
try {
|
||||
const subpathEmbeddings = await embeddingsProvider.embed(
|
||||
chunkArticle(article).map((chunk) => {
|
||||
chunkArticle(article, embeddingsProvider.maxChunkSize).map((chunk) => {
|
||||
chunks.push(chunk);
|
||||
|
||||
return chunk.content;
|
||||
|
|
@ -268,7 +290,14 @@ export class DocsService {
|
|||
|
||||
// Add docs to databases
|
||||
console.log("Adding ", embeddings.length, " embeddings to db");
|
||||
yield {
|
||||
progress: 0.5,
|
||||
desc: `Adding ${embeddings.length} embeddings to db`,
|
||||
status: "indexing",
|
||||
};
|
||||
|
||||
await this.add(siteIndexingConfig.title, startUrl, chunks, embeddings);
|
||||
this.docsIndexingQueue.delete(startUrl.toString());
|
||||
|
||||
yield {
|
||||
progress: 1,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { Readability } from "@mozilla/readability";
|
||||
import { JSDOM } from "jsdom";
|
||||
import { Chunk } from "../../index.js";
|
||||
import { MAX_CHUNK_SIZE } from "../../llm/constants.js";
|
||||
import { cleanFragment, cleanHeader } from "../chunk/markdown.js";
|
||||
import { PageData } from "./crawl.js";
|
||||
|
||||
|
|
@ -21,6 +20,7 @@ function breakdownArticleComponent(
|
|||
url: string,
|
||||
article: ArticleComponent,
|
||||
subpath: string,
|
||||
max_chunk_size: number,
|
||||
): Chunk[] {
|
||||
const chunks: Chunk[] = [];
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ function breakdownArticleComponent(
|
|||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
if (content.length + line.length <= MAX_CHUNK_SIZE) {
|
||||
if (content.length + line.length <= max_chunk_size) {
|
||||
content += `${line}\n`;
|
||||
endLine = i;
|
||||
} else {
|
||||
|
|
@ -79,7 +79,10 @@ function breakdownArticleComponent(
|
|||
return chunks.filter((c) => c.content.trim().length > 20);
|
||||
}
|
||||
|
||||
export function chunkArticle(articleResult: Article): Chunk[] {
|
||||
export function chunkArticle(
|
||||
articleResult: Article,
|
||||
maxChunkSize: number,
|
||||
): Chunk[] {
|
||||
let chunks: Chunk[] = [];
|
||||
|
||||
for (const article of articleResult.article_components) {
|
||||
|
|
@ -87,6 +90,7 @@ export function chunkArticle(articleResult: Article): Chunk[] {
|
|||
articleResult.url,
|
||||
article,
|
||||
articleResult.subpath,
|
||||
maxChunkSize,
|
||||
);
|
||||
chunks = [...chunks, ...articleChunks];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import {
|
|||
FetchFunction,
|
||||
} from "../../index.js";
|
||||
|
||||
import { MAX_CHUNK_SIZE } from "../../llm/constants.js";
|
||||
|
||||
export interface IBaseEmbeddingsProvider extends EmbeddingsProvider {
|
||||
options: EmbedOptions;
|
||||
fetch: FetchFunction;
|
||||
|
|
@ -29,11 +31,20 @@ abstract class BaseEmbeddingsProvider implements IBaseEmbeddingsProvider {
|
|||
...options,
|
||||
};
|
||||
this.fetch = fetch;
|
||||
this.id = `${this.constructor.name}::${this.options.model}`;
|
||||
// Include the `max_chunk_size` if it is not the default, since we need to create other indices for different chunk_sizes
|
||||
if (this.maxChunkSize !== MAX_CHUNK_SIZE) {
|
||||
this.id = `${this.constructor.name}::${this.options.model}::${this.maxChunkSize}`;
|
||||
} else {
|
||||
this.id = `${this.constructor.name}::${this.options.model}`;
|
||||
}
|
||||
}
|
||||
|
||||
abstract embed(chunks: string[]): Promise<number[][]>;
|
||||
|
||||
get maxChunkSize(): number {
|
||||
return this.options.maxChunkSize ?? MAX_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
static getBatchedChunks(chunks: string[]): string[][] {
|
||||
if (!this.maxBatchSize) {
|
||||
console.warn(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { findLlmInfo } from "@continuedev/llm-info";
|
||||
import Handlebars from "handlebars";
|
||||
import {
|
||||
ChatMessage,
|
||||
|
|
@ -114,14 +115,17 @@ export abstract class BaseLLM implements ILLM {
|
|||
..._options,
|
||||
};
|
||||
|
||||
this.model = options.model;
|
||||
const llmInfo = findLlmInfo(this.model);
|
||||
|
||||
const templateType =
|
||||
options.template ?? autodetectTemplateType(options.model);
|
||||
|
||||
this.title = options.title;
|
||||
this.uniqueId = options.uniqueId ?? "None";
|
||||
this.model = options.model;
|
||||
this.systemMessage = options.systemMessage;
|
||||
this.contextLength = options.contextLength ?? DEFAULT_CONTEXT_LENGTH;
|
||||
this.contextLength =
|
||||
options.contextLength ?? llmInfo?.contextLength ?? DEFAULT_CONTEXT_LENGTH;
|
||||
this.completionOptions = {
|
||||
...options.completionOptions,
|
||||
model: options.model || "gpt-4",
|
||||
|
|
|
|||
|
|
@ -14,8 +14,11 @@ class Mistral extends OpenAI {
|
|||
|
||||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
if (options.model.includes("codestral")) {
|
||||
this.apiBase = "https://codestral.mistral.ai/v1/";
|
||||
if (
|
||||
options.model.includes("codestral") &&
|
||||
!options.model.includes("mamba")
|
||||
) {
|
||||
this.apiBase = options.apiBase ?? "https://codestral.mistral.ai/v1/";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +34,7 @@ class Mistral extends OpenAI {
|
|||
const finalOptions = super._convertArgs(options, messages);
|
||||
|
||||
const lastMessage = finalOptions.messages[finalOptions.messages.length - 1];
|
||||
if (lastMessage.role === "assistant") {
|
||||
if (lastMessage?.role === "assistant") {
|
||||
(lastMessage as any).prefix = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ ${otherData.codeToEdit}
|
|||
${suffixTag}
|
||||
\`\`\`
|
||||
|
||||
Please rewrite the entire code block above in order to satisfy the following request: "${otherData.userInput}".${suffixExplanation}`,
|
||||
Please rewrite the entire code block above in order to satisfy the following request: "${otherData.userInput}". You should rewrite the entire code block without leaving placeholders, even if the code is the same as before.${suffixExplanation}`,
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
|
|
@ -115,7 +115,7 @@ ${otherData.codeToEdit}
|
|||
${suffixTag}
|
||||
\`\`\`
|
||||
|
||||
Please rewrite the entire code block above, editing the portion below "${START_TAG}" in order to satisfy the following request: "${otherData.userInput}".${suffixExplanation}
|
||||
Please rewrite the entire code block above, editing the portion below "${START_TAG}" in order to satisfy the following request: "${otherData.userInput}". You should rewrite the entire code block without leaving placeholders, even if the code is the same as before.${suffixExplanation}
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
6
core/package-lock.json
generated
6
core/package-lock.json
generated
|
|
@ -12,6 +12,7 @@
|
|||
"@aws-sdk/client-bedrock-runtime": "^3.574.0",
|
||||
"@aws-sdk/credential-providers": "^3.596.0",
|
||||
"@continuedev/config-types": "^1.0.6",
|
||||
"@continuedev/llm-info": "^1.0.1",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@types/jsdom": "^21.1.6",
|
||||
|
|
@ -3937,6 +3938,11 @@
|
|||
"zod": "^3.23.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@continuedev/llm-info": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/llm-info/-/llm-info-1.0.1.tgz",
|
||||
"integrity": "sha512-fmRXuOSwJ9ogBPSDduoedHF3WVg1rge3o8SRRg1hkUagRnxwZqtQj1sS5SjQyAqjQv6VPMGPDEtD77Za/hc4Jg=="
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.17.19",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz",
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
"@aws-sdk/client-bedrock-runtime": "^3.574.0",
|
||||
"@aws-sdk/credential-providers": "^3.596.0",
|
||||
"@continuedev/config-types": "^1.0.6",
|
||||
"@continuedev/llm-info": "^1.0.1",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@types/jsdom": "^21.1.6",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
"autocomplete/complete": [AutocompleteInput, string[]];
|
||||
"context/addDocs": [SiteIndexingConfig, void];
|
||||
"context/removeDocs": [{ baseUrl: string }, void];
|
||||
"context/indexDocs": [{ reIndex: boolean }, void];
|
||||
"autocomplete/cancel": [undefined, void];
|
||||
"autocomplete/accept": [{ completionId: string }, void];
|
||||
"command/run": [
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"context/loadSubmenuItems",
|
||||
"context/addDocs",
|
||||
"context/removeDocs",
|
||||
"context/indexDocs",
|
||||
"autocomplete/complete",
|
||||
"autocomplete/cancel",
|
||||
"autocomplete/accept",
|
||||
|
|
|
|||
|
|
@ -1,150 +0,0 @@
|
|||
import { streamDiff } from "../diff/streamDiff.js";
|
||||
|
||||
const oldCode = [
|
||||
`A
|
||||
B`,
|
||||
`A
|
||||
B
|
||||
C`,
|
||||
`A
|
||||
B
|
||||
C
|
||||
A
|
||||
B
|
||||
B
|
||||
A`,
|
||||
`function mergeSortAlgorithm() {
|
||||
// TODO: implement
|
||||
}`,
|
||||
`function mergeSortAlgorithm() {
|
||||
// TODO: implement
|
||||
}`,
|
||||
];
|
||||
|
||||
const newCode = [
|
||||
`C
|
||||
D`,
|
||||
`D
|
||||
E
|
||||
C
|
||||
F
|
||||
C`,
|
||||
`C
|
||||
B
|
||||
A
|
||||
B
|
||||
A
|
||||
C`,
|
||||
`function mergeSortAlgorithm(arr: number[]): number[] {
|
||||
if (arr.length <= 1) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
const middle = Math.floor(arr.length / 2);
|
||||
const left = arr.slice(0, middle);
|
||||
const right = arr.slice(middle);
|
||||
|
||||
return merge(mergeSortAlgorithm(left), mergeSortAlgorithm(right));
|
||||
}
|
||||
|
||||
function merge(left: number[], right: number[]): number[] {
|
||||
let resultArray = [], leftIndex = 0, rightIndex = 0;
|
||||
|
||||
while (leftIndex < left.length && rightIndex < right.length) {
|
||||
if (left[leftIndex] < right[rightIndex]) {
|
||||
resultArray.push(left[leftIndex]);
|
||||
leftIndex++;
|
||||
} else {
|
||||
resultArray.push(right[rightIndex]);
|
||||
rightIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
return resultArray
|
||||
.concat(left.slice(leftIndex))
|
||||
.concat(right.slice(rightIndex));
|
||||
}`,
|
||||
`function mergeSortAlgorithm(array) {
|
||||
if (array.length <= 1) {
|
||||
return array;
|
||||
}
|
||||
|
||||
const mid = Math.floor(array.length / 2);
|
||||
const left = array.slice(0, mid);
|
||||
const right = array.slice(mid);
|
||||
|
||||
return merge(mergeSortAlgorithm(left), mergeSortAlgorithm(right));
|
||||
}
|
||||
|
||||
function merge(left, right) {
|
||||
let resultArray = [], leftIndex = 0, rightIndex = 0;
|
||||
|
||||
while (leftIndex < left.length && rightIndex < right.length) {
|
||||
if (left[leftIndex] < right[rightIndex]) {
|
||||
resultArray.push(left[leftIndex]);
|
||||
leftIndex++;
|
||||
} else {
|
||||
resultArray.push(right[rightIndex]);
|
||||
rightIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
return resultArray
|
||||
.concat(left.slice(leftIndex))
|
||||
.concat(right.slice(rightIndex));
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
async function* generateLines(lines: string[]): AsyncGenerator<string> {
|
||||
for (const line of lines) {
|
||||
yield line;
|
||||
}
|
||||
}
|
||||
|
||||
describe.skip("streamDiff", () => {
|
||||
for (let i = 0; i < oldCode.length; i++) {
|
||||
test(`outputs valid diff #${i}`, async () => {
|
||||
const oldLines = oldCode[i].split("\n");
|
||||
const newLines = newCode[i].split("\n");
|
||||
|
||||
const diff = [];
|
||||
for await (const diffLine of streamDiff(
|
||||
oldLines,
|
||||
generateLines(newLines),
|
||||
)) {
|
||||
diff.push(diffLine);
|
||||
}
|
||||
|
||||
console.log(
|
||||
diff
|
||||
.map((dl) => {
|
||||
return (
|
||||
(dl.type === "old" ? "- " : dl.type === "new" ? "+ " : " ") +
|
||||
dl.line
|
||||
);
|
||||
})
|
||||
.join("\n"),
|
||||
);
|
||||
|
||||
const numSame = diff.filter((dl) => dl.type === "same").length;
|
||||
const numOld = diff.filter((dl) => dl.type === "old").length;
|
||||
const numNew = diff.filter((dl) => dl.type === "new").length;
|
||||
|
||||
// Check that every line is represented
|
||||
expect(oldLines.length).toEqual(numOld + numSame);
|
||||
expect(newLines.length).toEqual(numNew + numSame);
|
||||
|
||||
// Check that there are no red lines immediately following green (they should always be above)
|
||||
for (let i = 1; i < diff.length; i++) {
|
||||
if (diff[i].type === "old" && diff[i - 1].type === "new") {
|
||||
throw new Error(
|
||||
`Found red '${diff[i].line}' immediately after green line '${
|
||||
diff[i - 1].line
|
||||
}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
164
core/test/streamDiff.test.ts
Normal file
164
core/test/streamDiff.test.ts
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
import { streamDiff } from "../diff/streamDiff.js";
|
||||
import { DiffLine } from "../index.js";
|
||||
|
||||
async function* generateLines(lines: string[]): AsyncGenerator<string> {
|
||||
for (const line of lines) {
|
||||
yield line;
|
||||
}
|
||||
}
|
||||
|
||||
const collectDiff = async (
|
||||
oldLines: string[],
|
||||
newLines: string[],
|
||||
): Promise<DiffLine[]> => {
|
||||
const result: DiffLine[] = [];
|
||||
|
||||
for await (const diffLine of streamDiff(oldLines, generateLines(newLines))) {
|
||||
result.push(diffLine);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// We use a longer `console.log()` string here to not get
|
||||
// caught by the fuzzy matcher
|
||||
describe("streamDiff()", () => {
|
||||
test("no changes", async () => {
|
||||
const oldLines = [
|
||||
"console.log(first)",
|
||||
"console.log(second)",
|
||||
"console.log(third)",
|
||||
];
|
||||
const newLines = [
|
||||
"console.log(first)",
|
||||
"console.log(second)",
|
||||
"console.log(third)",
|
||||
];
|
||||
|
||||
const diff = await collectDiff(oldLines, newLines);
|
||||
|
||||
expect(diff).toEqual([
|
||||
{ type: "same", line: "console.log(first)" },
|
||||
{ type: "same", line: "console.log(second)" },
|
||||
{ type: "same", line: "console.log(third)" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("add new line", async () => {
|
||||
const oldLines = ["console.log(first)", "console.log(second)"];
|
||||
const newLines = [
|
||||
"console.log(first)",
|
||||
"console.log(second)",
|
||||
"console.log(third)",
|
||||
];
|
||||
|
||||
const diff = await collectDiff(oldLines, newLines);
|
||||
|
||||
expect(diff).toEqual([
|
||||
{ type: "same", line: "console.log(first)" },
|
||||
{ type: "same", line: "console.log(second)" },
|
||||
{ type: "new", line: "console.log(third)" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("remove line", async () => {
|
||||
const oldLines = [
|
||||
"console.log(first)",
|
||||
"console.log(second)",
|
||||
"console.log(third)",
|
||||
];
|
||||
const newLines = ["console.log(first)", "console.log(third)"];
|
||||
|
||||
const diff = await collectDiff(oldLines, newLines);
|
||||
|
||||
expect(diff).toEqual([
|
||||
{ type: "same", line: "console.log(first)" },
|
||||
{ type: "old", line: "console.log(second)" },
|
||||
{ type: "same", line: "console.log(third)" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("modify line", async () => {
|
||||
const oldLines = [
|
||||
"console.log(first)",
|
||||
"console.log(second)",
|
||||
"console.log(third)",
|
||||
];
|
||||
const newLines = [
|
||||
"console.log(first)",
|
||||
"console.log(modified second)",
|
||||
"console.log(third)",
|
||||
];
|
||||
|
||||
const diff = await collectDiff(oldLines, newLines);
|
||||
|
||||
expect(diff).toEqual([
|
||||
{ type: "same", line: "console.log(first)" },
|
||||
{ type: "old", line: "console.log(second)" },
|
||||
{ type: "new", line: "console.log(modified second)" },
|
||||
{ type: "same", line: "console.log(third)" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("add multiple lines", async () => {
|
||||
const oldLines = ["console.log(first)", "fourth"];
|
||||
const newLines = [
|
||||
"console.log(first)",
|
||||
"console.log(second)",
|
||||
"console.log(third)",
|
||||
"fourth",
|
||||
];
|
||||
|
||||
const diff = await collectDiff(oldLines, newLines);
|
||||
|
||||
expect(diff).toEqual([
|
||||
{ type: "same", line: "console.log(first)" },
|
||||
{ type: "new", line: "console.log(second)" },
|
||||
{ type: "new", line: "console.log(third)" },
|
||||
{ type: "same", line: "fourth" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("remove multiple lines", async () => {
|
||||
const oldLines = [
|
||||
"console.log(first)",
|
||||
"console.log(second)",
|
||||
"console.log(third)",
|
||||
"fourth",
|
||||
];
|
||||
const newLines = ["console.log(first)", "fourth"];
|
||||
|
||||
const diff = await collectDiff(oldLines, newLines);
|
||||
|
||||
expect(diff).toEqual([
|
||||
{ type: "same", line: "console.log(first)" },
|
||||
{ type: "old", line: "console.log(second)" },
|
||||
{ type: "old", line: "console.log(third)" },
|
||||
{ type: "same", line: "fourth" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("empty old lines", async () => {
|
||||
const oldLines: string[] = [];
|
||||
const newLines = ["console.log(first)", "console.log(second)"];
|
||||
|
||||
const diff = await collectDiff(oldLines, newLines);
|
||||
|
||||
expect(diff).toEqual([
|
||||
{ type: "new", line: "console.log(first)" },
|
||||
{ type: "new", line: "console.log(second)" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("empty new lines", async () => {
|
||||
const oldLines = ["console.log(first)", "console.log(second)"];
|
||||
const newLines: string[] = [];
|
||||
|
||||
const diff = await collectDiff(oldLines, newLines);
|
||||
|
||||
expect(diff).toEqual([
|
||||
{ type: "old", line: "console.log(first)" },
|
||||
{ type: "old", line: "console.log(second)" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
@ -139,6 +139,24 @@ export function getTsConfigPath(): string {
|
|||
return tsConfigPath;
|
||||
}
|
||||
|
||||
export function getContinueRcPath(): string {
|
||||
// Disable indexing of the config folder to prevent infinite loops
|
||||
const continuercPath = path.join(getContinueGlobalPath(), ".continuerc.json");
|
||||
if (!fs.existsSync(continuercPath)) {
|
||||
fs.writeFileSync(
|
||||
continuercPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
disableIndexing: true,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
}
|
||||
return continuercPath;
|
||||
}
|
||||
|
||||
export function devDataPath(): string {
|
||||
const sPath = path.join(getContinueGlobalPath(), "dev_data");
|
||||
if (!fs.existsSync(sPath)) {
|
||||
|
|
@ -177,19 +195,20 @@ function getMigrationsFolderPath(): string {
|
|||
return migrationsPath;
|
||||
}
|
||||
|
||||
export function migrate(
|
||||
export async function migrate(
|
||||
id: string,
|
||||
callback: () => void,
|
||||
callback: () => void | Promise<void>,
|
||||
onAlreadyComplete?: () => void,
|
||||
) {
|
||||
const migrationsPath = getMigrationsFolderPath();
|
||||
const migrationPath = path.join(migrationsPath, id);
|
||||
|
||||
if (!fs.existsSync(migrationPath)) {
|
||||
try {
|
||||
callback();
|
||||
await callback();
|
||||
fs.writeFileSync(migrationPath, "");
|
||||
} catch (e) {
|
||||
console.error(`Migration ${id} failed`, e);
|
||||
console.warn(`Migration ${id} failed`, e);
|
||||
}
|
||||
} else if (onAlreadyComplete) {
|
||||
onAlreadyComplete();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,14 @@ As an example, say you are working on solving a new GitHub Issue. You type '@iss
|
|||
|
||||
To use any of the built-in context providers, open `~/.continue/config.json` and add it to the `contextProviders` list.
|
||||
|
||||
### Files
|
||||
|
||||
Type '@file' to reference any file in your current workspace.
|
||||
|
||||
```json
|
||||
{ "name": "file" }
|
||||
```
|
||||
|
||||
### Code
|
||||
|
||||
Type '@code' to reference specific functions or classes from throughout your project.
|
||||
|
|
@ -50,6 +58,28 @@ Type `@docs` to index and retrieve snippets from any documentation site. You can
|
|||
|
||||
Continue also pre-indexes a number of common sites, listed [here](https://github.com/continuedev/continue/blob/main/core/indexing/docs/preIndexedDocs.ts). The embeddings for these sites are hosted by us, but downloaded for local use after the first time. All other indexing occurs entirely locally.
|
||||
|
||||
#### Adding a Documentation Site via Configuration
|
||||
|
||||
To add a documentation site via configuration, update the `config.json` file as follows:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "docs",
|
||||
"params": {
|
||||
"sites": [
|
||||
{
|
||||
"title": "ExampleDocs",
|
||||
"startUrl": "https://exampledocs.com/docs",
|
||||
"rootUrl": "https://exampledocs.com",
|
||||
"maxDepth": 3 // Default
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The docs are indexed when you modify the configuration file, unless indexing is disabled. If you want to manually trigger the indexing, you can use the command `Continue: Docs Index`. For force indexing, you can use the command `Continue: Docs Force Re-Index`. Note that these commands will work even if automatic indexing is disabled.
|
||||
|
||||
### Open Files
|
||||
|
||||
Type '@open' to reference the contents of all of your open files. Set `onlyPinned` to `true` to only reference pinned files.
|
||||
|
|
@ -498,9 +528,7 @@ Continue exposes an API for registering context providers from a 3rd party VSCod
|
|||
|
||||
```json
|
||||
{
|
||||
"extensionDependencies": [
|
||||
"continue.continue"
|
||||
],
|
||||
"extensionDependencies": ["continue.continue"]
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -513,7 +541,6 @@ Here is an example:
|
|||
import * as vscode from "vscode";
|
||||
|
||||
class MyCustomProvider implements IContextProvider {
|
||||
|
||||
get description(): ContextProviderDescription {
|
||||
return {
|
||||
title: "custom",
|
||||
|
|
@ -525,7 +552,7 @@ class MyCustomProvider implements IContextProvider {
|
|||
|
||||
async getContextItems(
|
||||
query: string,
|
||||
extras: ContextProviderExtras
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]> {
|
||||
return [
|
||||
{
|
||||
|
|
@ -537,7 +564,7 @@ class MyCustomProvider implements IContextProvider {
|
|||
}
|
||||
|
||||
async loadSubmenuItems(
|
||||
args: LoadSubmenuItemsArgs
|
||||
args: LoadSubmenuItemsArgs,
|
||||
): Promise<ContextSubmenuItem[]> {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -554,5 +581,4 @@ const continueApi = continueExt?.exports;
|
|||
|
||||
// register your custom provider
|
||||
continueApi?.registerCustomContextProvider(customProvider);
|
||||
|
||||
```
|
||||
```
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ The [Mistral](https://mistral.ai) API provides hosted access to their models, in
|
|||
"models": [
|
||||
{
|
||||
"provider": "mistral",
|
||||
"title": "Mistral Small",
|
||||
"model": "mistral-small",
|
||||
"title": "Codestral",
|
||||
"model": "codestral-latest",
|
||||
"apiKey": "<API_KEY>"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ function modifyConfig(config: Config): Config {
|
|||
}
|
||||
```
|
||||
|
||||
This exact function and a few other default implementations are available in [`continuedev.libs.llm.prompts.chat`](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/prompts/chat.py).
|
||||
This exact function and a few other default implementations are available in [`core/llm/templates/chat.ts`](https://github.com/continuedev/continue/blob/main/core/llm/templates/chat.ts).
|
||||
|
||||
## Customizing the /edit Prompt
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
---
|
||||
title: Quick Actions (experimental, VS Code only)
|
||||
description: Quick Actions automate repetitive tasks and streamline your development workflow
|
||||
description: Quick Actions streamline your development workflow by allowing quick edits on selected classes or functions
|
||||
keywords: [experimental, automate, configuration]
|
||||
toc_max_heading_level: 5
|
||||
---
|
||||
|
||||
# Quick Actions (experimental, VS Code only)
|
||||
## Quick Actions (experimental, VS Code only)
|
||||
|
||||
Quick Actions automate repetitive tasks and streamline your development workflow. Configure custom actions to execute complex operations with a single click.
|
||||
Quick Actions streamline your development workflow by providing a tool to quickly select an entire class or function to perform a quick edit on. Configure custom actions to execute complex operations with a single click.
|
||||
|
||||

|
||||
|
||||
|
|
@ -19,10 +19,9 @@ For the language of the file you have open, you must have the Language Server Pr
|
|||
|
||||
Quick Actions use a CodeLens provider to add interactive elements above functions and classes in your code.
|
||||
|
||||
By default, Quick Actions include two predefined actions:
|
||||
By default, Quick Actions include a single predefined action:
|
||||
|
||||
1. `Explain`: This action provides a short explanation of the selected code.
|
||||
2. `Docstring`: This action generates a docstring comment and inserts it above the code.
|
||||
- `Continue`: This action allows you to perform a quick edit on the selected class or function.
|
||||
|
||||
## How to disable Quick Actions
|
||||
|
||||
|
|
|
|||
8
docs/static/schemas/config.json
vendored
8
docs/static/schemas/config.json
vendored
|
|
@ -899,6 +899,7 @@
|
|||
"model": {
|
||||
"enum": [
|
||||
"codestral-latest",
|
||||
"codestral-mamba-latest",
|
||||
"open-mistral-7b",
|
||||
"open-mixtral-8x7b",
|
||||
"open-mixtral-8x22b",
|
||||
|
|
@ -1906,6 +1907,13 @@
|
|||
"title": "Request Options",
|
||||
"description": "Request options to be used in any fetch requests made by the embeddings provider",
|
||||
"$ref": "#/definitions/RequestOptions"
|
||||
},
|
||||
"maxChunkSize": {
|
||||
"title": "Maximum Chunk Size",
|
||||
"description": "The maximum number of tokens that each chunk of a document is allowed to have",
|
||||
"type": "integer",
|
||||
"minimum": 128,
|
||||
"exclusiveMaximum": 2147483647
|
||||
}
|
||||
},
|
||||
"required": ["provider"],
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ pluginGroup = com.github.continuedev.continueintellijextension
|
|||
pluginName = continue-intellij-extension
|
||||
pluginRepositoryUrl = https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion = 0.0.53
|
||||
pluginVersion = 0.0.54
|
||||
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild = 223
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package com.github.continuedev.continueintellijextension.autocomplete
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup
|
||||
import com.intellij.openapi.components.service
|
||||
|
||||
class AutocompleteActionGroup : DefaultActionGroup() {
|
||||
override fun getActionUpdateThread(): ActionUpdateThread {
|
||||
return ActionUpdateThread.EDT
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
super.update(e)
|
||||
removeAll()
|
||||
|
||||
val continueSettingsService = service<ContinueExtensionSettings>()
|
||||
if (continueSettingsService.continueState.enableTabAutocomplete) {
|
||||
addAll(
|
||||
DisableTabAutocompleteAction(),
|
||||
)
|
||||
} else {
|
||||
addAll(
|
||||
EnableTabAutocompleteAction(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,10 +12,15 @@ import com.intellij.openapi.util.TextRange
|
|||
class AutocompleteCaretListener: CaretListener {
|
||||
override fun caretPositionChanged(event: CaretEvent) {
|
||||
val caret = event.caret ?: return
|
||||
val oldPosition = event.oldPosition
|
||||
val offset = caret.offset
|
||||
val editor = caret.editor
|
||||
val autocompleteService = editor.project?.service<AutocompleteService>() ?: return
|
||||
|
||||
if (autocompleteService.lastChangeWasPartialAccept) {
|
||||
autocompleteService.lastChangeWasPartialAccept = false
|
||||
return
|
||||
}
|
||||
|
||||
val pending = autocompleteService.pendingCompletion;
|
||||
if (pending != null && pending.editor == editor && pending.offset == offset) {
|
||||
return
|
||||
|
|
@ -29,10 +34,16 @@ class AutocompleteDocumentListener(private val editorManager: FileEditorManager,
|
|||
if (editor != editorManager.selectedTextEditor) {
|
||||
return
|
||||
}
|
||||
|
||||
val service = editor.project?.service<AutocompleteService>() ?: return
|
||||
if (service.lastChangeWasPartialAccept) {
|
||||
return
|
||||
}
|
||||
|
||||
// Invoke later is important, otherwise the completion will be triggered before the document is updated
|
||||
// causing the old caret offset to be used
|
||||
invokeLater {
|
||||
editor.project?.service<AutocompleteService>()?.triggerCompletion(editor)
|
||||
service.triggerCompletion(editor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,18 +14,29 @@ import com.intellij.openapi.editor.Editor
|
|||
import com.intellij.openapi.editor.InlayProperties
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
|
||||
data class PendingCompletion (
|
||||
val editor: Editor,
|
||||
val offset: Int,
|
||||
val completionId: String,
|
||||
val text: String?
|
||||
val editor: Editor,
|
||||
var offset: Int,
|
||||
val completionId: String,
|
||||
var text: String?
|
||||
)
|
||||
|
||||
@Service(Service.Level.PROJECT)
|
||||
class AutocompleteService(private val project: Project) {
|
||||
var pendingCompletion: PendingCompletion? = null;
|
||||
private val autocompleteLookupListener = project.service<AutocompleteLookupListener>()
|
||||
private var widget: AutocompleteSpinnerWidget? = null
|
||||
|
||||
// To avoid triggering another completion on partial acceptance,
|
||||
// we need to keep track of whether the last change was a partial accept
|
||||
var lastChangeWasPartialAccept = false
|
||||
|
||||
init {
|
||||
val statusBar = WindowManager.getInstance().getStatusBar(project)
|
||||
widget = statusBar.getWidget("AutocompleteSpinnerWidget") as? AutocompleteSpinnerWidget
|
||||
}
|
||||
|
||||
fun triggerCompletion(editor: Editor) {
|
||||
val settings =
|
||||
|
|
@ -42,6 +53,7 @@ class AutocompleteService(private val project: Project) {
|
|||
val completionId = uuid()
|
||||
val offset = editor.caretModel.primaryCaret.offset
|
||||
pendingCompletion = PendingCompletion(editor, offset, completionId, null)
|
||||
widget?.setLoading(true)
|
||||
|
||||
// Request a completion from the core
|
||||
val virtualFile = FileDocumentManager.getInstance().getFile(editor.document)
|
||||
|
|
@ -63,11 +75,13 @@ class AutocompleteService(private val project: Project) {
|
|||
val lineLength = lineEnd - lineStart
|
||||
|
||||
project.service<ContinuePluginService>().coreMessenger?.request("autocomplete/complete", input, null, ({ response ->
|
||||
widget?.setLoading(false)
|
||||
|
||||
val completions = response as List<*>
|
||||
if (completions.isNotEmpty()) {
|
||||
val completion = completions[0].toString()
|
||||
|
||||
if (completion.lines().size === 1 || column >= lineLength) {
|
||||
if (completion.isNotEmpty() && (completion.lines().size === 1 || column >= lineLength)) {
|
||||
// Do not render if completion is multi-line and caret is in middle of line
|
||||
renderCompletion(editor, offset, completion)
|
||||
pendingCompletion = pendingCompletion?.copy(text = completion)
|
||||
|
|
@ -80,12 +94,18 @@ class AutocompleteService(private val project: Project) {
|
|||
}
|
||||
|
||||
private fun renderCompletion(editor: Editor, offset: Int, text: String) {
|
||||
if (text.isEmpty()) {
|
||||
return
|
||||
}
|
||||
// Don't render completions when code completion dropdown is visible
|
||||
if (!autocompleteLookupListener.isLookupEmpty()) {
|
||||
return
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
WriteAction.run<Throwable> {
|
||||
// Clear existing completions
|
||||
hideCompletions(editor)
|
||||
|
||||
val properties = InlayProperties()
|
||||
properties.relatesToPrecedingText(true)
|
||||
properties.disableSoftWrapping(true)
|
||||
|
|
@ -120,8 +140,57 @@ class AutocompleteService(private val project: Project) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun splitKeepingDelimiters(input: String, delimiterPattern: String = "\\s+"): List<String> {
|
||||
val initialSplit = input.split("(?<=$delimiterPattern)|(?=$delimiterPattern)".toRegex())
|
||||
.filter { it.isNotEmpty() }
|
||||
|
||||
val result = mutableListOf<String>()
|
||||
var currentDelimiter = ""
|
||||
|
||||
for (part in initialSplit) {
|
||||
if (part.matches(delimiterPattern.toRegex())) {
|
||||
currentDelimiter += part
|
||||
} else {
|
||||
if (currentDelimiter.isNotEmpty()) {
|
||||
result.add(currentDelimiter)
|
||||
currentDelimiter = ""
|
||||
}
|
||||
result.add(part)
|
||||
}
|
||||
}
|
||||
|
||||
if (currentDelimiter.isNotEmpty()) {
|
||||
result.add(currentDelimiter)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
fun partialAccept() {
|
||||
val completion = pendingCompletion ?: return
|
||||
val text = completion.text ?: return
|
||||
val editor = completion.editor
|
||||
val offset = completion.offset
|
||||
|
||||
lastChangeWasPartialAccept = true
|
||||
|
||||
// Split the text into words, keeping delimiters
|
||||
val words = splitKeepingDelimiters(text)
|
||||
println(words)
|
||||
val word = words[0]
|
||||
editor.document.insertString(offset, word)
|
||||
editor.caretModel.moveToOffset(offset + word.length)
|
||||
|
||||
// Remove the completion and re-display it
|
||||
hideCompletions(editor)
|
||||
completion.text = text.substring(word.length)
|
||||
completion.offset += word.length
|
||||
renderCompletion(editor, completion.offset, completion.text!!)
|
||||
}
|
||||
|
||||
private fun cancelCompletion(completion: PendingCompletion) {
|
||||
// Send cancellation message to core
|
||||
widget?.setLoading(false)
|
||||
project.service<ContinuePluginService>().coreMessenger?.request("autocomplete/cancel", null,null, ({}))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
package com.github.continuedev.continueintellijextension.autocomplete
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.wm.StatusBar
|
||||
import com.intellij.openapi.wm.StatusBarWidget
|
||||
import com.intellij.openapi.util.IconLoader
|
||||
import com.intellij.openapi.wm.StatusBarWidgetFactory
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
import com.intellij.openapi.wm.impl.status.EditorBasedWidget
|
||||
import com.intellij.ui.AnimatedIcon
|
||||
import com.intellij.util.Consumer
|
||||
import java.awt.event.MouseEvent
|
||||
import javax.swing.Icon
|
||||
import javax.swing.JLabel
|
||||
|
||||
class AutocompleteSpinnerWidget(project: Project): EditorBasedWidget(project), StatusBarWidget.IconPresentation, Disposable {
|
||||
private val iconLabel = JLabel()
|
||||
private var isLoading = false
|
||||
|
||||
private val animatedIcon = AnimatedIcon(
|
||||
100,
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading1(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading2(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading3(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading4(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading5(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading6(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading7(RiderLight).svg", javaClass),
|
||||
IconLoader.getIcon("/icons/AnimationLoadingIcon/AnimationLoading8(RiderLight).svg", javaClass),
|
||||
)
|
||||
|
||||
init {
|
||||
updateIcon()
|
||||
}
|
||||
|
||||
fun show() {
|
||||
println("Showing autocomplete spinner widget")
|
||||
}
|
||||
|
||||
override fun dispose() {}
|
||||
|
||||
override fun ID(): String {
|
||||
return "AutocompleteSpinnerWidget"
|
||||
}
|
||||
|
||||
override fun getTooltipText(): String? {
|
||||
val enabled = service<ContinueExtensionSettings>().state.enableTabAutocomplete
|
||||
return if (enabled) "Continue Autocomplete Enabled" else "Continue Autocomplete Disabled"
|
||||
}
|
||||
|
||||
override fun getClickConsumer(): Consumer<MouseEvent>? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getIcon(): Icon = if (isLoading) animatedIcon else
|
||||
IconLoader.getIcon("/icons/continue.svg", javaClass)
|
||||
|
||||
fun setLoading(loading: Boolean) {
|
||||
isLoading = loading
|
||||
updateIcon()
|
||||
}
|
||||
|
||||
private fun updateIcon() {
|
||||
iconLabel.icon = getIcon()
|
||||
|
||||
|
||||
// Update the widget
|
||||
val statusBar = WindowManager.getInstance().getStatusBar(project)
|
||||
statusBar.updateWidget(ID())
|
||||
}
|
||||
|
||||
override fun install(statusBar: StatusBar) {
|
||||
updateIcon()
|
||||
}
|
||||
|
||||
override fun getPresentation(): StatusBarWidget.WidgetPresentation? {
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
class AutocompleteSpinnerWidgetFactory: StatusBarWidgetFactory {
|
||||
fun create(project: Project): AutocompleteSpinnerWidget {
|
||||
return AutocompleteSpinnerWidget(project)
|
||||
}
|
||||
|
||||
override fun getId(): String {
|
||||
return "AutocompleteSpinnerWidget"
|
||||
}
|
||||
|
||||
override fun getDisplayName(): String {
|
||||
return "Continue Autocomplete"
|
||||
}
|
||||
|
||||
override fun isAvailable(p0: Project): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun createWidget(project: Project): StatusBarWidget {
|
||||
return AutocompleteSpinnerWidget(project)
|
||||
}
|
||||
|
||||
override fun disposeWidget(p0: StatusBarWidget) {
|
||||
Disposer.dispose(p0)
|
||||
}
|
||||
|
||||
override fun canBeEnabledOn(p0: StatusBar): Boolean = true
|
||||
}
|
||||
|
|
@ -19,7 +19,8 @@ class ContinueCustomElementRenderer (
|
|||
val text: String,
|
||||
) : EditorCustomElementRenderer {
|
||||
override fun calcWidthInPixels(inlay: Inlay<*>): Int {
|
||||
return (inlay.editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(this.text)
|
||||
val width = (inlay.editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(this.text)
|
||||
return width
|
||||
}
|
||||
|
||||
private fun font(editor: Editor): Font {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@ import com.intellij.openapi.editor.colors.EditorFontType
|
|||
import com.intellij.openapi.editor.impl.EditorImpl
|
||||
import com.intellij.openapi.editor.impl.FontInfo
|
||||
import com.intellij.openapi.editor.markup.TextAttributes
|
||||
import com.intellij.ui.Gray
|
||||
import com.intellij.ui.JBColor
|
||||
import java.awt.Color
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import java.awt.Font
|
||||
import java.awt.Graphics
|
||||
import java.awt.Rectangle
|
||||
|
|
@ -39,7 +38,7 @@ class ContinueMultilineCustomElementRenderer (
|
|||
protected val font: Font
|
||||
get() {
|
||||
val editorFont = editor.colorsScheme.getFont(EditorFontType.PLAIN)
|
||||
return editorFont.deriveFont(Font.PLAIN) ?: editorFont
|
||||
return UIUtil.getFontWithFallbackIfNeeded(editorFont, text).deriveFont(editor.colorsScheme.editorFontSize)
|
||||
}
|
||||
|
||||
private fun offsetY(): Int {
|
||||
|
|
@ -58,7 +57,9 @@ class ContinueMultilineCustomElementRenderer (
|
|||
FontInfo.getFontMetrics(font, FontInfo.getFontRenderContext(editor.contentComponent))
|
||||
val fontWidth =
|
||||
font.createGlyphVector(metrics.fontRenderContext, text).visualBounds.width
|
||||
val widthBeforeCaret = (editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(text.substring(0, currentColumn))
|
||||
val widthBeforeCaret = (editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(
|
||||
text.substring(0, minOf(currentColumn, text.length))
|
||||
)
|
||||
return max(0, widthBeforeCaret - (editor as EditorImpl).scrollingModel.horizontalScrollOffset)
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ class ContinueMultilineCustomElementRenderer (
|
|||
var additionalYOffset = -editor.lineHeight;
|
||||
var isFirstLine = true
|
||||
for (line in text.lines()) {
|
||||
g.drawString(line, if (isFirstLine) targetRegion.x + offsetX() else targetRegion.x, targetRegion.y + offsetY() + additionalYOffset)
|
||||
g.drawString(line, if (isFirstLine) targetRegion.x + offsetX() else targetRegion.x, targetRegion.y + inlay.editor.ascent + additionalYOffset)
|
||||
additionalYOffset += editor.lineHeight
|
||||
isFirstLine = false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.github.continuedev.continueintellijextension.autocomplete
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.components.service
|
||||
class DisableTabAutocompleteAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val continueSettingsService = service<ContinueExtensionSettings>()
|
||||
continueSettingsService.continueState.enableTabAutocomplete = true
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.github.continuedev.continueintellijextension.autocomplete
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.components.service
|
||||
class EnableTabAutocompleteAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val continueSettingsService = service<ContinueExtensionSettings>()
|
||||
continueSettingsService.continueState.enableTabAutocomplete = true
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler
|
|||
class PartialAcceptAutocompleteAction: EditorAction(object : EditorActionHandler() {
|
||||
override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) {
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
// TODO
|
||||
// editor.project?.service<AutocompleteService>()?.accept()
|
||||
editor.project?.service<AutocompleteService>()?.partialAccept()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class InlineEditAction : AnAction(), DumbAware {
|
|||
val modelTitles = mutableListOf<String>()
|
||||
continuePluginService.coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response ->
|
||||
val config = response as Map<String, Any>
|
||||
val models = config["models"] as List<Map<String, Any>>
|
||||
val models = (config["config"] as Map<String, Any>)["models"] as List<Map<String, Any>>
|
||||
modelTitles.addAll(models.map { it["title"] as String })
|
||||
}
|
||||
val maxWaitTime = 200
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
<projectService
|
||||
id="AutocompleteLookupListener"
|
||||
serviceImplementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteLookupListener"/>
|
||||
<statusBarWidgetFactory implementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteSpinnerWidgetFactory"
|
||||
id="AutocompleteSpinnerWidget"/>
|
||||
</extensions>
|
||||
|
||||
<resource-bundle>messages.MyBundle</resource-bundle>
|
||||
|
|
@ -108,10 +110,6 @@
|
|||
text="Start New Continue Session"
|
||||
icon="AllIcons.General.Add"
|
||||
description="Start New Continue Session">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="alt ctrl N"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="alt meta N"/>
|
||||
</action>
|
||||
|
||||
<action id="continue.viewHistory"
|
||||
|
|
@ -147,6 +145,13 @@
|
|||
text="Cancel Autocomplete Suggestion" description="Cancel Autocomplete Suggestion">
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="ESCAPE"/>
|
||||
</action>
|
||||
<action id="com.github.continuedev.continueintellijextension.autocomplete.PartialAcceptAutocompleteAction"
|
||||
class="com.github.continuedev.continueintellijextension.autocomplete.PartialAcceptAutocompleteAction"
|
||||
text="Partial Accept Autocomplete Suggestion"
|
||||
description="Partial Accept Autocomplete Suggestion">
|
||||
<keyboard-shortcut first-keystroke="control alt RIGHT" keymap="$default"/>
|
||||
<keyboard-shortcut first-keystroke="alt meta RIGHT" keymap="Mac OS X"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -899,6 +899,7 @@
|
|||
"model": {
|
||||
"enum": [
|
||||
"codestral-latest",
|
||||
"codestral-mamba-latest",
|
||||
"open-mistral-7b",
|
||||
"open-mixtral-8x7b",
|
||||
"open-mixtral-8x22b",
|
||||
|
|
@ -1906,6 +1907,13 @@
|
|||
"title": "Request Options",
|
||||
"description": "Request options to be used in any fetch requests made by the embeddings provider",
|
||||
"$ref": "#/definitions/RequestOptions"
|
||||
},
|
||||
"maxChunkSize": {
|
||||
"title": "Maximum Chunk Size",
|
||||
"description": "The maximum number of tokens that each chunk of a document is allowed to have",
|
||||
"type": "integer",
|
||||
"minimum": 128,
|
||||
"exclusiveMaximum": 2147483647
|
||||
}
|
||||
},
|
||||
"required": ["provider"],
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1,017 B |
|
|
@ -899,6 +899,7 @@
|
|||
"model": {
|
||||
"enum": [
|
||||
"codestral-latest",
|
||||
"codestral-mamba-latest",
|
||||
"open-mistral-7b",
|
||||
"open-mixtral-8x7b",
|
||||
"open-mixtral-8x22b",
|
||||
|
|
@ -1906,6 +1907,13 @@
|
|||
"title": "Request Options",
|
||||
"description": "Request options to be used in any fetch requests made by the embeddings provider",
|
||||
"$ref": "#/definitions/RequestOptions"
|
||||
},
|
||||
"maxChunkSize": {
|
||||
"title": "Maximum Chunk Size",
|
||||
"description": "The maximum number of tokens that each chunk of a document is allowed to have",
|
||||
"type": "integer",
|
||||
"minimum": 128,
|
||||
"exclusiveMaximum": 2147483647
|
||||
}
|
||||
},
|
||||
"required": ["provider"],
|
||||
|
|
|
|||
|
|
@ -983,6 +983,7 @@
|
|||
"model": {
|
||||
"enum": [
|
||||
"codestral-latest",
|
||||
"codestral-mamba-latest",
|
||||
"open-mistral-7b",
|
||||
"open-mixtral-8x7b",
|
||||
"open-mixtral-8x22b",
|
||||
|
|
@ -2119,6 +2120,13 @@
|
|||
"title": "Request Options",
|
||||
"description": "Request options to be used in any fetch requests made by the embeddings provider",
|
||||
"$ref": "#/definitions/RequestOptions"
|
||||
},
|
||||
"maxChunkSize": {
|
||||
"title": "Maximum Chunk Size",
|
||||
"description": "The maximum number of tokens that each chunk of a document is allowed to have",
|
||||
"type": "integer",
|
||||
"minimum": 128,
|
||||
"exclusiveMaximum": 2147483647
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
|
|
|||
5
extensions/vscode/package-lock.json
generated
5
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.181",
|
||||
"version": "0.9.184",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.181",
|
||||
"version": "0.9.184",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
@ -98,6 +98,7 @@
|
|||
"@aws-sdk/client-bedrock-runtime": "^3.574.0",
|
||||
"@aws-sdk/credential-providers": "^3.596.0",
|
||||
"@continuedev/config-types": "^1.0.6",
|
||||
"@continuedev/llm-info": "^1.0.1",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@types/jsdom": "^21.1.6",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"version": "0.9.182",
|
||||
"version": "0.9.184",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -229,6 +229,18 @@
|
|||
"category": "Continue",
|
||||
"title": "Fix Grammar / Spelling",
|
||||
"group": "Continue"
|
||||
},
|
||||
{
|
||||
"command": "continue.docsIndex",
|
||||
"category": "Continue",
|
||||
"title": "Docs Index",
|
||||
"group": "Continue"
|
||||
},
|
||||
{
|
||||
"command": "continue.docsReIndex",
|
||||
"category": "Continue",
|
||||
"title": "Docs Force Re-Index",
|
||||
"group": "Continue"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { getTsConfigPath, migrate } from "core/util/paths";
|
||||
import { getTsConfigPath, getContinueRcPath, migrate } from "core/util/paths";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
|
|
@ -13,6 +13,7 @@ import { setupInlineTips } from "./inlineTips";
|
|||
export async function activateExtension(context: vscode.ExtensionContext) {
|
||||
// Add necessary files
|
||||
getTsConfigPath();
|
||||
getContinueRcPath();
|
||||
|
||||
// Register commands and providers
|
||||
registerQuickFixProvider();
|
||||
|
|
@ -61,4 +62,4 @@ export async function activateExtension(context: vscode.ExtensionContext) {
|
|||
extension: vscodeExtension,
|
||||
}
|
||||
: continuePublicApi;
|
||||
}
|
||||
}
|
||||
|
|
@ -22,9 +22,10 @@ import {
|
|||
import { ContinueGUIWebviewViewProvider } from "./ContinueGUIWebviewViewProvider";
|
||||
import { DiffManager } from "./diff/horizontal";
|
||||
import { VerticalPerLineDiffManager } from "./diff/verticalPerLine/manager";
|
||||
import { QuickEdit } from "./quickEdit/QuickEditQuickPick";
|
||||
import { QuickEdit, QuickEditShowParams } from "./quickEdit/QuickEditQuickPick";
|
||||
import { Battery } from "./util/battery";
|
||||
import type { VsCodeWebviewProtocol } from "./webviewProtocol";
|
||||
import { Core } from "core/core";
|
||||
|
||||
let fullScreenPanel: vscode.WebviewPanel | undefined;
|
||||
|
||||
|
|
@ -170,6 +171,7 @@ const commandsMap: (
|
|||
continueServerClientPromise: Promise<ContinueServerClient>,
|
||||
battery: Battery,
|
||||
quickEdit: QuickEdit,
|
||||
core: Core,
|
||||
) => { [command: string]: (...args: any) => any } = (
|
||||
ide,
|
||||
extensionContext,
|
||||
|
|
@ -180,6 +182,7 @@ const commandsMap: (
|
|||
continueServerClientPromise,
|
||||
battery,
|
||||
quickEdit,
|
||||
core
|
||||
) => {
|
||||
/**
|
||||
* Streams an inline edit to the vertical diff manager.
|
||||
|
|
@ -259,26 +262,10 @@ const commandsMap: (
|
|||
|
||||
vscode.commands.executeCommand("continue.continueGUIView.focus");
|
||||
},
|
||||
"continue.defaultQuickActionDocstring": async (range: vscode.Range) => {
|
||||
captureCommandTelemetry("defaultQuickActionDocstring");
|
||||
|
||||
streamInlineEdit(
|
||||
"docstring",
|
||||
"Write a docstring for this code. Do not change anything about the code itself.",
|
||||
true,
|
||||
range,
|
||||
);
|
||||
},
|
||||
"continue.defaultQuickActionExplain": async (range: vscode.Range) => {
|
||||
captureCommandTelemetry("defaultQuickActionExplain");
|
||||
|
||||
const prompt =
|
||||
`Explain the above code in a few sentences without ` +
|
||||
`going into detail on specific methods.`;
|
||||
|
||||
addCodeToContextFromRange(range, sidebar.webviewProtocol, prompt);
|
||||
|
||||
vscode.commands.executeCommand("continue.continueGUIView.focus");
|
||||
// Passthrough for telemetry purposes
|
||||
"continue.defaultQuickAction": async (args: QuickEditShowParams) => {
|
||||
captureCommandTelemetry("defaultQuickAction");
|
||||
vscode.commands.executeCommand("continue.quickEdit", args);
|
||||
},
|
||||
"continue.customQuickActionSendToChat": async (
|
||||
prompt: string,
|
||||
|
|
@ -301,6 +288,12 @@ const commandsMap: (
|
|||
"continue.toggleAuxiliaryBar": () => {
|
||||
vscode.commands.executeCommand("workbench.action.toggleAuxiliaryBar");
|
||||
},
|
||||
"continue.docsIndex": async () => {
|
||||
core.invoke("context/indexDocs", {reIndex: false});
|
||||
},
|
||||
"continue.docsReIndex": async () => {
|
||||
core.invoke("context/indexDocs", {reIndex: true});
|
||||
},
|
||||
"continue.focusContinueInput": async () => {
|
||||
const fullScreenTab = getFullScreenTab();
|
||||
if (!fullScreenTab) {
|
||||
|
|
@ -346,9 +339,9 @@ const commandsMap: (
|
|||
await addHighlightedCodeToContext(sidebar.webviewProtocol);
|
||||
}
|
||||
},
|
||||
"continue.quickEdit": async (initialPrompt?: string) => {
|
||||
"continue.quickEdit": async (args: QuickEditShowParams) => {
|
||||
captureCommandTelemetry("quickEdit");
|
||||
quickEdit.show(initialPrompt);
|
||||
quickEdit.show(args);
|
||||
},
|
||||
"continue.writeCommentsForCode": async () => {
|
||||
captureCommandTelemetry("writeCommentsForCode");
|
||||
|
|
@ -685,6 +678,7 @@ export function registerAllCommands(
|
|||
continueServerClientPromise: Promise<ContinueServerClient>,
|
||||
battery: Battery,
|
||||
quickEdit: QuickEdit,
|
||||
core: Core,
|
||||
) {
|
||||
for (const [command, callback] of Object.entries(
|
||||
commandsMap(
|
||||
|
|
@ -697,6 +691,7 @@ export function registerAllCommands(
|
|||
continueServerClientPromise,
|
||||
battery,
|
||||
quickEdit,
|
||||
core
|
||||
),
|
||||
)) {
|
||||
context.subscriptions.push(
|
||||
|
|
|
|||
|
|
@ -1,94 +0,0 @@
|
|||
import { matchLine } from "core/diff/util";
|
||||
|
||||
interface NextLineEvent {
|
||||
type: "nextLine";
|
||||
}
|
||||
|
||||
interface InsertDeletionEvent {
|
||||
type: "insertDeletion";
|
||||
lines: string[];
|
||||
aboveLineAtIndex: number;
|
||||
}
|
||||
|
||||
interface ReplaceLineEvent {
|
||||
type: "replaceLine";
|
||||
index: number;
|
||||
newLine: string;
|
||||
}
|
||||
|
||||
interface InsertLineEvent {
|
||||
type: "insertLine";
|
||||
aboveLineAtIndex: number;
|
||||
line: string;
|
||||
}
|
||||
|
||||
type VerticalPerLineDiffEvent =
|
||||
| NextLineEvent
|
||||
| InsertDeletionEvent
|
||||
| ReplaceLineEvent
|
||||
| InsertLineEvent;
|
||||
|
||||
async function* streamVerticalPerLineDiff(
|
||||
lineGenerator: AsyncGenerator<string>,
|
||||
oldCode: string,
|
||||
): AsyncGenerator<VerticalPerLineDiffEvent> {
|
||||
const remainingLines = oldCode.split("\n");
|
||||
let index = 0; // Index in terms of oldCode
|
||||
|
||||
let accumulatedDeletedLines: string[] = [];
|
||||
|
||||
for await (const line of lineGenerator) {
|
||||
const [matchIndex, isPerfectMatch] = matchLine(line, remainingLines);
|
||||
|
||||
if (matchIndex < 0) {
|
||||
// No match, so insert above remainingLines[0]
|
||||
yield {
|
||||
type: "insertLine",
|
||||
aboveLineAtIndex: index,
|
||||
line,
|
||||
};
|
||||
} else if (matchIndex === 0) {
|
||||
if (isPerfectMatch) {
|
||||
// Perfect match of the next line, so insert and clear existing block
|
||||
yield {
|
||||
type: "insertDeletion",
|
||||
lines: accumulatedDeletedLines,
|
||||
aboveLineAtIndex: index,
|
||||
};
|
||||
remainingLines.shift();
|
||||
accumulatedDeletedLines = [];
|
||||
} else {
|
||||
// Replace next line, so part of same block if one exists
|
||||
yield {
|
||||
type: "replaceLine",
|
||||
index,
|
||||
newLine: line,
|
||||
};
|
||||
|
||||
const nextLine = remainingLines.shift();
|
||||
nextLine && accumulatedDeletedLines.push();
|
||||
}
|
||||
} else {
|
||||
// Already in a block, which is disconnected from this one, so insert and clear it
|
||||
accumulatedDeletedLines.push(...remainingLines.splice(0, matchIndex));
|
||||
if (isPerfectMatch) {
|
||||
yield {
|
||||
type: "insertDeletion",
|
||||
lines: accumulatedDeletedLines,
|
||||
aboveLineAtIndex: index - accumulatedDeletedLines.length,
|
||||
};
|
||||
accumulatedDeletedLines = [];
|
||||
} else {
|
||||
// Add to the current block all of the lines in between, then replace with the new line
|
||||
yield {
|
||||
type: "insertLine",
|
||||
aboveLineAtIndex: index - accumulatedDeletedLines.length,
|
||||
line,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
index += Math.max(0, matchIndex);
|
||||
remainingLines.splice(0, matchIndex);
|
||||
}
|
||||
}
|
||||
|
|
@ -196,6 +196,7 @@ export class VsCodeExtension {
|
|||
this.core.continueServerClientPromise,
|
||||
this.battery,
|
||||
quickEdit,
|
||||
this.core
|
||||
);
|
||||
|
||||
registerDebugTracker(this.sidebar.webviewProtocol, this.ide);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import {
|
|||
} from "../../../util/workspaceConfig";
|
||||
import { isTutorialFile } from "./TutorialCodeLensProvider";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import { QuickEditShowParams } from "../../../quickEdit/QuickEditQuickPick";
|
||||
|
||||
export const ENABLE_QUICK_ACTIONS_KEY = "enableQuickActions";
|
||||
|
||||
|
|
@ -83,20 +84,14 @@ export class QuickActionsCodeLensProvider implements vscode.CodeLensProvider {
|
|||
});
|
||||
}
|
||||
|
||||
getDefaultCommands(range: vscode.Range): vscode.Command[] {
|
||||
const explain: vscode.Command = {
|
||||
command: "continue.defaultQuickActionExplain",
|
||||
title: "Explain",
|
||||
arguments: [range],
|
||||
getDefaultCommand(range: vscode.Range): vscode.Command[] {
|
||||
const quickEdit: vscode.Command = {
|
||||
command: "continue.defaultQuickAction",
|
||||
title: "Continue",
|
||||
arguments: [{ range } as QuickEditShowParams],
|
||||
};
|
||||
|
||||
const comment: vscode.Command = {
|
||||
command: "continue.defaultQuickActionDocstring",
|
||||
title: "Docstring",
|
||||
arguments: [range],
|
||||
};
|
||||
|
||||
return [explain, comment];
|
||||
return [quickEdit];
|
||||
}
|
||||
|
||||
async provideCodeLenses(
|
||||
|
|
@ -129,7 +124,7 @@ export class QuickActionsCodeLensProvider implements vscode.CodeLensProvider {
|
|||
return filteredSmybols.flatMap(({ range }) => {
|
||||
const commands: vscode.Command[] = !!this.customQuickActionsConfig
|
||||
? this.getCustomCommands(range, this.customQuickActionsConfig)
|
||||
: this.getDefaultCommands(range);
|
||||
: this.getDefaultCommand(range);
|
||||
|
||||
return commands.map((command) => new vscode.CodeLens(range, command));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import path from "path";
|
|||
import * as vscode from "vscode";
|
||||
import { getPlatform } from "../../../util/util";
|
||||
import { getExtensionUri } from "../../../util/vscode";
|
||||
import { QuickEditShowParams } from "../../../quickEdit/QuickEditQuickPick";
|
||||
|
||||
interface TutorialCodeLensItems {
|
||||
lineIncludes: string;
|
||||
|
|
@ -44,7 +45,7 @@ const actions: TutorialCodeLensItems[] = [
|
|||
{
|
||||
title: `${cmdCtrl}+I`,
|
||||
command: "continue.quickEdit",
|
||||
arguments: ["Add comments"],
|
||||
arguments: [{ initialPrompt: "Add comments" } as QuickEditShowParams],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { IDE } from "core";
|
||||
import { walkDir } from "core/indexing/walkDir";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import * as vscode from "vscode";
|
||||
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import { walkDir } from "core/indexing/walkDir";
|
||||
import { appendToHistory, getHistoryQuickPickVal } from "./HistoryQuickPick";
|
||||
import { getContextProviderQuickPickVal } from "./ContextProvidersQuickPick";
|
||||
import { appendToHistory, getHistoryQuickPickVal } from "./HistoryQuickPick";
|
||||
import { getModelQuickPickVal } from "./ModelSelectionQuickPick";
|
||||
|
||||
// @ts-ignore - error finding typings
|
||||
import MiniSearch from "minisearch";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
// @ts-ignore
|
||||
import MiniSearch from "minisearch";
|
||||
|
||||
/**
|
||||
* Used to track what action to take after a user interacts
|
||||
|
|
@ -24,6 +25,15 @@ enum QuickEditInitialItemLabels {
|
|||
Submit = "Submit",
|
||||
}
|
||||
|
||||
export type QuickEditShowParams = {
|
||||
initialPrompt?: string;
|
||||
/**
|
||||
* Used for Quick Actions where the user has not highlighted code.
|
||||
* Instead the range comes from the document symbol.
|
||||
*/
|
||||
range?: vscode.Range;
|
||||
};
|
||||
|
||||
type FileMiniSearchResult = { filename: string };
|
||||
|
||||
/**
|
||||
|
|
@ -42,6 +52,10 @@ export class QuickEdit {
|
|||
);
|
||||
|
||||
private static maxFileSearchResults = 20;
|
||||
|
||||
private range?: vscode.Range;
|
||||
private initialPrompt?: string;
|
||||
|
||||
private miniSearch = new MiniSearch<FileMiniSearchResult>({
|
||||
fields: ["filename"],
|
||||
storeFields: ["filename"],
|
||||
|
|
@ -77,11 +91,15 @@ export class QuickEdit {
|
|||
private readonly ide: IDE,
|
||||
private readonly context: vscode.ExtensionContext,
|
||||
) {
|
||||
this.intializeQuickEditState();
|
||||
this.initializeQuickEditState();
|
||||
}
|
||||
|
||||
private async intializeQuickEditState() {
|
||||
const editor = vscode.window.activeTextEditor!;
|
||||
private async initializeQuickEditState() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
|
||||
const existingHandler = this.verticalDiffManager.getHandlerForFile(
|
||||
editor.document.uri.fsPath ?? "",
|
||||
|
|
@ -141,10 +159,14 @@ export class QuickEdit {
|
|||
}
|
||||
|
||||
const fileName = vscode.workspace.asRelativePath(uri, true);
|
||||
const { start, end } = this.editorWhenOpened.selection;
|
||||
const selectionEmpty = this.editorWhenOpened.selection.isEmpty;
|
||||
|
||||
return selectionEmpty
|
||||
const { start, end } = !!this.range
|
||||
? this.range
|
||||
: this.editorWhenOpened.selection;
|
||||
|
||||
const isSelectionEmpty = start.isEqual(end);
|
||||
|
||||
return isSelectionEmpty
|
||||
? `Edit ${fileName}`
|
||||
: `Edit ${fileName}:${start.line}${
|
||||
end.line > start.line ? `-${end.line}` : ""
|
||||
|
|
@ -182,12 +204,11 @@ export class QuickEdit {
|
|||
modelTitle,
|
||||
undefined,
|
||||
this.previousInput,
|
||||
this.range,
|
||||
);
|
||||
}
|
||||
|
||||
async _getInitialQuickPickVal(
|
||||
injectedPrompt?: string,
|
||||
): Promise<string | undefined> {
|
||||
async _getInitialQuickPickVal(): Promise<string | undefined> {
|
||||
const modelTitle = await this._getCurModelTitle();
|
||||
|
||||
const initialItems: vscode.QuickPickItem[] = [
|
||||
|
|
@ -236,7 +257,7 @@ export class QuickEdit {
|
|||
"Enter a prompt to edit your code (@ to search files, ⏎ to submit)";
|
||||
quickPick.title = this._getQuickPickTitle();
|
||||
quickPick.ignoreFocusOut = true;
|
||||
quickPick.value = injectedPrompt ?? "";
|
||||
quickPick.value = this.initialPrompt ?? "";
|
||||
|
||||
quickPick.show();
|
||||
|
||||
|
|
@ -341,18 +362,35 @@ export class QuickEdit {
|
|||
return selectedItemLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the state of the quick pick
|
||||
*/
|
||||
private clear() {
|
||||
this.initialPrompt = undefined;
|
||||
this.range = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the Quick Edit Quick Pick, allowing the user to select an initial item or enter a prompt.
|
||||
* Displays a quick pick for "History" or "ContextProviders" to set the prompt or context provider string.
|
||||
* Displays a quick pick for "Model" to set the current model title.
|
||||
* Appends the entered prompt to the history and streams the edit with input and context.
|
||||
*/
|
||||
async show(initialPrompt?: string) {
|
||||
async show(args?: QuickEditShowParams) {
|
||||
// Clean up state from previous quick picks, e.g. if a user pressed `esc`
|
||||
this.clear();
|
||||
|
||||
const config = await this.configHandler.loadConfig();
|
||||
|
||||
const selectedLabelOrInputVal = await this._getInitialQuickPickVal(
|
||||
initialPrompt,
|
||||
);
|
||||
if (!!args?.initialPrompt) {
|
||||
this.initialPrompt = args.initialPrompt;
|
||||
}
|
||||
|
||||
if (!!args?.range) {
|
||||
this.range = args.range;
|
||||
}
|
||||
|
||||
const selectedLabelOrInputVal = await this._getInitialQuickPickVal();
|
||||
|
||||
Telemetry.capture("quickEditSelection", {
|
||||
selection: selectedLabelOrInputVal,
|
||||
|
|
@ -374,7 +412,7 @@ export class QuickEdit {
|
|||
this.contextProviderStr = contextProviderVal ?? "";
|
||||
|
||||
// Recurse back to let the user write their prompt
|
||||
this.show(initialPrompt);
|
||||
this.show(args);
|
||||
|
||||
break;
|
||||
|
||||
|
|
@ -391,7 +429,7 @@ export class QuickEdit {
|
|||
}
|
||||
|
||||
// Recurse back to let the user write their prompt
|
||||
this.show(initialPrompt);
|
||||
this.show(args);
|
||||
|
||||
break;
|
||||
|
||||
|
|
|
|||
8
gui/package-lock.json
generated
8
gui/package-lock.json
generated
|
|
@ -64,6 +64,7 @@
|
|||
"devDependencies": {
|
||||
"@swc/cli": "^0.3.12",
|
||||
"@swc/core": "^1.5.25",
|
||||
"@types/lodash": "^4.17.6",
|
||||
"@types/node": "^20.5.6",
|
||||
"@types/node-fetch": "^2.6.4",
|
||||
"@types/react": "^18.0.27",
|
||||
|
|
@ -90,6 +91,7 @@
|
|||
"@aws-sdk/client-bedrock-runtime": "^3.574.0",
|
||||
"@aws-sdk/credential-providers": "^3.596.0",
|
||||
"@continuedev/config-types": "^1.0.6",
|
||||
"@continuedev/llm-info": "^1.0.1",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@types/jsdom": "^21.1.6",
|
||||
|
|
@ -1998,6 +2000,12 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/lodash": {
|
||||
"version": "4.17.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.6.tgz",
|
||||
"integrity": "sha512-OpXEVoCKSS3lQqjx9GGGOapBeuW5eUboYHRlHP9urXPX25IKZ6AnP5ZRxtVf63iieUbsHxLn8NQ5Nlftc6yzAA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/mdast": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@
|
|||
"devDependencies": {
|
||||
"@swc/cli": "^0.3.12",
|
||||
"@swc/core": "^1.5.25",
|
||||
"@types/lodash": "^4.17.6",
|
||||
"@types/node": "^20.5.6",
|
||||
"@types/node-fetch": "^2.6.4",
|
||||
"@types/react": "^18.0.27",
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1,017 B |
|
|
@ -11,6 +11,14 @@ const GridDiv = styled.div`
|
|||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 8px;
|
||||
align-items: center;
|
||||
|
||||
> * {
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
> :nth-last-child(2):first-child {
|
||||
grid-column: 1;
|
||||
}
|
||||
`;
|
||||
|
||||
interface ConfirmationDialogProps {
|
||||
|
|
@ -18,6 +26,8 @@ interface ConfirmationDialogProps {
|
|||
onCancel?: () => void;
|
||||
text: string;
|
||||
title?: string;
|
||||
hideCancelButton?: boolean;
|
||||
confirmText?: string;
|
||||
}
|
||||
|
||||
function ConfirmationDialog(props: ConfirmationDialogProps) {
|
||||
|
|
@ -29,15 +39,17 @@ function ConfirmationDialog(props: ConfirmationDialogProps) {
|
|||
<p>{props.text}</p>
|
||||
|
||||
<GridDiv>
|
||||
<SecondaryButton
|
||||
onClick={() => {
|
||||
props.onCancel?.();
|
||||
dispatch(setShowDialog(false));
|
||||
dispatch(setDialogMessage(undefined));
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</SecondaryButton>
|
||||
{!!props.hideCancelButton || (
|
||||
<SecondaryButton
|
||||
onClick={() => {
|
||||
props.onCancel?.();
|
||||
dispatch(setShowDialog(false));
|
||||
dispatch(setDialogMessage(undefined));
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</SecondaryButton>
|
||||
)}
|
||||
<Button
|
||||
onClick={() => {
|
||||
props.onConfirm();
|
||||
|
|
@ -45,7 +57,7 @@ function ConfirmationDialog(props: ConfirmationDialogProps) {
|
|||
dispatch(setDialogMessage(undefined));
|
||||
}}
|
||||
>
|
||||
Confirm
|
||||
{props.confirmText ?? "Confirm"}
|
||||
</Button>
|
||||
</GridDiv>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import styled from "styled-components";
|
|||
import {
|
||||
VSC_BACKGROUND_VAR,
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
parseColorForHex,
|
||||
vscBackground,
|
||||
vscFocusBorder,
|
||||
vscForeground,
|
||||
} from "..";
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ const Dialog = styled.div`
|
|||
border-radius: ${defaultBorderRadius};
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid ${vscFocusBorder};
|
||||
border: 1px solid ${lightGray};
|
||||
margin: auto;
|
||||
word-wrap: break-word;
|
||||
// overflow: hidden;
|
||||
|
|
|
|||
|
|
@ -15,15 +15,16 @@ import FileIcon from "../FileIcon";
|
|||
|
||||
const ContextItemDiv = styled.div`
|
||||
cursor: pointer;
|
||||
padding-left: 6px;
|
||||
padding-right: 10px;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
padding: 6px 10px 6px 6px;
|
||||
margin-left: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
width: fit-content;
|
||||
font-size: ${getFontSize()};
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
&:hover {
|
||||
background-color: #fff1;
|
||||
|
|
|
|||
|
|
@ -23,14 +23,19 @@ import {
|
|||
} from "../../util";
|
||||
import ModelSelect from "../modelSelection/ModelSelect";
|
||||
|
||||
const paddingTop = 4;
|
||||
const height = 20;
|
||||
|
||||
const StyledDiv = styled.div<{ hidden?: boolean }>`
|
||||
position: absolute;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
right: 4px;
|
||||
bottom: 4px;
|
||||
width: calc(100% - 10px);
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap-reverse;
|
||||
flex-direction: row-reverse;
|
||||
gap: 1px;
|
||||
background-color: ${vscInputBackground};
|
||||
padding-top: ${paddingTop}px;
|
||||
|
||||
height: ${height}px;
|
||||
|
||||
${(props) => (props.hidden ? "display: none;" : "")}
|
||||
|
||||
|
|
@ -84,112 +89,127 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
const useActiveFile = useSelector(selectUseActiveFile);
|
||||
|
||||
return (
|
||||
<StyledDiv hidden={props.hidden} onClick={props.onClick} id="input-toolbar">
|
||||
<span className="cursor-pointer mr-auto flex items-center">
|
||||
<ModelSelect />
|
||||
<span
|
||||
style={{
|
||||
color: lightGray,
|
||||
}}
|
||||
onClick={(e) => {
|
||||
props.onAddContextItem();
|
||||
}}
|
||||
className="hover:underline cursor-pointer"
|
||||
>
|
||||
+ Add Context
|
||||
</span>
|
||||
{defaultModel &&
|
||||
modelSupportsImages(
|
||||
defaultModel.provider,
|
||||
defaultModel.model,
|
||||
defaultModel.title,
|
||||
) && (
|
||||
<>
|
||||
{props.hidden && (
|
||||
<div style={{ height: `${height + paddingTop}px` }}></div>
|
||||
)}
|
||||
<StyledDiv
|
||||
hidden={props.hidden}
|
||||
onClick={props.onClick}
|
||||
id="input-toolbar"
|
||||
>
|
||||
<span className="flex items-center whitespace-nowrap">
|
||||
{props.showNoContext ? (
|
||||
<span
|
||||
className="ml-1.5 mt-0.5"
|
||||
onMouseLeave={() => setFileSelectHovered(false)}
|
||||
onMouseEnter={() => setFileSelectHovered(true)}
|
||||
style={{
|
||||
color: props.usingCodebase ? vscBadgeBackground : lightGray,
|
||||
backgroundColor: props.usingCodebase
|
||||
? lightGray + "33"
|
||||
: undefined,
|
||||
borderRadius: defaultBorderRadius,
|
||||
padding: "2px 4px",
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="file"
|
||||
ref={fileInputRef}
|
||||
style={{ display: "none" }}
|
||||
accept=".jpg,.jpeg,.png,.gif,.svg,.webp"
|
||||
onChange={(e) => {
|
||||
for (const file of e.target.files) {
|
||||
props.onImageFileSelected(file);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{fileSelectHovered ? (
|
||||
<SolidPhotoIcon
|
||||
width="1.4em"
|
||||
height="1.4em"
|
||||
color={lightGray}
|
||||
onClick={(e) => {
|
||||
fileInputRef.current?.click();
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<OutlinePhotoIcon
|
||||
width="1.4em"
|
||||
height="1.4em"
|
||||
color={lightGray}
|
||||
onClick={(e) => {
|
||||
fileInputRef.current?.click();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{getAltKeyLabel()} ⏎{" "}
|
||||
{useActiveFile ? "No context" : "Use active file"}
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
style={{
|
||||
color: props.usingCodebase ? vscBadgeBackground : lightGray,
|
||||
backgroundColor: props.usingCodebase
|
||||
? lightGray + "33"
|
||||
: undefined,
|
||||
borderRadius: defaultBorderRadius,
|
||||
padding: "2px 4px",
|
||||
}}
|
||||
onClick={(e) => {
|
||||
props.onEnter({
|
||||
useCodebase: true,
|
||||
noContext: !useActiveFile,
|
||||
});
|
||||
}}
|
||||
className={"hover:underline cursor-pointer float-right"}
|
||||
>
|
||||
{getMetaKeyLabel()} ⏎ Use codebase
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
{props.showNoContext ? (
|
||||
<span
|
||||
style={{
|
||||
color: props.usingCodebase ? vscBadgeBackground : lightGray,
|
||||
backgroundColor: props.usingCodebase ? lightGray + "33" : undefined,
|
||||
borderRadius: defaultBorderRadius,
|
||||
padding: "2px 4px",
|
||||
}}
|
||||
>
|
||||
{getAltKeyLabel()} ⏎{" "}
|
||||
{useActiveFile ? "No context" : "Use active file"}
|
||||
<EnterButton
|
||||
offFocus={props.usingCodebase}
|
||||
// disabled={
|
||||
// !active &&
|
||||
// (!(inputRef.current as any)?.value ||
|
||||
// typeof client === "undefined")
|
||||
// }
|
||||
onClick={(e) => {
|
||||
props.onEnter({
|
||||
useCodebase: isMetaEquivalentKeyPressed(e),
|
||||
noContext: useActiveFile ? e.altKey : !e.altKey,
|
||||
});
|
||||
}}
|
||||
>
|
||||
⏎ Enter
|
||||
</EnterButton>
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
style={{
|
||||
color: props.usingCodebase ? vscBadgeBackground : lightGray,
|
||||
backgroundColor: props.usingCodebase ? lightGray + "33" : undefined,
|
||||
borderRadius: defaultBorderRadius,
|
||||
padding: "2px 4px",
|
||||
}}
|
||||
onClick={(e) => {
|
||||
props.onEnter({
|
||||
useCodebase: true,
|
||||
noContext: !useActiveFile,
|
||||
});
|
||||
}}
|
||||
className={"hover:underline cursor-pointer float-right"}
|
||||
>
|
||||
{getMetaKeyLabel()} ⏎ Use codebase
|
||||
<span className="flex flex-wrap-reverse items-center whitespace-nowrap">
|
||||
<ModelSelect />
|
||||
<span
|
||||
style={{
|
||||
color: lightGray,
|
||||
}}
|
||||
onClick={(e) => {
|
||||
props.onAddContextItem();
|
||||
}}
|
||||
className="hover:underline cursor-pointer"
|
||||
>
|
||||
+ Add Context
|
||||
</span>
|
||||
{defaultModel &&
|
||||
modelSupportsImages(
|
||||
defaultModel.provider,
|
||||
defaultModel.model,
|
||||
defaultModel.title,
|
||||
) && (
|
||||
<span
|
||||
className="ml-1.5 mt-0.5"
|
||||
onMouseLeave={() => setFileSelectHovered(false)}
|
||||
onMouseEnter={() => setFileSelectHovered(true)}
|
||||
>
|
||||
<input
|
||||
type="file"
|
||||
ref={fileInputRef}
|
||||
style={{ display: "none" }}
|
||||
accept=".jpg,.jpeg,.png,.gif,.svg,.webp"
|
||||
onChange={(e) => {
|
||||
for (const file of e.target.files) {
|
||||
props.onImageFileSelected(file);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{fileSelectHovered ? (
|
||||
<SolidPhotoIcon
|
||||
width="1.4em"
|
||||
height="1.4em"
|
||||
color={lightGray}
|
||||
onClick={(e) => {
|
||||
fileInputRef.current?.click();
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<OutlinePhotoIcon
|
||||
width="1.4em"
|
||||
height="1.4em"
|
||||
color={lightGray}
|
||||
onClick={(e) => {
|
||||
fileInputRef.current?.click();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
<EnterButton
|
||||
offFocus={props.usingCodebase}
|
||||
// disabled={
|
||||
// !active &&
|
||||
// (!(inputRef.current as any)?.value ||
|
||||
// typeof client === "undefined")
|
||||
// }
|
||||
onClick={(e) => {
|
||||
props.onEnter({
|
||||
useCodebase: isMetaEquivalentKeyPressed(e),
|
||||
noContext: useActiveFile ? e.altKey : !e.altKey,
|
||||
});
|
||||
}}
|
||||
>
|
||||
⏎ Enter
|
||||
</EnterButton>
|
||||
</StyledDiv>
|
||||
</StyledDiv>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
float: left;
|
||||
height: 0;
|
||||
pointer-events: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.gap-cursor {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ const InputBoxDiv = styled.div`
|
|||
resize: none;
|
||||
|
||||
padding: 8px;
|
||||
padding-bottom: 24px;
|
||||
padding-bottom: 4px;
|
||||
font-family: inherit;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
margin: 0;
|
||||
|
|
@ -70,7 +70,6 @@ const InputBoxDiv = styled.div`
|
|||
border: 0.5px solid ${vscInputBorder};
|
||||
outline: none;
|
||||
font-size: ${getFontSize()}px;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ interface TutorialCardProps {
|
|||
const TutorialCardDiv = styled.div`
|
||||
border: 1px solid ${lightGray};
|
||||
border-radius: 0.125rem;
|
||||
padding: 0.5rem;
|
||||
margin: 1.5rem;
|
||||
padding: 1rem 2.5rem 1rem 2rem;
|
||||
margin: 1rem;
|
||||
max-width: 28rem;
|
||||
position: relative;
|
||||
`;
|
||||
|
|
@ -31,10 +31,10 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
|
|||
role="button"
|
||||
aria-label="Close"
|
||||
>
|
||||
<XMarkIcon width="1.4em" height="1.4em" />
|
||||
<XMarkIcon width="1.2em" height="1.2em" />
|
||||
</div>
|
||||
|
||||
<ul className="text-gray-300 space-y-4">
|
||||
<ul className="text-gray-300 space-y-4 pl-0">
|
||||
<li className="flex items-start">
|
||||
<PencilSquareIcon
|
||||
width="1.4em"
|
||||
|
|
|
|||
|
|
@ -170,6 +170,10 @@ function ModelSelect() {
|
|||
|
||||
const [options, setOptions] = useState<Option[]>([]);
|
||||
|
||||
const selectedProfileId = useSelector(
|
||||
(store: RootState) => store.state.selectedProfileId,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setOptions(
|
||||
allModels.map((model) => {
|
||||
|
|
@ -227,22 +231,26 @@ function ModelSelect() {
|
|||
/>
|
||||
))}
|
||||
|
||||
<Divider />
|
||||
{selectedProfileId === "local" && (
|
||||
<>
|
||||
{options.length > 0 && <Divider />}
|
||||
|
||||
<StyledListboxOption
|
||||
key={options.length}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
navigate("/addModel");
|
||||
}}
|
||||
value={"addModel" as any}
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<PlusIcon className="w-4 h-4 mr-2" />
|
||||
Add Model
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
<StyledListboxOption
|
||||
key={options.length}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
navigate("/addModel");
|
||||
}}
|
||||
value={"addModel" as any}
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<PlusIcon className="w-4 h-4 mr-2" />
|
||||
Add Model
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Divider />
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { useDispatch } from "react-redux";
|
|||
import ConfirmationDialog from "../components/dialogs/ConfirmationDialog";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiStateSlice";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import { useWebviewListener } from "./useWebviewListener";
|
||||
|
||||
export function useAuth(): {
|
||||
|
|
@ -31,7 +32,27 @@ export function useAuth(): {
|
|||
console.log("login");
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", { silent: false })
|
||||
.then(setSession);
|
||||
.then((session) => {
|
||||
setSession(session);
|
||||
|
||||
// If this is the first time the user has logged in, explain how profiles work
|
||||
if (!getLocalStorage("shownProfilesIntroduction")) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
text={
|
||||
"Welcome to Continue for teams! Using the toggle in the bottom right, you can switch between your local profile (defined by config.json) and team profiles (defined in the Continue for teams web app). Each profile defines a set of models, slash commands, context providers, and other settings to customize Continue."
|
||||
}
|
||||
hideCancelButton={true}
|
||||
confirmText="Ok"
|
||||
onConfirm={() => {}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
setLocalStorage("shownProfilesIntroduction", true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
|
|
@ -39,6 +60,8 @@ export function useAuth(): {
|
|||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
hideCancelButton={true}
|
||||
confirmText="Ok"
|
||||
text={"Click the user icon in the bottom left of VS Code to log out."}
|
||||
onConfirm={() => {}}
|
||||
/>,
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@ import {
|
|||
import { RootState } from "../redux/store";
|
||||
|
||||
import { isJetBrains } from "../util";
|
||||
import { setLocalStorage } from "../util/localStorage";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import useChatHandler from "./useChatHandler";
|
||||
import { useWebviewListener } from "./useWebviewListener";
|
||||
import { debounce } from "lodash";
|
||||
|
||||
function useSetup(dispatch: Dispatch<any>) {
|
||||
const [configLoaded, setConfigLoaded] = useState<boolean>(false);
|
||||
|
|
@ -30,6 +31,7 @@ function useSetup(dispatch: Dispatch<any>) {
|
|||
dispatch(setConfig(config));
|
||||
dispatch(setSelectedProfileId(profileId));
|
||||
setConfigLoaded(true);
|
||||
setLocalStorage("disableIndexing", config.disableIndexing || false);
|
||||
|
||||
// Perform any actions needed with the config
|
||||
if (config.ui?.fontSize) {
|
||||
|
|
@ -86,8 +88,16 @@ function useSetup(dispatch: Dispatch<any>) {
|
|||
});
|
||||
});
|
||||
|
||||
const debouncedIndexDocs = debounce(() => {
|
||||
ideMessenger.request("context/indexDocs", { reIndex: false });
|
||||
}, 1000);
|
||||
|
||||
useWebviewListener("configUpdate", async () => {
|
||||
loadConfig();
|
||||
await loadConfig();
|
||||
|
||||
if (!isJetBrains && !getLocalStorage("disableIndexing")) {
|
||||
debouncedIndexDocs();
|
||||
}
|
||||
});
|
||||
|
||||
useWebviewListener("submitMessage", async (data) => {
|
||||
|
|
|
|||
|
|
@ -276,7 +276,19 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
},
|
||||
icon: "mistral.png",
|
||||
providerOptions: ["mistral"],
|
||||
isOpenSource: false,
|
||||
isOpenSource: true,
|
||||
},
|
||||
codestralMamba: {
|
||||
title: "Codestral Mamba",
|
||||
description: "A Mamba 2 language model specialized in code generation.",
|
||||
params: {
|
||||
title: "Codestral Mamba",
|
||||
model: "codestral-mamba-latest",
|
||||
contextLength: 256_000,
|
||||
},
|
||||
icon: "mistral.png",
|
||||
providerOptions: ["mistral"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
mistral7b: {
|
||||
title: "Mistral 7B",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { ModelProvider } from "core";
|
||||
import { HTMLInputTypeAttribute } from "react";
|
||||
import { ModelProviderTags } from "../../../components/modelSelection/ModelProviderTag";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../../util/freeTrial";
|
||||
import { completionParamsInputs } from "./completionParamsInputs";
|
||||
import type { ModelPackage } from "./models";
|
||||
import { models } from "./models";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../../util/freeTrial";
|
||||
|
||||
export interface InputDescriptor {
|
||||
inputType: HTMLInputTypeAttribute;
|
||||
|
|
@ -186,6 +186,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
],
|
||||
packages: [
|
||||
models.codestral,
|
||||
models.codestralMamba,
|
||||
models.mistralLarge,
|
||||
models.mistralSmall,
|
||||
models.mistral8x22b,
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ import {
|
|||
vscBackground,
|
||||
vscForeground,
|
||||
} from "../components";
|
||||
import { ChatScrollAnchor } from "../components/ChatScrollAnchor";
|
||||
import StepContainer from "../components/gui/StepContainer";
|
||||
import TimelineItem from "../components/gui/TimelineItem";
|
||||
import ContinueInputBox from "../components/mainInput/ContinueInputBox";
|
||||
import { defaultInputModifiers } from "../components/mainInput/inputModifiers";
|
||||
import { TutorialCard } from "../components/mainInput/TutorialCard";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import useChatHandler from "../hooks/useChatHandler";
|
||||
import useHistory from "../hooks/useHistory";
|
||||
|
|
@ -52,10 +54,8 @@ import {
|
|||
isJetBrains,
|
||||
isMetaEquivalentKeyPressed,
|
||||
} from "../util";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial";
|
||||
import { ChatScrollAnchor } from "../components/ChatScrollAnchor";
|
||||
import { TutorialCard } from "../components/mainInput/TutorialCard";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
|
||||
const TopGuiDiv = styled.div`
|
||||
overflow-y: scroll;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ type LocalStorageTypes = {
|
|||
signedInToGh: boolean;
|
||||
isOnboardingInProgress: boolean;
|
||||
showTutorialCard: boolean;
|
||||
shownProfilesIntroduction: boolean;
|
||||
disableIndexing: boolean;
|
||||
};
|
||||
|
||||
export function getLocalStorage<T extends keyof LocalStorageTypes>(
|
||||
|
|
|
|||
29
packages/control-plane-types/package-lock.json
generated
29
packages/control-plane-types/package-lock.json
generated
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"name": "control-plane-types",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "control-plane-types",
|
||||
"version": "1.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz",
|
||||
"integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4
packages/control-plane-types/src/index.d.ts
vendored
4
packages/control-plane-types/src/index.d.ts
vendored
|
|
@ -1,4 +0,0 @@
|
|||
export interface Test {
|
||||
a: string;
|
||||
b: number;
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
||||
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
||||
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
||||
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
||||
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
||||
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
}
|
||||
}
|
||||
3
packages/llm-info/README.md
Normal file
3
packages/llm-info/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# @continuedev/llm-info
|
||||
|
||||
A lightweight package providing information about various Large Language Models (LLMs).
|
||||
|
|
@ -1,15 +1,18 @@
|
|||
{
|
||||
"name": "control-plane-types",
|
||||
"version": "1.0.0",
|
||||
"name": "@continuedev/llm-info",
|
||||
"version": "1.0.1",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "tsc"
|
||||
},
|
||||
"author": "Nate Sesti and Ty Dunn",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
18
packages/llm-info/src/index.ts
Normal file
18
packages/llm-info/src/index.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { AnthropicLlms } from "./models/anthropic.js";
|
||||
import { GoogleLlms } from "./models/google.js";
|
||||
import { MistralLlms } from "./models/mistral.js";
|
||||
import { OpenAiLlms } from "./models/openai.js";
|
||||
import { LlmInfo } from "./types.js";
|
||||
|
||||
export const allLlms: LlmInfo[] = [
|
||||
...OpenAiLlms,
|
||||
...GoogleLlms,
|
||||
...AnthropicLlms,
|
||||
...MistralLlms,
|
||||
];
|
||||
|
||||
export function findLlmInfo(model: string): LlmInfo | undefined {
|
||||
return allLlms.find((llm) =>
|
||||
llm.regex ? llm.regex.test(model) : llm.model === model,
|
||||
);
|
||||
}
|
||||
60
packages/llm-info/src/models/anthropic.ts
Normal file
60
packages/llm-info/src/models/anthropic.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { LlmInfo } from "../types.js";
|
||||
|
||||
export const AnthropicLlms: LlmInfo[] = [
|
||||
{
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
displayName: "Claude 3.5 Sonnet",
|
||||
contextLength: 200_000,
|
||||
description:
|
||||
"Most intelligent model with the highest level of intelligence and capability.",
|
||||
regex: /claude-3\.5-sonnet/i,
|
||||
},
|
||||
{
|
||||
model: "claude-3-opus-20240229",
|
||||
displayName: "Claude 3 Opus",
|
||||
contextLength: 200_000,
|
||||
description:
|
||||
"Powerful model for highly complex tasks with top-level performance, intelligence, fluency, and understanding.",
|
||||
regex: /claude-3-opus/i,
|
||||
},
|
||||
{
|
||||
model: "claude-3-sonnet-20240229",
|
||||
displayName: "Claude 3 Sonnet",
|
||||
contextLength: 200_000,
|
||||
description:
|
||||
"Balance of intelligence and speed with strong utility, balanced for scaled deployments.",
|
||||
regex: /claude-3-sonnet/i,
|
||||
},
|
||||
{
|
||||
model: "claude-3-haiku-20240307",
|
||||
displayName: "Claude 3 Haiku",
|
||||
contextLength: 200_000,
|
||||
description:
|
||||
"Fastest and most compact model for near-instant responsiveness with quick and accurate targeted performance.",
|
||||
regex: /claude-3-haiku/i,
|
||||
},
|
||||
{
|
||||
model: "claude-2.1",
|
||||
displayName: "Claude 2.1",
|
||||
contextLength: 200_000,
|
||||
description:
|
||||
"Updated version of Claude 2 with improved accuracy and consistency.",
|
||||
regex: /claude-2\.1/i,
|
||||
},
|
||||
{
|
||||
model: "claude-2.0",
|
||||
displayName: "Claude 2",
|
||||
contextLength: 100_000,
|
||||
description:
|
||||
"Predecessor to Claude 3, offering strong all-round performance.",
|
||||
regex: /claude-2\.0/i,
|
||||
},
|
||||
{
|
||||
model: "claude-instant-1.2",
|
||||
displayName: "Claude Instant 1.2",
|
||||
contextLength: 100_000,
|
||||
description:
|
||||
"Our cheapest small and fast model, a predecessor of Claude Haiku.",
|
||||
regex: /claude-instant-1\.2/i,
|
||||
},
|
||||
];
|
||||
22
packages/llm-info/src/models/google.ts
Normal file
22
packages/llm-info/src/models/google.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { AllMediaTypes, LlmInfo } from "../types.js";
|
||||
|
||||
export const GoogleLlms: LlmInfo[] = [
|
||||
{
|
||||
model: "gemini-1.5-flash",
|
||||
displayName: "Gemini 1.5 Flash",
|
||||
contextLength: 1_048_576,
|
||||
mediaTypes: AllMediaTypes,
|
||||
regex: /gemini-1\.5-flash/i,
|
||||
},
|
||||
{
|
||||
model: "gemini-1.5-pro",
|
||||
displayName: "Gemini 1.5 Pro",
|
||||
contextLength: 2_097_152,
|
||||
regex: /gemini-1\.5-pro/i,
|
||||
},
|
||||
{
|
||||
model: "gemini-1.0-pro",
|
||||
displayName: "Gemini 1.0 Pro",
|
||||
regex: /gemini-1\.0-pro/i,
|
||||
},
|
||||
];
|
||||
75
packages/llm-info/src/models/mistral.ts
Normal file
75
packages/llm-info/src/models/mistral.ts
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
import { LlmInfo } from "../types.js";
|
||||
|
||||
export const MistralLlms: LlmInfo[] = [
|
||||
{
|
||||
model: "mistral-large-latest",
|
||||
displayName: "Mistral Large",
|
||||
contextLength: 32768,
|
||||
description:
|
||||
"Flagship model ideal for complex tasks requiring large reasoning capabilities or highly specialized tasks like synthetic text generation, code generation, RAG, or agents.",
|
||||
regex: /mistral-large/i,
|
||||
},
|
||||
{
|
||||
model: "mistral-medium-latest",
|
||||
displayName: "Mistral Medium",
|
||||
contextLength: 32768,
|
||||
description:
|
||||
"Ideal for intermediate tasks requiring moderate reasoning such as data extraction, document summarization, email writing, job descriptions, or product descriptions. (Note: Will be deprecated in the coming months)",
|
||||
regex: /mistral-medium/i,
|
||||
},
|
||||
{
|
||||
model: "mistral-small-latest",
|
||||
displayName: "Mistral Small",
|
||||
contextLength: 32768,
|
||||
description:
|
||||
"Suitable for simple tasks that can be done in bulk like classification, customer support, or text generation.",
|
||||
regex: /mistral-small/i,
|
||||
},
|
||||
{
|
||||
model: "open-mistral-7b",
|
||||
displayName: "Mistral 7B",
|
||||
contextLength: 32768,
|
||||
description:
|
||||
"First dense model released by Mistral AI, perfect for experimentation, customization, and quick iteration. Matches capabilities of models up to 30B parameters at release time.",
|
||||
regex: /open-mistral-7b/i,
|
||||
},
|
||||
{
|
||||
model: "open-mixtral-8x7b",
|
||||
displayName: "Mixtral 8x7B",
|
||||
contextLength: 32768,
|
||||
description:
|
||||
"Sparse mixture of experts model leveraging up to 45B parameters but using about 12B during inference, offering better inference throughput at the cost of more vRAM.",
|
||||
regex: /open-mixtral-8x7b/i,
|
||||
},
|
||||
{
|
||||
model: "open-mixtral-8x22b",
|
||||
displayName: "Mixtral 8x22B",
|
||||
contextLength: 65536,
|
||||
description:
|
||||
"Larger sparse mixture of experts model leveraging up to 141B parameters but using about 39B during inference, providing better inference throughput at the cost of more vRAM.",
|
||||
regex: /open-mixtral-8x22b/i,
|
||||
},
|
||||
{
|
||||
model: "mistral-embed",
|
||||
displayName: "Mistral Embeddings",
|
||||
contextLength: 8192,
|
||||
description:
|
||||
"Model that converts text into numerical vectors of embeddings in 1024 dimensions. Enables retrieval and retrieval-augmented generation applications with a retrieval score of 55.26 on MTEB.",
|
||||
regex: /mistral-embed/i,
|
||||
},
|
||||
{
|
||||
model: "codestral-mamba-latest",
|
||||
displayName: "Codestral Mamba",
|
||||
contextLength: 256_000,
|
||||
description: "A Mamba 2 language model specialized in code generation.",
|
||||
regex: /codestral-mamba/i,
|
||||
},
|
||||
{
|
||||
model: "codestral-latest",
|
||||
displayName: "Codestral",
|
||||
contextLength: 32768,
|
||||
description:
|
||||
"Cutting-edge generative model specifically designed and optimized for code generation tasks, including fill-in-the-middle and code completion.",
|
||||
regex: /codestral/i,
|
||||
},
|
||||
];
|
||||
69
packages/llm-info/src/models/openai.ts
Normal file
69
packages/llm-info/src/models/openai.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import { LlmInfo } from "../types.js";
|
||||
|
||||
export const OpenAiLlms: LlmInfo[] = [
|
||||
{
|
||||
model: "gpt-3.5-turbo",
|
||||
displayName: "GPT-3.5 Turbo",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-3.5-turbo-0613",
|
||||
displayName: "GPT-3.5 Turbo (0613)",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-3.5-turbo-16k",
|
||||
displayName: "GPT-3.5 Turbo 16K",
|
||||
contextLength: 16384,
|
||||
},
|
||||
{
|
||||
model: "gpt-35-turbo-16k",
|
||||
displayName: "GPT-3.5 Turbo 16K",
|
||||
contextLength: 16384,
|
||||
},
|
||||
{
|
||||
model: "gpt-35-turbo-0613",
|
||||
displayName: "GPT-3.5 Turbo (0613)",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-35-turbo",
|
||||
displayName: "GPT-3.5 Turbo",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-4",
|
||||
displayName: "GPT-4",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-4-32k",
|
||||
displayName: "GPT-4 32K",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-4-turbo-preview",
|
||||
displayName: "GPT-4 Turbo Preview",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-4o",
|
||||
displayName: "GPT-4o",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-4-vision",
|
||||
displayName: "GPT-4 Vision",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-4-0125-preview",
|
||||
displayName: "GPT-4 (0125 Preview)",
|
||||
contextLength: 4096,
|
||||
},
|
||||
{
|
||||
model: "gpt-4-1106-preview",
|
||||
displayName: "GPT-4 (1106 Preview)",
|
||||
contextLength: 4096,
|
||||
},
|
||||
];
|
||||
30
packages/llm-info/src/types.ts
Normal file
30
packages/llm-info/src/types.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
export interface LlmInfo {
|
||||
model: string;
|
||||
displayName?: string;
|
||||
description?: string;
|
||||
contextLength?: number;
|
||||
regex?: RegExp;
|
||||
|
||||
/** If not set, assumes "text" only */
|
||||
mediaTypes?: MediaType[];
|
||||
}
|
||||
|
||||
export enum MediaType {
|
||||
Text = "text",
|
||||
Image = "image",
|
||||
Audio = "audio",
|
||||
Video = "video",
|
||||
}
|
||||
|
||||
export const AllMediaTypes = [
|
||||
MediaType.Text,
|
||||
MediaType.Image,
|
||||
MediaType.Audio,
|
||||
MediaType.Video,
|
||||
];
|
||||
|
||||
export interface ApiProviderInfo {
|
||||
displayName: string;
|
||||
supportsStreaming: boolean;
|
||||
handlesTemplating: boolean;
|
||||
}
|
||||
23
packages/llm-info/tsconfig.json
Normal file
23
packages/llm-info/tsconfig.json
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["DOM", "ESNext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "NodeNext",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmitOnError": false,
|
||||
"types": ["node"],
|
||||
"outDir": "dist",
|
||||
"declaration": true
|
||||
// "sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue