Merge branch 'main' into dependent-context-indexing
This commit is contained in:
commit
887994038f
679 changed files with 91142 additions and 6294 deletions
20
.github/actions/run-jetbrains-tests/action.yml
vendored
20
.github/actions/run-jetbrains-tests/action.yml
vendored
|
|
@ -44,6 +44,7 @@ runs:
|
|||
- name: Setup FFmpeg
|
||||
uses: AnimMouse/setup-ffmpeg@v1
|
||||
with:
|
||||
version: 7.1
|
||||
token: ${{ inputs.github-token }}
|
||||
|
||||
- name: Setup Gradle
|
||||
|
|
@ -93,6 +94,13 @@ runs:
|
|||
path: binary/node_modules
|
||||
key: ${{ runner.os }}-binary-node-modules-${{ hashFiles('binary/package-lock.json') }}
|
||||
|
||||
- name: Install binary dependencies
|
||||
if: steps.binary-cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
cd binary
|
||||
npm ci
|
||||
|
||||
- name: Build the binaries
|
||||
shell: bash
|
||||
run: |
|
||||
|
|
@ -128,14 +136,22 @@ runs:
|
|||
shell: bash
|
||||
run: |
|
||||
cd extensions/intellij
|
||||
mv video build/reports
|
||||
if [ -d "video" ]; then
|
||||
mv video build/reports
|
||||
else
|
||||
echo "No video directory found to move"
|
||||
fi
|
||||
|
||||
- name: Copy logs
|
||||
if: ${{ failure() }}
|
||||
shell: bash
|
||||
run: |
|
||||
cd extensions/intellij
|
||||
mv build/idea-sandbox/system/log/ build/reports
|
||||
if [ -d "build/idea-sandbox/system/log/" ]; then
|
||||
mv build/idea-sandbox/system/log/ build/reports
|
||||
else
|
||||
echo "No log directory found to copy"
|
||||
fi
|
||||
|
||||
- name: Save fails report
|
||||
if: ${{ failure() }}
|
||||
|
|
|
|||
19
.github/actions/track-rerun/action.yml
vendored
Normal file
19
.github/actions/track-rerun/action.yml
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
name: Track Workflow Rerun
|
||||
description: Track when GitHub Actions workflows are rerun (attempt > 1)
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
# Eventually we can start logging this to monitor codebase health (e.g. to Slack, PostHog, etc.)
|
||||
- name: Track workflow rerun
|
||||
if: github.run_attempt > 1
|
||||
shell: bash
|
||||
run: |
|
||||
echo "🔄 Workflow rerun detected - Attempt #${{ github.run_attempt }}"
|
||||
echo "📊 Workflow: ${{ github.workflow }}"
|
||||
echo "🔀 PR: ${{ github.event.pull_request.number || 'N/A' }}"
|
||||
echo "📝 Commit: ${{ github.sha }}"
|
||||
echo "👤 Actor: ${{ github.actor }}"
|
||||
echo "⏰ Timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo ""
|
||||
echo "::notice title=Workflow Rerun Detected::This is attempt #${{ github.run_attempt }} of workflow '${{ github.workflow }}'"
|
||||
115
.github/workflows/beta-release.yml
vendored
Normal file
115
.github/workflows/beta-release.yml
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
name: Beta Release
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run every day at 9am UTC
|
||||
- cron: "0 9 * * *"
|
||||
workflow_dispatch:
|
||||
# Allow manual triggering
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
beta-release:
|
||||
name: Beta Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
always-auth: true
|
||||
|
||||
- name: Setup packages
|
||||
uses: ./.github/actions/setup-packages
|
||||
|
||||
- name: Setup core component
|
||||
uses: ./.github/actions/setup-component
|
||||
with:
|
||||
component: core
|
||||
include-root: true
|
||||
|
||||
- name: Build core
|
||||
run: |
|
||||
cd core
|
||||
npm run build
|
||||
|
||||
- name: Install CLI dependencies
|
||||
working-directory: extensions/cli
|
||||
run: npm ci
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Get current version
|
||||
id: get_version
|
||||
working-directory: extensions/cli
|
||||
run: |
|
||||
# Get the latest version from package.json or npm registry
|
||||
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
||||
if [[ "$CURRENT_VERSION" == "0.0.0-dev" ]]; then
|
||||
# If it's dev version, get latest from npm registry
|
||||
LATEST_VERSION=$(npm view @continuedev/cli version --silent 2>/dev/null || echo "0.0.0")
|
||||
echo "Using latest npm version: $LATEST_VERSION"
|
||||
CURRENT_VERSION=$LATEST_VERSION
|
||||
fi
|
||||
|
||||
# Create beta version with current date
|
||||
DATE_SUFFIX=$(date -u +%Y%m%d)
|
||||
BETA_VERSION="${CURRENT_VERSION}-beta.${DATE_SUFFIX}"
|
||||
|
||||
# Check if this version already exists on npm
|
||||
if npm view @continuedev/cli@$BETA_VERSION version --silent >/dev/null 2>&1; then
|
||||
echo "Version $BETA_VERSION already exists, adding timestamp"
|
||||
# Add hour and minute to make it unique
|
||||
TIMESTAMP_SUFFIX=$(date -u +%Y%m%d.%H%M)
|
||||
BETA_VERSION="${CURRENT_VERSION}-beta.${TIMESTAMP_SUFFIX}"
|
||||
echo "Using timestamped version: $BETA_VERSION"
|
||||
fi
|
||||
|
||||
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "beta_version=$BETA_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "date_suffix=$DATE_SUFFIX" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update package.json for beta
|
||||
working-directory: extensions/cli
|
||||
run: |
|
||||
# Update version in package.json
|
||||
npm version ${{ steps.get_version.outputs.beta_version }} --no-git-tag-version
|
||||
|
||||
- name: Build
|
||||
working-directory: extensions/cli
|
||||
run: npm run build
|
||||
|
||||
- name: Publish beta to npm
|
||||
working-directory: extensions/cli
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
npm publish --tag beta
|
||||
echo "Published beta version: ${{ steps.get_version.outputs.beta_version }}"
|
||||
|
||||
- name: Create beta release on GitHub
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
|
||||
run: |
|
||||
# Create a git tag for the beta
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git tag "v${{ steps.get_version.outputs.beta_version }}"
|
||||
git push origin "v${{ steps.get_version.outputs.beta_version }}"
|
||||
|
||||
# Create GitHub release
|
||||
gh release create "v${{ steps.get_version.outputs.beta_version }}" \
|
||||
--title "Beta Release v${{ steps.get_version.outputs.beta_version }}" \
|
||||
--notes "Daily beta release for testing. This version will be promoted to stable after 7 days if no critical issues are found." \
|
||||
--prerelease
|
||||
2
.github/workflows/cla.yaml
vendored
2
.github/workflows/cla.yaml
vendored
|
|
@ -27,5 +27,5 @@ jobs:
|
|||
path-to-document: "https://github.com/continuedev/continue/blob/main/CLA.md"
|
||||
branch: cla-signatures
|
||||
# Bots and CLAs signed outside of GitHub
|
||||
allowlist: dependabot[bot],fbricon,panyamkeerthana,Jazzcort,owtaylor,halfline
|
||||
allowlist: dependabot[bot],fbricon,panyamkeerthana,Jazzcort,owtaylor,halfline,agent@continue.dev
|
||||
signed-commit-message: "CLA signed in $pullRequestNo"
|
||||
|
|
|
|||
135
.github/workflows/cli-pr-checks.yml
vendored
Normal file
135
.github/workflows/cli-pr-checks.yml
vendored
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
name: CLI PR Checks
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
track-rerun:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.run_attempt > 1
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Track workflow rerun
|
||||
uses: ./.github/actions/track-rerun
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "npm"
|
||||
cache-dependency-path: extensions/cli/package-lock.json
|
||||
|
||||
- name: Setup packages
|
||||
uses: ./.github/actions/setup-packages
|
||||
- name: Setup core component
|
||||
uses: ./.github/actions/setup-component
|
||||
with:
|
||||
component: core
|
||||
include-root: true
|
||||
|
||||
- name: Build core
|
||||
run: |
|
||||
cd core
|
||||
npm run build
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd extensions/cli
|
||||
npm ci --include=optional
|
||||
|
||||
- name: Run linting
|
||||
run: |
|
||||
cd extensions/cli
|
||||
npm run lint
|
||||
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
node-version: [18, 20, 22, 24]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Cache CLI node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: extensions/cli/node_modules
|
||||
key: ${{ runner.os }}-node${{ matrix.node-version }}-cli-modules-${{ hashFiles('extensions/cli/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node${{ matrix.node-version }}-cli-modules-
|
||||
|
||||
- name: Setup packages
|
||||
uses: ./.github/actions/setup-packages
|
||||
- name: Setup core component
|
||||
uses: ./.github/actions/setup-component
|
||||
with:
|
||||
component: core
|
||||
include-root: true
|
||||
|
||||
- name: Build core
|
||||
run: |
|
||||
cd core
|
||||
npm run build
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd extensions/cli
|
||||
npm ci --include=optional
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd extensions/cli
|
||||
npm run build
|
||||
|
||||
- name: Run smoke tests
|
||||
run: |
|
||||
cd extensions/cli
|
||||
npm run test:smoke
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd extensions/cli
|
||||
npm test
|
||||
|
||||
# e2e tests are failing on Windows specifically - likely due to stdout flush issues
|
||||
- name: Run e2e tests
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: |
|
||||
cd extensions/cli
|
||||
npm run test:e2e
|
||||
|
||||
# GitHub does not have a way of requiring that all checks pass (you must manually select each job)
|
||||
# This action at least lets us manage the list of required tests via source control
|
||||
# so that creators of new jobs can add them to this list
|
||||
require-all-checks-to-pass-cli:
|
||||
if: always()
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- lint
|
||||
- test
|
||||
|
||||
steps:
|
||||
- name: Decide whether the needed jobs succeeded or failed
|
||||
uses: re-actors/alls-green@release/v1
|
||||
with:
|
||||
jobs: ${{ toJSON(needs) }}
|
||||
2
.github/workflows/compliance.yaml
vendored
2
.github/workflows/compliance.yaml
vendored
|
|
@ -36,7 +36,7 @@ jobs:
|
|||
else
|
||||
echo "❌ PR title does not follow conventional commit format"
|
||||
echo "valid=false" >> $GITHUB_OUTPUT
|
||||
exit 1
|
||||
# Don't exit with failure - just mark as invalid for comment
|
||||
fi
|
||||
|
||||
- name: Add PR title guidance comment
|
||||
|
|
|
|||
32
.github/workflows/docs.yml
vendored
32
.github/workflows/docs.yml
vendored
|
|
@ -1,32 +0,0 @@
|
|||
name: Docs Check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'docs2/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'docs2/**'
|
||||
|
||||
jobs:
|
||||
check-broken-links:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: docs2/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: ./docs2
|
||||
run: npm ci
|
||||
|
||||
- name: Check for broken links
|
||||
working-directory: ./docs2
|
||||
run: npx mintlify broken-links
|
||||
18
.github/workflows/jetbrains-release.yaml
vendored
18
.github/workflows/jetbrains-release.yaml
vendored
|
|
@ -120,7 +120,7 @@ jobs:
|
|||
|
||||
# # Set up Java environment for the next steps
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 17
|
||||
|
|
@ -189,6 +189,8 @@ jobs:
|
|||
cd ../../gui
|
||||
npm ci
|
||||
npm run build
|
||||
env:
|
||||
NODE_OPTIONS: "--max-old-space-size=8192"
|
||||
|
||||
# Run prepackage.js script
|
||||
- name: Run prepackage script
|
||||
|
|
@ -255,6 +257,7 @@ jobs:
|
|||
# Publish the plugin to JetBrains Marketplace
|
||||
- name: Publish EAP Plugin
|
||||
if: github.event_name == 'release' || (github.event.inputs.eap_channel == 'true' && github.event.inputs.build_only != 'true')
|
||||
continue-on-error: true
|
||||
env:
|
||||
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
|
||||
CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
|
||||
|
|
@ -265,6 +268,7 @@ jobs:
|
|||
|
||||
- name: Publish Stable Plugin
|
||||
if: github.event_name == 'release' || (github.event.inputs.stable_channel == 'true' && github.event.inputs.build_only != 'true')
|
||||
continue-on-error: true
|
||||
env:
|
||||
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
|
||||
CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
|
||||
|
|
@ -433,7 +437,7 @@ jobs:
|
|||
|
||||
# Set up Java environment for the next steps
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 17
|
||||
|
|
@ -456,12 +460,6 @@ jobs:
|
|||
name: tests-result
|
||||
path: ${{ github.workspace }}/extensions/intellij/build/reports/tests
|
||||
|
||||
# Upload the Kover report to CodeCov
|
||||
# - name: Upload Code Coverage Report
|
||||
# uses: codecov/codecov-action@v4
|
||||
# with:
|
||||
# files: ${{ github.workspace }}/build/reports/kover/report.xml
|
||||
|
||||
# Run Qodana inspections and provide report
|
||||
inspectCode:
|
||||
if: false
|
||||
|
|
@ -486,7 +484,7 @@ jobs:
|
|||
|
||||
# Set up Java environment for the next steps
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 17
|
||||
|
|
@ -517,7 +515,7 @@ jobs:
|
|||
|
||||
# Set up Java environment for the next steps
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: zulu
|
||||
java-version: 17
|
||||
|
|
|
|||
2
.github/workflows/main.yaml
vendored
2
.github/workflows/main.yaml
vendored
|
|
@ -9,7 +9,7 @@ on:
|
|||
publish_build:
|
||||
description: "Whether or not to publish the built extension to the VS Code marketplace"
|
||||
required: true
|
||||
default: false
|
||||
default: "false"
|
||||
|
||||
jobs:
|
||||
check_release_name:
|
||||
|
|
|
|||
8
.github/workflows/pr-checks.yaml
vendored
8
.github/workflows/pr-checks.yaml
vendored
|
|
@ -11,6 +11,14 @@ on:
|
|||
- main
|
||||
|
||||
jobs:
|
||||
track-rerun:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.run_attempt > 1
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Track workflow rerun
|
||||
uses: ./.github/actions/track-rerun
|
||||
|
||||
prettier-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
|
|||
4
.github/workflows/preview.yaml
vendored
4
.github/workflows/preview.yaml
vendored
|
|
@ -9,7 +9,7 @@ on:
|
|||
publish_build:
|
||||
description: "Whether or not to publish the built extension to the VS Code marketplace"
|
||||
required: true
|
||||
default: false
|
||||
default: "false"
|
||||
|
||||
jobs:
|
||||
check_release_name:
|
||||
|
|
@ -20,7 +20,7 @@ jobs:
|
|||
- id: check
|
||||
working-directory: .
|
||||
run: |
|
||||
if [[ "${{ github.event.release.tag_name }}" == v1.1.*-vscode ]]; then
|
||||
if [[ "${{ github.event.release.tag_name }}" == v1.3.*-vscode ]]; then
|
||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||
|
|
|
|||
222
.github/workflows/stable-release.yml
vendored
Normal file
222
.github/workflows/stable-release.yml
vendored
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
name: Stable Release
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run every Monday at 10am UTC (1 hour after beta release)
|
||||
- cron: "0 10 * * 1"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_type:
|
||||
description: "Release type"
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- "promote-beta"
|
||||
- "direct-stable"
|
||||
default: "promote-beta"
|
||||
beta_version:
|
||||
description: "Specific beta version to promote (required if release_type is 'promote-beta')"
|
||||
required: false
|
||||
type: string
|
||||
stable_version:
|
||||
description: "Version for direct stable release (e.g., 1.2.3) - required if release_type is 'direct-stable'"
|
||||
required: false
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
stable-release:
|
||||
name: Stable Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
always-auth: true
|
||||
|
||||
- name: Validate inputs
|
||||
run: |
|
||||
RELEASE_TYPE="${{ inputs.release_type || 'promote-beta' }}"
|
||||
echo "Release type: $RELEASE_TYPE"
|
||||
|
||||
if [[ "$RELEASE_TYPE" == "direct-stable" ]]; then
|
||||
if [[ -z "${{ inputs.stable_version }}" ]]; then
|
||||
echo "Error: stable_version is required for direct-stable release type"
|
||||
exit 1
|
||||
fi
|
||||
echo "Direct stable release version: ${{ inputs.stable_version }}"
|
||||
elif [[ "$RELEASE_TYPE" == "promote-beta" ]]; then
|
||||
echo "Beta promotion release (beta_version: ${{ inputs.beta_version }})"
|
||||
else
|
||||
echo "Error: Invalid release type: $RELEASE_TYPE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Find beta version to promote
|
||||
if: ${{ (inputs.release_type || 'promote-beta') == 'promote-beta' }}
|
||||
id: find_beta
|
||||
working-directory: extensions/cli
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
if [[ -n "${{ inputs.beta_version }}" ]]; then
|
||||
# Manual input provided
|
||||
BETA_VERSION="${{ inputs.beta_version }}"
|
||||
echo "Using manually specified beta version: $BETA_VERSION"
|
||||
else
|
||||
# Find beta version that's at least 7 days old
|
||||
SEVEN_DAYS_AGO=$(date -u -d '7 days ago' +%Y%m%d)
|
||||
echo "Looking for beta versions from $SEVEN_DAYS_AGO or earlier"
|
||||
|
||||
# Get all beta versions from npm
|
||||
BETA_VERSIONS=$(npm view @continuedev/cli versions --json | jq -r '.[] | select(contains("-beta."))' | sort -V)
|
||||
|
||||
CANDIDATE_VERSION=""
|
||||
for version in $BETA_VERSIONS; do
|
||||
# Extract date from beta version (format: x.y.z-beta.YYYYMMDD)
|
||||
if [[ $version =~ -beta\.([0-9]{8}) ]]; then
|
||||
BETA_DATE="${BASH_REMATCH[1]}"
|
||||
if [[ $BETA_DATE -le $SEVEN_DAYS_AGO ]]; then
|
||||
CANDIDATE_VERSION=$version
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "$CANDIDATE_VERSION" ]]; then
|
||||
echo "No beta version found that is at least 7 days old"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BETA_VERSION=$CANDIDATE_VERSION
|
||||
echo "Selected beta version for promotion: $BETA_VERSION"
|
||||
fi
|
||||
|
||||
# Extract base version (remove -beta.YYYYMMDD suffix)
|
||||
STABLE_VERSION=$(echo "$BETA_VERSION" | sed 's/-beta\.[0-9]\{8\}//')
|
||||
|
||||
echo "beta_version=$BETA_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "stable_version=$STABLE_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set version for direct stable release
|
||||
if: ${{ inputs.release_type == 'direct-stable' }}
|
||||
id: direct_stable
|
||||
run: |
|
||||
echo "stable_version=${{ inputs.stable_version }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Download and verify beta package
|
||||
if: ${{ (inputs.release_type || 'promote-beta') == 'promote-beta' }}
|
||||
working-directory: extensions/cli
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
# Download the specific beta version
|
||||
npm pack @continuedev/cli@${{ steps.find_beta.outputs.beta_version }}
|
||||
|
||||
# Extract and verify the package
|
||||
PACKAGE_FILE=$(ls continuedev-cli-*.tgz)
|
||||
tar -xzf "$PACKAGE_FILE"
|
||||
|
||||
echo "Beta package contents verified"
|
||||
ls -la package/
|
||||
|
||||
- name: Prepare package for beta promotion
|
||||
if: ${{ (inputs.release_type || 'promote-beta') == 'promote-beta' }}
|
||||
working-directory: extensions/cli
|
||||
run: |
|
||||
# Copy the beta package contents
|
||||
cp -r package/* .
|
||||
|
||||
# Update version to stable (remove beta suffix)
|
||||
npm version ${{ steps.find_beta.outputs.stable_version }} --no-git-tag-version
|
||||
|
||||
- name: Setup packages (for direct stable release)
|
||||
if: ${{ inputs.release_type == 'direct-stable' }}
|
||||
uses: ./.github/actions/setup-packages
|
||||
|
||||
- name: Setup core component (for direct stable release)
|
||||
if: ${{ inputs.release_type == 'direct-stable' }}
|
||||
uses: ./.github/actions/setup-component
|
||||
with:
|
||||
component: core
|
||||
include-root: true
|
||||
|
||||
- name: Build core
|
||||
run: |
|
||||
cd core
|
||||
npm run build
|
||||
|
||||
- name: Prepare package for direct stable release
|
||||
if: ${{ inputs.release_type == 'direct-stable' }}
|
||||
working-directory: extensions/cli
|
||||
run: |
|
||||
# Install dependencies for direct build
|
||||
npm ci
|
||||
|
||||
# Update version to the specified stable version
|
||||
npm version ${{ inputs.stable_version }} --no-git-tag-version
|
||||
|
||||
- name: Build (verification step)
|
||||
working-directory: extensions/cli
|
||||
run: npm run build
|
||||
|
||||
- name: Run tests (verification step)
|
||||
working-directory: extensions/cli
|
||||
run: npm test
|
||||
|
||||
- name: Set final version
|
||||
id: final_version
|
||||
run: |
|
||||
if [[ "${{ inputs.release_type || 'promote-beta' }}" == "direct-stable" ]]; then
|
||||
STABLE_VERSION="${{ steps.direct_stable.outputs.stable_version }}"
|
||||
RELEASE_NOTES="Direct stable release from main branch. Version $STABLE_VERSION built and published directly from the latest main branch."
|
||||
else
|
||||
STABLE_VERSION="${{ steps.find_beta.outputs.stable_version }}"
|
||||
RELEASE_NOTES="Stable release promoted from tested beta version ${{ steps.find_beta.outputs.beta_version }}. This version has been thoroughly tested in beta for at least 7 days."
|
||||
fi
|
||||
echo "stable_version=$STABLE_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "release_notes=$RELEASE_NOTES" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Publish stable to npm
|
||||
working-directory: extensions/cli
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
npm publish --tag latest
|
||||
echo "Published stable version: ${{ steps.final_version.outputs.stable_version }}"
|
||||
|
||||
- name: Create stable release on GitHub
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
|
||||
run: |
|
||||
# Create a git tag for the stable release
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git tag "v${{ steps.final_version.outputs.stable_version }}"
|
||||
git push origin "v${{ steps.final_version.outputs.stable_version }}"
|
||||
|
||||
# Create GitHub release
|
||||
gh release create "v${{ steps.final_version.outputs.stable_version }}" \
|
||||
--title "Stable Release v${{ steps.final_version.outputs.stable_version }}" \
|
||||
--notes "${{ steps.final_version.outputs.release_notes }}" \
|
||||
--latest
|
||||
|
||||
- name: Update GitHub release notes for beta promotion
|
||||
if: ${{ (inputs.release_type || 'promote-beta') == 'promote-beta' }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
|
||||
run: |
|
||||
# Mark the original beta release as superseded
|
||||
gh release edit "v${{ steps.find_beta.outputs.beta_version }}" \
|
||||
--notes "This beta version has been promoted to stable as v${{ steps.final_version.outputs.stable_version }}."
|
||||
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
- name: Checkout sources
|
||||
uses: actions/checkout@v5
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -158,6 +158,7 @@ extensions/intellij/.idea/**
|
|||
**/.idea/shelf/
|
||||
**/.idea/inspectionProfiles/Project_Default.xml
|
||||
**/.idea/php.xml
|
||||
**/.idea/kotlinc.xml
|
||||
|
||||
|
||||
extensions/intellij/bin
|
||||
|
|
|
|||
6
.idea/kotlinc.xml
generated
6
.idea/kotlinc.xml
generated
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.8.0" />
|
||||
</component>
|
||||
</project>
|
||||
43
.vscode/launch.json
vendored
43
.vscode/launch.json
vendored
|
|
@ -131,6 +131,49 @@
|
|||
"env": {
|
||||
"NODE_OPTIONS": "--experimental-vm-modules"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Debug CLI",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/extensions/cli/src/index.ts",
|
||||
"args": [],
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
// "CONTINUE_API_BASE": "http://localhost:3001/",
|
||||
// "WORKOS_CLIENT_ID": "client_01J0FW6XCPMJMQ3CG51RB4HBZQ",
|
||||
// "HUB_URL": "http://localhost:3000"
|
||||
},
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"runtimeArgs": ["--loader", "ts-node/esm"],
|
||||
"sourceMaps": true,
|
||||
"resolveSourceMapLocations": [
|
||||
"${workspaceFolder}/**",
|
||||
"!**/node_modules/**"
|
||||
],
|
||||
"preLaunchTask": "watch-logs",
|
||||
"cwd": "${workspaceFolder}/extensions/cli"
|
||||
},
|
||||
{
|
||||
"name": "Debug CLI Tests",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/extensions/cli/node_modules/.bin/vitest",
|
||||
"args": ["--run", "--no-cache"],
|
||||
"env": {
|
||||
"NODE_ENV": "test"
|
||||
},
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"sourceMaps": true,
|
||||
"resolveSourceMapLocations": [
|
||||
"${workspaceFolder}/**",
|
||||
"!**/node_modules/**"
|
||||
],
|
||||
"cwd": "${workspaceFolder}/extensions/cli"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -42,7 +42,8 @@
|
|||
"extensions/vscode/e2e/_output": true,
|
||||
"extensions/vscode/e2e/storage": true,
|
||||
"extensions/vscode/e2e/vsix": true,
|
||||
"extensions/.continue-debug": true
|
||||
"extensions/.continue-debug": true,
|
||||
"extensions/cli/dist/**": true
|
||||
// "sync/**": true
|
||||
},
|
||||
"editor.formatOnSave": true,
|
||||
|
|
|
|||
62
.vscode/tasks.json
vendored
62
.vscode/tasks.json
vendored
|
|
@ -311,6 +311,68 @@
|
|||
"close": true,
|
||||
"focus": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "cli:build",
|
||||
"type": "npm",
|
||||
"script": "build",
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "silent",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": false
|
||||
},
|
||||
"problemMatcher": ["$tsc"],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/extensions/cli"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "cli:test",
|
||||
"type": "npm",
|
||||
"script": "test",
|
||||
"group": "test",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": false
|
||||
},
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/extensions/cli"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "watch-logs",
|
||||
"type": "shell",
|
||||
"command": "npm run watch:logs",
|
||||
"isBackground": true,
|
||||
"problemMatcher": {
|
||||
"pattern": {
|
||||
"regexp": "^$",
|
||||
"file": 1,
|
||||
"location": 2,
|
||||
"message": 3
|
||||
},
|
||||
"background": {
|
||||
"activeOnStart": true,
|
||||
"beginsPattern": "^.*$",
|
||||
"endsPattern": "^.*$"
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new",
|
||||
"focus": false
|
||||
},
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/extensions/cli"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
189
binary/package-lock.json
generated
189
binary/package-lock.json
generated
|
|
@ -40,7 +40,7 @@
|
|||
"pkg": "^5.8.1",
|
||||
"rimraf": "^5.0.7",
|
||||
"ts-jest": "^29.1.4",
|
||||
"typescript": "^5.3.3"
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
},
|
||||
"../core": {
|
||||
|
|
@ -59,7 +59,11 @@
|
|||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
"@sentry/cli": "^2.50.2",
|
||||
"@sentry/core": "^9.43.0",
|
||||
"@sentry/esbuild-plugin": "^4.0.2",
|
||||
"@sentry/node": "^9.43.0",
|
||||
"@sentry/vite-plugin": "^4.0.2",
|
||||
"@xenova/transformers": "2.14.0",
|
||||
"adf-to-md": "^1.1.0",
|
||||
"async-mutex": "^0.5.0",
|
||||
|
|
@ -78,7 +82,7 @@
|
|||
"http-proxy-agent": "^7.0.1",
|
||||
"https-proxy-agent": "^7.0.3",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ignore": "^5.3.1",
|
||||
"ignore": "^7.0.5",
|
||||
"is-localhost-ip": "^2.0.0",
|
||||
"jinja-js": "0.1.8",
|
||||
"js-tiktoken": "^1.0.8",
|
||||
|
|
@ -91,7 +95,7 @@
|
|||
"node-html-markdown": "^1.3.0",
|
||||
"ollama": "^0.4.6",
|
||||
"onnxruntime-node": "1.14.0",
|
||||
"openai": "^4.104.0",
|
||||
"openai": "^5.13.1",
|
||||
"p-limit": "^6.1.0",
|
||||
"partial-json": "^0.1.7",
|
||||
"pg": "^8.11.3",
|
||||
|
|
@ -139,6 +143,8 @@
|
|||
"@types/tar": "^6.1.13",
|
||||
"@types/uuid": "^9.0.7",
|
||||
"@types/win-ca": "^3.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
||||
"@typescript-eslint/parser": "^8.40.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild": "0.17.19",
|
||||
"eslint": "^8",
|
||||
|
|
@ -2890,6 +2896,19 @@
|
|||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/callsites": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
||||
|
|
@ -3363,6 +3382,20 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/eastasianwidth": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
||||
|
|
@ -3411,6 +3444,51 @@
|
|||
"is-arrayish": "^0.2.1"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-set-tostringtag": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
||||
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.6",
|
||||
"has-tostringtag": "^1.0.2",
|
||||
"hasown": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.19.11",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.11.tgz",
|
||||
|
|
@ -3690,12 +3768,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz",
|
||||
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -3768,7 +3849,6 @@
|
|||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"dev": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
|
|
@ -3791,6 +3871,30 @@
|
|||
"node": "6.* || 8.* || >= 10.*"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-package-type": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",
|
||||
|
|
@ -3800,6 +3904,19 @@
|
|||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/get-stream": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
|
||||
|
|
@ -3881,6 +3998,18 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/graceful-fs": {
|
||||
"version": "4.2.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||
|
|
@ -3904,11 +4033,37 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-tostringtag": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
|
|
@ -5179,6 +5334,15 @@
|
|||
"tmpl": "1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/merge-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
|
||||
|
|
@ -6758,10 +6922,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.4.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
|
||||
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
|
||||
"version": "5.9.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
|
||||
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
"pkg": "^5.8.1",
|
||||
"rimraf": "^5.0.7",
|
||||
"ts-jest": "^29.1.4",
|
||||
"typescript": "^5.3.3"
|
||||
"typescript": "^5.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/rest": "^20.0.2",
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js";
|
|||
import { shouldCompleteMultiline } from "./classification/shouldCompleteMultiline.js";
|
||||
import { ContextRetrievalService } from "./context/ContextRetrievalService.js";
|
||||
|
||||
import { isSecurityConcern } from "../indexing/ignore.js";
|
||||
import { BracketMatchingService } from "./filtering/BracketMatchingService.js";
|
||||
import { CompletionStreamer } from "./generation/CompletionStreamer.js";
|
||||
import { postprocessCompletion } from "./postprocessing/index.js";
|
||||
import { shouldPrefilter } from "./prefiltering/index.js";
|
||||
import { renderPromptWithTokenLimit } from "./templating/index.js";
|
||||
import { getAllSnippetsWithoutRace } from "./snippets/index.js";
|
||||
import { renderPromptWithTokenLimit } from "./templating/index.js";
|
||||
import { GetLspDefinitionsFunction } from "./types.js";
|
||||
import { AutocompleteDebouncer } from "./util/AutocompleteDebouncer.js";
|
||||
import { AutocompleteLoggingService } from "./util/AutocompleteLoggingService.js";
|
||||
|
|
@ -150,6 +151,10 @@ export class CompletionProvider {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (isSecurityConcern(input.filepath)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const options = await this._getAutocompleteOptions(llm);
|
||||
|
||||
// Debounce
|
||||
|
|
@ -210,12 +215,6 @@ export class CompletionProvider {
|
|||
const multiline =
|
||||
!helper.options.transform || shouldCompleteMultiline(helper);
|
||||
|
||||
const rawGeneration = await llm.complete(
|
||||
prompt,
|
||||
token,
|
||||
completionOptions,
|
||||
);
|
||||
|
||||
const completionStream =
|
||||
this.completionStreamer.streamCompletionWithFilters(
|
||||
token,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { IDE } from "../..";
|
|||
import {
|
||||
getGlobalContinueIgArray,
|
||||
getWorkspaceContinueIgArray,
|
||||
} from "../../indexing/ignore";
|
||||
} from "../../indexing/continueignore";
|
||||
import { getConfigJsonPath } from "../../util/paths";
|
||||
import { findUriInDirs } from "../../util/uri";
|
||||
import { HelperVars } from "../util/HelperVars";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
import ignore from "ignore";
|
||||
|
||||
import type { FileType, IDE, SlashCommand } from "../../..";
|
||||
import {
|
||||
DEFAULT_IGNORE,
|
||||
getGlobalContinueIgArray,
|
||||
gitIgArrayFromFile,
|
||||
} from "../../../indexing/ignore";
|
||||
import { getGlobalContinueIgArray } from "../../../indexing/continueignore";
|
||||
import { DEFAULT_IGNORE, gitIgArrayFromFile } from "../../../indexing/ignore";
|
||||
import { renderChatMessage } from "../../../util/messageContent";
|
||||
import {
|
||||
findUriInDirs,
|
||||
|
|
|
|||
|
|
@ -1,37 +1,8 @@
|
|||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const defaultContextProvidersVsCode: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "code" },
|
||||
{ provider: "docs" },
|
||||
{ provider: "diff" },
|
||||
{ provider: "terminal" },
|
||||
{ provider: "problems" },
|
||||
{ provider: "folder" },
|
||||
{ provider: "codebase" },
|
||||
];
|
||||
|
||||
export const defaultContextProvidersJetBrains: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "diff" },
|
||||
{ provider: "folder" },
|
||||
{ provider: "codebase" },
|
||||
];
|
||||
|
||||
export const defaultConfig: ConfigYaml = {
|
||||
name: "Local Agent",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [],
|
||||
context: defaultContextProvidersVsCode,
|
||||
};
|
||||
|
||||
export const defaultConfigJetBrains: ConfigYaml = {
|
||||
name: "Local Agent",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [],
|
||||
context: defaultContextProvidersJetBrains,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import {
|
|||
ContinueRcJson,
|
||||
CustomContextProvider,
|
||||
EmbeddingsProviderDescription,
|
||||
IContextProvider,
|
||||
IDE,
|
||||
IdeInfo,
|
||||
IdeSettings,
|
||||
|
|
@ -36,10 +35,6 @@ import { getLegacyBuiltInSlashCommandFromDescription } from "../commands/slash/b
|
|||
import { convertCustomCommandToSlashCommand } from "../commands/slash/customSlashCommand";
|
||||
import { slashCommandFromPromptFile } from "../commands/slash/promptFileSlashCommand";
|
||||
import { MCPManagerSingleton } from "../context/mcp/MCPManagerSingleton";
|
||||
import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider";
|
||||
import CustomContextProviderClass from "../context/providers/CustomContextProvider";
|
||||
import FileContextProvider from "../context/providers/FileContextProvider";
|
||||
import { contextProviderClassFromName } from "../context/providers/index";
|
||||
import { useHub } from "../control-plane/env";
|
||||
import { BaseLLM } from "../llm";
|
||||
import { LLMClasses, llmFromDescription } from "../llm/llms";
|
||||
|
|
@ -62,9 +57,11 @@ import {
|
|||
} from "../util/paths";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
|
||||
import { getToolsForIde } from "../tools";
|
||||
import CustomContextProviderClass from "../context/providers/CustomContextProvider";
|
||||
import { getBaseToolDefinitions } from "../tools";
|
||||
import { resolveRelativePathInDir } from "../util/ideUtils";
|
||||
import { getWorkspaceRcConfigs } from "./json/loadRcConfigs";
|
||||
import { loadConfigContextProviders } from "./loadContextProviders";
|
||||
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
|
||||
import {
|
||||
getModelByRole,
|
||||
|
|
@ -229,7 +226,7 @@ function applyRequestOptionsToModels(
|
|||
export function isContextProviderWithParams(
|
||||
contextProvider: CustomContextProvider | ContextProviderWithParams,
|
||||
): contextProvider is ContextProviderWithParams {
|
||||
return (contextProvider as ContextProviderWithParams).name !== undefined;
|
||||
return "name" in contextProvider && !!contextProvider.name;
|
||||
}
|
||||
|
||||
/** Only difference between intermediate and final configs is the `models` array */
|
||||
|
|
@ -285,6 +282,7 @@ async function intermediateToFinalConfig({
|
|||
...desc,
|
||||
model: modelName,
|
||||
title: modelName,
|
||||
isFromAutoDetect: true,
|
||||
},
|
||||
ide.readFile.bind(ide),
|
||||
getUriFromPath,
|
||||
|
|
@ -322,6 +320,7 @@ async function intermediateToFinalConfig({
|
|||
...desc.options,
|
||||
model: modelName,
|
||||
logger: llmLogger,
|
||||
isFromAutoDetect: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
|
@ -386,50 +385,25 @@ async function intermediateToFinalConfig({
|
|||
|
||||
applyRequestOptionsToModels(tabAutocompleteModels, config);
|
||||
|
||||
// These context providers are always included, regardless of what, if anything,
|
||||
// the user has configured in config.json
|
||||
// Load context providers
|
||||
const { providers: contextProviders, errors: contextErrors } =
|
||||
loadConfigContextProviders(
|
||||
config.contextProviders
|
||||
?.filter((cp) => isContextProviderWithParams(cp))
|
||||
.map((cp) => ({
|
||||
provider: (cp as ContextProviderWithParams).name,
|
||||
params: (cp as ContextProviderWithParams).params,
|
||||
})),
|
||||
!!config.docs?.length,
|
||||
ideInfo.ideType,
|
||||
);
|
||||
|
||||
const codebaseContextParams =
|
||||
(
|
||||
(config.contextProviders || [])
|
||||
.filter(isContextProviderWithParams)
|
||||
.find((cp) => cp.name === "codebase") as
|
||||
| ContextProviderWithParams
|
||||
| undefined
|
||||
)?.params || {};
|
||||
|
||||
const DEFAULT_CONTEXT_PROVIDERS = [new FileContextProvider({})];
|
||||
|
||||
const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS.map(
|
||||
({ description: { title } }) => title,
|
||||
);
|
||||
|
||||
// Context providers
|
||||
const contextProviders: IContextProvider[] = DEFAULT_CONTEXT_PROVIDERS;
|
||||
|
||||
for (const provider of config.contextProviders || []) {
|
||||
if (isContextProviderWithParams(provider)) {
|
||||
const cls = contextProviderClassFromName(provider.name) as any;
|
||||
if (!cls) {
|
||||
if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(provider.name)) {
|
||||
console.warn(`Unknown context provider ${provider.name}`);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
const instance: IContextProvider = new cls(provider.params);
|
||||
|
||||
// Handle continue-proxy
|
||||
if (instance.description.title === "continue-proxy") {
|
||||
(instance as ContinueProxyContextProvider).workOsAccessToken =
|
||||
workOsAccessToken;
|
||||
}
|
||||
|
||||
contextProviders.push(instance);
|
||||
} else {
|
||||
contextProviders.push(new CustomContextProviderClass(provider));
|
||||
for (const cp of config.contextProviders ?? []) {
|
||||
if (!isContextProviderWithParams(cp)) {
|
||||
contextProviders.push(new CustomContextProviderClass(cp));
|
||||
}
|
||||
}
|
||||
errors.push(...contextErrors);
|
||||
|
||||
// Embeddings Provider
|
||||
function getEmbeddingsILLM(
|
||||
|
|
@ -526,7 +500,7 @@ async function intermediateToFinalConfig({
|
|||
const continueConfig: ContinueConfig = {
|
||||
...config,
|
||||
contextProviders,
|
||||
tools: await getToolsForIde(ide),
|
||||
tools: getBaseToolDefinitions(),
|
||||
mcpServerStatuses: [],
|
||||
slashCommands: [],
|
||||
modelsByRole: {
|
||||
|
|
@ -654,6 +628,7 @@ function llmToSerializedModelDescription(llm: ILLM): ModelDescription {
|
|||
apiKeyLocation: llm.apiKeyLocation,
|
||||
envSecretLocations: llm.envSecretLocations,
|
||||
sourceFile: llm.sourceFile,
|
||||
isFromAutoDetect: llm.isFromAutoDetect,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
95
core/config/loadContextProviders.ts
Normal file
95
core/config/loadContextProviders.ts
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
import {
|
||||
AssistantUnrolledNonNullable,
|
||||
ConfigValidationError,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { IContextProvider, IdeType } from "..";
|
||||
import { contextProviderClassFromName } from "../context/providers";
|
||||
import CurrentFileContextProvider from "../context/providers/CurrentFileContextProvider";
|
||||
import DiffContextProvider from "../context/providers/DiffContextProvider";
|
||||
import DocsContextProvider from "../context/providers/DocsContextProvider";
|
||||
import FileContextProvider from "../context/providers/FileContextProvider";
|
||||
import ProblemsContextProvider from "../context/providers/ProblemsContextProvider";
|
||||
import RulesContextProvider from "../context/providers/RulesContextProvider";
|
||||
import TerminalContextProvider from "../context/providers/TerminalContextProvider";
|
||||
|
||||
/*
|
||||
Loads context providers based on configuration
|
||||
- default providers will always be loaded, using config params if present
|
||||
- other providers will be loaded if configured
|
||||
|
||||
NOTE the MCPContextProvider is added in doLoadConfig if any resources are present
|
||||
*/
|
||||
export function loadConfigContextProviders(
|
||||
configContext: AssistantUnrolledNonNullable["context"],
|
||||
hasDocs: boolean,
|
||||
ideType: IdeType,
|
||||
): {
|
||||
providers: IContextProvider[];
|
||||
errors: ConfigValidationError[];
|
||||
} {
|
||||
const providers: IContextProvider[] = [];
|
||||
const errors: ConfigValidationError[] = [];
|
||||
|
||||
const defaultProviders: IContextProvider[] = [
|
||||
new FileContextProvider({}),
|
||||
new CurrentFileContextProvider({}),
|
||||
new DiffContextProvider({}),
|
||||
new TerminalContextProvider({}),
|
||||
new ProblemsContextProvider({}),
|
||||
new RulesContextProvider({}),
|
||||
];
|
||||
|
||||
// Add from config
|
||||
if (configContext) {
|
||||
for (const config of configContext) {
|
||||
const cls = contextProviderClassFromName(config.provider) as any;
|
||||
if (
|
||||
!cls &&
|
||||
!defaultProviders.find((p) => p.description.title === config.provider)
|
||||
) {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `Unknown context provider ${config.provider}`,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
providers.push(
|
||||
new cls({
|
||||
name: config.name,
|
||||
...config.params,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Add from defaults if not found in config
|
||||
for (const defaultProvider of defaultProviders) {
|
||||
if (
|
||||
!providers.find(
|
||||
(p) => p.description.title === defaultProvider.description.title,
|
||||
)
|
||||
) {
|
||||
providers.push(defaultProvider);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDocs && !providers?.some((cp) => cp.description.title === "docs")) {
|
||||
providers.push(new DocsContextProvider({}));
|
||||
}
|
||||
|
||||
// @problems and @terminal are not supported in jetbrains
|
||||
const filteredProviders = providers.filter((pv) => {
|
||||
if (ideType === "jetbrains") {
|
||||
return (
|
||||
pv.description.title !== TerminalContextProvider.description.title &&
|
||||
pv.description.title !== ProblemsContextProvider.description.title
|
||||
);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return {
|
||||
providers: filteredProviders,
|
||||
errors,
|
||||
};
|
||||
}
|
||||
590
core/config/loadContextProviders.vitest.ts
Normal file
590
core/config/loadContextProviders.vitest.ts
Normal file
|
|
@ -0,0 +1,590 @@
|
|||
import { beforeEach, describe, expect, it, MockedFunction, vi } from "vitest";
|
||||
import { contextProviderClassFromName } from "../context/providers";
|
||||
import CurrentFileContextProvider from "../context/providers/CurrentFileContextProvider";
|
||||
import DiffContextProvider from "../context/providers/DiffContextProvider";
|
||||
import FileContextProvider from "../context/providers/FileContextProvider";
|
||||
import ProblemsContextProvider from "../context/providers/ProblemsContextProvider";
|
||||
import RulesContextProvider from "../context/providers/RulesContextProvider";
|
||||
import TerminalContextProvider from "../context/providers/TerminalContextProvider";
|
||||
import { loadConfigContextProviders } from "./loadContextProviders";
|
||||
|
||||
// Mock the contextProviderClassFromName function
|
||||
vi.mock("../context/providers", () => ({
|
||||
contextProviderClassFromName: vi.fn(),
|
||||
}));
|
||||
|
||||
// Mock all provider classes
|
||||
vi.mock("../context/providers/CurrentFileContextProvider", () => ({
|
||||
default: vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "current-file" },
|
||||
options,
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock("../context/providers/DiffContextProvider", () => ({
|
||||
default: vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "diff" },
|
||||
options,
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock("../context/providers/FileContextProvider", () => ({
|
||||
default: vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "file" },
|
||||
options,
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock("../context/providers/ProblemsContextProvider", () => {
|
||||
const MockProblemsContextProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "problems" },
|
||||
options,
|
||||
}));
|
||||
(MockProblemsContextProvider as any).description = { title: "problems" };
|
||||
return { default: MockProblemsContextProvider };
|
||||
});
|
||||
|
||||
vi.mock("../context/providers/RulesContextProvider", () => ({
|
||||
default: vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "rules" },
|
||||
options,
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock("../context/providers/TerminalContextProvider", () => {
|
||||
const MockTerminalContextProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "terminal" },
|
||||
options,
|
||||
}));
|
||||
(MockTerminalContextProvider as any).description = { title: "terminal" };
|
||||
return { default: MockTerminalContextProvider };
|
||||
});
|
||||
|
||||
const mockedContextProviderClassFromName =
|
||||
contextProviderClassFromName as MockedFunction<
|
||||
typeof contextProviderClassFromName
|
||||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe("loadConfigContextProviders", () => {
|
||||
describe("with empty or undefined config", () => {
|
||||
it("should return only default providers when config is undefined", () => {
|
||||
const result = loadConfigContextProviders(undefined, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(result.providers).toHaveLength(6);
|
||||
|
||||
// Verify all default providers are included
|
||||
const providerTitles = result.providers.map((p) => p.description.title);
|
||||
expect(providerTitles).toEqual(
|
||||
expect.arrayContaining([
|
||||
"file",
|
||||
"current-file",
|
||||
"diff",
|
||||
"terminal",
|
||||
"problems",
|
||||
"rules",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("should return only default providers when config is empty array", () => {
|
||||
const result = loadConfigContextProviders([], false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(result.providers).toHaveLength(6);
|
||||
|
||||
const providerTitles = result.providers.map((p) => p.description.title);
|
||||
expect(providerTitles).toEqual(
|
||||
expect.arrayContaining([
|
||||
"file",
|
||||
"current-file",
|
||||
"diff",
|
||||
"terminal",
|
||||
"problems",
|
||||
"rules",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("should exclude problems and terminal in jetbrains", () => {
|
||||
const result = loadConfigContextProviders([], false, "jetbrains");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(result.providers).toHaveLength(4);
|
||||
|
||||
const providerTitles = result.providers.map((p) => p.description.title);
|
||||
expect(providerTitles).toEqual(
|
||||
expect.arrayContaining(["file", "current-file", "diff", "rules"]),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("should return default + docs when has docs is true", () => {
|
||||
const result = loadConfigContextProviders([], true, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(result.providers).toHaveLength(7);
|
||||
|
||||
const providerTitles = result.providers.map((p) => p.description.title);
|
||||
expect(providerTitles).toEqual(
|
||||
expect.arrayContaining([
|
||||
"file",
|
||||
"current-file",
|
||||
"diff",
|
||||
"terminal",
|
||||
"problems",
|
||||
"rules",
|
||||
"docs",
|
||||
]),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with valid config", () => {
|
||||
it("should load providers from config with correct parameters", () => {
|
||||
const mockProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "custom-provider" },
|
||||
options,
|
||||
})) as any;
|
||||
|
||||
mockedContextProviderClassFromName.mockReturnValue(mockProvider);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "custom-provider",
|
||||
name: "my-custom-provider",
|
||||
params: {
|
||||
apiKey: "test-key",
|
||||
baseUrl: "https://api.example.com",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(mockedContextProviderClassFromName).toHaveBeenCalledWith(
|
||||
"custom-provider",
|
||||
);
|
||||
expect(mockProvider).toHaveBeenCalledWith({
|
||||
name: "my-custom-provider",
|
||||
apiKey: "test-key",
|
||||
baseUrl: "https://api.example.com",
|
||||
});
|
||||
|
||||
// Should have custom provider + all defaults
|
||||
expect(result.providers).toHaveLength(7);
|
||||
|
||||
const customProvider = result.providers.find(
|
||||
(p) => p.description.title === "custom-provider",
|
||||
);
|
||||
expect(customProvider).toBeDefined();
|
||||
expect((customProvider as any)?.options).toEqual({
|
||||
name: "my-custom-provider",
|
||||
apiKey: "test-key",
|
||||
baseUrl: "https://api.example.com",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle multiple providers in config", () => {
|
||||
const mockProvider1 = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "provider-1" },
|
||||
options,
|
||||
})) as any;
|
||||
|
||||
const mockProvider2 = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "provider-2" },
|
||||
options,
|
||||
})) as any;
|
||||
|
||||
mockedContextProviderClassFromName
|
||||
.mockReturnValueOnce(mockProvider1)
|
||||
.mockReturnValueOnce(mockProvider2);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "provider-1",
|
||||
name: "first-provider",
|
||||
params: { setting1: "value1" },
|
||||
},
|
||||
{
|
||||
provider: "provider-2",
|
||||
name: "second-provider",
|
||||
params: { setting2: "value2" },
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(result.providers).toHaveLength(8); // 2 custom + 6 defaults
|
||||
|
||||
expect(mockProvider1).toHaveBeenCalledWith({
|
||||
name: "first-provider",
|
||||
setting1: "value1",
|
||||
});
|
||||
|
||||
expect(mockProvider2).toHaveBeenCalledWith({
|
||||
name: "second-provider",
|
||||
setting2: "value2",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle config with empty params", () => {
|
||||
const mockProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "no-params-provider" },
|
||||
options,
|
||||
})) as any;
|
||||
|
||||
mockedContextProviderClassFromName.mockReturnValue(mockProvider);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "no-params-provider",
|
||||
name: "simple-provider",
|
||||
params: {},
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(mockProvider).toHaveBeenCalledWith({
|
||||
name: "simple-provider",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle config without params property", () => {
|
||||
const mockProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "provider-without-params" },
|
||||
options,
|
||||
})) as any;
|
||||
|
||||
mockedContextProviderClassFromName.mockReturnValue(mockProvider);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "provider-without-params",
|
||||
name: "minimal-provider",
|
||||
} as any, // Cast to bypass type checking for test
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(mockProvider).toHaveBeenCalledWith({
|
||||
name: "minimal-provider",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("error handling", () => {
|
||||
it("should add error for unknown provider", () => {
|
||||
mockedContextProviderClassFromName.mockReturnValue(undefined);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "unknown-provider",
|
||||
name: "test-provider",
|
||||
params: {},
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([
|
||||
{
|
||||
fatal: false,
|
||||
message: "Unknown context provider unknown-provider",
|
||||
},
|
||||
]);
|
||||
|
||||
// Should still have default providers
|
||||
expect(result.providers).toHaveLength(6);
|
||||
expect(mockedContextProviderClassFromName).toHaveBeenCalledWith(
|
||||
"unknown-provider",
|
||||
);
|
||||
});
|
||||
|
||||
it("should handle multiple unknown providers", () => {
|
||||
mockedContextProviderClassFromName.mockReturnValue(undefined);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "unknown-1",
|
||||
name: "test-1",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
provider: "unknown-2",
|
||||
name: "test-2",
|
||||
params: {},
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([
|
||||
{
|
||||
fatal: false,
|
||||
message: "Unknown context provider unknown-1",
|
||||
},
|
||||
{
|
||||
fatal: false,
|
||||
message: "Unknown context provider unknown-2",
|
||||
},
|
||||
]);
|
||||
|
||||
expect(result.providers).toHaveLength(6); // Only defaults
|
||||
});
|
||||
|
||||
it("should handle mix of valid and invalid providers", () => {
|
||||
const mockValidProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "valid-provider" },
|
||||
options,
|
||||
})) as any;
|
||||
|
||||
mockedContextProviderClassFromName
|
||||
.mockReturnValueOnce(mockValidProvider)
|
||||
.mockReturnValueOnce(undefined);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "valid-provider",
|
||||
name: "valid",
|
||||
params: { key: "value" },
|
||||
},
|
||||
{
|
||||
provider: "invalid-provider",
|
||||
name: "invalid",
|
||||
params: {},
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([
|
||||
{
|
||||
fatal: false,
|
||||
message: "Unknown context provider invalid-provider",
|
||||
},
|
||||
]);
|
||||
|
||||
// Should have valid provider + defaults
|
||||
expect(result.providers).toHaveLength(7);
|
||||
expect(mockValidProvider).toHaveBeenCalledWith({
|
||||
name: "valid",
|
||||
key: "value",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("default provider merging", () => {
|
||||
it("should not duplicate providers when config matches defaults", () => {
|
||||
// Mock FileContextProvider to be returned by contextProviderClassFromName
|
||||
mockedContextProviderClassFromName.mockReturnValue(FileContextProvider);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "file",
|
||||
name: "custom-file-provider",
|
||||
params: { maxFiles: 100 },
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
|
||||
// Should have configured file provider + other defaults (not duplicate file)
|
||||
expect(result.providers).toHaveLength(6);
|
||||
|
||||
const fileProviders = result.providers.filter(
|
||||
(p) => p.description.title === "file",
|
||||
);
|
||||
expect(fileProviders).toHaveLength(1);
|
||||
|
||||
// The configured one should be used (with custom params)
|
||||
expect(FileContextProvider).toHaveBeenCalledWith({
|
||||
name: "custom-file-provider",
|
||||
maxFiles: 100,
|
||||
});
|
||||
});
|
||||
|
||||
it("should add default providers not present in config", () => {
|
||||
const mockCustomProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "custom-only" },
|
||||
options,
|
||||
})) as any;
|
||||
|
||||
mockedContextProviderClassFromName.mockReturnValue(mockCustomProvider);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "custom-only",
|
||||
name: "custom",
|
||||
params: {},
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(result.providers).toHaveLength(7); // 1 custom + 6 defaults
|
||||
|
||||
// All defaults should be present
|
||||
const providerTitles = result.providers.map((p) => p.description.title);
|
||||
expect(providerTitles).toEqual(
|
||||
expect.arrayContaining([
|
||||
"custom-only",
|
||||
"file",
|
||||
"current-file",
|
||||
"diff",
|
||||
"terminal",
|
||||
"problems",
|
||||
"rules",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("should preserve order with configured providers first", () => {
|
||||
const mockProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "custom-provider" },
|
||||
options,
|
||||
})) as any;
|
||||
|
||||
mockedContextProviderClassFromName.mockReturnValue(mockProvider);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "custom-provider",
|
||||
name: "custom",
|
||||
params: {},
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.providers[0].description.title).toBe("custom-provider");
|
||||
|
||||
// Rest should be defaults in their original order
|
||||
const defaultTitles = result.providers
|
||||
.slice(1)
|
||||
.map((p) => p.description.title);
|
||||
expect(defaultTitles).toEqual([
|
||||
"file",
|
||||
"current-file",
|
||||
"diff",
|
||||
"terminal",
|
||||
"problems",
|
||||
"rules",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("edge cases", () => {
|
||||
it("should handle provider constructor throwing error", () => {
|
||||
const mockProvider = vi.fn().mockImplementation(() => {
|
||||
throw new Error("Provider construction failed");
|
||||
}) as any;
|
||||
|
||||
mockedContextProviderClassFromName.mockReturnValue(mockProvider);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "failing-provider",
|
||||
name: "failing",
|
||||
params: {},
|
||||
},
|
||||
];
|
||||
|
||||
expect(() => loadConfigContextProviders(config, false, "vscode")).toThrow(
|
||||
"Provider construction failed",
|
||||
);
|
||||
});
|
||||
|
||||
it("should handle null provider class", () => {
|
||||
mockedContextProviderClassFromName.mockReturnValue(undefined);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "null-provider",
|
||||
name: "null",
|
||||
params: {},
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([
|
||||
{
|
||||
fatal: false,
|
||||
message: "Unknown context provider null-provider",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("should handle provider with same title as default but different implementation", () => {
|
||||
// Mock a provider with same title as a default
|
||||
const mockFileProvider = vi.fn().mockImplementation((options) => ({
|
||||
description: { title: "file" }, // Same title as FileContextProvider
|
||||
options,
|
||||
customProperty: "custom-implementation",
|
||||
})) as any;
|
||||
|
||||
mockedContextProviderClassFromName.mockReturnValue(mockFileProvider);
|
||||
|
||||
const config = [
|
||||
{
|
||||
provider: "custom-file",
|
||||
name: "my-file-provider",
|
||||
params: { customParam: "value" },
|
||||
},
|
||||
];
|
||||
|
||||
const result = loadConfigContextProviders(config, false, "vscode");
|
||||
|
||||
expect(result.errors).toEqual([]);
|
||||
|
||||
// Should not duplicate - custom implementation should be used
|
||||
const fileProviders = result.providers.filter(
|
||||
(p) => p.description.title === "file",
|
||||
);
|
||||
expect(fileProviders).toHaveLength(1);
|
||||
|
||||
const fileProvider = fileProviders[0] as any;
|
||||
expect(fileProvider.customProperty).toBe("custom-implementation");
|
||||
expect(fileProvider.options).toEqual({
|
||||
name: "my-file-provider",
|
||||
customParam: "value",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("provider instantiation", () => {
|
||||
it("should call default provider constructors with empty options", () => {
|
||||
loadConfigContextProviders([], false, "vscode");
|
||||
|
||||
expect(FileContextProvider).toHaveBeenCalledWith({});
|
||||
expect(CurrentFileContextProvider).toHaveBeenCalledWith({});
|
||||
expect(DiffContextProvider).toHaveBeenCalledWith({});
|
||||
expect(TerminalContextProvider).toHaveBeenCalledWith({});
|
||||
expect(ProblemsContextProvider).toHaveBeenCalledWith({});
|
||||
expect(RulesContextProvider).toHaveBeenCalledWith({});
|
||||
});
|
||||
|
||||
it("should call provider constructors exactly once per provider", () => {
|
||||
loadConfigContextProviders([], false, "vscode");
|
||||
|
||||
expect(FileContextProvider).toHaveBeenCalledTimes(1);
|
||||
expect(CurrentFileContextProvider).toHaveBeenCalledTimes(1);
|
||||
expect(DiffContextProvider).toHaveBeenCalledTimes(1);
|
||||
expect(TerminalContextProvider).toHaveBeenCalledTimes(1);
|
||||
expect(ProblemsContextProvider).toHaveBeenCalledTimes(1);
|
||||
expect(RulesContextProvider).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
|
@ -35,7 +35,11 @@ async function getDefinitionFilesInDir(
|
|||
}
|
||||
|
||||
const overrideDefaultIgnores = ignore()
|
||||
.add(DEFAULT_IGNORE_FILETYPES.filter((t) => t !== "config.yaml"))
|
||||
.add(
|
||||
DEFAULT_IGNORE_FILETYPES.filter(
|
||||
(t) => t !== "config.yaml" && t !== "config.yml",
|
||||
),
|
||||
)
|
||||
.add(DEFAULT_IGNORE_DIRS);
|
||||
|
||||
const uris = await walkDir(dir, ide, {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ describe("ASSISTANTS getAllDotContinueDefinitionFiles with fileExtType option",
|
|||
[".continue/assistants/assistant2.yml", "yaml content 2"],
|
||||
[".continue/assistants/assistant3.md", "markdown content 1"],
|
||||
[".continue/assistants/assistant4.txt", "txt content"],
|
||||
[".continue/assistants/config.yaml", "txt content"],
|
||||
[".continue/assistants/config.yml", "txt content"],
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
@ -38,9 +40,14 @@ describe("ASSISTANTS getAllDotContinueDefinitionFiles with fileExtType option",
|
|||
options,
|
||||
"assistants",
|
||||
);
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result).toHaveLength(4);
|
||||
expect(result.map((f) => f.path.split("/").pop())).toEqual(
|
||||
expect.arrayContaining(["assistant1.yaml", "assistant2.yml"]),
|
||||
expect.arrayContaining([
|
||||
"assistant1.yaml",
|
||||
"assistant2.yml",
|
||||
"config.yaml",
|
||||
"config.yml",
|
||||
]),
|
||||
);
|
||||
expect(result.map((f) => f.path.split("/").pop())).not.toContain(
|
||||
"assistant3.md",
|
||||
|
|
@ -69,6 +76,12 @@ describe("ASSISTANTS getAllDotContinueDefinitionFiles with fileExtType option",
|
|||
expect(result.map((f) => f.path.split("/").pop())).not.toContain(
|
||||
"assistant2.yml",
|
||||
);
|
||||
expect(result.map((f) => f.path.split("/").pop())).not.toContain(
|
||||
"config.yml",
|
||||
);
|
||||
expect(result.map((f) => f.path.split("/").pop())).not.toContain(
|
||||
"config.yaml",
|
||||
);
|
||||
});
|
||||
|
||||
it("should return all supported files when fileExtType is not specified", async () => {
|
||||
|
|
@ -83,11 +96,13 @@ describe("ASSISTANTS getAllDotContinueDefinitionFiles with fileExtType option",
|
|||
options,
|
||||
"assistants",
|
||||
);
|
||||
expect(result).toHaveLength(3);
|
||||
expect(result).toHaveLength(5);
|
||||
expect(result.map((f) => f.path.split("/").pop())).toEqual(
|
||||
expect.arrayContaining([
|
||||
"assistant1.yaml",
|
||||
"assistant2.yml",
|
||||
"config.yml",
|
||||
"config.yaml",
|
||||
"assistant3.md",
|
||||
]),
|
||||
);
|
||||
|
|
@ -124,9 +139,14 @@ describe("ASSISTANTS getAllDotContinueDefinitionFiles with fileExtType option",
|
|||
workspaceOnOptions,
|
||||
"assistants",
|
||||
);
|
||||
expect(workspaceResult).toHaveLength(2);
|
||||
expect(workspaceResult).toHaveLength(4);
|
||||
expect(workspaceResult.map((f) => f.path.split("/").pop())).toEqual(
|
||||
expect.arrayContaining(["assistant1.yaml", "assistant2.yml"]),
|
||||
expect.arrayContaining([
|
||||
"assistant1.yaml",
|
||||
"assistant2.yml",
|
||||
"config.yaml",
|
||||
"config.yml",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
@ -187,7 +207,7 @@ describe("ASSISTANTS getAllDotContinueDefinitionFiles with fileExtType option",
|
|||
options,
|
||||
"assistants",
|
||||
);
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result).toHaveLength(4);
|
||||
const yamlFile = result.find((f) => f.path.includes("assistant1.yaml"));
|
||||
expect(yamlFile?.content).toBe("yaml content 1");
|
||||
});
|
||||
|
|
@ -212,9 +232,14 @@ describe("ASSISTANTS getAllDotContinueDefinitionFiles with fileExtType option",
|
|||
"assistants",
|
||||
);
|
||||
// Should only get lowercase extensions (current implementation)
|
||||
expect(yamlResult).toHaveLength(2);
|
||||
expect(yamlResult).toHaveLength(4);
|
||||
expect(yamlResult.map((f) => f.path.split("/").pop())).toEqual(
|
||||
expect.arrayContaining(["assistant1.yaml", "assistant2.yml"]),
|
||||
expect.arrayContaining([
|
||||
"assistant1.yaml",
|
||||
"assistant2.yml",
|
||||
"config.yaml",
|
||||
"config.yml",
|
||||
]),
|
||||
);
|
||||
expect(yamlResult.map((f) => f.path.split("/").pop())).not.toContain(
|
||||
"assistant5.YAML",
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@ import {
|
|||
} from "../../";
|
||||
import { stringifyMcpPrompt } from "../../commands/slash/mcpSlashCommand";
|
||||
import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
|
||||
import CurrentFileContextProvider from "../../context/providers/CurrentFileContextProvider";
|
||||
import ContinueProxyContextProvider from "../../context/providers/ContinueProxyContextProvider";
|
||||
import MCPContextProvider from "../../context/providers/MCPContextProvider";
|
||||
import RulesContextProvider from "../../context/providers/RulesContextProvider";
|
||||
import { ControlPlaneProxyInfo } from "../../control-plane/analytics/IAnalyticsProvider.js";
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { getControlPlaneEnv } from "../../control-plane/env.js";
|
||||
|
|
@ -158,17 +157,13 @@ export default async function doLoadConfig(options: {
|
|||
const { rules, errors: rulesErrors } = await loadRules(ide);
|
||||
errors.push(...rulesErrors);
|
||||
newConfig.rules.unshift(...rules);
|
||||
newConfig.contextProviders.push(new RulesContextProvider({}));
|
||||
|
||||
// Add current file as context if setting is enabled
|
||||
if (
|
||||
newConfig.experimental?.useCurrentFileAsContext === true &&
|
||||
!newConfig.contextProviders.find(
|
||||
(c) =>
|
||||
c.description.title === CurrentFileContextProvider.description.title,
|
||||
)
|
||||
) {
|
||||
newConfig.contextProviders.push(new CurrentFileContextProvider({}));
|
||||
const proxyContextProvider = newConfig.contextProviders?.find(
|
||||
(cp) => cp.description.title === "continue-proxy",
|
||||
);
|
||||
if (proxyContextProvider) {
|
||||
(proxyContextProvider as ContinueProxyContextProvider).workOsAccessToken =
|
||||
workOsAccessToken;
|
||||
}
|
||||
|
||||
// Show deprecation warnings for providers
|
||||
|
|
@ -287,6 +282,8 @@ export default async function doLoadConfig(options: {
|
|||
enableExperimentalTools:
|
||||
newConfig.experimental?.enableExperimentalTools ?? false,
|
||||
isSignedIn,
|
||||
isRemote: await ide.isWorkspaceRemote(),
|
||||
modelName: newConfig.selectedModelByRole.chat?.model,
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export const sharedConfigSchema = z
|
|||
displayRawMarkdown: z.boolean(),
|
||||
showChatScrollbar: z.boolean(),
|
||||
autoAcceptEditToolDiffs: z.boolean(),
|
||||
continueAfterToolRejection: z.boolean(),
|
||||
|
||||
// `tabAutocompleteOptions` in `ContinueConfig`
|
||||
useAutocompleteCache: z.boolean(),
|
||||
|
|
@ -158,6 +159,11 @@ export function modifyAnyConfigWithSharedConfig<
|
|||
configCopy.ui.showSessionTabs = sharedConfig.showSessionTabs;
|
||||
}
|
||||
|
||||
if (sharedConfig.continueAfterToolRejection !== undefined) {
|
||||
configCopy.ui.continueAfterToolRejection =
|
||||
sharedConfig.continueAfterToolRejection;
|
||||
}
|
||||
|
||||
configCopy.experimental = {
|
||||
...configCopy.experimental,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
import { ModelDescription } from "../index.d";
|
||||
|
||||
/**
|
||||
* Determines if system message tools should be auto-enabled for the given model.
|
||||
* This is used to automatically enable system message tools for certain provider/model combinations
|
||||
* where we have a strong preference, taking priority over user manual settings.
|
||||
*
|
||||
* System message tools are an alternative to native tool calling where tool definitions and calls
|
||||
* are embedded in the system message as text rather than using the provider's native tool calling API.
|
||||
* This can be beneficial for providers/models that don't support native tool calling or have
|
||||
* poor tool calling performance.
|
||||
*
|
||||
* Current auto-enable rules:
|
||||
* - OpenRouter provider: true for all models except those containing "claude" (since Claude models
|
||||
* generally have good native tool calling support)
|
||||
* - All other providers: undefined (no auto-preference, use manual setting)
|
||||
*
|
||||
* @param model The model description to check
|
||||
* @returns true to force enable, false to force disable, undefined for no auto-preference
|
||||
*/
|
||||
export function shouldAutoEnableSystemMessageTools(
|
||||
model: ModelDescription,
|
||||
): boolean | undefined {
|
||||
// Auto-enable for OpenRouter, but exclude Claude models which have good native tool calling
|
||||
if (model.provider === "openrouter") {
|
||||
return !model.model.toLowerCase().includes("claude");
|
||||
}
|
||||
|
||||
// No auto-preference for all other providers - use manual setting
|
||||
return undefined;
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
import { describe, expect, test } from "vitest";
|
||||
import { ModelDescription } from "../index.d";
|
||||
import { shouldAutoEnableSystemMessageTools } from "./shouldAutoEnableSystemMessageTools";
|
||||
|
||||
describe("shouldAutoEnableSystemMessageTools", () => {
|
||||
const createModel = (provider: string, model: string): ModelDescription => ({
|
||||
title: "Test Model",
|
||||
provider,
|
||||
underlyingProviderName: provider,
|
||||
model,
|
||||
});
|
||||
|
||||
test("should return true for OpenRouter models that don't contain 'claude'", () => {
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(createModel("openrouter", "gpt-4o")),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("openrouter", "llama-3.3-70b-instruct"),
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("openrouter", "qwen/qwen-2.5-72b-instruct"),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test("should return false for OpenRouter Claude models", () => {
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("openrouter", "anthropic/claude-3-sonnet"),
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("openrouter", "anthropic/claude-3.5-sonnet"),
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("openrouter", "claude-3-haiku"),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
test("should return undefined for all other providers", () => {
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(createModel("openai", "gpt-4o")),
|
||||
).toBe(undefined);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("anthropic", "claude-3.5-sonnet"),
|
||||
),
|
||||
).toBe(undefined);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("groq", "llama-3.3-70b-versatile"),
|
||||
),
|
||||
).toBe(undefined);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("together", "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"),
|
||||
),
|
||||
).toBe(undefined);
|
||||
});
|
||||
|
||||
test("should be case insensitive for 'claude' detection", () => {
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("openrouter", "CLAUDE-models"),
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("openrouter", "Claude-3.5"),
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldAutoEnableSystemMessageTools(
|
||||
createModel("openrouter", "some-model-Claude"),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
@ -14,18 +14,8 @@ import {
|
|||
} from "@continuedev/config-yaml";
|
||||
import { dirname } from "node:path";
|
||||
|
||||
import {
|
||||
ContinueConfig,
|
||||
IContextProvider,
|
||||
IDE,
|
||||
IdeInfo,
|
||||
IdeSettings,
|
||||
ILLMLogger,
|
||||
} from "../..";
|
||||
import { ContinueConfig, IDE, IdeInfo, IdeSettings, ILLMLogger } from "../..";
|
||||
import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
|
||||
import DocsContextProvider from "../../context/providers/DocsContextProvider";
|
||||
import FileContextProvider from "../../context/providers/FileContextProvider";
|
||||
import { contextProviderClassFromName } from "../../context/providers/index";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { getAllPromptFiles } from "../../promptFiles/getPromptFiles";
|
||||
|
|
@ -35,8 +25,9 @@ import { modifyAnyConfigWithSharedConfig } from "../sharedConfig";
|
|||
import { convertPromptBlockToSlashCommand } from "../../commands/slash/promptBlockSlashCommand";
|
||||
import { slashCommandFromPromptFile } from "../../commands/slash/promptFileSlashCommand";
|
||||
import { getControlPlaneEnvSync } from "../../control-plane/env";
|
||||
import { getToolsForIde } from "../../tools";
|
||||
import { getBaseToolDefinitions } from "../../tools";
|
||||
import { getCleanUriPath } from "../../util/uri";
|
||||
import { loadConfigContextProviders } from "../loadContextProviders";
|
||||
import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants";
|
||||
import { unrollLocalYamlBlocks } from "./loadLocalYamlBlocks";
|
||||
import { LocalPlatformClient } from "./LocalPlatformClient";
|
||||
|
|
@ -177,7 +168,7 @@ async function configYamlToContinueConfig(options: {
|
|||
|
||||
const continueConfig: ContinueConfig = {
|
||||
slashCommands: [],
|
||||
tools: await getToolsForIde(ide),
|
||||
tools: getBaseToolDefinitions(),
|
||||
mcpServerStatuses: [],
|
||||
contextProviders: [],
|
||||
modelsByRole: {
|
||||
|
|
@ -376,42 +367,14 @@ async function configYamlToContinueConfig(options: {
|
|||
});
|
||||
}
|
||||
|
||||
// Context providers
|
||||
const DEFAULT_CONTEXT_PROVIDERS = [new FileContextProvider({})];
|
||||
|
||||
const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS.map(
|
||||
({ description: { title } }) => title,
|
||||
const { providers, errors: contextErrors } = loadConfigContextProviders(
|
||||
config.context,
|
||||
!!config.docs?.length,
|
||||
ideInfo.ideType,
|
||||
);
|
||||
|
||||
continueConfig.contextProviders = (config.context
|
||||
?.map((context) => {
|
||||
const cls = contextProviderClassFromName(context.provider) as any;
|
||||
if (!cls) {
|
||||
if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.provider)) {
|
||||
localErrors.push({
|
||||
fatal: false,
|
||||
message: `Unknown context provider ${context.provider}`,
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
const instance: IContextProvider = new cls({
|
||||
name: context.name,
|
||||
...context.params,
|
||||
});
|
||||
return instance;
|
||||
})
|
||||
.filter((p) => !!p) ?? []) as IContextProvider[];
|
||||
continueConfig.contextProviders.push(...DEFAULT_CONTEXT_PROVIDERS);
|
||||
|
||||
if (
|
||||
continueConfig.docs?.length &&
|
||||
!continueConfig.contextProviders?.some(
|
||||
(cp) => cp.description.title === "docs",
|
||||
)
|
||||
) {
|
||||
continueConfig.contextProviders.push(new DocsContextProvider({}));
|
||||
}
|
||||
continueConfig.contextProviders = providers;
|
||||
localErrors.push(...contextErrors);
|
||||
|
||||
// Trigger MCP server refreshes (Config is reloaded again once connected!)
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
|
|
|
|||
|
|
@ -32,12 +32,14 @@ async function modelConfigToBaseLLM({
|
|||
ideSettings,
|
||||
llmLogger,
|
||||
config,
|
||||
isFromAutoDetect,
|
||||
}: {
|
||||
model: ModelConfig;
|
||||
uniqueId: string;
|
||||
ideSettings: IdeSettings;
|
||||
llmLogger: ILLMLogger;
|
||||
config: ContinueConfig;
|
||||
isFromAutoDetect?: boolean;
|
||||
}): Promise<BaseLLM | undefined> {
|
||||
const cls = getModelClass(model);
|
||||
|
||||
|
|
@ -71,6 +73,7 @@ async function modelConfigToBaseLLM({
|
|||
nextEdit: model.capabilities?.includes("next_edit"),
|
||||
},
|
||||
autocompleteOptions: model.autocompleteOptions,
|
||||
isFromAutoDetect,
|
||||
};
|
||||
|
||||
// Model capabilities - need to be undefined if not found
|
||||
|
|
@ -173,7 +176,6 @@ async function autodetectModels({
|
|||
if (modelName === AUTODETECT) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return await modelConfigToBaseLLM({
|
||||
model: {
|
||||
...model,
|
||||
|
|
@ -184,6 +186,7 @@ async function autodetectModels({
|
|||
ideSettings,
|
||||
llmLogger,
|
||||
config,
|
||||
isFromAutoDetect: true,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import {
|
|||
ContextSubmenuItem,
|
||||
LoadSubmenuItemsArgs,
|
||||
} from "../../";
|
||||
import { isSecurityConcern } from "../../indexing/ignore";
|
||||
import { walkDirs } from "../../indexing/walkDir";
|
||||
import {
|
||||
getShortestUniqueRelativeUriPaths,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {
|
|||
ContextProviderDescription,
|
||||
ContextProviderExtras,
|
||||
} from "../../index.js";
|
||||
import { isSecurityConcern } from "../../indexing/ignore.js";
|
||||
import { getUriDescription } from "../../util/uri.js";
|
||||
import { BaseContextProvider } from "../index.js";
|
||||
|
||||
|
|
@ -27,10 +28,23 @@ class OpenFilesContextProvider extends BaseContextProvider {
|
|||
|
||||
return await Promise.all(
|
||||
openFiles.map(async (filepath: string) => {
|
||||
const content = await ide.readFile(filepath);
|
||||
const { relativePathOrBasename, last2Parts, baseName } =
|
||||
getUriDescription(filepath, workspaceDirs);
|
||||
|
||||
if (isSecurityConcern(filepath)) {
|
||||
return {
|
||||
description: last2Parts,
|
||||
content:
|
||||
"Content redacted, this file cannot be viewed for security reasons",
|
||||
name: baseName,
|
||||
uri: {
|
||||
type: "file",
|
||||
value: filepath,
|
||||
},
|
||||
};
|
||||
}
|
||||
const content = await ide.readFile(filepath);
|
||||
|
||||
return {
|
||||
description: last2Parts,
|
||||
content: `\`\`\`${relativePathOrBasename}\n${content}\n\`\`\``,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {
|
|||
ContextProviderDescription,
|
||||
ContextProviderExtras,
|
||||
} from "../../index.js";
|
||||
import { isSecurityConcern } from "../../indexing/ignore.js";
|
||||
import { getUriDescription } from "../../util/uri.js";
|
||||
import { BaseContextProvider } from "../index.js";
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ class ProblemsContextProvider extends BaseContextProvider {
|
|||
return {
|
||||
description: "Problems in current file",
|
||||
content: `\`\`\`${relativePathOrBasename}\n${rangeContent}\n\`\`\`\n${problem.message}\n\n`,
|
||||
name: `Warning in ${baseName}`,
|
||||
name: `Warnings in ${baseName}`,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { BaseContextProvider } from "../";
|
||||
import { ContextProviderName } from "../../";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
|
||||
import ClipboardContextProvider from "./ClipboardContextProvider";
|
||||
import CodebaseContextProvider from "./CodebaseContextProvider";
|
||||
|
|
@ -12,6 +11,7 @@ import DebugLocalsProvider from "./DebugLocalsProvider";
|
|||
import DiffContextProvider from "./DiffContextProvider";
|
||||
import DiscordContextProvider from "./DiscordContextProvider";
|
||||
import DocsContextProvider from "./DocsContextProvider";
|
||||
import FileContextProvider from "./FileContextProvider";
|
||||
import FileTreeContextProvider from "./FileTreeContextProvider";
|
||||
import FolderContextProvider from "./FolderContextProvider";
|
||||
import GitCommitContextProvider from "./GitCommitContextProvider";
|
||||
|
|
@ -41,6 +41,7 @@ import WebContextProvider from "./WebContextProvider";
|
|||
* See this issue for details: https://github.com/continuedev/continue/issues/1365
|
||||
*/
|
||||
export const Providers: (typeof BaseContextProvider)[] = [
|
||||
FileContextProvider,
|
||||
DiffContextProvider,
|
||||
FileTreeContextProvider,
|
||||
GitHubIssuesContextProvider,
|
||||
|
|
@ -78,10 +79,5 @@ export function contextProviderClassFromName(
|
|||
): typeof BaseContextProvider | undefined {
|
||||
const provider = Providers.find((cls) => cls.description.title === name);
|
||||
|
||||
void Telemetry.capture("context_provider_load", {
|
||||
providerName: name,
|
||||
found: !!provider, // also capture those which user expected to be present
|
||||
});
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
const nFinal =
|
||||
options?.nFinal ??
|
||||
Math.min(DEFAULT_N_FINAL, contextLength / tokensPerSnippet / 2);
|
||||
const useReranking = !!extras.reranker;
|
||||
const useReranking = options?.useReranking ?? !!extras.reranker;
|
||||
const nRetrieve = useReranking ? options?.nRetrieve || 2 * nFinal : nFinal;
|
||||
|
||||
const branches = (await Promise.race([
|
||||
|
|
|
|||
17
core/core.ts
17
core/core.ts
|
|
@ -10,7 +10,6 @@ import {
|
|||
import { ConfigHandler } from "./config/ConfigHandler";
|
||||
import { SYSTEM_PROMPT_DOT_FILE } from "./config/getWorkspaceContinueRuleDotFiles";
|
||||
import { addModel, deleteModel } from "./config/util";
|
||||
import CurrentFileContextProvider from "./context/providers/CurrentFileContextProvider";
|
||||
import { getAuthUrlForTokenPage } from "./control-plane/auth/index";
|
||||
import { getControlPlaneEnv } from "./control-plane/env";
|
||||
import { DevDataSqliteDb } from "./data/devdataSqlite";
|
||||
|
|
@ -973,6 +972,10 @@ export class Core {
|
|||
on("docs/getDetails", async (msg) => {
|
||||
return await this.docsService.getDetails(msg.data.startUrl);
|
||||
});
|
||||
on("docs/getIndexedPages", async (msg) => {
|
||||
const pages = await this.docsService.getIndexedPages(msg.data.startUrl);
|
||||
return Array.from(pages);
|
||||
});
|
||||
|
||||
on("didChangeSelectedProfile", async (msg) => {
|
||||
if (msg.data.id) {
|
||||
|
|
@ -1287,15 +1290,9 @@ export class Core {
|
|||
throw new Error("No chat model selected");
|
||||
}
|
||||
|
||||
const provider =
|
||||
config.contextProviders?.find(
|
||||
(provider) => provider.description.title === name,
|
||||
) ??
|
||||
[
|
||||
// user doesn't need these in their config.json for the shortcuts to work
|
||||
// option+enter
|
||||
new CurrentFileContextProvider({}),
|
||||
].find((provider) => provider.description.title === name);
|
||||
const provider = config.contextProviders?.find(
|
||||
(provider) => provider.description.title === name,
|
||||
);
|
||||
if (!provider) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ const INFINITE_STREAM_SAFETY = 0.9;
|
|||
const DUD_PROMPT_LOG: PromptLog = {
|
||||
modelTitle: "",
|
||||
modelProvider: "",
|
||||
completionOptions: { model: "" },
|
||||
prompt: "",
|
||||
completion: "",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -426,101 +426,6 @@ const a = 1;`;
|
|||
});
|
||||
});
|
||||
|
||||
describe("jaroWinklerFuzzyMatch strategy", () => {
|
||||
it("should match similar code with variable name differences", () => {
|
||||
const fileContent = `function calculateTotal(items) {
|
||||
let sum = 0;
|
||||
for (const item of items) {
|
||||
sum += item.price;
|
||||
}
|
||||
return sum;
|
||||
}`;
|
||||
const searchContent = `function calculateTotal(products) {
|
||||
let total = 0;
|
||||
for (const product of products) {
|
||||
total += product.price;
|
||||
}
|
||||
return total;
|
||||
}`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.strategyName).toBe("jaroWinklerFuzzyMatch");
|
||||
});
|
||||
|
||||
it("should match code with minor typos", () => {
|
||||
const testCases = [
|
||||
{
|
||||
name: "typo in function name",
|
||||
fileContent: "function getUserName() { return this.name; }",
|
||||
searchContent: "function getUserNaem() { return this.name; }",
|
||||
},
|
||||
{
|
||||
name: "typo in variable",
|
||||
fileContent: "const message = 'Hello World';",
|
||||
searchContent: "const mesage = 'Hello World';",
|
||||
},
|
||||
{
|
||||
name: "missing character",
|
||||
fileContent: "console.log('Debug info');",
|
||||
searchContent: "console.log('Debug nfo');",
|
||||
},
|
||||
];
|
||||
|
||||
testCases.forEach(({ name, fileContent, searchContent }) => {
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.strategyName).toBe("jaroWinklerFuzzyMatch");
|
||||
});
|
||||
});
|
||||
|
||||
it("should not match when similarity is too low", () => {
|
||||
const fileContent = "function add(a, b) { return a + b; }";
|
||||
const searchContent =
|
||||
"class Calculator { multiply(x, y) { return x * y; } }";
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("should handle multiline fuzzy matches", () => {
|
||||
const fileContent = `if (userIsLoggedIn) {
|
||||
showDashboard();
|
||||
loadUserData();
|
||||
}`;
|
||||
const searchContent = `if (isUserLoggedIn) {
|
||||
displayDashboard();
|
||||
fetchUserData();
|
||||
}`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.strategyName).toBe("jaroWinklerFuzzyMatch");
|
||||
});
|
||||
|
||||
it("should verify replacement with fuzzy matches", () => {
|
||||
const fileContent = "const userName = 'John';";
|
||||
const searchContent = "const usrName = 'John';"; // Typo in variable name
|
||||
const replacement = "const userName = 'Jane';";
|
||||
|
||||
const match = findSearchMatch(fileContent, searchContent);
|
||||
expect(match).not.toBeNull();
|
||||
expect(match!.strategyName).toBe("jaroWinklerFuzzyMatch");
|
||||
|
||||
const result = performReplacement(fileContent, match!, replacement);
|
||||
expect(result).toBe(replacement);
|
||||
});
|
||||
|
||||
it("should handle edge case with very short strings", () => {
|
||||
const fileContent = "ab";
|
||||
const searchContent = "ac";
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
// Should not match due to low similarity on short strings
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Empty search content", () => {
|
||||
it("should always return position 0 for empty search", () => {
|
||||
const testCases = [
|
||||
|
|
|
|||
|
|
@ -191,34 +191,6 @@ describe("Empty search content", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("No matches", () => {
|
||||
it("should return null when search content is not found", () => {
|
||||
const fileContent = `function hello() {
|
||||
console.log("world");
|
||||
}`;
|
||||
const searchContent = `function goodbye() {
|
||||
console.log("world");
|
||||
}`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result?.strategyName).toEqual("jaroWinklerFuzzyMatch");
|
||||
});
|
||||
|
||||
it("should return only fuzzy result when trimmed search content is not found", () => {
|
||||
const fileContent = `function hello() {
|
||||
console.log("world");
|
||||
}`;
|
||||
const searchContent = `\n\nfunction goodbye() {
|
||||
console.log("world");
|
||||
}\n\n`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result?.strategyName).toEqual("jaroWinklerFuzzyMatch");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Edge cases", () => {
|
||||
it("should handle empty file with non-empty search", () => {
|
||||
const fileContent = "";
|
||||
|
|
@ -612,157 +584,4 @@ function test() {
|
|||
strategyName: "exactMatch",
|
||||
});
|
||||
});
|
||||
|
||||
describe("Jaro-Winkler fuzzy matching", () => {
|
||||
describe("Basic fuzzy matching", () => {
|
||||
it("should find fuzzy match for similar strings", () => {
|
||||
const fileContent = `function calculateSum(a, b) {
|
||||
return a + b;
|
||||
}`;
|
||||
const searchContent = `function calculateSum(x, y) {
|
||||
return x + y;
|
||||
}`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
});
|
||||
|
||||
it("should find fuzzy match with minor typos", () => {
|
||||
const fileContent = `const message = "Hello World";`;
|
||||
const searchContent = `const mesage = "Hello World";`; // Missing 's' in 'message'
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.startIndex).toBe(0);
|
||||
});
|
||||
|
||||
it("should find fuzzy match with different variable names", () => {
|
||||
const fileContent = `let userAge = 25;
|
||||
let userName = "John";`;
|
||||
const searchContent = `let age = 25;
|
||||
let name = "John";`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
});
|
||||
|
||||
it("should find fuzzy match for similar function signature", () => {
|
||||
const fileContent = `function processUserData(userData) {
|
||||
validateInput(userData);
|
||||
return formatOutput(userData);
|
||||
}`;
|
||||
const searchContent = `function processData(data) {
|
||||
validateInput(data);
|
||||
return formatOutput(data);
|
||||
}`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Multi-line fuzzy matching", () => {
|
||||
it("should find fuzzy match for multi-line blocks", () => {
|
||||
const fileContent = `class Calculator {
|
||||
constructor() {
|
||||
this.result = 0;
|
||||
}
|
||||
|
||||
add(value) {
|
||||
this.result += value;
|
||||
return this;
|
||||
}
|
||||
}`;
|
||||
const searchContent = `class Calculator {
|
||||
constructor() {
|
||||
this.value = 0;
|
||||
}
|
||||
|
||||
add(num) {
|
||||
this.value += num;
|
||||
return this;
|
||||
}
|
||||
}`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
});
|
||||
|
||||
it("should find fuzzy match for partial blocks", () => {
|
||||
const fileContent = `function processData(input) {
|
||||
const validated = validateInput(input);
|
||||
const processed = transformData(validated);
|
||||
const result = formatOutput(processed);
|
||||
return result;
|
||||
}`;
|
||||
const searchContent = `const validated = validateInput(input);
|
||||
const processed = transformData(validated);`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Edge cases with fuzzy matching", () => {
|
||||
it("should handle empty search content with fuzzy matching enabled", () => {
|
||||
const fileContent = `function test() {}`;
|
||||
const searchContent = "";
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).toEqual({
|
||||
startIndex: 0,
|
||||
endIndex: 0,
|
||||
strategyName: "emptySearch",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle empty file content with fuzzy matching enabled", () => {
|
||||
const fileContent = "";
|
||||
const searchContent = "function test() {}";
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("should prefer exact match over fuzzy match", () => {
|
||||
const fileContent = `function test() { return true; }
|
||||
function test() { return false; }`;
|
||||
const searchContent = `function test() { return true; }`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.startIndex).toBe(0);
|
||||
});
|
||||
|
||||
it("should handle very short strings", () => {
|
||||
const fileContent = `a b c`;
|
||||
const searchContent = `a c`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
// Should not match due to low similarity
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("should handle special characters in fuzzy matching", () => {
|
||||
const fileContent = `const regex = /[a-zA-Z]+/g;
|
||||
const symbols = !@#$%^&*();`;
|
||||
const searchContent = `const regex = /[a-zA-Z0-9]+/g;
|
||||
const symbols = !@#$%^&*();`;
|
||||
|
||||
const result = findSearchMatch(fileContent, searchContent);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -144,161 +144,6 @@ function whitespaceIgnoredMatch(
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the Jaro similarity between two strings
|
||||
*/
|
||||
function jaroSimilarity(s1: string, s2: string): number {
|
||||
if (s1 === s2) return 1.0;
|
||||
if (s1.length === 0 || s2.length === 0) return 0.0;
|
||||
|
||||
const matchDistance = Math.floor(Math.max(s1.length, s2.length) / 2) - 1;
|
||||
if (matchDistance < 0) return 0.0;
|
||||
|
||||
const s1Matches = new Array(s1.length).fill(false);
|
||||
const s2Matches = new Array(s2.length).fill(false);
|
||||
|
||||
let matches = 0;
|
||||
let transpositions = 0;
|
||||
|
||||
// Find matches
|
||||
for (let i = 0; i < s1.length; i++) {
|
||||
const start = Math.max(0, i - matchDistance);
|
||||
const end = Math.min(i + matchDistance + 1, s2.length);
|
||||
|
||||
for (let j = start; j < end; j++) {
|
||||
if (s2Matches[j] || s1[i] !== s2[j]) continue;
|
||||
s1Matches[i] = true;
|
||||
s2Matches[j] = true;
|
||||
matches++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matches === 0) return 0.0;
|
||||
|
||||
// Count transpositions
|
||||
let k = 0;
|
||||
for (let i = 0; i < s1.length; i++) {
|
||||
if (!s1Matches[i]) continue;
|
||||
while (!s2Matches[k]) k++;
|
||||
if (s1[i] !== s2[k]) transpositions++;
|
||||
k++;
|
||||
}
|
||||
|
||||
return (
|
||||
(matches / s1.length +
|
||||
matches / s2.length +
|
||||
(matches - transpositions / 2) / matches) /
|
||||
3.0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the Jaro-Winkler similarity between two strings
|
||||
*/
|
||||
function jaroWinklerSimilarity(
|
||||
s1: string,
|
||||
s2: string,
|
||||
prefixScale = 0.1,
|
||||
): number {
|
||||
const jaroSim = jaroSimilarity(s1, s2);
|
||||
|
||||
if (jaroSim < 0.7) return jaroSim;
|
||||
|
||||
// Calculate common prefix length (up to 4 characters)
|
||||
let prefixLength = 0;
|
||||
const maxPrefix = Math.min(4, Math.min(s1.length, s2.length));
|
||||
|
||||
for (let i = 0; i < maxPrefix; i++) {
|
||||
if (s1[i] === s2[i]) {
|
||||
prefixLength++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return jaroSim + prefixLength * prefixScale * (1 - jaroSim);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the best fuzzy match for search content in file content using Jaro-Winkler
|
||||
*/
|
||||
function findFuzzyMatch(
|
||||
fileContent: string,
|
||||
searchContent: string,
|
||||
threshold: number = 0.9,
|
||||
): BasicMatchResult | null {
|
||||
const searchLines = searchContent.split("\n");
|
||||
const fileLines = fileContent.split("\n");
|
||||
|
||||
let bestMatch: BasicMatchResult | null = null;
|
||||
let bestSimilarity = 0;
|
||||
|
||||
// Try matching the search content as a whole block
|
||||
const searchBlock = searchContent.trim();
|
||||
if (searchBlock.length > 5) {
|
||||
// Require minimum length for meaningful matches
|
||||
// Use sliding window approach for multi-line search
|
||||
for (let i = 0; i <= fileLines.length - searchLines.length; i++) {
|
||||
const candidateLines = fileLines.slice(i, i + searchLines.length);
|
||||
const candidateBlock = candidateLines.join("\n").trim();
|
||||
|
||||
if (candidateBlock.length < 5) continue; // Skip very short blocks
|
||||
|
||||
const similarity = jaroWinklerSimilarity(searchBlock, candidateBlock);
|
||||
|
||||
if (similarity >= threshold && similarity > bestSimilarity) {
|
||||
// Calculate character positions
|
||||
const linesBeforeMatch = fileLines.slice(0, i);
|
||||
const startIndex =
|
||||
linesBeforeMatch.join("\n").length +
|
||||
(linesBeforeMatch.length > 0 ? 1 : 0);
|
||||
const endIndex = startIndex + candidateBlock.length;
|
||||
|
||||
bestMatch = {
|
||||
startIndex,
|
||||
endIndex,
|
||||
};
|
||||
bestSimilarity = similarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Also try line-by-line matching for better granularity
|
||||
for (
|
||||
let searchLineIdx = 0;
|
||||
searchLineIdx < searchLines.length;
|
||||
searchLineIdx++
|
||||
) {
|
||||
const searchLine = searchLines[searchLineIdx].trim();
|
||||
if (searchLine.length === 0 || searchLine.length < 3) continue; // Skip very short lines
|
||||
|
||||
for (let fileLineIdx = 0; fileLineIdx < fileLines.length; fileLineIdx++) {
|
||||
const fileLine = fileLines[fileLineIdx].trim();
|
||||
if (fileLine.length === 0 || fileLine.length < 3) continue; // Skip very short lines
|
||||
|
||||
const similarity = jaroWinklerSimilarity(searchLine, fileLine);
|
||||
|
||||
if (similarity >= threshold && similarity > bestSimilarity) {
|
||||
// Calculate character positions for the line
|
||||
const linesBeforeMatch = fileLines.slice(0, fileLineIdx);
|
||||
const startIndex =
|
||||
linesBeforeMatch.join("\n").length +
|
||||
(linesBeforeMatch.length > 0 ? 1 : 0);
|
||||
const endIndex = startIndex + fileLines[fileLineIdx].length;
|
||||
|
||||
bestMatch = {
|
||||
startIndex,
|
||||
endIndex,
|
||||
};
|
||||
bestSimilarity = similarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordered list of matching strategies to try with their names
|
||||
*/
|
||||
|
|
@ -306,7 +151,6 @@ const matchingStrategies: Array<{ strategy: MatchStrategy; name: string }> = [
|
|||
{ strategy: exactMatch, name: "exactMatch" },
|
||||
{ strategy: trimmedMatch, name: "trimmedMatch" },
|
||||
{ strategy: whitespaceIgnoredMatch, name: "whitespaceIgnoredMatch" },
|
||||
{ strategy: findFuzzyMatch, name: "jaroWinklerFuzzyMatch" },
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
8
core/index.d.ts
vendored
8
core/index.d.ts
vendored
|
|
@ -461,7 +461,6 @@ export type FileSymbolMap = Record<string, SymbolWithRange[]>;
|
|||
export interface PromptLog {
|
||||
modelTitle: string;
|
||||
modelProvider: string;
|
||||
completionOptions: CompletionOptions;
|
||||
prompt: string;
|
||||
completion: string;
|
||||
}
|
||||
|
|
@ -671,6 +670,7 @@ export interface LLMOptions {
|
|||
env?: Record<string, string | number | boolean>;
|
||||
|
||||
sourceFile?: string;
|
||||
isFromAutoDetect?: boolean;
|
||||
}
|
||||
|
||||
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
|
||||
|
|
@ -1117,6 +1117,8 @@ export interface ConfigDependentToolParams {
|
|||
rules: RuleWithSource[];
|
||||
enableExperimentalTools: boolean;
|
||||
isSignedIn: boolean;
|
||||
isRemote: boolean;
|
||||
modelName: string | undefined;
|
||||
}
|
||||
|
||||
export type GetTool = (params: ConfigDependentToolParams) => Tool;
|
||||
|
|
@ -1180,6 +1182,7 @@ export interface ModelDescription {
|
|||
configurationStatus?: LLMConfigurationStatuses;
|
||||
|
||||
sourceFile?: string;
|
||||
isFromAutoDetect?: boolean;
|
||||
}
|
||||
|
||||
export interface JSONEmbedOptions {
|
||||
|
|
@ -1348,6 +1351,7 @@ export interface ContinueUIConfig {
|
|||
codeWrap?: boolean;
|
||||
showSessionTabs?: boolean;
|
||||
autoAcceptEditToolDiffs?: boolean;
|
||||
continueAfterToolRejection?: boolean;
|
||||
}
|
||||
|
||||
export interface ContextMenuConfig {
|
||||
|
|
@ -1610,6 +1614,7 @@ export interface JSONModelDescription {
|
|||
aiGatewaySlug?: string;
|
||||
useLegacyCompletionsEndpoint?: boolean;
|
||||
deploymentId?: string;
|
||||
isFromAutoDetect?: boolean;
|
||||
}
|
||||
|
||||
// config.json
|
||||
|
|
@ -1687,6 +1692,7 @@ export interface Config {
|
|||
experimental?: ExperimentalConfig;
|
||||
/** Analytics configuration */
|
||||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
data?: DataDestination[];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ class TestCodebaseIndexer extends CodebaseIndexer {
|
|||
}
|
||||
|
||||
// Add public methods to test private methods
|
||||
public testHasCodebaseContextProvider() {
|
||||
return (this as any).hasCodebaseContextProvider();
|
||||
public testHasIndexingProvider() {
|
||||
return (this as any).hasIndexingContextProvider();
|
||||
}
|
||||
|
||||
public async testHandleConfigUpdate(
|
||||
|
|
@ -203,7 +203,7 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
test("should have indexed all of the files", async () => {
|
||||
const indexed = await getAllIndexedFiles();
|
||||
expect(indexed.length).toBe(4); // Files are indexed twice due to test execution
|
||||
expect(indexed.length).toBe(2);
|
||||
expect(indexed.some((file) => file.endsWith("test.ts"))).toBe(true);
|
||||
expect(indexed.some((file) => file.endsWith("main.py"))).toBe(true);
|
||||
});
|
||||
|
|
@ -227,7 +227,7 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
// Check that the new file was indexed
|
||||
const files = await getAllIndexedFiles();
|
||||
expect(files.length).toBe(5); // Updated to match actual behavior
|
||||
expect(files.length).toBe(3);
|
||||
expect(files.some((file) => file.endsWith("main.rs"))).toBe(true);
|
||||
});
|
||||
|
||||
|
|
@ -241,7 +241,7 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
// Check that the deleted file was removed from the index
|
||||
const files = await getAllIndexedFiles();
|
||||
expect(files.length).toBe(4); // Updated to match actual behavior
|
||||
expect(files.length).toBe(2);
|
||||
expect(files.every((file) => !file.endsWith("main.rs"))).toBe(true);
|
||||
});
|
||||
|
||||
|
|
@ -475,20 +475,14 @@ describe("CodebaseIndexer", () => {
|
|||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe("hasCodebaseContextProvider", () => {
|
||||
describe("hasIndexingProvider", () => {
|
||||
test("should return true when codebase context provider is present", () => {
|
||||
// Set up config with codebase context provider
|
||||
(testIndexer as any).config = {
|
||||
contextProviders: [
|
||||
{
|
||||
description: {
|
||||
title: CodebaseContextProvider.description.title,
|
||||
},
|
||||
},
|
||||
],
|
||||
contextProviders: [new CodebaseContextProvider({})],
|
||||
};
|
||||
|
||||
const result = testIndexer.testHasCodebaseContextProvider();
|
||||
const result = testIndexer.testHasIndexingProvider();
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
|
|
@ -497,7 +491,7 @@ describe("CodebaseIndexer", () => {
|
|||
contextProviders: undefined,
|
||||
};
|
||||
|
||||
const result = testIndexer.testHasCodebaseContextProvider();
|
||||
const result = testIndexer.testHasIndexingProvider();
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
|
|
@ -512,7 +506,7 @@ describe("CodebaseIndexer", () => {
|
|||
],
|
||||
};
|
||||
|
||||
const result = testIndexer.testHasCodebaseContextProvider();
|
||||
const result = testIndexer.testHasIndexingProvider();
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
|
|
@ -521,7 +515,7 @@ describe("CodebaseIndexer", () => {
|
|||
contextProviders: [],
|
||||
};
|
||||
|
||||
const result = testIndexer.testHasCodebaseContextProvider();
|
||||
const result = testIndexer.testHasIndexingProvider();
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
@ -536,9 +530,8 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
await testIndexer.testHandleConfigUpdate(configResult);
|
||||
|
||||
// These get called once on init, so we want them to not get called again
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(1);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(0);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("should return early when newConfig is undefined", async () => {
|
||||
|
|
@ -550,9 +543,8 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
await testIndexer.testHandleConfigUpdate(configResult);
|
||||
|
||||
// These get called once on init, so we want them to not get called again
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(1);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(0);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("should return early when no codebase context provider is present", async () => {
|
||||
|
|
@ -578,21 +570,14 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
await testIndexer.testHandleConfigUpdate(configResult);
|
||||
|
||||
// These get called once on init, so we want them to not get called again
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(1);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(0);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("should return early when no embed model is configured", async () => {
|
||||
const configResult: ConfigResult<ContinueConfig> = {
|
||||
config: {
|
||||
contextProviders: [
|
||||
{
|
||||
description: {
|
||||
title: CodebaseContextProvider.description.title,
|
||||
},
|
||||
},
|
||||
],
|
||||
contextProviders: [new CodebaseContextProvider({})],
|
||||
selectedModelByRole: {
|
||||
embed: undefined,
|
||||
},
|
||||
|
|
@ -603,21 +588,14 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
await testIndexer.testHandleConfigUpdate(configResult);
|
||||
|
||||
// These get called once on init, so we want them to not get called again
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(1);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(0);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("should call refreshCodebaseIndex when all conditions are met", async () => {
|
||||
const configResult: ConfigResult<ContinueConfig> = {
|
||||
config: {
|
||||
contextProviders: [
|
||||
{
|
||||
description: {
|
||||
title: CodebaseContextProvider.description.title,
|
||||
},
|
||||
},
|
||||
],
|
||||
contextProviders: [new CodebaseContextProvider({})],
|
||||
selectedModelByRole: {
|
||||
embed: {
|
||||
model: "test-model",
|
||||
|
|
@ -631,9 +609,8 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
await testIndexer.testHandleConfigUpdate(configResult);
|
||||
|
||||
// These get called once on init, and we want them to get called again
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(2);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(2);
|
||||
expect(mockGetWorkspaceDirs).toHaveBeenCalledTimes(1);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(1);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledWith([
|
||||
"/test/workspace",
|
||||
]);
|
||||
|
|
@ -641,13 +618,7 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
test("should set config property before checking conditions", async () => {
|
||||
const testConfig = {
|
||||
contextProviders: [
|
||||
{
|
||||
description: {
|
||||
title: CodebaseContextProvider.description.title,
|
||||
},
|
||||
},
|
||||
],
|
||||
contextProviders: [new CodebaseContextProvider({})],
|
||||
selectedModelByRole: {
|
||||
embed: {
|
||||
model: "test-model",
|
||||
|
|
@ -667,7 +638,7 @@ describe("CodebaseIndexer", () => {
|
|||
// Verify that the config was set
|
||||
expect((testIndexer as any).config).toBe(testConfig);
|
||||
// These get called once on init, and we want them to get called again
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(2);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("should handle multiple context providers correctly", async () => {
|
||||
|
|
@ -679,11 +650,7 @@ describe("CodebaseIndexer", () => {
|
|||
title: "SomeOtherProvider",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: {
|
||||
title: CodebaseContextProvider.description.title,
|
||||
},
|
||||
},
|
||||
new CodebaseContextProvider({}),
|
||||
{
|
||||
description: {
|
||||
title: "AnotherProvider",
|
||||
|
|
@ -703,8 +670,7 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
await testIndexer.testHandleConfigUpdate(configResult);
|
||||
|
||||
// These get called once on init, and we want them to get called again
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(2);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledTimes(1);
|
||||
expect(mockRefreshCodebaseIndex).toHaveBeenCalledWith([
|
||||
"/test/workspace",
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -13,11 +13,9 @@ import type { IMessenger } from "../protocol/messenger";
|
|||
import { extractMinimalStackTraceInfo } from "../util/extractMinimalStackTraceInfo.js";
|
||||
import { Logger } from "../util/Logger.js";
|
||||
import { getIndexSqlitePath, getLanceDbPath } from "../util/paths.js";
|
||||
import { Telemetry } from "../util/posthog.js";
|
||||
import { findUriInDirs, getUriPathBasename } from "../util/uri.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import CodebaseContextProvider from "../context/providers/CodebaseContextProvider.js";
|
||||
import { ContinueServerClient } from "../continueServer/stubs/client";
|
||||
import { LLMError } from "../llm/index.js";
|
||||
import { getRootCause } from "../util/errors.js";
|
||||
|
|
@ -688,14 +686,6 @@ export class CodebaseIndexer {
|
|||
update.desc,
|
||||
update.debugInfo,
|
||||
);
|
||||
void Telemetry.capture(
|
||||
"indexing_error",
|
||||
{
|
||||
error: update.desc,
|
||||
stack: update.debugInfo,
|
||||
},
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -833,11 +823,9 @@ export class CodebaseIndexer {
|
|||
return this.codebaseIndexingState;
|
||||
}
|
||||
|
||||
private hasCodebaseContextProvider() {
|
||||
private hasIndexingContextProvider() {
|
||||
return !!this.config.contextProviders?.some(
|
||||
(provider) =>
|
||||
provider.description.title ===
|
||||
CodebaseContextProvider.description.title,
|
||||
({ description: { dependsOnIndexing } }) => dependsOnIndexing,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -866,8 +854,8 @@ export class CodebaseIndexer {
|
|||
this.config = newConfig; // IMPORTANT - need to set up top, other methods below use this without passing it in
|
||||
|
||||
// No point in indexing if no codebase context provider
|
||||
const hasCodebaseContextProvider = this.hasCodebaseContextProvider();
|
||||
if (!hasCodebaseContextProvider) {
|
||||
const hasIndexingProviders = this.hasIndexingContextProvider();
|
||||
if (!hasIndexingProviders) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,22 @@ export async function* chunkDocumentWithoutId(
|
|||
return;
|
||||
}
|
||||
const extension = getUriFileExtension(fileUri);
|
||||
if (extension in supportedLanguages) {
|
||||
// Files that should use basicChunker despite having tree-sitter support
|
||||
// These files don't have code structure (classes/functions) that codeChunker expects
|
||||
const NON_CODE_EXTENSIONS = [
|
||||
"css",
|
||||
"html",
|
||||
"htm",
|
||||
"json",
|
||||
"toml",
|
||||
"yaml",
|
||||
"yml",
|
||||
];
|
||||
|
||||
if (
|
||||
extension in supportedLanguages &&
|
||||
!NON_CODE_EXTENSIONS.includes(extension)
|
||||
) {
|
||||
try {
|
||||
for await (const chunk of codeChunker(fileUri, contents, maxChunkSize)) {
|
||||
yield chunk;
|
||||
|
|
|
|||
26
core/indexing/continueignore.ts
Normal file
26
core/indexing/continueignore.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import fs from "fs";
|
||||
import { IDE } from "..";
|
||||
import { getGlobalContinueIgnorePath } from "../util/paths";
|
||||
import { gitIgArrayFromFile } from "./ignore";
|
||||
|
||||
export const getGlobalContinueIgArray = () => {
|
||||
const contents = fs.readFileSync(getGlobalContinueIgnorePath(), "utf8");
|
||||
return gitIgArrayFromFile(contents);
|
||||
};
|
||||
|
||||
export const getWorkspaceContinueIgArray = async (ide: IDE) => {
|
||||
const dirs = await ide.getWorkspaceDirs();
|
||||
return await dirs.reduce(
|
||||
async (accPromise, dir) => {
|
||||
const acc = await accPromise;
|
||||
try {
|
||||
const contents = await ide.readFile(`${dir}/.continueignore`);
|
||||
return [...acc, ...gitIgArrayFromFile(contents)];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
Promise.resolve([] as string[]),
|
||||
);
|
||||
};
|
||||
|
|
@ -858,6 +858,27 @@ export default class DocsService {
|
|||
return docs.map(this.lanceDBRowToChunk);
|
||||
}
|
||||
|
||||
async getIndexedPages(startUrl: string): Promise<Set<string>> {
|
||||
try {
|
||||
const table = await this.getOrCreateLanceTable({
|
||||
initializationVector: [],
|
||||
startUrl,
|
||||
});
|
||||
|
||||
const rows = (await table
|
||||
.filter(`starturl = '${startUrl}'`)
|
||||
.select(["path"]) // Only select path to minimize data transfer
|
||||
.limit(99999999) // Default is 10, we want to show all
|
||||
.execute()) as { path: string }[];
|
||||
|
||||
// Get unique paths (pages)
|
||||
return new Set(rows.map((row) => row.path));
|
||||
} catch (e) {
|
||||
console.warn(`Error getting page list for ${startUrl}:`, e);
|
||||
return new Set();
|
||||
}
|
||||
}
|
||||
|
||||
// SQLITE DB
|
||||
private async getOrCreateSqliteDb() {
|
||||
if (!this.sqliteDb) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,100 @@
|
|||
import fs from "fs";
|
||||
|
||||
import ignore from "ignore";
|
||||
|
||||
import { IDE } from "..";
|
||||
import { getGlobalContinueIgnorePath } from "../util/paths";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
export const DEFAULT_IGNORE_FILETYPES = [
|
||||
// Security-focused ignore patterns - these should always be excluded for security reasons
|
||||
export const DEFAULT_SECURITY_IGNORE_FILETYPES = [
|
||||
// Environment and configuration files with secrets
|
||||
"*.env",
|
||||
"*.env.*",
|
||||
".env*",
|
||||
"config.json",
|
||||
"config.yaml",
|
||||
"config.yml",
|
||||
"settings.json",
|
||||
"appsettings.json",
|
||||
"appsettings.*.json",
|
||||
|
||||
// Certificate and key files
|
||||
"*.key",
|
||||
"*.pem",
|
||||
"*.p12",
|
||||
"*.pfx",
|
||||
"*.crt",
|
||||
"*.cer",
|
||||
"*.jks",
|
||||
"*.keystore",
|
||||
"*.truststore",
|
||||
|
||||
// Database files that may contain sensitive data
|
||||
"*.db",
|
||||
"*.sqlite",
|
||||
"*.sqlite3",
|
||||
"*.mdb",
|
||||
"*.accdb",
|
||||
|
||||
// Credential and secret files
|
||||
"*.secret",
|
||||
"*.secrets",
|
||||
"credentials",
|
||||
"credentials.*",
|
||||
"auth.json",
|
||||
"token",
|
||||
"token.*",
|
||||
"*.token",
|
||||
|
||||
// Backup files that might contain sensitive data
|
||||
"*.bak",
|
||||
"*.backup",
|
||||
"*.old",
|
||||
"*.orig",
|
||||
|
||||
// Docker secrets
|
||||
"docker-compose.override.yml",
|
||||
"docker-compose.override.yaml",
|
||||
|
||||
// SSH and GPG
|
||||
"id_rsa",
|
||||
"id_dsa",
|
||||
"id_ecdsa",
|
||||
"id_ed25519",
|
||||
"*.ppk",
|
||||
"*.gpg",
|
||||
];
|
||||
|
||||
export const DEFAULT_SECURITY_IGNORE_DIRS = [
|
||||
// Environment and configuration directories
|
||||
".env/",
|
||||
"env/",
|
||||
|
||||
// Cloud provider credential directories
|
||||
".aws/",
|
||||
".gcp/",
|
||||
".azure/",
|
||||
".kube/",
|
||||
".docker/",
|
||||
|
||||
// Secret directories
|
||||
"secrets/",
|
||||
".secrets/",
|
||||
"private/",
|
||||
".private/",
|
||||
"certs/",
|
||||
"certificates/",
|
||||
"keys/",
|
||||
".ssh/",
|
||||
".gnupg/",
|
||||
".gpg/",
|
||||
|
||||
// Temporary directories that might contain sensitive data
|
||||
"tmp/secrets/",
|
||||
"temp/secrets/",
|
||||
".tmp/",
|
||||
];
|
||||
|
||||
// Additional non-security patterns for general indexing exclusion
|
||||
export const ADDITIONAL_INDEXING_IGNORE_FILETYPES = [
|
||||
"*.DS_Store",
|
||||
"*-lock.json",
|
||||
"*.lock",
|
||||
|
|
@ -46,8 +135,6 @@ export const DEFAULT_IGNORE_FILETYPES = [
|
|||
"*.mpeg",
|
||||
"*.mov",
|
||||
"*.mp3",
|
||||
"*.mp4",
|
||||
"*.mkv",
|
||||
"*.mkv",
|
||||
"*.webm",
|
||||
"*.jar",
|
||||
|
|
@ -56,20 +143,15 @@ export const DEFAULT_IGNORE_FILETYPES = [
|
|||
"*.pqt",
|
||||
"*.wav",
|
||||
"*.webp",
|
||||
"*.db",
|
||||
"*.sqlite",
|
||||
"*.wasm",
|
||||
"*.plist",
|
||||
"*.profraw",
|
||||
"*.gcda",
|
||||
"*.gcno",
|
||||
"go.sum",
|
||||
"*.env",
|
||||
"*.gitignore",
|
||||
"*.gitkeep",
|
||||
"*.continueignore",
|
||||
"config.json",
|
||||
"config.yaml",
|
||||
"*.csv",
|
||||
"*.uasset",
|
||||
"*.pdb",
|
||||
|
|
@ -78,19 +160,13 @@ export const DEFAULT_IGNORE_FILETYPES = [
|
|||
"*.swp",
|
||||
"*.jsonl",
|
||||
// "*.prompt", // can be incredibly confusing for the LLM to have another set of instructions injected into the prompt
|
||||
// Application specific
|
||||
".continue/",
|
||||
];
|
||||
|
||||
export const defaultIgnoreFile = ignore().add(DEFAULT_IGNORE_FILETYPES);
|
||||
export const DEFAULT_IGNORE_DIRS = [
|
||||
export const ADDITIONAL_INDEXING_IGNORE_DIRS = [
|
||||
".git/",
|
||||
".svn/",
|
||||
".vscode/",
|
||||
".idea/",
|
||||
".vs/",
|
||||
"venv/",
|
||||
".venv/",
|
||||
"env/",
|
||||
".env/",
|
||||
"node_modules/",
|
||||
"dist/",
|
||||
"build/",
|
||||
|
|
@ -100,7 +176,6 @@ export const DEFAULT_IGNORE_DIRS = [
|
|||
"bin/",
|
||||
".pytest_cache/",
|
||||
".vscode-test/",
|
||||
".continue/",
|
||||
"__pycache__/",
|
||||
"site-packages/",
|
||||
".gradle/",
|
||||
|
|
@ -108,42 +183,84 @@ export const DEFAULT_IGNORE_DIRS = [
|
|||
".cache/",
|
||||
"gems/",
|
||||
"vendor/",
|
||||
|
||||
".venv/",
|
||||
"venv/",
|
||||
|
||||
".vscode/",
|
||||
".idea/",
|
||||
".vs/",
|
||||
];
|
||||
|
||||
// Combined patterns: security + additional
|
||||
export const DEFAULT_IGNORE_FILETYPES = [
|
||||
...DEFAULT_SECURITY_IGNORE_FILETYPES,
|
||||
...ADDITIONAL_INDEXING_IGNORE_FILETYPES,
|
||||
];
|
||||
|
||||
export const DEFAULT_IGNORE_DIRS = [
|
||||
...DEFAULT_SECURITY_IGNORE_DIRS,
|
||||
...ADDITIONAL_INDEXING_IGNORE_DIRS,
|
||||
];
|
||||
|
||||
// Create ignore instances
|
||||
export const defaultSecurityIgnoreFile = ignore().add(
|
||||
DEFAULT_SECURITY_IGNORE_FILETYPES,
|
||||
);
|
||||
export const defaultSecurityIgnoreDir = ignore().add(
|
||||
DEFAULT_SECURITY_IGNORE_DIRS,
|
||||
);
|
||||
export const defaultIgnoreFile = ignore().add(DEFAULT_IGNORE_FILETYPES);
|
||||
export const defaultIgnoreDir = ignore().add(DEFAULT_IGNORE_DIRS);
|
||||
|
||||
// String representations
|
||||
export const DEFAULT_SECURITY_IGNORE =
|
||||
DEFAULT_SECURITY_IGNORE_FILETYPES.join("\n") +
|
||||
"\n" +
|
||||
DEFAULT_SECURITY_IGNORE_DIRS.join("\n");
|
||||
|
||||
export const DEFAULT_IGNORE =
|
||||
DEFAULT_IGNORE_FILETYPES.join("\n") + "\n" + DEFAULT_IGNORE_DIRS.join("\n");
|
||||
|
||||
// Combined ignore instances
|
||||
export const defaultFileAndFolderSecurityIgnores = ignore()
|
||||
.add(defaultSecurityIgnoreFile)
|
||||
.add(defaultSecurityIgnoreDir);
|
||||
|
||||
export const defaultIgnoreFileAndDir = ignore()
|
||||
.add(defaultIgnoreFile)
|
||||
.add(defaultIgnoreDir);
|
||||
|
||||
export function isSecurityConcern(filePathOrUri: string) {
|
||||
if (!filePathOrUri) {
|
||||
return false;
|
||||
}
|
||||
let filepath = filePathOrUri;
|
||||
try {
|
||||
filepath = fileURLToPath(filePathOrUri);
|
||||
} catch {}
|
||||
if (path.isAbsolute(filepath)) {
|
||||
const dir = path.dirname(filepath).split(/\/|\\/).at(-1) ?? "";
|
||||
const basename = path.basename(filepath);
|
||||
filepath = `${dir ? dir + "/" : ""}${basename}`;
|
||||
}
|
||||
if (!filepath) {
|
||||
return false;
|
||||
}
|
||||
return defaultFileAndFolderSecurityIgnores.ignores(filepath);
|
||||
}
|
||||
|
||||
export function throwIfFileIsSecurityConcern(filepath: string) {
|
||||
if (isSecurityConcern(filepath)) {
|
||||
throw new Error(
|
||||
`Reading or Editing ${filepath} is not allowed because it is a security concern. Do not attempt to read or edit this file in any way.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function gitIgArrayFromFile(file: string) {
|
||||
return file
|
||||
.split(/\r?\n/) // Split on new line
|
||||
.map((l) => l.trim()) // Remove whitespace
|
||||
.filter((l) => !/^#|^$/.test(l)); // Remove empty lines
|
||||
}
|
||||
|
||||
export const getGlobalContinueIgArray = () => {
|
||||
const contents = fs.readFileSync(getGlobalContinueIgnorePath(), "utf8");
|
||||
return gitIgArrayFromFile(contents);
|
||||
};
|
||||
|
||||
export const getWorkspaceContinueIgArray = async (ide: IDE) => {
|
||||
const dirs = await ide.getWorkspaceDirs();
|
||||
return await dirs.reduce(
|
||||
async (accPromise, dir) => {
|
||||
const acc = await accPromise;
|
||||
try {
|
||||
const contents = await ide.readFile(`${dir}/.continueignore`);
|
||||
return [...acc, ...gitIgArrayFromFile(contents)];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
Promise.resolve([] as string[]),
|
||||
);
|
||||
};
|
||||
|
|
|
|||
257
core/indexing/ignore.vitest.ts
Normal file
257
core/indexing/ignore.vitest.ts
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
DEFAULT_SECURITY_IGNORE_DIRS,
|
||||
DEFAULT_SECURITY_IGNORE_FILETYPES,
|
||||
defaultFileAndFolderSecurityIgnores,
|
||||
isSecurityConcern,
|
||||
} from "./ignore";
|
||||
|
||||
describe("isSecurityConcern", () => {
|
||||
describe("Security file types", () => {
|
||||
it("should detect environment files as security concerns", () => {
|
||||
expect(isSecurityConcern(".env")).toBe(true);
|
||||
expect(isSecurityConcern(".env.local")).toBe(true);
|
||||
expect(isSecurityConcern(".env.production")).toBe(true);
|
||||
expect(isSecurityConcern("config/.env")).toBe(true);
|
||||
expect(isSecurityConcern("/path/to/.env")).toBe(true);
|
||||
expect(isSecurityConcern("file:///path/to/.env")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect configuration files as security concerns", () => {
|
||||
expect(isSecurityConcern("config.json")).toBe(true);
|
||||
expect(isSecurityConcern("config.yaml")).toBe(true);
|
||||
expect(isSecurityConcern("config.yml")).toBe(true);
|
||||
expect(isSecurityConcern("settings.json")).toBe(true);
|
||||
expect(isSecurityConcern("appsettings.json")).toBe(true);
|
||||
expect(isSecurityConcern("appsettings.development.json")).toBe(true);
|
||||
expect(isSecurityConcern("appsettings.production.json")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect certificate and key files as security concerns", () => {
|
||||
expect(isSecurityConcern("private.key")).toBe(true);
|
||||
expect(isSecurityConcern("certificate.pem")).toBe(true);
|
||||
expect(isSecurityConcern("server.crt")).toBe(true);
|
||||
expect(isSecurityConcern("keystore.jks")).toBe(true);
|
||||
expect(isSecurityConcern("ssl/server.key")).toBe(true);
|
||||
expect(isSecurityConcern("/etc/ssl/certs/server.pem")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect database files as security concerns", () => {
|
||||
expect(isSecurityConcern("database.db")).toBe(true);
|
||||
expect(isSecurityConcern("users.sqlite")).toBe(true);
|
||||
expect(isSecurityConcern("data.sqlite3")).toBe(true);
|
||||
expect(isSecurityConcern("app.mdb")).toBe(true);
|
||||
expect(isSecurityConcern("data/users.db")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect credential files as security concerns", () => {
|
||||
expect(isSecurityConcern("app.secret")).toBe(true);
|
||||
expect(isSecurityConcern("api.secrets")).toBe(true);
|
||||
expect(isSecurityConcern("credentials")).toBe(true);
|
||||
expect(isSecurityConcern("credentials.json")).toBe(true);
|
||||
expect(isSecurityConcern("auth.json")).toBe(true);
|
||||
expect(isSecurityConcern("token")).toBe(true);
|
||||
expect(isSecurityConcern("api.token")).toBe(true);
|
||||
expect(isSecurityConcern("access.token")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect backup files as security concerns", () => {
|
||||
expect(isSecurityConcern("database.bak")).toBe(true);
|
||||
expect(isSecurityConcern("config.backup")).toBe(true);
|
||||
expect(isSecurityConcern("settings.old")).toBe(true);
|
||||
expect(isSecurityConcern("app.orig")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect Docker override files as security concerns", () => {
|
||||
expect(isSecurityConcern("docker-compose.override.yml")).toBe(true);
|
||||
expect(isSecurityConcern("docker-compose.override.yaml")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect SSH and GPG files as security concerns", () => {
|
||||
expect(isSecurityConcern("id_rsa")).toBe(true);
|
||||
expect(isSecurityConcern("id_dsa")).toBe(true);
|
||||
expect(isSecurityConcern("id_ecdsa")).toBe(true);
|
||||
expect(isSecurityConcern("id_ed25519")).toBe(true);
|
||||
expect(isSecurityConcern("private.ppk")).toBe(true);
|
||||
expect(isSecurityConcern("secret.gpg")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Security directories", () => {
|
||||
it("should detect environment directories as security concerns", () => {
|
||||
expect(isSecurityConcern(".env/")).toBe(true);
|
||||
expect(isSecurityConcern("env/")).toBe(true);
|
||||
expect(isSecurityConcern(".env/config")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect cloud provider directories as security concerns", () => {
|
||||
expect(isSecurityConcern(".aws/")).toBe(true);
|
||||
expect(isSecurityConcern(".gcp/")).toBe(true);
|
||||
expect(isSecurityConcern(".azure/")).toBe(true);
|
||||
expect(isSecurityConcern(".kube/")).toBe(true);
|
||||
expect(isSecurityConcern(".docker/")).toBe(true);
|
||||
expect(isSecurityConcern(".aws/credentials")).toBe(true);
|
||||
expect(isSecurityConcern(".kube/config")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect secret directories as security concerns", () => {
|
||||
expect(isSecurityConcern("secrets/")).toBe(true);
|
||||
expect(isSecurityConcern(".secrets/")).toBe(true);
|
||||
expect(isSecurityConcern("private/")).toBe(true);
|
||||
expect(isSecurityConcern(".private/")).toBe(true);
|
||||
expect(isSecurityConcern("certs/")).toBe(true);
|
||||
expect(isSecurityConcern("certificates/")).toBe(true);
|
||||
expect(isSecurityConcern("keys/")).toBe(true);
|
||||
expect(isSecurityConcern(".ssh/")).toBe(true);
|
||||
expect(isSecurityConcern(".gnupg/")).toBe(true);
|
||||
expect(isSecurityConcern(".gpg/")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect continue directory as security concern", () => {
|
||||
expect(isSecurityConcern(".continue/config.json")).toBe(true);
|
||||
});
|
||||
|
||||
it("should detect temporary secret directories as security concerns", () => {
|
||||
expect(isSecurityConcern("tmp/secrets/")).toBe(true);
|
||||
expect(isSecurityConcern("temp/secrets/")).toBe(true);
|
||||
expect(isSecurityConcern(".tmp/")).toBe(true);
|
||||
expect(isSecurityConcern("tmp/secrets/api.key")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Path variations", () => {
|
||||
it("should handle absolute paths", () => {
|
||||
expect(isSecurityConcern("/home/user/.env")).toBe(true);
|
||||
expect(isSecurityConcern("/var/www/.secrets/")).toBe(true);
|
||||
expect(isSecurityConcern("/etc/ssl/private.key")).toBe(true);
|
||||
});
|
||||
|
||||
it("should handle URI schemes", () => {
|
||||
expect(isSecurityConcern("file:///home/user/.env")).toBe(true);
|
||||
expect(isSecurityConcern("file:///var/secrets/api.key")).toBe(true);
|
||||
});
|
||||
|
||||
it("should handle nested paths", () => {
|
||||
expect(isSecurityConcern("project/config/.env")).toBe(true);
|
||||
expect(isSecurityConcern("src/main/resources/application.secret")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(isSecurityConcern("backend/certs/server.key")).toBe(true);
|
||||
});
|
||||
|
||||
// it("should handle Windows-style paths", () => {
|
||||
// expect(isSecurityConcern("C:\\Users\\user\\.env")).toBe(true);
|
||||
// expect(isSecurityConcern("D:\\projects\\app\\secrets\\")).toBe(true);
|
||||
// });
|
||||
});
|
||||
|
||||
describe("Non-security files", () => {
|
||||
it("should not flag regular source code files", () => {
|
||||
expect(isSecurityConcern("src/main.js")).toBe(false);
|
||||
expect(isSecurityConcern("components/App.tsx")).toBe(false);
|
||||
expect(isSecurityConcern("utils/helper.py")).toBe(false);
|
||||
expect(isSecurityConcern("models/User.java")).toBe(false);
|
||||
expect(isSecurityConcern("styles/main.css")).toBe(false);
|
||||
});
|
||||
|
||||
it("should not flag regular configuration files", () => {
|
||||
expect(isSecurityConcern("package.json")).toBe(false);
|
||||
expect(isSecurityConcern("tsconfig.json")).toBe(false);
|
||||
expect(isSecurityConcern("webpack.config.js")).toBe(false);
|
||||
expect(isSecurityConcern("babel.config.js")).toBe(false);
|
||||
expect(isSecurityConcern("jest.config.js")).toBe(false);
|
||||
});
|
||||
|
||||
it("should not flag documentation files", () => {
|
||||
expect(isSecurityConcern("README.md")).toBe(false);
|
||||
expect(isSecurityConcern("CHANGELOG.md")).toBe(false);
|
||||
expect(isSecurityConcern("docs/api.md")).toBe(false);
|
||||
expect(isSecurityConcern("LICENSE")).toBe(false);
|
||||
});
|
||||
|
||||
it("should not flag regular directories", () => {
|
||||
expect(isSecurityConcern("src/")).toBe(false);
|
||||
expect(isSecurityConcern("components/")).toBe(false);
|
||||
expect(isSecurityConcern("utils/")).toBe(false);
|
||||
expect(isSecurityConcern("tests/")).toBe(false);
|
||||
expect(isSecurityConcern("docs/")).toBe(false);
|
||||
});
|
||||
|
||||
it("should not flag files with similar names but different extensions", () => {
|
||||
expect(isSecurityConcern("environment.js")).toBe(false);
|
||||
expect(isSecurityConcern("config-template.json")).toBe(false);
|
||||
expect(isSecurityConcern("secret-utils.js")).toBe(false);
|
||||
expect(isSecurityConcern("token-validator.ts")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Edge cases", () => {
|
||||
it("should handle empty strings", () => {
|
||||
expect(isSecurityConcern("")).toBe(false);
|
||||
});
|
||||
|
||||
it("should handle paths with only separators", () => {
|
||||
expect(isSecurityConcern("/")).toBe(false);
|
||||
});
|
||||
|
||||
it("should handle paths with multiple extensions", () => {
|
||||
expect(isSecurityConcern("backup.env.old")).toBe(true); // matches *.old
|
||||
expect(isSecurityConcern("config.json.bak")).toBe(true); // matches *.bak
|
||||
expect(isSecurityConcern("server.key.backup")).toBe(true); // matches *.backup
|
||||
});
|
||||
|
||||
it("should handle files in root vs subdirectories", () => {
|
||||
expect(isSecurityConcern(".env")).toBe(true);
|
||||
expect(isSecurityConcern("project/.env")).toBe(true);
|
||||
expect(isSecurityConcern("deeply/nested/path/.env")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Pattern matching consistency", () => {
|
||||
it("should match all defined security file patterns", () => {
|
||||
// Test a sample from each category to ensure patterns work
|
||||
DEFAULT_SECURITY_IGNORE_FILETYPES.forEach((pattern) => {
|
||||
// Create a test file name that should match the pattern
|
||||
let testFile: string;
|
||||
if (pattern.startsWith("*.")) {
|
||||
testFile = `test${pattern.substring(1)}`;
|
||||
} else if (pattern.includes("*")) {
|
||||
testFile = pattern.replace("*", "test");
|
||||
} else {
|
||||
testFile = pattern;
|
||||
}
|
||||
|
||||
expect(isSecurityConcern(testFile)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("should match all defined security directory patterns", () => {
|
||||
DEFAULT_SECURITY_IGNORE_DIRS.forEach((pattern) => {
|
||||
// Test the directory pattern directly
|
||||
expect(isSecurityConcern(pattern)).toBe(true);
|
||||
|
||||
// Test a file inside the directory
|
||||
const fileInDir = `${pattern}testfile.txt`;
|
||||
expect(isSecurityConcern(fileInDir)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Integration with ignore library", () => {
|
||||
it("should use the same ignore instance as defaultFileAndFolderSecurityIgnores", () => {
|
||||
// Test that our function uses the same logic as the exported ignore instance
|
||||
const testFiles = [
|
||||
".env",
|
||||
"secrets/api.key",
|
||||
".aws/credentials",
|
||||
"regular-file.js",
|
||||
];
|
||||
|
||||
testFiles.forEach((file) => {
|
||||
const functionResult = isSecurityConcern(file);
|
||||
const ignoreResult = defaultFileAndFolderSecurityIgnores.ignores(file);
|
||||
expect(functionResult).toBe(ignoreResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import ignore from "ignore";
|
||||
import type { FileType, IDE } from "../";
|
||||
import { findUriInDirs, getUriPathBasename } from "../util/uri";
|
||||
import { defaultIgnoreFileAndDir, getGlobalContinueIgArray } from "./ignore";
|
||||
import { getGlobalContinueIgArray } from "./continueignore";
|
||||
import { defaultIgnoreFileAndDir } from "./ignore";
|
||||
import { getIgnoreContext } from "./walkDir";
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -3,11 +3,8 @@ import ignore, { Ignore } from "ignore";
|
|||
import type { FileType, IDE } from "..";
|
||||
|
||||
import { joinPathsToUri } from "../util/uri";
|
||||
import {
|
||||
defaultIgnoreFileAndDir,
|
||||
getGlobalContinueIgArray,
|
||||
gitIgArrayFromFile,
|
||||
} from "./ignore";
|
||||
import { getGlobalContinueIgArray } from "./continueignore";
|
||||
import { defaultIgnoreFileAndDir, gitIgArrayFromFile } from "./ignore";
|
||||
|
||||
export interface WalkerOptions {
|
||||
include?: "dirs" | "files" | "both";
|
||||
|
|
|
|||
|
|
@ -178,7 +178,6 @@ function isProviderHandlesTemplatingOrNoTemplateTypeRequired(
|
|||
// update core/nextEdit/templating/NextEditPromptEngine.ts as well.
|
||||
const MODEL_SUPPORTS_NEXT_EDIT: string[] = [
|
||||
NEXT_EDIT_MODELS.MERCURY_CODER,
|
||||
NEXT_EDIT_MODELS.MERCURY_CODER_NEXTEDIT,
|
||||
NEXT_EDIT_MODELS.INSTINCT,
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ describe("modelSupportsNextEdit", () => {
|
|||
expect(
|
||||
modelSupportsNextEdit(
|
||||
{ nextEdit: false },
|
||||
"mercury-coder-nextedit",
|
||||
"mercury-coder",
|
||||
"Mercury Coder",
|
||||
),
|
||||
).toBe(false);
|
||||
|
|
@ -231,7 +231,7 @@ describe("modelSupportsNextEdit", () => {
|
|||
expect(
|
||||
modelSupportsNextEdit(
|
||||
{ nextEdit: false },
|
||||
"mercury-coder-nextedit",
|
||||
"mercury-coder",
|
||||
"Mercury Coder",
|
||||
),
|
||||
).toBe(false);
|
||||
|
|
@ -239,10 +239,10 @@ describe("modelSupportsNextEdit", () => {
|
|||
});
|
||||
|
||||
describe("when capabilities.nextEdit is undefined", () => {
|
||||
it("should return true for mercury-coder-nextedit model (case insensitive)", () => {
|
||||
expect(
|
||||
modelSupportsNextEdit(undefined, "Mercury-Coder-Nextedit", undefined),
|
||||
).toBe(true);
|
||||
it("should return true for mercury-coder model (case insensitive)", () => {
|
||||
expect(modelSupportsNextEdit(undefined, "Mercury-Coder", undefined)).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("should return true for instinct", () => {
|
||||
|
|
@ -255,7 +255,7 @@ describe("modelSupportsNextEdit", () => {
|
|||
expect(
|
||||
modelSupportsNextEdit(
|
||||
undefined,
|
||||
"provider/mercury-coder-nextedit-v2",
|
||||
"provider/mercury-coder-v2",
|
||||
undefined,
|
||||
),
|
||||
).toBe(true);
|
||||
|
|
@ -266,7 +266,7 @@ describe("modelSupportsNextEdit", () => {
|
|||
modelSupportsNextEdit(
|
||||
undefined,
|
||||
"some-model",
|
||||
"This is mercury-coder-nextedit model",
|
||||
"This is mercury-coder model",
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
|
@ -312,14 +312,14 @@ describe("modelSupportsNextEdit", () => {
|
|||
});
|
||||
|
||||
it("should handle undefined title gracefully", () => {
|
||||
expect(
|
||||
modelSupportsNextEdit(undefined, "mercury-coder-nextedit", undefined),
|
||||
).toBe(true);
|
||||
expect(modelSupportsNextEdit(undefined, "mercury-coder", undefined)).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("should handle case sensitivity correctly", () => {
|
||||
expect(
|
||||
modelSupportsNextEdit(undefined, "MERCURY-CODER-NEXTEDIT", "instinct"),
|
||||
modelSupportsNextEdit(undefined, "MERCURY-CODER", "instinct"),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ export enum LLMConfigurationStatuses {
|
|||
|
||||
export enum NEXT_EDIT_MODELS {
|
||||
MERCURY_CODER = "mercury-coder",
|
||||
MERCURY_CODER_NEXTEDIT = "mercury-coder-nextedit",
|
||||
INSTINCT = "instinct",
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ export const EDIT_CODE_INSTRUCTIONS = `\
|
|||
of changes unless the user specifically asks for code only.
|
||||
`;
|
||||
|
||||
const BRIEF_LAZY_INSTRUCTIONS = `For larger codeblocks (>20 lines), use brief language-appropriate placeholders for unmodified sections, e.g. '// ... existing code ...'`;
|
||||
|
||||
export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\
|
||||
<important_rules>
|
||||
You are in chat mode.
|
||||
|
|
@ -64,6 +66,11 @@ export const DEFAULT_AGENT_SYSTEM_MESSAGE = `\
|
|||
If you need to use multiple tools, you can call multiple read only tools simultaneously.
|
||||
|
||||
${CODEBLOCK_FORMATTING_INSTRUCTIONS}
|
||||
|
||||
${BRIEF_LAZY_INSTRUCTIONS}
|
||||
|
||||
However, only output codeblocks for suggestion and demonstration purposes, for example, when enumerating multiple hypothetical options. For implementing changes, use the edit tools.
|
||||
|
||||
</important_rules>`;
|
||||
|
||||
// The note about read-only tools is for MCP servers
|
||||
|
|
@ -75,7 +82,10 @@ export const DEFAULT_PLAN_SYSTEM_MESSAGE = `\
|
|||
If the user wants to make changes, offer that they can switch to Agent mode to give you access to write tools to make the suggested updates.
|
||||
|
||||
${CODEBLOCK_FORMATTING_INSTRUCTIONS}
|
||||
${EDIT_CODE_INSTRUCTIONS}
|
||||
|
||||
${BRIEF_LAZY_INSTRUCTIONS}
|
||||
|
||||
However, only output codeblocks for suggestion and planning purposes. When ready to implement changes, request to switch to Agent mode.
|
||||
|
||||
In plan mode, only write code when directly suggesting changes. Prioritize understanding and developing a plan.
|
||||
</important_rules>`;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import {
|
|||
import Handlebars from "handlebars";
|
||||
|
||||
import { DevDataSqliteDb } from "../data/devdataSqlite.js";
|
||||
import { Logger } from "../util/Logger.js";
|
||||
import { DataLogger } from "../data/log.js";
|
||||
import {
|
||||
CacheBehavior,
|
||||
|
|
@ -31,10 +30,11 @@ import {
|
|||
TemplateType,
|
||||
Usage,
|
||||
} from "../index.js";
|
||||
import { Logger } from "../util/Logger.js";
|
||||
import mergeJson from "../util/merge.js";
|
||||
import { renderChatMessage } from "../util/messageContent.js";
|
||||
import { isOllamaInstalled } from "../util/ollamaHelper.js";
|
||||
import { Telemetry } from "../util/posthog.js";
|
||||
import { TokensBatchingService } from "../util/TokensBatchingService.js";
|
||||
import { withExponentialBackoff } from "../util/withExponentialBackoff.js";
|
||||
|
||||
import {
|
||||
|
|
@ -191,6 +191,8 @@ export abstract class BaseLLM implements ILLM {
|
|||
//URI to local block defining this LLM
|
||||
sourceFile?: string;
|
||||
|
||||
isFromAutoDetect?: boolean;
|
||||
|
||||
private _llmOptions: LLMOptions;
|
||||
|
||||
protected openaiAdapter?: BaseLlmApi;
|
||||
|
|
@ -294,6 +296,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
|
||||
this.autocompleteOptions = options.autocompleteOptions;
|
||||
this.sourceFile = options.sourceFile;
|
||||
this.isFromAutoDetect = options.isFromAutoDetect;
|
||||
}
|
||||
|
||||
get contextLength() {
|
||||
|
|
@ -343,15 +346,11 @@ export abstract class BaseLLM implements ILLM {
|
|||
let generatedTokens = this.countTokens(completion);
|
||||
let thinkingTokens = thinking ? this.countTokens(thinking) : 0;
|
||||
|
||||
void Telemetry.capture(
|
||||
"tokens_generated",
|
||||
{
|
||||
model: model,
|
||||
provider: this.providerName,
|
||||
promptTokens: promptTokens,
|
||||
generatedTokens: generatedTokens,
|
||||
},
|
||||
true,
|
||||
TokensBatchingService.getInstance().addTokens(
|
||||
model,
|
||||
this.providerName,
|
||||
promptTokens,
|
||||
generatedTokens,
|
||||
);
|
||||
|
||||
void DevDataSqliteDb.logTokensGenerated(
|
||||
|
|
@ -1143,7 +1142,6 @@ export abstract class BaseLLM implements ILLM {
|
|||
modelProvider: this.underlyingProviderName,
|
||||
prompt,
|
||||
completion,
|
||||
completionOptions,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ async function dudLLMCall(llm: ILLM, messages: ChatMessage[]) {
|
|||
await gen.next();
|
||||
await gen.return({
|
||||
completion: "",
|
||||
completionOptions: {
|
||||
model: "",
|
||||
},
|
||||
modelTitle: "",
|
||||
modelProvider: "",
|
||||
prompt: "",
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ function testLLM(
|
|||
description: "Say Hello",
|
||||
parameters: {
|
||||
type: "object",
|
||||
required: ["name"],
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
|
|
@ -165,7 +166,7 @@ function testLLM(
|
|||
},
|
||||
)) {
|
||||
const typedChunk = chunk as AssistantChatMessage;
|
||||
if (!typedChunk.toolCalls) {
|
||||
if (!typedChunk.toolCalls || typedChunk.toolCalls.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const toolCall = typedChunk.toolCalls[0];
|
||||
|
|
@ -182,6 +183,15 @@ function testLLM(
|
|||
}
|
||||
}
|
||||
|
||||
// For Mistral, if no tool calls were received, skip the test
|
||||
// as it may not support forced tool use
|
||||
if (args === "" && llm.constructor.name === "Mistral") {
|
||||
console.log(
|
||||
"Mistral did not return tool calls, skipping assertion",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const parsedArgs = JSON.parse(args);
|
||||
expect(parsedArgs.name).toBe("Nate");
|
||||
}),
|
||||
|
|
@ -203,7 +213,7 @@ describe("LLM", () => {
|
|||
|
||||
testLLM(
|
||||
new Anthropic({
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
model: "claude-sonnet-4-0",
|
||||
apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
}),
|
||||
{ skip: false, testToolCall: true },
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelInstaller,
|
||||
ThinkingChatMessage,
|
||||
} from "../../index.js";
|
||||
import { renderChatMessage } from "../../util/messageContent.js";
|
||||
import { getRemoteModelInfo } from "../../util/ollamaHelper.js";
|
||||
|
|
@ -18,6 +19,7 @@ type OllamaChatMessage = {
|
|||
role: ChatMessageRole;
|
||||
content: string;
|
||||
images?: string[] | null;
|
||||
thinking?: string;
|
||||
tool_calls?: {
|
||||
function: {
|
||||
name: string;
|
||||
|
|
@ -148,7 +150,7 @@ class Ollama extends BaseLLM implements ModelInstaller {
|
|||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
|
||||
if (options.model === "AUTODETECT") {
|
||||
if (options.isFromAutoDetect) {
|
||||
return;
|
||||
}
|
||||
const headers: Record<string, string> = {
|
||||
|
|
@ -430,6 +432,13 @@ class Ollama extends BaseLLM implements ModelInstaller {
|
|||
);
|
||||
}
|
||||
if (res.message.role === "assistant") {
|
||||
if (res.message.thinking) {
|
||||
const thinkingMessage: ThinkingChatMessage = {
|
||||
role: "thinking",
|
||||
content: res.message.thinking,
|
||||
};
|
||||
return thinkingMessage;
|
||||
}
|
||||
const chatMessage: ChatMessage = {
|
||||
role: "assistant",
|
||||
content: res.message.content,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Vllm extends OpenAI {
|
|||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
|
||||
if (options.model === "AUTODETECT") {
|
||||
if (options.isFromAutoDetect) {
|
||||
this._setupCompletionOptions();
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ class Vllm extends OpenAI {
|
|||
// vLLM uses 'results' array instead of 'data'
|
||||
if (results.results && Array.isArray(results.results)) {
|
||||
const sortedResults = results.results.sort((a, b) => a.index - b.index);
|
||||
return sortedResults.map((result) => result.index);
|
||||
return sortedResults.map((result) => result.relevance_score);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
|
|
|
|||
|
|
@ -101,15 +101,17 @@ export function toChatBody(
|
|||
};
|
||||
|
||||
if (options.tools?.length) {
|
||||
params.tools = options.tools.map((tool) => ({
|
||||
type: tool.type,
|
||||
function: {
|
||||
name: tool.function.name,
|
||||
description: tool.function.description,
|
||||
parameters: tool.function.parameters,
|
||||
strict: tool.function.strict,
|
||||
},
|
||||
}));
|
||||
params.tools = options.tools
|
||||
.filter((tool) => !tool.type || tool.type === "function")
|
||||
.map((tool) => ({
|
||||
type: tool.type,
|
||||
function: {
|
||||
name: tool.function.name,
|
||||
description: tool.function.description,
|
||||
parameters: tool.function.parameters,
|
||||
strict: tool.function.strict,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
return params;
|
||||
|
|
@ -158,7 +160,16 @@ export function fromChatResponse(response: ChatCompletion): ChatMessage {
|
|||
return {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
toolCalls: message.tool_calls,
|
||||
toolCalls: message.tool_calls
|
||||
?.filter((tc) => !tc.type || tc.type === "function")
|
||||
.map((tc) => ({
|
||||
id: tc.id,
|
||||
type: "function" as const,
|
||||
function: {
|
||||
name: (tc as any).function?.name,
|
||||
arguments: (tc as any).function?.arguments,
|
||||
},
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -179,18 +190,24 @@ export function fromChatCompletionChunk(
|
|||
content: delta.content,
|
||||
};
|
||||
} else if (delta?.tool_calls) {
|
||||
return {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
toolCalls: delta?.tool_calls.map((tool_call) => ({
|
||||
const toolCalls = delta?.tool_calls
|
||||
.filter((tool_call) => !tool_call.type || tool_call.type === "function")
|
||||
.map((tool_call) => ({
|
||||
id: tool_call.id,
|
||||
type: tool_call.type,
|
||||
type: "function" as const,
|
||||
function: {
|
||||
name: tool_call.function?.name,
|
||||
arguments: tool_call.function?.arguments,
|
||||
name: (tool_call as any).function?.name,
|
||||
arguments: (tool_call as any).function?.arguments,
|
||||
},
|
||||
})),
|
||||
};
|
||||
}));
|
||||
|
||||
if (toolCalls.length > 0) {
|
||||
return {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
toolCalls,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
|
|
|||
|
|
@ -280,6 +280,34 @@ describe("PROVIDER_TOOL_SUPPORT", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("novita", () => {
|
||||
const supportsFn = PROVIDER_TOOL_SUPPORT["novita"];
|
||||
|
||||
it("should return true for exact match models", () => {
|
||||
expect(supportsFn("deepseek/deepseek-r1-0528")).toBe(true);
|
||||
expect(supportsFn("deepseek/deepseek-r1-turbo")).toBe(true);
|
||||
expect(supportsFn("deepseek/deepseek-v3-0324")).toBe(true);
|
||||
expect(supportsFn("deepseek/deepseek-v3-turbo")).toBe(true);
|
||||
expect(supportsFn("meta-llama/llama-3.3-70b-instruct")).toBe(true);
|
||||
expect(supportsFn("qwen/qwen-2.5-72b-instruct")).toBe(true);
|
||||
expect(supportsFn("zai-org/glm-4.5")).toBe(true);
|
||||
expect(supportsFn("moonshotai/kimi-k2-instruct")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for prefix match models", () => {
|
||||
expect(supportsFn("qwen/qwen3-235b-a22b-instruct-2507")).toBe(true);
|
||||
expect(supportsFn("openai/gpt-oss-20b")).toBe(true);
|
||||
expect(supportsFn("openai/gpt-oss-120b")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false for unsupported models", () => {
|
||||
expect(supportsFn("deepseek/deepseek-chat")).toBe(false);
|
||||
expect(supportsFn("meta-llama/llama-2-7b")).toBe(false);
|
||||
expect(supportsFn("qwen/qwen-2.0-7b")).toBe(false);
|
||||
expect(supportsFn("openai/gpt-4")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("openrouter", () => {
|
||||
const supportsFn = PROVIDER_TOOL_SUPPORT["openrouter"];
|
||||
|
||||
|
|
@ -297,6 +325,7 @@ describe("PROVIDER_TOOL_SUPPORT", () => {
|
|||
expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false);
|
||||
expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBe(false);
|
||||
expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBe(false);
|
||||
expect(PROVIDER_TOOL_SUPPORT["novita"]("")).toBe(false);
|
||||
});
|
||||
|
||||
it("should handle non-existent provider", () => {
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
|
|||
"nova-pro",
|
||||
"nova-micro",
|
||||
"nova-premier",
|
||||
"gpt-oss",
|
||||
].some((part) => model.toLowerCase().includes(part))
|
||||
) {
|
||||
return true;
|
||||
|
|
@ -302,6 +303,7 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
|
|||
"meta-llama/llama-3-70b-instruct",
|
||||
"arcee-ai/caller-large",
|
||||
"nousresearch/hermes-3-llama-3.1-70b",
|
||||
"moonshotai/kimi-k2",
|
||||
];
|
||||
for (const model of specificModels) {
|
||||
if (model.toLowerCase() === model) {
|
||||
|
|
@ -332,6 +334,36 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
|
|||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
novita: (model) => {
|
||||
const lower = model.toLowerCase();
|
||||
|
||||
// Exact match models
|
||||
const exactMatches = [
|
||||
"deepseek/deepseek-r1-0528",
|
||||
"deepseek/deepseek-r1-turbo",
|
||||
"deepseek/deepseek-v3-0324",
|
||||
"deepseek/deepseek-v3-turbo",
|
||||
"meta-llama/llama-3.3-70b-instruct",
|
||||
"qwen/qwen-2.5-72b-instruct",
|
||||
"zai-org/glm-4.5",
|
||||
"moonshotai/kimi-k2-instruct",
|
||||
];
|
||||
|
||||
if (exactMatches.includes(lower)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Prefix match models
|
||||
const prefixMatches = ["qwen/qwen3", "openai/gpt-oss"];
|
||||
|
||||
for (const prefix of prefixMatches) {
|
||||
if (lower.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
|
@ -343,6 +375,7 @@ export function isRecommendedAgentModel(modelName: string): boolean {
|
|||
[/deepseek/, /r1|reasoner/],
|
||||
[/gemini/, /2\.5/, /pro/],
|
||||
[/gpt/, /4/],
|
||||
[/gpt-5/],
|
||||
[/claude/, /sonnet/, /3\.5|3\.7|3-5|3-7|-4/],
|
||||
[/claude/, /opus/, /-4/],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -11,6 +11,16 @@ export class NextEditLoggingService {
|
|||
private _abortControllers = new Map<string, AbortController>();
|
||||
private _logRejectionTimeouts = new Map<string, NodeJS.Timeout>();
|
||||
private _outcomes = new Map<string, NextEditOutcome>();
|
||||
// Track minimal data for completions that get aborted before we have full outcome.
|
||||
private _pendingCompletions = new Map<
|
||||
string,
|
||||
{
|
||||
startTime: number;
|
||||
modelName?: string;
|
||||
modelProvider?: string;
|
||||
filepath?: string;
|
||||
}
|
||||
>();
|
||||
_lastDisplayedCompletion: { id: string; displayedAt: number } | undefined =
|
||||
undefined;
|
||||
|
||||
|
|
@ -26,21 +36,54 @@ export class NextEditLoggingService {
|
|||
public createAbortController(completionId: string): AbortController {
|
||||
const abortController = new AbortController();
|
||||
this._abortControllers.set(completionId, abortController);
|
||||
this.trackPendingCompletion(completionId);
|
||||
return abortController;
|
||||
}
|
||||
|
||||
public deleteAbortController(completionId: string) {
|
||||
this._abortControllers.delete(completionId);
|
||||
this._pendingCompletions.delete(completionId);
|
||||
}
|
||||
|
||||
// Keep track of a new completion request.
|
||||
public trackPendingCompletion(completionId: string) {
|
||||
this._pendingCompletions.set(completionId, {
|
||||
startTime: Date.now(),
|
||||
});
|
||||
}
|
||||
|
||||
// Update pending completion info as it becomes available.
|
||||
public updatePendingCompletion(
|
||||
completionId: string,
|
||||
data: {
|
||||
modelName?: string;
|
||||
modelProvider?: string;
|
||||
filepath?: string;
|
||||
},
|
||||
) {
|
||||
const pending = this._pendingCompletions.get(completionId);
|
||||
if (pending) {
|
||||
this._pendingCompletions.set(completionId, { ...pending, ...data });
|
||||
} else {
|
||||
// If we haven't tracked it yet, create new entry with provided data.
|
||||
this._pendingCompletions.set(completionId, {
|
||||
startTime: Date.now(),
|
||||
...data,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public cancel() {
|
||||
this._abortControllers.forEach((abortController, id) => {
|
||||
this._abortControllers.forEach((abortController, completionId) => {
|
||||
this.handleAbort(completionId);
|
||||
abortController.abort();
|
||||
});
|
||||
this._abortControllers.clear();
|
||||
}
|
||||
|
||||
public accept(completionId: string): NextEditOutcome | undefined {
|
||||
this._pendingCompletions.delete(completionId);
|
||||
|
||||
if (this._logRejectionTimeouts.has(completionId)) {
|
||||
clearTimeout(this._logRejectionTimeouts.get(completionId));
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
|
|
@ -48,6 +91,7 @@ export class NextEditLoggingService {
|
|||
if (this._outcomes.has(completionId)) {
|
||||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = true;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._outcomes.delete(completionId);
|
||||
return outcome;
|
||||
|
|
@ -55,6 +99,8 @@ export class NextEditLoggingService {
|
|||
}
|
||||
|
||||
public reject(completionId: string): NextEditOutcome | undefined {
|
||||
this._pendingCompletions.delete(completionId);
|
||||
|
||||
if (this._logRejectionTimeouts.has(completionId)) {
|
||||
clearTimeout(this._logRejectionTimeouts.get(completionId));
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
|
|
@ -63,6 +109,7 @@ export class NextEditLoggingService {
|
|||
if (this._outcomes.has(completionId)) {
|
||||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = false;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._outcomes.delete(completionId);
|
||||
return outcome;
|
||||
|
|
@ -86,12 +133,19 @@ export class NextEditLoggingService {
|
|||
}
|
||||
|
||||
public markDisplayed(completionId: string, outcome: NextEditOutcome) {
|
||||
// Remove from pending since we now have full data.
|
||||
this._pendingCompletions.delete(completionId);
|
||||
outcome.aborted = false;
|
||||
|
||||
const logRejectionTimeout = setTimeout(() => {
|
||||
// Wait 10 seconds, then assume it wasn't accepted
|
||||
outcome.accepted = false;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
this._outcomes.delete(completionId);
|
||||
}, COUNT_COMPLETION_REJECTED_AFTER);
|
||||
|
||||
this._outcomes.set(completionId, outcome);
|
||||
this._logRejectionTimeouts.set(completionId, logRejectionTimeout);
|
||||
|
||||
|
|
@ -124,7 +178,62 @@ export class NextEditLoggingService {
|
|||
};
|
||||
}
|
||||
|
||||
public handleAbort(completionId: string) {
|
||||
// Clear any pending rejection timeout.
|
||||
if (this._logRejectionTimeouts.has(completionId)) {
|
||||
clearTimeout(this._logRejectionTimeouts.get(completionId));
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
}
|
||||
|
||||
// If we have the full outcome, log it as aborted.
|
||||
if (this._outcomes.has(completionId)) {
|
||||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = false;
|
||||
outcome.aborted = true;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._outcomes.delete(completionId);
|
||||
} else {
|
||||
// Log minimal abort event for requests that never got displayed.
|
||||
const pendingData = this._pendingCompletions.get(completionId);
|
||||
|
||||
const minimalAbortOutcome: Partial<NextEditOutcome> = {
|
||||
completionId,
|
||||
accepted: false,
|
||||
aborted: true,
|
||||
timestamp: Date.now(),
|
||||
uniqueId: completionId,
|
||||
elapsed: pendingData ? Date.now() - pendingData.startTime : 0,
|
||||
modelName: pendingData?.modelName || "unknown",
|
||||
modelProvider: pendingData?.modelProvider || "unknown",
|
||||
fileUri: pendingData?.filepath || "unknown",
|
||||
|
||||
// Empty/default values for fields we don't have.
|
||||
completion: "",
|
||||
prompt: "",
|
||||
userEdits: "",
|
||||
userExcerpts: "",
|
||||
originalEditableRange: "",
|
||||
workspaceDirUri: "",
|
||||
cursorPosition: { line: -1, character: -1 },
|
||||
finalCursorPosition: { line: -1, character: -1 },
|
||||
editableRegionStartLine: -1,
|
||||
editableRegionEndLine: -1,
|
||||
diffLines: [],
|
||||
completionOptions: {},
|
||||
};
|
||||
|
||||
this.logNextEditOutcome(minimalAbortOutcome as NextEditOutcome);
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
this._pendingCompletions.delete(completionId);
|
||||
}
|
||||
|
||||
private logNextEditOutcome(outcome: NextEditOutcome) {
|
||||
if (outcome.aborted === undefined) {
|
||||
outcome.aborted = false;
|
||||
}
|
||||
|
||||
void DataLogger.getInstance().logDevData({
|
||||
name: "nextEditOutcome",
|
||||
data: outcome,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,6 @@
|
|||
import * as path from "path";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { ConfigHandler } from "../config/ConfigHandler.js";
|
||||
import {
|
||||
ChatMessage,
|
||||
DiffLine,
|
||||
IDE,
|
||||
ILLM,
|
||||
Position,
|
||||
Range,
|
||||
RangeInFile,
|
||||
} from "../index.js";
|
||||
import { ChatMessage, IDE, ILLM, Range, RangeInFile } from "../index.js";
|
||||
import OpenAI from "../llm/llms/OpenAI.js";
|
||||
import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js";
|
||||
|
||||
|
|
@ -18,10 +9,7 @@ import { ContextRetrievalService } from "../autocomplete/context/ContextRetrieva
|
|||
import { BracketMatchingService } from "../autocomplete/filtering/BracketMatchingService.js";
|
||||
import { CompletionStreamer } from "../autocomplete/generation/CompletionStreamer.js";
|
||||
import { shouldPrefilter } from "../autocomplete/prefiltering/index.js";
|
||||
import {
|
||||
getAllSnippetsWithoutRace,
|
||||
SnippetPayload,
|
||||
} from "../autocomplete/snippets/index.js";
|
||||
import { getAllSnippetsWithoutRace } from "../autocomplete/snippets/index.js";
|
||||
import { AutocompleteCodeSnippet } from "../autocomplete/snippets/types.js";
|
||||
import { GetLspDefinitionsFunction } from "../autocomplete/types.js";
|
||||
import { getAst } from "../autocomplete/util/ast.js";
|
||||
|
|
@ -29,38 +17,23 @@ import { AutocompleteDebouncer } from "../autocomplete/util/AutocompleteDebounce
|
|||
import AutocompleteLruCache from "../autocomplete/util/AutocompleteLruCache.js";
|
||||
import { HelperVars } from "../autocomplete/util/HelperVars.js";
|
||||
import { AutocompleteInput } from "../autocomplete/util/types.js";
|
||||
import { myersDiff } from "../diff/myers.js";
|
||||
import { isSecurityConcern } from "../indexing/ignore.js";
|
||||
import { modelSupportsNextEdit } from "../llm/autodetect.js";
|
||||
import { NEXT_EDIT_MODELS } from "../llm/constants.js";
|
||||
import { countTokens } from "../llm/countTokens.js";
|
||||
import { localPathOrUriToPath } from "../util/pathToUri.js";
|
||||
import {
|
||||
INSTINCT_SYSTEM_PROMPT,
|
||||
MERCURY_SYSTEM_PROMPT,
|
||||
MODEL_WINDOW_SIZES,
|
||||
UNIQUE_TOKEN,
|
||||
} from "./constants.js";
|
||||
import { createDiff, DiffFormatType } from "./context/diffFormatting.js";
|
||||
import {
|
||||
calculateFinalCursorPosition,
|
||||
DiffGroup,
|
||||
groupDiffLines,
|
||||
} from "./diff/diff.js";
|
||||
import { DocumentHistoryTracker } from "./DocumentHistoryTracker.js";
|
||||
import { NextEditLoggingService } from "./NextEditLoggingService.js";
|
||||
import { PrefetchQueue } from "./NextEditPrefetchQueue.js";
|
||||
import { NextEditProviderFactory } from "./NextEditProviderFactory.js";
|
||||
import { BaseNextEditProvider } from "./providers/BaseNextEditProvider.js";
|
||||
import {
|
||||
renderDefaultSystemPrompt,
|
||||
renderDefaultUserPrompt,
|
||||
renderPrompt,
|
||||
} from "./templating/NextEditPromptEngine.js";
|
||||
import {
|
||||
ModelSpecificContext,
|
||||
NextEditOutcome,
|
||||
Prompt,
|
||||
PromptMetadata,
|
||||
RecentlyEditedRange,
|
||||
} from "./types.js";
|
||||
import { isWhitespaceOnlyDeletion } from "./utils.js";
|
||||
|
||||
const autocompleteCache = AutocompleteLruCache.get();
|
||||
|
||||
|
|
@ -91,6 +64,9 @@ export class NextEditProvider {
|
|||
private previousCompletions: NextEditOutcome[] = [];
|
||||
// private nextEditableRegionsInTheCurrentChain: RangeInFile[] = [];
|
||||
|
||||
// Model-specific provider instance.
|
||||
private modelProvider: BaseNextEditProvider | null = null;
|
||||
|
||||
private constructor(
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
|
|
@ -285,6 +261,9 @@ export class NextEditProvider {
|
|||
usingFullFileDiff: boolean;
|
||||
},
|
||||
): Promise<NextEditOutcome | undefined> {
|
||||
if (isSecurityConcern(input.filepath)) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
this.previousRequest = input;
|
||||
const {
|
||||
|
|
@ -294,28 +273,23 @@ export class NextEditProvider {
|
|||
} = await this._initializeCompletionRequest(input, token);
|
||||
if (!helper) return undefined;
|
||||
|
||||
// Create model-specific provider based on the model name.
|
||||
this.modelProvider = NextEditProviderFactory.createProvider(
|
||||
helper.modelName,
|
||||
);
|
||||
|
||||
const { editableRegionStartLine, editableRegionEndLine, prompts } =
|
||||
await this._generatePrompts(helper, opts);
|
||||
|
||||
if (this.endpointType === "default") {
|
||||
return await this._handleDefaultEndpointCompletion(
|
||||
helper,
|
||||
prompts,
|
||||
abortToken,
|
||||
startTime,
|
||||
editableRegionEndLine,
|
||||
);
|
||||
} else {
|
||||
return await this._handleFineTunedEndpointCompletion(
|
||||
helper,
|
||||
prompts,
|
||||
abortToken,
|
||||
startTime,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
opts,
|
||||
);
|
||||
}
|
||||
return await this._handleCompletion(
|
||||
helper,
|
||||
prompts,
|
||||
abortToken,
|
||||
startTime,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
opts,
|
||||
);
|
||||
} catch (e: any) {
|
||||
this.onError(e);
|
||||
} finally {
|
||||
|
|
@ -331,17 +305,21 @@ export class NextEditProvider {
|
|||
startTime: number;
|
||||
helper: HelperVars | undefined;
|
||||
}> {
|
||||
// Create abort signal if not given.
|
||||
// Create abort signal if not given
|
||||
if (!token) {
|
||||
const controller = this.loggingService.createAbortController(
|
||||
input.completionId,
|
||||
);
|
||||
token = controller.signal;
|
||||
} else {
|
||||
// Token was provided externally, just track the completion.
|
||||
this.loggingService.trackPendingCompletion(input.completionId);
|
||||
}
|
||||
|
||||
const startTime = Date.now();
|
||||
const options = await this._getAutocompleteOptions();
|
||||
|
||||
// Debounce.
|
||||
// Debounce
|
||||
if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) {
|
||||
return { token, startTime, helper: undefined };
|
||||
}
|
||||
|
|
@ -351,9 +329,14 @@ export class NextEditProvider {
|
|||
return { token, startTime, helper: undefined };
|
||||
}
|
||||
|
||||
// In vscode, this check is done in extensions/vscode/src/extension/VsCodeExtension.ts.
|
||||
// For other editors, this check should be done in their respective config reloaders.
|
||||
// This is left for a final check.
|
||||
// Update pending completion with model info.
|
||||
this.loggingService.updatePendingCompletion(input.completionId, {
|
||||
modelName: llm.model,
|
||||
modelProvider: llm.providerName,
|
||||
filepath: input.filepath,
|
||||
});
|
||||
|
||||
// Check model capabilities
|
||||
if (!modelSupportsNextEdit(llm.capabilities, llm.model, llm.title)) {
|
||||
console.error(`${llm.model} is not capable of next edit.`);
|
||||
return { token, startTime, helper: undefined };
|
||||
|
|
@ -383,6 +366,10 @@ export class NextEditProvider {
|
|||
editableRegionEndLine: number;
|
||||
prompts: Prompt[];
|
||||
}> {
|
||||
if (!this.modelProvider) {
|
||||
throw new Error("Model provider not initialized");
|
||||
}
|
||||
|
||||
const [snippetPayload, workspaceDirs] = await Promise.all([
|
||||
getAllSnippetsWithoutRace({
|
||||
helper,
|
||||
|
|
@ -393,56 +380,118 @@ export class NextEditProvider {
|
|||
this.ide.getWorkspaceDirs(),
|
||||
]);
|
||||
|
||||
const modelName = helper.modelName.includes(
|
||||
NEXT_EDIT_MODELS.MERCURY_CODER_NEXTEDIT,
|
||||
)
|
||||
? NEXT_EDIT_MODELS.MERCURY_CODER_NEXTEDIT
|
||||
: helper.modelName.includes(NEXT_EDIT_MODELS.MERCURY_CODER)
|
||||
? NEXT_EDIT_MODELS.MERCURY_CODER
|
||||
: NEXT_EDIT_MODELS.INSTINCT;
|
||||
|
||||
// Calculate editable region based on model and options.
|
||||
const { editableRegionStartLine, editableRegionEndLine } =
|
||||
opts?.usingFullFileDiff
|
||||
? this._calculateOptimalEditableRegion(helper, "tokenizer")
|
||||
: {
|
||||
editableRegionStartLine: Math.max(
|
||||
helper.pos.line - MODEL_WINDOW_SIZES[modelName].topMargin,
|
||||
0,
|
||||
),
|
||||
editableRegionEndLine: Math.min(
|
||||
helper.pos.line + MODEL_WINDOW_SIZES[modelName].bottomMargin,
|
||||
helper.fileLines.length - 1,
|
||||
),
|
||||
};
|
||||
this.modelProvider.calculateEditableRegion(
|
||||
helper,
|
||||
opts?.usingFullFileDiff ?? false,
|
||||
);
|
||||
|
||||
// const editableRegionStartLine = opts?.usingFullFileDiff
|
||||
// ? 0
|
||||
// : Math.max(helper.pos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN, 0);
|
||||
// Build context for model-specific prompt generation.
|
||||
const context: ModelSpecificContext = {
|
||||
helper,
|
||||
snippetPayload,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
diffContext: this.diffContext,
|
||||
autocompleteContext: this.autocompleteContext,
|
||||
historyDiff: createDiff({
|
||||
beforeContent:
|
||||
DocumentHistoryTracker.getInstance().getMostRecentDocumentHistory(
|
||||
localPathOrUriToPath(helper.filepath),
|
||||
) ?? "",
|
||||
afterContent: helper.fileContents,
|
||||
filePath: helper.filepath,
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 3,
|
||||
}),
|
||||
};
|
||||
|
||||
// const editableRegionEndLine = opts?.usingFullFileDiff
|
||||
// ? helper.fileLines.length - 1
|
||||
// : Math.min(
|
||||
// helper.pos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN,
|
||||
// helper.fileLines.length - 1,
|
||||
// );
|
||||
const prompts = await this.modelProvider.generatePrompts(context);
|
||||
|
||||
const prompts: Prompt[] = [];
|
||||
this.promptMetadata = this.modelProvider.buildPromptMetadata(context);
|
||||
|
||||
if (this.endpointType === "default") {
|
||||
prompts.push(renderDefaultSystemPrompt());
|
||||
prompts.push(renderDefaultUserPrompt(snippetPayload, helper));
|
||||
return { editableRegionStartLine, editableRegionEndLine, prompts };
|
||||
}
|
||||
|
||||
private async _handleCompletion(
|
||||
helper: HelperVars,
|
||||
prompts: Prompt[],
|
||||
token: AbortSignal,
|
||||
startTime: number,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
opts?: {
|
||||
withChain: boolean;
|
||||
usingFullFileDiff: boolean;
|
||||
},
|
||||
): Promise<NextEditOutcome | undefined> {
|
||||
if (!this.modelProvider) {
|
||||
throw new Error("Model provider not initialized");
|
||||
}
|
||||
|
||||
const llm = await this._prepareLlm();
|
||||
if (!llm) return undefined;
|
||||
|
||||
// Inject unique token if needed (for Mercury models).
|
||||
if (this.modelProvider.shouldInjectUniqueToken()) {
|
||||
const uniqueToken = this.modelProvider.getUniqueToken();
|
||||
if (uniqueToken) {
|
||||
const lastPrompt = prompts[prompts.length - 1];
|
||||
if (lastPrompt && typeof lastPrompt.content === "string") {
|
||||
lastPrompt.content += uniqueToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send prompts to LLM (using only user prompt for fine-tuned models).
|
||||
const msg: ChatMessage = await llm.chat([prompts[1]], token, {
|
||||
stream: false,
|
||||
});
|
||||
|
||||
if (typeof msg.content !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Extract completion using model-specific logic.
|
||||
const nextCompletion = this.modelProvider.extractCompletion(msg.content);
|
||||
|
||||
let outcome: NextEditOutcome | undefined;
|
||||
|
||||
// Handle based on diff type.
|
||||
if (opts?.usingFullFileDiff === false || !opts?.usingFullFileDiff) {
|
||||
outcome = await this.modelProvider.handlePartialFileDiff(
|
||||
helper,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
startTime,
|
||||
llm,
|
||||
nextCompletion,
|
||||
this.promptMetadata!,
|
||||
this.ide,
|
||||
);
|
||||
} else {
|
||||
prompts.push(
|
||||
...(await this._generateFineTunedPrompts(
|
||||
helper,
|
||||
snippetPayload,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
)),
|
||||
outcome = await this.modelProvider.handleFullFileDiff(
|
||||
helper,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
startTime,
|
||||
llm,
|
||||
nextCompletion,
|
||||
this.promptMetadata!,
|
||||
this.ide,
|
||||
);
|
||||
}
|
||||
|
||||
return { editableRegionStartLine, editableRegionEndLine, prompts };
|
||||
if (outcome) {
|
||||
// Handle NextEditProvider-specific state
|
||||
this.previousCompletions.push(outcome);
|
||||
|
||||
// Mark as displayed for JetBrains
|
||||
await this._markDisplayedIfJetBrains(helper.input.completionId, outcome);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
private _calculateOptimalEditableRegion(
|
||||
|
|
@ -536,500 +585,6 @@ export class NextEditProvider {
|
|||
};
|
||||
}
|
||||
|
||||
private async _generateFineTunedPrompts(
|
||||
helper: HelperVars,
|
||||
snippetPayload: SnippetPayload,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
): Promise<Prompt[]> {
|
||||
const historyDiff = createDiff({
|
||||
beforeContent:
|
||||
DocumentHistoryTracker.getInstance().getMostRecentDocumentHistory(
|
||||
localPathOrUriToPath(helper.filepath),
|
||||
) ?? "",
|
||||
afterContent: helper.fileContents,
|
||||
filePath: helper.filepath,
|
||||
diffType: DiffFormatType.Unified,
|
||||
contextLines: 3,
|
||||
});
|
||||
|
||||
const modelName = helper.modelName;
|
||||
let ctx: any;
|
||||
|
||||
if (
|
||||
modelName.includes(NEXT_EDIT_MODELS.MERCURY_CODER) ||
|
||||
modelName.includes(NEXT_EDIT_MODELS.MERCURY_CODER_NEXTEDIT)
|
||||
) {
|
||||
ctx = {
|
||||
recentlyViewedCodeSnippets:
|
||||
snippetPayload.recentlyVisitedRangesSnippets.map((snip) => ({
|
||||
filepath: snip.filepath,
|
||||
content: snip.content,
|
||||
})) ?? [],
|
||||
currentFileContent: helper.fileContents,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
editDiffHistory: this.diffContext,
|
||||
currentFilePath: helper.filepath,
|
||||
};
|
||||
} else if (modelName.includes(NEXT_EDIT_MODELS.INSTINCT)) {
|
||||
// Calculate the window around the cursor position (25 lines above and below).
|
||||
const windowStart = Math.max(0, helper.pos.line - 25);
|
||||
const windowEnd = Math.min(
|
||||
helper.fileLines.length - 1,
|
||||
helper.pos.line + 25,
|
||||
);
|
||||
|
||||
// // The editable region is defined as: cursor line - 1 to cursor line + 5 (inclusive).
|
||||
// const actualEditableStart = Math.max(
|
||||
// 0,
|
||||
// helper.pos.line - MODEL_WINDOW_SIZES["instinct"].topMargin,
|
||||
// );
|
||||
// const actualEditableEnd = Math.min(
|
||||
// helper.fileLines.length - 1,
|
||||
// helper.pos.line + MODEL_WINDOW_SIZES["instinct"].bottomMargin,
|
||||
// );
|
||||
|
||||
// Ensure editable region boundaries are within the window.
|
||||
const adjustedEditableStart = Math.max(
|
||||
windowStart,
|
||||
editableRegionStartLine,
|
||||
);
|
||||
const adjustedEditableEnd = Math.min(windowEnd, editableRegionEndLine);
|
||||
ctx = {
|
||||
contextSnippets: this.autocompleteContext,
|
||||
currentFileContent: helper.fileContents,
|
||||
windowStart,
|
||||
windowEnd,
|
||||
editableRegionStartLine: adjustedEditableStart,
|
||||
editableRegionEndLine: adjustedEditableEnd,
|
||||
editDiffHistory: this.diffContext,
|
||||
currentFilePath: helper.filepath,
|
||||
languageShorthand: helper.lang.name,
|
||||
};
|
||||
} else {
|
||||
ctx = {};
|
||||
}
|
||||
|
||||
const promptMetadata = await renderPrompt(helper, ctx);
|
||||
this.promptMetadata = promptMetadata;
|
||||
|
||||
const systemPrompt: Prompt = {
|
||||
role: "system",
|
||||
content:
|
||||
modelName.includes(NEXT_EDIT_MODELS.MERCURY_CODER) ||
|
||||
modelName.includes(NEXT_EDIT_MODELS.MERCURY_CODER_NEXTEDIT)
|
||||
? MERCURY_SYSTEM_PROMPT
|
||||
: INSTINCT_SYSTEM_PROMPT,
|
||||
};
|
||||
|
||||
return [systemPrompt, promptMetadata.prompt];
|
||||
}
|
||||
|
||||
private async _handleDefaultEndpointCompletion(
|
||||
helper: HelperVars,
|
||||
prompts: Prompt[],
|
||||
token: AbortSignal,
|
||||
startTime: number,
|
||||
editableRegionEndLine: number,
|
||||
): Promise<NextEditOutcome | undefined> {
|
||||
const llm = await this._prepareLlm();
|
||||
if (!llm) return undefined;
|
||||
|
||||
const msg: ChatMessage = await llm.chat(prompts, token);
|
||||
|
||||
if (typeof msg.content === "string") {
|
||||
const nextCompletion = JSON.parse(msg.content).newCode;
|
||||
const finalCursorPos: Position = {
|
||||
line: editableRegionEndLine,
|
||||
character: 0,
|
||||
};
|
||||
|
||||
const outcomeNext = await this._createNextEditOutcome({
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
promptContent: prompts.join("\n"),
|
||||
completion: nextCompletion,
|
||||
finalCursorPosition: finalCursorPos,
|
||||
editableRegionStartLine: 0,
|
||||
editableRegionEndLine: 0,
|
||||
userEdits: "",
|
||||
userExcerpts: "",
|
||||
originalEditableRange: "",
|
||||
diffLines: [],
|
||||
});
|
||||
|
||||
// Mark as displayed for JetBrains extension
|
||||
await this._markDisplayedIfJetBrains(
|
||||
helper.input.completionId,
|
||||
outcomeNext,
|
||||
);
|
||||
|
||||
return outcomeNext;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private async _handleFineTunedEndpointCompletion(
|
||||
helper: HelperVars,
|
||||
prompts: Prompt[],
|
||||
token: AbortSignal,
|
||||
startTime: number,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
opts?: {
|
||||
withChain: boolean;
|
||||
usingFullFileDiff: boolean;
|
||||
},
|
||||
): Promise<NextEditOutcome | undefined> {
|
||||
const llm = await this._prepareLlm();
|
||||
if (!llm) return undefined;
|
||||
|
||||
// Check for mercury models, and inject unique token for next edit.
|
||||
// Capture the unique tokens in llm Inception.ts and apis Inception.ts
|
||||
const modelName = helper.modelName;
|
||||
if (
|
||||
modelName.includes(NEXT_EDIT_MODELS.MERCURY_CODER) ||
|
||||
modelName.includes(NEXT_EDIT_MODELS.MERCURY_CODER_NEXTEDIT)
|
||||
) {
|
||||
// Inject the unique token to the last prompt's content.
|
||||
const lastPrompt = prompts[prompts.length - 1];
|
||||
if (lastPrompt && typeof lastPrompt.content === "string") {
|
||||
lastPrompt.content += UNIQUE_TOKEN;
|
||||
}
|
||||
}
|
||||
|
||||
const msg: ChatMessage = await llm.chat([prompts[1]], token, {
|
||||
stream: false,
|
||||
});
|
||||
|
||||
if (typeof msg.content !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// NOTE: Keep this in case there is a change in spec.
|
||||
// const nextCompletion =
|
||||
// msg.content
|
||||
// .split(`${MERCURY_CODE_TO_EDIT_OPEN}\n`)[1]
|
||||
// .replace(/\n$/, "") ?? msg.content;
|
||||
const nextCompletion = msg.content.slice(
|
||||
msg.content.indexOf("\`\`\`\n") + "\'\'\'\n".length,
|
||||
msg.content.lastIndexOf("\n\n\`\`\`"),
|
||||
);
|
||||
|
||||
if (opts?.usingFullFileDiff === false || !opts?.usingFullFileDiff) {
|
||||
return await this._handlePartialFileDiff(
|
||||
// we could use fillFileDiff
|
||||
helper,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
startTime,
|
||||
llm,
|
||||
nextCompletion,
|
||||
);
|
||||
} else {
|
||||
return await this._handleFullFileDiff(
|
||||
helper,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
startTime,
|
||||
llm,
|
||||
nextCompletion,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async _handlePartialFileDiff(
|
||||
helper: HelperVars,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
nextCompletion: string,
|
||||
): Promise<NextEditOutcome | undefined> {
|
||||
const oldEditRangeSlice = helper.fileContents
|
||||
.split("\n")
|
||||
.slice(editableRegionStartLine, editableRegionEndLine + 1)
|
||||
.join("\n");
|
||||
|
||||
const finalCursorPos = calculateFinalCursorPosition(
|
||||
helper.pos,
|
||||
editableRegionStartLine,
|
||||
oldEditRangeSlice,
|
||||
nextCompletion,
|
||||
);
|
||||
|
||||
const outcomeNext = await this._createNextEditOutcome({
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
promptContent: this.promptMetadata!.prompt.content,
|
||||
completion: nextCompletion,
|
||||
finalCursorPosition: finalCursorPos,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
userEdits: this.promptMetadata!.userEdits,
|
||||
userExcerpts: this.promptMetadata!.userExcerpts,
|
||||
originalEditableRange: oldEditRangeSlice,
|
||||
diffLines: [],
|
||||
});
|
||||
|
||||
this.previousCompletions.push(outcomeNext);
|
||||
|
||||
// Mark as displayed for JetBrains extension
|
||||
await this._markDisplayedIfJetBrains(
|
||||
helper.input.completionId,
|
||||
outcomeNext,
|
||||
);
|
||||
|
||||
return outcomeNext;
|
||||
}
|
||||
|
||||
private async _handleFullFileDiff(
|
||||
helper: HelperVars,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
nextCompletion: string,
|
||||
): Promise<NextEditOutcome | undefined> {
|
||||
const fileSlice = helper.fileLines
|
||||
.slice(editableRegionStartLine, editableRegionEndLine + 1)
|
||||
.join("\n");
|
||||
const diffLines = myersDiff(fileSlice, nextCompletion);
|
||||
const diffGroups = groupDiffLines(
|
||||
diffLines,
|
||||
editableRegionStartLine,
|
||||
5,
|
||||
).filter((group) => !isWhitespaceOnlyDeletion(group.lines));
|
||||
const currentLine = helper.pos.line;
|
||||
const prefetchQueue = PrefetchQueue.getInstance();
|
||||
|
||||
// Process diff groups and find the one containing the cursor
|
||||
const cursorLocalDiffGroup = await this._processDiffGroups(
|
||||
diffGroups,
|
||||
currentLine,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
prefetchQueue,
|
||||
);
|
||||
|
||||
// Handle the diff group containing the cursor if found
|
||||
if (cursorLocalDiffGroup) {
|
||||
return await this._createOutcomeFromDiffGroup(
|
||||
cursorLocalDiffGroup,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
helper.input.completionId,
|
||||
true,
|
||||
);
|
||||
// } else if (diffGroups.length > 0) {
|
||||
// // Fallback to first diff group if cursor's group not found
|
||||
// return await this._createOutcomeFromDiffGroup(
|
||||
// diffGroups[0],
|
||||
// helper,
|
||||
// startTime,
|
||||
// llm,
|
||||
// helper.input.completionId,
|
||||
// false,
|
||||
// );
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private async _processDiffGroups(
|
||||
diffGroups: DiffGroup[],
|
||||
currentLine: number,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
prefetchQueue: PrefetchQueue,
|
||||
): Promise<DiffGroup | undefined> {
|
||||
let cursorGroup: DiffGroup | undefined;
|
||||
|
||||
console.log("diffGroups:");
|
||||
console.log(diffGroups);
|
||||
|
||||
for (const group of diffGroups) {
|
||||
if (currentLine >= group.startLine && currentLine <= group.endLine) {
|
||||
cursorGroup = group;
|
||||
} else {
|
||||
// Add non-cursor groups to prefetch queue
|
||||
await this._addDiffGroupToPrefetchQueue(
|
||||
group,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
prefetchQueue,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return cursorGroup;
|
||||
}
|
||||
|
||||
private async _addDiffGroupToPrefetchQueue(
|
||||
group: DiffGroup,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
prefetchQueue: PrefetchQueue,
|
||||
): Promise<void> {
|
||||
const groupContent = group.lines
|
||||
.filter((l) => l.type !== "old")
|
||||
.map((l) => l.line)
|
||||
.join("\n");
|
||||
|
||||
// Create a range for this diff group
|
||||
const rangeInFile: RangeInFile = {
|
||||
filepath: helper.filepath,
|
||||
range: {
|
||||
start: { line: group.startLine, character: 0 },
|
||||
end: {
|
||||
line: group.endLine,
|
||||
character: group.lines[group.lines.length - 1].line.length,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const originalContent = group.lines
|
||||
.filter((l) => l.type !== "new")
|
||||
.map((l) => l.line)
|
||||
.join("\n");
|
||||
|
||||
// Build outcome for this diff group
|
||||
const groupOutcome = await this._createNextEditOutcome({
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
promptContent: this.promptMetadata!.prompt.content,
|
||||
completion: groupContent,
|
||||
finalCursorPosition: {
|
||||
line: group.endLine,
|
||||
character: group.lines[group.lines.length - 1].line.length,
|
||||
},
|
||||
editableRegionStartLine: group.startLine,
|
||||
editableRegionEndLine: group.endLine,
|
||||
userEdits: this.promptMetadata!.userEdits,
|
||||
userExcerpts: this.promptMetadata!.userExcerpts,
|
||||
originalEditableRange: originalContent,
|
||||
cursorPosition: { line: group.startLine, character: 0 },
|
||||
completionId: uuidv4(), // Generate a new ID for this prefetched item
|
||||
diffLines: group.lines,
|
||||
});
|
||||
|
||||
// Add to prefetch queue
|
||||
prefetchQueue.enqueueProcessed({
|
||||
location: rangeInFile,
|
||||
outcome: groupOutcome,
|
||||
});
|
||||
}
|
||||
|
||||
private async _createOutcomeFromDiffGroup(
|
||||
diffGroup: DiffGroup,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
completionId: string,
|
||||
isCurrentCursorGroup: boolean,
|
||||
): Promise<NextEditOutcome> {
|
||||
const groupContent = diffGroup.lines
|
||||
.filter((l) => l.type !== "old")
|
||||
.map((line) => line.line)
|
||||
.join("\n");
|
||||
|
||||
const originalContent = diffGroup.lines
|
||||
.filter((l) => l.type !== "new")
|
||||
.map((l) => l.line)
|
||||
.join("\n");
|
||||
|
||||
// Use the actual cursor position if this is the group containing the cursor
|
||||
// Otherwise use the start of the diff group
|
||||
const cursorPos = isCurrentCursorGroup
|
||||
? helper.pos
|
||||
: { line: diffGroup.startLine, character: 0 };
|
||||
|
||||
const finalCursorPos = calculateFinalCursorPosition(
|
||||
cursorPos,
|
||||
diffGroup.startLine,
|
||||
originalContent,
|
||||
groupContent,
|
||||
);
|
||||
|
||||
const outcomeNext = await this._createNextEditOutcome({
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
promptContent: this.promptMetadata!.prompt.content,
|
||||
completion: groupContent,
|
||||
finalCursorPosition: finalCursorPos,
|
||||
editableRegionStartLine: diffGroup.startLine,
|
||||
editableRegionEndLine: diffGroup.endLine,
|
||||
userEdits: this.promptMetadata!.userEdits,
|
||||
userExcerpts: this.promptMetadata!.userExcerpts,
|
||||
originalEditableRange: originalContent,
|
||||
cursorPosition: cursorPos,
|
||||
completionId,
|
||||
diffLines: diffGroup.lines,
|
||||
});
|
||||
|
||||
this.previousCompletions.push(outcomeNext);
|
||||
|
||||
// Mark as displayed for JetBrains
|
||||
await this._markDisplayedIfJetBrains(completionId, outcomeNext);
|
||||
|
||||
return outcomeNext;
|
||||
}
|
||||
|
||||
private async _createNextEditOutcome(outcomeCtx: {
|
||||
helper: HelperVars;
|
||||
startTime: number;
|
||||
llm: ILLM;
|
||||
promptContent: string;
|
||||
completion: string;
|
||||
finalCursorPosition: Position;
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
userEdits: string;
|
||||
userExcerpts: string;
|
||||
originalEditableRange: string;
|
||||
cursorPosition?: Position;
|
||||
completionId?: string;
|
||||
diffLines: DiffLine[];
|
||||
}): Promise<NextEditOutcome> {
|
||||
return {
|
||||
elapsed: Date.now() - outcomeCtx.startTime,
|
||||
modelProvider: outcomeCtx.llm.underlyingProviderName,
|
||||
modelName: outcomeCtx.llm.model + ":zetaDataset",
|
||||
completionOptions: null,
|
||||
completionId:
|
||||
outcomeCtx.completionId || outcomeCtx.helper.input.completionId,
|
||||
gitRepo: await this.ide.getRepoName(outcomeCtx.helper.filepath),
|
||||
uniqueId: await this.ide.getUniqueId(),
|
||||
timestamp: Date.now(),
|
||||
fileUri: outcomeCtx.helper.filepath,
|
||||
workspaceDirUri:
|
||||
outcomeCtx.helper.workspaceUris[0] ??
|
||||
path.dirname(outcomeCtx.helper.filepath),
|
||||
prompt: outcomeCtx.promptContent,
|
||||
userEdits: outcomeCtx.userEdits ?? "",
|
||||
userExcerpts: outcomeCtx.userExcerpts ?? "",
|
||||
originalEditableRange: outcomeCtx.originalEditableRange ?? "",
|
||||
completion: outcomeCtx.completion,
|
||||
cursorPosition: outcomeCtx.cursorPosition || outcomeCtx.helper.pos,
|
||||
finalCursorPosition: outcomeCtx.finalCursorPosition,
|
||||
editableRegionStartLine: outcomeCtx.editableRegionStartLine,
|
||||
editableRegionEndLine: outcomeCtx.editableRegionEndLine,
|
||||
diffLines: outcomeCtx.diffLines,
|
||||
...outcomeCtx.helper.options,
|
||||
};
|
||||
}
|
||||
|
||||
private async _markDisplayedIfJetBrains(
|
||||
completionId: string,
|
||||
outcome: NextEditOutcome,
|
||||
|
|
|
|||
16
core/nextEdit/NextEditProviderFactory.ts
Normal file
16
core/nextEdit/NextEditProviderFactory.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { NEXT_EDIT_MODELS } from "../llm/constants.js";
|
||||
import { BaseNextEditProvider } from "./providers/BaseNextEditProvider.js";
|
||||
import { InstinctProvider } from "./providers/InstinctNextEditProvider.js";
|
||||
import { MercuryCoderProvider } from "./providers/MercuryCoderNextEditProvider.js";
|
||||
|
||||
export class NextEditProviderFactory {
|
||||
static createProvider(modelName: string): BaseNextEditProvider {
|
||||
if (modelName.includes(NEXT_EDIT_MODELS.MERCURY_CODER)) {
|
||||
return new MercuryCoderProvider();
|
||||
} else if (modelName.includes(NEXT_EDIT_MODELS.INSTINCT)) {
|
||||
return new InstinctProvider();
|
||||
} else {
|
||||
throw new Error(`Unsupported model: ${modelName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,10 +12,6 @@ export const MODEL_WINDOW_SIZES: Record<
|
|||
topMargin: 0,
|
||||
bottomMargin: 5,
|
||||
}, // mercury coder uses full file diff, so this should be unnecessary
|
||||
"mercury-coder-nextedit": {
|
||||
topMargin: 0,
|
||||
bottomMargin: 5,
|
||||
}, // mercury coder nextedit uses full file diff, so this should be unnecessary
|
||||
instinct: { topMargin: 1, bottomMargin: 5 },
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
} from "../../autocomplete/util/types";
|
||||
import { ConfigHandler } from "../../config/ConfigHandler";
|
||||
import { IDE, ILLM } from "../../index";
|
||||
import { isSecurityConcern } from "../../indexing/ignore";
|
||||
import { DEFAULT_AUTOCOMPLETE_OPTS } from "../../util/parameters";
|
||||
|
||||
/**
|
||||
|
|
@ -61,6 +62,10 @@ export const getAutocompleteContext = async (
|
|||
throw new Error("No config available");
|
||||
}
|
||||
|
||||
if (isSecurityConcern(input.filepath)) {
|
||||
throw new Error("File is a security concern, autocomplete disabled");
|
||||
}
|
||||
|
||||
// Use provided autocomplete model or fall back to configured autocomplete model
|
||||
let finalModel: ILLM;
|
||||
let modelNameForTemplating: string;
|
||||
|
|
|
|||
415
core/nextEdit/providers/BaseNextEditProvider.ts
Normal file
415
core/nextEdit/providers/BaseNextEditProvider.ts
Normal file
|
|
@ -0,0 +1,415 @@
|
|||
import * as path from "path";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import { HelperVars } from "../../autocomplete/util/HelperVars.js";
|
||||
import { myersDiff } from "../../diff/myers.js";
|
||||
import { DiffLine, IDE, ILLM, Position, RangeInFile } from "../../index.js";
|
||||
import { countTokens } from "../../llm/countTokens.js";
|
||||
import {
|
||||
calculateFinalCursorPosition,
|
||||
DiffGroup,
|
||||
groupDiffLines,
|
||||
} from "../diff/diff.js";
|
||||
import { PrefetchQueue } from "../NextEditPrefetchQueue.js";
|
||||
import {
|
||||
ModelSpecificContext,
|
||||
NextEditOutcome,
|
||||
Prompt,
|
||||
PromptMetadata,
|
||||
} from "../types.js";
|
||||
import { isWhitespaceOnlyDeletion } from "../utils.js";
|
||||
|
||||
export abstract class BaseNextEditProvider {
|
||||
protected readonly modelName: string;
|
||||
|
||||
constructor(modelName: string) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
// Leave methods as abstract when you must have the models implement their own versions.
|
||||
abstract getSystemPrompt(): string;
|
||||
abstract generatePrompts(context: ModelSpecificContext): Promise<Prompt[]>;
|
||||
abstract extractCompletion(message: string): string;
|
||||
abstract buildPromptContext(context: ModelSpecificContext): any;
|
||||
abstract buildPromptMetadata(context: ModelSpecificContext): PromptMetadata;
|
||||
abstract getWindowSize(): { topMargin: number; bottomMargin: number };
|
||||
abstract calculateEditableRegion(
|
||||
helper: HelperVars,
|
||||
usingFullFileDiff: boolean,
|
||||
): {
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
};
|
||||
|
||||
// Methods that can be used as default fallback.
|
||||
public async handlePartialFileDiff(
|
||||
helper: HelperVars,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
nextCompletion: string,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<NextEditOutcome> {
|
||||
const oldEditRangeSlice = helper.fileContents
|
||||
.split("\n")
|
||||
.slice(editableRegionStartLine, editableRegionEndLine + 1)
|
||||
.join("\n");
|
||||
|
||||
const finalCursorPos = calculateFinalCursorPosition(
|
||||
helper.pos,
|
||||
editableRegionStartLine,
|
||||
oldEditRangeSlice,
|
||||
nextCompletion,
|
||||
);
|
||||
|
||||
const outcome = await this.createNextEditOutcome({
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
promptContent: promptMetadata.prompt.content,
|
||||
completion: nextCompletion,
|
||||
finalCursorPosition: finalCursorPos,
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
userEdits: promptMetadata.userEdits,
|
||||
userExcerpts: promptMetadata.userExcerpts,
|
||||
originalEditableRange: oldEditRangeSlice,
|
||||
diffLines: [],
|
||||
ide,
|
||||
});
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public async handleFullFileDiff(
|
||||
helper: HelperVars,
|
||||
editableRegionStartLine: number,
|
||||
editableRegionEndLine: number,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
nextCompletion: string,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<NextEditOutcome | undefined> {
|
||||
const fileSlice = helper.fileLines
|
||||
.slice(editableRegionStartLine, editableRegionEndLine + 1)
|
||||
.join("\n");
|
||||
|
||||
const diffLines = myersDiff(fileSlice, nextCompletion);
|
||||
const diffGroups = groupDiffLines(
|
||||
diffLines,
|
||||
editableRegionStartLine,
|
||||
5,
|
||||
).filter((group) => !isWhitespaceOnlyDeletion(group.lines));
|
||||
const currentLine = helper.pos.line;
|
||||
const prefetchQueue = PrefetchQueue.getInstance();
|
||||
|
||||
const cursorLocalDiffGroup = await this.processDiffGroups(
|
||||
diffGroups,
|
||||
currentLine,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
prefetchQueue,
|
||||
promptMetadata,
|
||||
ide,
|
||||
);
|
||||
|
||||
if (cursorLocalDiffGroup) {
|
||||
return await this.createOutcomeFromDiffGroup(
|
||||
cursorLocalDiffGroup,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
helper.input.completionId,
|
||||
true,
|
||||
promptMetadata,
|
||||
ide,
|
||||
);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process diff groups and find the one containing the cursor.
|
||||
*/
|
||||
private async processDiffGroups(
|
||||
diffGroups: DiffGroup[],
|
||||
currentLine: number,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
prefetchQueue: PrefetchQueue,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<DiffGroup | undefined> {
|
||||
let cursorGroup: DiffGroup | undefined;
|
||||
|
||||
for (const group of diffGroups) {
|
||||
if (currentLine >= group.startLine && currentLine <= group.endLine) {
|
||||
cursorGroup = group;
|
||||
} else {
|
||||
await this.addDiffGroupToPrefetchQueue(
|
||||
group,
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
prefetchQueue,
|
||||
promptMetadata,
|
||||
ide,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return cursorGroup;
|
||||
}
|
||||
|
||||
private async addDiffGroupToPrefetchQueue(
|
||||
group: DiffGroup,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
prefetchQueue: PrefetchQueue,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<void> {
|
||||
// Extract lines that are not old.
|
||||
const groupContent = group.lines
|
||||
.filter((l) => l.type !== "old")
|
||||
.map((l) => l.line)
|
||||
.join("\n");
|
||||
|
||||
const rangeInFile: RangeInFile = {
|
||||
filepath: helper.filepath,
|
||||
range: {
|
||||
start: { line: group.startLine, character: 0 },
|
||||
end: {
|
||||
line: group.endLine,
|
||||
character: group.lines[group.lines.length - 1].line.length,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Extract lines that are not new.
|
||||
const originalContent = group.lines
|
||||
.filter((l) => l.type !== "new")
|
||||
.map((l) => l.line)
|
||||
.join("\n");
|
||||
|
||||
const groupOutcome = await this.createNextEditOutcome({
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
promptContent: promptMetadata.prompt.content,
|
||||
completion: groupContent,
|
||||
finalCursorPosition: {
|
||||
line: group.endLine,
|
||||
character: group.lines[group.lines.length - 1].line.length,
|
||||
},
|
||||
editableRegionStartLine: group.startLine,
|
||||
editableRegionEndLine: group.endLine,
|
||||
userEdits: promptMetadata.userEdits,
|
||||
userExcerpts: promptMetadata.userExcerpts,
|
||||
originalEditableRange: originalContent,
|
||||
cursorPosition: { line: group.startLine, character: 0 },
|
||||
completionId: uuidv4(), // Generate a new ID for this prefetched item.
|
||||
diffLines: group.lines,
|
||||
ide,
|
||||
});
|
||||
|
||||
prefetchQueue.enqueueProcessed({
|
||||
location: rangeInFile,
|
||||
outcome: groupOutcome,
|
||||
});
|
||||
}
|
||||
|
||||
private async createOutcomeFromDiffGroup(
|
||||
diffGroup: DiffGroup,
|
||||
helper: HelperVars,
|
||||
startTime: number,
|
||||
llm: ILLM,
|
||||
completionId: string,
|
||||
isCurrentCursorGroup: boolean,
|
||||
promptMetadata: PromptMetadata,
|
||||
ide: IDE,
|
||||
): Promise<NextEditOutcome> {
|
||||
const groupContent = diffGroup.lines
|
||||
.filter((l) => l.type !== "old")
|
||||
.map((l) => l.line)
|
||||
.join("\n");
|
||||
|
||||
const originalContent = diffGroup.lines
|
||||
.filter((l) => l.type !== "new")
|
||||
.map((l) => l.line)
|
||||
.join("\n");
|
||||
|
||||
const cursorPos = isCurrentCursorGroup
|
||||
? helper.pos
|
||||
: { line: diffGroup.startLine, character: 0 };
|
||||
|
||||
const finalCursorPos = calculateFinalCursorPosition(
|
||||
cursorPos,
|
||||
diffGroup.startLine,
|
||||
originalContent,
|
||||
groupContent,
|
||||
);
|
||||
|
||||
const outcomeNext = await this.createNextEditOutcome({
|
||||
helper,
|
||||
startTime,
|
||||
llm,
|
||||
promptContent: promptMetadata.prompt.content,
|
||||
completion: groupContent,
|
||||
finalCursorPosition: finalCursorPos,
|
||||
editableRegionStartLine: diffGroup.startLine,
|
||||
editableRegionEndLine: diffGroup.endLine,
|
||||
userEdits: promptMetadata.userEdits,
|
||||
userExcerpts: promptMetadata.userExcerpts,
|
||||
originalEditableRange: originalContent,
|
||||
cursorPosition: cursorPos,
|
||||
completionId,
|
||||
diffLines: diffGroup.lines,
|
||||
ide,
|
||||
});
|
||||
|
||||
return outcomeNext;
|
||||
}
|
||||
|
||||
protected async createNextEditOutcome(outcomeCtx: {
|
||||
helper: HelperVars;
|
||||
startTime: number;
|
||||
llm: ILLM;
|
||||
promptContent: string;
|
||||
completion: string;
|
||||
finalCursorPosition: Position;
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
userEdits: string;
|
||||
userExcerpts: string;
|
||||
originalEditableRange: string;
|
||||
cursorPosition?: Position;
|
||||
completionId?: string;
|
||||
diffLines: DiffLine[];
|
||||
ide: IDE;
|
||||
}): Promise<NextEditOutcome> {
|
||||
return {
|
||||
elapsed: Date.now() - outcomeCtx.startTime,
|
||||
modelProvider: outcomeCtx.llm.underlyingProviderName,
|
||||
modelName: outcomeCtx.llm.model,
|
||||
completionOptions: null,
|
||||
completionId:
|
||||
outcomeCtx.completionId || outcomeCtx.helper.input.completionId,
|
||||
gitRepo: await outcomeCtx.ide.getRepoName(outcomeCtx.helper.filepath),
|
||||
uniqueId: await outcomeCtx.ide.getUniqueId(),
|
||||
timestamp: Date.now(),
|
||||
fileUri: outcomeCtx.helper.filepath,
|
||||
workspaceDirUri:
|
||||
outcomeCtx.helper.workspaceUris[0] ??
|
||||
path.dirname(outcomeCtx.helper.filepath),
|
||||
prompt: outcomeCtx.promptContent,
|
||||
userEdits: outcomeCtx.userEdits ?? "",
|
||||
userExcerpts: outcomeCtx.userExcerpts ?? "",
|
||||
originalEditableRange: outcomeCtx.originalEditableRange ?? "",
|
||||
completion: outcomeCtx.completion,
|
||||
cursorPosition: outcomeCtx.cursorPosition || outcomeCtx.helper.pos,
|
||||
finalCursorPosition: outcomeCtx.finalCursorPosition,
|
||||
editableRegionStartLine: outcomeCtx.editableRegionStartLine,
|
||||
editableRegionEndLine: outcomeCtx.editableRegionEndLine,
|
||||
diffLines: outcomeCtx.diffLines,
|
||||
...outcomeCtx.helper.options,
|
||||
};
|
||||
}
|
||||
|
||||
// Shared utility for calculating editable regions.
|
||||
protected calculateOptimalEditableRegion(
|
||||
helper: HelperVars,
|
||||
maxTokens: number = 512,
|
||||
heuristic: "fourChars" | "tokenizer" = "tokenizer",
|
||||
): {
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
} {
|
||||
const cursorLine = helper.pos.line;
|
||||
const fileLines = helper.fileLines;
|
||||
|
||||
let editableRegionStartLine = cursorLine;
|
||||
let editableRegionEndLine = cursorLine;
|
||||
|
||||
let currentContent = fileLines[cursorLine];
|
||||
let totalTokens =
|
||||
heuristic === "tokenizer"
|
||||
? countTokens(currentContent, helper.modelName)
|
||||
: Math.ceil(currentContent.length / 4);
|
||||
|
||||
let addingAbove = true;
|
||||
|
||||
while (totalTokens < maxTokens) {
|
||||
let addedLine = false;
|
||||
|
||||
if (addingAbove) {
|
||||
if (editableRegionStartLine > 0) {
|
||||
editableRegionStartLine--;
|
||||
const lineContent = fileLines[editableRegionStartLine];
|
||||
const lineTokens =
|
||||
heuristic === "tokenizer"
|
||||
? countTokens(lineContent, helper.modelName)
|
||||
: Math.ceil(lineContent.length / 4);
|
||||
|
||||
totalTokens += lineTokens;
|
||||
addedLine = true;
|
||||
}
|
||||
} else {
|
||||
if (editableRegionEndLine < fileLines.length - 1) {
|
||||
editableRegionEndLine++;
|
||||
const lineContent = fileLines[editableRegionEndLine];
|
||||
const lineTokens =
|
||||
heuristic === "tokenizer"
|
||||
? countTokens(lineContent, helper.modelName)
|
||||
: Math.ceil(lineContent.length / 4);
|
||||
|
||||
totalTokens += lineTokens;
|
||||
addedLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!addedLine) {
|
||||
if (
|
||||
editableRegionStartLine === 0 &&
|
||||
editableRegionEndLine === fileLines.length - 1
|
||||
) {
|
||||
break;
|
||||
}
|
||||
addingAbove = !addingAbove;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (totalTokens > maxTokens) {
|
||||
if (addingAbove) {
|
||||
editableRegionStartLine++;
|
||||
} else {
|
||||
editableRegionEndLine--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
addingAbove = !addingAbove;
|
||||
}
|
||||
|
||||
return {
|
||||
editableRegionStartLine,
|
||||
editableRegionEndLine,
|
||||
};
|
||||
}
|
||||
|
||||
// Optional methods with defaults.
|
||||
shouldInjectUniqueToken(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
getUniqueToken(): string | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
155
core/nextEdit/providers/InstinctNextEditProvider.ts
Normal file
155
core/nextEdit/providers/InstinctNextEditProvider.ts
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
import { HelperVars } from "../../autocomplete/util/HelperVars.js";
|
||||
import { NEXT_EDIT_MODELS } from "../../llm/constants.js";
|
||||
import { INSTINCT_SYSTEM_PROMPT } from "../constants.js";
|
||||
import {
|
||||
contextSnippetsBlock,
|
||||
currentFileContentBlock,
|
||||
editHistoryBlock,
|
||||
} from "../templating/instinct.js";
|
||||
import {
|
||||
NEXT_EDIT_MODEL_TEMPLATES,
|
||||
PromptTemplateRenderer,
|
||||
} from "../templating/NextEditPromptEngine.js";
|
||||
import { ModelSpecificContext, Prompt, PromptMetadata } from "../types.js";
|
||||
import { BaseNextEditProvider } from "./BaseNextEditProvider.js";
|
||||
|
||||
export class InstinctProvider extends BaseNextEditProvider {
|
||||
private templateRenderer: PromptTemplateRenderer;
|
||||
|
||||
constructor() {
|
||||
super(NEXT_EDIT_MODELS.INSTINCT);
|
||||
|
||||
const template = NEXT_EDIT_MODEL_TEMPLATES[NEXT_EDIT_MODELS.INSTINCT];
|
||||
this.templateRenderer = new PromptTemplateRenderer(template.template);
|
||||
}
|
||||
|
||||
getSystemPrompt(): string {
|
||||
return INSTINCT_SYSTEM_PROMPT;
|
||||
}
|
||||
|
||||
getWindowSize() {
|
||||
return { topMargin: 1, bottomMargin: 5 };
|
||||
}
|
||||
|
||||
shouldInjectUniqueToken(): boolean {
|
||||
return false; // Instinct doesn't use unique tokens.
|
||||
}
|
||||
|
||||
extractCompletion(message: string): string {
|
||||
return message; // Instinct returns the completion directly.
|
||||
}
|
||||
|
||||
buildPromptContext(context: ModelSpecificContext): any {
|
||||
// Calculate the window around the cursor position (25 lines above and below).
|
||||
const windowStart = Math.max(0, context.helper.pos.line - 25);
|
||||
const windowEnd = Math.min(
|
||||
context.helper.fileLines.length - 1,
|
||||
context.helper.pos.line + 25,
|
||||
);
|
||||
|
||||
// Ensure editable region boundaries are within the window.
|
||||
const adjustedEditableStart = Math.max(
|
||||
windowStart,
|
||||
context.editableRegionStartLine,
|
||||
);
|
||||
const adjustedEditableEnd = Math.min(
|
||||
windowEnd,
|
||||
context.editableRegionEndLine,
|
||||
);
|
||||
|
||||
return {
|
||||
contextSnippets: context.autocompleteContext,
|
||||
currentFileContent: context.helper.fileContents,
|
||||
windowStart,
|
||||
windowEnd,
|
||||
editableRegionStartLine: adjustedEditableStart,
|
||||
editableRegionEndLine: adjustedEditableEnd,
|
||||
editDiffHistory: context.diffContext,
|
||||
currentFilePath: context.helper.filepath,
|
||||
languageShorthand: context.helper.lang.name,
|
||||
};
|
||||
}
|
||||
|
||||
async generatePrompts(context: ModelSpecificContext): Promise<Prompt[]> {
|
||||
const promptCtx = this.buildPromptContext(context);
|
||||
|
||||
const templateVars = {
|
||||
contextSnippets: contextSnippetsBlock(promptCtx.contextSnippets),
|
||||
currentFileContent: currentFileContentBlock(
|
||||
promptCtx.currentFileContent,
|
||||
promptCtx.windowStart,
|
||||
promptCtx.windowEnd,
|
||||
promptCtx.editableRegionStartLine,
|
||||
promptCtx.editableRegionEndLine,
|
||||
context.helper.pos,
|
||||
),
|
||||
editDiffHistory: editHistoryBlock(promptCtx.editDiffHistory),
|
||||
currentFilePath: promptCtx.currentFilePath,
|
||||
languageShorthand: promptCtx.languageShorthand,
|
||||
};
|
||||
|
||||
const userPromptContent = this.templateRenderer.render(templateVars);
|
||||
|
||||
return [
|
||||
{
|
||||
role: "system",
|
||||
content: this.getSystemPrompt(),
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: userPromptContent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
buildPromptMetadata(context: ModelSpecificContext): PromptMetadata {
|
||||
const promptCtx = this.buildPromptContext(context);
|
||||
|
||||
const templateVars = {
|
||||
contextSnippets: contextSnippetsBlock(promptCtx.contextSnippets),
|
||||
currentFileContent: currentFileContentBlock(
|
||||
promptCtx.currentFileContent,
|
||||
promptCtx.windowStart,
|
||||
promptCtx.windowEnd,
|
||||
promptCtx.editableRegionStartLine,
|
||||
promptCtx.editableRegionEndLine,
|
||||
context.helper.pos,
|
||||
),
|
||||
editDiffHistory: editHistoryBlock(promptCtx.editDiffHistory),
|
||||
currentFilePath: promptCtx.currentFilePath,
|
||||
languageShorthand: promptCtx.languageShorthand,
|
||||
};
|
||||
|
||||
const userPromptContent = this.templateRenderer.render(templateVars);
|
||||
|
||||
return {
|
||||
prompt: {
|
||||
role: "user",
|
||||
content: userPromptContent,
|
||||
},
|
||||
userEdits: promptCtx.editDiffHistory.join("\n"),
|
||||
userExcerpts: templateVars.currentFileContent,
|
||||
};
|
||||
}
|
||||
|
||||
calculateEditableRegion(
|
||||
helper: HelperVars,
|
||||
usingFullFileDiff: boolean,
|
||||
): {
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
} {
|
||||
if (usingFullFileDiff) {
|
||||
return this.calculateOptimalEditableRegion(helper, 512, "tokenizer");
|
||||
} else {
|
||||
const { topMargin, bottomMargin } = this.getWindowSize();
|
||||
return {
|
||||
editableRegionStartLine: Math.max(helper.pos.line - topMargin, 0),
|
||||
editableRegionEndLine: Math.min(
|
||||
helper.pos.line + bottomMargin,
|
||||
helper.fileLines.length - 1,
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
145
core/nextEdit/providers/MercuryCoderNextEditProvider.ts
Normal file
145
core/nextEdit/providers/MercuryCoderNextEditProvider.ts
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
import { HelperVars } from "../../autocomplete/util/HelperVars.js";
|
||||
import { NEXT_EDIT_MODELS } from "../../llm/constants.js";
|
||||
import { MERCURY_SYSTEM_PROMPT, UNIQUE_TOKEN } from "../constants.js";
|
||||
import {
|
||||
currentFileContentBlock,
|
||||
editHistoryBlock,
|
||||
recentlyViewedCodeSnippetsBlock,
|
||||
} from "../templating/mercuryCoderNextEdit.js";
|
||||
import {
|
||||
NEXT_EDIT_MODEL_TEMPLATES,
|
||||
PromptTemplateRenderer,
|
||||
} from "../templating/NextEditPromptEngine.js";
|
||||
import { ModelSpecificContext, Prompt, PromptMetadata } from "../types.js";
|
||||
import { BaseNextEditProvider } from "./BaseNextEditProvider.js";
|
||||
|
||||
export class MercuryCoderProvider extends BaseNextEditProvider {
|
||||
private templateRenderer: PromptTemplateRenderer;
|
||||
|
||||
constructor() {
|
||||
super(NEXT_EDIT_MODELS.MERCURY_CODER);
|
||||
|
||||
const template = NEXT_EDIT_MODEL_TEMPLATES[NEXT_EDIT_MODELS.MERCURY_CODER];
|
||||
this.templateRenderer = new PromptTemplateRenderer(template.template);
|
||||
}
|
||||
|
||||
getSystemPrompt(): string {
|
||||
return MERCURY_SYSTEM_PROMPT;
|
||||
}
|
||||
|
||||
getWindowSize() {
|
||||
return { topMargin: 0, bottomMargin: 5 };
|
||||
}
|
||||
|
||||
shouldInjectUniqueToken(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
getUniqueToken(): string {
|
||||
return UNIQUE_TOKEN;
|
||||
}
|
||||
|
||||
extractCompletion(message: string): string {
|
||||
// Extract the code between the markdown code blocks.
|
||||
return message.slice(
|
||||
message.indexOf("```\n") + "```\n".length,
|
||||
message.lastIndexOf("\n\n```"),
|
||||
);
|
||||
}
|
||||
|
||||
buildPromptContext(context: ModelSpecificContext): any {
|
||||
return {
|
||||
recentlyViewedCodeSnippets:
|
||||
context.snippetPayload.recentlyVisitedRangesSnippets.map((snip) => ({
|
||||
filepath: snip.filepath,
|
||||
content: snip.content,
|
||||
})) ?? [],
|
||||
currentFileContent: context.helper.fileContents,
|
||||
editableRegionStartLine: context.editableRegionStartLine,
|
||||
editableRegionEndLine: context.editableRegionEndLine,
|
||||
editDiffHistory: context.diffContext,
|
||||
currentFilePath: context.helper.filepath,
|
||||
};
|
||||
}
|
||||
|
||||
async generatePrompts(context: ModelSpecificContext): Promise<Prompt[]> {
|
||||
const promptCtx = this.buildPromptContext(context);
|
||||
|
||||
const templateVars = {
|
||||
recentlyViewedCodeSnippets: recentlyViewedCodeSnippetsBlock(
|
||||
promptCtx.recentlyViewedCodeSnippets,
|
||||
),
|
||||
currentFileContent: currentFileContentBlock(
|
||||
promptCtx.currentFileContent,
|
||||
promptCtx.editableRegionStartLine,
|
||||
promptCtx.editableRegionEndLine,
|
||||
context.helper.pos,
|
||||
),
|
||||
editDiffHistory: editHistoryBlock(promptCtx.editDiffHistory),
|
||||
currentFilePath: promptCtx.currentFilePath,
|
||||
};
|
||||
|
||||
const userPromptContent = this.templateRenderer.render(templateVars);
|
||||
|
||||
return [
|
||||
{
|
||||
role: "system",
|
||||
content: this.getSystemPrompt(),
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: userPromptContent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
buildPromptMetadata(context: ModelSpecificContext): PromptMetadata {
|
||||
const promptCtx = this.buildPromptContext(context);
|
||||
|
||||
const templateVars = {
|
||||
recentlyViewedCodeSnippets: recentlyViewedCodeSnippetsBlock(
|
||||
promptCtx.recentlyViewedCodeSnippets,
|
||||
),
|
||||
currentFileContent: currentFileContentBlock(
|
||||
promptCtx.currentFileContent,
|
||||
promptCtx.editableRegionStartLine,
|
||||
promptCtx.editableRegionEndLine,
|
||||
context.helper.pos,
|
||||
),
|
||||
editDiffHistory: editHistoryBlock(promptCtx.editDiffHistory),
|
||||
currentFilePath: promptCtx.currentFilePath,
|
||||
};
|
||||
|
||||
const userPromptContent = this.templateRenderer.render(templateVars);
|
||||
|
||||
return {
|
||||
prompt: {
|
||||
role: "user",
|
||||
content: userPromptContent,
|
||||
},
|
||||
userEdits: promptCtx.editDiffHistory.join("\n"),
|
||||
userExcerpts: templateVars.currentFileContent,
|
||||
};
|
||||
}
|
||||
|
||||
calculateEditableRegion(
|
||||
helper: HelperVars,
|
||||
usingFullFileDiff: boolean,
|
||||
): {
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
} {
|
||||
if (usingFullFileDiff) {
|
||||
return this.calculateOptimalEditableRegion(helper, 512, "tokenizer");
|
||||
} else {
|
||||
const { topMargin, bottomMargin } = this.getWindowSize();
|
||||
return {
|
||||
editableRegionStartLine: Math.max(helper.pos.line - topMargin, 0),
|
||||
editableRegionEndLine: Math.min(
|
||||
helper.pos.line + bottomMargin,
|
||||
helper.fileLines.length - 1,
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
import Handlebars from "handlebars";
|
||||
import { Position } from "../..";
|
||||
import { SnippetPayload } from "../../autocomplete/snippets";
|
||||
import { HelperVars } from "../../autocomplete/util/HelperVars";
|
||||
import { NEXT_EDIT_MODELS } from "../../llm/constants";
|
||||
import {
|
||||
INSTINCT_USER_PROMPT_PREFIX,
|
||||
|
|
@ -12,274 +9,39 @@ import {
|
|||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE,
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN,
|
||||
} from "../constants";
|
||||
import {
|
||||
InstinctTemplateVars,
|
||||
MercuryTemplateVars,
|
||||
NextEditTemplate,
|
||||
PromptMetadata,
|
||||
SystemPrompt,
|
||||
TemplateVars,
|
||||
UserPrompt,
|
||||
} from "../types";
|
||||
import {
|
||||
contextSnippetsBlock,
|
||||
currentFileContentBlock as instinctCurrentFileContentBlock,
|
||||
editHistoryBlock as instinctEditHistoryBlock,
|
||||
} from "./instinct";
|
||||
import {
|
||||
currentFileContentBlock,
|
||||
editHistoryBlock,
|
||||
recentlyViewedCodeSnippetsBlock,
|
||||
} from "./mercuryCoderNextEdit";
|
||||
import {
|
||||
insertCursorToken,
|
||||
insertEditableRegionTokensWithStaticRange,
|
||||
} from "./utils";
|
||||
import { NextEditTemplate, TemplateVars } from "../types";
|
||||
|
||||
type TemplateRenderer = (vars: TemplateVars) => string;
|
||||
|
||||
const NEXT_EDIT_MODEL_TEMPLATES: Record<NEXT_EDIT_MODELS, NextEditTemplate> = {
|
||||
// Keep the template registry
|
||||
export const NEXT_EDIT_MODEL_TEMPLATES: Record<
|
||||
NEXT_EDIT_MODELS,
|
||||
NextEditTemplate
|
||||
> = {
|
||||
"mercury-coder": {
|
||||
template: `${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN}\n{{{recentlyViewedCodeSnippets}}}\n${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE}\n\n${MERCURY_CURRENT_FILE_CONTENT_OPEN}\n{{{currentFileContent}}}\n${MERCURY_CURRENT_FILE_CONTENT_CLOSE}\n\n${MERCURY_EDIT_DIFF_HISTORY_OPEN}\n{{{editDiffHistory}}}\n${MERCURY_EDIT_DIFF_HISTORY_CLOSE}\n`,
|
||||
},
|
||||
"mercury-coder-nextedit": {
|
||||
template: `${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN}\n{{{recentlyViewedCodeSnippets}}}\n${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE}\n\n${MERCURY_CURRENT_FILE_CONTENT_OPEN}\n{{{currentFileContent}}}\n${MERCURY_CURRENT_FILE_CONTENT_CLOSE}\n\n${MERCURY_EDIT_DIFF_HISTORY_OPEN}\n{{{editDiffHistory}}}\n${MERCURY_EDIT_DIFF_HISTORY_CLOSE}\n`,
|
||||
},
|
||||
instinct: {
|
||||
template: `${INSTINCT_USER_PROMPT_PREFIX}\n\n### Context:\n{{{contextSnippets}}}\n\n### User Edits:\n\n{{{editDiffHistory}}}\n\n### User Excerpt:\n{{{currentFilePath}}}\n\n{{{currentFileContent}}}\`\`\`\n### Response:`,
|
||||
},
|
||||
};
|
||||
|
||||
function templateRendererOfModel(
|
||||
modelName: NEXT_EDIT_MODELS,
|
||||
): TemplateRenderer {
|
||||
let template = NEXT_EDIT_MODEL_TEMPLATES[modelName];
|
||||
// Export a utility for providers to use
|
||||
export class PromptTemplateRenderer {
|
||||
private compiledTemplate: HandlebarsTemplateDelegate;
|
||||
|
||||
constructor(template: string) {
|
||||
this.compiledTemplate = Handlebars.compile(template);
|
||||
}
|
||||
|
||||
render(vars: TemplateVars): string {
|
||||
return this.compiledTemplate(vars);
|
||||
}
|
||||
}
|
||||
|
||||
// Keep for backward compatibility or remove if not needed
|
||||
export function getTemplateForModel(modelName: NEXT_EDIT_MODELS): string {
|
||||
const template = NEXT_EDIT_MODEL_TEMPLATES[modelName];
|
||||
if (!template) {
|
||||
throw new Error(`Model ${modelName} is not supported for next edit.`);
|
||||
}
|
||||
|
||||
const compiledTemplate = Handlebars.compile(template.template);
|
||||
|
||||
return (vars: TemplateVars): string => {
|
||||
return compiledTemplate(vars);
|
||||
};
|
||||
}
|
||||
|
||||
export async function renderPrompt(
|
||||
helper: HelperVars,
|
||||
ctx: any,
|
||||
): Promise<PromptMetadata> {
|
||||
let modelName = helper.modelName as NEXT_EDIT_MODELS;
|
||||
|
||||
// Validate that the modelName is actually a supported model.
|
||||
if (!Object.keys(NEXT_EDIT_MODEL_TEMPLATES).includes(modelName)) {
|
||||
// Check if modelName includes any known model name as substring.
|
||||
const matchingModel = Object.keys(NEXT_EDIT_MODEL_TEMPLATES).find((key) =>
|
||||
modelName.includes(key),
|
||||
);
|
||||
|
||||
if (matchingModel) {
|
||||
modelName = matchingModel as NEXT_EDIT_MODELS;
|
||||
} else {
|
||||
throw new Error(
|
||||
`${helper.modelName} is not yet supported for next edit.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const renderer = templateRendererOfModel(modelName);
|
||||
let userEdits = "";
|
||||
let editedCodeWithTokens = "";
|
||||
let tv: TemplateVars;
|
||||
|
||||
switch (modelName) {
|
||||
case NEXT_EDIT_MODELS.MERCURY_CODER: {
|
||||
userEdits = ctx.editDiffHistory;
|
||||
|
||||
// editedCodeWithTokens = insertTokens(
|
||||
// helper.fileContents.split("\n"),
|
||||
// helper.pos,
|
||||
// MERCURY_CURSOR,
|
||||
// );
|
||||
|
||||
const mercuryCtx: MercuryTemplateVars = {
|
||||
recentlyViewedCodeSnippets: recentlyViewedCodeSnippetsBlock(
|
||||
ctx.recentlyViewedCodeSnippets,
|
||||
),
|
||||
currentFileContent: currentFileContentBlock(
|
||||
ctx.currentFileContent,
|
||||
ctx.editableRegionStartLine,
|
||||
ctx.editableRegionEndLine,
|
||||
helper.pos,
|
||||
),
|
||||
editDiffHistory: editHistoryBlock(ctx.editDiffHistory),
|
||||
currentFilePath: ctx.currentFilePath,
|
||||
};
|
||||
|
||||
tv = mercuryCtx;
|
||||
|
||||
editedCodeWithTokens = mercuryCtx.currentFileContent;
|
||||
|
||||
break;
|
||||
}
|
||||
case NEXT_EDIT_MODELS.MERCURY_CODER_NEXTEDIT: {
|
||||
userEdits = ctx.editDiffHistory;
|
||||
|
||||
// editedCodeWithTokens = insertTokens(
|
||||
// helper.fileContents.split("\n"),
|
||||
// helper.pos,
|
||||
// MERCURY_CURSOR,
|
||||
// );
|
||||
|
||||
const mercuryCtx: MercuryTemplateVars = {
|
||||
recentlyViewedCodeSnippets: recentlyViewedCodeSnippetsBlock(
|
||||
ctx.recentlyViewedCodeSnippets,
|
||||
),
|
||||
currentFileContent: currentFileContentBlock(
|
||||
ctx.currentFileContent,
|
||||
ctx.editableRegionStartLine,
|
||||
ctx.editableRegionEndLine,
|
||||
helper.pos,
|
||||
),
|
||||
editDiffHistory: editHistoryBlock(ctx.editDiffHistory),
|
||||
currentFilePath: ctx.currentFilePath,
|
||||
};
|
||||
|
||||
tv = mercuryCtx;
|
||||
|
||||
editedCodeWithTokens = mercuryCtx.currentFileContent;
|
||||
|
||||
break;
|
||||
}
|
||||
case NEXT_EDIT_MODELS.INSTINCT: {
|
||||
userEdits = ctx.editDiffHistory;
|
||||
|
||||
// editedCodeWithTokens = insertTokens(
|
||||
// helper.fileContents.split("\n"),
|
||||
// helper.pos,
|
||||
// INSTINCT_USER_CURSOR_IS_HERE_TOKEN,
|
||||
// );
|
||||
|
||||
const instinctCtx: InstinctTemplateVars = {
|
||||
contextSnippets: contextSnippetsBlock(ctx.contextSnippets),
|
||||
currentFileContent: instinctCurrentFileContentBlock(
|
||||
ctx.currentFileContent,
|
||||
ctx.windowStart,
|
||||
ctx.windowEnd,
|
||||
ctx.editableRegionStartLine,
|
||||
ctx.editableRegionEndLine,
|
||||
helper.pos,
|
||||
),
|
||||
editDiffHistory: instinctEditHistoryBlock(ctx.editDiffHistory),
|
||||
currentFilePath: ctx.currentFilePath,
|
||||
languageShorthand: ctx.languageShorthand,
|
||||
};
|
||||
|
||||
tv = instinctCtx;
|
||||
|
||||
editedCodeWithTokens = instinctCtx.currentFileContent;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
tv = {};
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
prompt: {
|
||||
role: "user",
|
||||
content: renderer(tv),
|
||||
},
|
||||
userEdits,
|
||||
userExcerpts: editedCodeWithTokens,
|
||||
};
|
||||
}
|
||||
|
||||
export function renderDefaultSystemPrompt(): SystemPrompt {
|
||||
return {
|
||||
role: "system",
|
||||
content: [
|
||||
/* Identity forming */
|
||||
"You are an expert polyglot developer who is overseeing a junior developer write code in some language.",
|
||||
"You are psychic as well, so you are an expert at reading minds just from what the junior has done.",
|
||||
"As an expert, you know what the next edit of the junior is going to be, and you want to suggest it to save both of your's time.",
|
||||
/* Action crash course */
|
||||
"An action is a change in code state that preserves the well-formedness of the code.",
|
||||
"Well-formedness means that given a cursor location, the local syntax tree that the cursor is in is syntactically correct, and the semantic correctness in the current cursor's character location - 1.",
|
||||
/* Input description */
|
||||
// 'You will receive a prompt that includes an instruction, and a JSON of following format: { "language": string; "originalCode": string; "newCode": string }.',
|
||||
// "language is the language the code is written in.",
|
||||
// "originalCode is the code state before the junior has taken some edit action.",
|
||||
// "editedCode is the code state after the junior has taken some edit action.",
|
||||
// "If we put originalCode and editedCode on a timeline, originalCode lives in the past, and editedCode is the current code state.",
|
||||
// "Measure the difference between the originalCode and editedCode inside the prompt, make your best understanding of what the junior wants to accomplish, and figure out what the junior will do next.",
|
||||
'You will receive a prompt that includes an instruction, and a JSON of following format: { "language": string; "rootPathSnippets": string; "importDefinitionSnippets": string; "ideSnippets": string; "recentlyEditedRangeSnippets": string; "diffSnippets": string; "clipboardSnippets": string; "recentlyVisitedRangesSnippets": string; }.',
|
||||
"rootPathSnippet is all the code that is part of an AST path from the root node to the node at the current cursor.",
|
||||
"recentlyEditedRange is the code that the junior has recently edited.",
|
||||
"Do not guess what previous edit the junior has taken right before the request -- this is already given to you.",
|
||||
"The next edit action can happen any location, so do not default to where the junior left off. A potential next edit action can happen before or after the junior edit.",
|
||||
"The junior might want to add new code, delete existing code, or replace different parts of code.",
|
||||
"The next edit action isn't strictly additive. It could be deleting existing code, or replacing parts of code.",
|
||||
/* Output description */
|
||||
'Reply with a JSON that has the following type: { "actionType": string; "newCode": string }.',
|
||||
/* NOTE: Jacob -- try toggling between these two descriptions of actionType.*/
|
||||
/* NOTE: Without reasoning, mercury tends to skew greatly towards not deleting things. */
|
||||
"actionType is a four-sentence description of the type of action the junior has taken and the reason why you determined that to be the case. Actually analyze the given edit.",
|
||||
// "actionType is the type of action the junior has taken.",
|
||||
"newCode is what the full code looks like after applying your nextEditContent.",
|
||||
// "Make sure that newCode does not have errors. You are given the language, and you should know what the typescript compiler will complain about.",
|
||||
"Given the above definition of an action, you should prioritize fixing the following:",
|
||||
"- Patterns and repetition in code.",
|
||||
"- Static errors that the compiler of the language may return.",
|
||||
"- The junior's code style.",
|
||||
"If the junior has deleted some code, there's a good chance that the next edit will also be deletions.",
|
||||
"If the junior has added some code, there's a good chance that the next edit will also be additions.",
|
||||
"If the junior has performed an action on some part of the code, and you see similar code remaining, there's a good chance that the next edit will also target these remaining similar code.",
|
||||
"Careful of language intricacies.",
|
||||
// "Always try deletion and replacements. Add code if there are no other valid or reasonable edit actions.",
|
||||
"Do not reply in markdown.",
|
||||
"Do not hallucinate.",
|
||||
].join(" "),
|
||||
};
|
||||
}
|
||||
|
||||
export function renderDefaultUserPrompt(
|
||||
// originalCode: string,
|
||||
// editedCode: string,
|
||||
snippets: SnippetPayload,
|
||||
helper: HelperVars,
|
||||
): UserPrompt {
|
||||
const userEdit = {
|
||||
language: helper.lang,
|
||||
rootPathSnippets: snippets.rootPathSnippets,
|
||||
importDefinitionSnippets: snippets.importDefinitionSnippets,
|
||||
ideSnippets: snippets.ideSnippets,
|
||||
recentlyEditedRangeSnippets: snippets.recentlyEditedRangeSnippets,
|
||||
diffSnippets: snippets.diffSnippets,
|
||||
clipboardSnippets: snippets.clipboardSnippets,
|
||||
recentlyVisitedRangesSnippets: snippets.recentlyVisitedRangesSnippets,
|
||||
};
|
||||
|
||||
return {
|
||||
role: "user",
|
||||
content: `Your junior made the following edit: ${JSON.stringify(userEdit)}. What is the most possible next edit your junior ${helper.lang.name} developer will make?`,
|
||||
};
|
||||
}
|
||||
|
||||
function insertTokens(
|
||||
lines: string[],
|
||||
cursorPos: Position,
|
||||
cursorToken: string,
|
||||
editableRegionStart?: number,
|
||||
editableRegionEnd?: number,
|
||||
) {
|
||||
const a = insertCursorToken(lines, cursorPos, cursorToken);
|
||||
const b = insertEditableRegionTokensWithStaticRange(
|
||||
a,
|
||||
cursorPos,
|
||||
editableRegionStart,
|
||||
editableRegionEnd,
|
||||
);
|
||||
return b.join("\n");
|
||||
return template.template;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,239 +1,112 @@
|
|||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { Position } from "../..";
|
||||
import { SnippetPayload } from "../../autocomplete/snippets";
|
||||
import { AutocompleteSnippetType } from "../../autocomplete/snippets/types";
|
||||
import { HelperVars } from "../../autocomplete/util/HelperVars";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { NEXT_EDIT_MODELS } from "../../llm/constants";
|
||||
import {
|
||||
INSTINCT_USER_CURSOR_IS_HERE_TOKEN,
|
||||
INSTINCT_USER_PROMPT_PREFIX,
|
||||
MERCURY_CURRENT_FILE_CONTENT_CLOSE,
|
||||
MERCURY_CURRENT_FILE_CONTENT_OPEN,
|
||||
MERCURY_CURSOR,
|
||||
MERCURY_EDIT_DIFF_HISTORY_CLOSE,
|
||||
MERCURY_EDIT_DIFF_HISTORY_OPEN,
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE,
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN,
|
||||
} from "../constants";
|
||||
import {
|
||||
renderDefaultSystemPrompt,
|
||||
renderDefaultUserPrompt,
|
||||
renderPrompt,
|
||||
NEXT_EDIT_MODEL_TEMPLATES,
|
||||
PromptTemplateRenderer,
|
||||
getTemplateForModel,
|
||||
} from "./NextEditPromptEngine";
|
||||
|
||||
describe("NextEditPromptEngine", () => {
|
||||
describe("renderPrompt", () => {
|
||||
let mercuryHelper: HelperVars;
|
||||
let instinctHelper: HelperVars;
|
||||
let testHelper: HelperVars;
|
||||
let unsupportedHelper: HelperVars;
|
||||
let ctx: any;
|
||||
|
||||
beforeEach(() => {
|
||||
mercuryHelper = {
|
||||
modelName: "inception/mercury-coder-nextedit" as NEXT_EDIT_MODELS,
|
||||
fileContents: "function test() {\n const a = 1;\n return a;\n}",
|
||||
pos: { line: 1, character: 12 } as Position,
|
||||
lang: { name: "typescript" },
|
||||
} as HelperVars;
|
||||
instinctHelper = {
|
||||
modelName: "continuedev/instinct" as NEXT_EDIT_MODELS,
|
||||
fileContents: "function test() {\n const a = 1;\n return a;\n}",
|
||||
pos: { line: 1, character: 12 } as Position,
|
||||
lang: { name: "typescript" },
|
||||
} as HelperVars;
|
||||
unsupportedHelper = {
|
||||
modelName: "mistral/codestral" as NEXT_EDIT_MODELS,
|
||||
fileContents: "function test() {\n const a = 1;\n return a;\n}",
|
||||
pos: { line: 1, character: 12 } as Position,
|
||||
lang: { name: "typescript" },
|
||||
} as HelperVars;
|
||||
|
||||
ctx = {
|
||||
recentlyViewedCodeSnippets: [
|
||||
{ filepath: "/path/to/file1.ts", content: "const b = 2;" },
|
||||
],
|
||||
currentFileContent: "function test() {\n const a = 1;\n return a;\n}",
|
||||
editDiffHistory: ["diff --git a/file.ts b/file.ts\n@@ -1,3 +1,4 @@"],
|
||||
editableRegionStartLine: 0,
|
||||
editableRegionEndLine: 3,
|
||||
userEdits: "Added constant a",
|
||||
languageShorthand: "ts",
|
||||
userExcerpts: "const a = 1;",
|
||||
};
|
||||
});
|
||||
|
||||
it("should render mercury-coder-nextedit prompt correctly", async () => {
|
||||
const result = await renderPrompt(mercuryHelper, ctx);
|
||||
|
||||
expect(result).toHaveProperty("prompt");
|
||||
expect(result.prompt.role).toBe("user");
|
||||
|
||||
const content = result.prompt.content;
|
||||
expect(content).toContain(MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN);
|
||||
expect(content).toContain(MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE);
|
||||
expect(content).toContain(MERCURY_CURRENT_FILE_CONTENT_OPEN);
|
||||
expect(content).toContain(MERCURY_CURRENT_FILE_CONTENT_CLOSE);
|
||||
expect(content).toContain(MERCURY_EDIT_DIFF_HISTORY_OPEN);
|
||||
expect(content).toContain(MERCURY_EDIT_DIFF_HISTORY_CLOSE);
|
||||
|
||||
expect(result.userEdits).toBe(ctx.editDiffHistory);
|
||||
expect(result.userExcerpts).toContain(MERCURY_CURSOR);
|
||||
});
|
||||
|
||||
it("should render instinct prompt correctly", async () => {
|
||||
// Create proper instinct context structure matching NextEditProvider.ts
|
||||
const instinctCtx = {
|
||||
contextSnippets:
|
||||
"+++++ /path/to/context.ts\nconst contextVar = 'test';",
|
||||
currentFileContent: instinctHelper.fileContents,
|
||||
windowStart: 0, // Math.max(0, helper.pos.line - 25)
|
||||
windowEnd: 3, // Math.min(helper.fileLines.length - 1, helper.pos.line + 25)
|
||||
editableRegionStartLine: 0, // Math.max(0, helper.pos.line - 1) within window
|
||||
editableRegionEndLine: 2, // Math.min(helper.pos.line + 5) within window
|
||||
editDiffHistory: [
|
||||
"diff --git a/file.ts b/file.ts\nindex 123..456 789\n--- a/file.ts\n+++ b/file.ts\n@@ -1,3 +1,4 @@\n function test() {\n+ const a = 1;\n return a;\n }",
|
||||
], // unified diff
|
||||
currentFilePath: "/path/to/file.ts",
|
||||
languageShorthand: "ts",
|
||||
};
|
||||
|
||||
const result = await renderPrompt(instinctHelper, instinctCtx);
|
||||
console.log(result);
|
||||
|
||||
expect(result).toHaveProperty("prompt");
|
||||
expect(result.prompt.role).toBe("user");
|
||||
expect(result.prompt.content).toContain(INSTINCT_USER_PROMPT_PREFIX);
|
||||
expect(result.prompt.content).toContain("### Context:");
|
||||
expect(result.prompt.content).toContain("### User Edits:");
|
||||
expect(result.prompt.content).toContain("### User Excerpt:");
|
||||
|
||||
expect(result.userEdits).toBe(instinctCtx.editDiffHistory);
|
||||
expect(result.userExcerpts).toContain(INSTINCT_USER_CURSOR_IS_HERE_TOKEN);
|
||||
});
|
||||
|
||||
it("should throw error for unsupported model name", async () => {
|
||||
await expect(renderPrompt(unsupportedHelper, ctx)).rejects.toThrow(
|
||||
"mistral/codestral is not yet supported for next edit.",
|
||||
describe("NEXT_EDIT_MODEL_TEMPLATES", () => {
|
||||
it("should contain templates for all supported models", () => {
|
||||
expect(NEXT_EDIT_MODEL_TEMPLATES).toHaveProperty(
|
||||
NEXT_EDIT_MODELS.MERCURY_CODER,
|
||||
);
|
||||
expect(NEXT_EDIT_MODEL_TEMPLATES).toHaveProperty(
|
||||
NEXT_EDIT_MODELS.INSTINCT,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("renderDefaultSystemPrompt", () => {
|
||||
it("should return a system prompt with expected role and content", () => {
|
||||
const result = renderDefaultSystemPrompt();
|
||||
it("mercury-coder template should contain expected tokens", () => {
|
||||
const template =
|
||||
NEXT_EDIT_MODEL_TEMPLATES[NEXT_EDIT_MODELS.MERCURY_CODER].template;
|
||||
|
||||
expect(result.role).toBe("system");
|
||||
expect(result.content).toContain("You are an expert polyglot developer");
|
||||
expect(result.content).toContain("Do not hallucinate.");
|
||||
expect(template).toContain(MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN);
|
||||
expect(template).toContain(MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE);
|
||||
expect(template).toContain(MERCURY_CURRENT_FILE_CONTENT_OPEN);
|
||||
expect(template).toContain(MERCURY_CURRENT_FILE_CONTENT_CLOSE);
|
||||
expect(template).toContain(MERCURY_EDIT_DIFF_HISTORY_OPEN);
|
||||
expect(template).toContain(MERCURY_EDIT_DIFF_HISTORY_CLOSE);
|
||||
expect(template).toContain("{{{recentlyViewedCodeSnippets}}}");
|
||||
expect(template).toContain("{{{currentFileContent}}}");
|
||||
expect(template).toContain("{{{editDiffHistory}}}");
|
||||
});
|
||||
|
||||
it("instinct template should contain expected tokens", () => {
|
||||
const template =
|
||||
NEXT_EDIT_MODEL_TEMPLATES[NEXT_EDIT_MODELS.INSTINCT].template;
|
||||
|
||||
expect(template).toContain(INSTINCT_USER_PROMPT_PREFIX);
|
||||
expect(template).toContain("### Context:");
|
||||
expect(template).toContain("### User Edits:");
|
||||
expect(template).toContain("### User Excerpt:");
|
||||
expect(template).toContain("{{{contextSnippets}}}");
|
||||
expect(template).toContain("{{{currentFileContent}}}");
|
||||
expect(template).toContain("{{{editDiffHistory}}}");
|
||||
expect(template).toContain("{{{currentFilePath}}}");
|
||||
});
|
||||
});
|
||||
|
||||
describe("renderDefaultUserPrompt", () => {
|
||||
it("should render a user prompt with the correct structure", () => {
|
||||
const snippets: SnippetPayload = {
|
||||
rootPathSnippets: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Code,
|
||||
filepath: "",
|
||||
content: "root path",
|
||||
},
|
||||
],
|
||||
importDefinitionSnippets: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Code,
|
||||
filepath: "",
|
||||
content: "import def",
|
||||
},
|
||||
],
|
||||
ideSnippets: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Code,
|
||||
filepath: "",
|
||||
content: "ide snippets",
|
||||
},
|
||||
],
|
||||
recentlyEditedRangeSnippets: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Code,
|
||||
filepath: "",
|
||||
content: "recent edits",
|
||||
},
|
||||
],
|
||||
diffSnippets: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Diff,
|
||||
content: "diff snippets",
|
||||
},
|
||||
],
|
||||
clipboardSnippets: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Clipboard,
|
||||
content: "clipboard",
|
||||
copiedAt: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
recentlyVisitedRangesSnippets: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Code,
|
||||
filepath: "",
|
||||
content: "visited ranges",
|
||||
},
|
||||
],
|
||||
recentlyOpenedFileSnippets: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Code,
|
||||
filepath: "",
|
||||
content: "recently opened files",
|
||||
},
|
||||
],
|
||||
staticSnippet: [
|
||||
{
|
||||
type: AutocompleteSnippetType.Static,
|
||||
filepath: "",
|
||||
content: "static content",
|
||||
},
|
||||
],
|
||||
};
|
||||
describe("PromptTemplateRenderer", () => {
|
||||
it("should render a template with provided variables", () => {
|
||||
const template = "Hello {{{name}}}, you have {{{count}}} messages";
|
||||
const renderer = new PromptTemplateRenderer(template);
|
||||
|
||||
const helper: HelperVars = {
|
||||
lang: { name: "typescript" },
|
||||
} as HelperVars;
|
||||
|
||||
const result = renderDefaultUserPrompt(snippets, helper);
|
||||
|
||||
expect(result.role).toBe("user");
|
||||
expect(result.content).toContain("Your junior made the following edit:");
|
||||
expect(result.content).toContain("typescript");
|
||||
expect(result.content).toContain("root path");
|
||||
});
|
||||
});
|
||||
|
||||
describe("insertTokens", () => {
|
||||
it("should correctly insert cursor and editable region tokens", () => {
|
||||
const mercuryHelper = {
|
||||
modelName: "inception/mercury-coder-nextedit" as NEXT_EDIT_MODELS,
|
||||
fileContents: "function test() {\n const a = 1;\n return a;\n}",
|
||||
pos: { line: 1, character: 12 } as Position,
|
||||
lang: { name: "typescript" },
|
||||
} as HelperVars;
|
||||
|
||||
const ctx = {
|
||||
recentlyViewedCodeSnippets: [
|
||||
{ filepath: "/path/to/file1.ts", content: "const b = 2;" },
|
||||
],
|
||||
currentFileContent: "function test() {\n const a = 1;\n return a;\n}",
|
||||
editDiffHistory: ["diff --git a/file.ts b/file.ts\n@@ -1,3 +1,4 @@"],
|
||||
editableRegionStartLine: 0,
|
||||
editableRegionEndLine: 3,
|
||||
userEdits: "Added constant a",
|
||||
languageShorthand: "ts",
|
||||
userExcerpts: "const a = 1;",
|
||||
};
|
||||
|
||||
return renderPrompt(mercuryHelper, ctx).then((result) => {
|
||||
expect(result.userExcerpts).toContain(MERCURY_CURSOR);
|
||||
const result = renderer.render({
|
||||
name: "Alice",
|
||||
count: "5",
|
||||
});
|
||||
|
||||
expect(result).toBe("Hello Alice, you have 5 messages");
|
||||
});
|
||||
|
||||
it("should handle missing variables gracefully", () => {
|
||||
const template = "Hello {{{name}}}";
|
||||
const renderer = new PromptTemplateRenderer(template);
|
||||
|
||||
const result = renderer.render({});
|
||||
|
||||
expect(result).toBe("Hello ");
|
||||
});
|
||||
|
||||
it("should render complex templates correctly", () => {
|
||||
const template =
|
||||
NEXT_EDIT_MODEL_TEMPLATES[NEXT_EDIT_MODELS.MERCURY_CODER].template;
|
||||
const renderer = new PromptTemplateRenderer(template);
|
||||
|
||||
const result = renderer.render({
|
||||
recentlyViewedCodeSnippets: "snippet1",
|
||||
currentFileContent: "file content",
|
||||
editDiffHistory: "diff history",
|
||||
});
|
||||
|
||||
expect(result).toContain("snippet1");
|
||||
expect(result).toContain("file content");
|
||||
expect(result).toContain("diff history");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getTemplateForModel", () => {
|
||||
it("should return the correct template for a supported model", () => {
|
||||
const template = getTemplateForModel(NEXT_EDIT_MODELS.MERCURY_CODER);
|
||||
expect(template).toBe(
|
||||
NEXT_EDIT_MODEL_TEMPLATES[NEXT_EDIT_MODELS.MERCURY_CODER].template,
|
||||
);
|
||||
});
|
||||
|
||||
it("should throw an error for an unsupported model", () => {
|
||||
expect(() =>
|
||||
getTemplateForModel("unsupported" as NEXT_EDIT_MODELS),
|
||||
).toThrow("Model unsupported is not supported for next edit.");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import {
|
|||
MERCURY_CODE_TO_EDIT_CLOSE,
|
||||
MERCURY_CODE_TO_EDIT_OPEN,
|
||||
MERCURY_CURSOR,
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_CLOSE,
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_OPEN,
|
||||
} from "../constants";
|
||||
import { insertCursorToken } from "./utils";
|
||||
|
||||
|
|
@ -11,8 +13,10 @@ export function recentlyViewedCodeSnippetsBlock(
|
|||
) {
|
||||
return recentlyViewedCodeSnippets.reduce((acc, snippet, i) => {
|
||||
const block = [
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_OPEN,
|
||||
`code_snippet_file_path: ${snippet.filepath}`,
|
||||
snippet.content,
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_CLOSE,
|
||||
].join("\n");
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import {
|
|||
MERCURY_CODE_TO_EDIT_CLOSE,
|
||||
MERCURY_CODE_TO_EDIT_OPEN,
|
||||
MERCURY_CURSOR,
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_CLOSE,
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_OPEN,
|
||||
} from "../constants";
|
||||
import {
|
||||
currentFileContentBlock,
|
||||
|
|
@ -25,10 +27,14 @@ describe("mercuryCoderNextEdit", () => {
|
|||
const result = recentlyViewedCodeSnippetsBlock(snippets);
|
||||
|
||||
const expected =
|
||||
`${MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_OPEN}\n` +
|
||||
"code_snippet_file_path: /path/to/file1.ts\n" +
|
||||
"const a = 1;\n" +
|
||||
`${MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_CLOSE}\n` +
|
||||
`${MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_OPEN}\n` +
|
||||
"code_snippet_file_path: /path/to/file2.ts\n" +
|
||||
"function test() { return true; }";
|
||||
"function test() { return true; }\n" +
|
||||
MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_CLOSE;
|
||||
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import {
|
|||
RangeInFile,
|
||||
TabAutocompleteOptions,
|
||||
} from "../";
|
||||
import { SnippetPayload } from "../autocomplete/snippets";
|
||||
import { AutocompleteCodeSnippet } from "../autocomplete/snippets/types";
|
||||
import { HelperVars } from "../autocomplete/util/HelperVars";
|
||||
|
||||
export type RecentlyEditedRange = RangeInFile & {
|
||||
timestamp: number;
|
||||
|
|
@ -61,6 +63,7 @@ export interface NextEditOutcome extends TabAutocompleteOptions {
|
|||
cursorPosition: { line: number; character: number };
|
||||
finalCursorPosition: { line: number; character: number };
|
||||
accepted?: boolean;
|
||||
aborted?: boolean;
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
diffLines: DiffLine[];
|
||||
|
|
@ -104,3 +107,36 @@ export interface MercuryTemplateVars extends TemplateVars {
|
|||
editDiffHistory: string; // could be a singe large unified diff
|
||||
currentFilePath: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context object containing all necessary information for model-specific operations.
|
||||
*/
|
||||
export interface ModelSpecificContext {
|
||||
helper: HelperVars;
|
||||
snippetPayload: SnippetPayload;
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
diffContext: string[];
|
||||
autocompleteContext: string;
|
||||
historyDiff?: string;
|
||||
workspaceDirs?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for editable region calculation.
|
||||
*/
|
||||
export interface EditableRegionConfig {
|
||||
usingFullFileDiff?: boolean;
|
||||
maxTokens?: number;
|
||||
topMargin?: number;
|
||||
bottomMargin?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for prompt generation.
|
||||
*/
|
||||
export interface PromptConfig {
|
||||
includeHistory?: boolean;
|
||||
includeRecentEdits?: boolean;
|
||||
maxContextSnippets?: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { DiffLine } from "..";
|
||||
import { NEXT_EDIT_MODELS } from "../llm/constants";
|
||||
|
||||
export function isNextEditTest(): boolean {
|
||||
const enabled = process.env.NEXT_EDIT_TEST_ENABLED;
|
||||
|
|
@ -21,3 +22,11 @@ export function isWhitespaceOnlyDeletion(diffLines: DiffLine[]): boolean {
|
|||
(diff.line.trim() === "" || /^\s+$/.test(diff.line)),
|
||||
);
|
||||
}
|
||||
|
||||
export function convertNextEditModelNameToEnum(
|
||||
modelName: string,
|
||||
): NEXT_EDIT_MODELS | undefined {
|
||||
const nextEditModels = Object.values(NEXT_EDIT_MODELS);
|
||||
|
||||
return nextEditModels.find((model) => modelName.includes(model));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { describe, expect, test, vi } from "vitest";
|
||||
import { DiffLine } from "..";
|
||||
import { isNextEditTest, isWhitespaceOnlyDeletion } from "./utils";
|
||||
import { NEXT_EDIT_MODELS } from "../llm/constants";
|
||||
import {
|
||||
convertNextEditModelNameToEnum,
|
||||
isNextEditTest,
|
||||
isWhitespaceOnlyDeletion,
|
||||
} from "./utils";
|
||||
|
||||
describe("isNextEditTest", () => {
|
||||
test("returns true when NEXT_EDIT_TEST_ENABLED is 'true'", () => {
|
||||
|
|
@ -57,3 +62,35 @@ describe("isWhitespaceOnlyDeletion", () => {
|
|||
expect(isWhitespaceOnlyDeletion(diffLines)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("convertNextEditModelNameToEnum", () => {
|
||||
test("returns correct enum for exact matches", () => {
|
||||
Object.values(NEXT_EDIT_MODELS).forEach((model) => {
|
||||
expect(convertNextEditModelNameToEnum(model)).toBe(model);
|
||||
});
|
||||
});
|
||||
|
||||
test("returns correct enum when model name is contained in a longer string", () => {
|
||||
expect(convertNextEditModelNameToEnum("inception/mercury-coder")).toBe(
|
||||
NEXT_EDIT_MODELS.MERCURY_CODER,
|
||||
);
|
||||
expect(convertNextEditModelNameToEnum("blah/instinct")).toBe(
|
||||
NEXT_EDIT_MODELS.INSTINCT,
|
||||
);
|
||||
});
|
||||
|
||||
test("returns undefined for non-matching model names", () => {
|
||||
expect(convertNextEditModelNameToEnum("unknown-model")).toBeUndefined();
|
||||
expect(convertNextEditModelNameToEnum("random-string")).toBeUndefined();
|
||||
expect(convertNextEditModelNameToEnum("")).toBeUndefined();
|
||||
});
|
||||
|
||||
test("returns first match when multiple models could match", () => {
|
||||
const modelName = "model-that-contains-multiple-matches";
|
||||
const result = convertNextEditModelNameToEnum(modelName);
|
||||
|
||||
if (result !== undefined) {
|
||||
expect(Object.values(NEXT_EDIT_MODELS)).toContain(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
453
core/package-lock.json
generated
453
core/package-lock.json
generated
|
|
@ -25,7 +25,6 @@
|
|||
"@sentry/esbuild-plugin": "^4.0.2",
|
||||
"@sentry/node": "^9.43.0",
|
||||
"@sentry/vite-plugin": "^4.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
"@xenova/transformers": "2.14.0",
|
||||
"adf-to-md": "^1.1.0",
|
||||
"async-mutex": "^0.5.0",
|
||||
|
|
@ -44,7 +43,7 @@
|
|||
"http-proxy-agent": "^7.0.1",
|
||||
"https-proxy-agent": "^7.0.3",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ignore": "^5.3.1",
|
||||
"ignore": "^7.0.5",
|
||||
"is-localhost-ip": "^2.0.0",
|
||||
"jinja-js": "0.1.8",
|
||||
"js-tiktoken": "^1.0.8",
|
||||
|
|
@ -57,7 +56,7 @@
|
|||
"node-html-markdown": "^1.3.0",
|
||||
"ollama": "^0.4.6",
|
||||
"onnxruntime-node": "1.14.0",
|
||||
"openai": "^4.104.0",
|
||||
"openai": "^5.13.1",
|
||||
"p-limit": "^6.1.0",
|
||||
"partial-json": "^0.1.7",
|
||||
"pg": "^8.11.3",
|
||||
|
|
@ -105,6 +104,8 @@
|
|||
"@types/tar": "^6.1.13",
|
||||
"@types/uuid": "^9.0.7",
|
||||
"@types/win-ca": "^3.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
||||
"@typescript-eslint/parser": "^8.40.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild": "0.17.19",
|
||||
"eslint": "^8",
|
||||
|
|
@ -201,19 +202,19 @@
|
|||
},
|
||||
"../packages/openai-adapters": {
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.1.1",
|
||||
"version": "1.5.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.842.0",
|
||||
"@aws-sdk/credential-providers": "^3.840.0",
|
||||
"@continuedev/config-types": "file:../config-types",
|
||||
"@continuedev/config-yaml": "file:../config-yaml",
|
||||
"@continuedev/fetch": "file:../fetch",
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"@continuedev/config-yaml": "^1.8.0",
|
||||
"@continuedev/fetch": "^1.0.16",
|
||||
"dotenv": "^16.5.0",
|
||||
"google-auth-library": "^10.1.0",
|
||||
"json-schema": "^0.4.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"openai": "^4.104.0",
|
||||
"openai": "^5.13.1",
|
||||
"uuid": "^11.1.0",
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
|
|
@ -227,6 +228,7 @@
|
|||
"@types/follow-redirects": "^1.14.4",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/json-schema": "^7.0.15",
|
||||
"@types/node": "^24.3.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"semantic-release": "^24.2.7",
|
||||
"ts-jest": "^29.2.3",
|
||||
|
|
@ -3388,9 +3390,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@eslint-community/eslint-utils": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz",
|
||||
"integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==",
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz",
|
||||
"integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"eslint-visitor-keys": "^3.4.3"
|
||||
},
|
||||
|
|
@ -3458,6 +3461,15 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/ignore": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||
"integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
|
|
@ -6789,6 +6801,7 @@
|
|||
"version": "2.6.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.12.tgz",
|
||||
"integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^4.0.0"
|
||||
|
|
@ -6974,113 +6987,150 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.18.0.tgz",
|
||||
"integrity": "sha512-94EQTWZ40mzBc42ATNIBimBEDltSJ9RQHCC8vc/PDbxi4k8dVwUAv4o98dk50M1zB+JGFxp43FP7f8+FP8R6Sw==",
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.40.0.tgz",
|
||||
"integrity": "sha512-w/EboPlBwnmOBtRbiOvzjD+wdiZdgFeo17lkltrtn7X37vagKKWJABvyfsJXTlHe6XBzugmYgd4A4nW+k8Mixw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.10.0",
|
||||
"@typescript-eslint/scope-manager": "7.18.0",
|
||||
"@typescript-eslint/type-utils": "7.18.0",
|
||||
"@typescript-eslint/utils": "7.18.0",
|
||||
"@typescript-eslint/visitor-keys": "7.18.0",
|
||||
"@typescript-eslint/scope-manager": "8.40.0",
|
||||
"@typescript-eslint/type-utils": "8.40.0",
|
||||
"@typescript-eslint/utils": "8.40.0",
|
||||
"@typescript-eslint/visitor-keys": "8.40.0",
|
||||
"graphemer": "^1.4.0",
|
||||
"ignore": "^5.3.1",
|
||||
"ignore": "^7.0.0",
|
||||
"natural-compare": "^1.4.0",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
"ts-api-utils": "^2.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/parser": "^7.0.0",
|
||||
"eslint": "^8.56.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"@typescript-eslint/parser": "^8.40.0",
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.18.0.tgz",
|
||||
"integrity": "sha512-4Z+L8I2OqhZV8qA132M4wNL30ypZGYOQVBfMgxDH/K5UX0PNqTu1c6za9ST5r9+tavvHiTWmBnKzpCJ/GlVFtg==",
|
||||
"peer": true,
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.40.0.tgz",
|
||||
"integrity": "sha512-jCNyAuXx8dr5KJMkecGmZ8KI61KBUhkCob+SD+C+I5+Y1FWI2Y3QmY4/cxMCC5WAsZqoEtEETVhUiUMIGCf6Bw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "7.18.0",
|
||||
"@typescript-eslint/types": "7.18.0",
|
||||
"@typescript-eslint/typescript-estree": "7.18.0",
|
||||
"@typescript-eslint/visitor-keys": "7.18.0",
|
||||
"@typescript-eslint/scope-manager": "8.40.0",
|
||||
"@typescript-eslint/types": "8.40.0",
|
||||
"@typescript-eslint/typescript-estree": "8.40.0",
|
||||
"@typescript-eslint/visitor-keys": "8.40.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.56.0"
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/project-service": {
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.40.0.tgz",
|
||||
"integrity": "sha512-/A89vz7Wf5DEXsGVvcGdYKbVM9F7DyFXj52lNYUDS1L9yJfqjW/fIp5PgMuEJL/KeqVTe2QSbXAGUZljDUpArw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/tsconfig-utils": "^8.40.0",
|
||||
"@typescript-eslint/types": "^8.40.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.18.0.tgz",
|
||||
"integrity": "sha512-jjhdIE/FPF2B7Z1uzc6i3oWKbGcHb87Qw7AWj6jmEqNOfDFbJWtjt/XfwCpvNkpGWlcJaog5vTR+VV8+w9JflA==",
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.40.0.tgz",
|
||||
"integrity": "sha512-y9ObStCcdCiZKzwqsE8CcpyuVMwRouJbbSrNuThDpv16dFAj429IkM6LNb1dZ2m7hK5fHyzNcErZf7CEeKXR4w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.18.0",
|
||||
"@typescript-eslint/visitor-keys": "7.18.0"
|
||||
"@typescript-eslint/types": "8.40.0",
|
||||
"@typescript-eslint/visitor-keys": "8.40.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.18.0.tgz",
|
||||
"integrity": "sha512-XL0FJXuCLaDuX2sYqZUUSOJ2sG5/i1AAze+axqmLnSkNEVMVYLF+cbwlB2w8D1tinFuSikHmFta+P+HOofrLeA==",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/typescript-estree": "7.18.0",
|
||||
"@typescript-eslint/utils": "7.18.0",
|
||||
"debug": "^4.3.4",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
},
|
||||
"node_modules/@typescript-eslint/tsconfig-utils": {
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.40.0.tgz",
|
||||
"integrity": "sha512-jtMytmUaG9d/9kqSl/W3E3xaWESo4hFDxAIHGVW/WKKtQhesnRIJSAJO6XckluuJ6KDB5woD1EiqknriCtAmcw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.56.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.40.0.tgz",
|
||||
"integrity": "sha512-eE60cK4KzAc6ZrzlJnflXdrMqOBaugeukWICO2rB0KNvwdIMaEaYiywwHMzA1qFpTxrLhN9Lp4E/00EgWcD3Ow==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.40.0",
|
||||
"@typescript-eslint/typescript-estree": "8.40.0",
|
||||
"@typescript-eslint/utils": "8.40.0",
|
||||
"debug": "^4.3.4",
|
||||
"ts-api-utils": "^2.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.18.0.tgz",
|
||||
"integrity": "sha512-iZqi+Ds1y4EDYUtlOOC+aUmxnE9xS/yCigkjA7XpTKV6nCBd3Hp/PRGGmdwnfkV2ThMyYldP1wRpm/id99spTQ==",
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.40.0.tgz",
|
||||
"integrity": "sha512-ETdbFlgbAmXHyFPwqUIYrfc12ArvpBhEVgGAxVYSwli26dn8Ko+lIo4Su9vI9ykTZdJn+vJprs/0eZU0YMAEQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
|
|
@ -7088,36 +7138,40 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.18.0.tgz",
|
||||
"integrity": "sha512-aP1v/BSPnnyhMHts8cf1qQ6Q1IFwwRvAQGRvBFkWlo3/lH29OXA3Pts+c10nxRxIBrDnoMqzhgdwVe5f2D6OzA==",
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.40.0.tgz",
|
||||
"integrity": "sha512-k1z9+GJReVVOkc1WfVKs1vBrR5MIKKbdAjDTPvIK3L8De6KbFfPFt6BKpdkdk7rZS2GtC/m6yI5MYX+UsuvVYQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.18.0",
|
||||
"@typescript-eslint/visitor-keys": "7.18.0",
|
||||
"@typescript-eslint/project-service": "8.40.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.40.0",
|
||||
"@typescript-eslint/types": "8.40.0",
|
||||
"@typescript-eslint/visitor-keys": "8.40.0",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"fast-glob": "^3.3.2",
|
||||
"is-glob": "^4.0.3",
|
||||
"minimatch": "^9.0.4",
|
||||
"semver": "^7.6.0",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
"ts-api-utils": "^2.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
|
||||
"version": "7.6.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz",
|
||||
"integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==",
|
||||
"version": "7.7.2",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
||||
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
|
|
@ -7126,42 +7180,60 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.18.0.tgz",
|
||||
"integrity": "sha512-kK0/rNa2j74XuHVcoCZxdFBMF+aq/vH83CXAOHieC+2Gis4mF8jJXT5eAfyD3K0sAxtPuwxaIOIOvhwzVDt/kw==",
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.40.0.tgz",
|
||||
"integrity": "sha512-Cgzi2MXSZyAUOY+BFwGs17s7ad/7L+gKt6Y8rAVVWS+7o6wrjeFN4nVfTpbE25MNcxyJ+iYUXflbs2xR9h4UBg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "7.18.0",
|
||||
"@typescript-eslint/types": "7.18.0",
|
||||
"@typescript-eslint/typescript-estree": "7.18.0"
|
||||
"@eslint-community/eslint-utils": "^4.7.0",
|
||||
"@typescript-eslint/scope-manager": "8.40.0",
|
||||
"@typescript-eslint/types": "8.40.0",
|
||||
"@typescript-eslint/typescript-estree": "8.40.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.56.0"
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.18.0.tgz",
|
||||
"integrity": "sha512-cDF0/Gf81QpY3xYyJKDV14Zwdmid5+uuENhjH2EqFaF0ni+yAyq/LzMaIJdhNJXZI7uLzwIlA+V7oWoyn6Curg==",
|
||||
"version": "8.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.40.0.tgz",
|
||||
"integrity": "sha512-8CZ47QwalyRjsypfwnbI3hKy5gJDPmrkLjkgMxhi0+DZZ2QNx2naS6/hWoVYUHU7LU2zleF68V9miaVZvhFfTA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.18.0",
|
||||
"eslint-visitor-keys": "^3.4.3"
|
||||
"@typescript-eslint/types": "8.40.0",
|
||||
"eslint-visitor-keys": "^4.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
|
||||
"integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@ungap/structured-clone": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.1.tgz",
|
||||
|
|
@ -7439,6 +7511,7 @@
|
|||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz",
|
||||
"integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"humanize-ms": "^1.2.1"
|
||||
},
|
||||
|
|
@ -7632,14 +7705,6 @@
|
|||
"resolved": "https://registry.npmjs.org/array-timsort/-/array-timsort-1.0.3.tgz",
|
||||
"integrity": "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ=="
|
||||
},
|
||||
"node_modules/array-union": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
|
||||
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/array.prototype.findlastindex": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.5.tgz",
|
||||
|
|
@ -9430,17 +9495,6 @@
|
|||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dir-glob": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
|
||||
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
|
||||
"dependencies": {
|
||||
"path-type": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/doctrine": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
|
||||
|
|
@ -10575,6 +10629,15 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/ignore": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||
"integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
|
|
@ -10927,15 +10990,17 @@
|
|||
"integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ=="
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
|
||||
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
|
||||
"integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@nodelib/fs.stat": "^2.0.2",
|
||||
"@nodelib/fs.walk": "^1.2.3",
|
||||
"glob-parent": "^5.1.2",
|
||||
"merge2": "^1.3.0",
|
||||
"micromatch": "^4.0.4"
|
||||
"micromatch": "^4.0.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.6.0"
|
||||
|
|
@ -10945,6 +11010,8 @@
|
|||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"is-glob": "^4.0.1"
|
||||
},
|
||||
|
|
@ -11243,31 +11310,6 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/form-data-encoder": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz",
|
||||
"integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A=="
|
||||
},
|
||||
"node_modules/formdata-node": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz",
|
||||
"integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==",
|
||||
"dependencies": {
|
||||
"node-domexception": "1.0.0",
|
||||
"web-streams-polyfill": "4.0.0-beta.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.20"
|
||||
}
|
||||
},
|
||||
"node_modules/formdata-node/node_modules/web-streams-polyfill": {
|
||||
"version": "4.0.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz",
|
||||
"integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==",
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/formdata-polyfill": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||
|
|
@ -11683,25 +11725,6 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"dependencies": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/google-auth-library": {
|
||||
"version": "9.15.0",
|
||||
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.15.0.tgz",
|
||||
|
|
@ -12120,6 +12143,7 @@
|
|||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
|
||||
"integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"ms": "^2.0.0"
|
||||
}
|
||||
|
|
@ -12155,9 +12179,10 @@
|
|||
]
|
||||
},
|
||||
"node_modules/ignore": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||
"integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==",
|
||||
"version": "7.0.5",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz",
|
||||
"integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
}
|
||||
|
|
@ -14499,6 +14524,8 @@
|
|||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
|
||||
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
|
|
@ -14601,6 +14628,7 @@
|
|||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"braces": "^3.0.3",
|
||||
"picomatch": "^2.3.1"
|
||||
|
|
@ -15526,18 +15554,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/openai": {
|
||||
"version": "4.104.0",
|
||||
"resolved": "https://registry.npmjs.org/openai/-/openai-4.104.0.tgz",
|
||||
"integrity": "sha512-p99EFNsA/yX6UhVO93f5kJsDRLAg+CTA2RBqdHK4RtK8u5IJw32Hyb2dTGKbnnFmnuoBv5r7Z2CURI9sGZpSuA==",
|
||||
"dependencies": {
|
||||
"@types/node": "^18.11.18",
|
||||
"@types/node-fetch": "^2.6.4",
|
||||
"abort-controller": "^3.0.0",
|
||||
"agentkeepalive": "^4.2.1",
|
||||
"form-data-encoder": "1.7.2",
|
||||
"formdata-node": "^4.3.2",
|
||||
"node-fetch": "^2.6.7"
|
||||
},
|
||||
"version": "5.13.1",
|
||||
"resolved": "https://registry.npmjs.org/openai/-/openai-5.13.1.tgz",
|
||||
"integrity": "sha512-Jty97Apw40znKSlXZL2YDap1U2eN9NfXbqm/Rj1rExeOLEnhwezpKQ+v43kIqojavUgm30SR3iuvGlNEBR+AFg==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"openai": "bin/cli"
|
||||
},
|
||||
|
|
@ -15554,52 +15574,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/openai/node_modules/@types/node": {
|
||||
"version": "18.19.67",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.67.tgz",
|
||||
"integrity": "sha512-wI8uHusga+0ZugNp0Ol/3BqQfEcCCNfojtO6Oou9iVNGPTL6QNSdnUdqq85fRgIorLhLMuPIKpsN98QE9Nh+KQ==",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"node_modules/openai/node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/openai/node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||
},
|
||||
"node_modules/openai/node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
||||
},
|
||||
"node_modules/openai/node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.9.4",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
|
||||
|
|
@ -15880,14 +15854,6 @@
|
|||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/path-type": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
|
||||
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pathe": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
|
||||
|
|
@ -17663,6 +17629,7 @@
|
|||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
|
||||
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
|
|
@ -18653,14 +18620,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/ts-api-utils": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.3.tgz",
|
||||
"integrity": "sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==",
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz",
|
||||
"integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.2.0"
|
||||
"typescript": ">=4.8.4"
|
||||
}
|
||||
},
|
||||
"node_modules/ts-jest": {
|
||||
|
|
@ -18924,6 +18893,7 @@
|
|||
"version": "5.7.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
|
||||
"integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
|
||||
"devOptional": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
|
@ -19009,11 +18979,6 @@
|
|||
"node": ">=18.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "5.26.5",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
|
||||
},
|
||||
"node_modules/unicode-canonical-property-names-ecmascript": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
"vitest": "vitest run",
|
||||
"test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage && open ./coverage/lcov-report/index.html",
|
||||
"tsc:check": "tsc -p ./ --noEmit",
|
||||
"build:npm": "tsc -p ./tsconfig.npm.json && npm run sentry:sourcemaps",
|
||||
"build": "tsc -p ./tsconfig.npm.json",
|
||||
"build:npm": "npm run build && npm run sentry:sourcemaps",
|
||||
"lint": "eslint . --ext ts",
|
||||
"lint:fix": "eslint . --ext ts --fix",
|
||||
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org continue-xd --project continue ./dist && sentry-cli sourcemaps upload --org continue-xd --project continue ./dist"
|
||||
|
|
@ -36,6 +37,8 @@
|
|||
"@types/tar": "^6.1.13",
|
||||
"@types/uuid": "^9.0.7",
|
||||
"@types/win-ca": "^3.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
||||
"@typescript-eslint/parser": "^8.40.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild": "0.17.19",
|
||||
"eslint": "^8",
|
||||
|
|
@ -66,7 +69,6 @@
|
|||
"@sentry/esbuild-plugin": "^4.0.2",
|
||||
"@sentry/node": "^9.43.0",
|
||||
"@sentry/vite-plugin": "^4.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
"@xenova/transformers": "2.14.0",
|
||||
"adf-to-md": "^1.1.0",
|
||||
"async-mutex": "^0.5.0",
|
||||
|
|
@ -85,7 +87,7 @@
|
|||
"http-proxy-agent": "^7.0.1",
|
||||
"https-proxy-agent": "^7.0.3",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ignore": "^5.3.1",
|
||||
"ignore": "^7.0.5",
|
||||
"is-localhost-ip": "^2.0.0",
|
||||
"jinja-js": "0.1.8",
|
||||
"js-tiktoken": "^1.0.8",
|
||||
|
|
@ -98,7 +100,7 @@
|
|||
"node-html-markdown": "^1.3.0",
|
||||
"ollama": "^0.4.6",
|
||||
"onnxruntime-node": "1.14.0",
|
||||
"openai": "^4.104.0",
|
||||
"openai": "^5.13.1",
|
||||
"p-limit": "^6.1.0",
|
||||
"partial-json": "^0.1.7",
|
||||
"pg": "^8.11.3",
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
"docs/getSuggestedDocs": [undefined, void];
|
||||
"docs/initStatuses": [undefined, void];
|
||||
"docs/getDetails": [{ startUrl: string }, DocsIndexingDetails];
|
||||
"docs/getIndexedPages": [{ startUrl: string }, string[]];
|
||||
addAutocompleteModel: [{ model: ModelDescription }, void];
|
||||
|
||||
"auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }];
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"indexing/setPaused",
|
||||
"docs/initStatuses",
|
||||
"docs/getDetails",
|
||||
"docs/getIndexedPages",
|
||||
//
|
||||
"onboarding/complete",
|
||||
"addAutocompleteModel",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ export enum BuiltInToolNames {
|
|||
ReadFile = "read_file",
|
||||
EditExistingFile = "edit_existing_file",
|
||||
SearchAndReplaceInFile = "search_and_replace_in_file",
|
||||
SingleFindAndReplace = "single_find_and_replace",
|
||||
MultiEdit = "multi_edit",
|
||||
ReadCurrentlyOpenFile = "read_currently_open_file",
|
||||
CreateNewFile = "create_new_file",
|
||||
RunTerminalCommand = "run_terminal_command",
|
||||
|
|
@ -25,4 +27,6 @@ export const BUILT_IN_GROUP_NAME = "Built-In";
|
|||
export const CLIENT_TOOLS_IMPLS = [
|
||||
BuiltInToolNames.EditExistingFile,
|
||||
BuiltInToolNames.SearchAndReplaceInFile,
|
||||
BuiltInToolNames.SingleFindAndReplace,
|
||||
BuiltInToolNames.MultiEdit,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ export { fetchUrlContentTool } from "./fetchUrlContent";
|
|||
export { globSearchTool } from "./globSearch";
|
||||
export { grepSearchTool } from "./grepSearch";
|
||||
export { lsTool } from "./ls";
|
||||
export { multiEditTool } from "./multiEdit";
|
||||
export { readCurrentlyOpenFileTool } from "./readCurrentlyOpenFile";
|
||||
export { readFileTool } from "./readFile";
|
||||
export { requestRuleTool } from "./requestRule";
|
||||
export { runTerminalCommandTool } from "./runTerminalCommand";
|
||||
export { searchAndReplaceInFileTool } from "./searchAndReplaceInFile";
|
||||
export { searchWebTool } from "./searchWeb";
|
||||
export { singleFindAndReplaceTool } from "./singleFindAndReplace";
|
||||
export { viewDiffTool } from "./viewDiff";
|
||||
export { viewRepoMapTool } from "./viewRepoMap";
|
||||
export { viewSubdirectoryTool } from "./viewSubdirectory";
|
||||
|
|
|
|||
131
core/tools/definitions/multiEdit.ts
Normal file
131
core/tools/definitions/multiEdit.ts
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
import { Tool } from "../..";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export interface EditOperation {
|
||||
old_string: string;
|
||||
new_string: string;
|
||||
replace_all?: boolean;
|
||||
}
|
||||
|
||||
export interface MultiEditArgs {
|
||||
filepath: string;
|
||||
edits: EditOperation[];
|
||||
}
|
||||
|
||||
export const multiEditTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Multi Edit",
|
||||
wouldLikeTo: "edit {{{ filepath }}}",
|
||||
isCurrently: "editing {{{ filepath }}}",
|
||||
hasAlready: "edited {{{ filepath }}}",
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
readonly: false,
|
||||
isInstant: false,
|
||||
function: {
|
||||
name: BuiltInToolNames.MultiEdit,
|
||||
description: `This is a tool for making multiple edits to a single file in one operation. It
|
||||
is built on top of the single find and replace tool and allows you to perform multiple
|
||||
find-and-replace operations efficiently. Prefer this tool over the single find and replace tool
|
||||
when you need to make multiple edits to the same file.
|
||||
|
||||
Before using this tool:
|
||||
|
||||
1. Use the read_file tool to understand the file's contents and context
|
||||
2. Verify the directory path is correct
|
||||
|
||||
To make multiple file edits, provide the following:
|
||||
|
||||
1. filepath: The path to the file to modify (relative to the root of the workspace)
|
||||
2. edits: An array of edit operations to perform, where each edit contains:
|
||||
- old_string: The text to replace (must match the file contents exactly, including all whitespace and indentation)
|
||||
- new_string: The edited text to replace the old_string
|
||||
- replace_all: Replace all occurrences of old_string. This parameter is optional and defaults to false.
|
||||
|
||||
IMPORTANT:
|
||||
- All edits are applied in sequence, in the order they are provided
|
||||
- Each edit operates on the result of the previous edit
|
||||
- All edits must be valid for the operation to succeed - if any edit fails,
|
||||
none will be applied
|
||||
- This tool is ideal when you need to make several changes to different parts
|
||||
of the same file
|
||||
|
||||
CRITICAL REQUIREMENTS:
|
||||
|
||||
1. All edits follow the same requirements as the single find and replace tool
|
||||
2. The edits are atomic - either all succeed or none are applied
|
||||
3. Plan your edits carefully to avoid conflicts between sequential operations
|
||||
|
||||
WARNING:
|
||||
|
||||
- The tool will fail if edits.old_string doesn't match the file contents
|
||||
exactly (including whitespace)
|
||||
- The tool will fail if edits.old_string and edits.new_string are the same
|
||||
- Since edits are applied in sequence, ensure that earlier edits don't affect
|
||||
the text that later edits are trying to find
|
||||
|
||||
When making edits:
|
||||
|
||||
- Ensure all edits result in idiomatic, correct code
|
||||
- Do not leave the code in a broken state
|
||||
- Only use emojis if the user explicitly requests it. Avoid adding emojis to
|
||||
files unless asked.
|
||||
- Use replace_all for replacing and renaming strings across the file. This
|
||||
parameter is useful if you want to rename a variable for instance.
|
||||
|
||||
If you want to create a new file, use:
|
||||
- A new file path
|
||||
- First edit: empty old_string and the new file's contents as new_string
|
||||
- Subsequent edits are not allowed - there is no need since you are creating`,
|
||||
parameters: {
|
||||
type: "object",
|
||||
required: ["filepath", "edits"],
|
||||
properties: {
|
||||
filepath: {
|
||||
type: "string",
|
||||
description:
|
||||
"The path to the file to modify, relative to the root of the workspace",
|
||||
},
|
||||
edits: {
|
||||
type: "array",
|
||||
description:
|
||||
"Array of edit operations to perform sequentially on the file",
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["old_string", "new_string"],
|
||||
properties: {
|
||||
old_string: {
|
||||
type: "string",
|
||||
description: "The text to replace",
|
||||
},
|
||||
new_string: {
|
||||
type: "string",
|
||||
description: "The text to replace it with",
|
||||
},
|
||||
replace_all: {
|
||||
type: "boolean",
|
||||
description:
|
||||
"Replace all occurrences of old_string (default false)",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
systemMessageDescription: {
|
||||
prefix: `To make multiple edits to a single file, use the ${BuiltInToolNames.MultiEdit} tool with a filepath (relative to the root of the workspace) and an array of edit operations.
|
||||
|
||||
For example, you could respond with:`,
|
||||
exampleArgs: [
|
||||
["filepath", "path/to/file.ts"],
|
||||
[
|
||||
"edits",
|
||||
`[
|
||||
{ "old_string": "const oldVar = 'value'", "new_string": "const newVar = 'updated'" },
|
||||
{ "old_string": "oldFunction()", "new_string": "newFunction()", "replace_all": true }
|
||||
]`,
|
||||
],
|
||||
],
|
||||
},
|
||||
defaultToolPolicy: "allowedWithPermission",
|
||||
};
|
||||
|
|
@ -13,7 +13,7 @@ export const readCurrentlyOpenFileTool: Tool = {
|
|||
function: {
|
||||
name: BuiltInToolNames.ReadCurrentlyOpenFile,
|
||||
description:
|
||||
"Read the currently open file in the IDE. If the user seems to be referring to a file that you can't see, try using this",
|
||||
"Read the currently open file in the IDE. If the user seems to be referring to a file that you can't see, or is requesting an action on content that seems missing, try using this tool.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {},
|
||||
|
|
|
|||
84
core/tools/definitions/singleFindAndReplace.ts
Normal file
84
core/tools/definitions/singleFindAndReplace.ts
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
import { Tool } from "../..";
|
||||
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
||||
|
||||
export interface SingleFindAndReplaceArgs {
|
||||
filepath: string;
|
||||
old_string: string;
|
||||
new_string: string;
|
||||
replace_all?: boolean;
|
||||
}
|
||||
|
||||
export const singleFindAndReplaceTool: Tool = {
|
||||
type: "function",
|
||||
displayTitle: "Find and Replace",
|
||||
wouldLikeTo: "find and replace in {{{ filepath }}}",
|
||||
isCurrently: "finding and replacing in {{{ filepath }}}",
|
||||
hasAlready: "found and replaced in {{{ filepath }}}",
|
||||
group: BUILT_IN_GROUP_NAME,
|
||||
readonly: false,
|
||||
isInstant: false,
|
||||
function: {
|
||||
name: BuiltInToolNames.SingleFindAndReplace,
|
||||
description: `Performs exact string replacements in files.
|
||||
|
||||
Usage:
|
||||
|
||||
- You must use your \`read_file\` tool at least once in the conversation before
|
||||
editing. This tool will error if you attempt an edit without reading the file.
|
||||
|
||||
- When editing text from read_file tool output, ensure you preserve the exact
|
||||
indentation (tabs/spaces) as it appears AFTER the line number prefix. The line
|
||||
number prefix format is: spaces + line number + tab. Everything after that tab
|
||||
is the actual file content to match. Never include any part of the line number
|
||||
prefix in the old_string or new_string.
|
||||
|
||||
- ALWAYS prefer editing existing files in the codebase. NEVER write new files
|
||||
unless explicitly required.
|
||||
|
||||
- Only use emojis if the user explicitly requests it. Avoid adding emojis to
|
||||
files unless asked.
|
||||
|
||||
- The edit will FAIL if \`old_string\` is not unique in the file. Either provide
|
||||
a larger string with more surrounding context to make it unique or use
|
||||
\`replace_all\` to change every instance of \`old_string\`.
|
||||
|
||||
- Use \`replace_all\` for replacing and renaming strings across the file. This
|
||||
parameter is useful if you want to rename a variable for instance.`,
|
||||
parameters: {
|
||||
type: "object",
|
||||
required: ["filepath", "old_string", "new_string"],
|
||||
properties: {
|
||||
filepath: {
|
||||
type: "string",
|
||||
description:
|
||||
"The path to the file to modify, relative to the root of the workspace",
|
||||
},
|
||||
old_string: {
|
||||
type: "string",
|
||||
description: "The text to replace",
|
||||
},
|
||||
new_string: {
|
||||
type: "string",
|
||||
description:
|
||||
"The text to replace it with (must be different from old_string)",
|
||||
},
|
||||
replace_all: {
|
||||
type: "boolean",
|
||||
description: "Replace all occurrences of old_string (default false)",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
systemMessageDescription: {
|
||||
prefix: `To perform exact string replacements in files, use the ${BuiltInToolNames.SingleFindAndReplace} tool with a filepath (relative to the root of the workspace) and the strings to find and replace.
|
||||
|
||||
For example, you could respond with:`,
|
||||
exampleArgs: [
|
||||
["filepath", "path/to/file.ts"],
|
||||
["old_string", "const oldVariable = 'value'"],
|
||||
["new_string", "const newVariable = 'updated'"],
|
||||
["replace_all", "false"],
|
||||
],
|
||||
},
|
||||
defaultToolPolicy: "allowedWithPermission",
|
||||
};
|
||||
|
|
@ -8,6 +8,8 @@ describe("Tool Definitions", () => {
|
|||
rules: [],
|
||||
enableExperimentalTools: false,
|
||||
isSignedIn: false,
|
||||
isRemote: false,
|
||||
modelName: "a model",
|
||||
};
|
||||
|
||||
// Helper function to get the actual tool object
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ export const fetchUrlContentImpl: ToolImpl = async (args, extras) => {
|
|||
// Add truncation warning if needed
|
||||
if (truncatedUrls.length > 0) {
|
||||
processedItems.push({
|
||||
name: "URL content truncation warning",
|
||||
description: "Informs that URL content was truncated",
|
||||
name: "Truncation warning",
|
||||
description: "",
|
||||
content: `The content from ${truncatedUrls.join(", ")} was truncated because it exceeded the ${DEFAULT_FETCH_URL_CHAR_LIMIT} character limit. If you need more content, consider fetching specific sections or using a more targeted approach.`,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ test("fetchUrlContent should truncate content exceeding character limit", async
|
|||
|
||||
expect(result).toHaveLength(2); // Original item + warning
|
||||
expect(result[0].content.length).toBe(DEFAULT_FETCH_URL_CHAR_LIMIT);
|
||||
expect(result[1].name).toBe("URL content truncation warning");
|
||||
expect(result[1].name).toBe("Truncation warning");
|
||||
expect(result[1].content).toContain("was truncated");
|
||||
expect(result[1].content).toContain("20000 character limit");
|
||||
});
|
||||
|
|
@ -87,5 +87,5 @@ test("fetchUrlContent should add truncation warning with multiple truncated item
|
|||
expect(result).toHaveLength(3); // Two original items + warning
|
||||
expect(result[0].content.length).toBe(DEFAULT_FETCH_URL_CHAR_LIMIT);
|
||||
expect(result[1].content.length).toBe(DEFAULT_FETCH_URL_CHAR_LIMIT);
|
||||
expect(result[2].name).toBe("URL content truncation warning");
|
||||
expect(result[2].name).toBe("Truncation warning");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,10 +10,20 @@ export const fileGlobSearchImpl: ToolImpl = async (args, extras) => {
|
|||
pattern,
|
||||
MAX_AGENT_GLOB_RESULTS,
|
||||
);
|
||||
|
||||
if (results.length === 0) {
|
||||
return [
|
||||
{
|
||||
name: "File results",
|
||||
description: "glob search",
|
||||
content: "The glob search returned no results.",
|
||||
},
|
||||
];
|
||||
}
|
||||
const contextItems: ContextItem[] = [
|
||||
{
|
||||
name: "File results",
|
||||
description: "Results from file glob search",
|
||||
description: "glob search",
|
||||
content: results.join("\n"),
|
||||
},
|
||||
];
|
||||
|
|
@ -22,7 +32,7 @@ export const fileGlobSearchImpl: ToolImpl = async (args, extras) => {
|
|||
if (results.length === MAX_AGENT_GLOB_RESULTS) {
|
||||
contextItems.push({
|
||||
name: "Truncation warning",
|
||||
description: "Inform the model that results were truncated",
|
||||
description: "",
|
||||
content: `Warning: the results above were truncated to the first ${MAX_AGENT_GLOB_RESULTS} files. If the results are not satisfactory, refine your search pattern`,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,15 @@
|
|||
import { ToolImpl } from ".";
|
||||
import { ContextItem } from "../..";
|
||||
import { formatGrepSearchResults } from "../../util/grepSearch";
|
||||
import { prepareQueryForRipgrep } from "../../util/regexValidator";
|
||||
import { getStringArg } from "../parseArgs";
|
||||
|
||||
const DEFAULT_GREP_SEARCH_RESULTS_LIMIT = 100;
|
||||
const DEFAULT_GREP_SEARCH_CHAR_LIMIT = 5000; // ~1000 tokens, will keep truncation simply for now
|
||||
const DEFAULT_GREP_SEARCH_CHAR_LIMIT = 7500; // ~1500 tokens, will keep truncation simply for now
|
||||
|
||||
function splitGrepResultsByFile(content: string): ContextItem[] {
|
||||
const matches = [...content.matchAll(/^\.\/([^\n]+)$/gm)];
|
||||
|
||||
if (matches.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const contextItems: ContextItem[] = [];
|
||||
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
|
|
@ -42,16 +39,48 @@ function splitGrepResultsByFile(content: string): ContextItem[] {
|
|||
}
|
||||
|
||||
export const grepSearchImpl: ToolImpl = async (args, extras) => {
|
||||
const query = getStringArg(args, "query");
|
||||
const rawQuery = getStringArg(args, "query");
|
||||
|
||||
const { query, warning } = prepareQueryForRipgrep(rawQuery);
|
||||
|
||||
let results: string;
|
||||
try {
|
||||
results = await extras.ide.getSearchResults(
|
||||
query,
|
||||
DEFAULT_GREP_SEARCH_RESULTS_LIMIT,
|
||||
);
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
|
||||
// Helpful error for common ripgrep exit code
|
||||
if (errorMessage.includes("Process exited with code 2")) {
|
||||
return [
|
||||
{
|
||||
name: "Search error",
|
||||
description: "The search query could not be processed",
|
||||
content: `The search failed due to an invalid regex pattern.\n\nOriginal query: ${rawQuery}\nProcessed query: ${query}\n\nError: ${errorMessage}\n\nTip: If you're searching for literal text with special characters, the query was automatically escaped. If you need regex patterns, ensure they use proper regex syntax.`,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
const results = await extras.ide.getSearchResults(
|
||||
query,
|
||||
DEFAULT_GREP_SEARCH_RESULTS_LIMIT,
|
||||
);
|
||||
const { formatted, numResults, truncated } = formatGrepSearchResults(
|
||||
results,
|
||||
DEFAULT_GREP_SEARCH_CHAR_LIMIT,
|
||||
);
|
||||
|
||||
if (numResults === 0) {
|
||||
return [
|
||||
{
|
||||
name: "Search results",
|
||||
description: "Results from grep search",
|
||||
content: "The search returned no results.",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const truncationReasons: string[] = [];
|
||||
if (numResults === DEFAULT_GREP_SEARCH_RESULTS_LIMIT) {
|
||||
truncationReasons.push(
|
||||
|
|
@ -64,7 +93,7 @@ export const grepSearchImpl: ToolImpl = async (args, extras) => {
|
|||
);
|
||||
}
|
||||
|
||||
let contextItems: ContextItem[] = [];
|
||||
let contextItems: ContextItem[];
|
||||
|
||||
const splitByFile: boolean = args?.splitByFile || false;
|
||||
if (splitByFile) {
|
||||
|
|
@ -79,10 +108,21 @@ export const grepSearchImpl: ToolImpl = async (args, extras) => {
|
|||
];
|
||||
}
|
||||
|
||||
// Add warnings about query modifications or truncation
|
||||
const warnings: string[] = [];
|
||||
if (warning) {
|
||||
warnings.push(warning);
|
||||
}
|
||||
if (truncationReasons.length > 0) {
|
||||
warnings.push(
|
||||
`Results were truncated because ${truncationReasons.join(" and ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (truncationReasons.length > 0) {
|
||||
contextItems.push({
|
||||
name: "Search truncation warning",
|
||||
description: "Informs the model that search results were truncated",
|
||||
name: "Truncation warning",
|
||||
description: "",
|
||||
content: `The above search results were truncated because ${truncationReasons.join(" and ")}. If the results are not satisfactory, try refining your search query.`,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import ignore from "ignore";
|
||||
|
||||
import { ToolImpl } from ".";
|
||||
import { walkDir } from "../../indexing/walkDir";
|
||||
import { resolveRelativePathInDir } from "../../util/ideUtils";
|
||||
|
|
@ -27,6 +29,7 @@ export const lsToolImpl: ToolImpl = async (args, extras) => {
|
|||
returnRelativeUrisPaths: true,
|
||||
include: "both",
|
||||
recursive: args?.recursive ?? false,
|
||||
overrideDefaultIgnores: ignore(), // Show all directories including dist/, build/, etc.
|
||||
});
|
||||
|
||||
const lines = entries.slice(0, MAX_LS_TOOL_LINES);
|
||||
|
|
@ -50,8 +53,8 @@ export const lsToolImpl: ToolImpl = async (args, extras) => {
|
|||
warningContent += ". Try using a non-recursive search";
|
||||
}
|
||||
contextItems.push({
|
||||
name: "ls truncation warning",
|
||||
description: "Informs the model that ls results were truncated",
|
||||
name: "Truncation warning",
|
||||
description: "",
|
||||
content: warningContent,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
import { getUriDescription } from "../../util/uri";
|
||||
|
||||
import { ToolImpl } from ".";
|
||||
import { throwIfFileIsSecurityConcern } from "../../indexing/ignore";
|
||||
import { throwIfFileExceedsHalfOfContext } from "./readFileLimit";
|
||||
|
||||
export const readCurrentlyOpenFileImpl: ToolImpl = async (args, extras) => {
|
||||
export const readCurrentlyOpenFileImpl: ToolImpl = async (_, extras) => {
|
||||
const result = await extras.ide.getCurrentFile();
|
||||
|
||||
if (result) {
|
||||
throwIfFileIsSecurityConcern(result.path);
|
||||
await throwIfFileExceedsHalfOfContext(
|
||||
result.path,
|
||||
result.contents,
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ import { resolveRelativePathInDir } from "../../util/ideUtils";
|
|||
import { getUriPathBasename } from "../../util/uri";
|
||||
|
||||
import { ToolImpl } from ".";
|
||||
import { throwIfFileIsSecurityConcern } from "../../indexing/ignore";
|
||||
import { getStringArg } from "../parseArgs";
|
||||
import { throwIfFileExceedsHalfOfContext } from "./readFileLimit";
|
||||
|
||||
export const readFileImpl: ToolImpl = async (args, extras) => {
|
||||
const filepath = getStringArg(args, "filepath");
|
||||
throwIfFileIsSecurityConcern(filepath);
|
||||
|
||||
const firstUriMatch = await resolveRelativePathInDir(filepath, extras.ide);
|
||||
if (!firstUriMatch) {
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ export const searchWebImpl: ToolImpl = async (args, extras) => {
|
|||
// Add truncation warning if needed
|
||||
if (truncatedResults.length > 0) {
|
||||
processedResults.push({
|
||||
name: "Web search truncation warning",
|
||||
description: "Informs that search results were truncated",
|
||||
name: "Truncation warning",
|
||||
description: "",
|
||||
content: `The content from the following search results was truncated because it exceeded the ${DEFAULT_WEB_SEARCH_CHAR_LIMIT} character limit: ${truncatedResults.join(", ")}. For more detailed information, consider refining your search query.`,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue