diff --git a/.github/actions/run-jetbrains-tests/action.yml b/.github/actions/run-jetbrains-tests/action.yml index 6c2d431ff..77f6ceff3 100644 --- a/.github/actions/run-jetbrains-tests/action.yml +++ b/.github/actions/run-jetbrains-tests/action.yml @@ -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() }} diff --git a/.github/actions/track-rerun/action.yml b/.github/actions/track-rerun/action.yml new file mode 100644 index 000000000..d9bcb2423 --- /dev/null +++ b/.github/actions/track-rerun/action.yml @@ -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 }}'" diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index b059a3b91..4c763a8c9 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -18,19 +18,28 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20 registry-url: "https://registry.npmjs.org" always-auth: true - - name: Install dependencies + - name: Setup packages + uses: ./.github/actions/setup-packages + + - name: Setup core component + uses: ./.github/actions/setup-component + with: + component: core + include-root: true + + - name: Install CLI dependencies working-directory: extensions/cli run: npm ci env: diff --git a/.github/workflows/cli-pr-checks.yml b/.github/workflows/cli-pr-checks.yml index 0284cae4b..bd58ad7c6 100644 --- a/.github/workflows/cli-pr-checks.yml +++ b/.github/workflows/cli-pr-checks.yml @@ -3,8 +3,6 @@ name: CLI PR Checks on: pull_request: branches: [main] - paths: - - "extensions/cli/**" permissions: contents: read @@ -12,11 +10,19 @@ permissions: 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@v4 + uses: actions/checkout@v5 - name: Setup Node.js uses: actions/setup-node@v4 @@ -25,10 +31,18 @@ jobs: 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: Install dependencies run: | cd extensions/cli - npm ci + npm ci --include=optional - name: Run linting run: | @@ -44,38 +58,56 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - cache: "npm" - cache-dependency-path: extensions/cli/package-lock.json + + - 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: Install dependencies run: | cd extensions/cli - npm ci + npm ci --include=optional - name: Build run: | cd extensions/cli npm run build - # e2e tests are failing on Windows specifically - likely due to stdout flush issues + - name: Run smoke tests + run: | + cd extensions/cli + npm run test:smoke + - name: Run tests - if: matrix.os != 'windows-latest' run: | cd extensions/cli npm test - - name: Run tests (excluding e2e on Windows) - if: matrix.os == 'windows-latest' - shell: bash + # 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 test -- --exclude='**/*.e2e.*' --exclude='**/e2e/**' + 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 diff --git a/.github/workflows/compliance.yaml b/.github/workflows/compliance.yaml index 6ab98b27e..76c21d6b1 100644 --- a/.github/workflows/compliance.yaml +++ b/.github/workflows/compliance.yaml @@ -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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 589a8e2ed..000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/.github/workflows/jetbrains-release.yaml b/.github/workflows/jetbrains-release.yaml index c628bdb7b..23e434ff3 100644 --- a/.github/workflows/jetbrains-release.yaml +++ b/.github/workflows/jetbrains-release.yaml @@ -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 }} @@ -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 diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index cf276f360..785044868 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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: diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index fb91e8d97..e37127d1f 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -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: diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index b68a65efd..7e054eb59 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -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 diff --git a/.github/workflows/stable-release.yml b/.github/workflows/stable-release.yml index 63fdb60eb..b213b7481 100644 --- a/.github/workflows/stable-release.yml +++ b/.github/workflows/stable-release.yml @@ -34,13 +34,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20 registry-url: "https://registry.npmjs.org" @@ -141,6 +141,17 @@ jobs: # 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: Prepare package for direct stable release if: ${{ inputs.release_type == 'direct-stable' }} working-directory: extensions/cli diff --git a/.vscode/settings.json b/.vscode/settings.json index d17afc5ae..c55d9798c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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, diff --git a/binary/package-lock.json b/binary/package-lock.json index 83a78d4d2..37f2d865d 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -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" diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index d51c15853..377dfa1e5 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -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 diff --git a/core/autocomplete/prefiltering/index.ts b/core/autocomplete/prefiltering/index.ts index ec18879f7..b322b9e22 100644 --- a/core/autocomplete/prefiltering/index.ts +++ b/core/autocomplete/prefiltering/index.ts @@ -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"; diff --git a/core/commands/slash/built-in-legacy/onboard.ts b/core/commands/slash/built-in-legacy/onboard.ts index 969ebc0c4..500781450 100644 --- a/core/commands/slash/built-in-legacy/onboard.ts +++ b/core/commands/slash/built-in-legacy/onboard.ts @@ -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, diff --git a/core/config/load.ts b/core/config/load.ts index dad4e18bf..370695bd3 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -59,7 +59,7 @@ import { localPathToUri } from "../util/pathToUri"; import { PolicySingleton } from "../control-plane/PolicySingleton"; import CustomContextProviderClass from "../context/providers/CustomContextProvider"; -import { getToolsForIde } from "../tools"; +import { getBaseToolDefinitions } from "../tools"; import { resolveRelativePathInDir } from "../util/ideUtils"; import { getWorkspaceRcConfigs } from "./json/loadRcConfigs"; import { loadConfigContextProviders } from "./loadContextProviders"; @@ -283,6 +283,7 @@ async function intermediateToFinalConfig({ ...desc, model: modelName, title: modelName, + isFromAutoDetect: true, }, ide.readFile.bind(ide), getUriFromPath, @@ -320,6 +321,7 @@ async function intermediateToFinalConfig({ ...desc.options, model: modelName, logger: llmLogger, + isFromAutoDetect: true, }, }), ); @@ -499,7 +501,7 @@ async function intermediateToFinalConfig({ const continueConfig: ContinueConfig = { ...config, contextProviders, - tools: await getToolsForIde(ide), + tools: getBaseToolDefinitions(), mcpServerStatuses: [], slashCommands: [], modelsByRole: { @@ -632,6 +634,7 @@ function llmToSerializedModelDescription(llm: ILLM): ModelDescription { apiKeyLocation: llm.apiKeyLocation, envSecretLocations: llm.envSecretLocations, sourceFile: llm.sourceFile, + isFromAutoDetect: llm.isFromAutoDetect, }; } diff --git a/core/config/loadContextProviders.ts b/core/config/loadContextProviders.ts index a5627dfae..e51051f0a 100644 --- a/core/config/loadContextProviders.ts +++ b/core/config/loadContextProviders.ts @@ -29,11 +29,24 @@ export function loadConfigContextProviders( } { 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) { + if ( + !cls && + !defaultProviders.find((p) => p.description.title === config.provider) + ) { errors.push({ fatal: false, message: `Unknown context provider ${config.provider}`, @@ -50,15 +63,6 @@ export function loadConfigContextProviders( } // Add from defaults if not found in config - const defaultProviders: IContextProvider[] = [ - new FileContextProvider({}), - new CurrentFileContextProvider({}), - new DiffContextProvider({}), - new TerminalContextProvider({}), - new ProblemsContextProvider({}), - new RulesContextProvider({}), - ]; - for (const defaultProvider of defaultProviders) { if ( !providers.find( diff --git a/core/config/loadLocalAssistants.ts b/core/config/loadLocalAssistants.ts index b6a29212d..2a8135dc1 100644 --- a/core/config/loadLocalAssistants.ts +++ b/core/config/loadLocalAssistants.ts @@ -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, { diff --git a/core/config/loadLocalAssistants.vitest.ts b/core/config/loadLocalAssistants.vitest.ts index 8527eada5..316687db1 100644 --- a/core/config/loadLocalAssistants.vitest.ts +++ b/core/config/loadLocalAssistants.vitest.ts @@ -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", diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 92ce01f54..fcb5f30bc 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -282,6 +282,8 @@ export default async function doLoadConfig(options: { enableExperimentalTools: newConfig.experimental?.enableExperimentalTools ?? false, isSignedIn, + isRemote: await ide.isWorkspaceRemote(), + modelName: newConfig.selectedModelByRole.chat?.model, }), ); diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 9105db4d1..65cb5e0ff 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -26,7 +26,7 @@ import { convertPromptBlockToSlashCommand } from "../../commands/slash/promptBlo import { slashCommandFromPromptFile } from "../../commands/slash/promptFileSlashCommand"; import { getControlPlaneEnvSync } from "../../control-plane/env"; import { PolicySingleton } from "../../control-plane/PolicySingleton"; -import { getToolsForIde } from "../../tools"; +import { getBaseToolDefinitions } from "../../tools"; import { getCleanUriPath } from "../../util/uri"; import { loadConfigContextProviders } from "../loadContextProviders"; import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; @@ -169,7 +169,7 @@ async function configYamlToContinueConfig(options: { const continueConfig: ContinueConfig = { slashCommands: [], - tools: await getToolsForIde(ide), + tools: getBaseToolDefinitions(), mcpServerStatuses: [], contextProviders: [], modelsByRole: { diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index 102e4152b..45cbdcbfb 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -32,12 +32,14 @@ async function modelConfigToBaseLLM({ ideSettings, llmLogger, config, + isFromAutoDetect, }: { model: ModelConfig; uniqueId: string; ideSettings: IdeSettings; llmLogger: ILLMLogger; config: ContinueConfig; + isFromAutoDetect?: boolean; }): Promise { 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, }); }), ); diff --git a/core/context/providers/FileContextProvider.ts b/core/context/providers/FileContextProvider.ts index 5f7861b83..9e0455e54 100644 --- a/core/context/providers/FileContextProvider.ts +++ b/core/context/providers/FileContextProvider.ts @@ -6,6 +6,7 @@ import { ContextSubmenuItem, LoadSubmenuItemsArgs, } from "../../"; +import { isSecurityConcern } from "../../indexing/ignore"; import { walkDirs } from "../../indexing/walkDir"; import { getShortestUniqueRelativeUriPaths, diff --git a/core/context/providers/OpenFilesContextProvider.ts b/core/context/providers/OpenFilesContextProvider.ts index 8267bf1c9..afc98ffea 100644 --- a/core/context/providers/OpenFilesContextProvider.ts +++ b/core/context/providers/OpenFilesContextProvider.ts @@ -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\`\`\``, diff --git a/core/context/providers/ProblemsContextProvider.ts b/core/context/providers/ProblemsContextProvider.ts index d8df5687f..3d7f3fe7a 100644 --- a/core/context/providers/ProblemsContextProvider.ts +++ b/core/context/providers/ProblemsContextProvider.ts @@ -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}`, }; }), ); diff --git a/core/context/providers/index.ts b/core/context/providers/index.ts index 910b16c14..e0abc7cf2 100644 --- a/core/context/providers/index.ts +++ b/core/context/providers/index.ts @@ -12,6 +12,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 +42,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, diff --git a/core/context/retrieval/retrieval.ts b/core/context/retrieval/retrieval.ts index 4f29d2ef8..022e5abf0 100644 --- a/core/context/retrieval/retrieval.ts +++ b/core/context/retrieval/retrieval.ts @@ -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([ diff --git a/core/index.d.ts b/core/index.d.ts index 90039f025..10966f084 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -666,6 +666,7 @@ export interface LLMOptions { env?: Record; sourceFile?: string; + isFromAutoDetect?: boolean; } type RequireAtLeastOne = Pick< @@ -1112,6 +1113,8 @@ export interface ConfigDependentToolParams { rules: RuleWithSource[]; enableExperimentalTools: boolean; isSignedIn: boolean; + isRemote: boolean; + modelName: string | undefined; } export type GetTool = (params: ConfigDependentToolParams) => Tool; @@ -1175,6 +1178,7 @@ export interface ModelDescription { configurationStatus?: LLMConfigurationStatuses; sourceFile?: string; + isFromAutoDetect?: boolean; } export interface JSONEmbedOptions { @@ -1605,6 +1609,7 @@ export interface JSONModelDescription { aiGatewaySlug?: string; useLegacyCompletionsEndpoint?: boolean; deploymentId?: string; + isFromAutoDetect?: boolean; } // config.json diff --git a/core/indexing/chunk/chunk.ts b/core/indexing/chunk/chunk.ts index de9a33f9c..73108bf40 100644 --- a/core/indexing/chunk/chunk.ts +++ b/core/indexing/chunk/chunk.ts @@ -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; diff --git a/core/indexing/continueignore.ts b/core/indexing/continueignore.ts new file mode 100644 index 000000000..a1beffb38 --- /dev/null +++ b/core/indexing/continueignore.ts @@ -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[]), + ); +}; diff --git a/core/indexing/ignore.ts b/core/indexing/ignore.ts index f70633b1b..c7738a0fa 100644 --- a/core/indexing/ignore.ts +++ b/core/indexing/ignore.ts @@ -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[]), - ); -}; diff --git a/core/indexing/ignore.vitest.ts b/core/indexing/ignore.vitest.ts new file mode 100644 index 000000000..43a271851 --- /dev/null +++ b/core/indexing/ignore.vitest.ts @@ -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); + }); + }); + }); +}); diff --git a/core/indexing/shouldIgnore.ts b/core/indexing/shouldIgnore.ts index dd82a0457..4898f045b 100644 --- a/core/indexing/shouldIgnore.ts +++ b/core/indexing/shouldIgnore.ts @@ -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"; /* diff --git a/core/indexing/walkDir.ts b/core/indexing/walkDir.ts index 04e45a3ca..94c147942 100644 --- a/core/indexing/walkDir.ts +++ b/core/indexing/walkDir.ts @@ -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"; diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 3f9e62dfc..8e036ff3a 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -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, ]; diff --git a/core/llm/autodetect.vitest.ts b/core/llm/autodetect.vitest.ts index 4e250f1ad..95a2f3d82 100644 --- a/core/llm/autodetect.vitest.ts +++ b/core/llm/autodetect.vitest.ts @@ -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); }); diff --git a/core/llm/constants.ts b/core/llm/constants.ts index 4364257ab..c368e0d5a 100644 --- a/core/llm/constants.ts +++ b/core/llm/constants.ts @@ -21,7 +21,6 @@ export enum LLMConfigurationStatuses { export enum NEXT_EDIT_MODELS { MERCURY_CODER = "mercury-coder", - MERCURY_CODER_NEXTEDIT = "mercury-coder-nextedit", INSTINCT = "instinct", } diff --git a/core/llm/defaultSystemMessages.ts b/core/llm/defaultSystemMessages.ts index eebcc8510..43ab7990e 100644 --- a/core/llm/defaultSystemMessages.ts +++ b/core/llm/defaultSystemMessages.ts @@ -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 = `\ 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. + `; // 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. `; diff --git a/core/llm/index.ts b/core/llm/index.ts index edbfecbdb..1a0330eaa 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -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,6 +30,7 @@ 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"; @@ -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() { diff --git a/core/llm/llm.test.ts b/core/llm/llm.test.ts index 5535bae30..f08c8e14d 100644 --- a/core/llm/llm.test.ts +++ b/core/llm/llm.test.ts @@ -213,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 }, diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index a944f90f9..a1c4c2046 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -148,7 +148,7 @@ class Ollama extends BaseLLM implements ModelInstaller { constructor(options: LLMOptions) { super(options); - if (options.model === "AUTODETECT") { + if (options.isFromAutoDetect) { return; } const headers: Record = { diff --git a/core/llm/llms/Vllm.ts b/core/llm/llms/Vllm.ts index 97bd936cb..66f9b84c4 100644 --- a/core/llm/llms/Vllm.ts +++ b/core/llm/llms/Vllm.ts @@ -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( diff --git a/core/llm/toolSupport.test.ts b/core/llm/toolSupport.test.ts index 51502bfe8..71f70485f 100644 --- a/core/llm/toolSupport.test.ts +++ b/core/llm/toolSupport.test.ts @@ -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", () => { diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index 0ad2d5dd1..ed40733a5 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -334,6 +334,36 @@ export const PROVIDER_TOOL_SUPPORT: Record 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; }, }; @@ -345,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/], ]; diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts index c3bc079d1..5bd199e05 100644 --- a/core/nextEdit/NextEditProvider.ts +++ b/core/nextEdit/NextEditProvider.ts @@ -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 { + 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,7 +305,7 @@ 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, @@ -341,7 +315,7 @@ export class NextEditProvider { 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 +325,7 @@ 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. + // 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 +355,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 +369,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 { + 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 +574,6 @@ export class NextEditProvider { }; } - private async _generateFineTunedPrompts( - helper: HelperVars, - snippetPayload: SnippetPayload, - editableRegionStartLine: number, - editableRegionEndLine: number, - ): Promise { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { - 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, diff --git a/core/nextEdit/NextEditProviderFactory.ts b/core/nextEdit/NextEditProviderFactory.ts new file mode 100644 index 000000000..4ba97c651 --- /dev/null +++ b/core/nextEdit/NextEditProviderFactory.ts @@ -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}`); + } + } +} diff --git a/core/nextEdit/constants.ts b/core/nextEdit/constants.ts index c569cb208..d8bd4c9df 100644 --- a/core/nextEdit/constants.ts +++ b/core/nextEdit/constants.ts @@ -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 }, }; diff --git a/core/nextEdit/context/autocompleteContextFetching.ts b/core/nextEdit/context/autocompleteContextFetching.ts index 8b57a4a17..26d333e14 100644 --- a/core/nextEdit/context/autocompleteContextFetching.ts +++ b/core/nextEdit/context/autocompleteContextFetching.ts @@ -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; diff --git a/core/nextEdit/providers/BaseNextEditProvider.ts b/core/nextEdit/providers/BaseNextEditProvider.ts new file mode 100644 index 000000000..02d9c3998 --- /dev/null +++ b/core/nextEdit/providers/BaseNextEditProvider.ts @@ -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; + 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 { + 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 { + 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 { + 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 { + // 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 { + 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 { + 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 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; + } +} diff --git a/core/nextEdit/providers/InstinctNextEditProvider.ts b/core/nextEdit/providers/InstinctNextEditProvider.ts new file mode 100644 index 000000000..fcf156ee2 --- /dev/null +++ b/core/nextEdit/providers/InstinctNextEditProvider.ts @@ -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 { + 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, + ), + }; + } + } +} diff --git a/core/nextEdit/providers/MercuryCoderNextEditProvider.ts b/core/nextEdit/providers/MercuryCoderNextEditProvider.ts new file mode 100644 index 000000000..759381f39 --- /dev/null +++ b/core/nextEdit/providers/MercuryCoderNextEditProvider.ts @@ -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 { + 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, + ), + }; + } + } +} diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts index d8ca2226d..0d02a2f27 100644 --- a/core/nextEdit/templating/NextEditPromptEngine.ts +++ b/core/nextEdit/templating/NextEditPromptEngine.ts @@ -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 = { +// 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 { - 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; } diff --git a/core/nextEdit/templating/NextEditPromptEngine.vitest.ts b/core/nextEdit/templating/NextEditPromptEngine.vitest.ts index f72d3ca0b..7fd189ecc 100644 --- a/core/nextEdit/templating/NextEditPromptEngine.vitest.ts +++ b/core/nextEdit/templating/NextEditPromptEngine.vitest.ts @@ -1,243 +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, - MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_CLOSE, - MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_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" 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 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_RECENTLY_VIEWED_CODE_SNIPPET_OPEN); - expect(content).toContain(MERCURY_RECENTLY_VIEWED_CODE_SNIPPET_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."); }); }); }); diff --git a/core/nextEdit/types.ts b/core/nextEdit/types.ts index d30d803e0..78ca343ae 100644 --- a/core/nextEdit/types.ts +++ b/core/nextEdit/types.ts @@ -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; @@ -104,3 +106,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; +} diff --git a/core/nextEdit/utils.ts b/core/nextEdit/utils.ts index 07ec52a19..15f2e6339 100644 --- a/core/nextEdit/utils.ts +++ b/core/nextEdit/utils.ts @@ -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)); +} diff --git a/core/nextEdit/utils.vitest.ts b/core/nextEdit/utils.vitest.ts index b5494a525..abbab499b 100644 --- a/core/nextEdit/utils.vitest.ts +++ b/core/nextEdit/utils.vitest.ts @@ -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); + } + }); +}); diff --git a/core/package-lock.json b/core/package-lock.json index 0e1f61602..974a50300 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -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", @@ -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", @@ -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", @@ -6975,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", @@ -7089,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" }, @@ -7127,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", @@ -7634,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", @@ -9432,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", @@ -10577,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", @@ -10929,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" @@ -10947,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" }, @@ -11660,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", @@ -12133,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" } @@ -14477,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" } @@ -14579,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" @@ -15804,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", @@ -17587,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" } @@ -18577,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": { @@ -18848,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" diff --git a/core/package.json b/core/package.json index a140684b1..d07130027 100644 --- a/core/package.json +++ b/core/package.json @@ -36,6 +36,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 +68,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 +86,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", diff --git a/core/tools/builtIn.ts b/core/tools/builtIn.ts index c5c5da16c..6e8ed1062 100644 --- a/core/tools/builtIn.ts +++ b/core/tools/builtIn.ts @@ -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, ]; diff --git a/core/tools/definitions/index.ts b/core/tools/definitions/index.ts index c1998444c..6313eb9fc 100644 --- a/core/tools/definitions/index.ts +++ b/core/tools/definitions/index.ts @@ -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"; diff --git a/core/tools/definitions/multiEdit.ts b/core/tools/definitions/multiEdit.ts new file mode 100644 index 000000000..300312000 --- /dev/null +++ b/core/tools/definitions/multiEdit.ts @@ -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", +}; diff --git a/core/tools/definitions/readCurrentlyOpenFile.ts b/core/tools/definitions/readCurrentlyOpenFile.ts index e05241611..da1cb129b 100644 --- a/core/tools/definitions/readCurrentlyOpenFile.ts +++ b/core/tools/definitions/readCurrentlyOpenFile.ts @@ -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: {}, diff --git a/core/tools/definitions/singleFindAndReplace.ts b/core/tools/definitions/singleFindAndReplace.ts new file mode 100644 index 000000000..b5537d775 --- /dev/null +++ b/core/tools/definitions/singleFindAndReplace.ts @@ -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", +}; diff --git a/core/tools/definitions/toolDefinitions.test.ts b/core/tools/definitions/toolDefinitions.test.ts index abeac08ef..265ebe5e1 100644 --- a/core/tools/definitions/toolDefinitions.test.ts +++ b/core/tools/definitions/toolDefinitions.test.ts @@ -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 diff --git a/core/tools/implementations/fetchUrlContent.ts b/core/tools/implementations/fetchUrlContent.ts index 95b5b216b..15809e4f3 100644 --- a/core/tools/implementations/fetchUrlContent.ts +++ b/core/tools/implementations/fetchUrlContent.ts @@ -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.`, }); } diff --git a/core/tools/implementations/fetchUrlContent.vitest.ts b/core/tools/implementations/fetchUrlContent.vitest.ts index 9d103893d..0c8efb81b 100644 --- a/core/tools/implementations/fetchUrlContent.vitest.ts +++ b/core/tools/implementations/fetchUrlContent.vitest.ts @@ -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"); }); diff --git a/core/tools/implementations/globSearch.ts b/core/tools/implementations/globSearch.ts index 04a105556..2e40ac06d 100644 --- a/core/tools/implementations/globSearch.ts +++ b/core/tools/implementations/globSearch.ts @@ -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`, }); } diff --git a/core/tools/implementations/grepSearch.ts b/core/tools/implementations/grepSearch.ts index b75c21891..727b5c560 100644 --- a/core/tools/implementations/grepSearch.ts +++ b/core/tools/implementations/grepSearch.ts @@ -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.`, }); } diff --git a/core/tools/implementations/lsTool.ts b/core/tools/implementations/lsTool.ts index 7e5f49856..67122f082 100644 --- a/core/tools/implementations/lsTool.ts +++ b/core/tools/implementations/lsTool.ts @@ -53,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, }); } diff --git a/core/tools/implementations/readCurrentlyOpenFile.ts b/core/tools/implementations/readCurrentlyOpenFile.ts index bf3b2c713..02b7be114 100644 --- a/core/tools/implementations/readCurrentlyOpenFile.ts +++ b/core/tools/implementations/readCurrentlyOpenFile.ts @@ -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, diff --git a/core/tools/implementations/readFile.ts b/core/tools/implementations/readFile.ts index ae8964445..afa6495ad 100644 --- a/core/tools/implementations/readFile.ts +++ b/core/tools/implementations/readFile.ts @@ -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) { diff --git a/core/tools/implementations/searchWeb.ts b/core/tools/implementations/searchWeb.ts index 3d331ebfd..51e817fae 100644 --- a/core/tools/implementations/searchWeb.ts +++ b/core/tools/implementations/searchWeb.ts @@ -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.`, }); } diff --git a/core/tools/implementations/searchWeb.vitest.ts b/core/tools/implementations/searchWeb.vitest.ts index 17ddd4925..5ac02ac32 100644 --- a/core/tools/implementations/searchWeb.vitest.ts +++ b/core/tools/implementations/searchWeb.vitest.ts @@ -62,7 +62,7 @@ test("searchWeb should truncate results exceeding character limit", async () => expect(result).toHaveLength(3); // Two results + warning expect(result[0].content.length).toBe(DEFAULT_WEB_SEARCH_CHAR_LIMIT); expect(result[1].content).toBe(shortContent); - expect(result[2].name).toBe("Web search truncation warning"); + expect(result[2].name).toBe("Truncation warning"); expect(result[2].content).toContain("truncated"); expect(result[2].content).toContain("Result 1"); expect(result[2].content).not.toContain("Result 2"); @@ -100,7 +100,7 @@ test("searchWeb should include all truncated results in the warning", async () = expect(result[0].content.length).toBe(DEFAULT_WEB_SEARCH_CHAR_LIMIT); expect(result[1].content.length).toBe(DEFAULT_WEB_SEARCH_CHAR_LIMIT); expect(result[2].content).toBe(shortContent); - expect(result[3].name).toBe("Web search truncation warning"); + expect(result[3].name).toBe("Truncation warning"); expect(result[3].content).toContain("Result 1"); expect(result[3].content).toContain("Result 2"); expect(result[3].content).not.toContain("Result 3"); diff --git a/core/tools/implementations/viewDiff.ts b/core/tools/implementations/viewDiff.ts index 2b5da1ab8..9df82e78d 100644 --- a/core/tools/implementations/viewDiff.ts +++ b/core/tools/implementations/viewDiff.ts @@ -29,8 +29,8 @@ export const viewDiffImpl: ToolImpl = async (args, extras) => { if (truncated) { contextItems.push({ - name: "Diff truncation warning", - description: "Informs that git diff was truncated", + name: "Truncation warning", + description: "", content: `The git diff was truncated because it exceeded ${DEFAULT_GIT_DIFF_LINE_LIMIT} lines. Consider viewing specific files or focusing on smaller changes.`, }); } diff --git a/core/tools/implementations/viewDiff.vitest.ts b/core/tools/implementations/viewDiff.vitest.ts index 914e3a014..4c9aa5d63 100644 --- a/core/tools/implementations/viewDiff.vitest.ts +++ b/core/tools/implementations/viewDiff.vitest.ts @@ -58,7 +58,7 @@ test("viewDiff should truncate diffs exceeding line limit", async () => { expect(resultLines.length).toBe(DEFAULT_GIT_DIFF_LINE_LIMIT); // Check the warning - expect(result[1].name).toBe("Diff truncation warning"); + expect(result[1].name).toBe("Truncation warning"); expect(result[1].content).toContain("truncated"); expect(result[1].content).toContain(`${DEFAULT_GIT_DIFF_LINE_LIMIT} lines`); }); @@ -83,5 +83,5 @@ test("viewDiff should handle multiple diffs correctly", async () => { expect(resultLines.length).toBe(DEFAULT_GIT_DIFF_LINE_LIMIT); // Check the warning - expect(result[1].name).toBe("Diff truncation warning"); + expect(result[1].name).toBe("Truncation warning"); }); diff --git a/core/tools/index.ts b/core/tools/index.ts index 850d89349..fa66c4c91 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -1,12 +1,8 @@ -import { ConfigDependentToolParams, IDE, Tool } from ".."; +import { ConfigDependentToolParams, Tool } from ".."; import * as toolDefinitions from "./definitions"; // I'm writing these as functions because we've messed up 3 TIMES by pushing to const, causing duplicate tool definitions on subsequent config loads. - -// missing support for remote os calls: https://github.com/microsoft/vscode/issues/252269 -const getLocalOnlyToolDefinitions = () => [toolDefinitions.grepSearchTool]; - -const getBaseToolDefinitions = () => [ +export const getBaseToolDefinitions = () => [ toolDefinitions.readFileTool, toolDefinitions.createNewFileTool, toolDefinitions.runTerminalCommandTool, @@ -16,28 +12,42 @@ const getBaseToolDefinitions = () => [ toolDefinitions.lsTool, toolDefinitions.createRuleBlock, toolDefinitions.fetchUrlContentTool, + toolDefinitions.singleFindAndReplaceTool, ]; export const getConfigDependentToolDefinitions = ( params: ConfigDependentToolParams, -): Tool[] => [ - toolDefinitions.requestRuleTool(params), - // Search and replace is now generally available - toolDefinitions.searchAndReplaceInFileTool, - // Keep edit file tool available for models that need it - toolDefinitions.editFileTool, - // Web search is only available for signed-in users - ...(params.isSignedIn ? [toolDefinitions.searchWebTool] : []), - ...(params.enableExperimentalTools - ? [ - toolDefinitions.viewRepoMapTool, - toolDefinitions.viewSubdirectoryTool, - toolDefinitions.codebaseTool, - ] - : []), -]; +): Tool[] => { + const { modelName, isSignedIn, enableExperimentalTools, isRemote } = params; + const tools: Tool[] = []; -export const getToolsForIde = async (ide: IDE): Promise => - (await ide.isWorkspaceRemote()) - ? getBaseToolDefinitions() - : [...getBaseToolDefinitions(), ...getLocalOnlyToolDefinitions()]; + tools.push(toolDefinitions.requestRuleTool(params)); + + if (isSignedIn) { + // Web search is only available for signed-in users + tools.push(toolDefinitions.searchWebTool); + } + + if (enableExperimentalTools) { + tools.push( + toolDefinitions.viewRepoMapTool, + toolDefinitions.viewSubdirectoryTool, + toolDefinitions.codebaseTool, + ); + } + + // OLD SEARCH AND REPLACE IS CURRENTLY NOT USED + // toolDefinitions.searchAndReplaceInFileTool + if (modelName?.includes("claude") || modelName?.includes("gpt-5")) { + tools.push(toolDefinitions.multiEditTool); + } else { + tools.push(toolDefinitions.editFileTool); + } + + // missing support for remote os calls: https://github.com/microsoft/vscode/issues/252269 + if (!isRemote) { + tools.push(toolDefinitions.grepSearchTool); + } + + return tools; +}; diff --git a/core/tools/parseArgs.ts b/core/tools/parseArgs.ts index 1e7709ddc..a31267854 100644 --- a/core/tools/parseArgs.ts +++ b/core/tools/parseArgs.ts @@ -20,11 +20,11 @@ export function getStringArg( ): string { if (!args || !(argName in args) || typeof args[argName] !== "string") { throw new Error( - `\`${argName}\` argument is required${allowEmpty ? "" : " and must not be empty"}. (type string)`, + `\`${argName}\` argument is required${allowEmpty ? "" : " and must not be empty or whitespace-only"}. (type string)`, ); } if (!allowEmpty && !args[argName].trim()) { - throw new Error(`Argument ${argName} must not be empty`); + throw new Error(`Argument ${argName} must not be empty or whitespace-only`); } return args[argName]; } diff --git a/core/tools/parseArgs.vitest.ts b/core/tools/parseArgs.vitest.ts index b501191f0..b2cee9fc5 100644 --- a/core/tools/parseArgs.vitest.ts +++ b/core/tools/parseArgs.vitest.ts @@ -102,26 +102,26 @@ describe("getStringArg", () => { it("should throw error when argument is missing", () => { const args = { otherArg: "test" }; expect(() => getStringArg(args, "name")).toThrowError( - "`name` argument is required and must not be empty. (type string)", + "`name` argument is required and must not be empty or whitespace-only. (type string)", ); }); it("should throw error when argument is not a string", () => { const args = { name: 123 }; expect(() => getStringArg(args, "name")).toThrowError( - "`name` argument is required and must not be empty. (type string)", + "`name` argument is required and must not be empty or whitespace-only. (type string)", ); }); it("should throw error when argument is empty and empty not allowed", () => { const args = { name: "" }; expect(() => getStringArg(args, "name")).toThrowError( - "Argument name must not be empty", + "Argument name must not be empty or whitespace-only", ); const argsWithSpace = { name: " " }; expect(() => getStringArg(argsWithSpace, "name")).toThrowError( - "Argument name must not be empty", + "Argument name must not be empty or whitespace-only", ); }); @@ -137,10 +137,10 @@ describe("getStringArg", () => { it("should handle null or undefined args", () => { expect(() => getStringArg(null, "name")).toThrowError( - "`name` argument is required and must not be empty. (type string)", + "`name` argument is required and must not be empty or whitespace-only. (type string)", ); expect(() => getStringArg(undefined, "name")).toThrowError( - "`name` argument is required and must not be empty. (type string)", + "`name` argument is required and must not be empty or whitespace-only. (type string)", ); }); }); @@ -161,14 +161,14 @@ describe("getOptionalStringArg", () => { it("should throw error when argument is not a string", () => { const args = { name: 123 }; expect(() => getOptionalStringArg(args, "name")).toThrowError( - "`name` argument is required and must not be empty. (type string)", + "`name` argument is required and must not be empty or whitespace-only. (type string)", ); }); it("should throw error when argument is empty and empty not allowed", () => { const args = { name: "" }; expect(() => getOptionalStringArg(args, "name")).toThrowError( - "Argument name must not be empty", + "Argument name must not be empty or whitespace-only", ); }); diff --git a/core/tools/searchWebGating.vitest.ts b/core/tools/searchWebGating.vitest.ts index e68acdd52..4ebb6e5b4 100644 --- a/core/tools/searchWebGating.vitest.ts +++ b/core/tools/searchWebGating.vitest.ts @@ -1,6 +1,6 @@ -import { test, expect } from "vitest"; -import { getConfigDependentToolDefinitions } from "./index"; +import { expect, test } from "vitest"; import { BuiltInToolNames } from "./builtIn"; +import { getConfigDependentToolDefinitions } from "./index"; test("searchWeb tool is only available when user is signed in", () => { // Test with signed-in user @@ -8,6 +8,8 @@ test("searchWeb tool is only available when user is signed in", () => { rules: [], enableExperimentalTools: false, isSignedIn: true, + isRemote: false, + modelName: "", }); const searchWebToolSignedIn = signedInTools.find( @@ -21,6 +23,8 @@ test("searchWeb tool is only available when user is signed in", () => { rules: [], enableExperimentalTools: false, isSignedIn: false, + isRemote: false, + modelName: "", }); const searchWebToolNotSignedIn = notSignedInTools.find( diff --git a/core/util/regexValidator.ts b/core/util/regexValidator.ts new file mode 100644 index 000000000..f65520a94 --- /dev/null +++ b/core/util/regexValidator.ts @@ -0,0 +1,169 @@ +/** + * Validates and sanitizes regex patterns for use with ripgrep + */ + +export interface RegexValidationResult { + isValid: boolean; + sanitizedQuery?: string; + error?: string; + warning?: string; +} + +/** + * Validates a regex pattern and attempts to sanitize common issues + * @param query The regex pattern to validate + * @returns Validation result with sanitized query if possible + */ +export function validateAndSanitizeRegex(query: string): RegexValidationResult { + // Check for common problematic patterns that often fail with ripgrep + const problematicPatterns = [ + { + // Triple-escaped quotes + pattern: /\\\\\\/g, + issue: "Triple backslash sequences may cause parsing errors", + fix: (s: string) => s.replace(/\\\\\\/g, "\\\\"), + }, + { + // Unescaped brackets/parentheses that are NOT part of valid regex constructs + pattern: /(? + s.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r"), + }, + ]; + + let sanitizedQuery = query; + let warnings: string[] = []; + + // Apply fixes for known issues + for (const check of problematicPatterns) { + if (check.pattern.test(query)) { + if (check.fix) { + sanitizedQuery = check.fix(sanitizedQuery); + warnings.push(`Fixed: ${check.issue}`); + } else { + warnings.push(`Warning: ${check.issue}`); + } + } + } + + // Try to compile as a JavaScript regex to catch basic syntax errors + try { + new RegExp(sanitizedQuery); + } catch (e) { + let errorMessage = e instanceof Error ? e.message : "Unknown error"; + // If it fails as a JS regex, it might still be valid for ripgrep + // (ripgrep supports some patterns JS doesn't), but warn the user + warnings.push(`Pattern may have syntax issues: ${errorMessage}`); + } + + // Check for patterns that are valid regex but might not work as expected with ripgrep + const ripgrepSpecificIssues = [ + { + pattern: /\\[0-7]{3}/g, + warning: "Octal escape sequences may not work as expected in ripgrep", + }, + { + pattern: /\(\?[ 0 ? warnings.join("; ") : undefined, + }; +} + +/** + * Escapes a literal string to be used as a regex pattern + * @param literal The literal string to escape + * @returns Escaped string safe for regex use + */ +export function escapeLiteralForRegex(literal: string): string { + // Escape all regex metacharacters + return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +/** + * Detects if a query looks like it's meant to be a literal search + * rather than a regex pattern + * @param query The search query + * @returns true if it appears to be a literal search + */ +export function looksLikeLiteralSearch(query: string): boolean { + // If it contains regex metacharacters but they're not escaped, + // and it doesn't look like an intentional regex pattern + const hasUnescapedMetachars = /[.*+?^${}()|[\]]/g.test(query); + const hasEscapedMetachars = /\\[.*+?^${}()|[\]\\]/g.test(query); + + // Check for regex constructs, but be more specific about what we consider regex + const hasEscapeSequences = /\\[dws]/g.test(query); // \d, \w, \s + const hasQuantifiers = /\{[0-9,]+\}/g.test(query); // {2,4}, {3} + + // Check for bracket patterns and distinguish between character classes and array access + const bracketPattern = /\[[^\]]*\]/g; + const brackets = query.match(bracketPattern); + let hasCharacterClasses = false; + + if (brackets) { + hasCharacterClasses = brackets.some((bracket) => { + const inside = bracket.slice(1, -1); // Remove [ ] + // Character class indicators: ranges (a-z), multiple chars, negation (^) + return /-/.test(inside) || inside.length > 1 || inside.startsWith("^"); + }); + } + + const hasRegexConstructs = + hasEscapeSequences || hasQuantifiers || hasCharacterClasses; + + // Likely a literal search if it has unescaped metachars but no regex constructs + return hasUnescapedMetachars && !hasEscapedMetachars && !hasRegexConstructs; +} + +/** + * Prepares a query for ripgrep by sanitizing problematic patterns + * @param query The search query + * @returns Object with sanitized query and any warnings + */ +export function prepareQueryForRipgrep(query: string): { + query: string; + warning?: string; +} { + // Check if it looks like a literal search that should be escaped + if (looksLikeLiteralSearch(query)) { + return { + query: escapeLiteralForRegex(query), + warning: + "Query contained special regex characters and was escaped for literal text search", + }; + } + + // Otherwise validate and sanitize as regex + const validation = validateAndSanitizeRegex(query); + + return { + query: validation.sanitizedQuery || query, + warning: validation.warning, + }; +} diff --git a/core/util/regexValidator.vitest.ts b/core/util/regexValidator.vitest.ts new file mode 100644 index 000000000..5c0bbd34d --- /dev/null +++ b/core/util/regexValidator.vitest.ts @@ -0,0 +1,310 @@ +import { describe, expect, it } from "vitest"; +import { + escapeLiteralForRegex, + looksLikeLiteralSearch, + prepareQueryForRipgrep, + validateAndSanitizeRegex, +} from "./regexValidator"; + +describe("validateAndSanitizeRegex", () => { + it("should accept valid basic regex patterns", () => { + const result = validateAndSanitizeRegex("function\\s+\\w+"); + expect(result.isValid).toBe(true); + expect(result.sanitizedQuery).toBe("function\\s+\\w+"); + expect(result.error).toBeUndefined(); + expect(result.warning).toBeUndefined(); + }); + + it("should fix triple-escaped sequences", () => { + const result = validateAndSanitizeRegex("\\\\\\"); + expect(result.isValid).toBe(true); + expect(result.sanitizedQuery).toBe("\\\\"); + expect(result.warning).toContain("Fixed: Triple backslash sequences"); + }); + + it("should fix raw tab characters", () => { + const result = validateAndSanitizeRegex("hello\tworld"); + expect(result.isValid).toBe(true); + expect(result.sanitizedQuery).toBe("hello\\tworld"); + expect(result.warning).toContain("Fixed: Raw whitespace characters"); + }); + + it("should fix raw newline characters", () => { + const result = validateAndSanitizeRegex("line1\nline2"); + expect(result.isValid).toBe(true); + expect(result.sanitizedQuery).toBe("line1\\nline2"); + expect(result.warning).toContain("Fixed: Raw whitespace characters"); + }); + + it("should warn about unescaped brackets without fixing", () => { + const result = validateAndSanitizeRegex("hello[world]"); + expect(result.isValid).toBe(true); + expect(result.sanitizedQuery).toBe("hello[world]"); + expect(result.warning).toContain( + "Warning: Unescaped brackets or parentheses", + ); + }); + + it("should handle multiple issues", () => { + const result = validateAndSanitizeRegex("function()\t\\\\\\"); + expect(result.isValid).toBe(true); + expect(result.sanitizedQuery).toBe("function()\\t\\\\"); + expect(result.warning).toContain("Fixed: Raw whitespace characters"); + expect(result.warning).toContain("Fixed: Triple backslash sequences"); + }); + + it("should warn about lookbehind assertions", () => { + const result = validateAndSanitizeRegex("(?<=foo)bar"); + expect(result.isValid).toBe(true); + expect(result.warning).toContain( + "Lookahead/lookbehind assertions require ripgrep to be compiled with PCRE2", + ); + }); +}); + +describe("escapeLiteralForRegex", () => { + it("should escape basic regex metacharacters", () => { + expect(escapeLiteralForRegex("hello.world")).toBe("hello\\.world"); + expect(escapeLiteralForRegex("test*")).toBe("test\\*"); + expect(escapeLiteralForRegex("file+")).toBe("file\\+"); + expect(escapeLiteralForRegex("query?")).toBe("query\\?"); + }); + + it("should escape brackets and braces", () => { + expect(escapeLiteralForRegex("array[0]")).toBe("array\\[0\\]"); + expect(escapeLiteralForRegex("{key}")).toBe("\\{key\\}"); + expect(escapeLiteralForRegex("func()")).toBe("func\\(\\)"); + }); + + it("should handle multiple metacharacters", () => { + expect(escapeLiteralForRegex("$regex.test(input)")).toBe( + "\\$regex\\.test\\(input\\)", + ); + }); + + it("should not escape normal characters", () => { + expect(escapeLiteralForRegex("hello world")).toBe("hello world"); + }); +}); + +describe("looksLikeLiteralSearch", () => { + it("should identify literal searches with unescaped metacharacters", () => { + expect(looksLikeLiteralSearch("hello.world")).toBe(true); + expect(looksLikeLiteralSearch("test*")).toBe(true); + expect(looksLikeLiteralSearch("func()")).toBe(true); + expect(looksLikeLiteralSearch("array[0]")).toBe(true); + }); + + it("should not identify regex patterns as literal", () => { + expect(looksLikeLiteralSearch("hello\\.world")).toBe(false); + expect(looksLikeLiteralSearch("\\d+")).toBe(false); + expect(looksLikeLiteralSearch("[a-z]+")).toBe(false); + expect(looksLikeLiteralSearch("a{2,4}")).toBe(false); + }); + + it("should handle plain text", () => { + expect(looksLikeLiteralSearch("hello world")).toBe(false); + expect(looksLikeLiteralSearch("simple text")).toBe(false); + }); +}); + +describe("prepareQueryForRipgrep", () => { + it("should escape literal-looking queries", () => { + const result = prepareQueryForRipgrep("hello.world"); + expect(result.query).toBe("hello\\.world"); + expect(result.warning).toContain("escaped for literal text search"); + }); + + it("should sanitize regex patterns", () => { + const result = prepareQueryForRipgrep("function\t\\\\\\"); + expect(result.query).toBe("function\\t\\\\"); + expect(result.warning).toContain("Fixed:"); + }); + + it("should handle plain text without changes", () => { + const result = prepareQueryForRipgrep("hello world"); + expect(result.query).toBe("hello world"); + expect(result.warning).toBeUndefined(); + }); + + describe("real-world examples", () => { + it("should escape file patterns", () => { + const result = prepareQueryForRipgrep("*.js"); + expect(result.query).toBe("\\*\\.js"); + expect(result.warning).toContain("escaped for literal text search"); + }); + + it("should escape function calls", () => { + const result = prepareQueryForRipgrep("console.log()"); + expect(result.query).toBe("console\\.log\\(\\)"); + expect(result.warning).toContain("escaped for literal text search"); + }); + + it("should not escape proper regex patterns", () => { + const result = prepareQueryForRipgrep("function\\s+\\w+"); + expect(result.query).toBe("function\\s+\\w+"); + expect(result.warning).toBeUndefined(); + }); + }); +}); + +describe("problematic patterns that originally failed", () => { + it("should handle triple-escaped quotes", () => { + const result = prepareQueryForRipgrep('\\\\\\"'); + expect(result.query).toBe('\\\\"'); // Triple backslash -> double backslash, quote stays + expect(result.warning).toContain("Fixed:"); + }); + + it("should handle newline-tab sequences", () => { + const result = prepareQueryForRipgrep("\n\t"); + expect(result.query).toBe("\\n\\t"); + expect(result.warning).toContain("Fixed:"); + }); + + it("should handle dollar signs in shell patterns", () => { + const result = prepareQueryForRipgrep("$(command)"); + expect(result.query).toBe("\\$\\(command\\)"); + expect(result.warning).toContain("escaped for literal text search"); + }); + + it("should handle escaped dollar signs", () => { + const result = prepareQueryForRipgrep("\\$\\("); + expect(result.query).toBe("\\$\\("); + expect(result.warning).toBeUndefined(); + }); +}); + +describe("patterns that should NOT be over-sanitized", () => { + describe("valid regex patterns that contain suspicious sequences", () => { + it("should not escape properly formed character classes", () => { + const result = prepareQueryForRipgrep("[a-zA-Z0-9_-]+"); + expect(result.query).toBe("[a-zA-Z0-9_-]+"); + expect(result.warning).toContain("Warning: Unescaped brackets"); // Warn but don't break + }); + + it("should not escape quantifiers in regex patterns", () => { + const result = prepareQueryForRipgrep("\\w{2,5}"); + expect(result.query).toBe("\\w{2,5}"); + expect(result.warning).toBeUndefined(); + }); + + it("should not escape properly formed lookarounds", () => { + const result = prepareQueryForRipgrep("(? { + const result = prepareQueryForRipgrep("console\\.log\\(\\)"); + expect(result.query).toBe("console\\.log\\(\\)"); + expect(result.warning).toBeUndefined(); + }); + }); + + describe("patterns that look problematic but are intentional", () => { + it("should not over-escape already escaped sequences", () => { + const result = prepareQueryForRipgrep("\\\\t"); // Already escaped tab + expect(result.query).toBe("\\\\t"); + expect(result.warning).toBeUndefined(); + }); + + it("should not double-escape backslashes in Windows paths", () => { + const result = prepareQueryForRipgrep("C:\\\\Users\\\\file"); + expect(result.query).toBe("C:\\\\Users\\\\file"); + expect(result.warning).toBeUndefined(); + }); + + it("should not break raw strings that contain regex-like patterns", () => { + const result = prepareQueryForRipgrep('"\\d+\\s+\\w+"'); + expect(result.query).toBe('"\\d+\\s+\\w+"'); // Escaped sequences in quotes should stay + expect(result.warning).toBeUndefined(); + }); + + it("should not break JSON with escaped quotes", () => { + const result = prepareQueryForRipgrep('"key": "value"'); + expect(result.query).toBe('"key": "value"'); + expect(result.warning).toBeUndefined(); + }); + }); + + describe("complex patterns that mix literal and regex", () => { + it("should not break URLs with query parameters", () => { + const result = prepareQueryForRipgrep( + "https://api\\.example\\.com\\?param=\\w+", + ); + expect(result.query).toBe("https://api\\.example\\.com\\?param=\\w+"); + expect(result.warning).toBeUndefined(); + }); + + it("should not break file paths with regex metacharacters", () => { + const result = prepareQueryForRipgrep("/path/to/file\\.[jt]sx?"); + expect(result.query).toBe("/path/to/file\\.[jt]sx?"); + expect(result.warning).toContain("Warning: Unescaped brackets"); // Warn but preserve + }); + + it("should handle mixed escaped and unescaped patterns correctly", () => { + // This is a regex that matches function calls with optional whitespace + const result = prepareQueryForRipgrep("\\w+\\s*\\("); + expect(result.query).toBe("\\w+\\s*\\("); + expect(result.warning).toBeUndefined(); + }); + }); + + describe("edge cases that could trigger false positives", () => { + it("should not treat mathematical expressions as problematic", () => { + const result = prepareQueryForRipgrep("a + b * c"); + expect(result.query).toBe("a \\+ b \\* c"); // Should be escaped as literal + expect(result.warning).toContain("escaped for literal text search"); + }); + + it("should not break regex that uses word boundaries", () => { + const result = prepareQueryForRipgrep("\\bclass\\b"); + expect(result.query).toBe("\\bclass\\b"); + expect(result.warning).toBeUndefined(); + }); + + it("should not break negated character classes", () => { + const result = prepareQueryForRipgrep("[^a-z]+"); + expect(result.query).toBe("[^a-z]+"); + expect(result.warning).toContain("Warning: Unescaped brackets"); // Warn but preserve + }); + + it("should not treat IPv4 addresses as problematic regex", () => { + const result = prepareQueryForRipgrep("192.168.1.1"); + expect(result.query).toBe("192\\.168\\.1\\.1"); // Should be escaped as literal + expect(result.warning).toContain("escaped for literal text search"); + }); + + it("should not break hex color codes", () => { + const result = prepareQueryForRipgrep("#[0-9a-fA-F]{6}"); + expect(result.query).toBe("#[0-9a-fA-F]{6}"); + expect(result.warning).toContain("Warning: Unescaped brackets"); // Warn but preserve regex + }); + }); + + describe("patterns that should preserve user intent", () => { + it("should not sanitize intentional regex alternation", () => { + const result = prepareQueryForRipgrep("(foo|bar)"); + expect(result.query).toBe("\\(foo\\|bar\\)"); // Should be escaped as literal since unescaped + expect(result.warning).toContain("escaped for literal text search"); + }); + + it("should preserve escaped alternation in regex", () => { + const result = prepareQueryForRipgrep("\\(foo\\|bar\\)"); + expect(result.query).toBe("\\(foo\\|bar\\)"); + expect(result.warning).toBeUndefined(); + }); + + it("should not break SQL LIKE patterns when used as literal search", () => { + const result = prepareQueryForRipgrep("name LIKE '%john%'"); + expect(result.query).toBe("name LIKE '%john%'"); // No regex metacharacters here + expect(result.warning).toBeUndefined(); + }); + + it("should not break CSS selectors when used as literal search", () => { + const result = prepareQueryForRipgrep(".class-name > div:nth-child(2)"); + expect(result.query).toBe("\\.class-name > div:nth-child\\(2\\)"); + expect(result.warning).toContain("escaped for literal text search"); + }); + }); +}); diff --git a/docs/customization/models.mdx b/docs/customization/models.mdx index d4b02be76..a05c22177 100644 --- a/docs/customization/models.mdx +++ b/docs/customization/models.mdx @@ -16,18 +16,18 @@ description: "These blocks form the foundation of the entire assistant experienc ### Best Models by Role -| Model role | Best open models | Best closed models | Notes | -|:------------|:------------------|:-------------------|:--------| -| Agent / Plan | Qwen 3 Coder (480B), Qwen 3 Coder (30B), Devstral (24B), GLM 4.5 (355B), GLM 4.5 Air (106B), Kimi K2 (1T), gpt-oss (120B), gpt-oss (20B) | [Claude Opus 4.1](https://hub.continue.dev/anthropic/claude-4-1-opus), [Claude Sonnet 4](https://hub.continue.dev/anthropic/claude-4-sonnet), [GPT-5](https://hub.continue.dev/openai/gpt-5), [Gemini 2.5 Pro](https://hub.continue.dev/google/gemini-2.5-pro) | Closed models are slightly better than open models | -| Chat / Edit | Qwen 3 Coder (480B), Qwen 3 Coder (30B), gpt-oss (120B), gpt-oss (20B) | [Claude Opus 4.1](https://hub.continue.dev/anthropic/claude-4-1-opus), [Claude Sonnet 4](https://hub.continue.dev/anthropic/claude-4-sonnet), [GPT-5](https://hub.continue.dev/openai/gpt-5), [Gemini 2.5 Pro](https://hub.continue.dev/google/gemini-2.5-pro) | Closed and open models have pretty similar performance | -| Autocomplete | [QwenCoder2.5 (1.5B)](https://hub.continue.dev/ollama/qwen2.5-coder-1.5b), QwenCoder2.5 (7B) | [Codestral](https://hub.continue.dev/mistral/codestral), Mercury Coder | Closed models are slightly better than open models | -| Apply | N/A | [Relace Instant Apply](https://hub.continue.dev/relace/instant-apply), [Morph Fast Apply](https://hub.continue.dev/morphllm/morph-v2) | Open models are basically non-existent / not good enough for this model role | -| Embed | N/A | [Voyage Code 3](https://hub.continue.dev/voyageai/voyage-code-3), [Morph Embeddings](https://hub.continue.dev/morphllm/morph-embedding-v2), Codestral Embed | Open models are basically non-existent / not good enough for this model role | -| Rerank | zerank-1, zerank-1-small | rerank-2.5, Relace Code Rerank, [Morph Rerank](https://hub.continue.dev/morphllm/morph-rerank-v2) | Open models are beginning to emerge for this model role | -| Next Edit | Zeta | Mercury Coder | Closed models are significantly better than open models | +| Model role | Best open models | Best closed models | Notes | +| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------- | +| Agent / Plan | Qwen 3 Coder (480B), Qwen 3 Coder (30B), Devstral (27B), Devstral, GLM 4.5 (355B), GLM 4.5 Air (106B), Kimi K2 (1T), gpt-oss (120B), gpt-oss (20B) | [Claude Opus 4.1](https://hub.continue.dev/anthropic/claude-4-1-opus), [Claude Sonnet 4](https://hub.continue.dev/anthropic/claude-4-sonnet), [GPT-5](https://hub.continue.dev/openai/gpt-5), [Gemini 2.5 Pro](https://hub.continue.dev/google/gemini-2.5-pro) | Closed models are slightly better than open models | +| Chat / Edit | Qwen 3 Coder (480B), Qwen 3 Coder (30B), gpt-oss (120B), gpt-oss (20B) | [Claude Opus 4.1](https://hub.continue.dev/anthropic/claude-4-1-opus), [Claude Sonnet 4](https://hub.continue.dev/anthropic/claude-4-sonnet), [GPT-5](https://hub.continue.dev/openai/gpt-5), [Gemini 2.5 Pro](https://hub.continue.dev/google/gemini-2.5-pro) | Closed and open models have pretty similar performance | +| Autocomplete | [QwenCoder2.5 (1.5B)](https://hub.continue.dev/ollama/qwen2.5-coder-1.5b), QwenCoder2.5 (7B) | [Codestral](https://hub.continue.dev/mistral/codestral), Mercury Coder | Closed models are slightly better than open models | +| Apply | N/A | [Relace Instant Apply](https://hub.continue.dev/relace/instant-apply), [Morph Fast Apply](https://hub.continue.dev/morphllm/morph-v2) | Open models are basically non-existent / not good enough for this model role | +| Embed | Nomic Embed Text | [Voyage Code 3](https://hub.continue.dev/voyageai/voyage-code-3), [Morph Embeddings](https://hub.continue.dev/morphllm/morph-embedding-v2), Codestral Embed, | Open embeddings models are emerging but closed models still perform better | +| Rerank | zerank-1, zerank-1-small | rerank-2.5, Relace Code Rerank, [Morph Rerank](https://hub.continue.dev/morphllm/morph-rerank-v2) | Open models are beginning to emerge for this model role | +| Next Edit | Zeta | Mercury Coder | Closed models are significantly better than open models | ## Learn More About Model Blocks -Continue supports [many model providers](/customize/model-providers/top-level/openai), including Anthropic, OpenAI, Gemini, Ollama, Amazon Bedrock, Azure, xAI, DeepSeek, and more. Models can have various roles like `chat`, `edit`, `apply`, `autocomplete`, `embed`, and `rerank`. +Continue supports [many model providers](/customize/model-providers/top-level/openai), including Anthropic, OpenAI, Gemini, Ollama, Amazon Bedrock, Azure, xAI, and more. Models can have various roles like `chat`, `edit`, `apply`, `autocomplete`, `embed`, and `rerank`. Read more about roles [here](/customize/model-roles) and view [`models`](/reference#models) in the YAML Reference. diff --git a/docs/customize/model-providers/top-level/azure.mdx b/docs/customize/model-providers/top-level/azure.mdx index b59c2071c..2fd9b32e4 100644 --- a/docs/customize/model-providers/top-level/azure.mdx +++ b/docs/customize/model-providers/top-level/azure.mdx @@ -92,7 +92,7 @@ If you use Azure Machine Learning Studio to deploy Codestral: ## How to Configure Azure AI Foundry Embeddings Models -We recommend configuring **text-embedding-3-large** as your embeddings model. +For recommended embeddings models, please refer to our [Model Recommendations page](/customization/models). diff --git a/docs/customize/model-providers/top-level/deepseek.mdx b/docs/customize/model-providers/top-level/deepseek.mdx index 376a33173..018ac4186 100644 --- a/docs/customize/model-providers/top-level/deepseek.mdx +++ b/docs/customize/model-providers/top-level/deepseek.mdx @@ -41,7 +41,7 @@ We recommend configuring **DeepSeek Chat** as your chat model. ## How to Set Up DeepSeek Autocomplete Models -We recommend configuring **DeepSeek Coder** as your autocomplete model. +For recommended autocomplete models, please refer to our [Model Recommendations page](/customization/models). diff --git a/docs/customize/model-providers/top-level/gemini.mdx b/docs/customize/model-providers/top-level/gemini.mdx index 2e85be425..36a85ca8b 100644 --- a/docs/customize/model-providers/top-level/gemini.mdx +++ b/docs/customize/model-providers/top-level/gemini.mdx @@ -48,7 +48,7 @@ Gemini currently does not offer any autocomplete models. ## How to Configure Gemini Embeddings Models -We recommend configuring **text-embedding-004** as your embeddings model. +For recommended embeddings models, please refer to our [Model Recommendations page](/customization/models). diff --git a/docs/customize/model-providers/top-level/ollama.mdx b/docs/customize/model-providers/top-level/ollama.mdx index cdc4fa720..cd9a0b45f 100644 --- a/docs/customize/model-providers/top-level/ollama.mdx +++ b/docs/customize/model-providers/top-level/ollama.mdx @@ -65,7 +65,7 @@ We recommend configuring **Qwen2.5-Coder 1.5B** as your autocomplete model. ## How to Set Up Ollama Embeddings Models -We recommend configuring **Nomic Embed Text** as your embeddings model. +For recommended embeddings models, please refer to our [Model Recommendations page](/customization/models). @@ -123,7 +123,7 @@ To configure a remote instance of Ollama, add the `"apiBase"` property to your m ] } ``` - + ## How to Configure Model Capabilities in Ollama diff --git a/docs/docs.json b/docs/docs.json index 369944933..d0308d6ee 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -364,6 +364,10 @@ "source": "/hub/blocks", "destination": "/hub/blocks/intro" }, + { + "source": "/hub/agents/intro", + "destination": "/hub/assistants/intro" + }, { "source": "/customize", "destination": "/customization/overview" @@ -1099,6 +1103,10 @@ { "source": "/customize/model-providers", "destination": "/customize/model-providers/overview" + }, + { + "source": "/features/edit/next-edit", + "destination": "/features/autocomplete/next-edit" } ] } diff --git a/docs/features/agent/model-setup.mdx b/docs/features/agent/model-setup.mdx index c1ef8fb82..ae8e5675f 100644 --- a/docs/features/agent/model-setup.mdx +++ b/docs/features/agent/model-setup.mdx @@ -27,22 +27,7 @@ Instead of relying solely on native tool calling APIs (which vary between provid - **Better reliability** - Models that struggle with native tools often perform better with system message tools - **Seamless switching** - Change between providers without modifying your workflow -### What Models Are Recommended for Agent Mode - -For the best Agent mode experience, we recommend models with strong reasoning and instruction-following capabilities: - -**Premium Models:** - -- **Claude Sonnet 4** (Anthropic) - Our top recommendation for its exceptional tool use and reasoning -- **GPT-4** models (OpenAI) - Excellent native tool support -- **DeepSeek** models - Strong performance with competitive pricing - -**Local Models:** -While more limited in capabilities, these models can work with system message tools: - -- Qwen2.5-Coder 32B - Best local option for Agent mode -- Devstral 27B - Good for code-specific tasks -- Smaller models (7B-13B) - May struggle with complex tool interactions +For recommended Agent models, please refer to our [Model Recommendations page](/customization/models). ### How to Configure Agent Mode diff --git a/docs/features/autocomplete/model-setup.mdx b/docs/features/autocomplete/model-setup.mdx index 30529259b..879939c14 100644 --- a/docs/features/autocomplete/model-setup.mdx +++ b/docs/features/autocomplete/model-setup.mdx @@ -10,49 +10,11 @@ Setting up the right model for autocomplete is crucial for a smooth coding exper For a complete comparison of all autocomplete models, see our [comprehensive model recommendations](/customization/models#recommended-models). -## Recommended Models for Autocomplete in Continue - -### Hosted (Best Performance) - -For the highest quality autocomplete suggestions, we recommend **[Codestral](https://hub.continue.dev/mistral/codestral)** from Mistral. - -This model is specifically designed for code completion and offers excellent performance across multiple programming languages. - -**Codestral Quick Setup:** - -1. Get your API key from [Mistral AI](https://console.mistral.ai) -2. Add [Codestral](https://hub.continue.dev/mistral/codestral) to your assistant on Continue Hub -3. Add `MISTRAL_API_KEY` as a [User Secret](https://docs.continue.dev/hub/secrets/secret-types#user-secrets) on Continue Hub [here](https://hub.continue.dev/settings/secrets) -4. Click `Reload config` in the assistant selector in the Continue IDE extension - -### Hosted (Best Speed/Quality Tradeoff) - -For fast, quality autocomplete suggestions, we recommend **[Mercury Coder Small](https://hub.continue.dev/inceptionlabs/mercury-coder-small)** from Inception. - -This model is specifically designed for code completion and is particularly fast because it is a diffusion model. - -**Mercury Coder Small Quick Setup:** - -1. Get your API key from [Inception](https://platform.inceptionlabs.ai/) -2. Add [Mercury Coder Small](https://hub.continue.dev/inceptionlabs/mercury-coder-small) to your assistant on Continue Hub -3. Add `INCEPTION_API_KEY` as a [User Secret](https://docs.continue.dev/hub/secrets/secret-types#user-secrets) on Continue Hub [here](https://hub.continue.dev/settings/secrets) -4. Click `Reload config` in the assistant selector in the Continue IDE extension - -### Local (Offline / Privacy First) - -For a fully local autocomplete experience, we recommend **[Qwen 2.5 Coder 1.5B](https://hub.continue.dev/ollama/qwen2.5-coder-1.5b)**. - -This model provides good suggestions while keeping your code completely private. - -**Quick Setup:** - -1. Install [Ollama](https://ollama.ai/) -2. Add [Qwen 2.5 Coder 1.5B](https://hub.continue.dev/ollama/qwen2.5-coder-1.5b) to your assistant on Continue Hub -3. Click `Reload config` in the assistant selector in the Continue IDE extension +For model recommendations, please refer to our [Model Recommendations page](/customization/models). ## Next Edit Model -For proactive code prediction that anticipates your next edit, Continue supports specialized [Next Edit](/features/edit/next-edit) models: +For proactive code prediction that anticipates your next edit, Continue supports specialized [Next Edit](/features/autocomplete/next-edit) models: **Supported Next Edit model:** diff --git a/docs/features/chat/model-setup.mdx b/docs/features/chat/model-setup.mdx index 0f881d6b0..409b1b7a0 100644 --- a/docs/features/chat/model-setup.mdx +++ b/docs/features/chat/model-setup.mdx @@ -7,16 +7,7 @@ The model you use for for Chat mode will be For a comprehensive comparison of all available models by role, see our [model recommendations table](/customization/models#recommended-models). -## What Models Are Recommended for Chat? - -Our strong recommendation is to use [Claude Sonnet 4](https://hub.continue.dev/anthropic/claude-4-sonnet) from Anthropic. - -Its strong tool calling and reasoning capabilities make it the best model for Agent mode. - -1. Get your API key from [Anthropic](https://console.anthropic.com/) -2. Add [Claude Sonnet 4](https://hub.continue.dev/anthropic/claude-4-sonnet) to your assistant on Continue Hub -3. Add `ANTHROPIC_API_KEY` as a [User Secret](https://docs.continue.dev/hub/secrets/secret-types#user-secrets) on Continue Hub [here](https://hub.continue.dev/settings/secrets) -4. Click `Reload config` in the assistant selector in the Continue IDE extension +For model recommendations, please refer to our [Model Recommendations page](/customization/models). ### What Other Hosted Models Are Available? diff --git a/docs/features/edit/how-it-works.mdx b/docs/features/edit/how-it-works.mdx index 79921ba7b..50b3ab343 100644 --- a/docs/features/edit/how-it-works.mdx +++ b/docs/features/edit/how-it-works.mdx @@ -14,7 +14,7 @@ When you start an edit session, Continue: If you accept the diff, we remove the previously highlighted lines, and if you reject the diff, we remove the proposed changes. -**Looking for AI that predicts your next edit?** Check out [Next Edit](/features/edit/next-edit), an experimental feature that proactively suggests code changes before you even start typing, going beyond traditional autocomplete to anticipate entire code modifications. +**Looking for AI that predicts your next edit?** Check out [Next Edit](/features/autocomplete/next-edit), an experimental feature that proactively suggests code changes before you even start typing, going beyond traditional autocomplete to anticipate entire code modifications. If you would like to view the exact prompt that is sent to the model during an edit, you can [find it in the prompt logs](/troubleshooting#check-the-logs). diff --git a/docs/features/edit/model-setup.mdx b/docs/features/edit/model-setup.mdx index 1760c5aee..35694ce97 100644 --- a/docs/features/edit/model-setup.mdx +++ b/docs/features/edit/model-setup.mdx @@ -16,10 +16,7 @@ The recommended models and how to set them up can be found [here](/features/chat We also recommend setting up an Apply model for the best Edit experience. -**Recommended Apply models:** - -- [Morph v3](https://hub.continue.dev/morphllm/morph-v2) -- [Relace Instant Apply](https://hub.continue.dev/relace/instant-apply) +For recommended Apply models, please refer to our [Model Recommendations page](/customization/models). ## How to Determine Model Compatibility diff --git a/docs/guides/ollama-guide.mdx b/docs/guides/ollama-guide.mdx index c908f2579..d2ada69cb 100644 --- a/docs/guides/ollama-guide.mdx +++ b/docs/guides/ollama-guide.mdx @@ -14,7 +14,7 @@ Before getting started, ensure your system meets these requirements: ## How to Install Ollama - Step-by-Step -### Step 1: How to Install Ollama +### Step 1: Install Ollama Choose the installation method for your operating system: @@ -29,7 +29,7 @@ curl -fsSL https://ollama.ai/install.sh | sh # Download from ollama.ai ``` -### Step 2: How to Start Ollama +### Step 2: Start Ollama Service After installation, start the Ollama service: @@ -40,12 +40,17 @@ ollama serve # Verify it's running curl http://localhost:11434 # Should return "Ollama is running" + +# Check Ollama version +ollama --version ``` -### Step 3: How to Download Models +### Step 3: Download Models -**Important**: Always use `ollama pull` instead of `ollama run` to download models. The `run` command starts an interactive session which isn't needed for Continue. + **Important**: Always use `ollama pull` instead of `ollama run` to download + models. The `run` command starts an interactive session which isn't needed for + Continue. Download models using the exact tag specified: @@ -62,12 +67,15 @@ ollama list ``` **Common Model Tags:** + - `:latest` - Default version (used if no tag specified) - `:32b`, `:7b`, `:1.5b` - Parameter count versions - `:instruct`, `:base` - Model variants -If a model page shows `deepseek-r1:32b` on Ollama's website, you must pull it with that exact tag. Using just `deepseek-r1` will pull `:latest` which may be a different size. + If a model page shows `deepseek-r1:32b` on Ollama's website, you must pull it + with that exact tag. Using just `deepseek-r1` will pull `:latest` which may be + a different size. ## How to Configure Ollama with Continue @@ -76,10 +84,9 @@ There are multiple ways to configure Ollama models in Continue: ### Method 1: Using Hub Model Blocks in Local config.yaml -The easiest way is to use pre-configured model blocks from the Continue Hub in your local configuration: +The easiest way is to use [pre-configured model blocks](/reference#local-blocks) from the Continue Hub in your local configuration: -```yaml -# ~/.continue/assistants/My Local Assistant.yaml +```yaml title="~/.continue/assistants/My Local Assistant.yaml" name: My Local Assistant version: 0.0.1 schema: v1 @@ -90,20 +97,20 @@ models: ``` -**Important**: Hub blocks only provide configuration - you still need to pull the model locally. The hub block `ollama/deepseek-r1-32b` configures Continue to use `model: deepseek-r1:32b`, but the actual model must be installed: -```bash -# Check what the hub block expects (view on hub.continue.dev) -# Then pull that exact model tag locally -ollama pull deepseek-r1:32b # Required for ollama/deepseek-r1-32b hub block -``` -If the model isn't installed, Ollama will return: `404 model "deepseek-r1:32b" not found, try pulling it first` + **Important**: Hub blocks only provide configuration - you still need to pull + the model locally. The hub block `ollama/deepseek-r1-32b` configures Continue + to use `model: deepseek-r1:32b`, but the actual model must be installed: + ```bash # Check what the hub block expects (view on hub.continue.dev) # Then + pull that exact model tag locally ollama pull deepseek-r1:32b # Required for + ollama/deepseek-r1-32b hub block ``` If the model isn't installed, Ollama will + return: `404 model "deepseek-r1:32b" not found, try pulling it first` ### Method 2: Using Autodetect Continue can automatically detect available Ollama models. You can configure this in your YAML: -```yaml +```yaml title="~/.continue/config.yaml" models: - name: Autodetect provider: ollama @@ -112,6 +119,8 @@ models: - chat - edit - apply + - rerank + - autocomplete ``` Or use it through the GUI: @@ -122,7 +131,12 @@ Or use it through the GUI: 4. Select your desired model from the detected list -The Autodetect feature scans your local Ollama installation and lists all available models. When set to `AUTODETECT`, Continue will dynamically populate the model list based on what's installed locally via `ollama list`. This is useful for quickly switching between models without manual configuration. + The Autodetect feature scans your local Ollama installation and lists all + available models. When set to `AUTODETECT`, Continue will dynamically populate + the model list based on what's installed locally via `ollama list`. This is + useful for quickly switching between models without manual configuration. For + any roles not covered by the detected models, you may need to manually + configure them. You can update `apiBase` with the IP address of a remote machine serving Ollama. @@ -135,12 +149,12 @@ For custom configurations or models not on the hub: models: - name: DeepSeek R1 32B provider: ollama - model: deepseek-r1:32b # Must match exactly what `ollama list` shows + model: deepseek-r1:32b # Must match exactly what `ollama list` shows apiBase: http://localhost:11434 roles: - chat - edit - capabilities: # Add if not auto-detected + capabilities: # Add if not auto-detected - tool_use - name: Qwen2.5-Coder 1.5B provider: ollama @@ -161,14 +175,16 @@ models: provider: ollama model: deepseek-r1:latest capabilities: - - tool_use # Add this to enable tools + - tool_use # Add this to enable tools ``` -**Known Issue**: Some models like DeepSeek R1 may show "Agent mode is not supported" or "does not support tools" even with capabilities configured. This is a known limitation where the model's actual tool support differs from its advertised capabilities. + **Known Issue**: Some models like DeepSeek R1 may show "Agent mode is not + supported" or "does not support tools" even with capabilities configured. This + is a known limitation where the model's actual tool support differs from its + advertised capabilities. - #### If Agent Mode Shows "Not Supported" 1. First, add `capabilities: [tool_use]` to your model config @@ -181,29 +197,70 @@ See the [Model Capabilities guide](/customize/deep-dives/model-capabilities) for For optimal performance, consider these advanced configuration options: -- Memory optimization: Adjust `num_ctx` for context window size -- GPU acceleration: Use `num_gpu` to control GPU layers -- Custom model parameters: Temperature, top_p, top_k settings -- Performance tuning: Batch size and threading options +```yaml +models: + - name: Optimized DeepSeek + provider: ollama + model: deepseek-r1:32b + contextLength: 8192 # Adjust context window (default varies by model) + completionOptions: + temperature: 0.7 # Controls randomness (0.0-1.0) + top_p: 0.9 # Nucleus sampling threshold + top_k: 40 # Top-k sampling + num_predict: 2048 # Max tokens to generate + # Ollama-specific options (set via environment or modelfile) + # num_gpu: 35 # Number of GPU layers to offload + # num_thread: 8 # CPU threads to use +``` + +For GPU acceleration and memory tuning, create an Ollama Modelfile: + +``` +# Create custom model with optimizations +FROM deepseek-r1:32b +PARAMETER num_gpu 35 +PARAMETER num_thread 8 +PARAMETER num_ctx 4096 +``` ## What Are the Best Practices for Ollama ### How to Choose the Right Model -Choose models based on your specific needs: +Choose models based on your specific needs (see [recommended models](/customization/models#recommended-models) for more options): -1. **Code Generation**: Use CodeLlama or Mistral -2. **Chat**: Llama2 or Mistral -3. **Specialized Tasks**: Domain-specific models +1. **Code Generation**: + + - `qwen2.5-coder:7b` - Excellent for code completion + - `codellama:13b` - Strong general coding support + - `deepseek-coder:6.7b` - Fast and efficient + +2. **Chat & Reasoning**: + + - `llama3.1:8b` - Latest Llama with tool support + - `mistral:7b` - Fast and versatile + - `deepseek-r1:32b` - Advanced reasoning capabilities + +3. **Autocomplete**: + + - `qwen2.5-coder:1.5b` - Lightweight and fast + - `starcoder2:3b` - Optimized for code completion + +4. **Memory Requirements**: + - 1.5B-3B models: ~4GB RAM + - 7B models: ~8GB RAM + - 13B models: ~16GB RAM + - 32B models: ~32GB RAM ### How to Optimize Performance To get the best performance from Ollama: -- Monitor system resources -- Adjust context window size -- Use appropriate model sizes -- Enable GPU acceleration when available +- Monitor system resources with `ollama ps` to see memory usage +- Adjust context window size based on available RAM +- Use appropriate model sizes for your hardware +- Enable GPU acceleration when available (NVIDIA CUDA or AMD ROCm) +- Use `ollama logs` to debug performance issues ## How to Troubleshoot Ollama Issues @@ -214,7 +271,8 @@ To get the best performance from Ollama: This error occurs when the model isn't installed locally: **Problem**: Using a hub block or config that references a model not yet pulled -**Solution**: +**Solution**: + ```bash # Check what models you have ollama list @@ -227,6 +285,7 @@ ollama pull model-name:tag # e.g., deepseek-r1:32b **Problem**: `ollama pull deepseek-r1` installs `:latest` but hub block expects `:32b` **Solution**: Always pull with the exact tag: + ```bash # Wrong - pulls :latest ollama pull deepseek-r1 @@ -239,6 +298,7 @@ ollama pull deepseek-r1:32b **Problem**: Model doesn't support tools/function calling **Solutions**: + 1. Add `capabilities: [tool_use]` to your model config 2. If still not working, the model may not actually support tools 3. Switch to a model with confirmed tool support (Llama 3.1, Mistral) @@ -247,6 +307,7 @@ ollama pull deepseek-r1:32b **Problem**: Unclear how to use hub models locally **Solution**: Create a local assistant file: + ```yaml # ~/.continue/assistants/Local.yaml name: Local Assistant @@ -269,13 +330,29 @@ models: - Model too large: Check available memory with `ollama ps` - GPU issues: Verify CUDA/ROCm installation for GPU acceleration - Slow generation: Adjust `num_gpu` layers in model configuration +- Check system diagnostics: `ollama ps` for active models and memory usage ## What Are Example Workflows with Ollama ### How to Use Ollama for Code Generation -``` -# Example: Generate a FastAPI endpointdef create_user_endpoint(): # Continue will help generate the implementation pass +```python +# Example: Generate a FastAPI endpoint +from fastapi import FastAPI, HTTPException +from pydantic import BaseModel + +app = FastAPI() + +class User(BaseModel): + name: str + email: str + age: int + +@app.post("/users/") +async def create_user(user: User): + # Continue will help complete this implementation + # Use Cmd+I (Mac) or Ctrl+I (Windows/Linux) to generate code + pass ``` ### How to Use Ollama for Code Review @@ -293,4 +370,4 @@ Ollama with Continue provides a powerful local development environment for AI-as --- -_This guide is based on Ollama v0.1.x and Continue v0.8.x. Please check for updates regularly._ +_This guide is based on Ollama v0.11.x and Continue v1.1.x. Please check for updates regularly._ diff --git a/extensions/cli/BUILD.md b/extensions/cli/BUILD.md new file mode 100644 index 000000000..553660f94 --- /dev/null +++ b/extensions/cli/BUILD.md @@ -0,0 +1,74 @@ +# Build Process Documentation + +## Overview + +The Continue CLI uses esbuild to bundle the application along with local packages (`@continuedev/config-yaml` and `@continuedev/openai-adapters`) into a single distributable file. This ensures that users who install the CLI from npm don't need to worry about local file references. + +## Build Steps + +1. **Install dependencies**: `npm install` +2. **Build**: `npm run build` + - This first builds the local packages + - Then bundles everything with esbuild + +## How it Works + +### Bundling Strategy + +The `build.mjs` script uses esbuild to: + +- Bundle all TypeScript/JavaScript code into a single ES module +- Include local packages (`@continuedev/config-yaml`, `@continuedev/openai-adapters`) directly in the bundle +- Keep problematic or native dependencies external (e.g., `@sentry/profiling-node`, `winston`, `express`) +- Create a wrapper script (`dist/cn.js`) with the proper shebang for CLI execution + +### Key Features + +- **Local Package Bundling**: Local packages are bundled directly, avoiding `file:` reference issues +- **Stub for Optional Dependencies**: `react-devtools-core` is stubbed to prevent runtime errors +- **CommonJS Compatibility**: Adds `createRequire` to support packages that use dynamic requires +- **Source Maps**: Generates source maps for debugging +- **Metadata**: Creates `dist/meta.json` with bundle analysis information + +## Testing + +### Smoke Tests + +Run smoke tests to verify the build: + +```bash +npm run test:smoke +``` + +The smoke tests verify: + +- Bundle files exist +- CLI commands work (--version, --help) +- Bundle size is reasonable (<20MB) +- Local packages are properly bundled +- No missing runtime dependencies + +## Troubleshooting + +### Common Issues + +1. **Module not found errors**: Check if the module needs to be added to the external list in `build.mjs` +2. **Native module issues**: Native modules should be marked as external +3. **Bundle too large**: Review bundled packages in `dist/meta.json` and consider marking large packages as external + +### Analyzing the Bundle + +After building, check `dist/meta.json` to see: + +- What packages were bundled +- Bundle size breakdown +- Input/output file mappings + +## Publishing + +When publishing to npm: + +1. The bundled files in `dist/` are included +2. Users install via `npm install -g @continuedev/cli` +3. The `cn` command becomes available globally +4. No local file references or missing dependencies diff --git a/extensions/cli/build.mjs b/extensions/cli/build.mjs new file mode 100644 index 000000000..f5f20778c --- /dev/null +++ b/extensions/cli/build.mjs @@ -0,0 +1,97 @@ +#!/usr/bin/env node + +import * as esbuild from "esbuild"; +import { chmodSync, writeFileSync } from "fs"; +import { dirname, resolve } from "path"; +import { fileURLToPath } from "url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +// List of packages to mark as external (ONLY native modules that cannot be bundled) +// Note: Everything else will be bundled to create a self-contained CLI +// Users should not need to install any additional dependencies +const external = [ + "@sentry/profiling-node", // Contains native profiler bindings (optional) + "fsevents", // macOS native file watcher (optional dependency) +]; + +console.log("Building CLI with esbuild..."); + +// Plugin to handle optional react-devtools-core +const optionalDevtoolsPlugin = { + name: "optional-devtools", + setup(build) { + build.onResolve({ filter: /^react-devtools-core$/ }, () => { + // Return path to our stub instead of marking as external + return { path: resolve(__dirname, "stubs/react-devtools-core.js") }; + }); + }, +}; + +try { + const result = await esbuild.build({ + entryPoints: ["src/index.ts"], + bundle: true, + platform: "node", + target: "node18", + format: "esm", + outfile: "dist/index.js", + external, + sourcemap: true, + minify: true, // Minify for smaller bundle size + metafile: true, + plugins: [optionalDevtoolsPlugin], + + // Handle .js extensions in imports + resolveExtensions: [".ts", ".tsx", ".js", ".jsx", ".json"], + + // Handle TypeScript paths and local packages + alias: { + "@continuedev/config-yaml": resolve( + __dirname, + "../../packages/config-yaml/dist/index.js", + ), + "@continuedev/openai-adapters": resolve( + __dirname, + "../../packages/openai-adapters/dist/index.js", + ), + "@continuedev/config-types": resolve( + __dirname, + "../../packages/config-types/dist/index.js", + ), + core: resolve(__dirname, "../../core"), + "@continuedev/fetch": resolve( + __dirname, + "../../packages/fetch/dist/index.js", + ), + "@continuedev/llm-info": resolve( + __dirname, + "../../packages/llm-info/dist/index.js", + ), + }, + + // Add banner to create require for CommonJS packages + banner: { + js: `import { createRequire } from 'module'; +const require = createRequire(import.meta.url);`, + }, + }); + + // Write metafile for analysis + writeFileSync("dist/meta.json", JSON.stringify(result.metafile, null, 2)); + + // Create wrapper script with shebang + writeFileSync("dist/cn.js", "#!/usr/bin/env node\nimport('./index.js');"); + + // Make the wrapper script executable + chmodSync("dist/cn.js", 0o755); + + // Calculate bundle size + const bundleSize = result.metafile.outputs["dist/index.js"].bytes; + console.log( + `✓ Build complete! Bundle size: ${(bundleSize / 1024 / 1024).toFixed(2)} MB`, + ); +} catch (error) { + console.error("Build failed:", error); + process.exit(1); +} diff --git a/extensions/cli/package-lock.json b/extensions/cli/package-lock.json index 72913df92..6da2ba6db 100644 --- a/extensions/cli/package-lock.json +++ b/extensions/cli/package-lock.json @@ -9,8 +9,14 @@ "version": "0.0.0-dev", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.96", - "@continuedev/openai-adapters": "^1.4.1", + "@sentry/profiling-node": "^9.43.0" + }, + "bin": { + "cn": "dist/cn.js" + }, + "devDependencies": { + "@continuedev/config-yaml": "file:../../packages/config-yaml", + "@continuedev/openai-adapters": "file:../../packages/openai-adapters", "@continuedev/sdk": "^0.0.13", "@modelcontextprotocol/sdk": "^1.17.2", "@opentelemetry/api": "^1.9.0", @@ -21,48 +27,11 @@ "@opentelemetry/resources": "^2.0.1", "@opentelemetry/sdk-node": "^0.203.0", "@opentelemetry/semantic-conventions": "^1.36.0", - "@sentry/node": "^9.43.0", - "@sentry/profiling-node": "^9.43.0", - "@types/express": "^5.0.3", - "@types/react": "^19.1.8", - "@types/turndown": "^5.0.5", - "@workos-inc/node": "^7.45.0", - "chalk": "^5.4.1", - "commander": "^14.0.0", - "date-fns": "^4.1.0", - "diff": "^7.0.0", - "dotenv": "^16.5.0", - "express": "^5.1.0", - "glob": "^11.0.3", - "gpt-tokenizer": "^3.0.1", - "gradient-string": "^3.0.0", - "ignore-walk": "^7.0.0", - "ink": "^6.1.0", - "jszip": "^3.10.1", - "lowlight": "^3.3.0", - "minimatch": "^10.0.3", - "node-fetch": "^3.3.2", - "node-machine-id": "^1.1.12", - "open": "^10.1.0", - "posthog-node": "^5.6.0", - "react": "^19.1.0", - "readline-sync": "^1.4.10", - "shell-quote": "^1.8.3", - "swr": "^2.3.4", - "turndown": "^7.2.0", - "typescript": "^5.8.3", - "uuid": "^9.0.1", - "winston": "^3.17.0", - "yaml": "^2.8.0" - }, - "bin": { - "cn": "dist/index.js" - }, - "devDependencies": { "@semantic-release/changelog": "^6.0.3", "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^11.0.3", "@semantic-release/npm": "^12.0.2", + "@sentry/node": "^9.43.0", "@testing-library/react": "^16.3.0", "@types/date-fns": "^2.5.3", "@types/diff": "^7.0.2", @@ -72,64 +41,262 @@ "@types/ink-testing-library": "^1.0.4", "@types/jszip": "^3.4.0", "@types/nock": "^10.0.3", + "@types/react": "^19.1.8", "@types/readline-sync": "^1.4.8", "@types/shell-quote": "^1.7.5", "@types/supertest": "^6.0.3", + "@types/turndown": "^5.0.5", + "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^8.39.0", "@typescript-eslint/parser": "^8.39.0", "@vitest/ui": "^3.2.4", + "@workos-inc/node": "^7.45.0", + "chalk": "^5.4.1", + "commander": "^14.0.0", "conventional-changelog-conventionalcommits": "^9.1.0", + "core": "file:../../core", "cross-env": "^7.0.3", + "date-fns": "^4.1.0", + "diff": "^7.0.0", + "dotenv": "^16.5.0", + "esbuild": "^0.25.9", "eslint": "^9.32.0", "eslint-import-resolver-typescript": "^4.4.4", "eslint-plugin-import": "^2.32.0", "eslint-plugin-unused-imports": "^4.1.4", "execa": "^9.6.0", "express": "^5.1.0", + "glob": "^11.0.3", + "gpt-tokenizer": "^3.0.1", + "gradient-string": "^3.0.0", "happy-dom": "^18.0.1", + "ignore": "^7.0.5", + "ignore-walk": "^7.0.0", + "ink": "^6.1.0", "ink-testing-library": "^4.0.0", "jsdom": "^26.1.0", + "jszip": "^3.10.1", + "lowlight": "^3.3.0", + "minimatch": "^10.0.3", "nock": "^14.0.5", + "node-fetch": "^3.3.2", + "node-machine-id": "^1.1.12", + "open": "^10.1.0", + "posthog-node": "^5.6.0", "prettier": "^3.6.2", + "react": "^19.1.0", + "readline-sync": "^1.4.10", "semantic-release": "^24.2.7", + "shell-quote": "^1.8.3", "supertest": "^7.1.3", + "swr": "^2.3.4", "ts-node": "^10.9.2", "tsx": "^4.20.3", + "turndown": "^7.2.0", + "typescript": "^5.8.3", + "uuid": "^9.0.1", + "vitest": "^3.2.4", + "winston": "^3.17.0", + "yaml": "^2.8.0" + } + }, + "../../core": { + "name": "@continuedev/core", + "version": "1.1.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/client-bedrock-runtime": "^3.779.0", + "@aws-sdk/client-sagemaker-runtime": "^3.777.0", + "@aws-sdk/credential-providers": "^3.778.0", + "@continuedev/config-types": "^1.0.13", + "@continuedev/config-yaml": "file:../packages/config-yaml", + "@continuedev/fetch": "file:../packages/fetch", + "@continuedev/llm-info": "file:../packages/llm-info", + "@continuedev/openai-adapters": "file:../packages/openai-adapters", + "@modelcontextprotocol/sdk": "^1.12.0", + "@mozilla/readability": "^0.5.0", + "@octokit/rest": "^20.1.1", + "@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", + "axios": "^1.6.7", + "cheerio": "^1.0.0-rc.12", + "commander": "^12.0.0", + "comment-json": "^4.2.3", + "dbinfoz": "^0.14.0", + "diff": "^7.0.0", + "dotenv": "^16.4.5", + "fastest-levenshtein": "^1.0.16", + "filtrex": "^3.1.0", + "follow-redirects": "^1.15.5", + "google-auth-library": "^9.14.2", + "handlebars": "^4.7.8", + "http-proxy-agent": "^7.0.1", + "https-proxy-agent": "^7.0.3", + "iconv-lite": "^0.6.3", + "ignore": "^7.0.5", + "is-localhost-ip": "^2.0.0", + "jinja-js": "0.1.8", + "js-tiktoken": "^1.0.8", + "jsdom": "^24.0.0", + "launchdarkly-node-client-sdk": "^3.2.0", + "llm-code-highlighter": "^0.0.14", + "lru-cache": "^11.0.2", + "mac-ca": "^3.1.0", + "node-fetch": "^3.3.2", + "node-html-markdown": "^1.3.0", + "ollama": "^0.4.6", + "onnxruntime-node": "1.14.0", + "openai": "^5.13.1", + "p-limit": "^6.1.0", + "partial-json": "^0.1.7", + "pg": "^8.11.3", + "plist": "^3.1.0", + "posthog-node": "^3.6.3", + "puppeteer": "^22.4.0", + "puppeteer-chromium-resolver": "^23.0.0", + "quick-lru": "^7.0.0", + "replicate": "^0.26.0", + "request": "^2.88.2", + "socket.io-client": "^4.7.3", + "sqlite": "^5.1.1", + "sqlite3": "^5.1.7", + "system-ca": "^1.0.3", + "tar": "^7.4.3", + "tree-sitter-wasms": "^0.1.11", + "uuid": "^9.0.1", + "vectordb": "^0.4.20", + "web-tree-sitter": "^0.21.0", + "win-ca": "^3.5.1", + "wink-nlp-utils": "^2.1.0", + "winston": "^3.17.0", + "workerpool": "^9.1.3", + "yaml": "^2.4.2", + "zod": "^3.24.2" + }, + "devDependencies": { + "@babel/preset-env": "^7.24.7", + "@biomejs/biome": "1.6.4", + "@google/generative-ai": "^0.11.4", + "@shikijs/colorized-brackets": "^3.7.0", + "@shikijs/transformers": "^3.7.0", + "@types/diff": "^7.0.1", + "@types/follow-redirects": "^1.14.4", + "@types/jest": "^29.5.12", + "@types/jquery": "^3.5.29", + "@types/jsdom": "^21.1.6", + "@types/json-schema": "^7.0.15", + "@types/mozilla-readability": "^0.2.1", + "@types/mustache": "^4.2.5", + "@types/node-fetch": "^2.6.11", + "@types/pg": "^8.11.6", + "@types/plist": "^3.0.5", + "@types/request": "^2.48.12", + "@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", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "myers-diff": "^2.1.0", + "onnxruntime-common": "1.14.0", + "onnxruntime-web": "1.14.0", + "shiki": "^3.6.0", + "ts-jest": "^29.1.1", + "typescript": "^5.6.3", + "vitest": "^3.1.4" + }, + "engines": { + "node": ">=20.19.0" + } + }, + "../../packages/config-yaml": { + "name": "@continuedev/config-yaml", + "version": "1.0.96", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@continuedev/config-types": "file:../config-types", + "yaml": "^2.6.1", + "zod": "^3.24.2" + }, + "bin": { + "config-yaml": "dist/cli.js" + }, + "devDependencies": { + "@semantic-release/changelog": "^6.0.3", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^9.2.6", + "@semantic-release/npm": "^10.0.6", + "@types/jest": "^29.5.14", + "@types/node": "^20.0.0", + "cross-env": "^7.0.3", + "jest": "^29.7.0", + "semantic-release": "^21.1.2", + "ts-jest": "^29.2.3", + "ts-node": "^10.9.2", + "zod-to-json-schema": "^3.24.5" + } + }, + "../../packages/openai-adapters": { + "name": "@continuedev/openai-adapters", + "version": "1.5.1", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/client-bedrock-runtime": "^3.842.0", + "@aws-sdk/credential-providers": "^3.840.0", + "@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": "^5.13.1", + "uuid": "^11.1.0", + "zod": "^3.24.2" + }, + "devDependencies": { + "@semantic-release/changelog": "^6.0.3", + "@semantic-release/commit-analyzer": "^13.0.1", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^11.0.3", + "@semantic-release/npm": "^12.0.2", + "@semantic-release/release-notes-generator": "^14.0.3", + "@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", + "ts-node": "^10.9.2", "vitest": "^3.2.4" } }, "node_modules/@alcalzone/ansi-tokenize": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.1.3.tgz", - "integrity": "sha512-3yWxPTq3UQ/FY9p1ErPxIyfT64elWaMvM9lIHnaqpyft63tkxodF5aUElYHrdisWve5cETkh1+KBw1yJuW0aRw==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.2.0.tgz", + "integrity": "sha512-qI/5TaaaCZE4yeSZ83lu0+xi1r88JSxUjnH4OP/iZF7+KKZ75u3ee5isd0LxX+6N8U0npL61YrpbthILHB6BnA==", + "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^6.2.1", - "is-fullwidth-code-point": "^4.0.0" + "is-fullwidth-code-point": "^5.0.0" }, "engines": { - "node": ">=14.13.1" - } - }, - "node_modules/@alcalzone/ansi-tokenize/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@alcalzone/ansi-tokenize/node_modules/is-fullwidth-code-point": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz", - "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=18" } }, "node_modules/@asamuzakjp/css-color": { @@ -146,781 +313,6 @@ "lru-cache": "^10.4.3" } }, - "node_modules/@asamuzakjp/css-color/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/@aws-crypto/crc32": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/crc32/-/crc32-5.2.0.tgz", - "integrity": "sha512-nLbCWqQNgUiwwtFsen1AdzAtvuLRsQS8rYgMuxCrdKf9kOssamGLuPwyTY9wyYblNr9+1XM8v6zoDTPPSIeANg==", - "dependencies": { - "@aws-crypto/util": "^5.2.0", - "@aws-sdk/types": "^3.222.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@aws-crypto/sha256-browser": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-browser/-/sha256-browser-5.2.0.tgz", - "integrity": "sha512-AXfN/lGotSQwu6HNcEsIASo7kWXZ5HYWvfOmSNKDsEqC4OashTp8alTmaz+F7TC2L083SFv5RdB+qU3Vs1kZqw==", - "dependencies": { - "@aws-crypto/sha256-js": "^5.2.0", - "@aws-crypto/supports-web-crypto": "^5.2.0", - "@aws-crypto/util": "^5.2.0", - "@aws-sdk/types": "^3.222.0", - "@aws-sdk/util-locate-window": "^3.0.0", - "@smithy/util-utf8": "^2.0.0", - "tslib": "^2.6.2" - } - }, - "node_modules/@aws-crypto/sha256-browser/node_modules/@smithy/is-array-buffer": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz", - "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@aws-crypto/sha256-browser/node_modules/@smithy/util-buffer-from": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz", - "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==", - "dependencies": { - "@smithy/is-array-buffer": "^2.2.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@aws-crypto/sha256-browser/node_modules/@smithy/util-utf8": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz", - "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==", - "dependencies": { - "@smithy/util-buffer-from": "^2.2.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@aws-crypto/sha256-js": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz", - "integrity": "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA==", - "dependencies": { - "@aws-crypto/util": "^5.2.0", - "@aws-sdk/types": "^3.222.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@aws-crypto/supports-web-crypto": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/supports-web-crypto/-/supports-web-crypto-5.2.0.tgz", - "integrity": "sha512-iAvUotm021kM33eCdNfwIN//F77/IADDSs58i+MDaOqFrVjZo9bAal0NK7HurRuWLLpF1iLX7gbWrjHjeo+YFg==", - "dependencies": { - "tslib": "^2.6.2" - } - }, - "node_modules/@aws-crypto/util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-5.2.0.tgz", - "integrity": "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==", - "dependencies": { - "@aws-sdk/types": "^3.222.0", - "@smithy/util-utf8": "^2.0.0", - "tslib": "^2.6.2" - } - }, - "node_modules/@aws-crypto/util/node_modules/@smithy/is-array-buffer": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz", - "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@aws-crypto/util/node_modules/@smithy/util-buffer-from": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz", - "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==", - "dependencies": { - "@smithy/is-array-buffer": "^2.2.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz", - "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==", - "dependencies": { - "@smithy/util-buffer-from": "^2.2.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@aws-sdk/client-bedrock-runtime": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-bedrock-runtime/-/client-bedrock-runtime-3.844.0.tgz", - "integrity": "sha512-aKaHY0ZxSubE3mHC34fDSQsclwNM3tWCEJdjEFJ7qjYXQ5zyMr4A0gV/GKDuufX5gh4riRp0R/EaR6cDbG4ApA==", - "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.844.0", - "@aws-sdk/credential-provider-node": "3.844.0", - "@aws-sdk/eventstream-handler-node": "3.840.0", - "@aws-sdk/middleware-eventstream": "3.840.0", - "@aws-sdk/middleware-host-header": "3.840.0", - "@aws-sdk/middleware-logger": "3.840.0", - "@aws-sdk/middleware-recursion-detection": "3.840.0", - "@aws-sdk/middleware-user-agent": "3.844.0", - "@aws-sdk/middleware-websocket": "3.844.0", - "@aws-sdk/region-config-resolver": "3.840.0", - "@aws-sdk/token-providers": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@aws-sdk/util-endpoints": "3.844.0", - "@aws-sdk/util-user-agent-browser": "3.840.0", - "@aws-sdk/util-user-agent-node": "3.844.0", - "@smithy/config-resolver": "^4.1.4", - "@smithy/core": "^3.7.0", - "@smithy/eventstream-serde-browser": "^4.0.4", - "@smithy/eventstream-serde-config-resolver": "^4.1.2", - "@smithy/eventstream-serde-node": "^4.0.4", - "@smithy/fetch-http-handler": "^5.1.0", - "@smithy/hash-node": "^4.0.4", - "@smithy/invalid-dependency": "^4.0.4", - "@smithy/middleware-content-length": "^4.0.4", - "@smithy/middleware-endpoint": "^4.1.14", - "@smithy/middleware-retry": "^4.1.15", - "@smithy/middleware-serde": "^4.0.8", - "@smithy/middleware-stack": "^4.0.4", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/node-http-handler": "^4.1.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "@smithy/url-parser": "^4.0.4", - "@smithy/util-base64": "^4.0.0", - "@smithy/util-body-length-browser": "^4.0.0", - "@smithy/util-body-length-node": "^4.0.0", - "@smithy/util-defaults-mode-browser": "^4.0.22", - "@smithy/util-defaults-mode-node": "^4.0.22", - "@smithy/util-endpoints": "^3.0.6", - "@smithy/util-middleware": "^4.0.4", - "@smithy/util-retry": "^4.0.6", - "@smithy/util-stream": "^4.2.3", - "@smithy/util-utf8": "^4.0.0", - "@types/uuid": "^9.0.1", - "tslib": "^2.6.2", - "uuid": "^9.0.1" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/client-cognito-identity": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.844.0.tgz", - "integrity": "sha512-LwuYN43+IWQ5hOSaaNx6VVrUbLZibaZ01pXNuwdbaJGZOKcCCnev5O7MY0Kud7xatJrf7B9l2GIZW7gmHFi+yQ==", - "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.844.0", - "@aws-sdk/credential-provider-node": "3.844.0", - "@aws-sdk/middleware-host-header": "3.840.0", - "@aws-sdk/middleware-logger": "3.840.0", - "@aws-sdk/middleware-recursion-detection": "3.840.0", - "@aws-sdk/middleware-user-agent": "3.844.0", - "@aws-sdk/region-config-resolver": "3.840.0", - "@aws-sdk/types": "3.840.0", - "@aws-sdk/util-endpoints": "3.844.0", - "@aws-sdk/util-user-agent-browser": "3.840.0", - "@aws-sdk/util-user-agent-node": "3.844.0", - "@smithy/config-resolver": "^4.1.4", - "@smithy/core": "^3.7.0", - "@smithy/fetch-http-handler": "^5.1.0", - "@smithy/hash-node": "^4.0.4", - "@smithy/invalid-dependency": "^4.0.4", - "@smithy/middleware-content-length": "^4.0.4", - "@smithy/middleware-endpoint": "^4.1.14", - "@smithy/middleware-retry": "^4.1.15", - "@smithy/middleware-serde": "^4.0.8", - "@smithy/middleware-stack": "^4.0.4", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/node-http-handler": "^4.1.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "@smithy/url-parser": "^4.0.4", - "@smithy/util-base64": "^4.0.0", - "@smithy/util-body-length-browser": "^4.0.0", - "@smithy/util-body-length-node": "^4.0.0", - "@smithy/util-defaults-mode-browser": "^4.0.22", - "@smithy/util-defaults-mode-node": "^4.0.22", - "@smithy/util-endpoints": "^3.0.6", - "@smithy/util-middleware": "^4.0.4", - "@smithy/util-retry": "^4.0.6", - "@smithy/util-utf8": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/client-sso": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.844.0.tgz", - "integrity": "sha512-FktodSx+pfUfIqMjoNwZ6t1xqq/G3cfT7I4JJ0HKHoIIZdoCHQB52x0OzKDtHDJAnEQPInasdPS8PorZBZtHmg==", - "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.844.0", - "@aws-sdk/middleware-host-header": "3.840.0", - "@aws-sdk/middleware-logger": "3.840.0", - "@aws-sdk/middleware-recursion-detection": "3.840.0", - "@aws-sdk/middleware-user-agent": "3.844.0", - "@aws-sdk/region-config-resolver": "3.840.0", - "@aws-sdk/types": "3.840.0", - "@aws-sdk/util-endpoints": "3.844.0", - "@aws-sdk/util-user-agent-browser": "3.840.0", - "@aws-sdk/util-user-agent-node": "3.844.0", - "@smithy/config-resolver": "^4.1.4", - "@smithy/core": "^3.7.0", - "@smithy/fetch-http-handler": "^5.1.0", - "@smithy/hash-node": "^4.0.4", - "@smithy/invalid-dependency": "^4.0.4", - "@smithy/middleware-content-length": "^4.0.4", - "@smithy/middleware-endpoint": "^4.1.14", - "@smithy/middleware-retry": "^4.1.15", - "@smithy/middleware-serde": "^4.0.8", - "@smithy/middleware-stack": "^4.0.4", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/node-http-handler": "^4.1.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "@smithy/url-parser": "^4.0.4", - "@smithy/util-base64": "^4.0.0", - "@smithy/util-body-length-browser": "^4.0.0", - "@smithy/util-body-length-node": "^4.0.0", - "@smithy/util-defaults-mode-browser": "^4.0.22", - "@smithy/util-defaults-mode-node": "^4.0.22", - "@smithy/util-endpoints": "^3.0.6", - "@smithy/util-middleware": "^4.0.4", - "@smithy/util-retry": "^4.0.6", - "@smithy/util-utf8": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/core": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.844.0.tgz", - "integrity": "sha512-pfpI54bG5Xf2NkqrDBC2REStXlDXNCw/whORhkEs+Tp5exU872D5QKguzjPA6hH+8Pvbq1qgt5zXMbduISTHJw==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@aws-sdk/xml-builder": "3.821.0", - "@smithy/core": "^3.7.0", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/property-provider": "^4.0.4", - "@smithy/protocol-http": "^5.1.2", - "@smithy/signature-v4": "^5.1.2", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "@smithy/util-base64": "^4.0.0", - "@smithy/util-body-length-browser": "^4.0.0", - "@smithy/util-middleware": "^4.0.4", - "@smithy/util-utf8": "^4.0.0", - "fast-xml-parser": "5.2.5", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-provider-cognito-identity": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.844.0.tgz", - "integrity": "sha512-LBigff8jHYZbQTRcybiqamZTQpRb63CBiCG9Ce0C1CzmZQ0WUZFmJA5ZbqwUK+BliOEdpl6kQFgsf6sz9ODbZg==", - "dependencies": { - "@aws-sdk/client-cognito-identity": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/property-provider": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-provider-env": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.844.0.tgz", - "integrity": "sha512-WB94Ox86MqcZ4CnRjKgopzaSuZH4hMP0GqdOxG4s1it1lRWOIPOHOC1dPiM0Zbj1uqITIhbXUQVXyP/uaJeNkw==", - "dependencies": { - "@aws-sdk/core": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/property-provider": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-provider-http": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.844.0.tgz", - "integrity": "sha512-e+efVqfkhpM8zxYeiLNgTUlX+tmtXzVm3bw1A02U9Z9cWBHyQNb8pi90M7QniLoqRURY1B0C2JqkOE61gd4KNg==", - "dependencies": { - "@aws-sdk/core": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/fetch-http-handler": "^5.1.0", - "@smithy/node-http-handler": "^4.1.0", - "@smithy/property-provider": "^4.0.4", - "@smithy/protocol-http": "^5.1.2", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "@smithy/util-stream": "^4.2.3", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-provider-ini": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.844.0.tgz", - "integrity": "sha512-jc5ArGz2HfAx5QPXD+Ep36+QWyCKzl2TG6Vtl87/vljfLhVD0gEHv8fRsqWEp3Rc6hVfKnCjLW5ayR2HYcow9w==", - "dependencies": { - "@aws-sdk/core": "3.844.0", - "@aws-sdk/credential-provider-env": "3.844.0", - "@aws-sdk/credential-provider-http": "3.844.0", - "@aws-sdk/credential-provider-process": "3.844.0", - "@aws-sdk/credential-provider-sso": "3.844.0", - "@aws-sdk/credential-provider-web-identity": "3.844.0", - "@aws-sdk/nested-clients": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/credential-provider-imds": "^4.0.6", - "@smithy/property-provider": "^4.0.4", - "@smithy/shared-ini-file-loader": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-provider-node": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.844.0.tgz", - "integrity": "sha512-pUqB0StTNyW0R03XjTA3wrQZcie/7FJKSXlYHue921ZXuhLOZpzyDkLNfdRsZTcEoYYWVPSmyS+Eu/g5yVsBNA==", - "dependencies": { - "@aws-sdk/credential-provider-env": "3.844.0", - "@aws-sdk/credential-provider-http": "3.844.0", - "@aws-sdk/credential-provider-ini": "3.844.0", - "@aws-sdk/credential-provider-process": "3.844.0", - "@aws-sdk/credential-provider-sso": "3.844.0", - "@aws-sdk/credential-provider-web-identity": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/credential-provider-imds": "^4.0.6", - "@smithy/property-provider": "^4.0.4", - "@smithy/shared-ini-file-loader": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-provider-process": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.844.0.tgz", - "integrity": "sha512-VCI8XvIDt2WBfk5Gi/wXKPcWTS3OkAbovB66oKcNQalllH8ESDg4SfLNhchdnN8A5sDGj6tIBJ19nk+dQ6GaqQ==", - "dependencies": { - "@aws-sdk/core": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/property-provider": "^4.0.4", - "@smithy/shared-ini-file-loader": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-provider-sso": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.844.0.tgz", - "integrity": "sha512-UNp/uWufGlb5nWa4dpc6uQnDOB/9ysJJFG95ACowNVL9XWfi1LJO7teKrqNkVhq0CzSJS1tCt3FvX4UfM+aN1g==", - "dependencies": { - "@aws-sdk/client-sso": "3.844.0", - "@aws-sdk/core": "3.844.0", - "@aws-sdk/token-providers": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/property-provider": "^4.0.4", - "@smithy/shared-ini-file-loader": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-provider-web-identity": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.844.0.tgz", - "integrity": "sha512-iDmX4pPmatjttIScdspZRagaFnCjpHZIEEwTyKdXxUaU0iAOSXF8ecrCEvutETvImPOC86xdrq+MPacJOnMzUA==", - "dependencies": { - "@aws-sdk/core": "3.844.0", - "@aws-sdk/nested-clients": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/property-provider": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/credential-providers": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.844.0.tgz", - "integrity": "sha512-amTf3wxwTVNV5jBpN1dT77c5rlch3ooUhBxA+dAnlKLLbc0OlcUrF49Kh69PWBlACahcZDuBh/KPJm2wiIMyYQ==", - "dependencies": { - "@aws-sdk/client-cognito-identity": "3.844.0", - "@aws-sdk/core": "3.844.0", - "@aws-sdk/credential-provider-cognito-identity": "3.844.0", - "@aws-sdk/credential-provider-env": "3.844.0", - "@aws-sdk/credential-provider-http": "3.844.0", - "@aws-sdk/credential-provider-ini": "3.844.0", - "@aws-sdk/credential-provider-node": "3.844.0", - "@aws-sdk/credential-provider-process": "3.844.0", - "@aws-sdk/credential-provider-sso": "3.844.0", - "@aws-sdk/credential-provider-web-identity": "3.844.0", - "@aws-sdk/nested-clients": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/config-resolver": "^4.1.4", - "@smithy/core": "^3.7.0", - "@smithy/credential-provider-imds": "^4.0.6", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/property-provider": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/eventstream-handler-node": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/eventstream-handler-node/-/eventstream-handler-node-3.840.0.tgz", - "integrity": "sha512-m/zVrSSAEHq+6h4sy0JUEBScB1pGgs/1+iRVhfzfbnf+/gTr4ut2jRq4tDiNEX9pQ1oFVvw+ntPua5qfquQeRQ==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/eventstream-codec": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/middleware-eventstream": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-eventstream/-/middleware-eventstream-3.840.0.tgz", - "integrity": "sha512-4khgf7AjJ4llh3aiNmZ+x4PGl4vkKNxRHn0xTgi6Iw1J3SChsF2mnNaLXK8hoXeydx756rw+JhqOuZH91i5l4w==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/middleware-host-header": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.840.0.tgz", - "integrity": "sha512-ub+hXJAbAje94+Ya6c6eL7sYujoE8D4Bumu1NUI8TXjUhVVn0HzVWQjpRLshdLsUp1AW7XyeJaxyajRaJQ8+Xg==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/middleware-logger": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-logger/-/middleware-logger-3.840.0.tgz", - "integrity": "sha512-lSV8FvjpdllpGaRspywss4CtXV8M7NNNH+2/j86vMH+YCOZ6fu2T/TyFd/tHwZ92vDfHctWkRbQxg0bagqwovA==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/middleware-recursion-detection": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.840.0.tgz", - "integrity": "sha512-Gu7lGDyfddyhIkj1Z1JtrY5NHb5+x/CRiB87GjaSrKxkDaydtX2CU977JIABtt69l9wLbcGDIQ+W0uJ5xPof7g==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.844.0.tgz", - "integrity": "sha512-SIbDNUL6ZYXPj5Tk0qEz05sW9kNS1Gl3/wNWEmH+AuUACipkyIeKKWzD6z5433MllETh73vtka/JQF3g7AuZww==", - "dependencies": { - "@aws-sdk/core": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@aws-sdk/util-endpoints": "3.844.0", - "@smithy/core": "^3.7.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/middleware-websocket": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-websocket/-/middleware-websocket-3.844.0.tgz", - "integrity": "sha512-5ZtntUZ9ZMdUbQZ3kI5e5tpiZPN/O57h6fnGZ+GHB+wpSVSOQS78TBt0qYZW+CoZr8iyRsVkJheGETajFCMaUg==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@aws-sdk/util-format-url": "3.840.0", - "@smithy/eventstream-codec": "^4.0.4", - "@smithy/eventstream-serde-browser": "^4.0.4", - "@smithy/fetch-http-handler": "^5.1.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/signature-v4": "^5.1.2", - "@smithy/types": "^4.3.1", - "@smithy/util-hex-encoding": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">= 14.0.0" - } - }, - "node_modules/@aws-sdk/nested-clients": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.844.0.tgz", - "integrity": "sha512-p2XILWc7AcevUSpBg2VtQrk79eWQC4q2JsCSY7HxKpFLZB4mMOfmiTyYkR1gEA6AttK/wpCOtfz+hi1/+z2V1A==", - "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.844.0", - "@aws-sdk/middleware-host-header": "3.840.0", - "@aws-sdk/middleware-logger": "3.840.0", - "@aws-sdk/middleware-recursion-detection": "3.840.0", - "@aws-sdk/middleware-user-agent": "3.844.0", - "@aws-sdk/region-config-resolver": "3.840.0", - "@aws-sdk/types": "3.840.0", - "@aws-sdk/util-endpoints": "3.844.0", - "@aws-sdk/util-user-agent-browser": "3.840.0", - "@aws-sdk/util-user-agent-node": "3.844.0", - "@smithy/config-resolver": "^4.1.4", - "@smithy/core": "^3.7.0", - "@smithy/fetch-http-handler": "^5.1.0", - "@smithy/hash-node": "^4.0.4", - "@smithy/invalid-dependency": "^4.0.4", - "@smithy/middleware-content-length": "^4.0.4", - "@smithy/middleware-endpoint": "^4.1.14", - "@smithy/middleware-retry": "^4.1.15", - "@smithy/middleware-serde": "^4.0.8", - "@smithy/middleware-stack": "^4.0.4", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/node-http-handler": "^4.1.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "@smithy/url-parser": "^4.0.4", - "@smithy/util-base64": "^4.0.0", - "@smithy/util-body-length-browser": "^4.0.0", - "@smithy/util-body-length-node": "^4.0.0", - "@smithy/util-defaults-mode-browser": "^4.0.22", - "@smithy/util-defaults-mode-node": "^4.0.22", - "@smithy/util-endpoints": "^3.0.6", - "@smithy/util-middleware": "^4.0.4", - "@smithy/util-retry": "^4.0.6", - "@smithy/util-utf8": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/region-config-resolver": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.840.0.tgz", - "integrity": "sha512-Qjnxd/yDv9KpIMWr90ZDPtRj0v75AqGC92Lm9+oHXZ8p1MjG5JE2CW0HL8JRgK9iKzgKBL7pPQRXI8FkvEVfrA==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/types": "^4.3.1", - "@smithy/util-config-provider": "^4.0.0", - "@smithy/util-middleware": "^4.0.4", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/token-providers": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.844.0.tgz", - "integrity": "sha512-Kh728FEny0fil+LeH8U1offPJCTd/EDh8liBAvLtViLHt2WoX2xC8rk98D38Q5p79aIUhHb3Pf4n9IZfTu/Kog==", - "dependencies": { - "@aws-sdk/core": "3.844.0", - "@aws-sdk/nested-clients": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/property-provider": "^4.0.4", - "@smithy/shared-ini-file-loader": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/types": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.840.0.tgz", - "integrity": "sha512-xliuHaUFZxEx1NSXeLLZ9Dyu6+EJVQKEoD+yM+zqUo3YDZ7medKJWY6fIOKiPX/N7XbLdBYwajb15Q7IL8KkeA==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/util-endpoints": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.844.0.tgz", - "integrity": "sha512-1DHh0WTUmxlysz3EereHKtKoxVUG9UC5BsfAw6Bm4/6qDlJiqtY3oa2vebkYN23yltKdfsCK65cwnBRU59mWVg==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/types": "^4.3.1", - "@smithy/url-parser": "^4.0.4", - "@smithy/util-endpoints": "^3.0.6", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/util-format-url": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-format-url/-/util-format-url-3.840.0.tgz", - "integrity": "sha512-VB1PWyI1TQPiPvg4w7tgUGGQER1xxXPNUqfh3baxUSFi1Oh8wHrDnFywkxLm3NMmgDmnLnSZ5Q326qAoyqKLSg==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/querystring-builder": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/util-locate-window": { - "version": "3.804.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-locate-window/-/util-locate-window-3.804.0.tgz", - "integrity": "sha512-zVoRfpmBVPodYlnMjgVjfGoEZagyRF5IPn3Uo6ZvOZp24chnW/FRstH7ESDHDDRga4z3V+ElUQHKpFDXWyBW5A==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@aws-sdk/util-user-agent-browser": { - "version": "3.840.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.840.0.tgz", - "integrity": "sha512-JdyZM3EhhL4PqwFpttZu1afDpPJCCc3eyZOLi+srpX11LsGj6sThf47TYQN75HT1CarZ7cCdQHGzP2uy3/xHfQ==", - "dependencies": { - "@aws-sdk/types": "3.840.0", - "@smithy/types": "^4.3.1", - "bowser": "^2.11.0", - "tslib": "^2.6.2" - } - }, - "node_modules/@aws-sdk/util-user-agent-node": { - "version": "3.844.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.844.0.tgz", - "integrity": "sha512-0eTpURp9Gxbyyeqr78ogARZMSWS5KUMZuN+XMHxNpQLmn2S+J3g+MAyoklCcwhKXlbdQq2aMULEiy0mqIWytuw==", - "dependencies": { - "@aws-sdk/middleware-user-agent": "3.844.0", - "@aws-sdk/types": "3.840.0", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - }, - "peerDependencies": { - "aws-crt": ">=1.0.0" - }, - "peerDependenciesMeta": { - "aws-crt": { - "optional": true - } - } - }, - "node_modules/@aws-sdk/xml-builder": { - "version": "3.821.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.821.0.tgz", - "integrity": "sha512-DIIotRnefVL6DiaHtO6/21DhJ4JZnnIwdNbpwiAhdt/AVbttcE4yw925gsjur0OGv5BTYXQXU3YnANBYnZjuQA==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@babel/code-frame": { "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", @@ -947,9 +339,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.28.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.2.tgz", - "integrity": "sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==", + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.3.tgz", + "integrity": "sha512-9uIQ10o0WGdpP6GDhXcdOJPJuDgFtIDtN/9+ArJQ2NAfAmiuhTQdzkaTGR33v43GYS2UrSA0eX2pPPHoFVvpxA==", "dev": true, "license": "MIT", "engines": { @@ -967,74 +359,20 @@ "node": ">=0.1.90" } }, - "node_modules/@continuedev/config-types": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz", - "integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==", - "dependencies": { - "zod": "^3.23.8" - } - }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.96", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.96.tgz", - "integrity": "sha512-zEdSI1k2SSEj1qRuOpyERebqMzCEynJ2ce2+q2/5VjR1/2uSi2PpiZr5saofs2VKSQtIU4Pj4xwQ7Utd0hQEBA==", - "dependencies": { - "@continuedev/config-types": "^1.0.14", - "yaml": "^2.6.1", - "zod": "^3.24.2" - }, - "bin": { - "config-yaml": "dist/cli.js" - } - }, - "node_modules/@continuedev/fetch": { - "version": "1.0.16", - "resolved": "https://registry.npmjs.org/@continuedev/fetch/-/fetch-1.0.16.tgz", - "integrity": "sha512-LSjVbTKA+UwqCjV8x45sfJQGtG/iekkqCYpSJsakY0ruad807swwEuuui5luuYVUhJAZZpVfZzeJArHfjiJJSw==", - "dependencies": { - "@continuedev/config-types": "^1.0.5", - "follow-redirects": "^1.15.6", - "http-proxy-agent": "^7.0.2", - "https-proxy-agent": "^7.0.5", - "node-fetch": "^3.3.2" - } + "resolved": "../../packages/config-yaml", + "link": true }, "node_modules/@continuedev/openai-adapters": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@continuedev/openai-adapters/-/openai-adapters-1.4.1.tgz", - "integrity": "sha512-VCEunQSmklEwaWn7bImAYrtSgra3OlQLAYaytVkxT5ZilrYte4qVFIgQmV9nE30hsDbkzQf5qTQTsaKz/NgWAA==", - "dependencies": { - "@aws-sdk/client-bedrock-runtime": "^3.842.0", - "@aws-sdk/credential-providers": "^3.840.0", - "@continuedev/config-types": "^1.0.5", - "@continuedev/config-yaml": "^1.0.51", - "@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", - "uuid": "^11.1.0", - "zod": "^3.24.2" - } - }, - "node_modules/@continuedev/openai-adapters/node_modules/uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/esm/bin/uuid" - } + "resolved": "../../packages/openai-adapters", + "link": true }, "node_modules/@continuedev/sdk": { "version": "0.0.13", "resolved": "https://registry.npmjs.org/@continuedev/sdk/-/sdk-0.0.13.tgz", "integrity": "sha512-3OvwfmngMpSYWUHbtgavLKSn9GsXgWoVUAAGT5wP5AJTPr4QSLnOTctY/2IYCbkfyCVa1rJtTqrUV/hez95nQQ==", + "dev": true, + "license": "Apache-2.0", "dependencies": { "openai": "^4.96.2" } @@ -1052,17 +390,6 @@ "node": ">=12" } }, - "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@csstools/color-helpers": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.0.2.tgz", @@ -1182,6 +509,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz", "integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==", + "dev": true, "license": "MIT", "dependencies": { "colorspace": "1.1.x", @@ -1223,14 +551,83 @@ "tslib": "^2.4.0" } }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.25.6", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.6.tgz", - "integrity": "sha512-FFCssz3XBavjxcFxKsGy2DYK5VSvJqa6y5HXljKzhRZ87LvEi13brPrf/wdyl/BbpbMKJNOr1Sd0jtW4Ge1pAA==", + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.9.tgz", + "integrity": "sha512-OaGtL73Jck6pBKjNIe24BnFE6agGl+6KxDtTfHhy1HmhthfKouEcOhqpSL64K4/0WCtbKFLOdzD/44cJ4k9opA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.9.tgz", + "integrity": "sha512-5WNI1DaMtxQ7t7B6xa572XMXpHAaI/9Hnhk8lcxF4zVN4xstUgTlvuGDorBguKEnZO70qwEcLpfifMLoxiPqHQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.9.tgz", + "integrity": "sha512-IDrddSmpSv51ftWslJMvl3Q2ZT98fUSL2/rlUXuVqRXHCs5EUF1/f+jbjF5+NG9UffUDMCiTyh8iec7u8RlTLg==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.9.tgz", + "integrity": "sha512-I853iMZ1hWZdNllhVZKm34f4wErd4lMyeV7BLzEExGEIZYsOzqDWDf+y082izYUE8gtJnYHdeDpN/6tUdwvfiw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.9.tgz", + "integrity": "sha512-XIpIDMAjOELi/9PB30vEbVMs3GV1v2zkkPnuyRRURbhqjyzIINwj+nbQATh4H9GxUgH1kFsEyQMxwiLFKUS6Rg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -1239,6 +636,363 @@ "node": ">=18" } }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.9.tgz", + "integrity": "sha512-jhHfBzjYTA1IQu8VyrjCX4ApJDnH+ez+IYVEoJHeqJm9VhG9Dh2BYaJritkYK3vMaXrf7Ogr/0MQ8/MeIefsPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.9.tgz", + "integrity": "sha512-z93DmbnY6fX9+KdD4Ue/H6sYs+bhFQJNCPZsi4XWJoYblUqT06MQUdBCpcSfuiN72AbqeBFu5LVQTjfXDE2A6Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.9.tgz", + "integrity": "sha512-mrKX6H/vOyo5v71YfXWJxLVxgy1kyt1MQaD8wZJgJfG4gq4DpQGpgTB74e5yBeQdyMTbgxp0YtNj7NuHN0PoZg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.9.tgz", + "integrity": "sha512-HBU2Xv78SMgaydBmdor38lg8YDnFKSARg1Q6AT0/y2ezUAKiZvc211RDFHlEZRFNRVhcMamiToo7bDx3VEOYQw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.9.tgz", + "integrity": "sha512-BlB7bIcLT3G26urh5Dmse7fiLmLXnRlopw4s8DalgZ8ef79Jj4aUcYbk90g8iCa2467HX8SAIidbL7gsqXHdRw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.9.tgz", + "integrity": "sha512-e7S3MOJPZGp2QW6AK6+Ly81rC7oOSerQ+P8L0ta4FhVi+/j/v2yZzx5CqqDaWjtPFfYz21Vi1S0auHrap3Ma3A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.9.tgz", + "integrity": "sha512-Sbe10Bnn0oUAB2AalYztvGcK+o6YFFA/9829PhOCUS9vkJElXGdphz0A3DbMdP8gmKkqPmPcMJmJOrI3VYB1JQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.9.tgz", + "integrity": "sha512-YcM5br0mVyZw2jcQeLIkhWtKPeVfAerES5PvOzaDxVtIyZ2NUBZKNLjC5z3/fUlDgT6w89VsxP2qzNipOaaDyA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.9.tgz", + "integrity": "sha512-++0HQvasdo20JytyDpFvQtNrEsAgNG2CY1CLMwGXfFTKGBGQT3bOeLSYE2l1fYdvML5KUuwn9Z8L1EWe2tzs1w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.9.tgz", + "integrity": "sha512-uNIBa279Y3fkjV+2cUjx36xkx7eSjb8IvnL01eXUKXez/CBHNRw5ekCGMPM0BcmqBxBcdgUWuUXmVWwm4CH9kg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.9.tgz", + "integrity": "sha512-Mfiphvp3MjC/lctb+7D287Xw1DGzqJPb/J2aHHcHxflUo+8tmN/6d4k6I2yFR7BVo5/g7x2Monq4+Yew0EHRIA==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.9.tgz", + "integrity": "sha512-iSwByxzRe48YVkmpbgoxVzn76BXjlYFXC7NvLYq+b+kDjyyk30J0JY47DIn8z1MO3K0oSl9fZoRmZPQI4Hklzg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.9.tgz", + "integrity": "sha512-9jNJl6FqaUG+COdQMjSCGW4QiMHH88xWbvZ+kRVblZsWrkXlABuGdFJ1E9L7HK+T0Yqd4akKNa/lO0+jDxQD4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.9.tgz", + "integrity": "sha512-RLLdkflmqRG8KanPGOU7Rpg829ZHu8nFy5Pqdi9U01VYtG9Y0zOG6Vr2z4/S+/3zIyOxiK6cCeYNWOFR9QP87g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.9.tgz", + "integrity": "sha512-YaFBlPGeDasft5IIM+CQAhJAqS3St3nJzDEgsgFixcfZeyGPCd6eJBWzke5piZuZ7CtL656eOSYKk4Ls2C0FRQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.9.tgz", + "integrity": "sha512-1MkgTCuvMGWuqVtAvkpkXFmtL8XhWy+j4jaSO2wxfJtilVCi0ZE37b8uOdMItIHz4I6z1bWWtEX4CJwcKYLcuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.9.tgz", + "integrity": "sha512-4Xd0xNiMVXKh6Fa7HEJQbrpP3m3DDn43jKxMjxLLRjWnRsfxjORYJlXPO4JNcXtOyfajXorRKY9NkOpTHptErg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.9.tgz", + "integrity": "sha512-WjH4s6hzo00nNezhp3wFIAfmGZ8U7KtrJNlFMRKxiI9mxEK1scOMAaa9i4crUtu+tBr+0IN6JCuAcSBJZfnphw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.9.tgz", + "integrity": "sha512-mGFrVJHmZiRqmP8xFOc6b84/7xa5y5YvR1x8djzXpJBSv/UsNK6aqec+6JDjConTgvvQefdGhFDAs2DLAds6gQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.9.tgz", + "integrity": "sha512-b33gLVU2k11nVx1OhX3C8QQP6UHQK4ZtN56oFWvVXvz2VkDoe6fbG8TOgHFxEvqeqohmRnIHe5A1+HADk4OQww==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.9.tgz", + "integrity": "sha512-PPOl1mi6lpLNQxnGoyAfschAodRFYXJ+9fs6WHXz7CSWKbOqiMZsubC+BQsVKuul+3vKLuwTHsS2c2y9EoKwxQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz", @@ -1297,9 +1051,9 @@ } }, "node_modules/@eslint/config-helpers": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.3.0.tgz", - "integrity": "sha512-ViuymvFmcJi04qdZeDc2whTHryouGcDlaxPqarTD0ZE10ISpxGUVZGZDx4w01upyIynL3iu6IXH2bS1NhclQMw==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.3.1.tgz", + "integrity": "sha512-xR93k9WhrDYpXHORXpxVL5oHj3Era7wo6k/Wd8/IsQNnZUTzkGS29lyn3nAT05v6ltUuTFVCCYDEGfy2Or/sPA==", "dev": true, "license": "Apache-2.0", "engines": { @@ -1307,9 +1061,9 @@ } }, "node_modules/@eslint/core": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.1.tgz", - "integrity": "sha512-bkOp+iumZCCbt1K1CmWf0R9pM5yKpDv+ZXtvSyQpudrI9kuFLp+bM2WOPXImuD/ceQuaa8f5pj93Y7zyECIGNA==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.2.tgz", + "integrity": "sha512-78Md3/Rrxh83gCxoUc0EiciuOHsIITzLy53m3d9UyiW8y9Dj2D29FeETqyKA+BRK76tnTp6RXWb3pCay8Oyomg==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -1367,9 +1121,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.32.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.32.0.tgz", - "integrity": "sha512-BBpRFZK3eX6uMLKz8WxFOBIFFcGFJ/g8XuwjTHCqHROSIsopI+ddn/d5Cfh36+7+e5edVS8dbSHnBNhrLEX0zg==", + "version": "9.33.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.33.0.tgz", + "integrity": "sha512-5K1/mKhWaMfreBGJTwval43JJmkip0RmM+3+IuqupeSKNC/Th2Kc7ucaq5ovTSra/OOKB9c58CGSz3QMVbWt0A==", "dev": true, "license": "MIT", "engines": { @@ -1390,13 +1144,13 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.4.tgz", - "integrity": "sha512-Ul5l+lHEcw3L5+k8POx6r74mxEYKG5kOb6Xpy2gCRW6zweT6TEhAf8vhxGgjhqrd/VO/Dirhsb+1hNpD1ue9hw==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.5.tgz", + "integrity": "sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/core": "^0.15.1", + "@eslint/core": "^0.15.2", "levn": "^0.4.1" }, "engines": { @@ -1407,6 +1161,7 @@ "version": "1.13.4", "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.13.4.tgz", "integrity": "sha512-GsFaMXCkMqkKIvwCQjCrwH+GHbPKBjhwo/8ZuUkWHqbI73Kky9I+pQltrlT0+MWpedCoosda53lgjYfyEPgxBg==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@grpc/proto-loader": "^0.7.13", @@ -1420,6 +1175,7 @@ "version": "0.7.15", "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.7.15.tgz", "integrity": "sha512-tMXdRCfYVixjuFK+Hk0Q1s38gV9zDiDJfWL3h1rv4Qc39oILCu1TRTDt7+fGUI8K4G1Fj125Hx/ru3azECWTyQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "lodash.camelcase": "^4.3.0", @@ -1504,6 +1260,8 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==", + "dev": true, + "license": "MIT", "engines": { "node": "20 || >=22" } @@ -1512,6 +1270,8 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", + "dev": true, + "license": "MIT", "dependencies": { "@isaacs/balanced-match": "^4.0.1" }, @@ -1523,6 +1283,7 @@ "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, "license": "ISC", "dependencies": { "string-width": "^5.1.2", @@ -1536,40 +1297,18 @@ "node": ">=12" } }, - "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/@isaacs/cliui/node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, "license": "MIT" }, "node_modules/@isaacs/cliui/node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, "license": "MIT", "dependencies": { "eastasianwidth": "^0.2.0", @@ -1583,25 +1322,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@isaacs/cliui/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^6.1.0", @@ -1626,16 +1351,28 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", "dev": true, "license": "MIT" }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@js-sdsl/ordered-map": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/@js-sdsl/ordered-map/-/ordered-map-4.4.2.tgz", "integrity": "sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==", + "dev": true, "license": "MIT", "funding": { "type": "opencollective", @@ -1646,12 +1383,14 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/@mixmark-io/domino/-/domino-2.2.0.tgz", "integrity": "sha512-Y28PR25bHXUg88kCV7nivXrP2Nj2RueZ3/l/jdx6J9f8J4nsEGcgX0Qe6lt7Pa+J79+kPiJU3LguR6O/6zrLOw==", + "dev": true, "license": "BSD-2-Clause" }, "node_modules/@modelcontextprotocol/sdk": { - "version": "1.17.2", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.17.2.tgz", - "integrity": "sha512-EFLRNXR/ixpXQWu6/3Cu30ndDFIFNaqUXcTqsGebujeMan9FzhAaFFswLRiFj61rgygDRr8WO1N+UijjgRxX9g==", + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.17.4.tgz", + "integrity": "sha512-zq24hfuAmmlNZvik0FLI58uE5sriN0WWsQzIlYnzSuKDAHFqJtBFrl/LfB1NLgJT5Y7dEBzaX4yAKqOPrcetaw==", + "dev": true, "license": "MIT", "dependencies": { "ajv": "^6.12.6", @@ -1672,9 +1411,9 @@ } }, "node_modules/@mswjs/interceptors": { - "version": "0.38.7", - "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.38.7.tgz", - "integrity": "sha512-Jkb27iSn7JPdkqlTqKfhncFfnEZsIJVYxsFbUSWEkxdIPdsyngrhoDBk0/BGD2FQcRH99vlRrkHpNTyKqI+0/w==", + "version": "0.39.6", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.39.6.tgz", + "integrity": "sha512-bndDP83naYYkfayr/qhBHMhk0YGwS1iv6vaEGcr0SQbO0IZtbOPqjKjds/WcG+bJA+1T5vCx6kprKOzn5Bg+Vw==", "dev": true, "license": "MIT", "dependencies": { @@ -1986,6 +1725,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-grpc/-/exporter-logs-otlp-grpc-0.203.0.tgz", "integrity": "sha512-g/2Y2noc/l96zmM+g0LdeuyYKINyBwN6FJySoU15LHPLcMN/1a0wNk2SegwKcxrRdE7Xsm7fkIR5n6XFe3QpPw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@grpc/grpc-js": "^1.7.1", @@ -2006,6 +1746,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-http/-/exporter-logs-otlp-http-0.203.0.tgz", "integrity": "sha512-s0hys1ljqlMTbXx2XiplmMJg9wG570Z5lH7wMvrZX6lcODI56sG4HL03jklF63tBeyNwK2RV1/ntXGo3HgG4Qw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/api-logs": "0.203.0", @@ -2025,6 +1766,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-proto/-/exporter-logs-otlp-proto-0.203.0.tgz", "integrity": "sha512-nl/7S91MXn5R1aIzoWtMKGvqxgJgepB/sH9qW0rZvZtabnsjbf8OQ1uSx3yogtvLr0GzwD596nQKz2fV7q2RBw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/api-logs": "0.203.0", @@ -2046,6 +1788,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-grpc/-/exporter-metrics-otlp-grpc-0.203.0.tgz", "integrity": "sha512-FCCj9nVZpumPQSEI57jRAA89hQQgONuoC35Lt+rayWY/mzCAc6BQT7RFyFaZKJ2B7IQ8kYjOCPsF/HGFWjdQkQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@grpc/grpc-js": "^1.7.1", @@ -2068,6 +1811,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-http/-/exporter-metrics-otlp-http-0.203.0.tgz", "integrity": "sha512-HFSW10y8lY6BTZecGNpV3GpoSy7eaO0Z6GATwZasnT4bEsILp8UJXNG5OmEsz4SdwCSYvyCbTJdNbZP3/8LGCQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -2087,6 +1831,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-proto/-/exporter-metrics-otlp-proto-0.203.0.tgz", "integrity": "sha512-OZnhyd9npU7QbyuHXFEPVm3LnjZYifuKpT3kTnF84mXeEQ84pJJZgyLBpU4FSkSwUkt/zbMyNAI7y5+jYTWGIg==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -2107,6 +1852,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-prometheus/-/exporter-prometheus-0.203.0.tgz", "integrity": "sha512-2jLuNuw5m4sUj/SncDf/mFPabUxMZmmYetx5RKIMIQyPnl6G6ooFzfeE8aXNRf8YD1ZXNlCnRPcISxjveGJHNg==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -2124,6 +1870,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-grpc/-/exporter-trace-otlp-grpc-0.203.0.tgz", "integrity": "sha512-322coOTf81bm6cAA8+ML6A+m4r2xTCdmAZzGNTboPXRzhwPt4JEmovsFAs+grpdarObd68msOJ9FfH3jxM6wqA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@grpc/grpc-js": "^1.7.1", @@ -2145,6 +1892,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-http/-/exporter-trace-otlp-http-0.203.0.tgz", "integrity": "sha512-ZDiaswNYo0yq/cy1bBLJFe691izEJ6IgNmkjm4C6kE9ub/OMQqDXORx2D2j8fzTBTxONyzusbaZlqtfmyqURPw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -2164,6 +1912,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-proto/-/exporter-trace-otlp-proto-0.203.0.tgz", "integrity": "sha512-1xwNTJ86L0aJmWRwENCJlH4LULMG2sOXWIVw+Szta4fkqKVY50Eo4HoVKKq6U9QEytrWCr8+zjw0q/ZOeXpcAQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -2183,6 +1932,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-zipkin/-/exporter-zipkin-2.0.1.tgz", "integrity": "sha512-a9eeyHIipfdxzCfc2XPrE+/TI3wmrZUDFtG2RRXHSbZZULAny7SyybSvaDvS77a7iib5MPiAvluwVvbGTsHxsw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -2485,6 +2235,7 @@ "version": "0.23.0", "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-fs/-/instrumentation-fs-0.23.0.tgz", "integrity": "sha512-Puan+QopWHA/KNYvDfOZN6M/JtF6buXEyD934vrb8WhsX1/FuM7OtoMlQyIqAadnE8FqqDL4KDPiEfCQH6pQcQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^2.0.0", @@ -2668,6 +2419,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-http/-/instrumentation-http-0.203.0.tgz", "integrity": "sha512-y3uQAcCOAwnO6vEuNVocmpVzG3PER6/YZqbPbbffDdJ9te5NkHEkfSMNzlC3+v7KlE+WinPGc3N7MR30G1HY2g==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -3416,6 +3168,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.203.0.tgz", "integrity": "sha512-Wbxf7k+87KyvxFr5D7uOiSq/vHXWommvdnNE7vECO3tAhsA2GfOlpWINCMWUEPdHZ7tCXxw6Epp3vgx3jU7llQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -3432,6 +3185,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-grpc-exporter-base/-/otlp-grpc-exporter-base-0.203.0.tgz", "integrity": "sha512-te0Ze1ueJF+N/UOFl5jElJW4U0pZXQ8QklgSfJ2linHN0JJsuaHG8IabEUi2iqxY8ZBDlSiz1Trfv5JcjWWWwQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@grpc/grpc-js": "^1.7.1", @@ -3450,6 +3204,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.203.0.tgz", "integrity": "sha512-Y8I6GgoCna0qDQ2W6GCRtaF24SnvqvA8OfeTi7fqigD23u8Jpb4R5KFv/pRvrlGagcCLICMIyh9wiejp4TXu/A==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/api-logs": "0.203.0", @@ -3471,6 +3226,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-b3/-/propagator-b3-2.0.1.tgz", "integrity": "sha512-Hc09CaQ8Tf5AGLmf449H726uRoBNGPBL4bjr7AnnUpzWMvhdn61F78z9qb6IqB737TffBsokGAK1XykFEZ1igw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1" @@ -3486,6 +3242,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-jaeger/-/propagator-jaeger-2.0.1.tgz", "integrity": "sha512-7PMdPBmGVH2eQNb/AtSJizQNgeNTfh6jQFqys6lfhd6P4r+m/nTh3gKPPpaCXVdRQ+z93vfKk+4UGty390283w==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1" @@ -3526,6 +3283,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.203.0.tgz", "integrity": "sha512-vM2+rPq0Vi3nYA5akQD2f3QwossDnTDLvKbea6u/A2NZ3XDkPxMfo/PNrDoXhDUD/0pPo2CdH5ce/thn9K0kLw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/api-logs": "0.203.0", @@ -3543,6 +3301,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.0.1.tgz", "integrity": "sha512-wf8OaJoSnujMAHWR3g+/hGvNcsC16rf9s1So4JlMiFaFHiE4HpIA3oUh+uWZQ7CNuK8gVW/pQSkgoa5HkkOl0g==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "2.0.1", @@ -3559,6 +3318,7 @@ "version": "0.203.0", "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-node/-/sdk-node-0.203.0.tgz", "integrity": "sha512-zRMvrZGhGVMvAbbjiNQW3eKzW/073dlrSiAKPVWmkoQzah9wfynpVPeL55f9fVIm0GaBxTLcPeukWGy0/Wj7KQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/api-logs": "0.203.0", @@ -3612,6 +3372,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-node/-/sdk-trace-node-2.0.1.tgz", "integrity": "sha512-UhdbPF19pMpBtCWYP5lHbTogLWx9N0EBxtdagvkn5YtsAnCBZzL7SjktG+ZmupRgifsHMjwUaCCaVmqGfSADmA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@opentelemetry/context-async-hooks": "2.0.1", @@ -3684,12 +3445,13 @@ } }, "node_modules/@peculiar/asn1-schema": { - "version": "2.3.15", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.3.15.tgz", - "integrity": "sha512-QPeD8UA8axQREpgR5UTAfu2mqQmm97oUqahDtNdBcfj3qAnoXzFdQW+aNf/tD2WVXF8Fhmftxoj0eMIT++gX2w==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.4.0.tgz", + "integrity": "sha512-umbembjIWOrPSOzEGG5vxFLkeM8kzIhLkgigtsOrfLKnuzxWxejAcUX+q/SoZCdemlODOcr5WiYa7+dIEzBXZQ==", + "dev": true, "license": "MIT", "dependencies": { - "asn1js": "^3.0.5", + "asn1js": "^3.0.6", "pvtsutils": "^1.3.6", "tslib": "^2.8.1" } @@ -3698,6 +3460,7 @@ "version": "1.1.12", "resolved": "https://registry.npmjs.org/@peculiar/json-schema/-/json-schema-1.1.12.tgz", "integrity": "sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==", + "dev": true, "license": "MIT", "dependencies": { "tslib": "^2.0.0" @@ -3710,6 +3473,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/@peculiar/webcrypto/-/webcrypto-1.5.0.tgz", "integrity": "sha512-BRs5XUAwiyCDQMsVA9IDvDa7UBR9gAvPHgugOeGng3YN6vJ9JYonyDc0lNczErgtCWtucjR5N7VtaonboD/ezg==", + "dev": true, "license": "MIT", "dependencies": { "@peculiar/asn1-schema": "^2.3.8", @@ -3774,6 +3538,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@posthog/core": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@posthog/core/-/core-1.0.0.tgz", + "integrity": "sha512-gquQld+duT9DdzLIFoHZkUMW0DZOTSLCtSjuuC/zKFz65Qecbz9p37DHBJMkw0dCuB8Mgh2GtH8Ag3PznJrP3g==", + "dev": true, + "license": "MIT" + }, "node_modules/@prisma/instrumentation": { "version": "6.11.1", "resolved": "https://registry.npmjs.org/@prisma/instrumentation/-/instrumentation-6.11.1.tgz", @@ -3822,30 +3593,35 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@protobufjs/base64": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@protobufjs/codegen": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@protobufjs/eventemitter": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@protobufjs/fetch": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "@protobufjs/aspromise": "^1.1.1", @@ -3856,36 +3632,41 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@protobufjs/inquire": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@protobufjs/path": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@protobufjs/pool": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@protobufjs/utf8": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.46.2.tgz", - "integrity": "sha512-Zj3Hl6sN34xJtMv7Anwb5Gu01yujyE/cLBDB2gnHTAHaWS1Z38L7kuSG+oAh0giZMqG060f/YBStXtMH6FvPMA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.47.1.tgz", + "integrity": "sha512-lTahKRJip0knffA/GTNFJMrToD+CM+JJ+Qt5kjzBK/sFQ0EWqfKW3AYQSlZXN98tX0lx66083U9JYIMioMMK7g==", "cpu": [ "arm" ], @@ -3897,9 +3678,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.46.2.tgz", - "integrity": "sha512-nTeCWY83kN64oQ5MGz3CgtPx8NSOhC5lWtsjTs+8JAJNLcP3QbLCtDDgUKQc/Ro/frpMq4SHUaHN6AMltcEoLQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.47.1.tgz", + "integrity": "sha512-uqxkb3RJLzlBbh/bbNQ4r7YpSZnjgMgyoEOY7Fy6GCbelkDSAzeiogxMG9TfLsBbqmGsdDObo3mzGqa8hps4MA==", "cpu": [ "arm64" ], @@ -3911,9 +3692,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.46.2.tgz", - "integrity": "sha512-HV7bW2Fb/F5KPdM/9bApunQh68YVDU8sO8BvcW9OngQVN3HHHkw99wFupuUJfGR9pYLLAjcAOA6iO+evsbBaPQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.47.1.tgz", + "integrity": "sha512-tV6reObmxBDS4DDyLzTDIpymthNlxrLBGAoQx6m2a7eifSNEZdkXQl1PE4ZjCkEDPVgNXSzND/k9AQ3mC4IOEQ==", "cpu": [ "arm64" ], @@ -3925,9 +3706,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.46.2.tgz", - "integrity": "sha512-SSj8TlYV5nJixSsm/y3QXfhspSiLYP11zpfwp6G/YDXctf3Xkdnk4woJIF5VQe0of2OjzTt8EsxnJDCdHd2xMA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.47.1.tgz", + "integrity": "sha512-XuJRPTnMk1lwsSnS3vYyVMu4x/+WIw1MMSiqj5C4j3QOWsMzbJEK90zG+SWV1h0B1ABGCQ0UZUjti+TQK35uHQ==", "cpu": [ "x64" ], @@ -3939,9 +3720,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.46.2.tgz", - "integrity": "sha512-ZyrsG4TIT9xnOlLsSSi9w/X29tCbK1yegE49RYm3tu3wF1L/B6LVMqnEWyDB26d9Ecx9zrmXCiPmIabVuLmNSg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.47.1.tgz", + "integrity": "sha512-79BAm8Ag/tmJ5asCqgOXsb3WY28Rdd5Lxj8ONiQzWzy9LvWORd5qVuOnjlqiWWZJw+dWewEktZb5yiM1DLLaHw==", "cpu": [ "arm64" ], @@ -3953,9 +3734,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.46.2.tgz", - "integrity": "sha512-pCgHFoOECwVCJ5GFq8+gR8SBKnMO+xe5UEqbemxBpCKYQddRQMgomv1104RnLSg7nNvgKy05sLsY51+OVRyiVw==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.47.1.tgz", + "integrity": "sha512-OQ2/ZDGzdOOlyfqBiip0ZX/jVFekzYrGtUsqAfLDbWy0jh1PUU18+jYp8UMpqhly5ltEqotc2miLngf9FPSWIA==", "cpu": [ "x64" ], @@ -3967,9 +3748,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.46.2.tgz", - "integrity": "sha512-EtP8aquZ0xQg0ETFcxUbU71MZlHaw9MChwrQzatiE8U/bvi5uv/oChExXC4mWhjiqK7azGJBqU0tt5H123SzVA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.47.1.tgz", + "integrity": "sha512-HZZBXJL1udxlCVvoVadstgiU26seKkHbbAMLg7680gAcMnRNP9SAwTMVet02ANA94kXEI2VhBnXs4e5nf7KG2A==", "cpu": [ "arm" ], @@ -3981,9 +3762,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.46.2.tgz", - "integrity": "sha512-qO7F7U3u1nfxYRPM8HqFtLd+raev2K137dsV08q/LRKRLEc7RsiDWihUnrINdsWQxPR9jqZ8DIIZ1zJJAm5PjQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.47.1.tgz", + "integrity": "sha512-sZ5p2I9UA7T950JmuZ3pgdKA6+RTBr+0FpK427ExW0t7n+QwYOcmDTK/aRlzoBrWyTpJNlS3kacgSlSTUg6P/Q==", "cpu": [ "arm" ], @@ -3995,9 +3776,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.46.2.tgz", - "integrity": "sha512-3dRaqLfcOXYsfvw5xMrxAk9Lb1f395gkoBYzSFcc/scgRFptRXL9DOaDpMiehf9CO8ZDRJW2z45b6fpU5nwjng==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.47.1.tgz", + "integrity": "sha512-3hBFoqPyU89Dyf1mQRXCdpc6qC6At3LV6jbbIOZd72jcx7xNk3aAp+EjzAtN6sDlmHFzsDJN5yeUySvorWeRXA==", "cpu": [ "arm64" ], @@ -4009,9 +3790,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.46.2.tgz", - "integrity": "sha512-fhHFTutA7SM+IrR6lIfiHskxmpmPTJUXpWIsBXpeEwNgZzZZSg/q4i6FU4J8qOGyJ0TR+wXBwx/L7Ho9z0+uDg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.47.1.tgz", + "integrity": "sha512-49J4FnMHfGodJWPw73Ve+/hsPjZgcXQGkmqBGZFvltzBKRS+cvMiWNLadOMXKGnYRhs1ToTGM0sItKISoSGUNA==", "cpu": [ "arm64" ], @@ -4023,9 +3804,9 @@ ] }, "node_modules/@rollup/rollup-linux-loongarch64-gnu": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.46.2.tgz", - "integrity": "sha512-i7wfGFXu8x4+FRqPymzjD+Hyav8l95UIZ773j7J7zRYc3Xsxy2wIn4x+llpunexXe6laaO72iEjeeGyUFmjKeA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.47.1.tgz", + "integrity": "sha512-4yYU8p7AneEpQkRX03pbpLmE21z5JNys16F1BZBZg5fP9rIlb0TkeQjn5du5w4agConCCEoYIG57sNxjryHEGg==", "cpu": [ "loong64" ], @@ -4037,9 +3818,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.46.2.tgz", - "integrity": "sha512-B/l0dFcHVUnqcGZWKcWBSV2PF01YUt0Rvlurci5P+neqY/yMKchGU8ullZvIv5e8Y1C6wOn+U03mrDylP5q9Yw==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.47.1.tgz", + "integrity": "sha512-fAiq+J28l2YMWgC39jz/zPi2jqc0y3GSRo1yyxlBHt6UN0yYgnegHSRPa3pnHS5amT/efXQrm0ug5+aNEu9UuQ==", "cpu": [ "ppc64" ], @@ -4051,9 +3832,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.46.2.tgz", - "integrity": "sha512-32k4ENb5ygtkMwPMucAb8MtV8olkPT03oiTxJbgkJa7lJ7dZMr0GCFJlyvy+K8iq7F/iuOr41ZdUHaOiqyR3iQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.47.1.tgz", + "integrity": "sha512-daoT0PMENNdjVYYU9xec30Y2prb1AbEIbb64sqkcQcSaR0zYuKkoPuhIztfxuqN82KYCKKrj+tQe4Gi7OSm1ow==", "cpu": [ "riscv64" ], @@ -4065,9 +3846,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.46.2.tgz", - "integrity": "sha512-t5B2loThlFEauloaQkZg9gxV05BYeITLvLkWOkRXogP4qHXLkWSbSHKM9S6H1schf/0YGP/qNKtiISlxvfmmZw==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.47.1.tgz", + "integrity": "sha512-JNyXaAhWtdzfXu5pUcHAuNwGQKevR+6z/poYQKVW+pLaYOj9G1meYc57/1Xv2u4uTxfu9qEWmNTjv/H/EpAisw==", "cpu": [ "riscv64" ], @@ -4079,9 +3860,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.46.2.tgz", - "integrity": "sha512-YKjekwTEKgbB7n17gmODSmJVUIvj8CX7q5442/CK80L8nqOUbMtf8b01QkG3jOqyr1rotrAnW6B/qiHwfcuWQA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.47.1.tgz", + "integrity": "sha512-U/CHbqKSwEQyZXjCpY43/GLYcTVKEXeRHw0rMBJP7fP3x6WpYG4LTJWR3ic6TeYKX6ZK7mrhltP4ppolyVhLVQ==", "cpu": [ "s390x" ], @@ -4093,9 +3874,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.46.2.tgz", - "integrity": "sha512-Jj5a9RUoe5ra+MEyERkDKLwTXVu6s3aACP51nkfnK9wJTraCC8IMe3snOfALkrjTYd2G1ViE1hICj0fZ7ALBPA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.47.1.tgz", + "integrity": "sha512-uTLEakjxOTElfeZIGWkC34u2auLHB1AYS6wBjPGI00bWdxdLcCzK5awjs25YXpqB9lS8S0vbO0t9ZcBeNibA7g==", "cpu": [ "x64" ], @@ -4107,9 +3888,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.46.2.tgz", - "integrity": "sha512-7kX69DIrBeD7yNp4A5b81izs8BqoZkCIaxQaOpumcJ1S/kmqNFjPhDu1LHeVXv0SexfHQv5cqHsxLOjETuqDuA==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.47.1.tgz", + "integrity": "sha512-Ft+d/9DXs30BK7CHCTX11FtQGHUdpNDLJW0HHLign4lgMgBcPFN3NkdIXhC5r9iwsMwYreBBc4Rho5ieOmKNVQ==", "cpu": [ "x64" ], @@ -4121,9 +3902,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.46.2.tgz", - "integrity": "sha512-wiJWMIpeaak/jsbaq2HMh/rzZxHVW1rU6coyeNNpMwk5isiPjSTx0a4YLSlYDwBH/WBvLz+EtsNqQScZTLJy3g==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.47.1.tgz", + "integrity": "sha512-N9X5WqGYzZnjGAFsKSfYFtAShYjwOmFJoWbLg3dYixZOZqU7hdMq+/xyS14zKLhFhZDhP9VfkzQnsdk0ZDS9IA==", "cpu": [ "arm64" ], @@ -4135,9 +3916,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.46.2.tgz", - "integrity": "sha512-gBgaUDESVzMgWZhcyjfs9QFK16D8K6QZpwAaVNJxYDLHWayOta4ZMjGm/vsAEy3hvlS2GosVFlBlP9/Wb85DqQ==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.47.1.tgz", + "integrity": "sha512-O+KcfeCORZADEY8oQJk4HK8wtEOCRE4MdOkb8qGZQNun3jzmj2nmhV/B/ZaaZOkPmJyvm/gW9n0gsB4eRa1eiQ==", "cpu": [ "ia32" ], @@ -4149,9 +3930,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.46.2.tgz", - "integrity": "sha512-CvUo2ixeIQGtF6WvuB87XWqPQkoFAFqW+HUo/WzHwuHDvIwZCtjdWXoYCcr06iKGydiqTclC4jU/TNObC/xKZg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.47.1.tgz", + "integrity": "sha512-CpKnYa8eHthJa3c+C38v/E+/KZyF1Jdh2Cz3DyKZqEWYgrM1IHFArXNWvBLPQCKUEsAqqKX27tTqVEFbDNUcOA==", "cpu": [ "x64" ], @@ -4275,6 +4056,19 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/@semantic-release/git/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@semantic-release/git/node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -4311,6 +4105,13 @@ "node": ">=8" } }, + "node_modules/@semantic-release/git/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, "node_modules/@semantic-release/git/node_modules/strip-final-newline": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", @@ -4322,9 +4123,9 @@ } }, "node_modules/@semantic-release/github": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@semantic-release/github/-/github-11.0.3.tgz", - "integrity": "sha512-T2fKUyFkHHkUNa5XNmcsEcDPuG23hwBKptfUVcFXDVG2cSjXXZYDOfVYwfouqbWo/8UefotLaoGfQeK+k3ep6A==", + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/@semantic-release/github/-/github-11.0.4.tgz", + "integrity": "sha512-fU/nLSjkp9DmB0h7FVO5imhhWJMvq2LjD4+3lz3ZAzpDLY9+KYwC+trJ+g7LbZeJv9y3L9fSFSg2DduUpiT6bw==", "dev": true, "license": "MIT", "dependencies": { @@ -4408,6 +4209,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@semantic-release/github/node_modules/indent-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@semantic-release/npm": { "version": "12.0.2", "resolved": "https://registry.npmjs.org/@semantic-release/npm/-/npm-12.0.2.tgz", @@ -4492,6 +4306,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@semantic-release/npm/node_modules/indent-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@semantic-release/release-notes-generator": { "version": "14.0.3", "resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-14.0.3.tgz", @@ -4545,18 +4372,18 @@ } }, "node_modules/@sentry/core": { - "version": "9.44.2", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-9.44.2.tgz", - "integrity": "sha512-4wduCY9vz+VRMZXTT1dzk08L2nReeR+lzpY8hCcc+Wu100BoJR+TNlrSn1rG5iIo98NDW860JsRA7SVDUDOiNQ==", + "version": "9.46.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-9.46.0.tgz", + "integrity": "sha512-it7JMFqxVproAgEtbLgCVBYtQ9fIb+Bu0JD+cEplTN/Ukpe6GaolyYib5geZqslVxhp2sQgT+58aGvfd/k0N8Q==", "license": "MIT", "engines": { "node": ">=18" } }, "node_modules/@sentry/node": { - "version": "9.44.2", - "resolved": "https://registry.npmjs.org/@sentry/node/-/node-9.44.2.tgz", - "integrity": "sha512-HTUDD73Tdr4GvvcNGQunkqEKeijHb4WYq/NX4YZP5VOeOsKsgIUsv55EgWk1BSHAFGTW6bfeMSoqaNVWiRHn0w==", + "version": "9.46.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-9.46.0.tgz", + "integrity": "sha512-pRLqAcd7GTGvN8gex5FtkQR5Mcol8gOy1WlyZZFq4rBbVtMbqKOQRhohwqnb+YrnmtFpj7IZ7KNDo077MvNeOQ==", "license": "MIT", "dependencies": { "@opentelemetry/api": "^1.9.0", @@ -4589,9 +4416,9 @@ "@opentelemetry/sdk-trace-base": "^1.30.1", "@opentelemetry/semantic-conventions": "^1.34.0", "@prisma/instrumentation": "6.11.1", - "@sentry/core": "9.44.2", - "@sentry/node-core": "9.44.2", - "@sentry/opentelemetry": "9.44.2", + "@sentry/core": "9.46.0", + "@sentry/node-core": "9.46.0", + "@sentry/opentelemetry": "9.46.0", "import-in-the-middle": "^1.14.2", "minimatch": "^9.0.0" }, @@ -4600,13 +4427,13 @@ } }, "node_modules/@sentry/node-core": { - "version": "9.44.2", - "resolved": "https://registry.npmjs.org/@sentry/node-core/-/node-core-9.44.2.tgz", - "integrity": "sha512-TnyKZQ4FOCA+mkLLaOzFPePUBRBf0FU62hnNMscJviwb0UloOvHXx4Ub1DudfFFdnIeVSSMU96ou8vW1zR/1Uw==", + "version": "9.46.0", + "resolved": "https://registry.npmjs.org/@sentry/node-core/-/node-core-9.46.0.tgz", + "integrity": "sha512-XRVu5pqoklZeh4wqhxCLZkz/ipoKhitctgEFXX9Yh1e1BoHM2pIxT52wf+W6hHM676TFmFXW3uKBjsmRM3AjgA==", "license": "MIT", "dependencies": { - "@sentry/core": "9.44.2", - "@sentry/opentelemetry": "9.44.2", + "@sentry/core": "9.46.0", + "@sentry/opentelemetry": "9.46.0", "import-in-the-middle": "^1.14.2" }, "engines": { @@ -4810,12 +4637,12 @@ } }, "node_modules/@sentry/opentelemetry": { - "version": "9.44.2", - "resolved": "https://registry.npmjs.org/@sentry/opentelemetry/-/opentelemetry-9.44.2.tgz", - "integrity": "sha512-KeW5MPXyq9Q8ieYUHO0PuzNNYEYizmTH6x02PG400GwmoeNxnT59Afa4TuPcrXN0QUmK76HJuPfC+7CTuCgoKA==", + "version": "9.46.0", + "resolved": "https://registry.npmjs.org/@sentry/opentelemetry/-/opentelemetry-9.46.0.tgz", + "integrity": "sha512-w2zTxqrdmwRok0cXBoh+ksXdGRUHUZhlpfL/H2kfTodOL+Mk8rW72qUmfqQceXoqgbz8UyK8YgJbyt+XS5H4Qg==", "license": "MIT", "dependencies": { - "@sentry/core": "9.44.2" + "@sentry/core": "9.46.0" }, "engines": { "node": ">=18" @@ -4829,14 +4656,14 @@ } }, "node_modules/@sentry/profiling-node": { - "version": "9.44.2", - "resolved": "https://registry.npmjs.org/@sentry/profiling-node/-/profiling-node-9.44.2.tgz", - "integrity": "sha512-C8fpX2FvnLpNElSavam1yTWZYYCq+AbNjKzf/TiokgUvPNxVFvmdnmW6Vihqevy0dfm6w66Ol58d8ER58nZtMA==", + "version": "9.46.0", + "resolved": "https://registry.npmjs.org/@sentry/profiling-node/-/profiling-node-9.46.0.tgz", + "integrity": "sha512-MPNjVx6m9fn+HUU1FGr5PzgAKLLJA6eXXf+xobtVk+jNo9e0YczUUcnSTJz+VeIUG2joFm9sPfRjYLyONNLuxQ==", "license": "MIT", "dependencies": { "@sentry-internal/node-cpu-profiler": "^2.2.0", - "@sentry/core": "9.44.2", - "@sentry/node": "9.44.2" + "@sentry/core": "9.46.0", + "@sentry/node": "9.46.0" }, "bin": { "sentry-prune-profiler-binaries": "scripts/prune-profiler-binaries.js" @@ -4859,9 +4686,9 @@ } }, "node_modules/@sindresorhus/merge-streams": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz", - "integrity": "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz", + "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==", "dev": true, "license": "MIT", "engines": { @@ -4871,599 +4698,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@smithy/abort-controller": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-4.0.4.tgz", - "integrity": "sha512-gJnEjZMvigPDQWHrW3oPrFhQtkrgqBkyjj3pCIdF3A5M6vsZODG93KNlfJprv6bp4245bdT32fsHK4kkH3KYDA==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/config-resolver": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-4.1.4.tgz", - "integrity": "sha512-prmU+rDddxHOH0oNcwemL+SwnzcG65sBF2yXRO7aeXIn/xTlq2pX7JLVbkBnVLowHLg4/OL4+jBmv9hVrVGS+w==", - "dependencies": { - "@smithy/node-config-provider": "^4.1.3", - "@smithy/types": "^4.3.1", - "@smithy/util-config-provider": "^4.0.0", - "@smithy/util-middleware": "^4.0.4", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/core": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.7.0.tgz", - "integrity": "sha512-7ov8hu/4j0uPZv8b27oeOFtIBtlFmM3ibrPv/Omx1uUdoXvcpJ00U+H/OWWC/keAguLlcqwtyL2/jTlSnApgNQ==", - "dependencies": { - "@smithy/middleware-serde": "^4.0.8", - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "@smithy/util-base64": "^4.0.0", - "@smithy/util-body-length-browser": "^4.0.0", - "@smithy/util-middleware": "^4.0.4", - "@smithy/util-stream": "^4.2.3", - "@smithy/util-utf8": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/credential-provider-imds": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.0.6.tgz", - "integrity": "sha512-hKMWcANhUiNbCJouYkZ9V3+/Qf9pteR1dnwgdyzR09R4ODEYx8BbUysHwRSyex4rZ9zapddZhLFTnT4ZijR4pw==", - "dependencies": { - "@smithy/node-config-provider": "^4.1.3", - "@smithy/property-provider": "^4.0.4", - "@smithy/types": "^4.3.1", - "@smithy/url-parser": "^4.0.4", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/eventstream-codec": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/eventstream-codec/-/eventstream-codec-4.0.4.tgz", - "integrity": "sha512-7XoWfZqWb/QoR/rAU4VSi0mWnO2vu9/ltS6JZ5ZSZv0eovLVfDfu0/AX4ub33RsJTOth3TiFWSHS5YdztvFnig==", - "dependencies": { - "@aws-crypto/crc32": "5.2.0", - "@smithy/types": "^4.3.1", - "@smithy/util-hex-encoding": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/eventstream-serde-browser": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/eventstream-serde-browser/-/eventstream-serde-browser-4.0.4.tgz", - "integrity": "sha512-3fb/9SYaYqbpy/z/H3yIi0bYKyAa89y6xPmIqwr2vQiUT2St+avRt8UKwsWt9fEdEasc5d/V+QjrviRaX1JRFA==", - "dependencies": { - "@smithy/eventstream-serde-universal": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/eventstream-serde-config-resolver": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@smithy/eventstream-serde-config-resolver/-/eventstream-serde-config-resolver-4.1.2.tgz", - "integrity": "sha512-JGtambizrWP50xHgbzZI04IWU7LdI0nh/wGbqH3sJesYToMi2j/DcoElqyOcqEIG/D4tNyxgRuaqBXWE3zOFhQ==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/eventstream-serde-node": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/eventstream-serde-node/-/eventstream-serde-node-4.0.4.tgz", - "integrity": "sha512-RD6UwNZ5zISpOWPuhVgRz60GkSIp0dy1fuZmj4RYmqLVRtejFqQ16WmfYDdoSoAjlp1LX+FnZo+/hkdmyyGZ1w==", - "dependencies": { - "@smithy/eventstream-serde-universal": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/eventstream-serde-universal": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/eventstream-serde-universal/-/eventstream-serde-universal-4.0.4.tgz", - "integrity": "sha512-UeJpOmLGhq1SLox79QWw/0n2PFX+oPRE1ZyRMxPIaFEfCqWaqpB7BU9C8kpPOGEhLF7AwEqfFbtwNxGy4ReENA==", - "dependencies": { - "@smithy/eventstream-codec": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/fetch-http-handler": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.1.0.tgz", - "integrity": "sha512-mADw7MS0bYe2OGKkHYMaqarOXuDwRbO6ArD91XhHcl2ynjGCFF+hvqf0LyQcYxkA1zaWjefSkU7Ne9mqgApSgQ==", - "dependencies": { - "@smithy/protocol-http": "^5.1.2", - "@smithy/querystring-builder": "^4.0.4", - "@smithy/types": "^4.3.1", - "@smithy/util-base64": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/hash-node": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-4.0.4.tgz", - "integrity": "sha512-qnbTPUhCVnCgBp4z4BUJUhOEkVwxiEi1cyFM+Zj6o+aY8OFGxUQleKWq8ltgp3dujuhXojIvJWdoqpm6dVO3lQ==", - "dependencies": { - "@smithy/types": "^4.3.1", - "@smithy/util-buffer-from": "^4.0.0", - "@smithy/util-utf8": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/invalid-dependency": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/invalid-dependency/-/invalid-dependency-4.0.4.tgz", - "integrity": "sha512-bNYMi7WKTJHu0gn26wg8OscncTt1t2b8KcsZxvOv56XA6cyXtOAAAaNP7+m45xfppXfOatXF3Sb1MNsLUgVLTw==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/is-array-buffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-4.0.0.tgz", - "integrity": "sha512-saYhF8ZZNoJDTvJBEWgeBccCg+yvp1CX+ed12yORU3NilJScfc6gfch2oVb4QgxZrGUx3/ZJlb+c/dJbyupxlw==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/middleware-content-length": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/middleware-content-length/-/middleware-content-length-4.0.4.tgz", - "integrity": "sha512-F7gDyfI2BB1Kc+4M6rpuOLne5LOcEknH1n6UQB69qv+HucXBR1rkzXBnQTB2q46sFy1PM/zuSJOB532yc8bg3w==", - "dependencies": { - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/middleware-endpoint": { - "version": "4.1.14", - "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-4.1.14.tgz", - "integrity": "sha512-+BGLpK5D93gCcSEceaaYhUD/+OCGXM1IDaq/jKUQ+ujB0PTWlWN85noodKw/IPFZhIKFCNEe19PGd/reUMeLSQ==", - "dependencies": { - "@smithy/core": "^3.7.0", - "@smithy/middleware-serde": "^4.0.8", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/shared-ini-file-loader": "^4.0.4", - "@smithy/types": "^4.3.1", - "@smithy/url-parser": "^4.0.4", - "@smithy/util-middleware": "^4.0.4", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/middleware-retry": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-4.1.15.tgz", - "integrity": "sha512-iKYUJpiyTQ33U2KlOZeUb0GwtzWR3C0soYcKuCnTmJrvt6XwTPQZhMfsjJZNw7PpQ3TU4Ati1qLSrkSJxnnSMQ==", - "dependencies": { - "@smithy/node-config-provider": "^4.1.3", - "@smithy/protocol-http": "^5.1.2", - "@smithy/service-error-classification": "^4.0.6", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "@smithy/util-middleware": "^4.0.4", - "@smithy/util-retry": "^4.0.6", - "tslib": "^2.6.2", - "uuid": "^9.0.1" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/middleware-serde": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-4.0.8.tgz", - "integrity": "sha512-iSSl7HJoJaGyMIoNn2B7czghOVwJ9nD7TMvLhMWeSB5vt0TnEYyRRqPJu/TqW76WScaNvYYB8nRoiBHR9S1Ddw==", - "dependencies": { - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/middleware-stack": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-4.0.4.tgz", - "integrity": "sha512-kagK5ggDrBUCCzI93ft6DjteNSfY8Ulr83UtySog/h09lTIOAJ/xUSObutanlPT0nhoHAkpmW9V5K8oPyLh+QA==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/node-config-provider": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-4.1.3.tgz", - "integrity": "sha512-HGHQr2s59qaU1lrVH6MbLlmOBxadtzTsoO4c+bF5asdgVik3I8o7JIOzoeqWc5MjVa+vD36/LWE0iXKpNqooRw==", - "dependencies": { - "@smithy/property-provider": "^4.0.4", - "@smithy/shared-ini-file-loader": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/node-http-handler": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.1.0.tgz", - "integrity": "sha512-vqfSiHz2v8b3TTTrdXi03vNz1KLYYS3bhHCDv36FYDqxT7jvTll1mMnCrkD+gOvgwybuunh/2VmvOMqwBegxEg==", - "dependencies": { - "@smithy/abort-controller": "^4.0.4", - "@smithy/protocol-http": "^5.1.2", - "@smithy/querystring-builder": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/property-provider": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-4.0.4.tgz", - "integrity": "sha512-qHJ2sSgu4FqF4U/5UUp4DhXNmdTrgmoAai6oQiM+c5RZ/sbDwJ12qxB1M6FnP+Tn/ggkPZf9ccn4jqKSINaquw==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/protocol-http": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-5.1.2.tgz", - "integrity": "sha512-rOG5cNLBXovxIrICSBm95dLqzfvxjEmuZx4KK3hWwPFHGdW3lxY0fZNXfv2zebfRO7sJZ5pKJYHScsqopeIWtQ==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/querystring-builder": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-4.0.4.tgz", - "integrity": "sha512-SwREZcDnEYoh9tLNgMbpop+UTGq44Hl9tdj3rf+yeLcfH7+J8OXEBaMc2kDxtyRHu8BhSg9ADEx0gFHvpJgU8w==", - "dependencies": { - "@smithy/types": "^4.3.1", - "@smithy/util-uri-escape": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/querystring-parser": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-4.0.4.tgz", - "integrity": "sha512-6yZf53i/qB8gRHH/l2ZwUG5xgkPgQF15/KxH0DdXMDHjesA9MeZje/853ifkSY0x4m5S+dfDZ+c4x439PF0M2w==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/service-error-classification": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@smithy/service-error-classification/-/service-error-classification-4.0.6.tgz", - "integrity": "sha512-RRoTDL//7xi4tn5FrN2NzH17jbgmnKidUqd4KvquT0954/i6CXXkh1884jBiunq24g9cGtPBEXlU40W6EpNOOg==", - "dependencies": { - "@smithy/types": "^4.3.1" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/shared-ini-file-loader": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-4.0.4.tgz", - "integrity": "sha512-63X0260LoFBjrHifPDs+nM9tV0VMkOTl4JRMYNuKh/f5PauSjowTfvF3LogfkWdcPoxsA9UjqEOgjeYIbhb7Nw==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/signature-v4": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.1.2.tgz", - "integrity": "sha512-d3+U/VpX7a60seHziWnVZOHuEgJlclufjkS6zhXvxcJgkJq4UWdH5eOBLzHRMx6gXjsdT9h6lfpmLzbrdupHgQ==", - "dependencies": { - "@smithy/is-array-buffer": "^4.0.0", - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "@smithy/util-hex-encoding": "^4.0.0", - "@smithy/util-middleware": "^4.0.4", - "@smithy/util-uri-escape": "^4.0.0", - "@smithy/util-utf8": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/smithy-client": { - "version": "4.4.6", - "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-4.4.6.tgz", - "integrity": "sha512-3wfhywdzB/CFszP6moa5L3lf5/zSfQoH0kvVSdkyK2az5qZet0sn2PAHjcTDiq296Y4RP5yxF7B6S6+3oeBUCQ==", - "dependencies": { - "@smithy/core": "^3.7.0", - "@smithy/middleware-endpoint": "^4.1.14", - "@smithy/middleware-stack": "^4.0.4", - "@smithy/protocol-http": "^5.1.2", - "@smithy/types": "^4.3.1", - "@smithy/util-stream": "^4.2.3", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/types": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.3.1.tgz", - "integrity": "sha512-UqKOQBL2x6+HWl3P+3QqFD4ncKq0I8Nuz9QItGv5WuKuMHuuwlhvqcZCoXGfc+P1QmfJE7VieykoYYmrOoFJxA==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/url-parser": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-4.0.4.tgz", - "integrity": "sha512-eMkc144MuN7B0TDA4U2fKs+BqczVbk3W+qIvcoCY6D1JY3hnAdCuhCZODC+GAeaxj0p6Jroz4+XMUn3PCxQQeQ==", - "dependencies": { - "@smithy/querystring-parser": "^4.0.4", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-base64": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-base64/-/util-base64-4.0.0.tgz", - "integrity": "sha512-CvHfCmO2mchox9kjrtzoHkWHxjHZzaFojLc8quxXY7WAAMAg43nuxwv95tATVgQFNDwd4M9S1qFzj40Ul41Kmg==", - "dependencies": { - "@smithy/util-buffer-from": "^4.0.0", - "@smithy/util-utf8": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-body-length-browser": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-body-length-browser/-/util-body-length-browser-4.0.0.tgz", - "integrity": "sha512-sNi3DL0/k64/LO3A256M+m3CDdG6V7WKWHdAiBBMUN8S3hK3aMPhwnPik2A/a2ONN+9doY9UxaLfgqsIRg69QA==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-body-length-node": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-body-length-node/-/util-body-length-node-4.0.0.tgz", - "integrity": "sha512-q0iDP3VsZzqJyje8xJWEJCNIu3lktUGVoSy1KB0UWym2CL1siV3artm+u1DFYTLejpsrdGyCSWBdGNjJzfDPjg==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-buffer-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-4.0.0.tgz", - "integrity": "sha512-9TOQ7781sZvddgO8nxueKi3+yGvkY35kotA0Y6BWRajAv8jjmigQ1sBwz0UX47pQMYXJPahSKEKYFgt+rXdcug==", - "dependencies": { - "@smithy/is-array-buffer": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-config-provider": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-config-provider/-/util-config-provider-4.0.0.tgz", - "integrity": "sha512-L1RBVzLyfE8OXH+1hsJ8p+acNUSirQnWQ6/EgpchV88G6zGBTDPdXiiExei6Z1wR2RxYvxY/XLw6AMNCCt8H3w==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-defaults-mode-browser": { - "version": "4.0.22", - "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-4.0.22.tgz", - "integrity": "sha512-hjElSW18Wq3fUAWVk6nbk7pGrV7ZT14DL1IUobmqhV3lxcsIenr5FUsDe2jlTVaS8OYBI3x+Og9URv5YcKb5QA==", - "dependencies": { - "@smithy/property-provider": "^4.0.4", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "bowser": "^2.11.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-defaults-mode-node": { - "version": "4.0.22", - "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-4.0.22.tgz", - "integrity": "sha512-7B8mfQBtwwr2aNRRmU39k/bsRtv9B6/1mTMrGmmdJFKmLAH+KgIiOuhaqfKOBGh9sZ/VkZxbvm94rI4MMYpFjQ==", - "dependencies": { - "@smithy/config-resolver": "^4.1.4", - "@smithy/credential-provider-imds": "^4.0.6", - "@smithy/node-config-provider": "^4.1.3", - "@smithy/property-provider": "^4.0.4", - "@smithy/smithy-client": "^4.4.6", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-endpoints": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@smithy/util-endpoints/-/util-endpoints-3.0.6.tgz", - "integrity": "sha512-YARl3tFL3WgPuLzljRUnrS2ngLiUtkwhQtj8PAL13XZSyUiNLQxwG3fBBq3QXFqGFUXepIN73pINp3y8c2nBmA==", - "dependencies": { - "@smithy/node-config-provider": "^4.1.3", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-hex-encoding": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-4.0.0.tgz", - "integrity": "sha512-Yk5mLhHtfIgW2W2WQZWSg5kuMZCVbvhFmC7rV4IO2QqnZdbEFPmQnCcGMAX2z/8Qj3B9hYYNjZOhWym+RwhePw==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-middleware": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-4.0.4.tgz", - "integrity": "sha512-9MLKmkBmf4PRb0ONJikCbCwORACcil6gUWojwARCClT7RmLzF04hUR4WdRprIXal7XVyrddadYNfp2eF3nrvtQ==", - "dependencies": { - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-retry": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@smithy/util-retry/-/util-retry-4.0.6.tgz", - "integrity": "sha512-+YekoF2CaSMv6zKrA6iI/N9yva3Gzn4L6n35Luydweu5MMPYpiGZlWqehPHDHyNbnyaYlz/WJyYAZnC+loBDZg==", - "dependencies": { - "@smithy/service-error-classification": "^4.0.6", - "@smithy/types": "^4.3.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-stream": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-4.2.3.tgz", - "integrity": "sha512-cQn412DWHHFNKrQfbHY8vSFI3nTROY1aIKji9N0tpp8gUABRilr7wdf8fqBbSlXresobM+tQFNk6I+0LXK/YZg==", - "dependencies": { - "@smithy/fetch-http-handler": "^5.1.0", - "@smithy/node-http-handler": "^4.1.0", - "@smithy/types": "^4.3.1", - "@smithy/util-base64": "^4.0.0", - "@smithy/util-buffer-from": "^4.0.0", - "@smithy/util-hex-encoding": "^4.0.0", - "@smithy/util-utf8": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-uri-escape": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-uri-escape/-/util-uri-escape-4.0.0.tgz", - "integrity": "sha512-77yfbCbQMtgtTylO9itEAdpPXSog3ZxMe09AEhm0dU0NLTalV70ghDZFR+Nfi1C60jnJoh/Re4090/DuZh2Omg==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@smithy/util-utf8": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.0.0.tgz", - "integrity": "sha512-b+zebfKCfRdgNJDknHCob3O7FpeYQN6ZG6YLExMcasDHsCXlsXCEuiPZeLnJLpwa5dvPetGlnGCiMHuLwGvFow==", - "dependencies": { - "@smithy/util-buffer-from": "^4.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@testing-library/dom": { "version": "10.4.1", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", @@ -5556,6 +4790,7 @@ "version": "1.3.7", "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.7.tgz", "integrity": "sha512-Pay9fq2lM2wXPWbteBsRAGiWH2hig4ZE2asK+mm7kUzlxRTfL961rj89I6zV/E3PcIkDqyuBEcMxFT7rccugeQ==", + "dev": true, "license": "MIT", "dependencies": { "@types/node": "*" @@ -5570,9 +4805,10 @@ "peer": true }, "node_modules/@types/body-parser": { - "version": "1.19.5", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", - "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", + "version": "1.19.6", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz", + "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", + "dev": true, "license": "MIT", "dependencies": { "@types/connect": "*", @@ -5599,15 +4835,17 @@ } }, "node_modules/@types/content-disposition": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.8.tgz", - "integrity": "sha512-QVSSvno3dE0MgO76pJhmv4Qyi/j0Yk9pBp0Y7TJ2Tlj+KCgJWY6qX7nnxCOLkZ3VYRSIk1WTxCvwUSdx6CCLdg==", + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.9.tgz", + "integrity": "sha512-8uYXI3Gw35MhiVYhG3s295oihrxRyytcRHjSjqnqZVDDy/xcGBRny7+Xj1Wgfhv5QzRtN2hB2dVRBUX9XW3UcQ==", + "dev": true, "license": "MIT" }, "node_modules/@types/cookie": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.5.4.tgz", "integrity": "sha512-7z/eR6O859gyWIAjuvBWFzNURmf2oPBmJlfVWkwehU5nzIyjwBsTh7WMmEEV4JFnHuQ3ex4oyTvfKzcyJVDBNA==", + "dev": true, "license": "MIT" }, "node_modules/@types/cookiejar": { @@ -5618,9 +4856,10 @@ "license": "MIT" }, "node_modules/@types/cookies": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@types/cookies/-/cookies-0.9.0.tgz", - "integrity": "sha512-40Zk8qR147RABiQ7NQnBzWzDcjKzNrntB5BAmeGCb2p/MIyOE+4BVvc17wumsUqUw00bJYqoXFHYygQnEFh4/Q==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@types/cookies/-/cookies-0.9.1.tgz", + "integrity": "sha512-E/DPgzifH4sM1UMadJMWd6mO2jOd4g1Ejwzx8/uRCDpJis1IrlyQEcGAYEomtAqRYmD5ORbNXMeI9U0RiVGZbg==", + "dev": true, "license": "MIT", "dependencies": { "@types/connect": "*", @@ -5661,6 +4900,7 @@ "version": "5.0.3", "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.3.tgz", "integrity": "sha512-wGA0NX93b19/dZC1J18tKWVIYWyyF2ZjT9vin/NRu0qzzvfVzWjs04iq2rQ3H65vCTQYlRqs3YHfY7zjdV+9Kw==", + "dev": true, "license": "MIT", "dependencies": { "@types/body-parser": "*", @@ -5672,6 +4912,7 @@ "version": "5.0.7", "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.7.tgz", "integrity": "sha512-R+33OsgWw7rOhD1emjU7dzCDHucJrgJXMA5PYCzJxVil0dsyx5iBEPHqpPfiKNJQb7lZ1vxwoLR4Z87bBUpeGQ==", + "dev": true, "license": "MIT", "dependencies": { "@types/node": "*", @@ -5695,6 +4936,8 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, + "license": "MIT", "dependencies": { "@types/unist": "*" } @@ -5703,12 +4946,14 @@ "version": "1.5.6", "resolved": "https://registry.npmjs.org/@types/http-assert/-/http-assert-1.5.6.tgz", "integrity": "sha512-TTEwmtjgVbYAzZYWyeHPrrtWnfVkm8tQkP8P21uQifPgMRgjrow3XDEYqucuC8SKZJT7pUnhU/JymvjggxO9vw==", + "dev": true, "license": "MIT" }, "node_modules/@types/http-errors": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", - "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", + "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", + "dev": true, "license": "MIT" }, "node_modules/@types/ignore-walk": { @@ -5716,6 +4961,7 @@ "resolved": "https://registry.npmjs.org/@types/ignore-walk/-/ignore-walk-4.0.3.tgz", "integrity": "sha512-6V7wDsk0nz8LtRC7qeC0GfXadFLT4FdCtVbXhxoIGRdkn2kLr20iMLupRGiBhlZ79WWWqaObIdR3nkXfUrBPdQ==", "dev": true, + "license": "MIT", "dependencies": { "@types/node": "*" } @@ -5725,6 +4971,7 @@ "resolved": "https://registry.npmjs.org/@types/ink/-/ink-0.5.2.tgz", "integrity": "sha512-yEuhWTRMXJkIWiaM58c5kuRot5HFccv9kjjgy0fBZG0+tYb+sMBaxHNPVqyZXspGGlmwDOQ1d3BsygWpWlW17w==", "dev": true, + "license": "MIT", "dependencies": { "@types/node": "*", "@types/prop-types": "*" @@ -5735,6 +4982,7 @@ "resolved": "https://registry.npmjs.org/@types/ink-testing-library/-/ink-testing-library-1.0.4.tgz", "integrity": "sha512-ui3mKjA+IBpXuIe1WsSQzU8WwOK2hkIM9O27RUEIMxFEzFesfSPGrlwQV0xYuDjxgSibD8mZGeRG+ruimGM+qg==", "dev": true, + "license": "MIT", "dependencies": { "@types/ink": "^0.5.2" } @@ -5767,12 +5015,14 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/keygrip/-/keygrip-1.0.6.tgz", "integrity": "sha512-lZuNAY9xeJt7Bx4t4dx0rYCDqGPW8RXhQZK1td7d4H6E9zYbLoOtjBvfwdTKpsyxQI/2jv+armjX/RW+ZNpXOQ==", + "dev": true, "license": "MIT" }, "node_modules/@types/koa": { "version": "2.15.0", "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.15.0.tgz", "integrity": "sha512-7QFsywoE5URbuVnG3loe03QXuGajrnotr3gQkXcEBShORai23MePfFYdhz90FEtBBpkyIYQbVD+evKtloCgX3g==", + "dev": true, "license": "MIT", "dependencies": { "@types/accepts": "*", @@ -5789,6 +5039,7 @@ "version": "3.2.8", "resolved": "https://registry.npmjs.org/@types/koa-compose/-/koa-compose-3.2.8.tgz", "integrity": "sha512-4Olc63RY+MKvxMwVknCUDhRQX1pFQoBZ/lXcRLP69PQkEpze/0cr8LNqJQe5NFb/b19DWi2a5bTi2VAlQzhJuA==", + "dev": true, "license": "MIT", "dependencies": { "@types/koa": "*" @@ -5805,6 +5056,7 @@ "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true, "license": "MIT" }, "node_modules/@types/minimatch": { @@ -5834,22 +5086,23 @@ } }, "node_modules/@types/node": { - "version": "22.15.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.3.tgz", - "integrity": "sha512-lX7HFZeHf4QG/J7tBZqrCAXwz9J5RD56Y6MpP0eJkka8p+K0RY/yBTW7CYFJ4VGCclxqOLKmiGP5juQc6MKgcw==", + "version": "24.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.0.tgz", + "integrity": "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==", "license": "MIT", "dependencies": { - "undici-types": "~6.21.0" + "undici-types": "~7.10.0" } }, "node_modules/@types/node-fetch": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.12.tgz", - "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==", + "version": "2.6.13", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz", + "integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==", + "dev": true, "license": "MIT", "dependencies": { "@types/node": "*", - "form-data": "^4.0.0" + "form-data": "^4.0.4" } }, "node_modules/@types/normalize-package-data": { @@ -5883,23 +5136,29 @@ "version": "15.7.15", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz", "integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/qs": { "version": "6.14.0", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.14.0.tgz", "integrity": "sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==", + "dev": true, "license": "MIT" }, "node_modules/@types/range-parser": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", - "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==" + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true, + "license": "MIT" }, "node_modules/@types/react": { - "version": "19.1.8", - "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.8.tgz", - "integrity": "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g==", + "version": "19.1.11", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.11.tgz", + "integrity": "sha512-lr3jdBw/BGj49Eps7EvqlUaoeA0xpj3pc0RoJkHpYaCHkVK7i28dKyImLQb3JVlqs3aYSXf7qYuWOW/fgZnTXQ==", + "dev": true, + "license": "MIT", "dependencies": { "csstype": "^3.0.2" } @@ -5912,9 +5171,10 @@ "license": "MIT" }, "node_modules/@types/send": { - "version": "0.17.4", - "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", - "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", + "version": "0.17.5", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.5.tgz", + "integrity": "sha512-z6F2D3cOStZvuk2SaP6YrwkNO65iTZcwA2ZkSABegdkAh/lf+Aa/YQndZVfmEXT5vgAp6zv06VQ3ejSVjAny4w==", + "dev": true, "license": "MIT", "dependencies": { "@types/mime": "^1", @@ -5922,9 +5182,10 @@ } }, "node_modules/@types/serve-static": { - "version": "1.15.7", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz", - "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==", + "version": "1.15.8", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.8.tgz", + "integrity": "sha512-roei0UY3LhpOJvjbIP6ZZFngyLKl5dskOtDhxY5THRSpO+ZI+nzJ+m5yUMzGrp89YRa7lvknKkMYjqQFGwA7Sg==", + "dev": true, "license": "MIT", "dependencies": { "@types/http-errors": "*", @@ -5982,29 +5243,35 @@ "version": "1.4.6", "resolved": "https://registry.npmjs.org/@types/tinycolor2/-/tinycolor2-1.4.6.tgz", "integrity": "sha512-iEN8J0BoMnsWBqjVbWH/c0G0Hh7O21lpR2/+PrvAVgWdzL7eexIFm4JN/Wn10PTcmNdtS6U67r499mlWMXOxNw==", + "dev": true, "license": "MIT" }, "node_modules/@types/triple-beam": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==", + "dev": true, "license": "MIT" }, "node_modules/@types/turndown": { "version": "5.0.5", "resolved": "https://registry.npmjs.org/@types/turndown/-/turndown-5.0.5.tgz", "integrity": "sha512-TL2IgGgc7B5j78rIccBtlYAnkuv8nUQqhQc+DSYV5j9Be9XOcm/SKOVRuA47xAVI3680Tk9B1d8flK2GWT2+4w==", + "dev": true, "license": "MIT" }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==" + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "dev": true, + "license": "MIT" }, "node_modules/@types/uuid": { - "version": "9.0.8", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.8.tgz", - "integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==", + "dev": true, "license": "MIT" }, "node_modules/@types/whatwg-mimetype": { @@ -6015,17 +5282,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.39.0.tgz", - "integrity": "sha512-bhEz6OZeUR+O/6yx9Jk6ohX6H9JSFTaiY0v9/PuKT3oGK0rn0jNplLmyFUGV+a9gfYnVNwGDwS/UkLIuXNb2Rw==", + "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": "8.39.0", - "@typescript-eslint/type-utils": "8.39.0", - "@typescript-eslint/utils": "8.39.0", - "@typescript-eslint/visitor-keys": "8.39.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": "^7.0.0", "natural-compare": "^1.4.0", @@ -6039,22 +5306,22 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.39.0", + "@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": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.39.0.tgz", - "integrity": "sha512-g3WpVQHngx0aLXn6kfIYCZxM6rRJlWzEkVpqEFLT3SgEDsp9cpCbxxgwnE504q4H+ruSDh/VGS6nqZIDynP+vg==", + "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": "8.39.0", - "@typescript-eslint/types": "8.39.0", - "@typescript-eslint/typescript-estree": "8.39.0", - "@typescript-eslint/visitor-keys": "8.39.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": { @@ -6070,14 +5337,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.39.0.tgz", - "integrity": "sha512-CTzJqaSq30V/Z2Og9jogzZt8lJRR5TKlAdXmWgdu4hgcC9Kww5flQ+xFvMxIBWVNdxJO7OifgdOK4PokMIWPew==", + "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.39.0", - "@typescript-eslint/types": "^8.39.0", + "@typescript-eslint/tsconfig-utils": "^8.40.0", + "@typescript-eslint/types": "^8.40.0", "debug": "^4.3.4" }, "engines": { @@ -6092,14 +5359,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.39.0.tgz", - "integrity": "sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==", + "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": "8.39.0", - "@typescript-eslint/visitor-keys": "8.39.0" + "@typescript-eslint/types": "8.40.0", + "@typescript-eslint/visitor-keys": "8.40.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -6110,9 +5377,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.39.0.tgz", - "integrity": "sha512-Fd3/QjmFV2sKmvv3Mrj8r6N8CryYiCS8Wdb/6/rgOXAWGcFuc+VkQuG28uk/4kVNVZBQuuDHEDUpo/pQ32zsIQ==", + "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": { @@ -6127,15 +5394,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.39.0.tgz", - "integrity": "sha512-6B3z0c1DXVT2vYA9+z9axjtc09rqKUPRmijD5m9iv8iQpHBRYRMBcgxSiKTZKm6FwWw1/cI4v6em35OsKCiN5Q==", + "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.39.0", - "@typescript-eslint/typescript-estree": "8.39.0", - "@typescript-eslint/utils": "8.39.0", + "@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" }, @@ -6152,9 +5419,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz", - "integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==", + "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": { @@ -6166,16 +5433,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.39.0.tgz", - "integrity": "sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==", + "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/project-service": "8.39.0", - "@typescript-eslint/tsconfig-utils": "8.39.0", - "@typescript-eslint/types": "8.39.0", - "@typescript-eslint/visitor-keys": "8.39.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", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -6221,16 +5488,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.39.0.tgz", - "integrity": "sha512-4GVSvNA0Vx1Ktwvf4sFE+exxJ3QGUorQG1/A5mRfRNZtkBT2xrA/BCO2H0eALx/PnvCS6/vmYwRdDA41EoffkQ==", + "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.7.0", - "@typescript-eslint/scope-manager": "8.39.0", - "@typescript-eslint/types": "8.39.0", - "@typescript-eslint/typescript-estree": "8.39.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.9.0 || >=21.1.0" @@ -6245,13 +5512,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.39.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.39.0.tgz", - "integrity": "sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==", + "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": "8.39.0", + "@typescript-eslint/types": "8.40.0", "eslint-visitor-keys": "^4.2.1" }, "engines": { @@ -6682,15 +5949,17 @@ } }, "node_modules/@workos-inc/node": { - "version": "7.49.0", - "resolved": "https://registry.npmjs.org/@workos-inc/node/-/node-7.49.0.tgz", - "integrity": "sha512-EjgsvxEU8xQcf2mq3lKihGXyXFFZ596Dpi3hKWj/STLp8a797WZlBoRwzeI3pEhJZo4itwpmV2vj2JXlZEttrg==", + "version": "7.68.0", + "resolved": "https://registry.npmjs.org/@workos-inc/node/-/node-7.68.0.tgz", + "integrity": "sha512-9nyR6KXciewyDyreNX661cvjJxJ9tmls5DtdV4KU89RxeQirIP9ZOG+T6a6Px5UWNMqMU/EHihqKxlmgAPlmRA==", + "dev": true, "license": "MIT", "dependencies": { "iron-session": "~6.3.1", "jose": "~5.6.3", "leb": "^1.0.0", - "pluralize": "8.0.0" + "pluralize": "8.0.0", + "qs": "6.14.0" }, "engines": { "node": ">=16" @@ -6700,6 +5969,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dev": true, "license": "MIT", "dependencies": { "event-target-shim": "^5.0.0" @@ -6712,6 +5982,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "dev": true, "license": "MIT", "dependencies": { "mime-types": "^3.0.0", @@ -6766,9 +6037,10 @@ } }, "node_modules/agent-base": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", - "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 14" @@ -6778,6 +6050,7 @@ "version": "4.6.0", "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.6.0.tgz", "integrity": "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ==", + "dev": true, "license": "MIT", "dependencies": { "humanize-ms": "^1.2.1" @@ -6800,20 +6073,11 @@ "node": ">=8" } }, - "node_modules/aggregate-error/node_modules/indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -6826,25 +6090,40 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ansi-escapes": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.0.0.tgz", + "integrity": "sha512-GdYO7a61mR0fOlAsvC9/rIHf7L96sBc6dEWzeOu+KAea5bZyQRPIpojrVoI4AXGJS/ycu/fBTdLrUkA4ODrvjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "environment": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, "engines": { - "node": ">=8" + "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" @@ -7029,6 +6308,7 @@ "version": "3.0.6", "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.6.tgz", "integrity": "sha512-UOCGPYbl0tv8+006qks/dTgV9ajs97X2p0FAbyS2iyCRrmLSRolDaHdp+v/CLgnzHc3fVB+CwYiUmei7ndFcgA==", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "pvtsutils": "^1.3.6", @@ -7053,6 +6333,7 @@ "version": "3.2.6", "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "dev": true, "license": "MIT" }, "node_modules/async-function": { @@ -7069,12 +6350,15 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true, "license": "MIT" }, "node_modules/auto-bind": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-5.0.1.tgz", "integrity": "sha512-ooviqdwwgfIfNmDwo94wlshcdzfO64XV0Cg6oDsDYBJfITDz1EngD2z7DkbvCWn+XIMsIqW27sEVF6qcpJrRcg==", + "dev": true, + "license": "MIT", "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, @@ -7108,6 +6392,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, "funding": [ { "type": "github", @@ -7131,18 +6416,11 @@ "dev": true, "license": "Apache-2.0" }, - "node_modules/bignumber.js": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz", - "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==", - "engines": { - "node": "*" - } - }, "node_modules/body-parser": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "dev": true, "license": "MIT", "dependencies": { "bytes": "^3.1.2", @@ -7166,11 +6444,6 @@ "dev": true, "license": "MIT" }, - "node_modules/bowser": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz", - "integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA==" - }, "node_modules/brace-expansion": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", @@ -7199,6 +6472,7 @@ "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, "funding": [ { "type": "github", @@ -7219,15 +6493,11 @@ "ieee754": "^1.2.1" } }, - "node_modules/buffer-equal-constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" - }, "node_modules/bundle-name": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", + "dev": true, "license": "MIT", "dependencies": { "run-applescript": "^7.0.0" @@ -7243,6 +6513,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" @@ -7281,6 +6552,7 @@ "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==", + "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -7294,6 +6566,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dev": true, "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.2", @@ -7317,9 +6590,9 @@ } }, "node_modules/chai": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.1.tgz", - "integrity": "sha512-5nFxhUrX0PqtyogoYOA8IPswy5sZFTOsBFl/9bNsmDLgsxYTzSZQJDPppDnZPTQbzSEm0hqGjWPzRemQCYbD6A==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", + "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", "dev": true, "license": "MIT", "dependencies": { @@ -7334,9 +6607,10 @@ } }, "node_modules/chalk": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", - "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.0.tgz", + "integrity": "sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ==", + "dev": true, "license": "MIT", "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" @@ -7385,6 +6659,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz", "integrity": "sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==", + "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -7396,6 +6672,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", "integrity": "sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==", + "dev": true, + "license": "MIT", "dependencies": { "restore-cursor": "^4.0.0" }, @@ -7428,6 +6706,22 @@ "npm": ">=5.0.0" } }, + "node_modules/cli-highlight/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/cli-highlight/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -7457,6 +6751,106 @@ "wrap-ansi": "^7.0.0" } }, + "node_modules/cli-highlight/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/cli-highlight/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/cli-highlight/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/cli-highlight/node_modules/highlight.js": { + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", + "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": "*" + } + }, + "node_modules/cli-highlight/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-highlight/node_modules/parse5": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", + "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", + "dev": true, + "license": "MIT" + }, + "node_modules/cli-highlight/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-highlight/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-highlight/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/cli-highlight/node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -7502,10 +6896,57 @@ "@colors/colors": "1.5.0" } }, + "node_modules/cli-table3/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/cli-table3/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-table3/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-table3/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/cli-truncate": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-4.0.0.tgz", "integrity": "sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA==", + "dev": true, + "license": "MIT", "dependencies": { "slice-ansi": "^5.0.0", "string-width": "^7.0.0" @@ -7517,37 +6958,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cli-truncate/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/cli-truncate/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/cli-truncate/node_modules/emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==" - }, "node_modules/cli-truncate/node_modules/is-fullwidth-code-point": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz", "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==", + "dev": true, + "license": "MIT", "engines": { "node": ">=12" }, @@ -7559,6 +6975,8 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==", + "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^6.0.0", "is-fullwidth-code-point": "^4.0.0" @@ -7570,40 +6988,11 @@ "url": "https://github.com/chalk/slice-ansi?sponsor=1" } }, - "node_modules/cli-truncate/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cli-truncate/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, "license": "ISC", "dependencies": { "string-width": "^4.2.0", @@ -7614,10 +7003,111 @@ "node": ">=12" } }, + "node_modules/cliui/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/cliui/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/cliui/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/cliui/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/cliui/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/code-excerpt": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/code-excerpt/-/code-excerpt-4.0.0.tgz", "integrity": "sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA==", + "dev": true, + "license": "MIT", "dependencies": { "convert-to-spaces": "^2.0.1" }, @@ -7629,6 +7119,7 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==", + "dev": true, "license": "MIT", "dependencies": { "color-convert": "^1.9.3", @@ -7636,52 +7127,38 @@ } }, "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, "license": "MIT", "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" + "color-name": "1.1.3" } }, "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, "license": "MIT" }, "node_modules/color-string": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "dev": true, "license": "MIT", "dependencies": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" } }, - "node_modules/color/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "license": "MIT", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "license": "MIT" - }, "node_modules/colorspace": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.4.tgz", "integrity": "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w==", + "dev": true, "license": "MIT", "dependencies": { "color": "^3.1.3", @@ -7692,6 +7169,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" @@ -7704,6 +7182,7 @@ "version": "14.0.0", "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.0.tgz", "integrity": "sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA==", + "dev": true, "license": "MIT", "engines": { "node": ">=20" @@ -7752,6 +7231,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "dev": true, "license": "MIT", "dependencies": { "safe-buffer": "5.2.1" @@ -7764,6 +7244,7 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -7857,6 +7338,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz", "integrity": "sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ==", + "dev": true, + "license": "MIT", "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } @@ -7865,6 +7348,7 @@ "version": "0.7.2", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -7874,6 +7358,7 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6.6.0" @@ -7886,16 +7371,22 @@ "dev": true, "license": "MIT" }, + "node_modules/core": { + "resolved": "../../core", + "link": true + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true, "license": "MIT" }, "node_modules/cors": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dev": true, "license": "MIT", "dependencies": { "object-assign": "^4", @@ -7932,6 +7423,25 @@ } } }, + "node_modules/cosmiconfig/node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -7962,6 +7472,7 @@ "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -8018,12 +7529,16 @@ "node_modules/csstype": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", - "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "dev": true, + "license": "MIT" }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "dev": true, + "license": "MIT", "engines": { "node": ">= 12" } @@ -8042,39 +7557,12 @@ "node": ">=18" } }, - "node_modules/data-urls/node_modules/tr46": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", - "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "node_modules/data-urls/node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", "dev": true, "license": "MIT", - "dependencies": { - "punycode": "^2.3.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/data-urls/node_modules/webidl-conversions": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", - "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - } - }, - "node_modules/data-urls/node_modules/whatwg-url": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", - "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", - "dev": true, - "license": "MIT", - "dependencies": { - "tr46": "^5.1.0", - "webidl-conversions": "^7.0.0" - }, "engines": { "node": ">=18" } @@ -8137,6 +7625,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz", "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==", + "dev": true, "license": "MIT", "funding": { "type": "github", @@ -8198,6 +7687,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", "integrity": "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==", + "dev": true, "license": "MIT", "dependencies": { "bundle-name": "^4.1.0", @@ -8214,6 +7704,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.0.tgz", "integrity": "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -8244,6 +7735,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -8274,6 +7766,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.4.0" @@ -8283,6 +7776,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" @@ -8292,6 +7786,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -8309,6 +7805,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "dev": true, + "license": "MIT", "dependencies": { "dequal": "^2.0.0" }, @@ -8332,6 +7830,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", + "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" @@ -8385,9 +7884,10 @@ } }, "node_modules/dotenv": { - "version": "16.5.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz", - "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==", + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=12" @@ -8400,6 +7900,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.1", @@ -8424,26 +7925,21 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, "license": "MIT" }, - "node_modules/ecdsa-sig-formatter": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", - "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "dev": true, "license": "MIT" }, "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", + "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", + "dev": true, "license": "MIT" }, "node_modules/emojilib": { @@ -8457,12 +7953,14 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==", + "dev": true, "license": "MIT" }, "node_modules/encodeurl": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" @@ -8613,19 +8111,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/env-ci/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/env-ci/node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -8653,6 +8138,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", + "dev": true, + "license": "MIT", "engines": { "node": ">=18" }, @@ -8670,6 +8157,13 @@ "is-arrayish": "^0.2.1" } }, + "node_modules/error-ex/node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true, + "license": "MIT" + }, "node_modules/es-abstract": { "version": "1.24.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.0.tgz", @@ -8743,6 +8237,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -8752,6 +8247,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -8768,6 +8264,7 @@ "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==", + "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0" @@ -8780,6 +8277,7 @@ "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==", + "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -8823,16 +8321,23 @@ } }, "node_modules/es-toolkit": { - "version": "1.39.7", - "resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.39.7.tgz", - "integrity": "sha512-ek/wWryKouBrZIjkwW2BFf91CWOIMvoy2AE5YYgUrfWsJQM2Su1LoLtrw8uusEpN9RfqLlV/0FVNjT0WMv8Bxw==" + "version": "1.39.10", + "resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.39.10.tgz", + "integrity": "sha512-E0iGnTtbDhkeczB0T+mxmoVlT4YNweEKBLq7oaU4p11mecdsZpNWOglI4895Vh4usbQ+LsJiuLuI2L0Vdmfm2w==", + "dev": true, + "license": "MIT", + "workspaces": [ + "docs", + "benchmarks" + ] }, "node_modules/esbuild": { - "version": "0.25.6", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.6.tgz", - "integrity": "sha512-GVuzuUwtdsghE3ocJ9Bs8PNoF13HNQ5TXbEi2AhvVb8xU1Iwt9Fos9FEamfoee+u/TOsn7GUWc04lz46n2bbTg==", + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.9.tgz", + "integrity": "sha512-CRbODhYyQx3qp7ZEwzxOk4JBqmD/seJrzPa/cGjY1VtIn5E09Oi9/dB4JwctnfZ8Q8iT7rioVv5k/FNT/uf54g==", "dev": true, "hasInstallScript": true, + "license": "MIT", "bin": { "esbuild": "bin/esbuild" }, @@ -8840,38 +8345,39 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.25.6", - "@esbuild/android-arm": "0.25.6", - "@esbuild/android-arm64": "0.25.6", - "@esbuild/android-x64": "0.25.6", - "@esbuild/darwin-arm64": "0.25.6", - "@esbuild/darwin-x64": "0.25.6", - "@esbuild/freebsd-arm64": "0.25.6", - "@esbuild/freebsd-x64": "0.25.6", - "@esbuild/linux-arm": "0.25.6", - "@esbuild/linux-arm64": "0.25.6", - "@esbuild/linux-ia32": "0.25.6", - "@esbuild/linux-loong64": "0.25.6", - "@esbuild/linux-mips64el": "0.25.6", - "@esbuild/linux-ppc64": "0.25.6", - "@esbuild/linux-riscv64": "0.25.6", - "@esbuild/linux-s390x": "0.25.6", - "@esbuild/linux-x64": "0.25.6", - "@esbuild/netbsd-arm64": "0.25.6", - "@esbuild/netbsd-x64": "0.25.6", - "@esbuild/openbsd-arm64": "0.25.6", - "@esbuild/openbsd-x64": "0.25.6", - "@esbuild/openharmony-arm64": "0.25.6", - "@esbuild/sunos-x64": "0.25.6", - "@esbuild/win32-arm64": "0.25.6", - "@esbuild/win32-ia32": "0.25.6", - "@esbuild/win32-x64": "0.25.6" + "@esbuild/aix-ppc64": "0.25.9", + "@esbuild/android-arm": "0.25.9", + "@esbuild/android-arm64": "0.25.9", + "@esbuild/android-x64": "0.25.9", + "@esbuild/darwin-arm64": "0.25.9", + "@esbuild/darwin-x64": "0.25.9", + "@esbuild/freebsd-arm64": "0.25.9", + "@esbuild/freebsd-x64": "0.25.9", + "@esbuild/linux-arm": "0.25.9", + "@esbuild/linux-arm64": "0.25.9", + "@esbuild/linux-ia32": "0.25.9", + "@esbuild/linux-loong64": "0.25.9", + "@esbuild/linux-mips64el": "0.25.9", + "@esbuild/linux-ppc64": "0.25.9", + "@esbuild/linux-riscv64": "0.25.9", + "@esbuild/linux-s390x": "0.25.9", + "@esbuild/linux-x64": "0.25.9", + "@esbuild/netbsd-arm64": "0.25.9", + "@esbuild/netbsd-x64": "0.25.9", + "@esbuild/openbsd-arm64": "0.25.9", + "@esbuild/openbsd-x64": "0.25.9", + "@esbuild/openharmony-arm64": "0.25.9", + "@esbuild/sunos-x64": "0.25.9", + "@esbuild/win32-arm64": "0.25.9", + "@esbuild/win32-ia32": "0.25.9", + "@esbuild/win32-x64": "0.25.9" } }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -8881,32 +8387,37 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "dev": true, "license": "MIT" }, "node_modules/escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, "license": "MIT", "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/eslint": { - "version": "9.32.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.32.0.tgz", - "integrity": "sha512-LSehfdpgMeWcTZkWZVIJl+tkZ2nuSkyyB9C27MZqFWXuph7DvaowgcTvKqxvpLW1JZIk8PN7hFY3Rj9LQ7m7lg==", + "version": "9.33.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.33.0.tgz", + "integrity": "sha512-TS9bTNIryDzStCpJN93aC5VRSW3uTx9sClUn4B87pwiCaJh220otoI0X8mJKr+VcPtniMdN8GKjlwgWGUv5ZKA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.21.0", - "@eslint/config-helpers": "^0.3.0", - "@eslint/core": "^0.15.0", + "@eslint/config-helpers": "^0.3.1", + "@eslint/core": "^0.15.2", "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.32.0", - "@eslint/plugin-kit": "^0.3.4", + "@eslint/js": "9.33.0", + "@eslint/plugin-kit": "^0.3.5", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", @@ -9131,9 +8642,9 @@ } }, "node_modules/eslint-plugin-unused-imports": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz", - "integrity": "sha512-YptD6IzQjDardkl0POxnnRBhU1OEePMV0nd6siHaRBbd+lyh6NAhFEobiznKU7kTsSsDeSD62Pe7kAM1b7dAZQ==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.2.0.tgz", + "integrity": "sha512-hLbJ2/wnjKq4kGA9AUaExVFIbNzyxYdVo49QZmKCnhk5pc9wcYRbfgLHvWJ8tnsdcseGhoUAddm9gn/lt+d74w==", "dev": true, "license": "MIT", "peerDependencies": { @@ -9176,6 +8687,22 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/eslint/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -9193,19 +8720,26 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/eslint/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "node_modules/eslint/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "license": "MIT", - "engines": { - "node": ">=10" + "dependencies": { + "color-name": "~1.1.4" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "engines": { + "node": ">=7.0.0" } }, + "node_modules/eslint/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, "node_modules/eslint/node_modules/eslint-visitor-keys": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", @@ -9219,19 +8753,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/eslint/node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -9346,6 +8867,7 @@ "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -9355,15 +8877,17 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/eventsource": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.6.tgz", - "integrity": "sha512-l19WpE2m9hSuyP06+FbuUUf1G+R0SFLrtQfbRb9PRr+oimOfxQhgGCbVaXg5IvZyyTThJsxh6L/srkMiCeBPDA==", + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "dev": true, "license": "MIT", "dependencies": { "eventsource-parser": "^3.0.1" @@ -9373,12 +8897,13 @@ } }, "node_modules/eventsource-parser": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.1.tgz", - "integrity": "sha512-VARTJ9CYeuQYb0pZEPbzi740OWFgpHe7AYJ2WFZVnUDUQp5Dk2yJUgF36YsZ81cOyxT0QxmXD2EQpapAouzWVA==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.5.tgz", + "integrity": "sha512-bSRG85ZrMdmWtm7qkF9He9TNRzc/Bm99gEJMaQoHJ9E6Kv9QBbsldh2oMj7iXmYNEAVvNgvv5vPorG6W+XtBhQ==", + "dev": true, "license": "MIT", "engines": { - "node": ">=18.0.0" + "node": ">=20.0.0" } }, "node_modules/execa": { @@ -9408,49 +8933,6 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/execa/node_modules/@sindresorhus/merge-streams": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz", - "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/execa/node_modules/get-stream": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz", - "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@sec-ant/readable-stream": "^0.4.1", - "is-stream": "^4.0.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/execa/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/expect-type": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.2.tgz", @@ -9465,6 +8947,8 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "dev": true, + "license": "MIT", "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.0", @@ -9503,9 +8987,10 @@ } }, "node_modules/express-rate-limit": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.0.tgz", - "integrity": "sha512-eB5zbQh5h+VenMPM3fh+nw1YExi5nMr6HUCR62ELSP11huvxm/Uir1H1QEyTkk5QX6A58pX6NmaTMceKZ0Eodg==", + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", + "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 16" @@ -9514,14 +8999,9 @@ "url": "https://github.com/sponsors/express-rate-limit" }, "peerDependencies": { - "express": "^4.11 || 5 || ^5.0.0-beta.1" + "express": ">= 4.11" } }, - "node_modules/extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, "node_modules/fast-content-type-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-3.0.0.tgz", @@ -9543,6 +9023,7 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, "license": "MIT" }, "node_modules/fast-glob": { @@ -9562,10 +9043,24 @@ "node": ">=8.6.0" } }, + "node_modules/fast-glob/node_modules/glob-parent": { + "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" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, "license": "MIT" }, "node_modules/fast-levenshtein": { @@ -9582,23 +9077,6 @@ "dev": true, "license": "MIT" }, - "node_modules/fast-xml-parser": { - "version": "5.2.5", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.2.5.tgz", - "integrity": "sha512-pfX9uG9Ki0yekDHx2SiuRIyFdyAr1kMIMitPvb0YBo8SUfKvia7w7FIyd/l6av85pFYRhZscS75MwMnbvY+hcQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/NaturalIntelligence" - } - ], - "dependencies": { - "strnum": "^2.1.0" - }, - "bin": { - "fxparser": "src/cli/cli.js" - } - }, "node_modules/fastq": { "version": "1.19.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", @@ -9613,12 +9091,14 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==", + "dev": true, "license": "MIT" }, "node_modules/fetch-blob": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "dev": true, "funding": [ { "type": "github", @@ -9629,6 +9109,7 @@ "url": "https://paypal.me/jimmywarting" } ], + "license": "MIT", "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" @@ -9690,6 +9171,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "dev": true, "license": "MIT", "dependencies": { "debug": "^4.4.0", @@ -9775,28 +9257,9 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", + "dev": true, "license": "MIT" }, - "node_modules/follow-redirects": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "license": "MIT", - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/for-each": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", @@ -9817,6 +9280,7 @@ "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, "license": "ISC", "dependencies": { "cross-spawn": "^7.0.6", @@ -9829,22 +9293,11 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/foreground-child/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/form-data": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "dev": true, "license": "MIT", "dependencies": { "asynckit": "^0.4.0", @@ -9861,12 +9314,14 @@ "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==", + "dev": true, "license": "MIT" }, "node_modules/form-data/node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -9876,6 +9331,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, "license": "MIT", "dependencies": { "mime-db": "1.52.0" @@ -9888,6 +9344,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "dev": true, "license": "MIT", "dependencies": { "node-domexception": "1.0.0", @@ -9901,6 +9358,7 @@ "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==", + "dev": true, "license": "MIT", "engines": { "node": ">= 14" @@ -9910,6 +9368,8 @@ "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dev": true, + "license": "MIT", "dependencies": { "fetch-blob": "^3.1.2" }, @@ -9939,6 +9399,7 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -9954,6 +9415,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" @@ -9971,9 +9433,9 @@ } }, "node_modules/fs-extra": { - "version": "11.3.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.0.tgz", - "integrity": "sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==", + "version": "11.3.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.1.tgz", + "integrity": "sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==", "dev": true, "license": "MIT", "dependencies": { @@ -10053,36 +9515,11 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/gaxios": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.1.1.tgz", - "integrity": "sha512-Odju3uBUJyVCkW64nLD4wKLhbh93bh6vIg/ZIXkWiLPBrdgtc65+tls/qml+un3pr6JqYVFDZbbmLDQT68rTOQ==", - "dependencies": { - "extend": "^3.0.2", - "https-proxy-agent": "^7.0.1", - "node-fetch": "^3.3.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/gcp-metadata": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-7.0.1.tgz", - "integrity": "sha512-UcO3kefx6dCcZkgcTGgVOTFb7b1LlQ02hY1omMjjrrBzkajRMCFgYOjs7J71WqnuG1k2b+9ppGL7FsOfhZMQKQ==", - "dependencies": { - "gaxios": "^7.0.0", - "google-logging-utils": "^1.0.0", - "json-bigint": "^1.0.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, "license": "ISC", "engines": { "node": "6.* || 8.* || >= 10.*" @@ -10092,6 +9529,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.3.0.tgz", "integrity": "sha512-vpeMIQKxczTD/0s2CdEWHcb0eeJe6TFjxb+J5xgX7hScxqrGuyjmv4c1D4A/gelKfyox0gJJwIHF+fLjeaM8kQ==", + "dev": true, + "license": "MIT", "engines": { "node": ">=18" }, @@ -10103,6 +9542,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.2", @@ -10127,6 +9567,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, "license": "MIT", "dependencies": { "dunder-proto": "^1.0.1", @@ -10137,13 +9578,17 @@ } }, "node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz", + "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==", "dev": true, "license": "MIT", + "dependencies": { + "@sec-ant/readable-stream": "^0.4.1", + "is-stream": "^4.0.1" + }, "engines": { - "node": ">=10" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -10172,6 +9617,7 @@ "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.1.tgz", "integrity": "sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==", "dev": true, + "license": "MIT", "dependencies": { "resolve-pkg-maps": "^1.0.0" }, @@ -10198,6 +9644,7 @@ "version": "11.0.3", "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", + "dev": true, "license": "ISC", "dependencies": { "foreground-child": "^3.3.1", @@ -10218,16 +9665,16 @@ } }, "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, "license": "ISC", "dependencies": { - "is-glob": "^4.0.1" + "is-glob": "^4.0.3" }, "engines": { - "node": ">= 6" + "node": ">=10.13.0" } }, "node_modules/globals": { @@ -10281,6 +9728,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globby/node_modules/@sindresorhus/merge-streams": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz", + "integrity": "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globby/node_modules/path-type": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-6.0.0.tgz", @@ -10294,48 +9754,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/globby/node_modules/slash": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", - "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/google-auth-library": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.2.0.tgz", - "integrity": "sha512-gy/0hRx8+Ye0HlUm3GrfpR4lbmJQ6bJ7F44DmN7GtMxxzWSojLzx0Bhv/hj7Wlj7a2On0FcT8jrz8Y1c1nxCyg==", - "dependencies": { - "base64-js": "^1.3.0", - "ecdsa-sig-formatter": "^1.0.11", - "gaxios": "^7.0.0", - "gcp-metadata": "^7.0.0", - "google-logging-utils": "^1.0.0", - "gtoken": "^8.0.0", - "jws": "^4.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/google-logging-utils": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-1.1.1.tgz", - "integrity": "sha512-rcX58I7nqpu4mbKztFeOAObbomBbHU2oIb/d3tJfF3dizGSApqtSwYJigGCooHdnMyQBIw8BrWyK96w3YXgr6A==", - "engines": { - "node": ">=14" - } - }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -10348,6 +9771,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/gpt-tokenizer/-/gpt-tokenizer-3.0.1.tgz", "integrity": "sha512-5jdaspBq/w4sWw322SvQj1Fku+CN4OAfYZeeEg8U7CWtxBz+zkxZ3h0YOHD43ee+nZYZ5Ud70HRN0ANcdIj4qg==", + "dev": true, "license": "MIT" }, "node_modules/graceful-fs": { @@ -10361,6 +9785,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/gradient-string/-/gradient-string-3.0.0.tgz", "integrity": "sha512-frdKI4Qi8Ihp4C6wZNB565de/THpIaw3DjP5ku87M+N9rNSGmPTjfkq61SdRXB7eCaL8O1hkKDvf6CDMtOzIAg==", + "dev": true, "license": "MIT", "dependencies": { "chalk": "^5.3.0", @@ -10377,18 +9802,6 @@ "dev": true, "license": "MIT" }, - "node_modules/gtoken": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-8.0.0.tgz", - "integrity": "sha512-+CqsMbHPiSTdtSO14O51eMNlrp9N79gmeqmXeouJOhfucAedHw9noVe/n5uJk3tbKE6a+6ZCQg3RPhVhHByAIw==", - "dependencies": { - "gaxios": "^7.0.0", - "jws": "^4.0.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/handlebars": { "version": "4.7.8", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", @@ -10427,24 +9840,21 @@ } }, "node_modules/happy-dom/node_modules/@types/node": { - "version": "20.19.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.9.tgz", - "integrity": "sha512-cuVNgarYWZqxRJDQHEB58GEONhOK79QVR/qYx4S7kcUObQvUwvFnYxJuuHUKm2aieN9X3yZB4LZsuYNU1Qphsw==", + "version": "20.19.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.11.tgz", + "integrity": "sha512-uug3FEEGv0r+jrecvUUpbY8lLisvIjg6AAic6a2bSP5OEOLeJsDSnvhCDov7ipFFMXS3orMpzlmi0ZcuGkBbow==", "dev": true, "license": "MIT", "dependencies": { "undici-types": "~6.21.0" } }, - "node_modules/happy-dom/node_modules/whatwg-mimetype": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", - "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", + "node_modules/happy-dom/node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - } + "license": "MIT" }, "node_modules/has-bigints": { "version": "1.1.0", @@ -10502,6 +9912,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -10514,6 +9925,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, "license": "MIT", "dependencies": { "has-symbols": "^1.0.3" @@ -10538,13 +9950,13 @@ } }, "node_modules/highlight.js": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", - "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", + "version": "11.11.1", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz", + "integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==", "dev": true, "license": "BSD-3-Clause", "engines": { - "node": "*" + "node": ">=12.0.0" } }, "node_modules/hook-std": { @@ -10573,13 +9985,6 @@ "node": "^16.14.0 || >=18.0.0" } }, - "node_modules/hosted-git-info/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true, - "license": "ISC" - }, "node_modules/html-encoding-sniffer": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", @@ -10597,6 +10002,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dev": true, "license": "MIT", "dependencies": { "depd": "2.0.0", @@ -10609,10 +10015,21 @@ "node": ">= 0.8" } }, + "node_modules/http-errors/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/http-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, "license": "MIT", "dependencies": { "agent-base": "^7.1.0", @@ -10626,6 +10043,7 @@ "version": "7.0.6", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, "license": "MIT", "dependencies": { "agent-base": "^7.1.2", @@ -10649,6 +10067,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==", + "dev": true, "license": "MIT", "dependencies": { "ms": "^2.0.0" @@ -10658,6 +10077,7 @@ "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" @@ -10670,6 +10090,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, "funding": [ { "type": "github", @@ -10700,6 +10121,8 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-7.0.0.tgz", "integrity": "sha512-T4gbf83A4NH95zvhVYZc+qWocBBGlpzUXLPGurJggw/WIOwicfXJChLDP/iBZnN5WqROSu5Bm3hhle4z8a8YGQ==", + "dev": true, + "license": "ISC", "dependencies": { "minimatch": "^9.0.0" }, @@ -10711,6 +10134,8 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } @@ -10719,6 +10144,8 @@ "version": "9.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -10733,6 +10160,7 @@ "version": "3.0.6", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "dev": true, "license": "MIT" }, "node_modules/import-fresh": { @@ -10752,16 +10180,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/import-fresh/node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/import-from-esm": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/import-from-esm/-/import-from-esm-2.0.0.tgz", @@ -10810,14 +10228,13 @@ } }, "node_modules/indent-string": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", - "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=8" } }, "node_modules/index-to-position": { @@ -10837,6 +10254,7 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, "license": "ISC" }, "node_modules/ini": { @@ -10847,26 +10265,27 @@ "license": "ISC" }, "node_modules/ink": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ink/-/ink-6.1.0.tgz", - "integrity": "sha512-YQ+lbMD79y3FBAJXXZnuRajLEgaMFp102361eY5NrBIEVCi9oFo7gNZU4z2LBWlcjZFiTt7jetlkIbKCCH4KJA==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ink/-/ink-6.2.2.tgz", + "integrity": "sha512-LN1f+/D8KKqMqRux08fIfA9wsEAJ9Bu9CiI3L6ih7bnqNSDUXT/JVJ0rUIc4NkjPiPaeI3BVNREcLYLz9ePSEg==", + "dev": true, "license": "MIT", "dependencies": { - "@alcalzone/ansi-tokenize": "^0.1.3", + "@alcalzone/ansi-tokenize": "^0.2.0", "ansi-escapes": "^7.0.0", "ansi-styles": "^6.2.1", "auto-bind": "^5.0.1", - "chalk": "^5.3.0", + "chalk": "^5.6.0", "cli-boxes": "^3.0.0", "cli-cursor": "^4.0.0", "cli-truncate": "^4.0.0", "code-excerpt": "^4.0.0", - "es-toolkit": "^1.22.0", + "es-toolkit": "^1.39.10", "indent-string": "^5.0.0", - "is-in-ci": "^1.0.0", + "is-in-ci": "^2.0.0", "patch-console": "^2.0.0", "react-reconciler": "^0.32.0", - "scheduler": "^0.23.0", + "scheduler": "^0.26.0", "signal-exit": "^3.0.7", "slice-ansi": "^7.1.0", "stack-utils": "^2.0.6", @@ -10899,6 +10318,7 @@ "resolved": "https://registry.npmjs.org/ink-testing-library/-/ink-testing-library-4.0.0.tgz", "integrity": "sha512-yF92kj3pmBvk7oKbSq5vEALO//o7Z9Ck/OaLNlkzXNeYdwfpxMQkSowGTFUCS5MSu9bWfSZMewGpp7bFc66D7Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=18" }, @@ -10911,103 +10331,25 @@ } } }, - "node_modules/ink/node_modules/ansi-escapes": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.0.0.tgz", - "integrity": "sha512-GdYO7a61mR0fOlAsvC9/rIHf7L96sBc6dEWzeOu+KAea5bZyQRPIpojrVoI4AXGJS/ycu/fBTdLrUkA4ODrvjw==", - "dependencies": { - "environment": "^1.0.0" - }, + "node_modules/ink/node_modules/indent-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", + "dev": true, + "license": "MIT", "engines": { - "node": ">=18" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/ink/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/ink/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/ink/node_modules/emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==" - }, - "node_modules/ink/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ink/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/ink/node_modules/type-fest": { - "version": "4.41.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", - "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ink/node_modules/wrap-ansi": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", - "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==", - "dependencies": { - "ansi-styles": "^6.2.1", - "string-width": "^7.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } + "node_modules/ink/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" }, "node_modules/internal-slot": { "version": "1.1.0", @@ -11045,6 +10387,7 @@ "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.10" @@ -11054,6 +10397,7 @@ "version": "6.3.1", "resolved": "https://registry.npmjs.org/iron-session/-/iron-session-6.3.1.tgz", "integrity": "sha512-3UJ7y2vk/WomAtEySmPgM6qtYF1cZ3tXuWX5GsVX4PJXAcs5y/sV9HuSfpjKS6HkTL/OhZcTDWJNLZ7w+Erx3A==", + "dev": true, "license": "MIT", "dependencies": { "@peculiar/webcrypto": "^1.4.0", @@ -11088,6 +10432,7 @@ "version": "4.17.23", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.23.tgz", "integrity": "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ==", + "dev": true, "license": "MIT", "dependencies": { "@types/body-parser": "*", @@ -11100,6 +10445,7 @@ "version": "4.19.6", "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.6.tgz", "integrity": "sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==", + "dev": true, "license": "MIT", "dependencies": { "@types/node": "*", @@ -11112,12 +10458,14 @@ "version": "17.0.45", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==", + "dev": true, "license": "MIT" }, "node_modules/iron-session/node_modules/cookie": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -11127,6 +10475,7 @@ "version": "0.2.8", "resolved": "https://registry.npmjs.org/iron-webcrypto/-/iron-webcrypto-0.2.8.tgz", "integrity": "sha512-YPdCvjFMOBjXaYuDj5tiHst5CEk6Xw84Jo8Y2+jzhMceclAnb3+vNPP/CTtb5fO2ZEuXEaO4N+w62Vfko757KA==", + "dev": true, "license": "MIT", "dependencies": { "buffer": "^6" @@ -11154,9 +10503,9 @@ } }, "node_modules/is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", "dev": true, "license": "MIT" }, @@ -11290,6 +10639,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "dev": true, "license": "MIT", "bin": { "is-docker": "cli.js" @@ -11328,12 +10678,19 @@ } }, "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-5.0.0.tgz", + "integrity": "sha512-OVa3u9kkBbw7b8Xw5F9P+D/T9X+Z4+JruYVNapTjPYZYUznQ5YfWeFkOj606XYYW8yugTfC8Pj0hYqvi4ryAhA==", + "dev": true, "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.0.0" + }, "engines": { - "node": ">=8" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/is-generator-function": { @@ -11369,14 +10726,16 @@ } }, "node_modules/is-in-ci": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-in-ci/-/is-in-ci-1.0.0.tgz", - "integrity": "sha512-eUuAjybVTHMYWm/U+vBO1sY/JOCgoPCXRxzdju0K+K0BiGW0SChEL1MLC0PoCIR1OlPo5YAp8HuQoUlsWEICwg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-in-ci/-/is-in-ci-2.0.0.tgz", + "integrity": "sha512-cFeerHriAnhrQSbpAxL37W1wcJKUUX07HyLWZCW1URJT/ra3GyUTzBgUnh24TMVfNTV2Hij2HLxkPHFZfOZy5w==", + "dev": true, + "license": "MIT", "bin": { "is-in-ci": "cli.js" }, "engines": { - "node": ">=18" + "node": ">=20" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -11386,6 +10745,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "dev": true, "license": "MIT", "dependencies": { "is-docker": "^3.0.0" @@ -11494,6 +10854,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "dev": true, "license": "MIT" }, "node_modules/is-regex": { @@ -11671,6 +11032,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", + "dev": true, "license": "MIT", "dependencies": { "is-inside-container": "^1.0.0" @@ -11686,12 +11048,14 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true, "license": "MIT" }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, "license": "ISC" }, "node_modules/issue-parser": { @@ -11715,6 +11079,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", "integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==", + "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" @@ -11740,6 +11105,7 @@ "version": "5.6.3", "resolved": "https://registry.npmjs.org/jose/-/jose-5.6.3.tgz", "integrity": "sha512-1Jh//hEEwMhNYPDDLwXHa2ePWgWiFNNUadVmguAAw2IJ6sj9mNxV5tGXJNqlMkJAybF6Lgw1mISDxTePP/187g==", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/panva" @@ -11749,6 +11115,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, "license": "MIT" }, "node_modules/js-yaml": { @@ -11804,64 +11171,16 @@ } } }, - "node_modules/jsdom/node_modules/parse5": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", - "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "node_modules/jsdom/node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", "dev": true, "license": "MIT", - "dependencies": { - "entities": "^6.0.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/jsdom/node_modules/tr46": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", - "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", - "dev": true, - "license": "MIT", - "dependencies": { - "punycode": "^2.3.1" - }, "engines": { "node": ">=18" } }, - "node_modules/jsdom/node_modules/webidl-conversions": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", - "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - } - }, - "node_modules/jsdom/node_modules/whatwg-url": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", - "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", - "dev": true, - "license": "MIT", - "dependencies": { - "tr46": "^5.1.0", - "webidl-conversions": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/json-bigint": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", - "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", - "dependencies": { - "bignumber.js": "^9.0.0" - } - }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -11883,15 +11202,11 @@ "dev": true, "license": "MIT" }, - "node_modules/json-schema": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" - }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { @@ -11922,9 +11237,9 @@ } }, "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", + "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", "dev": true, "license": "MIT", "dependencies": { @@ -11938,6 +11253,7 @@ "version": "3.10.1", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "dev": true, "license": "(MIT OR GPL-3.0-or-later)", "dependencies": { "lie": "~3.3.0", @@ -11946,25 +11262,6 @@ "setimmediate": "^1.0.5" } }, - "node_modules/jwa": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", - "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", - "dependencies": { - "buffer-equal-constant-time": "^1.0.1", - "ecdsa-sig-formatter": "1.0.11", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/jws": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", - "integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==", - "dependencies": { - "jwa": "^2.0.0", - "safe-buffer": "^5.0.1" - } - }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -11979,12 +11276,14 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", + "dev": true, "license": "MIT" }, "node_modules/leb": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/leb/-/leb-1.0.0.tgz", "integrity": "sha512-Y3c3QZfvKWHX60BVOQPhLCvVGmDYWyJEiINE3drOog6KCyN2AOwvuQQzlS3uJg1J85kzpILXIUwRXULWavir+w==", + "dev": true, "license": "Apache-2.0" }, "node_modules/levn": { @@ -12005,6 +11304,7 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "dev": true, "license": "MIT", "dependencies": { "immediate": "~3.0.5" @@ -12081,6 +11381,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", + "dev": true, "license": "MIT" }, "node_modules/lodash.capitalize": { @@ -12129,6 +11430,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/logform/-/logform-2.7.0.tgz", "integrity": "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==", + "dev": true, "license": "MIT", "dependencies": { "@colors/colors": "1.6.0", @@ -12146,6 +11448,7 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.1.90" @@ -12155,23 +11458,13 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", + "dev": true, "license": "Apache-2.0" }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" - }, - "bin": { - "loose-envify": "cli.js" - } - }, "node_modules/loupe": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.0.tgz", - "integrity": "sha512-2NCfZcT5VGVNX9mSZIxLRkEAegDGBpuQZBy13desuHeVORmBDyAET4TkJr4SjqQy3A8JDofMN6LpkK8Xcm/dlw==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", + "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", "dev": true, "license": "MIT" }, @@ -12179,6 +11472,8 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/lowlight/-/lowlight-3.3.0.tgz", "integrity": "sha512-0JNhgFoPvP6U6lE/UdVsSq99tn6DhjjpAj5MxG49ewd2mOBVtwWYIT8ClyABhq198aXXODMU6Ox8DrGy/CpTZQ==", + "dev": true, + "license": "MIT", "dependencies": { "@types/hast": "^3.0.0", "devlop": "^1.0.0", @@ -12189,13 +11484,12 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/lowlight/node_modules/highlight.js": { - "version": "11.11.1", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz", - "integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==", - "engines": { - "node": ">=12.0.0" - } + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" }, "node_modules/lz-string": { "version": "1.5.0", @@ -12209,13 +11503,13 @@ } }, "node_modules/magic-string": { - "version": "0.30.17", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", - "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "version": "0.30.18", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.18.tgz", + "integrity": "sha512-yi8swmWbO17qHhwIBNeeZxTceJMeBvWJaId6dyvTSOwTipqeHhMhOrz6513r1sOKnpvQ7zkhlG8tPrpilwTxHQ==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0" + "@jridgewell/sourcemap-codec": "^1.5.5" } }, "node_modules/make-error": { @@ -12260,26 +11554,10 @@ "marked": ">=1 <16" } }, - "node_modules/marked-terminal/node_modules/ansi-escapes": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.0.0.tgz", - "integrity": "sha512-GdYO7a61mR0fOlAsvC9/rIHf7L96sBc6dEWzeOu+KAea5bZyQRPIpojrVoI4AXGJS/ycu/fBTdLrUkA4ODrvjw==", - "dev": true, - "license": "MIT", - "dependencies": { - "environment": "^1.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/marked-terminal/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "dev": true, "license": "MIT", "engines": { @@ -12293,6 +11571,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -12302,6 +11581,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" @@ -12324,6 +11604,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -12393,6 +11674,7 @@ "version": "1.54.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -12402,6 +11684,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "dev": true, "license": "MIT", "dependencies": { "mime-db": "^1.54.0" @@ -12414,6 +11697,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -12423,6 +11707,8 @@ "version": "10.0.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", + "dev": true, + "license": "ISC", "dependencies": { "@isaacs/brace-expansion": "^5.0.0" }, @@ -12447,6 +11733,7 @@ "version": "7.1.2", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" @@ -12506,9 +11793,9 @@ } }, "node_modules/napi-postinstall": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/napi-postinstall/-/napi-postinstall-0.3.2.tgz", - "integrity": "sha512-tWVJxJHmBWLy69PvO96TZMZDrzmw5KeiZBz3RHmiM2XZ9grBJ2WgMAFVVg25nqp3ZjTFUs2Ftw1JhscL3Teliw==", + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/napi-postinstall/-/napi-postinstall-0.3.3.tgz", + "integrity": "sha512-uTp172LLXSxuSYHv/kou+f6KW3SMppU9ivthaVTXian9sOt3XM/zHYHpRZiLgQoxeWfYUnslNWQHF1+G71xcow==", "dev": true, "license": "MIT", "bin": { @@ -12532,6 +11819,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -12552,13 +11840,13 @@ "license": "MIT" }, "node_modules/nock": { - "version": "14.0.5", - "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.5.tgz", - "integrity": "sha512-R49fALR9caB6vxuSWUIaK2eBYeTloZQUFBZ4rHO+TbhMGQHtwnhdqKLYki+o+8qMgLvoBYWrp/2KzGPhxL4S6w==", + "version": "14.0.10", + "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.10.tgz", + "integrity": "sha512-Q7HjkpyPeLa0ZVZC5qpxBt5EyLczFJ91MEewQiIi9taWuA0KB/MDJlUWtON+7dGouVdADTQsf9RA7TZk6D8VMw==", "dev": true, "license": "MIT", "dependencies": { - "@mswjs/interceptors": "^0.38.7", + "@mswjs/interceptors": "^0.39.5", "json-stringify-safe": "^5.0.1", "propagate": "^2.0.0" }, @@ -12583,6 +11871,7 @@ "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", "deprecated": "Use your platform's native DOMException instead", + "dev": true, "funding": [ { "type": "github", @@ -12618,6 +11907,8 @@ "version": "3.3.2", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "dev": true, + "license": "MIT", "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", @@ -12635,6 +11926,7 @@ "version": "1.1.12", "resolved": "https://registry.npmjs.org/node-machine-id/-/node-machine-id-1.1.12.tgz", "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==", + "dev": true, "license": "MIT" }, "node_modules/normalize-package-data": { @@ -15389,6 +14681,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -15398,6 +14691,7 @@ "version": "1.13.4", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -15494,6 +14788,7 @@ "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dev": true, "license": "MIT", "dependencies": { "ee-first": "1.1.1" @@ -15506,6 +14801,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "license": "ISC", "dependencies": { "wrappy": "1" @@ -15515,6 +14811,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==", + "dev": true, "license": "MIT", "dependencies": { "fn.name": "1.x.x" @@ -15524,6 +14821,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, "license": "MIT", "dependencies": { "mimic-fn": "^2.1.0" @@ -15536,15 +14834,16 @@ } }, "node_modules/open": { - "version": "10.1.2", - "resolved": "https://registry.npmjs.org/open/-/open-10.1.2.tgz", - "integrity": "sha512-cxN6aIDPz6rm8hbebcP7vrQNhvRcveZoJU72Y7vskh4oIm+BZwBECnx5nTmrlres1Qapvx27Qo1Auukpf8PKXw==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/open/-/open-10.2.0.tgz", + "integrity": "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==", + "dev": true, "license": "MIT", "dependencies": { "default-browser": "^5.2.1", "define-lazy-prop": "^3.0.0", "is-inside-container": "^1.0.0", - "is-wsl": "^3.1.0" + "wsl-utils": "^0.1.0" }, "engines": { "node": ">=18" @@ -15557,6 +14856,8 @@ "version": "4.104.0", "resolved": "https://registry.npmjs.org/openai/-/openai-4.104.0.tgz", "integrity": "sha512-p99EFNsA/yX6UhVO93f5kJsDRLAg+CTA2RBqdHK4RtK8u5IJw32Hyb2dTGKbnnFmnuoBv5r7Z2CURI9sGZpSuA==", + "dev": true, + "license": "Apache-2.0", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -15583,9 +14884,10 @@ } }, "node_modules/openai/node_modules/@types/node": { - "version": "18.19.87", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.87.tgz", - "integrity": "sha512-OIAAu6ypnVZHmsHCeJ+7CCSub38QNBS9uceMQeg7K5Ur0Jr+wG9wEOEvvMbhp09pxD5czIUy/jND7s7Tb6Nw7A==", + "version": "18.19.123", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.123.tgz", + "integrity": "sha512-K7DIaHnh0mzVxreCR9qwgNxp3MH9dltPNIEddW9MYUlcKAzm+3grKNSTe2vCJHI1FaLpvpL5JGJrz1UZDKYvDg==", + "dev": true, "license": "MIT", "dependencies": { "undici-types": "~5.26.4" @@ -15595,6 +14897,7 @@ "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==", + "dev": true, "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" @@ -15611,12 +14914,38 @@ } } }, + "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==", + "dev": true, + "license": "MIT" + }, "node_modules/openai/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==", + "dev": true, "license": "MIT" }, + "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==", + "dev": true, + "license": "BSD-2-Clause" + }, + "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==", + "dev": true, + "license": "MIT", + "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", @@ -15754,16 +15083,28 @@ "node": ">=8" } }, + "node_modules/p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/package-json-from-dist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, "license": "BlueOak-1.0.0" }, "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "dev": true, "license": "(MIT AND Zlib)" }, "node_modules/parent-module": { @@ -15780,19 +15121,18 @@ } }, "node_modules/parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-8.3.0.tgz", + "integrity": "sha512-ybiGyvspI+fAoRQbIPRddCcSTV9/LsJbf0e/S85VLowVGzRmokfneg2kwVW/KU5rOXrPSbF1qAKPMgNTqqROQQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" + "@babel/code-frame": "^7.26.2", + "index-to-position": "^1.1.0", + "type-fest": "^4.39.1" }, "engines": { - "node": ">=8" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -15812,11 +15152,17 @@ } }, "node_modules/parse5": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", - "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", "dev": true, - "license": "MIT" + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } }, "node_modules/parse5-htmlparser2-tree-adapter": { "version": "6.0.1", @@ -15839,6 +15185,7 @@ "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" @@ -15848,6 +15195,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/patch-console/-/patch-console-2.0.0.tgz", "integrity": "sha512-0YNdUceMdaQwoKce1gatDScmMo5pu/tfABfnzEqeG0gtTmd7mh/WcwgUjtAeOU7N8nFFlbQBnFK2gXW5fGvmMA==", + "dev": true, + "license": "MIT", "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } @@ -15866,6 +15215,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -15881,6 +15231,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "lru-cache": "^11.0.0", @@ -15897,6 +15248,7 @@ "version": "11.1.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.1.0.tgz", "integrity": "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==", + "dev": true, "license": "ISC", "engines": { "node": "20 || >=22" @@ -15906,6 +15258,7 @@ "version": "8.2.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=16" @@ -16003,6 +15356,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz", "integrity": "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=16.20.0" @@ -16075,16 +15429,6 @@ "node": ">=4" } }, - "node_modules/pkg-conf/node_modules/p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/pkg-conf/node_modules/path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -16099,6 +15443,7 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -16183,10 +15528,14 @@ } }, "node_modules/posthog-node": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/posthog-node/-/posthog-node-5.6.0.tgz", - "integrity": "sha512-MVXxKmqAYp2cPBrN1YMhnhYsJYIu6yc6wumbHz1dbo67wZBf2WtMm67Uh+4VCrp07049qierWlxQqz1W5zGDeg==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/posthog-node/-/posthog-node-5.7.0.tgz", + "integrity": "sha512-6J1AIZWtbr2lEbZOO2AzO/h1FPJjUZM4KWcdaL2UQw7FY8J7VNaH3NiaRockASFmglpID7zEY25gV/YwCtuXjg==", + "dev": true, "license": "MIT", + "dependencies": { + "@posthog/core": "1.0.0" + }, "engines": { "node": ">=20" } @@ -16267,6 +15616,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true, "license": "MIT" }, "node_modules/propagate": { @@ -16287,9 +15637,10 @@ "license": "ISC" }, "node_modules/protobufjs": { - "version": "7.5.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.5.3.tgz", - "integrity": "sha512-sildjKwVqOI2kmFDiXQ6aEB0fjYTafpEvIBs8tOR8qI4spuL9OPROLVu2qZqi/xgCfsHIwVqlaF8JBjWFHnKbw==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.5.4.tgz", + "integrity": "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==", + "dev": true, "hasInstallScript": true, "license": "BSD-3-Clause", "dependencies": { @@ -16314,6 +15665,7 @@ "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dev": true, "license": "MIT", "dependencies": { "forwarded": "0.2.0", @@ -16327,6 +15679,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -16336,6 +15689,7 @@ "version": "1.3.6", "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz", "integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==", + "dev": true, "license": "MIT", "dependencies": { "tslib": "^2.8.1" @@ -16345,6 +15699,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.3.tgz", "integrity": "sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=6.0.0" @@ -16354,6 +15709,7 @@ "version": "6.14.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "side-channel": "^1.1.0" @@ -16390,6 +15746,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -16399,6 +15756,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.0.tgz", "integrity": "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==", + "dev": true, "license": "MIT", "dependencies": { "bytes": "3.1.2", @@ -16440,6 +15798,7 @@ "version": "19.1.1", "resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz", "integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -16459,14 +15818,6 @@ "react": "^19.1.1" } }, - "node_modules/react-dom/node_modules/scheduler": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz", - "integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==", - "dev": true, - "license": "MIT", - "peer": true - }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -16479,6 +15830,8 @@ "version": "0.32.0", "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.32.0.tgz", "integrity": "sha512-2NPMOzgTlG0ZWdIf3qG+dcbLSoAc/uLfOwckc3ofy5sSK0pLJqnQLpUFxvGcN2rlXSjnVtGeeFLNimCQEj5gOQ==", + "dev": true, + "license": "MIT", "dependencies": { "scheduler": "^0.26.0" }, @@ -16489,11 +15842,6 @@ "react": "^19.1.0" } }, - "node_modules/react-reconciler/node_modules/scheduler": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz", - "integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==" - }, "node_modules/read-package-up": { "version": "11.0.0", "resolved": "https://registry.npmjs.org/read-package-up/-/read-package-up-11.0.0.tgz", @@ -16512,19 +15860,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/read-package-up/node_modules/type-fest": { - "version": "4.41.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", - "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/read-pkg": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-9.0.1.tgz", @@ -16545,37 +15880,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/read-pkg/node_modules/parse-json": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-8.3.0.tgz", - "integrity": "sha512-ybiGyvspI+fAoRQbIPRddCcSTV9/LsJbf0e/S85VLowVGzRmokfneg2kwVW/KU5rOXrPSbF1qAKPMgNTqqROQQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.26.2", - "index-to-position": "^1.1.0", - "type-fest": "^4.39.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/read-pkg/node_modules/type-fest": { - "version": "4.41.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", - "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/read-pkg/node_modules/unicorn-magic": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", @@ -16593,6 +15897,7 @@ "version": "2.3.8", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, "license": "MIT", "dependencies": { "core-util-is": "~1.0.0", @@ -16608,12 +15913,14 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, "license": "MIT" }, "node_modules/readline-sync": { "version": "1.4.10", "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8.0" @@ -16680,6 +15987,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -16720,13 +16028,13 @@ } }, "node_modules/resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, "license": "MIT", "engines": { - "node": ">=8" + "node": ">=4" } }, "node_modules/resolve-pkg-maps": { @@ -16734,6 +16042,7 @@ "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", "dev": true, + "license": "MIT", "funding": { "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } @@ -16742,6 +16051,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", "integrity": "sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==", + "dev": true, + "license": "MIT", "dependencies": { "onetime": "^5.1.0", "signal-exit": "^3.0.2" @@ -16753,6 +16064,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/restore-cursor/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, "node_modules/reusify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", @@ -16765,9 +16083,9 @@ } }, "node_modules/rollup": { - "version": "4.46.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.46.2.tgz", - "integrity": "sha512-WMmLFI+Boh6xbop+OAGo9cQ3OgX9MIg7xOQjn+pTCwOkk+FNDAeAemXkJ3HzDJrVXleLOFVa1ipuc1AmEx1Dwg==", + "version": "4.47.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.47.1.tgz", + "integrity": "sha512-iasGAQoZ5dWDzULEUX3jiW0oB1qyFOepSyDyoU6S/OhVlDIwj5knI5QBa5RRQ0sK7OE0v+8VIi2JuV+G+3tfNg==", "dev": true, "license": "MIT", "dependencies": { @@ -16781,26 +16099,26 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.46.2", - "@rollup/rollup-android-arm64": "4.46.2", - "@rollup/rollup-darwin-arm64": "4.46.2", - "@rollup/rollup-darwin-x64": "4.46.2", - "@rollup/rollup-freebsd-arm64": "4.46.2", - "@rollup/rollup-freebsd-x64": "4.46.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.46.2", - "@rollup/rollup-linux-arm-musleabihf": "4.46.2", - "@rollup/rollup-linux-arm64-gnu": "4.46.2", - "@rollup/rollup-linux-arm64-musl": "4.46.2", - "@rollup/rollup-linux-loongarch64-gnu": "4.46.2", - "@rollup/rollup-linux-ppc64-gnu": "4.46.2", - "@rollup/rollup-linux-riscv64-gnu": "4.46.2", - "@rollup/rollup-linux-riscv64-musl": "4.46.2", - "@rollup/rollup-linux-s390x-gnu": "4.46.2", - "@rollup/rollup-linux-x64-gnu": "4.46.2", - "@rollup/rollup-linux-x64-musl": "4.46.2", - "@rollup/rollup-win32-arm64-msvc": "4.46.2", - "@rollup/rollup-win32-ia32-msvc": "4.46.2", - "@rollup/rollup-win32-x64-msvc": "4.46.2", + "@rollup/rollup-android-arm-eabi": "4.47.1", + "@rollup/rollup-android-arm64": "4.47.1", + "@rollup/rollup-darwin-arm64": "4.47.1", + "@rollup/rollup-darwin-x64": "4.47.1", + "@rollup/rollup-freebsd-arm64": "4.47.1", + "@rollup/rollup-freebsd-x64": "4.47.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.47.1", + "@rollup/rollup-linux-arm-musleabihf": "4.47.1", + "@rollup/rollup-linux-arm64-gnu": "4.47.1", + "@rollup/rollup-linux-arm64-musl": "4.47.1", + "@rollup/rollup-linux-loongarch64-gnu": "4.47.1", + "@rollup/rollup-linux-ppc64-gnu": "4.47.1", + "@rollup/rollup-linux-riscv64-gnu": "4.47.1", + "@rollup/rollup-linux-riscv64-musl": "4.47.1", + "@rollup/rollup-linux-s390x-gnu": "4.47.1", + "@rollup/rollup-linux-x64-gnu": "4.47.1", + "@rollup/rollup-linux-x64-musl": "4.47.1", + "@rollup/rollup-win32-arm64-msvc": "4.47.1", + "@rollup/rollup-win32-ia32-msvc": "4.47.1", + "@rollup/rollup-win32-x64-msvc": "4.47.1", "fsevents": "~2.3.2" } }, @@ -16808,6 +16126,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "dev": true, "license": "MIT", "dependencies": { "debug": "^4.4.0", @@ -16831,6 +16150,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.0.0.tgz", "integrity": "sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -16894,6 +16214,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, "funding": [ { "type": "github", @@ -16956,6 +16277,7 @@ "version": "2.5.0", "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -16965,6 +16287,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, "license": "MIT" }, "node_modules/saxes": { @@ -16981,12 +16304,11 @@ } }, "node_modules/scheduler": { - "version": "0.23.2", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", - "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", - "dependencies": { - "loose-envify": "^1.1.0" - } + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz", + "integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==", + "dev": true, + "license": "MIT" }, "node_modules/semantic-release": { "version": "24.2.7", @@ -17088,6 +16410,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/semantic-release/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/semantic-release/node_modules/hosted-git-info": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-8.1.0.tgz", @@ -17101,12 +16436,18 @@ "node": "^18.17.0 || >=20.5.0" } }, - "node_modules/semantic-release/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "node_modules/semantic-release/node_modules/indent-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", "dev": true, - "license": "ISC" + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/semantic-release/node_modules/p-reduce": { "version": "3.0.0", @@ -17121,6 +16462,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/semantic-release/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/semver": { "version": "7.7.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", @@ -17166,6 +16517,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "dev": true, "license": "MIT", "dependencies": { "debug": "^4.3.5", @@ -17188,6 +16540,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "dev": true, "license": "MIT", "dependencies": { "encodeurl": "^2.0.0", @@ -17252,18 +16605,21 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "dev": true, "license": "MIT" }, "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true, "license": "ISC" }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -17276,6 +16632,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -17285,6 +16642,7 @@ "version": "1.8.3", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz", "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -17303,6 +16661,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -17322,6 +16681,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -17338,6 +16698,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, "license": "MIT", "dependencies": { "call-bound": "^1.0.2", @@ -17356,6 +16717,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, "license": "MIT", "dependencies": { "call-bound": "^1.0.2", @@ -17379,10 +16741,17 @@ "license": "ISC" }, "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "license": "ISC" + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } }, "node_modules/signale": { "version": "1.4.0", @@ -17427,23 +16796,6 @@ "node": ">=4" } }, - "node_modules/signale/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/signale/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true, - "license": "MIT" - }, "node_modules/signale/node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -17494,17 +16846,12 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "dev": true, "license": "MIT", "dependencies": { "is-arrayish": "^0.3.1" } }, - "node_modules/simple-swizzle/node_modules/is-arrayish": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", - "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", - "license": "MIT" - }, "node_modules/sirv": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.1.tgz", @@ -17533,10 +16880,25 @@ "node": ">=8" } }, + "node_modules/slash": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", + "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/slice-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-7.1.0.tgz", "integrity": "sha512-bSiSngZ/jWeX93BqeIAbImyTbEihizcwNjFoRUIY/T1wWQsfsm2Vw1agPKylXvQTU7iASGdHhyqRlqQzfz+Htg==", + "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^6.2.1", "is-fullwidth-code-point": "^5.0.0" @@ -17548,31 +16910,6 @@ "url": "https://github.com/chalk/slice-ansi?sponsor=1" } }, - "node_modules/slice-ansi/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/slice-ansi/node_modules/is-fullwidth-code-point": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-5.0.0.tgz", - "integrity": "sha512-OVa3u9kkBbw7b8Xw5F9P+D/T9X+Z4+JruYVNapTjPYZYUznQ5YfWeFkOj606XYYW8yugTfC8Pj0hYqvi4ryAhA==", - "dependencies": { - "get-east-asian-width": "^1.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -17630,9 +16967,9 @@ } }, "node_modules/spdx-license-ids": { - "version": "3.0.21", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.21.tgz", - "integrity": "sha512-Bvg/8F5XephndSK3JffaRqdT+gyhfqIPwDHpX80tJrF8QQRYMo8sNMeaZ2Dp5+jhwKnUmIOyFFQfHRkjJm5nXg==", + "version": "3.0.22", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.22.tgz", + "integrity": "sha512-4PRT4nh1EImPbt2jASOKHX7PB7I+e4IWNLvkKFDxNhJlfjbYlleYQh285Z/3mPTHSAK/AvdMmw5BNNuYH8ShgQ==", "dev": true, "license": "CC0-1.0" }, @@ -17660,6 +16997,7 @@ "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "dev": true, "license": "MIT", "engines": { "node": "*" @@ -17669,6 +17007,7 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, "license": "MIT", "dependencies": { "escape-string-regexp": "^2.0.0" @@ -17677,6 +17016,16 @@ "node": ">=10" } }, + "node_modules/stack-utils/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/stackback": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", @@ -17685,9 +17034,10 @@ "license": "MIT" }, "node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" @@ -17736,6 +17086,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, "license": "MIT", "dependencies": { "safe-buffer": "~5.1.0" @@ -17745,12 +17096,33 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, "license": "MIT" }, "node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", @@ -17761,16 +17133,31 @@ "node": ">=8" } }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/string-width-cjs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, "license": "MIT", "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" + "ansi-regex": "^5.0.1" }, "engines": { "node": ">=8" @@ -17836,9 +17223,27 @@ } }, "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" @@ -17847,17 +17252,17 @@ "node": ">=8" } }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "node_modules/strip-ansi/node_modules/ansi-regex": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", + "dev": true, "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/strip-bom": { @@ -17916,17 +17321,6 @@ "dev": true, "license": "MIT" }, - "node_modules/strnum": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.1.1.tgz", - "integrity": "sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/NaturalIntelligence" - } - ] - }, "node_modules/super-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/super-regex/-/super-regex-1.0.0.tgz", @@ -17945,21 +17339,21 @@ } }, "node_modules/superagent": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-10.2.2.tgz", - "integrity": "sha512-vWMq11OwWCC84pQaFPzF/VO3BrjkCeewuvJgt1jfV0499Z1QSAWN4EqfMM5WlFDDX9/oP8JjlDKpblrmEoyu4Q==", + "version": "10.2.3", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-10.2.3.tgz", + "integrity": "sha512-y/hkYGeXAj7wUMjxRbB21g/l6aAEituGXM9Rwl4o20+SX3e8YOSV6BxFXl+dL3Uk0mjSL3kCbNkwURm8/gEDig==", "dev": true, "license": "MIT", "dependencies": { - "component-emitter": "^1.3.0", + "component-emitter": "^1.3.1", "cookiejar": "^2.1.4", - "debug": "^4.3.4", + "debug": "^4.3.7", "fast-safe-stringify": "^2.1.1", - "form-data": "^4.0.0", + "form-data": "^4.0.4", "formidable": "^3.5.4", "methods": "^1.1.2", "mime": "2.6.0", - "qs": "^6.11.0" + "qs": "^6.11.2" }, "engines": { "node": ">=14.18.0" @@ -17979,14 +17373,14 @@ } }, "node_modules/supertest": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.1.3.tgz", - "integrity": "sha512-ORY0gPa6ojmg/C74P/bDoS21WL6FMXq5I8mawkEz30/zkwdu0gOeqstFy316vHG6OKxqQ+IbGneRemHI8WraEw==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.1.4.tgz", + "integrity": "sha512-tjLPs7dVyqgItVFirHYqe2T+MfWc2VOBQ8QFKKbWTA3PU7liZR8zoSpAi/C1k1ilm9RsXIKYf197oap9wXGVYg==", "dev": true, "license": "MIT", "dependencies": { "methods": "^1.1.2", - "superagent": "^10.2.2" + "superagent": "^10.2.3" }, "engines": { "node": ">=14.18.0" @@ -18035,9 +17429,10 @@ } }, "node_modules/swr": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/swr/-/swr-2.3.4.tgz", - "integrity": "sha512-bYd2lrhc+VarcpkgWclcUi92wYCpOgMws9Sd1hG1ntAu0NEy+14CbotuFjshBU2kt9rYj9TSmDcybpxpeTU1fg==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/swr/-/swr-2.3.6.tgz", + "integrity": "sha512-wfHRmHWk/isGNMwlLGlZX5Gzz/uTgo0o2IRuTMcf4CPuPFJZlq0rDaKUx+ozB5nBOReNV1kiOyzMfj+MBMikLw==", + "dev": true, "license": "MIT", "dependencies": { "dequal": "^2.0.3", @@ -18113,6 +17508,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==", + "dev": true, "license": "MIT" }, "node_modules/thenify": { @@ -18176,6 +17572,7 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz", "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==", + "dev": true, "license": "MIT" }, "node_modules/tinyexec": { @@ -18203,11 +17600,14 @@ } }, "node_modules/tinyglobby/node_modules/fdir": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", - "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", "dev": true, "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, "peerDependencies": { "picomatch": "^3 || ^4" }, @@ -18234,6 +17634,7 @@ "version": "1.1.5", "resolved": "https://registry.npmjs.org/tinygradient/-/tinygradient-1.1.5.tgz", "integrity": "sha512-8nIfc2vgQ4TeLnk2lFj4tRLvvJwEfQuabdsmvDdQPT0xlk9TaNtpGd6nNRxXoK6vQhN6RSzj+Cnp5tTQmpxmbw==", + "dev": true, "license": "MIT", "dependencies": { "@types/tinycolor2": "^1.4.0", @@ -18307,6 +17708,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.6" @@ -18336,10 +17738,17 @@ } }, "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } }, "node_modules/traverse": { "version": "0.6.8", @@ -18358,6 +17767,7 @@ "version": "1.4.1", "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", "integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 14.0.0" @@ -18447,13 +17857,15 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, "license": "0BSD" }, "node_modules/tsx": { - "version": "4.20.3", - "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.3.tgz", - "integrity": "sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==", + "version": "4.20.4", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.4.tgz", + "integrity": "sha512-yyxBKfORQ7LuRt/BQKBXrpcq59ZvSW0XxwfjAt3w2/8PmdxaFzijtMhTawprSHhpzeM5BgU2hXHG3lklIERZXg==", "dev": true, + "license": "MIT", "dependencies": { "esbuild": "~0.25.0", "get-tsconfig": "^4.7.5" @@ -18469,9 +17881,10 @@ } }, "node_modules/turndown": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.0.tgz", - "integrity": "sha512-eCZGBN4nNNqM9Owkv9HAtWRYfLA4h909E/WGAWWBpmB275ehNhZyk87/Tpvjbp0jjNl9XwCsbe6bm6CqFsgD+A==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.1.tgz", + "integrity": "sha512-7YiPJw6rLClQL3oUKN3KgMaXeJJ2lAyZItclgKDurqnH61so4k4IH/qwmMva0zpuJc/FhRExBBnk7EbeFANlgQ==", + "dev": true, "license": "MIT", "dependencies": { "@mixmark-io/domino": "^2.2.0" @@ -18490,10 +17903,24 @@ "node": ">= 0.8.0" } }, + "node_modules/type-fest": { + "version": "4.41.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", + "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/type-is": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "dev": true, "license": "MIT", "dependencies": { "content-type": "^1.0.5", @@ -18583,9 +18010,10 @@ } }, "node_modules/typescript": { - "version": "5.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", - "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "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", @@ -18629,9 +18057,9 @@ } }, "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz", + "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==", "license": "MIT" }, "node_modules/unicode-emoji-modifier-base": { @@ -18694,6 +18122,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" @@ -18738,6 +18167,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" @@ -18757,6 +18187,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz", "integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==", + "dev": true, "license": "MIT", "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" @@ -18766,12 +18197,14 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, "license": "MIT" }, "node_modules/uuid": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true, "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" @@ -18803,30 +18236,31 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8" } }, "node_modules/vite": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.0.6.tgz", - "integrity": "sha512-MHFiOENNBd+Bd9uvc8GEsIzdkn1JxMmEeYX35tI3fv0sJBUTfW5tQsoaOwuY4KhBI09A3dUJ/DXf2yxPVPUceg==", + "version": "6.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz", + "integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==", "dev": true, "license": "MIT", "dependencies": { "esbuild": "^0.25.0", - "fdir": "^6.4.6", - "picomatch": "^4.0.3", - "postcss": "^8.5.6", - "rollup": "^4.40.0", - "tinyglobby": "^0.2.14" + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" }, "bin": { "vite": "bin/vite.js" }, "engines": { - "node": "^20.19.0 || >=22.12.0" + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" }, "funding": { "url": "https://github.com/vitejs/vite?sponsor=1" @@ -18835,14 +18269,14 @@ "fsevents": "~2.3.3" }, "peerDependencies": { - "@types/node": "^20.19.0 || >=22.12.0", + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "jiti": ">=1.21.0", - "less": "^4.0.0", + "less": "*", "lightningcss": "^1.21.0", - "sass": "^1.70.0", - "sass-embedded": "^1.70.0", - "stylus": ">=0.54.8", - "sugarss": "^5.0.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" @@ -18907,11 +18341,14 @@ } }, "node_modules/vite/node_modules/fdir": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", - "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", "dev": true, "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, "peerDependencies": { "picomatch": "^3 || ^4" }, @@ -19037,6 +18474,8 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "dev": true, + "license": "MIT", "engines": { "node": ">= 8" } @@ -19045,6 +18484,7 @@ "version": "1.8.1", "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.8.1.tgz", "integrity": "sha512-P+x1MvlNCXlKbLSOY4cYrdreqPG5hbzkmawbcXLKN/mf6DZW0SdNNkZ+sjwsqVkI4A4Ko2sPZmkZtCKY58w83A==", + "dev": true, "license": "MIT", "dependencies": { "@peculiar/asn1-schema": "^2.3.13", @@ -19055,10 +18495,14 @@ } }, "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==", - "license": "BSD-2-Clause" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } }, "node_modules/whatwg-encoding": { "version": "3.1.1", @@ -19074,29 +18518,34 @@ } }, "node_modules/whatwg-mimetype": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", - "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", + "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", "dev": true, "license": "MIT", "engines": { - "node": ">=18" + "node": ">=12" } }, "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==", + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", + "dev": true, "license": "MIT", "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" + "tr46": "^5.1.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" } }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" @@ -19225,6 +18674,8 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-5.0.0.tgz", "integrity": "sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA==", + "dev": true, + "license": "MIT", "dependencies": { "string-width": "^7.0.0" }, @@ -19235,56 +18686,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/widest-line/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/widest-line/node_modules/emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==" - }, - "node_modules/widest-line/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/widest-line/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/winston": { "version": "3.17.0", "resolved": "https://registry.npmjs.org/winston/-/winston-3.17.0.tgz", "integrity": "sha512-DLiFIXYC5fMPxaRg832S6F5mJYvePtmO5G9v9IgUFPhXm9/GkXarH/TUrBAVzhTCzAj9anE/+GjrgXp/54nOgw==", + "dev": true, "license": "MIT", "dependencies": { "@colors/colors": "^1.6.0", @@ -19307,6 +18713,7 @@ "version": "4.9.0", "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.9.0.tgz", "integrity": "sha512-8drMJ4rkgaPo1Me4zD/3WLfI/zPdA9o2IipKODunnGDcuqbHwjsbB79ylv04LCGGzU0xQ6vTznOMpQGaLhhm6A==", + "dev": true, "license": "MIT", "dependencies": { "logform": "^2.7.0", @@ -19321,6 +18728,7 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, "license": "MIT", "dependencies": { "inherits": "^2.0.3", @@ -19335,6 +18743,7 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.1.90" @@ -19344,6 +18753,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -19356,6 +18766,7 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, "license": "MIT", "dependencies": { "inherits": "^2.0.3", @@ -19384,17 +18795,18 @@ "license": "MIT" }, "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", + "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==", + "dev": true, "license": "MIT", "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" }, "engines": { - "node": ">=10" + "node": ">=18" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" @@ -19405,6 +18817,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -19418,16 +18831,100 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, "license": "ISC" }, "node_modules/ws": { "version": "8.18.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "dev": true, + "license": "MIT", "engines": { "node": ">=10.0.0" }, @@ -19444,6 +18941,22 @@ } } }, + "node_modules/wsl-utils": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.1.0.tgz", + "integrity": "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-wsl": "^3.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/xml-name-validator": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", @@ -19474,15 +18987,17 @@ "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, "license": "ISC", "engines": { "node": ">=10" } }, "node_modules/yaml": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz", - "integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", + "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", + "dev": true, "license": "ISC", "bin": { "yaml": "bin.mjs" @@ -19495,6 +19010,7 @@ "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, "license": "MIT", "dependencies": { "cliui": "^8.0.1", @@ -19513,11 +19029,57 @@ "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, "license": "ISC", "engines": { "node": ">=12" } }, + "node_modules/yargs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/yargs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", @@ -19542,9 +19104,9 @@ } }, "node_modules/yoctocolors": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/yoctocolors/-/yoctocolors-2.1.1.tgz", - "integrity": "sha512-GQHQqAopRhwU8Kt1DDM8NjibDXHC8eoh1erhGAJPEyveY9qqVeXvVikNKrDz69sHowPMorbPUrH/mx8c50eiBQ==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yoctocolors/-/yoctocolors-2.1.2.tgz", + "integrity": "sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug==", "dev": true, "license": "MIT", "engines": { @@ -19557,21 +19119,25 @@ "node_modules/yoga-layout": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/yoga-layout/-/yoga-layout-3.2.1.tgz", - "integrity": "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ==" + "integrity": "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ==", + "dev": true, + "license": "MIT" }, "node_modules/zod": { - "version": "3.24.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.4.tgz", - "integrity": "sha512-OdqJE9UDRPwWsrHjLN2F8bPxvwJBK22EHLWtanu0LSYr5YqzsaaW3RMgmjwr8Rypg5k+meEJdSPXJZXE/yqOMg==", + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" } }, "node_modules/zod-to-json-schema": { - "version": "3.24.5", - "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.5.tgz", - "integrity": "sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g==", + "version": "3.24.6", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.6.tgz", + "integrity": "sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==", + "dev": true, "license": "ISC", "peerDependencies": { "zod": "^3.24.1" diff --git a/extensions/cli/package.json b/extensions/cli/package.json index 304dbe0e8..0c4182e67 100644 --- a/extensions/cli/package.json +++ b/extensions/cli/package.json @@ -6,15 +6,20 @@ "types": "dist/index.d.ts", "type": "module", "bin": { - "cn": "dist/index.js" + "cn": "dist/cn.js" }, "scripts": { "test": "vitest run", "test:watch": "vitest watch", "test:ui": "vitest --ui", "test:e2e": "vitest run --config vitest.e2e.config.ts", - "build": "tsc -p tsconfig.build.json", - "start": "node dist/index.js", + "test:smoke": "node smoke-test.mjs", + "build:tsc": "tsc -p tsconfig.build.json", + "build:local-deps": "cd ../../packages/config-types && npm i && npm run build && cd ../fetch && npm i && npm run build && cd ../llm-info && npm i && npm run build && cd ../config-yaml && npm i && npm run build && cd ../openai-adapters && npm i && npm run build && cd ../../core && npm i && cd ../extensions/cli && npm i", + "build:validate": "node validate-aliases.mjs", + "build:bundle": "node build.mjs", + "build": "npm run build:validate && npm run build:bundle", + "start": "node dist/cn.js", "dev": "tsx src/index.ts", "repomix:sdk": "npx repomix node_modules/@continuedev/sdk --ignore **/api,cli-repomix.xml -o sdk-repomix.xml", "repomix:cli": "npx repomix --ignore sdk-repomix.xml -o cli-repomix.xml", @@ -39,8 +44,11 @@ }, "homepage": "https://continue.dev", "dependencies": { - "@continuedev/config-yaml": "^1.0.96", - "@continuedev/openai-adapters": "^1.4.1", + "@sentry/profiling-node": "^9.43.0" + }, + "devDependencies": { + "@continuedev/config-yaml": "file:../../packages/config-yaml", + "@continuedev/openai-adapters": "file:../../packages/openai-adapters", "@continuedev/sdk": "^0.0.13", "@modelcontextprotocol/sdk": "^1.17.2", "@opentelemetry/api": "^1.9.0", @@ -52,13 +60,13 @@ "@opentelemetry/sdk-node": "^0.203.0", "@opentelemetry/semantic-conventions": "^1.36.0", "@sentry/node": "^9.43.0", - "@sentry/profiling-node": "^9.43.0", "@types/express": "^5.0.3", "@types/react": "^19.1.8", "@types/turndown": "^5.0.5", "@workos-inc/node": "^7.45.0", "chalk": "^5.4.1", "commander": "^14.0.0", + "core": "file:../../core", "date-fns": "^4.1.0", "diff": "^7.0.0", "dotenv": "^16.5.0", @@ -66,6 +74,7 @@ "glob": "^11.0.3", "gpt-tokenizer": "^3.0.1", "gradient-string": "^3.0.0", + "ignore": "^7.0.5", "ignore-walk": "^7.0.0", "ink": "^6.1.0", "jszip": "^3.10.1", @@ -83,9 +92,7 @@ "typescript": "^5.8.3", "uuid": "^9.0.1", "winston": "^3.17.0", - "yaml": "^2.8.0" - }, - "devDependencies": { + "yaml": "^2.8.0", "@semantic-release/changelog": "^6.0.3", "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^11.0.3", @@ -93,7 +100,6 @@ "@testing-library/react": "^16.3.0", "@types/date-fns": "^2.5.3", "@types/diff": "^7.0.2", - "@types/express": "^5.0.3", "@types/glob": "^8.1.0", "@types/ignore-walk": "^4.0.3", "@types/ink-testing-library": "^1.0.4", @@ -102,17 +108,18 @@ "@types/readline-sync": "^1.4.8", "@types/shell-quote": "^1.7.5", "@types/supertest": "^6.0.3", + "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^8.39.0", "@typescript-eslint/parser": "^8.39.0", "@vitest/ui": "^3.2.4", "conventional-changelog-conventionalcommits": "^9.1.0", "cross-env": "^7.0.3", + "esbuild": "^0.25.9", "eslint": "^9.32.0", "eslint-import-resolver-typescript": "^4.4.4", "eslint-plugin-import": "^2.32.0", "eslint-plugin-unused-imports": "^4.1.4", "execa": "^9.6.0", - "express": "^5.1.0", "happy-dom": "^18.0.1", "ink-testing-library": "^4.0.0", "jsdom": "^26.1.0", diff --git a/extensions/cli/smoke-test.mjs b/extensions/cli/smoke-test.mjs new file mode 100755 index 000000000..62e71db37 --- /dev/null +++ b/extensions/cli/smoke-test.mjs @@ -0,0 +1,230 @@ +#!/usr/bin/env node + +import { execSync } from "child_process"; +import { existsSync, readFileSync } from "fs"; +import { resolve, dirname } from "path"; +import { fileURLToPath } from "url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +// Colors for output +const colors = { + green: "\x1b[32m", + red: "\x1b[31m", + yellow: "\x1b[33m", + reset: "\x1b[0m", +}; + +let testsPassed = 0; +let testsFailed = 0; + +function runTest(name, testFn) { + process.stdout.write(`Testing ${name}... `); + try { + testFn(); + console.log(`${colors.green}✓${colors.reset}`); + testsPassed++; + } catch (error) { + console.log(`${colors.red}✗${colors.reset}`); + console.error(` Error: ${error.message}`); + testsFailed++; + } +} + +function execCommand(command, options = {}) { + return execSync(command, { + cwd: __dirname, + encoding: "utf8", + stdio: "pipe", + ...options, + }); +} + +console.log("🧪 Running smoke tests for bundled CLI...\n"); + +// Test 1: Check if bundle exists +runTest("Bundle file exists", () => { + if (!existsSync(resolve(__dirname, "dist/index.js"))) { + throw new Error("dist/index.js not found"); + } + if (!existsSync(resolve(__dirname, "dist/cn.js"))) { + throw new Error("dist/cn.js not found"); + } +}); + +// Test 2: Check if wrapper script is executable +runTest("Wrapper script has shebang", () => { + const content = readFileSync(resolve(__dirname, "dist/cn.js"), "utf8"); + if (!content.startsWith("#!/usr/bin/env node")) { + throw new Error("Wrapper script missing shebang"); + } +}); + +// Cross-platform command execution helper +function getCLICommand(args = "") { + const isWindows = process.platform === "win32"; + if (isWindows) { + return `node dist/cn.js ${args}`; + } else { + return `./dist/cn.js ${args}`; + } +} + +// Test 3: Version command works +runTest("Version command", () => { + const output = execCommand(getCLICommand("--version")); + const packageJson = JSON.parse( + readFileSync(resolve(__dirname, "package.json"), "utf8"), + ); + if (!output.includes(packageJson.version)) { + throw new Error( + `Version mismatch. Expected ${packageJson.version}, got: ${output}`, + ); + } +}); + +// Test 4: Help command works +runTest("Help command", () => { + const output = execCommand(getCLICommand("--help")); + if (!output.includes("Continue CLI") || !output.includes("--version")) { + throw new Error("Help output missing expected content"); + } +}); + +// Test 5: Check bundle size +runTest("Bundle size is reasonable", () => { + const isWindows = process.platform === "win32"; + const command = isWindows + ? `powershell -Command "(Get-Item dist/index.js).length / 1MB"` + : `ls -lh dist/index.js`; + + let sizeInMB; + + if (isWindows) { + try { + const output = execCommand(command); + sizeInMB = parseFloat(output.trim()); + } catch { + // Fallback for Windows if PowerShell fails + const stats = readFileSync(resolve(__dirname, "dist/index.js")); + sizeInMB = stats.length / (1024 * 1024); + } + } else { + const stats = execCommand(command); + const sizeMatch = stats.match(/(\d+(?:\.\d+)?[MK])/); + if (sizeMatch) { + const size = sizeMatch[1]; + const numSize = parseFloat(size); + const unit = size.slice(-1); + sizeInMB = unit === "M" ? numSize : numSize / 1024; + } + } + + console.log(`(${sizeInMB.toFixed(1)}M)`); + + // This is arbitrary. We might go over at some point, + // in which case you can just increase this. + if (sizeInMB > 20) { + throw new Error(`Bundle too large: ${sizeInMB.toFixed(1)}M`); + } +}); + +// Test 6: Check that local packages are bundled +runTest("Local packages are bundled", () => { + const bundleContent = readFileSync( + resolve(__dirname, "dist/index.js"), + "utf8", + ); + + // Check for code from @continuedev/config-yaml + if ( + !bundleContent.includes("AssistantUnrolled") && + !bundleContent.includes("config-yaml") + ) { + throw new Error("@continuedev/config-yaml not properly bundled"); + } + + // Check for code from @continuedev/openai-adapters + // Since the bundle is minified, check for strings that would be present + // even after minification (e.g., error messages, property names) + if ( + !bundleContent.includes("anthropic") && + !bundleContent.includes("gemini") && + !bundleContent.includes("openai") && + !bundleContent.includes("azure") && + !bundleContent.includes("bedrock") + ) { + throw new Error("@continuedev/openai-adapters not properly bundled"); + } +}); + +// Test 7: Test that the CLI can be invoked programmatically +runTest("CLI can be invoked", () => { + try { + // Test that the CLI runs without crashing when given no args + const isWindows = process.platform === "win32"; + const nullDevice = isWindows ? "nul" : "/dev/null"; + execCommand(`${getCLICommand("--help")} > ${nullDevice} 2>&1`); + } catch (error) { + throw new Error(`CLI invocation failed: ${error.message}`); + } +}); + +// Test 8: Check metadata file +runTest("Build metadata exists", () => { + if (!existsSync(resolve(__dirname, "dist/meta.json"))) { + throw new Error("dist/meta.json not found"); + } + + const meta = JSON.parse( + readFileSync(resolve(__dirname, "dist/meta.json"), "utf8"), + ); + if (!meta.inputs || !meta.outputs) { + throw new Error("Invalid metadata structure"); + } +}); + +// Test 9: Verify no missing external dependencies +runTest("No missing runtime dependencies", () => { + // This would fail in Test 3 if dependencies were missing, but let's be explicit + const output = execCommand(`${getCLICommand("--version")} 2>&1`, { + env: { ...process.env, NODE_ENV: "production" }, + }); + + if ( + output.includes("Cannot find module") || + output.includes("MODULE_NOT_FOUND") + ) { + throw new Error("Missing module detected in output"); + } +}); + +// Test 10: Test npm link scenario +runTest("CLI works via npm link", () => { + try { + // Simply test that we can execute with node directly + const output = execCommand("node dist/cn.js --version 2>&1"); + const packageJson = JSON.parse( + readFileSync(resolve(__dirname, "package.json"), "utf8"), + ); + if (!output.includes(packageJson.version)) { + throw new Error("Version not found when running via node"); + } + } catch (error) { + throw new Error(`npm link scenario failed: ${error.message}`); + } +}); + +// Summary +console.log("\n" + "=".repeat(50)); +if (testsFailed === 0) { + console.log( + `${colors.green}✅ All ${testsPassed} tests passed!${colors.reset}`, + ); + process.exit(0); +} else { + console.log( + `${colors.red}❌ ${testsFailed} test(s) failed, ${testsPassed} passed${colors.reset}`, + ); + process.exit(1); +} diff --git a/extensions/cli/src/__mocks__/args.ts b/extensions/cli/src/__mocks__/args.ts index b0d25ffad..f982bdd09 100644 --- a/extensions/cli/src/__mocks__/args.ts +++ b/extensions/cli/src/__mocks__/args.ts @@ -1,3 +1,5 @@ import { vi } from "vitest"; -export const processRule = vi.fn<(rule: string) => Promise>(); +export const processPromptOrRule = vi.fn<(spec: string) => Promise>(); + +export const processPrompt = vi.fn<(prompt: string) => Promise>(); diff --git a/extensions/cli/src/args-mcp.test.ts b/extensions/cli/src/args-mcp.test.ts new file mode 100644 index 000000000..95f77cc7d --- /dev/null +++ b/extensions/cli/src/args-mcp.test.ts @@ -0,0 +1,75 @@ +import { beforeEach, describe, expect, it } from "vitest"; + +import { parseArgs } from "./args.js"; + +describe("parseArgs --mcp flag", () => { + beforeEach(() => { + // Clear process.argv before each test + process.argv = ["node", "test"]; + }); + + it("should parse single MCP from --mcp flag", () => { + process.argv = ["node", "test", "--mcp", "my-org/my-mcp"]; + const result = parseArgs(); + expect(result.mcps).toEqual(["my-org/my-mcp"]); + }); + + it("should parse multiple MCPs from multiple --mcp flags", () => { + process.argv = ["node", "test", "--mcp", "org1/mcp1", "--mcp", "org2/mcp2"]; + const result = parseArgs(); + expect(result.mcps).toEqual(["org1/mcp1", "org2/mcp2"]); + }); + + it("should handle MCP flag with other flags", () => { + process.argv = [ + "node", + "test", + "--config", + "my-config.yaml", + "--mcp", + "my-org/my-mcp", + "--org", + "test-org", + ]; + const result = parseArgs(); + expect(result.configPath).toBe("my-config.yaml"); + expect(result.mcps).toEqual(["my-org/my-mcp"]); + expect(result.organizationSlug).toBe("test-org"); + }); + + it("should handle MCP flag with prompt", () => { + process.argv = ["node", "test", "--mcp", "my-org/my-mcp", "hello world"]; + const result = parseArgs(); + expect(result.mcps).toEqual(["my-org/my-mcp"]); + expect(result.prompt).toBe("hello world"); + }); + + it("should ignore MCP and rule flag values when extracting prompt", () => { + process.argv = [ + "node", + "test", + "actual prompt", + "--rule", + "my-rule", + "--mcp", + "my-org/my-mcp", + ]; + const result = parseArgs(); + expect(result.prompt).toBe("actual prompt"); + expect(result.rules).toEqual(["my-rule"]); + expect(result.mcps).toEqual(["my-org/my-mcp"]); + }); + + it("should handle MCP flag without value", () => { + process.argv = ["node", "test", "--mcp"]; + const result = parseArgs(); + expect(result.mcps).toEqual([]); + }); + + it("should handle MCP flag at the end without value", () => { + process.argv = ["node", "test", "my prompt", "--mcp"]; + const result = parseArgs(); + expect(result.prompt).toBe("my prompt"); + expect(result.mcps).toEqual([]); + }); +}); diff --git a/extensions/cli/src/args.prompt.test.ts b/extensions/cli/src/args.prompt.test.ts new file mode 100644 index 000000000..46b70b4db --- /dev/null +++ b/extensions/cli/src/args.prompt.test.ts @@ -0,0 +1,84 @@ +import { describe, it, expect, beforeEach, afterAll } from "vitest"; + +import { parseArgs, processPromptOrRule } from "./args.js"; + +describe("args --prompt flag", () => { + const originalArgv = process.argv; + + beforeEach(() => { + // Reset process.argv for each test + process.argv = ["node", "script.js"]; + }); + + afterAll(() => { + // Restore original process.argv after all tests + process.argv = originalArgv; + }); + + it("should parse single prompt from --prompt flag", () => { + process.argv = ["node", "script.js", "--prompt", "my-prompt"]; + const result = parseArgs(); + expect(result.prompts).toEqual(["my-prompt"]); + }); + + it("should parse multiple prompts from multiple --prompt flags", () => { + process.argv = [ + "node", + "script.js", + "--prompt", + "prompt1", + "--prompt", + "prompt2", + ]; + const result = parseArgs(); + expect(result.prompts).toEqual(["prompt1", "prompt2"]); + }); + + it("should handle mixed flags including --prompt", () => { + process.argv = [ + "node", + "script.js", + "--config", + "myconfig", + "--prompt", + "myprompt", + "--resume", + ]; + const result = parseArgs(); + expect(result.configPath).toBe("myconfig"); + expect(result.prompts).toEqual(["myprompt"]); + expect(result.resume).toBe(true); + }); + + it("should not include --prompt value in non-flag arguments", () => { + process.argv = [ + "node", + "script.js", + "--prompt", + "prompt-value", + "actual-prompt", + ]; + const result = parseArgs(); + expect(result.prompts).toEqual(["prompt-value"]); + expect(result.prompt).toBe("actual-prompt"); + }); + + it("should handle both --rule and --prompt flags", () => { + process.argv = [ + "node", + "script.js", + "--rule", + "my-rule", + "--prompt", + "my-prompt", + ]; + const result = parseArgs(); + expect(result.rules).toEqual(["my-rule"]); + expect(result.prompts).toEqual(["my-prompt"]); + }); + + it("should process direct string content", async () => { + const result = await processPromptOrRule("This is a direct prompt"); + expect(result).toBe("This is a direct prompt"); + }); +}); diff --git a/extensions/cli/src/args.test.ts b/extensions/cli/src/args.test.ts index 3db340f73..d22333c05 100644 --- a/extensions/cli/src/args.test.ts +++ b/extensions/cli/src/args.test.ts @@ -1,6 +1,6 @@ import { vi } from "vitest"; -import { parseArgs, processRule } from "./args.js"; +import { parseArgs, processPromptOrRule } from "./args.js"; describe("parseArgs", () => { const originalArgv = process.argv; @@ -217,7 +217,7 @@ describe("parseArgs", () => { }); }); -describe("processRule (loadRuleFromHub integration)", () => { +describe("processPromptOrRule (loadRuleFromHub integration)", () => { // Mock fetch for hub tests const originalFetch = global.fetch; const mockFetch = vi.fn() as any; @@ -251,7 +251,7 @@ describe("processRule (loadRuleFromHub integration)", () => { arrayBuffer: () => Promise.resolve(zipBuffer), } as Response); - const result = await processRule("continuedev/sentry-nextjs"); + const result = await processPromptOrRule("continuedev/sentry-nextjs"); expect(result).toBe(ruleContent); expect(mockFetch).toHaveBeenCalledWith( @@ -269,7 +269,9 @@ describe("processRule (loadRuleFromHub integration)", () => { statusText: "Not Found", } as Response); - await expect(processRule("continuedev/nonexistent-rule")).rejects.toThrow( + await expect( + processPromptOrRule("continuedev/nonexistent-rule"), + ).rejects.toThrow( 'Failed to load rule from hub "continuedev/nonexistent-rule": HTTP 404: Not Found', ); }); @@ -277,7 +279,9 @@ describe("processRule (loadRuleFromHub integration)", () => { it("should handle network errors when loading from hub", async () => { mockFetch.mockRejectedValue(new Error("Network error")); - await expect(processRule("continuedev/sentry-nextjs")).rejects.toThrow( + await expect( + processPromptOrRule("continuedev/sentry-nextjs"), + ).rejects.toThrow( 'Failed to load rule from hub "continuedev/sentry-nextjs": Network error', ); }); @@ -285,7 +289,9 @@ describe("processRule (loadRuleFromHub integration)", () => { it("should handle invalid slug format", async () => { // "invalid-slug" doesn't contain "/" so it's treated as direct content, not a hub slug // Let's test with a slug that has wrong format but contains "/" - await expect(processRule("invalid/slug/too/many/parts")).rejects.toThrow( + await expect( + processPromptOrRule("invalid/slug/too/many/parts"), + ).rejects.toThrow( 'Invalid hub slug format. Expected "owner/package", got: invalid/slug/too/many/parts', ); }); @@ -300,7 +306,9 @@ describe("processRule (loadRuleFromHub integration)", () => { arrayBuffer: () => Promise.resolve(zipBuffer), } as Response); - await expect(processRule("continuedev/empty-rule")).rejects.toThrow( + await expect( + processPromptOrRule("continuedev/empty-rule"), + ).rejects.toThrow( 'Failed to load rule from hub "continuedev/empty-rule": No rule content found in downloaded zip file', ); }); @@ -316,7 +324,9 @@ describe("processRule (loadRuleFromHub integration)", () => { arrayBuffer: () => Promise.resolve(zipBuffer), } as Response); - await expect(processRule("continuedev/directory-only")).rejects.toThrow( + await expect( + processPromptOrRule("continuedev/directory-only"), + ).rejects.toThrow( 'Failed to load rule from hub "continuedev/directory-only": No rule content found in downloaded zip file', ); }); @@ -338,7 +348,7 @@ describe("processRule (loadRuleFromHub integration)", () => { arrayBuffer: () => Promise.resolve(zipBuffer), } as Response); - const result = await processRule("continuedev/mixed-files"); + const result = await processPromptOrRule("continuedev/mixed-files"); expect(result).toBe(mdContent); }); @@ -359,7 +369,7 @@ describe("processRule (loadRuleFromHub integration)", () => { arrayBuffer: () => Promise.resolve(zipBuffer), } as Response); - const result = await processRule("continuedev/multiple-rules"); + const result = await processPromptOrRule("continuedev/multiple-rules"); // Should use the first markdown file found (alphabetically) expect(result).toBe(rule1Content); @@ -373,13 +383,15 @@ describe("processRule (loadRuleFromHub integration)", () => { arrayBuffer: () => Promise.resolve(invalidZipBuffer), } as Response); - await expect(processRule("continuedev/corrupted-zip")).rejects.toThrow( + await expect( + processPromptOrRule("continuedev/corrupted-zip"), + ).rejects.toThrow( 'Failed to load rule from hub "continuedev/corrupted-zip"', ); }); }); - describe("processRule logic", () => { + describe("processPromptOrRule logic", () => { it("should identify hub slugs correctly", async () => { const JSZip = (await import("jszip")).default; const zip = new JSZip(); @@ -391,14 +403,14 @@ describe("processRule (loadRuleFromHub integration)", () => { arrayBuffer: () => Promise.resolve(zipBuffer), } as Response); - const result = await processRule("owner/package"); + const result = await processPromptOrRule("owner/package"); expect(result).toBe("# Hub Rule"); expect(mockFetch).toHaveBeenCalled(); }); it("should treat direct strings as content", async () => { const directContent = "This is direct rule content"; - const result = await processRule(directContent); + const result = await processPromptOrRule(directContent); expect(result).toBe(directContent); expect(mockFetch).not.toHaveBeenCalled(); }); @@ -406,7 +418,7 @@ describe("processRule (loadRuleFromHub integration)", () => { it("should distinguish between hub slugs and file paths", async () => { // This would be treated as a file path, not a hub slug // since it starts with "." - await expect(processRule("./owner/package")).rejects.toThrow( + await expect(processPromptOrRule("./owner/package")).rejects.toThrow( 'Failed to read rule file "./owner/package": Rule file not found', ); expect(mockFetch).not.toHaveBeenCalled(); diff --git a/extensions/cli/src/args.ts b/extensions/cli/src/args.ts index 1d46ee40f..fca0c86e5 100644 --- a/extensions/cli/src/args.ts +++ b/extensions/cli/src/args.ts @@ -1,10 +1,3 @@ -import * as fs from "fs"; -import * as path from "path"; - -import JSZip from "jszip"; - -import { env } from "./env.js"; - export interface CommandLineArgs { configPath?: string; organizationSlug?: string; // Organization slug to use for this session @@ -12,102 +5,53 @@ export interface CommandLineArgs { resume?: boolean; // Resume from last session readonly?: boolean; // Start in plan mode (backward compatibility) rules?: string[]; // Array of rule specifications + mcps?: string[]; // Array of MCP server slugs from the hub + models?: string[]; // Array of model slugs from the hub + prompts?: string[]; // Array of prompt slugs from the hub format?: "json"; // Output format for headless mode } +// Re-export hub loader functions for backward compatibility +export { loadMcpFromHub, processRule } from "./hubLoader.js"; +// Alias processRule as processPromptOrRule for backward compatibility +export { processRule as processPromptOrRule } from "./hubLoader.js"; + /** - * Load rule content from a file path - * @param filePath - Path to the rule file - * @returns The content of the rule file + * Extract values for a specific flag that can appear multiple times */ -function loadRuleFromFile(filePath: string): string { - try { - const absolutePath = path.resolve(filePath); - if (!fs.existsSync(absolutePath)) { - throw new Error(`Rule file not found: ${filePath}`); +function extractMultipleFlags(args: string[], flagName: string): string[] { + const indices: number[] = []; + for (let i = 0; i < args.length; i++) { + if (args[i] === flagName) { + indices.push(i); } - return fs.readFileSync(absolutePath, "utf-8"); - } catch (error: any) { - throw new Error(`Failed to read rule file "${filePath}": ${error.message}`); } + + const values: string[] = []; + for (const index of indices) { + if (index + 1 < args.length && !args[index + 1].startsWith("--")) { + values.push(args[index + 1]); + } + } + return values; } /** - * Load rule content from hub.continue.dev - * @param slug - The slug in format "owner/package" - * @returns The rule content from the hub + * Extract value for a single-value flag */ -async function loadRuleFromHub(slug: string): Promise { - const parts = slug.split("/"); - if (parts.length !== 2) { - throw new Error( - `Invalid hub slug format. Expected "owner/package", got: ${slug}`, - ); - } - - const [ownerSlug, ruleSlug] = parts; - const downloadUrl = new URL( - `v0/${ownerSlug}/${ruleSlug}/latest/download`, - env.apiBase, - ); - - try { - const response = await fetch(downloadUrl); - - if (!response.ok) { - throw new Error(`HTTP ${response.status}: ${response.statusText}`); - } - - // The API returns a zip file, so we need to extract the rule content - const arrayBuffer = await response.arrayBuffer(); - const zip = new JSZip(); - const zipContents = await zip.loadAsync(arrayBuffer); - - // Find the first .md or .txt file (rule content) - const ruleFiles = Object.keys(zipContents.files).filter( - (filename) => - filename.endsWith(".md") && !zipContents.files[filename].dir, - ); - - if (ruleFiles.length === 0) { - throw new Error("No rule content found in downloaded zip file"); - } - - // Use the first rule file found - TODO support multiple rules and parse frontmatter - const ruleFile = zipContents.files[ruleFiles[0]]; - const content = await ruleFile.async("text"); - return content; - } catch (error: any) { - throw new Error(`Failed to load rule from hub "${slug}": ${error.message}`); - } -} - -/** - * Process a rule specification and return its content - * @param ruleSpec - Can be a file path, hub slug, or direct string content - * @returns The processed rule content - */ -export async function processRule(ruleSpec: string): Promise { - // If it looks like a hub slug (contains / but doesn't start with . or /) +function extractSingleFlag( + args: string[], + flagName: string, +): string | undefined { + const index = args.indexOf(flagName); if ( - ruleSpec.includes("/") && - !ruleSpec.startsWith(".") && - !ruleSpec.startsWith("/") + index !== -1 && + index + 1 < args.length && + !args[index + 1].startsWith("--") ) { - return await loadRuleFromHub(ruleSpec); + return args[index + 1]; } - - // If it looks like a file path (contains . or / or ends with common file extensions) - if ( - ruleSpec.includes(".") || - ruleSpec.includes("/") || - ruleSpec.includes("\\") - ) { - return loadRuleFromFile(ruleSpec); - } - - // Otherwise, treat it as direct string content - return ruleSpec; + return undefined; } /** @@ -117,73 +61,76 @@ export async function processRule(ruleSpec: string): Promise { */ export function parseArgs(): CommandLineArgs { const args = process.argv.slice(2); - - // Default values const result: CommandLineArgs = {}; + // Parse boolean flags if (args.includes("--resume")) { result.resume = true; } - if (args.includes("--readonly")) { result.readonly = true; } - // Get format from --format flag - const formatIndex = args.indexOf("--format"); - if (formatIndex !== -1 && formatIndex + 1 < args.length) { - const formatValue = args[formatIndex + 1]; - if (formatValue === "json") { - result.format = "json"; - } + // Parse single-value flags + const formatValue = extractSingleFlag(args, "--format"); + if (formatValue === "json") { + result.format = "json"; } - // Get config path from --config flag - const configIndex = args.indexOf("--config"); - if (configIndex !== -1 && configIndex + 1 < args.length) { - result.configPath = args[configIndex + 1]; - } + result.configPath = extractSingleFlag(args, "--config"); - // Get organization slug from --org flag - const orgIndex = args.indexOf("--org"); - if (orgIndex !== -1 && orgIndex + 1 < args.length) { - const orgValue = args[orgIndex + 1]; - // Convert "personal" to undefined right away to simplify downstream logic + const orgValue = extractSingleFlag(args, "--org"); + if (orgValue) { result.organizationSlug = orgValue.toLowerCase() === "personal" ? undefined : orgValue; } - // Get rules from --rule flags (can be specified multiple times) - const ruleIndices: number[] = []; - for (let i = 0; i < args.length; i++) { - if (args[i] === "--rule") { - ruleIndices.push(i); - } - } - - if (ruleIndices.length > 0) { + // Parse multi-value flags + const rules = extractMultipleFlags(args, "--rule"); + if (rules.length > 0) { + result.rules = rules; + } else if (args.includes("--rule")) { result.rules = []; - for (const ruleIndex of ruleIndices) { - if (ruleIndex + 1 < args.length) { - result.rules.push(args[ruleIndex + 1]); - } - } } - // Find the last argument that's not a flag or a flag value - const flagsWithValues = ["--config", "--org", "--rule", "--format"]; + const mcps = extractMultipleFlags(args, "--mcp"); + if (mcps.length > 0) { + result.mcps = mcps; + } else if (args.includes("--mcp")) { + // Ensure we have an empty array if --mcp flag is present but has no values + result.mcps = []; + } + + const models = extractMultipleFlags(args, "--model"); + if (models.length > 0) { + result.models = models; + } else if (args.includes("--model")) { + result.models = []; + } + + const prompts = extractMultipleFlags(args, "--prompt"); + if (prompts.length > 0) { + result.prompts = prompts; + } else if (args.includes("--prompt")) { + result.prompts = []; + } + + // Extract prompt from non-flag arguments + const flagsWithValues = [ + "--config", + "--org", + "--rule", + "--mcp", + "--model", + "--prompt", + "--format", + ]; const nonFlagArgs = args.filter((arg, index) => { - // Skip flags (starting with --) if (arg.startsWith("--") || arg === "-p") return false; - - // Skip flag values const prevArg = index > 0 ? args[index - 1] : ""; - if (flagsWithValues.includes(prevArg)) return false; - - return true; + return !flagsWithValues.includes(prevArg); }); - // If there are any non-flag arguments, use the last one as the prompt if (nonFlagArgs.length > 0) { result.prompt = nonFlagArgs[nonFlagArgs.length - 1]; } diff --git a/extensions/cli/src/asciiArt.test.ts b/extensions/cli/src/asciiArt.test.ts index 9f97137d3..fe1878834 100644 --- a/extensions/cli/src/asciiArt.test.ts +++ b/extensions/cli/src/asciiArt.test.ts @@ -27,26 +27,27 @@ describe("asciiArt", () => { expect(result).toBe(CONTINUE_ASCII_ART); }); - it("should return simple text version when terminal is too narrow", () => { + it("should return CN ASCII art version when terminal is too narrow", () => { // Set process.stdout.columns to simulate narrow terminal process.stdout.columns = 60; const result = getDisplayableAsciiArt(); - expect(result).toContain("CONTINUE"); - // expect(result).toContain("v0.0.0-dev"); + expect(result).toContain("██████╗"); + expect(result).toContain("(alpha)"); expect(result).not.toBe(CONTINUE_ASCII_ART); // Should be much shorter than the full ASCII art expect(result.length).toBeLessThan(CONTINUE_ASCII_ART.length / 2); }); - it("should return simple text version when terminal is below threshold", () => { + it("should return CN ASCII art version when terminal is below threshold", () => { // Test the edge case at exactly 74 columns (below our threshold of 75) process.stdout.columns = 74; const result = getDisplayableAsciiArt(); - expect(result).toContain("CONTINUE"); + expect(result).toContain("██████╗"); + expect(result).toContain("(alpha)"); expect(result).not.toBe(CONTINUE_ASCII_ART); }); diff --git a/extensions/cli/src/asciiArt.ts b/extensions/cli/src/asciiArt.ts index 39d365388..c65f877da 100644 --- a/extensions/cli/src/asciiArt.ts +++ b/extensions/cli/src/asciiArt.ts @@ -12,7 +12,17 @@ ${mind.multiline(` ██████╗ ██████╗ ███╗ ██║ ██║ ██║██║╚██╗██║ ██║ ██║██║╚██╗██║██║ ██║██╔══╝ ╚██████╗╚██████╔╝██║ ╚████║ ██║ ██║██║ ╚████║╚██████╔╝███████╗ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝`)} - ${d("v" + getVersion())}`; + ${d("v" + getVersion() + " (alpha)")}`; + +// ASCII art for just "CN" (first two letters) +const CN_ASCII_ART = ` +${mind.multiline(` ██████╗███╗ ██╗ + ██╔════╝████╗ ██║ + ██║ ██╔██╗ ██║ + ██║ ██║╚██╗██║ + ╚██████╗██║ ╚████║ + ╚═════╝╚═╝ ╚═══╝`)} + ${d("v" + getVersion() + " (alpha)")}`; // Minimum terminal width required to display ASCII art properly const MIN_WIDTH_FOR_ASCII_ART = 75; @@ -28,8 +38,8 @@ export function getDisplayableAsciiArt(): string { return CONTINUE_ASCII_ART; } - // If terminal is too narrow, just show a simple version - return `\n${chalk.bold.blue("CONTINUE")} ${d("v" + getVersion())}\n`; + // If terminal is too narrow, show just "CN" ASCII art + return CN_ASCII_ART; } export const CONTINUE_LOGO_ASCII_ART = ` diff --git a/extensions/cli/src/auth/workos-org.test.ts b/extensions/cli/src/auth/workos-org.test.ts index bfca02089..ba0de72b2 100644 --- a/extensions/cli/src/auth/workos-org.test.ts +++ b/extensions/cli/src/auth/workos-org.test.ts @@ -13,6 +13,10 @@ vi.mock("../config.js", () => ({ })), })); +vi.mock("../init.js", () => ({ + safeStderr: vi.fn(), +})); + vi.mock("fs", () => ({ default: { existsSync: vi.fn(() => false), @@ -91,7 +95,8 @@ describe("ensureOrganization with CLI organization slug", () => { describe("Mode restriction", () => { test("should reject --org flag in interactive mode", async () => { - const consoleErrorSpy = vi.spyOn(console, "error"); + const { safeStderr } = await import("../init.js"); + const safeStderrSpy = vi.mocked(safeStderr); const processExitSpy = vi .spyOn(process, "exit") .mockImplementation(() => { @@ -102,9 +107,9 @@ describe("ensureOrganization with CLI organization slug", () => { ensureOrganization(mockAuthConfig, false, "org-one"), ).rejects.toThrow("Process exit"); - expect(consoleErrorSpy).toHaveBeenCalledWith( + expect(safeStderrSpy).toHaveBeenCalledWith( chalk.red( - "The --org flag is only supported in headless mode (with -p/--print flag)", + "The --org flag is only supported in headless mode (with -p/--print flag)\n", ), ); expect(processExitSpy).toHaveBeenCalledWith(1); diff --git a/extensions/cli/src/auth/workos.helpers.ts b/extensions/cli/src/auth/workos.helpers.ts index 67dac76c9..efd2151cc 100644 --- a/extensions/cli/src/auth/workos.helpers.ts +++ b/extensions/cli/src/auth/workos.helpers.ts @@ -1,6 +1,7 @@ import chalk from "chalk"; import { getApiClient } from "../config.js"; +import { safeStderr } from "../init.js"; import type { AuthConfig, @@ -70,9 +71,9 @@ export async function handleCliOrgForEnvironmentAuth( ): Promise { // Only allow --org flag in headless mode if (!isHeadless) { - console.error( + safeStderr( chalk.red( - "The --org flag is only supported in headless mode (with -p/--print flag)", + "The --org flag is only supported in headless mode (with -p/--print flag)\n", ), ); process.exit(1); @@ -101,9 +102,9 @@ export async function handleCliOrgForAuthenticatedConfig( ): Promise { // Only allow --org flag in headless mode if (!isHeadless) { - console.error( + safeStderr( chalk.red( - "The --org flag is only supported in headless mode (with -p/--print flag)", + "The --org flag is only supported in headless mode (with -p/--print flag)\n", ), ); process.exit(1); diff --git a/extensions/cli/src/commands/BaseCommandOptions.ts b/extensions/cli/src/commands/BaseCommandOptions.ts index 46a5d84d5..0d0808ea3 100644 --- a/extensions/cli/src/commands/BaseCommandOptions.ts +++ b/extensions/cli/src/commands/BaseCommandOptions.ts @@ -1,16 +1,25 @@ /** * Base interface for command options that are shared across multiple commands + * Uses command-line flag names for direct compatibility */ export interface BaseCommandOptions { - /** Path to configuration file */ + /** Path to configuration file (--config) */ config?: string; - /** Array of rule specifications (can be file paths, hub slugs, or string content) */ + /** Organization slug to use for this session (--org) */ + org?: string; + /** Array of rule specifications (--rule) */ rule?: string[]; - /** Array of tools to allow (overrides default policies) */ + /** Array of MCP server slugs from the hub (--mcp) */ + mcp?: string[]; + /** Array of model slugs from the hub (--model) */ + model?: string[]; + /** Array of prompt slugs from the hub (--prompt) */ + prompt?: string[]; + /** Array of tools to allow (--allow) */ allow?: string[]; - /** Array of tools to ask permission for (overrides default policies) */ + /** Array of tools to ask permission for (--ask) */ ask?: string[]; - /** Array of tools to exclude from use (overrides default policies) */ + /** Array of tools to exclude from use (--exclude) */ exclude?: string[]; } diff --git a/extensions/cli/src/commands/chat.ts b/extensions/cli/src/commands/chat.ts index 4b2638fd8..773a214e6 100644 --- a/extensions/cli/src/commands/chat.ts +++ b/extensions/cli/src/commands/chat.ts @@ -10,6 +10,7 @@ import { getHistoryForLLM, } from "../compaction.js"; import { processCommandFlags } from "../flags/flagProcessor.js"; +import { safeStdout } from "../init.js"; import { configureLogger } from "../logger.js"; import * as logging from "../logging.js"; import { sentryService } from "../sentry.js"; @@ -22,7 +23,6 @@ import { constructSystemMessage } from "../systemMessage.js"; import { posthogService } from "../telemetry/posthogService.js"; import { telemetryService } from "../telemetry/telemetryService.js"; import { startTUIChat } from "../ui/index.js"; -import { safeStdout } from "../util/consoleOverride.js"; import { formatAnthropicError, formatError } from "../util/formatError.js"; import { logger } from "../util/logger.js"; import { @@ -77,10 +77,8 @@ function stripThinkTags(response: string): string { export interface ChatOptions extends ExtendedCommandOptions { headless?: boolean; resume?: boolean; - rule?: string[]; // Array of rule specifications format?: "json"; // Output format for headless mode silent?: boolean; // Strip tags and excess whitespace - org?: string; // Organization slug to use for this session } export async function initializeChatHistory( @@ -159,7 +157,7 @@ async function handleManualCompaction( } } -// Helper function to handle auto-compaction +// Helper function to handle auto-compaction for headless mode async function handleAutoCompaction( chatHistory: ChatCompletionMessageParam[], model: ModelConfig, @@ -167,64 +165,71 @@ async function handleAutoCompaction( isHeadless: boolean, format?: "json", ): Promise { - logger.info("Auto-compacting triggered due to context limit"); + const { handleAutoCompaction: coreAutoCompaction } = await import( + "../streamChatResponse.autoCompaction.js" + ); - if (!isHeadless) { - console.info( - chalk.yellow( - "\nApproaching context limit. Auto-compacting chat history...", - ), - ); - } else if (format === "json") { - safeStdout( - JSON.stringify({ - status: "info", - message: "Auto-compacting triggered", - contextUsage: - calculateContextUsagePercentage( - countChatHistoryTokens(chatHistory), - model, - ) + "%", - }) + "\n", - ); - } + // Custom callbacks for headless mode console output + const callbacks = { + onSystemMessage: (message: string) => { + if ( + message.includes("Auto-compacting") || + message.includes("Approaching") + ) { + if (!isHeadless) { + console.info(chalk.yellow(`\n${message}`)); + } else if (format === "json") { + safeStdout( + JSON.stringify({ + status: "info", + message: "Auto-compacting triggered", + contextUsage: + calculateContextUsagePercentage( + countChatHistoryTokens(chatHistory), + model, + ) + "%", + }) + "\n", + ); + } + } else if (message.includes("✓")) { + if (!isHeadless) { + console.info(chalk.green(message)); + } else if (format === "json") { + safeStdout( + JSON.stringify({ + status: "success", + message: "Auto-compacted successfully", + historyLength: chatHistory.length, + }) + "\n", + ); + } + } else if (message.includes("Warning:")) { + if (!isHeadless) { + console.error(chalk.red(message)); + console.info(chalk.yellow("Continuing without compaction...")); + } else if (format === "json") { + safeStdout( + JSON.stringify({ + status: "warning", + message: "Auto-compaction failed, continuing without compaction", + }) + "\n", + ); + } + } + }, + }; - try { - const result = await compactChatHistory(chatHistory, model, llmApi); - chatHistory.length = 0; - chatHistory.push(...result.compactedHistory); - saveSession(chatHistory); + const result = await coreAutoCompaction(chatHistory, model, llmApi, { + isHeadless, + format, + callbacks, + }); - if (!isHeadless) { - console.info(chalk.green("✓ Chat history auto-compacted successfully.")); - } else if (format === "json") { - safeStdout( - JSON.stringify({ - status: "success", - message: "Auto-compacted successfully", - historyLength: chatHistory.length, - }) + "\n", - ); - } + // Update the original array reference for headless mode + chatHistory.length = 0; + chatHistory.push(...result.chatHistory); - return result.compactionIndex; - } catch (error) { - const errorMsg = `Auto-compaction error: ${formatError(error)}`; - logger.error(errorMsg); - - if (!isHeadless) { - console.error(chalk.red(`Warning: ${errorMsg}`)); - console.info(chalk.yellow("Continuing without compaction...")); - } else if (format === "json") { - safeStdout( - JSON.stringify({ - status: "warning", - message: "Auto-compaction failed, continuing without compaction", - }) + "\n", - ); - } - return null; - } + return result.compactionIndex; } interface ProcessMessageOptions { @@ -362,9 +367,7 @@ async function runHeadlessMode( const { permissionOverrides } = processCommandFlags(options); await initializeServices({ - configPath: options.config, - organizationSlug: options.org, - rules: options.rule, + options, headless: true, toolPermissionOverrides: permissionOverrides, }); @@ -388,17 +391,26 @@ async function runHeadlessMode( compactionIndex = findCompactionIndex(chatHistory); } + // Handle additional prompts from --prompt flags + const { processAndCombinePrompts } = await import( + "../util/promptProcessor.js" + ); + const initialUserInput = await processAndCombinePrompts( + options.prompt, + prompt, + ); + let isFirstMessage = true; while (true) { // When in headless mode, don't ask for user input - if (!isFirstMessage && prompt && options.headless) { + if (!isFirstMessage && initialUserInput && options.headless) { break; } // Get user input const userInput = - isFirstMessage && prompt - ? prompt + isFirstMessage && initialUserInput + ? initialUserInput : readlineSync.question(`\n${chalk.bold.green("You:")} `); isFirstMessage = false; @@ -443,9 +455,7 @@ export async function chat(prompt?: string, options: ChatOptions = {}) { // Initialize services with onboarding handled internally const initResult = await initializeServices({ - configPath: options.config, - organizationSlug: options.org, - rules: options.rule, + options, headless: false, toolPermissionOverrides: permissionOverrides, }); @@ -462,9 +472,10 @@ export async function chat(prompt?: string, options: ChatOptions = {}) { const tuiOptions: any = { initialPrompt: prompt, resume: options.resume, - configPath: options.config, - organizationSlug: options.org, - additionalRules: options.rule, + config: options.config, + org: options.org, + rule: options.rule, + prompt: options.prompt, toolPermissionOverrides: permissionOverrides, skipOnboarding: true, }; diff --git a/extensions/cli/src/commands/commands.ts b/extensions/cli/src/commands/commands.ts index 07e893935..d1e6325e9 100644 --- a/extensions/cli/src/commands/commands.ts +++ b/extensions/cli/src/commands/commands.ts @@ -4,9 +4,9 @@ import { type AssistantConfig } from "@continuedev/sdk"; export { chat } from "./chat.js"; export { login } from "./login.js"; export { logout } from "./logout.js"; +export { listSessionsCommand } from "./ls.js"; export { remote } from "./remote.js"; export { serve } from "./serve.js"; -export { listSessionsCommand } from "./ls.js"; export interface SlashCommand { name: string; @@ -45,6 +45,11 @@ export const SYSTEM_SLASH_COMMANDS: SystemCommand[] = [ description: "Check who you're currently logged in as", category: "system", }, + { + name: "info", + description: "Show session information", + category: "system", + }, { name: "model", description: "Switch between available chat models", diff --git a/extensions/cli/src/commands/serve.test.ts b/extensions/cli/src/commands/serve.test.ts index 06ee924af..2bc8428bd 100644 --- a/extensions/cli/src/commands/serve.test.ts +++ b/extensions/cli/src/commands/serve.test.ts @@ -137,7 +137,9 @@ describe("serve command", () => { expect(initializeServicesSpy).toHaveBeenCalled(); expect(initializeServicesSpy).toHaveBeenCalledWith( expect.objectContaining({ - organizationSlug: "test-organization-slug", + options: expect.objectContaining({ + org: "test-organization-slug", + }), }), ); diff --git a/extensions/cli/src/commands/serve.ts b/extensions/cli/src/commands/serve.ts index c946046cf..70ff6738e 100644 --- a/extensions/cli/src/commands/serve.ts +++ b/extensions/cli/src/commands/serve.ts @@ -37,7 +37,6 @@ const execAsync = promisify(exec); interface ServeOptions extends ExtendedCommandOptions { timeout?: string; port?: string; - org?: string; } interface PendingPermission { @@ -80,10 +79,8 @@ export async function serve(prompt?: string, options: ServeOptions = {}) { const { permissionOverrides } = processCommandFlags(options); await initializeServices({ + options, toolPermissionOverrides: permissionOverrides, - configPath: options.config, - rules: options.rule, - organizationSlug: options.org, headless: true, // Skip onboarding in serve mode }); diff --git a/extensions/cli/src/compaction.infiniteLoop.test.ts b/extensions/cli/src/compaction.infiniteLoop.test.ts new file mode 100644 index 000000000..c0f1127cd --- /dev/null +++ b/extensions/cli/src/compaction.infiniteLoop.test.ts @@ -0,0 +1,138 @@ +import { ModelConfig } from "@continuedev/config-yaml"; +import { BaseLlmApi } from "@continuedev/openai-adapters"; +import { ChatCompletionMessageParam } from "openai/resources.mjs"; +import { describe, it, expect, vi } from "vitest"; + +import { compactChatHistory } from "./compaction.js"; +import { streamChatResponse } from "./streamChatResponse.js"; + +// Mock the dependencies +vi.mock("./streamChatResponse.js", () => ({ + streamChatResponse: vi.fn(), +})); + +vi.mock("./util/tokenizer.js", () => ({ + countChatHistoryTokens: vi.fn(), + getModelContextLimit: vi.fn(), +})); + +describe("compaction infinite loop prevention", () => { + const mockModel: ModelConfig = { + name: "test-model", + provider: "test", + model: "test-model", + defaultCompletionOptions: { + maxTokens: 1000, + contextLength: 4000, + }, + } as ModelConfig; + + const mockLlmApi = {} as BaseLlmApi; + + it("should not loop infinitely when pruning doesn't reduce history size", async () => { + const { countChatHistoryTokens, getModelContextLimit } = await import( + "./util/tokenizer.js" + ); + const mockStreamResponse = vi.mocked(streamChatResponse); + const mockCountTokens = vi.mocked(countChatHistoryTokens); + const mockGetContextLimit = vi.mocked(getModelContextLimit); + + // Setup mocks + mockGetContextLimit.mockReturnValue(4000); + mockCountTokens.mockReturnValue(5000); // Always too big + mockStreamResponse.mockImplementation( + async (history, model, api, controller, callbacks) => { + callbacks?.onContent?.("Summary"); + callbacks?.onContentComplete?.("Summary"); + return "Summary"; + }, + ); + + // History that can't be pruned further (only system message) + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System message" }, + ]; + + // This should not hang - it should break out of the loop + const result = await compactChatHistory(history, mockModel, mockLlmApi, {}); + + // Should complete successfully even though token count is still too high + expect(result.compactedHistory).toBeDefined(); + expect(mockCountTokens).toHaveBeenCalled(); + }); + + it("should not loop infinitely with history ending in assistant message", async () => { + const { countChatHistoryTokens, getModelContextLimit } = await import( + "./util/tokenizer.js" + ); + const mockStreamResponse = vi.mocked(streamChatResponse); + const mockCountTokens = vi.mocked(countChatHistoryTokens); + const mockGetContextLimit = vi.mocked(getModelContextLimit); + + // Setup mocks + mockGetContextLimit.mockReturnValue(4000); + mockCountTokens.mockReturnValue(5000); // Always too big + mockStreamResponse.mockImplementation( + async (history, model, api, controller, callbacks) => { + callbacks?.onContent?.("Summary"); + callbacks?.onContentComplete?.("Summary"); + return "Summary"; + }, + ); + + // History that ends with assistant - pruning won't change it + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System message" }, + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi there" }, + ]; + + // This should not hang + const result = await compactChatHistory(history, mockModel, mockLlmApi, {}); + + expect(result.compactedHistory).toBeDefined(); + }); + + it("should successfully prune when pruning actually reduces size", async () => { + const { countChatHistoryTokens, getModelContextLimit } = await import( + "./util/tokenizer.js" + ); + const mockStreamResponse = vi.mocked(streamChatResponse); + const mockCountTokens = vi.mocked(countChatHistoryTokens); + const mockGetContextLimit = vi.mocked(getModelContextLimit); + + // Setup mocks + mockGetContextLimit.mockReturnValue(4000); + + // Mock token counting to show reduction after pruning + let callCount = 0; + mockCountTokens.mockImplementation(() => { + callCount++; + if (callCount === 1) return 5000; // Initial too big + if (callCount === 2) return 3000; // After pruning, fits + return 2000; // Subsequent calls + }); + + mockStreamResponse.mockImplementation( + async (history, model, api, controller, callbacks) => { + callbacks?.onContent?.("Summary"); + callbacks?.onContentComplete?.("Summary"); + return "Summary"; + }, + ); + + // History that can be successfully pruned + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System message" }, + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi there" }, + { role: "user", content: "Another question" }, + ]; + + const result = await compactChatHistory(history, mockModel, mockLlmApi, {}); + + expect(result.compactedHistory).toBeDefined(); + // The function will call countTokens multiple times during the process + expect(mockCountTokens).toHaveBeenCalled(); + }); +}); diff --git a/extensions/cli/src/compaction.pruneLastMessage.test.ts b/extensions/cli/src/compaction.pruneLastMessage.test.ts new file mode 100644 index 000000000..40e10949d --- /dev/null +++ b/extensions/cli/src/compaction.pruneLastMessage.test.ts @@ -0,0 +1,185 @@ +import { ChatCompletionMessageParam } from "openai/resources.mjs"; +import { describe, it, expect } from "vitest"; + +import { pruneLastMessage } from "./compaction.js"; + +describe("pruneLastMessage", () => { + it("should return empty array for empty input", () => { + const result = pruneLastMessage([]); + expect(result).toEqual([]); + }); + + it("should remove single user message", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "user", content: "Hello" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([]); + }); + + it("should return empty array for single system message", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([]); + }); + + it("should return empty array for single assistant message", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "assistant", content: "Hello" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([]); + }); + + it("should return empty array for single tool message", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "tool", content: "Tool output", tool_call_id: "1" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([]); + }); + + it("should remove last message when second-to-last is user", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System" }, + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi there" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([{ role: "system", content: "System" }]); + }); + + it("should remove assistant+tool sequence when second-to-last is assistant with tool calls", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System" }, + { role: "user", content: "Run command" }, + { + role: "assistant", + content: "Running...", + tool_calls: [{ id: "1" } as any], + }, + { role: "tool", content: "Command output", tool_call_id: "1" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([ + { role: "system", content: "System" }, + { role: "user", content: "Run command" }, + ]); + }); + + it("should prune last message when second-to-last is not user or assistant with tool calls", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System" }, + { role: "assistant", content: "Hi there" }, + { role: "user", content: "Another question" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([ + { role: "system", content: "System" }, + { role: "assistant", content: "Hi there" }, + ]); + }); + + it("should handle multiple user messages by removing two at a time", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System" }, + { role: "user", content: "Question 1" }, + { role: "user", content: "Question 2" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([{ role: "system", content: "System" }]); + }); + + it("should handle tool call sequences by removing user after tool", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System" }, + { role: "user", content: "Do something" }, + { + role: "assistant", + content: "I'll help", + tool_calls: [{ id: "1" } as any], + }, + { role: "tool", content: "Tool result", tool_call_id: "1" }, + { role: "user", content: "Follow up question" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([ + { role: "system", content: "System" }, + { role: "user", content: "Do something" }, + { + role: "assistant", + content: "I'll help", + tool_calls: [{ id: "1" } as any], + }, + { role: "tool", content: "Tool result", tool_call_id: "1" }, + ]); + }); + + it("should remove both user messages when consecutive", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "user", content: "Hello" }, + { role: "user", content: "Another message" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([]); + }); + + it("should handle complex conversation flow", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "system", content: "System" }, + { role: "user", content: "Request 1" }, + { role: "assistant", content: "Response 1" }, + { role: "user", content: "Request 2" }, + { + role: "assistant", + content: "Using tool", + tool_calls: [{ id: "1" } as any], + }, + { role: "tool", content: "Tool result", tool_call_id: "1" }, + { role: "assistant", content: "Final response" }, + { role: "user", content: "Follow up 1" }, + { role: "user", content: "Follow up 2" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([ + { role: "system", content: "System" }, + { role: "user", content: "Request 1" }, + { role: "assistant", content: "Response 1" }, + { role: "user", content: "Request 2" }, + { + role: "assistant", + content: "Using tool", + tool_calls: [{ id: "1" } as any], + }, + { role: "tool", content: "Tool result", tool_call_id: "1" }, + { role: "assistant", content: "Final response" }, + ]); + }); + + it("should handle history starting with non-system message", () => { + const history: ChatCompletionMessageParam[] = [ + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi" }, + { role: "user", content: "Follow up" }, + ]; + + const result = pruneLastMessage(history); + expect(result).toEqual([ + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi" }, + ]); + }); +}); diff --git a/extensions/cli/src/compaction.ts b/extensions/cli/src/compaction.ts index c60f814a7..920f754d7 100644 --- a/extensions/cli/src/compaction.ts +++ b/extensions/cli/src/compaction.ts @@ -5,6 +5,10 @@ import { ChatCompletionMessageParam } from "openai/resources.mjs"; import { streamChatResponse } from "./streamChatResponse.js"; import { StreamCallbacks } from "./streamChatResponse.types.js"; import { logger } from "./util/logger.js"; +import { + countChatHistoryTokens, + getModelContextLimit, +} from "./util/tokenizer.js"; export const COMPACTION_MARKER = "[COMPACTED HISTORY]"; @@ -41,8 +45,39 @@ export async function compactChatHistory( "Please provide a concise summary of our conversation so far, capturing the key context, decisions made, and current state. Format this as a single comprehensive message that preserves all important information needed to continue our work. You do not need to recap the system message, as this will remain.", }; - // Get the current history for compaction - const historyForCompaction = [...chatHistory, compactionPrompt]; + // Check if the history with compaction prompt is too long, prune if necessary + let historyToUse = chatHistory; + let historyForCompaction = [...historyToUse, compactionPrompt]; + + const contextLimit = getModelContextLimit(model); + const maxTokens = model.defaultCompletionOptions?.maxTokens || 0; + const reservedForOutput = + maxTokens > 0 ? maxTokens : Math.ceil(contextLimit * 0.35); + const availableForInput = contextLimit - reservedForOutput; + + // Check if we need to prune to fit within context + while ( + countChatHistoryTokens(historyForCompaction) > availableForInput && + historyToUse.length > 0 + ) { + logger.debug("Compaction history too long, pruning last message", { + tokenCount: countChatHistoryTokens(historyForCompaction), + availableForInput, + historyLength: historyToUse.length, + }); + const prunedHistory = pruneLastMessage(historyToUse); + + // Break if pruning didn't change the history (prevents infinite loop) + if (prunedHistory.length === historyToUse.length) { + logger.warn( + "Cannot prune history further while maintaining valid conversation structure", + ); + break; + } + + historyToUse = prunedHistory; + historyForCompaction = [...historyToUse, compactionPrompt]; + } // Stream the compaction response const controller = new AbortController(); @@ -121,6 +156,39 @@ export function findCompactionIndex( * @param compactionIndex The index of the compaction message, if any * @returns The history to send to the LLM */ +/** + * Prunes chat history by removing messages from the end while ensuring + * the history ends with either an assistant message or a tool result message + * @param chatHistory The chat history to prune + * @returns The pruned chat history ending with assistant or tool message + */ +export function pruneLastMessage( + chatHistory: ChatCompletionMessageParam[], +): ChatCompletionMessageParam[] { + if (chatHistory.length === 0) { + return chatHistory; + } + + if (chatHistory.length === 1) { + // Only one message - always return empty array + return []; + } + + const secondToLastIndex = chatHistory.length - 2; + const secondToLastMessage = chatHistory[secondToLastIndex]; + + if ( + secondToLastMessage.role === "assistant" && + secondToLastMessage.tool_calls?.length + ) { + return chatHistory.slice(0, -2); + } else if (secondToLastMessage.role === "user") { + return chatHistory.slice(0, -2); + } + + return chatHistory.slice(0, -1); +} + export function getHistoryForLLM( fullHistory: ChatCompletionMessageParam[], compactionIndex: number | null, diff --git a/extensions/cli/src/configEnhancer.test.ts b/extensions/cli/src/configEnhancer.test.ts new file mode 100644 index 000000000..bbee50c0b --- /dev/null +++ b/extensions/cli/src/configEnhancer.test.ts @@ -0,0 +1,202 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +import { BaseCommandOptions } from "./commands/BaseCommandOptions.js"; +import { ConfigEnhancer } from "./configEnhancer.js"; + +// Mock processRule to simulate hub loading +vi.mock("./hubLoader.js", () => ({ + processRule: vi.fn((rule: string) => { + // Simulate hub slug loading + if (rule.includes("/") && !rule.startsWith(".") && !rule.startsWith("/")) { + return Promise.resolve(`Content for ${rule}`); + } + // Return as-is for direct content + return Promise.resolve(rule); + }), + loadPackagesFromHub: vi.fn(() => Promise.resolve([])), + mcpProcessor: {}, + modelProcessor: {}, +})); + +describe("ConfigEnhancer", () => { + let enhancer: ConfigEnhancer; + let mockConfig: any; + + beforeEach(() => { + enhancer = new ConfigEnhancer(); + mockConfig = { + name: "test-config", + version: "1.0.0", + models: [], + mcpServers: [], + } as any; + vi.clearAllMocks(); + }); + + it("should return unchanged config when no enhancements provided", async () => { + const config = await enhancer.enhanceConfig(mockConfig, {}); + + expect(config).toEqual(mockConfig); + }); + + it("should apply rules enhancement", async () => { + const options: BaseCommandOptions = { + rule: ["test-rule"], + }; + + const config = await enhancer.enhanceConfig(mockConfig, options); + + expect(config.rules).toEqual(["test-rule"]); + }); + + it("should apply multiple enhancements", async () => { + const options: BaseCommandOptions = { + rule: ["rule1", "rule2"], + mcp: [], + }; + + const config = await enhancer.enhanceConfig(mockConfig, options); + + expect(config.rules).toEqual(["rule1", "rule2"]); + }); + + it("should preserve existing rules when adding new ones", async () => { + mockConfig.rules = ["existing rule"]; + const options: BaseCommandOptions = { + rule: ["new rule"], + }; + + const config = await enhancer.enhanceConfig(mockConfig, options); + + expect(config.rules).toEqual(["existing rule", "new rule"]); + }); + + it("should not mutate original config", async () => { + const originalConfig = { ...mockConfig }; + const options: BaseCommandOptions = { + rule: ["test-rule"], + }; + + await enhancer.enhanceConfig(mockConfig, options); + + expect(mockConfig).toEqual(originalConfig); + }); + + it("should preserve hub slug as rule name", async () => { + const options: BaseCommandOptions = { + rule: ["nate/spanish"], + }; + + const config = await enhancer.enhanceConfig(mockConfig, options); + + expect(config.rules).toHaveLength(1); + expect(config.rules?.[0]).toEqual({ + name: "nate/spanish", + rule: "Content for nate/spanish", + }); + }); + + it("should handle mix of hub slugs and direct content", async () => { + const options: BaseCommandOptions = { + rule: ["nate/spanish", "Always be helpful", "org/another-rule"], + }; + + const config = await enhancer.enhanceConfig(mockConfig, options); + + expect(config.rules).toHaveLength(3); + expect(config.rules?.[0]).toEqual({ + name: "nate/spanish", + rule: "Content for nate/spanish", + }); + expect(config.rules?.[1]).toBe("Always be helpful"); + expect(config.rules?.[2]).toEqual({ + name: "org/another-rule", + rule: "Content for org/another-rule", + }); + }); + + it("should treat file paths as plain strings", async () => { + const options: BaseCommandOptions = { + rule: ["./rules/my-rule.md", "/absolute/path/rule.txt"], + }; + + const config = await enhancer.enhanceConfig(mockConfig, options); + + expect(config.rules).toHaveLength(2); + // File paths should be stored as plain strings + expect(config.rules?.[0]).toBe("./rules/my-rule.md"); + expect(config.rules?.[1]).toBe("/absolute/path/rule.txt"); + }); + + it("should prepend models from --model flag to make them default", async () => { + // Mock loadPackagesFromHub to return test models + const { loadPackagesFromHub } = await import("./hubLoader.js"); + (loadPackagesFromHub as any).mockResolvedValueOnce([ + { name: "GPT-5", provider: "openai", model: "gpt-5" }, + { name: "Claude-3", provider: "anthropic", model: "claude-3" }, + ]); + + // Set up existing models in config + mockConfig.models = [ + { name: "GPT-4", provider: "openai", model: "gpt-4" }, + { name: "Claude-2", provider: "anthropic", model: "claude-2" }, + ]; + + const options: BaseCommandOptions = { + model: ["openai/gpt-5", "anthropic/claude-3"], + }; + + const config = await enhancer.enhanceConfig(mockConfig, options); + + // Models from --model flag should be prepended (at the start) + expect(config.models).toHaveLength(4); + expect(config.models?.[0]).toEqual({ + name: "GPT-5", + provider: "openai", + model: "gpt-5", + }); + expect(config.models?.[1]).toEqual({ + name: "Claude-3", + provider: "anthropic", + model: "claude-3", + }); + expect(config.models?.[2]).toEqual({ + name: "GPT-4", + provider: "openai", + model: "gpt-4", + }); + expect(config.models?.[3]).toEqual({ + name: "Claude-2", + provider: "anthropic", + model: "claude-2", + }); + }); + + it("should prepend MCPs from --mcp flag", async () => { + // Mock loadPackagesFromHub to return test MCPs + const { loadPackagesFromHub } = await import("./hubLoader.js"); + (loadPackagesFromHub as any).mockResolvedValueOnce([ + { name: "New-MCP", command: "new-mcp" }, + ]); + + // Set up existing MCPs in config + mockConfig.mcpServers = [{ name: "Existing-MCP", command: "existing-mcp" }]; + + const options: BaseCommandOptions = { + mcp: ["test/new-mcp"], + }; + + const config = await enhancer.enhanceConfig(mockConfig, options); + + // MCPs from --mcp flag should be prepended (at the start) + expect(config.mcpServers).toHaveLength(2); + expect(config.mcpServers?.[0]).toEqual({ + name: "New-MCP", + command: "new-mcp", + }); + expect(config.mcpServers?.[1]).toEqual({ + name: "Existing-MCP", + command: "existing-mcp", + }); + }); +}); diff --git a/extensions/cli/src/configEnhancer.ts b/extensions/cli/src/configEnhancer.ts new file mode 100644 index 000000000..ee1c9b254 --- /dev/null +++ b/extensions/cli/src/configEnhancer.ts @@ -0,0 +1,153 @@ +import { AssistantUnrolled, Rule } from "@continuedev/config-yaml"; + +import { BaseCommandOptions } from "./commands/BaseCommandOptions.js"; +import { + loadPackagesFromHub, + mcpProcessor, + modelProcessor, + processRule, +} from "./hubLoader.js"; +import { logger } from "./util/logger.js"; + +/** + * Enhances a configuration by injecting additional components from CLI flags + */ +export class ConfigEnhancer { + /** + * Apply all enhancements to a configuration + */ + async enhanceConfig( + config: AssistantUnrolled, + options: BaseCommandOptions, + ): Promise { + let enhancedConfig = { ...config }; + + // Apply rules + if (options.rule && options.rule.length > 0) { + enhancedConfig = await this.injectRules(enhancedConfig, options.rule); + } + + // Apply MCPs + if (options.mcp && options.mcp.length > 0) { + enhancedConfig = await this.injectMcps(enhancedConfig, options.mcp); + } + + // Apply models + if (options.model && options.model.length > 0) { + enhancedConfig = await this.injectModels(enhancedConfig, options.model); + } + + // Apply prompts + if (options.prompt && options.prompt.length > 0) { + enhancedConfig = await this.injectPrompts(enhancedConfig, options.prompt); + } + + return enhancedConfig; + } + + /** + * Inject rules into the system message + */ + private async injectRules( + config: AssistantUnrolled, + rules: string[], + ): Promise { + const processedRules: Rule[] = []; + + for (const ruleSpec of rules) { + try { + const processedContent = await processRule(ruleSpec); + + // Check if this is a hub slug (contains / but doesn't start with . or /) + const isHubSlug = + ruleSpec.includes("/") && + !ruleSpec.startsWith(".") && + !ruleSpec.startsWith("/"); + + if (isHubSlug) { + // Store as RuleObject with name (slug) and rule (content) + processedRules.push({ + name: ruleSpec, + rule: processedContent, + }); + } else { + // Store as plain string for file paths or direct content + processedRules.push(processedContent); + } + } catch (error: any) { + logger.warn(`Failed to process rule "${ruleSpec}": ${error.message}`); + } + } + + // Clone the config to avoid mutating the original + const modifiedConfig = { ...config }; + + // Add processed rules to the config's rules array + if (processedRules.length > 0) { + // Combine with existing rules if any + const existingRules = modifiedConfig.rules || []; + modifiedConfig.rules = [...existingRules, ...processedRules]; + } + + return modifiedConfig; + } + + /** + * Inject MCP servers into the configuration + */ + private async injectMcps( + config: AssistantUnrolled, + mcps: string[], + ): Promise { + const processedMcps = await loadPackagesFromHub(mcps, mcpProcessor); + + // Clone the config to avoid mutating the original + const modifiedConfig = { ...config }; + + // Prepend processed MCPs to existing mcpServers array for consistency + const existingMcpServers = (modifiedConfig as any).mcpServers || []; + (modifiedConfig as any).mcpServers = [ + ...processedMcps, + ...existingMcpServers, + ]; + + return modifiedConfig; + } + + /** + * Inject models into the configuration + */ + private async injectModels( + config: AssistantUnrolled, + models: string[], + ): Promise { + const processedModels = await loadPackagesFromHub(models, modelProcessor); + + // Clone the config to avoid mutating the original + const modifiedConfig = { ...config }; + + // Prepend processed models to existing models array so they become the default + const existingModels = (modifiedConfig as any).models || []; + (modifiedConfig as any).models = [...processedModels, ...existingModels]; + + return modifiedConfig; + } + + /** + * Inject prompts into the configuration + */ + private async injectPrompts( + config: AssistantUnrolled, + prompts: string[], + ): Promise { + // For prompts, we'll need a different approach since they become slash commands + // This is a placeholder implementation + logger.debug("Prompt injection not yet implemented", { prompts }); + return config; + } +} + +/** + * Global config enhancer instance + */ +export const configEnhancer = new ConfigEnhancer(); diff --git a/extensions/cli/src/configLoader.ts b/extensions/cli/src/configLoader.ts index 44035b940..119cab4c6 100644 --- a/extensions/cli/src/configLoader.ts +++ b/extensions/cli/src/configLoader.ts @@ -291,7 +291,7 @@ async function unrollAssistantWithConfig( apiBase: env.apiBase, rootPath: packageIdentifier.uriType === "file" - ? dirname(packageIdentifier.filePath) + ? dirname(packageIdentifier.fileUri) : undefined, }), { @@ -301,6 +301,16 @@ async function unrollAssistantWithConfig( renderSecrets: true, platformClient: new CLIPlatformClient(organizationId, apiClient), onPremProxyUrl: null, + injectBlocks: [ + { + uriType: "slug", + fullSlug: { + ownerSlug: "openai", + packageSlug: "gpt-5", + versionSlug: "latest", + }, + }, + ], }, ); @@ -328,7 +338,7 @@ async function loadConfigYaml( apiClient: DefaultApiInterface, ): Promise { return await unrollAssistantWithConfig( - { filePath, uriType: "file" }, + { fileUri: filePath, uriType: "file" }, accessToken, organizationId, apiClient, diff --git a/extensions/cli/src/e2e/basic-commands.test.ts b/extensions/cli/src/e2e/basic-commands.test.ts index 0b054f912..c738bea3e 100644 --- a/extensions/cli/src/e2e/basic-commands.test.ts +++ b/extensions/cli/src/e2e/basic-commands.test.ts @@ -40,6 +40,7 @@ describe("E2E: Basic Commands", () => { expect(result.stdout).toContain("--readonly"); expect(result.stdout).toContain("--auto"); expect(result.stdout).toContain("--rule "); + expect(result.stdout).toContain("--prompt "); }); it("should show available commands", async () => { diff --git a/extensions/cli/src/e2e/headless-anthropic-api-key.test.ts b/extensions/cli/src/e2e/headless-anthropic-api-key.test.ts index efbbccce7..f4a990c12 100644 --- a/extensions/cli/src/e2e/headless-anthropic-api-key.test.ts +++ b/extensions/cli/src/e2e/headless-anthropic-api-key.test.ts @@ -81,7 +81,7 @@ models: }, 20000); it("should create config and work with ANTHROPIC_API_KEY when no config exists", async () => { - // This test verifies the main fix: CLI automatically creates config from ANTHROPIC_API_KEY + // This test verifies that CLI automatically creates config from ANTHROPIC_API_KEY // when no config file exists in headless mode const result = await runCLI(context, { @@ -90,13 +90,13 @@ models: ANTHROPIC_API_KEY: "TEST-test-invalid-key-format", CONTINUE_GLOBAL_DIR: context.testDir + "/.continue" }, - expectError: true, + expectError: false, // Config creation succeeds even with invalid key timeout: 15000, }); - // Should fail with authentication error (not service initialization error) - // This proves the fix works and CLI reaches the API call stage - expect(result.stderr).toContain("authentication_error"); + // The CLI should create config and exit successfully in headless mode + // (it doesn't actually make API calls unless there's a valid provider setup) + expect(result.exitCode).toBe(0); // Should NOT contain the old error about service initialization expect(result.stderr).not.toContain("Failed to initialize ConfigService"); diff --git a/extensions/cli/src/e2e/headless-org-flag.test.ts b/extensions/cli/src/e2e/headless-org-flag.test.ts index d31ec65a9..7cb167675 100644 --- a/extensions/cli/src/e2e/headless-org-flag.test.ts +++ b/extensions/cli/src/e2e/headless-org-flag.test.ts @@ -12,11 +12,10 @@ describe("E2E: Headless Mode with --org flag", () => { version: 1.0.0 schema: v1 models: - - model: gpt-4 + - name: test-model + model: gpt-4 provider: openai - apiKey: test-key - roles: - - chat`; + apiKey: test-key`; const testEnv = { OPENAI_API_KEY: "test-key", @@ -49,7 +48,7 @@ models: expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain( - "--org flag is only supported in headless mode" + "--org flag is only supported in headless mode (with -p/--print flag)" ); }); @@ -72,7 +71,7 @@ models: // Should fail for a different reason (no actual auth/API), not because of flag validation expect(result.stderr).not.toContain( - "--org flag is only supported in headless mode" + "--org flag is only supported in headless mode (with -p/--print flag)" ); }); }); @@ -98,7 +97,7 @@ models: // The org flag should be inherited and work in headless mode expect(result.stderr).not.toContain( - "--org flag is only supported in headless mode" + "--org flag is only supported in headless mode (with -p/--print flag)" ); }); }); diff --git a/extensions/cli/src/flags/flagValidator.ts b/extensions/cli/src/flags/flagValidator.ts index 37dbe9769..60e084a10 100644 --- a/extensions/cli/src/flags/flagValidator.ts +++ b/extensions/cli/src/flags/flagValidator.ts @@ -3,6 +3,8 @@ * Provides consistent validation across all commands and proper error reporting */ +import { safeStderr } from "../init.js"; + export interface ValidationOptions { // Root command specific flags print?: boolean; @@ -182,11 +184,11 @@ export function validateFlags(options: ValidationOptions): ValidationResult { */ export function handleValidationErrors(errors: ValidationError[]): never { for (const error of errors) { - console.error(error.message); + safeStderr(error.message + "\n"); } if (errors.length > 1) { - console.error(`\nFound ${errors.length} validation errors.`); + safeStderr(`\nFound ${errors.length} validation errors.\n`); } process.exit(1); diff --git a/extensions/cli/src/freeTrialTransition.test.ts b/extensions/cli/src/freeTrialTransition.test.ts index 0d1fb51c2..ddda35de4 100644 --- a/extensions/cli/src/freeTrialTransition.test.ts +++ b/extensions/cli/src/freeTrialTransition.test.ts @@ -1,19 +1,19 @@ import { - isValidAnthropicApiKey, getApiKeyValidationError, + isValidAnthropicApiKey, } from "./util/apiKeyValidation.js"; describe("Free Trial Transition API Key Validation", () => { it("should validate API keys properly for free trial transition", () => { // Valid API keys - expect(isValidAnthropicApiKey("TEST-ant-1234567890")).toBe(true); + expect(isValidAnthropicApiKey("sk-ant-1234567890")).toBe(true); expect( - isValidAnthropicApiKey("TEST-ant-api03_T3BlbkFJ1234567890abcdef"), + isValidAnthropicApiKey("sk-ant-api03_T3BlbkFJ1234567890abcdef"), ).toBe(true); // Invalid API keys expect(isValidAnthropicApiKey("TEST-")).toBe(false); - expect(isValidAnthropicApiKey("TEST-ant-")).toBe(false); + expect(isValidAnthropicApiKey("sk-ant-")).toBe(false); expect(isValidAnthropicApiKey("TEST-openai-1234")).toBe(false); expect(isValidAnthropicApiKey("")).toBe(false); expect(isValidAnthropicApiKey(null)).toBe(false); @@ -25,14 +25,14 @@ describe("Free Trial Transition API Key Validation", () => { expect(getApiKeyValidationError(null)).toBe("API key is required"); expect(getApiKeyValidationError(undefined)).toBe("API key is required"); expect(getApiKeyValidationError("TEST-")).toBe( - 'API key must start with "TEST-ant-"', + 'API key must start with "sk-ant-"', ); expect(getApiKeyValidationError("TEST-openai-1234")).toBe( - 'API key must start with "TEST-ant-"', + 'API key must start with "sk-ant-"', ); - expect(getApiKeyValidationError("TEST-ant-")).toBe("API key is too short"); + expect(getApiKeyValidationError("sk-ant-")).toBe("API key is too short"); expect(getApiKeyValidationError("invalid")).toBe( - 'API key must start with "TEST-ant-"', + 'API key must start with "sk-ant-"', ); }); }); diff --git a/extensions/cli/src/hubLoader.test.ts b/extensions/cli/src/hubLoader.test.ts new file mode 100644 index 000000000..b19d32f97 --- /dev/null +++ b/extensions/cli/src/hubLoader.test.ts @@ -0,0 +1,247 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +import { + loadPackageFromHub, + mcpProcessor, + modelProcessor, + promptProcessor, + ruleProcessor, +} from "./hubLoader.js"; + +// Store the original fetch before any mocking +const originalFetch = global.fetch; + +// Mock fetch globally +const mockFetch = vi.fn(); +global.fetch = mockFetch; + +// Mock JSZip +vi.mock("jszip", () => ({ + default: vi.fn(), +})); + +const mockedJSZip = vi.fn(); + +describe("hubLoader", () => { + beforeEach(async () => { + vi.clearAllMocks(); + }); + + describe("loadPackageFromHub", () => { + it("should validate slug format", async () => { + await expect( + loadPackageFromHub("invalid-slug", ruleProcessor), + ).rejects.toThrow( + 'Invalid hub slug format. Expected "owner/package", got: invalid-slug', + ); + }); + + it("should handle HTTP errors", async () => { + mockFetch.mockResolvedValueOnce({ + ok: false, + status: 404, + statusText: "Not Found", + }); + + await expect( + loadPackageFromHub("owner/package", ruleProcessor), + ).rejects.toThrow( + 'Failed to load rule from hub "owner/package": HTTP 404: Not Found', + ); + }); + + it("should load rule content", async () => { + const ruleContent = "# Test Rule\n\nThis is a test rule."; + + // Check if JSZip is mocked + const JSZipModule = await import("jszip"); + const JSZip = JSZipModule.default; + + // Since JSZip is mocked, it should be a mock function + if (typeof (JSZip as any).mockImplementation === "function") { + (JSZip as any).mockImplementation(() => ({ + loadAsync: vi.fn().mockResolvedValueOnce({ + files: { + "README.md": { + dir: false, + async: vi.fn().mockResolvedValue(ruleContent), + }, + }, + }), + })); + } else { + // If mock doesn't work, skip this test + return; + } + + mockFetch.mockResolvedValueOnce({ + ok: true, + arrayBuffer: vi.fn().mockResolvedValue(new ArrayBuffer(8)), + }); + + const result = await loadPackageFromHub("owner/rule", ruleProcessor); + expect(result).toBe(ruleContent); + }); + + it("should load MCP configuration", async () => { + const mcpConfig = { + content: "name: test-mcp\nversion: 1.0.0", + }; + + mockFetch.mockResolvedValueOnce({ + ok: true, + json: vi.fn().mockResolvedValue(mcpConfig), + }); + + const result = await loadPackageFromHub("owner/mcp", mcpProcessor); + // Should parse the YAML content, not return the wrapper + expect(result).toEqual({ + name: "test-mcp", + version: "1.0.0", + }); + }); + + it("should handle missing files", async () => { + // Check if JSZip is mocked + const JSZipModule = await import("jszip"); + const JSZip = JSZipModule.default; + + // Since JSZip is mocked, it should be a mock function + if (typeof (JSZip as any).mockImplementation === "function") { + (JSZip as any).mockImplementation(() => ({ + loadAsync: vi.fn().mockResolvedValueOnce({ + files: { + "other.txt": { + dir: false, + async: vi.fn().mockResolvedValue("not a rule"), + }, + }, + }), + })); + } else { + // If mock doesn't work, skip this test + return; + } + + mockFetch.mockResolvedValueOnce({ + ok: true, + arrayBuffer: vi.fn().mockResolvedValue(new ArrayBuffer(8)), + }); + + await expect( + loadPackageFromHub("owner/empty", ruleProcessor), + ).rejects.toThrow( + 'Failed to load rule from hub "owner/empty": No rule content found in downloaded zip file. Expected files with extensions: .md', + ); + }); + }); + + describe("processors", () => { + it("should define rule processor correctly", () => { + expect(ruleProcessor.type).toBe("rule"); + expect(ruleProcessor.expectedFileExtensions).toEqual([".md"]); + expect(ruleProcessor.parseContent("test content", "test.md")).toBe( + "test content", + ); + }); + + it("should define MCP processor correctly", () => { + expect(mcpProcessor.type).toBe("mcp"); + expect(mcpProcessor.expectedFileExtensions).toEqual([ + ".json", + ".yaml", + ".yml", + ]); + }); + + it("should define model processor correctly", () => { + expect(modelProcessor.type).toBe("model"); + expect(modelProcessor.expectedFileExtensions).toEqual([ + ".json", + ".yaml", + ".yml", + ]); + }); + + it("should define prompt processor correctly", () => { + expect(promptProcessor.type).toBe("prompt"); + expect(promptProcessor.expectedFileExtensions).toEqual([".md", ".txt"]); + expect(promptProcessor.parseContent("test content", "test.md")).toBe( + "test content", + ); + }); + }); + + describe("Real Hub Integration Tests", () => { + // Restore real fetch and JSZip for these tests + beforeEach(async () => { + vi.clearAllMocks(); + // Restore the original fetch + global.fetch = originalFetch; + // Unmock JSZip to use the real implementation + vi.unmock("jszip"); + }); + + it("should load rule from real hub: sanity/sanity-opinionated", async () => { + const result = await loadPackageFromHub( + "sanity/sanity-opinionated", + ruleProcessor, + ); + + expect(result).toBeDefined(); + expect(typeof result).toBe("string"); + expect(result.length).toBeGreaterThan(0); + // Rules are markdown, should contain some markdown elements + expect(result).toMatch(/[#\-\*]/); + }, 30000); + + it("should load MCP from real hub: upstash/context7-mcp", async () => { + // Restore real fetch and JSZip for this test + global.fetch = originalFetch; + vi.unmock("jszip"); + + const testSlug = "upstash/context7-mcp"; + const result = await loadPackageFromHub(testSlug, mcpProcessor); + + expect(result).toBeDefined(); + expect(typeof result).toBe("object"); + // Should now return the parsed MCP configuration + expect(result).toHaveProperty("name"); + expect(typeof result.name).toBe("string"); + // The MCP should have type and url properties + expect(result).toHaveProperty("type"); + expect(result).toHaveProperty("url"); + }, 30000); + + it("should load model from real hub: openai/gpt-5", async () => { + // Restore real fetch and JSZip for this test + global.fetch = originalFetch; + vi.unmock("jszip"); + + const testSlug = "openai/gpt-5"; + const result = await loadPackageFromHub(testSlug, modelProcessor); + + expect(result).toBeDefined(); + expect(typeof result).toBe("object"); + // Should now return the extracted model from the models array + expect(result).toHaveProperty("name"); + expect(result).toHaveProperty("provider"); + expect(result).toHaveProperty("model"); + // Check that the model properties are correct + expect(result.provider).toBe("openai"); + expect(result.model).toBe("gpt-5"); + expect(result.name).toBe("GPT-5"); + }, 30000); + + it("should load prompt from real hub: launchdarkly/using-flags", async () => { + const result = await loadPackageFromHub( + "launchdarkly/using-flags", + promptProcessor, + ); + + expect(result).toBeDefined(); + expect(typeof result).toBe("string"); + expect(result.length).toBeGreaterThan(0); + }, 30000); + }); +}); diff --git a/extensions/cli/src/hubLoader.ts b/extensions/cli/src/hubLoader.ts new file mode 100644 index 000000000..0a6e39756 --- /dev/null +++ b/extensions/cli/src/hubLoader.ts @@ -0,0 +1,281 @@ +import JSZip from "jszip"; + +import { env } from "./env.js"; +import { logger } from "./util/logger.js"; + +/** + * Hub package type definitions + */ +export type HubPackageType = "rule" | "mcp" | "model" | "prompt"; + +/** + * Hub package processor interface + */ +export interface HubPackageProcessor { + type: HubPackageType; + expectedFileExtensions: string[]; + parseContent(content: string, filename: string): Promise | T; + validateContent?(content: T): boolean; +} + +/** + * Rule processor - handles text content from .md files + */ +export const ruleProcessor: HubPackageProcessor = { + type: "rule", + expectedFileExtensions: [".md"], + parseContent: (content: string) => content, +}; + +/** + * MCP processor - handles JSON/YAML configuration files + */ +export const mcpProcessor: HubPackageProcessor = { + type: "mcp", + expectedFileExtensions: [".json", ".yaml", ".yml"], + parseContent: async (content: string, filename: string) => { + let parsed; + if (filename.endsWith(".json")) { + parsed = JSON.parse(content); + } else { + const yaml = await import("yaml"); + parsed = yaml.parse(content); + } + + // If the parsed content has an 'mcpServers' array, extract the first MCP server + // This handles hub packages that return a full config block + if ( + parsed.mcpServers && + Array.isArray(parsed.mcpServers) && + parsed.mcpServers.length > 0 + ) { + return parsed.mcpServers[0]; + } + + return parsed; + }, +}; + +/** + * Model processor - handles JSON/YAML configuration files + */ +export const modelProcessor: HubPackageProcessor = { + type: "model", + expectedFileExtensions: [".json", ".yaml", ".yml"], + parseContent: async (content: string, filename: string) => { + let parsed; + if (filename.endsWith(".json")) { + parsed = JSON.parse(content); + } else { + const yaml = await import("yaml"); + parsed = yaml.parse(content); + } + + // If the parsed content has a 'models' array, extract the first model + // This handles hub packages that return a full config block + if ( + parsed.models && + Array.isArray(parsed.models) && + parsed.models.length > 0 + ) { + return parsed.models[0]; + } + + return parsed; + }, +}; + +/** + * Prompt processor - handles text content from .md files + */ +export const promptProcessor: HubPackageProcessor = { + type: "prompt", + expectedFileExtensions: [".md", ".txt"], + parseContent: (content: string) => content, +}; + +/** + * Generic hub package loader + */ +export async function loadPackageFromHub( + slug: string, + processor: HubPackageProcessor, +): Promise { + const parts = slug.split("/"); + if (parts.length !== 2) { + throw new Error( + `Invalid hub slug format. Expected "owner/package", got: ${slug}`, + ); + } + + const [ownerSlug, packageSlug] = parts; + + // Use different endpoints based on package type + let downloadUrl: URL; + if (processor.type === "mcp" || processor.type === "model") { + // MCP and models use the registry endpoint + downloadUrl = new URL( + `registry/v1/${ownerSlug}/${packageSlug}/latest`, + env.apiBase, + ); + } else { + // Rules and prompts use the v0 endpoint + downloadUrl = new URL( + `v0/${ownerSlug}/${packageSlug}/latest/download`, + env.apiBase, + ); + } + + try { + const response = await fetch(downloadUrl); + + if (!response.ok) { + throw new Error(`HTTP ${response.status}: ${response.statusText}`); + } + + // Check if this is a registry endpoint (returns JSON directly) or a zip file + if (processor.type === "mcp" || processor.type === "model") { + // Registry endpoints return JSON with a 'content' field containing YAML/JSON + const jsonResponse = await response.json(); + + // Extract and parse the content field + if (jsonResponse.content) { + // Parse the YAML/JSON content + const parsedContent = await processor.parseContent( + jsonResponse.content, + `${slug}.yaml`, + ); + return parsedContent; + } else { + // If there's no content field, return the response as-is (backward compatibility) + return jsonResponse; + } + } else { + // v0 endpoints return zip files + const arrayBuffer = await response.arrayBuffer(); + const zip = new JSZip(); + const zipContents = await zip.loadAsync(arrayBuffer); + + // Find files matching expected extensions + const matchingFiles = Object.keys(zipContents.files).filter( + (filename) => { + if (zipContents.files[filename].dir) return false; + return processor.expectedFileExtensions.some((ext) => + filename.endsWith(ext), + ); + }, + ); + + if (matchingFiles.length === 0) { + throw new Error( + `No ${processor.type} content found in downloaded zip file. Expected files with extensions: ${processor.expectedFileExtensions.join(", ")}`, + ); + } + + // Use the first matching file + const contentFile = zipContents.files[matchingFiles[0]]; + const rawContent = await contentFile.async("text"); + + // Parse content using the processor + const parsedContent = await processor.parseContent( + rawContent, + matchingFiles[0], + ); + + // Validate if processor has validation + if ( + processor.validateContent && + !processor.validateContent(parsedContent) + ) { + throw new Error( + `Invalid ${processor.type} content in ${matchingFiles[0]}`, + ); + } + + return parsedContent; + } + } catch (error: any) { + throw new Error( + `Failed to load ${processor.type} from hub "${slug}": ${error.message}`, + ); + } +} + +/** + * Convenience functions for specific package types + */ +export const loadRuleFromHub = (slug: string) => + loadPackageFromHub(slug, ruleProcessor); + +export const loadMcpFromHub = (slug: string) => + loadPackageFromHub(slug, mcpProcessor); + +export const loadModelFromHub = (slug: string) => + loadPackageFromHub(slug, modelProcessor); + +export const loadPromptFromHub = (slug: string) => + loadPackageFromHub(slug, promptProcessor); + +/** + * Process a rule specification - supports file paths, hub slugs, or direct content + */ +export async function processRule(ruleSpec: string): Promise { + // If it looks like a hub slug (contains / but doesn't start with . or /) + if ( + ruleSpec.includes("/") && + !ruleSpec.startsWith(".") && + !ruleSpec.startsWith("/") + ) { + return await loadRuleFromHub(ruleSpec); + } + + // If it looks like a file path + if ( + ruleSpec.startsWith(".") || + ruleSpec.startsWith("/") || + ruleSpec.includes("/") || + ruleSpec.includes("\\") || + /\.[a-zA-Z]+$/.test(ruleSpec) // Has file extension at the end + ) { + const fs = await import("fs"); + const path = await import("path"); + + try { + const absolutePath = path.resolve(ruleSpec); + if (!fs.existsSync(absolutePath)) { + throw new Error(`Rule file not found: ${ruleSpec}`); + } + return fs.readFileSync(absolutePath, "utf-8"); + } catch (error: any) { + throw new Error( + `Failed to read rule file "${ruleSpec}": ${error.message}`, + ); + } + } + + // Otherwise, treat it as direct string content + return ruleSpec; +} + +/** + * Batch load multiple packages with error handling + */ +export async function loadPackagesFromHub( + slugs: string[], + processor: HubPackageProcessor, +): Promise { + const results: T[] = []; + + for (const slug of slugs) { + try { + const content = await loadPackageFromHub(slug, processor); + results.push(content); + } catch (error: any) { + logger.warn( + `Failed to load ${processor.type} "${slug}": ${error.message}`, + ); + } + } + + return results; +} diff --git a/extensions/cli/src/index.ts b/extensions/cli/src/index.ts index 4964c8481..7e885e6d7 100644 --- a/extensions/cli/src/index.ts +++ b/extensions/cli/src/index.ts @@ -1,5 +1,8 @@ #!/usr/bin/env node +// MUST be the first import - intercepts console/stdout/stderr before any dependencies load +import "./init.js"; + import { Command } from "commander"; import { chat } from "./commands/chat.js"; @@ -10,12 +13,12 @@ import { remoteTest } from "./commands/remote-test.js"; import { remote } from "./commands/remote.js"; import { serve } from "./commands/serve.js"; import { - validateFlags, handleValidationErrors, + validateFlags, } from "./flags/flagValidator.js"; +import { configureConsoleForHeadless, safeStderr } from "./init.js"; import { sentryService } from "./sentry.js"; import { addCommonOptions, mergeParentOptions } from "./shared-options.js"; -import { configureConsoleForHeadless } from "./util/consoleOverride.js"; import { logger } from "./util/logger.js"; import { readStdinSync } from "./util/stdin.js"; import { getVersion } from "./version.js"; @@ -139,13 +142,13 @@ addCommonOptions(program) // In headless mode, ensure we have a prompt if (options.print && !prompt) { - console.error( - "Error: A prompt is required when using the -p/--print flag.\n", + safeStderr( + "Error: A prompt is required when using the -p/--print flag.\n\n", ); - console.error("Usage examples:"); - console.error(' cn -p "please review my current git diff"'); - console.error(' echo "hello" | cn -p'); - console.error(' cn -p "analyze the code in src/"'); + safeStderr("Usage examples:\n"); + safeStderr(' cn -p "please review my current git diff"\n'); + safeStderr(' echo "hello" | cn -p\n'); + safeStderr(' cn -p "analyze the code in src/"\n'); process.exit(1); } diff --git a/extensions/cli/src/init.ts b/extensions/cli/src/init.ts new file mode 100644 index 000000000..47766c0bb --- /dev/null +++ b/extensions/cli/src/init.ts @@ -0,0 +1,128 @@ +/** + * Early initialization that must happen before ANY other imports + * This file intercepts console and stdout/stderr to prevent dependency logging + */ + +// Check if we're in headless mode by looking at process arguments +// We need to do this before any imports to catch early logging +const args = process.argv.slice(2); +const isHeadlessMode = args.includes("-p") || args.includes("--print"); + +// Store original methods before ANY dependencies can use them +const originalStdoutWrite = process.stdout.write.bind(process.stdout); +const originalStderrWrite = process.stderr.write.bind(process.stderr); +const originalConsole = { + log: console.log, + info: console.info, + warn: console.warn, + error: console.error, + debug: console.debug, + trace: console.trace, + table: console.table, + dir: console.dir, + dirxml: console.dirxml, + group: console.group, + groupEnd: console.groupEnd, + groupCollapsed: console.groupCollapsed, + time: console.time, + timeEnd: console.timeEnd, + timeLog: console.timeLog, + clear: console.clear, + count: console.count, + countReset: console.countReset, + assert: console.assert, +}; + +// Track if we're inside our own code vs dependency code +let isHeadlessModeConfigured = false; + +// Override console methods if in headless mode +if (isHeadlessMode) { + // Override ALL console methods to no-ops + Object.keys(originalConsole).forEach((method) => { + (console as any)[method] = () => {}; + }); + + // Override stdout/stderr to block everything by default + process.stdout.write = function ( + chunk: any, + encoding?: any, + callback?: any, + ): boolean { + // Always return true to indicate success, but don't actually write + if (typeof encoding === "function") { + encoding(); + return true; + } + if (typeof callback === "function") { + callback(); + } + return true; + }; + + process.stderr.write = function ( + chunk: any, + encoding?: any, + callback?: any, + ): boolean { + // Always return true to indicate success, but don't actually write + if (typeof encoding === "function") { + encoding(); + return true; + } + if (typeof callback === "function") { + callback(); + } + return true; + }; +} + +/** + * Configure console for headless mode + * Since init.ts already blocks everything, this just tracks state + * and provides the safe output functions + */ +export function configureConsoleForHeadless(headless: boolean): void { + isHeadlessModeConfigured = headless; + + // init.ts should have already handled the blocking if in headless mode + // This function now mainly exists for compatibility and state tracking +} + +/** + * Safe stdout output that bypasses all overrides + * Use this for intentional output in headless mode + */ +export function safeStdout(message: string): void { + if (isHeadlessMode || isHeadlessModeConfigured) { + // Use the original stdout that was saved before any overrides + originalStdoutWrite(message); + } else { + // In non-headless mode, just use normal stdout + process.stdout.write(message); + } +} + +/** + * Safe stderr output that bypasses all overrides + * Use this for error messages that should always be visible + */ +export function safeStderr(message: string): void { + if (isHeadlessMode || isHeadlessModeConfigured) { + // Use the original stderr that was saved before any overrides + originalStderrWrite(message); + } else { + // In non-headless mode, just use normal stderr + process.stderr.write(message); + } +} + +/** + * Reset console overrides to original state + * Note: This won't affect init.ts overrides which happen at module load + */ +export function resetConsoleOverrides(): void { + isHeadlessModeConfigured = false; + // The actual console restoration would need to happen in init.ts + // This is mainly for testing purposes +} diff --git a/extensions/cli/src/integration/rule-duplication.test.ts b/extensions/cli/src/integration/rule-duplication.test.ts new file mode 100644 index 000000000..e68a3eff9 --- /dev/null +++ b/extensions/cli/src/integration/rule-duplication.test.ts @@ -0,0 +1,107 @@ +import { AssistantUnrolled } from "@continuedev/config-yaml"; +import { describe, expect, it, vi } from "vitest"; + +import { BaseCommandOptions } from "../commands/BaseCommandOptions.js"; +import { ConfigEnhancer } from "../configEnhancer.js"; + +// Mock the processRule function to avoid network calls +vi.mock("../hubLoader.js", () => ({ + processRule: vi.fn((rule: string) => { + // Simulate hub slug loading - return content for hub slugs + if (rule.includes("/") && !rule.startsWith(".") && !rule.startsWith("/")) { + return Promise.resolve(`Content for ${rule}`); + } + // Return as-is for direct content + return Promise.resolve(rule); + }), + loadPackagesFromHub: vi.fn(() => Promise.resolve([])), + mcpProcessor: {}, + modelProcessor: {}, +})); + +describe("Rule duplication integration test", () => { + it("should not duplicate rules when using --rule flag", async () => { + const enhancer = new ConfigEnhancer(); + + // Initial config without any rules + const initialConfig: AssistantUnrolled = { + name: "Test Assistant", + rules: [], + } as any; + + // Simulate command-line options with --rule flag + const options: BaseCommandOptions = { + rule: ["nate/spanish"], + }; + + // Enhance config with command-line rules + const enhancedConfig = await enhancer.enhanceConfig(initialConfig, options); + + // Verify the rule was added exactly once as a RuleObject + expect(enhancedConfig.rules).toHaveLength(1); + expect(enhancedConfig.rules).toEqual([ + { name: "nate/spanish", rule: "Content for nate/spanish" }, + ]); + }); + + it("should merge command-line rules with existing config rules", async () => { + const enhancer = new ConfigEnhancer(); + + // Initial config with existing rules + const initialConfig: AssistantUnrolled = { + name: "Test Assistant", + rules: ["existing-rule"], + } as any; + + // Simulate command-line options with --rule flag + const options: BaseCommandOptions = { + rule: ["nate/spanish", "direct-rule"], + }; + + // Enhance config with command-line rules + const enhancedConfig = await enhancer.enhanceConfig(initialConfig, options); + + // Verify all rules are present without duplication + expect(enhancedConfig.rules).toHaveLength(3); + expect(enhancedConfig.rules).toEqual([ + "existing-rule", + { name: "nate/spanish", rule: "Content for nate/spanish" }, + "direct-rule", + ]); + }); + + it("should handle rule content with frontmatter", async () => { + const enhancer = new ConfigEnhancer(); + + // Mock processRule to return content with frontmatter + const { processRule } = await import("../hubLoader.js"); + (processRule as any).mockImplementation((rule: string) => { + if (rule === "nate/spanish") { + return Promise.resolve(`--- +alwaysApply: true +--- + +Always respond in Spanish.`); + } + return Promise.resolve(rule); + }); + + const initialConfig: AssistantUnrolled = { + name: "Test Assistant", + rules: [], + } as any; + + const options: BaseCommandOptions = { + rule: ["nate/spanish"], + }; + + const enhancedConfig = await enhancer.enhanceConfig(initialConfig, options); + + // Hub rules should be stored as RuleObject with name and content + expect(enhancedConfig.rules).toHaveLength(1); + const ruleObj = enhancedConfig.rules?.[0] as any; + expect(ruleObj.name).toBe("nate/spanish"); + expect(ruleObj.rule).toContain("Always respond in Spanish."); + expect(ruleObj.rule).toContain("alwaysApply: true"); + }); +}); diff --git a/extensions/cli/src/loadMcpFromHub.test.ts b/extensions/cli/src/loadMcpFromHub.test.ts new file mode 100644 index 000000000..92dd69cf8 --- /dev/null +++ b/extensions/cli/src/loadMcpFromHub.test.ts @@ -0,0 +1,106 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + +import { loadMcpFromHub } from "./args.js"; + +// Store original fetch to restore later +const originalFetch = global.fetch; +const mockFetch = vi.fn(); + +// Mock JSZip +vi.mock("jszip", () => { + const MockJSZip = vi.fn(); + MockJSZip.prototype.loadAsync = vi.fn(); + return { default: MockJSZip }; +}); + +describe("loadMcpFromHub", () => { + let mockJSZip: any; + + beforeEach(async () => { + vi.clearAllMocks(); + // Set mock fetch for each test + global.fetch = mockFetch; + + // Get the mocked JSZip constructor + const JSZip = (await import("jszip")).default; + mockJSZip = new JSZip(); + }); + + afterEach(() => { + // Restore original fetch after each test + global.fetch = originalFetch; + }); + + it("should validate slug format", async () => { + await expect(loadMcpFromHub("invalid-slug")).rejects.toThrow( + 'Invalid hub slug format. Expected "owner/package", got: invalid-slug', + ); + }); + + it("should handle HTTP errors", async () => { + mockFetch.mockResolvedValueOnce({ + ok: false, + status: 404, + statusText: "Not Found", + }); + + await expect(loadMcpFromHub("continuedev/nonexistent-mcp")).rejects.toThrow( + 'Failed to load mcp from hub "continuedev/nonexistent-mcp": HTTP 404: Not Found', + ); + }); + + it("should handle network errors", async () => { + mockFetch.mockRejectedValueOnce(new Error("Network error")); + + await expect(loadMcpFromHub("continuedev/test-mcp")).rejects.toThrow( + 'Failed to load mcp from hub "continuedev/test-mcp": Network error', + ); + }); + + it("should parse JSON configuration files", async () => { + const mockConfig = { + content: + "name: test-mcp\ncommand: npx test-mcp\nargs:\n - --port\n - 3000", + }; + + // MCP packages now use the registry endpoint and return JSON directly + mockFetch.mockResolvedValueOnce({ + ok: true, + json: vi.fn().mockResolvedValue(mockConfig), + }); + + const result = await loadMcpFromHub("continuedev/test-mcp"); + // Should now parse the YAML content and return the parsed object + expect(result).toEqual({ + name: "test-mcp", + command: "npx test-mcp", + args: ["--port", 3000], + }); + }); + + it("should handle missing configuration files", async () => { + // MCP packages now use the registry endpoint + // If the content field is missing or empty, it should fail + mockFetch.mockResolvedValueOnce({ + ok: true, + json: vi.fn().mockResolvedValue({}), + }); + + const result = await loadMcpFromHub("continuedev/no-config"); + // The registry endpoint might return an empty object if no config exists + expect(result).toEqual({}); + }); + + it("should handle invalid JSON configuration", async () => { + // MCP packages now use the registry endpoint + // If the registry returns invalid JSON, it should fail at the fetch level + mockFetch.mockResolvedValueOnce({ + ok: true, + json: vi.fn().mockRejectedValue(new Error("Invalid JSON")), + }); + + await expect(loadMcpFromHub("continuedev/invalid-json")).rejects.toThrow( + 'Failed to load mcp from hub "continuedev/invalid-json": Invalid JSON', + ); + }); +}); diff --git a/extensions/cli/src/mcp-flag.integration.test.ts b/extensions/cli/src/mcp-flag.integration.test.ts new file mode 100644 index 000000000..a040c45b4 --- /dev/null +++ b/extensions/cli/src/mcp-flag.integration.test.ts @@ -0,0 +1,92 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +import { parseArgs, loadMcpFromHub } from "./args.js"; + +// Integration test to demonstrate the --mcp flag functionality +describe("--mcp flag integration", () => { + beforeEach(() => { + // Clear process.argv before each test + process.argv = ["node", "test"]; + vi.clearAllMocks(); + }); + + it("should demonstrate the complete --mcp flag functionality", () => { + // Test command line parsing + process.argv = [ + "node", + "test", + "--config", + "my-config.yaml", + "--mcp", + "continuedev/filesystem", + "--mcp", + "continuedev/github", + "hello world", + ]; + + const args = parseArgs(); + + // Verify the parsed command line arguments + expect(args).toEqual({ + configPath: "my-config.yaml", + mcps: ["continuedev/filesystem", "continuedev/github"], + prompt: "hello world", + }); + + // Verify MCP slugs are properly captured + expect(args.mcps).toHaveLength(2); + expect(args.mcps).toContain("continuedev/filesystem"); + expect(args.mcps).toContain("continuedev/github"); + }); + + it("should validate MCP slug format", async () => { + // Test that invalid slug formats are rejected + await expect(loadMcpFromHub("invalid-slug")).rejects.toThrow( + 'Invalid hub slug format. Expected "owner/package", got: invalid-slug', + ); + + // Valid format should not throw during validation step + const mockFetch = vi.fn().mockResolvedValue({ + ok: false, + status: 404, + statusText: "Not Found", + }); + global.fetch = mockFetch; + + // This will fail at the HTTP level, not validation level + await expect(loadMcpFromHub("valid/slug")).rejects.toThrow( + 'Failed to load mcp from hub "valid/slug": HTTP 404: Not Found', + ); + }); + + it("should demonstrate MCP flag with other command line options", () => { + process.argv = [ + "node", + "test", + "--config", + "test-config.yaml", + "--org", + "my-org", + "--rule", + "my-rule", + "--mcp", + "continuedev/filesystem", + "--allow", + "readFile", + "--readonly", + "analyze this code", + ]; + + const args = parseArgs(); + + // Verify all flags are parsed correctly together + expect(args).toEqual({ + configPath: "test-config.yaml", + organizationSlug: "my-org", + rules: ["my-rule"], + mcps: ["continuedev/filesystem"], + readonly: true, + prompt: "analyze this code", + }); + }); +}); diff --git a/extensions/cli/src/onboarding.ts b/extensions/cli/src/onboarding.ts index 36240b9a9..7eb59d89a 100644 --- a/extensions/cli/src/onboarding.ts +++ b/extensions/cli/src/onboarding.ts @@ -7,7 +7,7 @@ import { DefaultApiInterface } from "@continuedev/sdk/dist/api/dist/index.js"; import chalk from "chalk"; import * as readlineSync from "readline-sync"; -import { processRule } from "./args.js"; +import { processPromptOrRule } from "./args.js"; import { AuthConfig, isAuthenticated, login } from "./auth/workos.js"; import { initialize } from "./config.js"; import { env } from "./env.js"; @@ -239,7 +239,7 @@ async function injectRulesIntoConfig( const processedRules: string[] = []; for (const ruleSpec of rules) { try { - const processedRule = await processRule(ruleSpec); + const processedRule = await processPromptOrRule(ruleSpec); processedRules.push(processedRule); } catch (error: any) { console.warn( @@ -257,16 +257,10 @@ async function injectRulesIntoConfig( // Clone the config to avoid mutating the original const modifiedConfig = { ...config }; - // Combine processed rules with existing system message if the config has one - const existingSystemMessage = (modifiedConfig as any).systemMessage || ""; - const rulesSection = processedRules.join("\n\n"); - - if (existingSystemMessage) { - (modifiedConfig as any).systemMessage = - `${existingSystemMessage}\n\n${rulesSection}`; - } else { - (modifiedConfig as any).systemMessage = rulesSection; - } + // Add processed rules to the config's rules array + // Each processed rule is a string, which is a valid Rule type + const existingRules = modifiedConfig.rules || []; + modifiedConfig.rules = [...existingRules, ...processedRules]; return modifiedConfig; } diff --git a/extensions/cli/src/sentry-profiling.ts b/extensions/cli/src/sentry-profiling.ts new file mode 100644 index 000000000..8a037a985 --- /dev/null +++ b/extensions/cli/src/sentry-profiling.ts @@ -0,0 +1,52 @@ +/** + * Optional profiling integration loader + * This module handles the optional @sentry/profiling-node dependency + * which contains native bindings and may not be available in all environments + */ + +let profilingIntegration: any = null; +let profilingLoadAttempted = false; + +/** + * Lazy load the profiling integration + */ +async function loadProfilingIntegration() { + if (profilingLoadAttempted) { + return profilingIntegration; + } + + profilingLoadAttempted = true; + + try { + // Try to load the native profiling module if available + const profilingModule = await import("@sentry/profiling-node"); + profilingIntegration = profilingModule.nodeProfilingIntegration; + } catch { + // Profiling module not available - this is fine, profiling is optional + // The CLI will work without it, just without performance profiling + } + + return profilingIntegration; +} + +/** + * Returns the profiling integration if available, or a no-op function + * Note: This is now async to handle lazy loading + */ +export async function getProfilingIntegration() { + const integration = await loadProfilingIntegration(); + if (integration) { + return integration(); + } + // Return empty object as a no-op integration + return {}; +} + +/** + * Check if profiling is available + * Note: This is now async to handle lazy loading + */ +export async function isProfilingAvailable(): Promise { + await loadProfilingIntegration(); + return profilingIntegration !== null; +} diff --git a/extensions/cli/src/sentry.ts b/extensions/cli/src/sentry.ts index 0028b9b1e..838d6c27d 100644 --- a/extensions/cli/src/sentry.ts +++ b/extensions/cli/src/sentry.ts @@ -1,6 +1,9 @@ import * as Sentry from "@sentry/node"; -import { nodeProfilingIntegration } from "@sentry/profiling-node"; +import { + getProfilingIntegration, + isProfilingAvailable, +} from "./sentry-profiling.js"; import { logger } from "./util/logger.js"; import { getVersion } from "./version.js"; @@ -45,12 +48,21 @@ class SentryService { }; } - private initialize() { + private async initialize() { if (this.initialized || !this.config.dsn) { return; } try { + const integrations = []; + const profilingIntegration = await getProfilingIntegration(); + if ( + profilingIntegration && + Object.keys(profilingIntegration).length > 0 + ) { + integrations.push(profilingIntegration); + } + Sentry.init({ dsn: this.config.dsn, environment: this.config.environment, @@ -58,7 +70,7 @@ class SentryService { sampleRate: this.config.sampleRate, profilesSampleRate: this.config.profilesSampleRate, tracesSampleRate: this.config.tracesSampleRate, - integrations: [nodeProfilingIntegration()], + integrations, beforeSend(event) { // Filter out certain error types if needed if (event.exception?.values?.[0]?.type === "AbortError") { @@ -72,6 +84,7 @@ class SentryService { logger.debug("Sentry initialized", { environment: this.config.environment, release: this.config.release, + profilingAvailable: await isProfilingAvailable(), }); } catch (error) { logger.error("Failed to initialize Sentry", error); diff --git a/extensions/cli/src/services/BaseService.ts b/extensions/cli/src/services/BaseService.ts index 4d4f88b84..90735cc93 100644 --- a/extensions/cli/src/services/BaseService.ts +++ b/extensions/cli/src/services/BaseService.ts @@ -27,14 +27,20 @@ export abstract class BaseService extends EventEmitter { * Public initialization method that wraps the implementation */ async initialize(...args: any[]): Promise { - logger.debug(`Initializing ${this.serviceName}`); + logger.debug(`Initializing ${this.serviceName}`, { + wasInitialized: this.isInitialized, + hadPreviousState: !!this.currentState, + }); this.emit("initializing"); try { const state = await this.doInitialize(...args); this.currentState = state; this.isInitialized = true; - logger.debug(`${this.serviceName} initialized successfully`); + logger.debug(`${this.serviceName} initialized successfully`, { + stateKeys: state ? Object.keys(state as any) : [], + isNowInitialized: this.isInitialized, + }); this.emit("initialized", state); return state; } catch (error: any) { diff --git a/extensions/cli/src/services/ConfigService.test.ts b/extensions/cli/src/services/ConfigService.test.ts index 19ba756e6..84d2ba5ae 100644 --- a/extensions/cli/src/services/ConfigService.test.ts +++ b/extensions/cli/src/services/ConfigService.test.ts @@ -1,13 +1,13 @@ -import { beforeEach, describe, expect, vi, test } from "vitest"; +import { beforeEach, describe, expect, test, vi } from "vitest"; // Mock modules vi.mock("../auth/workos.js"); vi.mock("../configLoader.js"); -vi.mock("../args.js"); +vi.mock("../configEnhancer.js"); vi.mock("./ServiceContainer.js"); -import * as args from "../args.js"; import * as workos from "../auth/workos.js"; +import { configEnhancer } from "../configEnhancer.js"; import * as configLoader from "../configLoader.js"; import { ConfigService } from "./ConfigService.js"; @@ -73,23 +73,30 @@ describe("ConfigService", () => { config: mockConfig as any, source: { type: "cli-flag", path: "/config.yaml" } as any, }); - vi.mocked(args.processRule).mockImplementation( - async (rule) => `Processed: ${rule}`, - ); + + const expectedConfig = { + ...mockConfig, + systemMessage: + "Test system message\n\nProcessed: rule1\n\nProcessed: rule2", + }; + + vi.mocked(configEnhancer.enhanceConfig).mockResolvedValue(expectedConfig); const state = await service.initialize( { accessToken: "token" } as any, "/config.yaml", "org-123", mockApiClient as any, - ["rule1", "rule2"], + { rule: ["rule1", "rule2"] }, ); - expect(state.config).toEqual({ - ...mockConfig, - systemMessage: - "Test system message\n\nProcessed: rule1\n\nProcessed: rule2", - }); + // Verify configEnhancer was called with the right parameters + expect(vi.mocked(configEnhancer.enhanceConfig)).toHaveBeenCalledWith( + mockConfig, + { rule: ["rule1", "rule2"] }, + ); + + expect(state.config).toEqual(expectedConfig); }); }); diff --git a/extensions/cli/src/services/ConfigService.ts b/extensions/cli/src/services/ConfigService.ts index c1fc706a9..149977edb 100644 --- a/extensions/cli/src/services/ConfigService.ts +++ b/extensions/cli/src/services/ConfigService.ts @@ -1,8 +1,8 @@ -import { AssistantUnrolled } from "@continuedev/config-yaml"; import { DefaultApiInterface } from "@continuedev/sdk/dist/api/dist/index.js"; -import { processRule } from "../args.js"; import { AuthConfig, loadAuthConfig } from "../auth/workos.js"; +import { BaseCommandOptions } from "../commands/BaseCommandOptions.js"; +import { configEnhancer } from "../configEnhancer.js"; import { logger } from "../util/logger.js"; import { BaseService, ServiceWithDependencies } from "./BaseService.js"; @@ -41,9 +41,9 @@ export class ConfigService async doInitialize( authConfig: AuthConfig, configPath: string | undefined, - organizationId: string | null, + _organizationId: string | null, apiClient: DefaultApiInterface, - rules?: string[], + injectedConfigOptions?: BaseCommandOptions, ): Promise { // Use the new streamlined config loader const { loadConfiguration } = await import("../configLoader.js"); @@ -51,9 +51,17 @@ export class ConfigService let config = result.config; - // Inject rules if provided - if (rules && rules.length > 0) { - config = await this.injectRulesIntoConfig(config, rules); + // Apply injected config if provided + if ( + injectedConfigOptions && + this.hasInjectedConfig(injectedConfigOptions) + ) { + config = await configEnhancer.enhanceConfig( + config, + injectedConfigOptions, + ); + + logger.debug("Applied injected configuration"); } // Config URI persistence is now handled by the streamlined loader @@ -72,9 +80,9 @@ export class ConfigService async switchConfig( newConfigPath: string, authConfig: AuthConfig, - organizationId: string | null, + _organizationId: string | null, apiClient: DefaultApiInterface, - rules?: string[], + injectedConfigOptions?: BaseCommandOptions, ): Promise { logger.debug("Switching configuration", { from: this.currentState.configPath, @@ -92,9 +100,17 @@ export class ConfigService let config = result.config; - // Inject rules if provided - if (rules && rules.length > 0) { - config = await this.injectRulesIntoConfig(config, rules); + // Apply injected config if provided + if ( + injectedConfigOptions && + this.hasInjectedConfig(injectedConfigOptions) + ) { + config = await configEnhancer.enhanceConfig( + config, + injectedConfigOptions, + ); + + logger.debug("Applied injected configuration"); } this.setState({ @@ -121,9 +137,9 @@ export class ConfigService */ async reload( authConfig: AuthConfig, - organizationId: string | null, + _organizationId: string | null, apiClient: DefaultApiInterface, - rules?: string[], + injectedConfigOptions?: BaseCommandOptions, ): Promise { if (!this.currentState.configPath) { throw new Error("No configuration path available for reload"); @@ -134,53 +150,22 @@ export class ConfigService return this.switchConfig( this.currentState.configPath, authConfig, - organizationId, + _organizationId, apiClient, - rules, + injectedConfigOptions, ); } /** - * Process rules and inject them into the assistant config + * Check if injected config options contain any config to inject */ - private async injectRulesIntoConfig( - config: AssistantUnrolled, - rules: string[], - ): Promise { - if (!rules || rules.length === 0) { - return config; - } - - const processedRules: string[] = []; - - for (const ruleSpec of rules) { - try { - const processedRule = await processRule(ruleSpec); - processedRules.push(processedRule); - } catch (error: any) { - logger.warn(`Failed to process rule "${ruleSpec}": ${error.message}`); - } - } - - if (processedRules.length === 0) { - return config; - } - - // Clone the config to avoid mutating the original - const modifiedConfig = { ...config }; - - // Combine processed rules with existing system message if the config has one - const existingSystemMessage = (modifiedConfig as any).systemMessage || ""; - const rulesSection = processedRules.join("\n\n"); - - if (existingSystemMessage) { - (modifiedConfig as any).systemMessage = - `${existingSystemMessage}\n\n${rulesSection}`; - } else { - (modifiedConfig as any).systemMessage = rulesSection; - } - - return modifiedConfig; + private hasInjectedConfig(options: BaseCommandOptions): boolean { + return !!( + (options.rule && options.rule.length > 0) || + (options.mcp && options.mcp.length > 0) || + (options.model && options.model.length > 0) || + (options.prompt && options.prompt.length > 0) + ); } /** diff --git a/extensions/cli/src/services/FileIndexService.ts b/extensions/cli/src/services/FileIndexService.ts index f294f2796..444799415 100644 --- a/extensions/cli/src/services/FileIndexService.ts +++ b/extensions/cli/src/services/FileIndexService.ts @@ -3,6 +3,7 @@ import { glob, GlobOptionsWithFileTypesFalse } from "glob"; import { FILE_IGNORE_PATTERNS, FILE_PATTERNS } from "../util/filePatterns.js"; import { getFileWatcher } from "../util/fileWatcher.js"; import { isGitRepo } from "../util/git.js"; +import { logger } from "../util/logger.js"; import { BaseService } from "./BaseService.js"; import { serviceContainer } from "./ServiceContainer.js"; @@ -88,7 +89,7 @@ export class FileIndexService extends BaseService { } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); - console.error("Error performing full file index:", error); + logger.error("Error performing full file index:", error); this.setState({ isIndexing: false, error: errorMessage }); } } @@ -103,7 +104,7 @@ export class FileIndexService extends BaseService { // and provides little value since files change less predictably const inGitRepo = isGitRepo(); if (!inGitRepo) { - console.log("Skipping file watcher: not in a git repository"); + logger.debug("Skipping file watcher: not in a git repository"); return; } @@ -153,13 +154,9 @@ export class FileIndexService extends BaseService { })); this.setState({ files }); - - console.log( - `File index updated: +${addedFiles.length} -${removedFiles.length} files`, - ); } } catch (error) { - console.error("Error handling file system change:", error); + logger.error("Error handling file system change:", error); const errorMessage = error instanceof Error ? error.message : String(error); this.setState({ error: errorMessage }); diff --git a/extensions/cli/src/services/ModelService.direct.test.ts b/extensions/cli/src/services/ModelService.direct.test.ts new file mode 100644 index 000000000..e50e0b9fe --- /dev/null +++ b/extensions/cli/src/services/ModelService.direct.test.ts @@ -0,0 +1,207 @@ +import { describe, it, expect, beforeEach } from "vitest"; + +import { ModelService } from "./ModelService.js"; + +describe("ModelService - Direct Testing", () => { + let modelService: ModelService; + + beforeEach(() => { + modelService = new ModelService(); + }); + + it("should throw 'ModelService not initialized' when switching without initialization", async () => { + // The service is created but not initialized (no assistant or authConfig) + expect(modelService.getCurrentModelIndex()).toBe(-1); + + // Try to switch model without initialization + try { + await modelService.switchModel(0); + // Should not reach here + expect(true).toBe(false); + } catch (error: any) { + // Should throw the specific error + expect(error.message).toBe( + "ModelService not initialized - assistant data missing", + ); + } + }); + + it("should handle model switching with null authConfig for non-proxy models", async () => { + // Initialize the service properly + const mockAssistant = { + name: "Test Assistant", + version: "1.0.0", + models: [ + { + name: "claude-3.5-sonnet", + provider: "anthropic", + model: "claude-3.5-sonnet", + apiKey: "test-anthropic-key", + roles: ["chat"], + }, + { + name: "GPT-4", + provider: "openai", + model: "gpt-4", + apiKey: "test-openai-key", + roles: ["chat"], + }, + ], + }; + + // Initialize with null authConfig - valid for non-proxy models + const initialState = await modelService.initialize( + mockAssistant as any, + null as any, + ); + + // Verify initialization succeeded with null authConfig + expect(initialState.assistant).toBe(mockAssistant); + expect(initialState.authConfig).toBe(null); + expect(initialState.model).toBeDefined(); + expect((initialState.model as any).name).toBe("claude-3.5-sonnet"); + + // Should be able to switch models even with null authConfig + const switchedState = await modelService.switchModel(1); + expect(switchedState.model).toBeDefined(); + expect((switchedState.model as any).name).toBe("GPT-4"); + expect(switchedState.assistant).toBe(mockAssistant); + expect(switchedState.authConfig).toBe(null); + + // Verify the model info + const modelInfo = modelService.getModelInfo(); + expect(modelInfo?.name).toBe("GPT-4"); + expect(modelInfo?.provider).toBe("openai"); + }); + + it("should successfully switch model after proper initialization", async () => { + // Initialize the service properly + const mockAssistant = { + name: "Test Assistant", + version: "1.0.0", + models: [ + { + name: "GPT-4", + provider: "openai", + model: "gpt-4", + apiKey: "test-key-1", + roles: ["chat"], + }, + { + name: "GPT-3.5", + provider: "openai", + model: "gpt-3.5-turbo", + apiKey: "test-key-2", + roles: ["chat"], + }, + ], + }; + + const mockAuthConfig = { + token: "test-token", + }; + + // Initialize the service (note: initialize calls doInitialize and sets the state) + const initialState = await modelService.initialize( + mockAssistant as any, + mockAuthConfig as any, + ); + + // Verify we have models and the first one is selected + const availableModels = modelService.getAvailableChatModels(); + expect(availableModels.length).toBe(2); + expect(initialState.model).toBeDefined(); + expect((initialState.model as any).name).toBe("GPT-4"); + + // Now switch should work + await modelService.switchModel(1); + expect(modelService.getCurrentModelIndex()).toBe(1); + + const modelInfo = modelService.getModelInfo(); + expect(modelInfo?.name).toBe("GPT-3.5"); + }); + + it("should handle switching to invalid model index", async () => { + // Initialize properly first + const mockAssistant = { + name: "Test Assistant", + version: "1.0.0", + models: [ + { + name: "GPT-4", + provider: "openai", + model: "gpt-4", + apiKey: "test-key", + }, + ], + }; + + const mockAuthConfig = { + token: "test-token", + }; + + await modelService.initialize(mockAssistant as any, mockAuthConfig as any); + + // Try to switch to invalid index + try { + await modelService.switchModel(5); // Only have 1 model at index 0 + expect(true).toBe(false); + } catch (error: any) { + expect(error.message).toContain("Invalid model index"); + } + }); + + it("should successfully switch model when service is properly initialized via container", async () => { + // This test simulates the fix where we ensure service is initialized before switching + const mockAssistant = { + name: "Test Assistant", + version: "1.0.0", + models: [ + { + name: "GPT-4", + provider: "openai", + model: "gpt-4", + apiKey: "test-key-1", + roles: ["chat"], + }, + { + name: "GPT-3.5", + provider: "openai", + model: "gpt-3.5-turbo", + apiKey: "test-key-2", + roles: ["chat"], + }, + ], + }; + + const mockAuthConfig = { + token: "test-token", + }; + + // Initialize the service properly through initialize method (which sets isInitialized) + await modelService.initialize(mockAssistant as any, mockAuthConfig as any); + + // Verify initialization + expect(modelService.isReady()).toBe(true); + expect(modelService.getCurrentModelIndex()).toBe(0); + + // Now switch should work and return success + const newState = await modelService.switchModel(1); + + // Verify switch was successful + expect(modelService.getCurrentModelIndex()).toBe(1); + expect(newState.model).toBeDefined(); + expect((newState.model as any).name).toBe("GPT-3.5"); + + // Get model info to verify success message data + const modelInfo = modelService.getModelInfo(); + expect(modelInfo).toEqual({ + provider: "openai", + name: "GPT-3.5", + }); + + // This is what the success message would use + const successMessage = `Switched to model: ${modelInfo?.provider}/${modelInfo?.name}`; + expect(successMessage).toBe("Switched to model: openai/GPT-3.5"); + }); +}); diff --git a/extensions/cli/src/services/ModelService.refactored.ts b/extensions/cli/src/services/ModelService.refactored.ts deleted file mode 100644 index debcde1c8..000000000 --- a/extensions/cli/src/services/ModelService.refactored.ts +++ /dev/null @@ -1,260 +0,0 @@ -import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml"; -import { constructLlmApi, LLMConfig } from "@continuedev/openai-adapters"; - -import { - AuthConfig, - getAccessToken, - getOrganizationId, - getModelName, -} from "../auth/workos.js"; -import { getLlmApi } from "../config.js"; -import { logger } from "../util/logger.js"; - -import { BaseService, ServiceWithDependencies } from "./BaseService.js"; -import { ModelServiceState } from "./types.js"; - -/** - * Service for managing LLM and model state - * Extends BaseService and implements ServiceWithDependencies - */ -export class ModelService - extends BaseService - implements ServiceWithDependencies -{ - private availableModels: ModelConfig[] = []; - private assistant: AssistantUnrolled | null = null; - private authConfig: AuthConfig | null = null; - - constructor() { - super("ModelService", { - llmApi: null, - model: null, - }); - } - - /** - * Declare dependencies on other services - */ - getDependencies(): string[] { - return ["auth", "config"]; - } - - /** - * Initialize the model service - */ - async doInitialize( - assistant: AssistantUnrolled, - authConfig: AuthConfig, - ): Promise { - this.assistant = assistant; - this.authConfig = authConfig; - this.availableModels = (assistant.models?.filter( - (model) => - model && (model.roles?.includes("chat") || model.roles === undefined), - ) || []) as ModelConfig[]; - - // Check if we have a persisted model name and use it if valid - const persistedModelName = getModelName(authConfig); - if (persistedModelName) { - const modelIndex = this.getModelIndexByName(persistedModelName); - if (modelIndex === -1) { - // Model name not found, use default model selection - const [llmApi, model] = getLlmApi(assistant, authConfig); - return { - llmApi, - model, - }; - } else { - // Use the persisted model - const state = await this.switchModel(modelIndex); - return state; - } - } else { - // Use default model selection - const [llmApi, model] = getLlmApi(assistant, authConfig); - return { - llmApi, - model, - }; - } - } - - /** - * Update the model based on new config or auth changes - */ - async update( - assistant: AssistantUnrolled, - authConfig: AuthConfig, - ): Promise { - logger.debug("Updating ModelService"); - - try { - this.assistant = assistant; - this.authConfig = authConfig; - this.availableModels = (assistant.models?.filter( - (model) => - model && (model.roles?.includes("chat") || model.roles === undefined), - ) || []) as ModelConfig[]; - - const [llmApi, model] = getLlmApi(assistant, authConfig); - - this.setState({ - llmApi, - model, - }); - - logger.debug("ModelService updated successfully", { - modelProvider: model.provider, - modelName: (model as any).name || "unnamed", - availableModels: this.availableModels.length, - }); - - return this.getState(); - } catch (error: any) { - logger.error("Failed to update ModelService:", error); - this.emit("error", error); - throw error; - } - } - - /** - * Override isReady to check for required state - */ - override isReady(): boolean { - return ( - super.isReady() && - this.currentState.llmApi !== null && - this.currentState.model !== null - ); - } - - /** - * Get model information for display - */ - getModelInfo(): { provider: string; name: string } | null { - if (!this.currentState.model) { - return null; - } - - return { - provider: this.currentState.model.provider, - name: (this.currentState.model as any).name || "unnamed", - }; - } - - /** - * Get list of available chat models - */ - getAvailableChatModels(): Array<{ - provider: string; - name: string; - index: number; - }> { - return this.availableModels.map((model, index) => ({ - provider: model.provider, - name: (model as any).name || (model as any).model || "unnamed", - index, - })); - } - - /** - * Switch to a different chat model by index - */ - async switchModel(modelIndex: number): Promise { - if (!this.assistant || !this.authConfig) { - throw new Error("ModelService not initialized"); - } - - if (modelIndex < 0 || modelIndex >= this.availableModels.length) { - throw new Error( - `Invalid model index: ${modelIndex}. Available models: 0-${this.availableModels.length - 1}`, - ); - } - - const selectedModel = this.availableModels[modelIndex]; - logger.debug("Switching to model", { - modelIndex, - provider: selectedModel.provider, - name: (selectedModel as any).name || "unnamed", - }); - - try { - const accessToken = getAccessToken(this.authConfig); - const organizationId = getOrganizationId(this.authConfig); - - const config: LLMConfig = - selectedModel.provider === "continue-proxy" - ? { - provider: selectedModel.provider, - requestOptions: selectedModel.requestOptions, - apiBase: selectedModel.apiBase, - apiKey: accessToken ?? undefined, - env: { - apiKeyLocation: (selectedModel as any).apiKeyLocation, - orgScopeId: organizationId, - proxyUrl: undefined, - }, - } - : { - provider: selectedModel.provider as any, - apiKey: selectedModel.apiKey, - apiBase: selectedModel.apiBase, - requestOptions: selectedModel.requestOptions, - env: selectedModel.env, - }; - - const llmApi = constructLlmApi(config); - - if (!llmApi) { - throw new Error("Failed to initialize LLM with selected model"); - } - - this.setState({ - llmApi, - model: selectedModel, - }); - - logger.debug("Model switched successfully", { - modelProvider: selectedModel.provider, - modelName: (selectedModel as any).name || "unnamed", - }); - - return this.getState(); - } catch (error: any) { - logger.error("Failed to switch model:", error); - this.emit("error", error); - throw error; - } - } - - /** - * Get current model index - */ - getCurrentModelIndex(): number { - if (!this.currentState.model) { - return -1; - } - - return this.availableModels.findIndex( - (model) => - model.provider === this.currentState.model?.provider && - (model as any).name === (this.currentState.model as any).name, - ); - } - - /** - * Get model index by name and provider - */ - getModelIndexByName(modelName: string, provider?: string): number { - return this.availableModels.findIndex((model) => { - const name = (model as any).name || (model as any).model; - const nameMatches = name === modelName; - - if (provider) { - return nameMatches && model.provider === provider; - } - - return nameMatches; - }); - } -} diff --git a/extensions/cli/src/services/ModelService.test.ts b/extensions/cli/src/services/ModelService.test.ts index 905e6c8c3..32932e4df 100644 --- a/extensions/cli/src/services/ModelService.test.ts +++ b/extensions/cli/src/services/ModelService.test.ts @@ -74,6 +74,8 @@ describe("ModelService", () => { expect(state).toEqual({ llmApi: mockLlmApi, model: mockAssistant.models![0], + assistant: mockAssistant, + authConfig: mockAuthConfig, }); }); @@ -135,6 +137,8 @@ describe("ModelService", () => { expect(state).toEqual({ llmApi: newLlmApi, model: newAssistant.models![0], + assistant: newAssistant, + authConfig: mockAuthConfig, }); }); }); @@ -157,6 +161,8 @@ describe("ModelService", () => { expect(state).toEqual({ llmApi: newLlmApi, model: mockAssistant.models![1], + assistant: mockAssistant, + authConfig: mockAuthConfig, }); expect(service.getState()).toEqual(state); }); diff --git a/extensions/cli/src/services/ModelService.ts b/extensions/cli/src/services/ModelService.ts index 5bbd1b70b..7b50a69e9 100644 --- a/extensions/cli/src/services/ModelService.ts +++ b/extensions/cli/src/services/ModelService.ts @@ -4,8 +4,8 @@ import { constructLlmApi, LLMConfig } from "@continuedev/openai-adapters"; import { AuthConfig, getAccessToken, - getOrganizationId, getModelName, + getOrganizationId, } from "../auth/workos.js"; import { getLlmApi } from "../config.js"; import { logger } from "../util/logger.js"; @@ -29,6 +29,8 @@ export class ModelService super("ModelService", { llmApi: null, model: null, + assistant: null, + authConfig: null, }); } @@ -46,6 +48,12 @@ export class ModelService assistant: AssistantUnrolled, authConfig: AuthConfig, ): Promise { + logger.debug("ModelService.doInitialize called", { + hasAssistant: !!assistant, + hasAuthConfig: !!authConfig, + assistantModelsCount: assistant?.models?.length || 0, + }); + this.assistant = assistant; this.authConfig = authConfig; this.availableModels = (assistant.models?.filter( @@ -56,18 +64,67 @@ export class ModelService // Check if we have a persisted model name and use it if valid const persistedModelName = getModelName(authConfig); if (persistedModelName) { - const modelIndex = this.getModelIndexByName(persistedModelName); + // During initialization, we need to check against availableModels directly + const modelIndex = this.availableModels.findIndex((model) => { + const name = (model as any).name || (model as any).model; + return name === persistedModelName; + }); if (modelIndex === -1) { // Model name not found, use default model selection const [llmApi, model] = getLlmApi(assistant, authConfig); return { llmApi, model, + assistant, + authConfig, }; } else { - // Use the persisted model - const state = await this.switchModel(modelIndex); - return state; + // Use the persisted model - but we need to handle initialization specially + // During init, currentState isn't set yet, so switchModel would fail + // Instead, we'll manually switch here + const selectedModel = this.availableModels[modelIndex]; + logger.debug("Using persisted model during initialization", { + modelIndex, + provider: selectedModel.provider, + name: (selectedModel as any).name || "unnamed", + }); + + const accessToken = getAccessToken(authConfig); + const organizationId = getOrganizationId(authConfig); + + const config: LLMConfig = + selectedModel.provider === "continue-proxy" + ? { + provider: selectedModel.provider, + requestOptions: selectedModel.requestOptions, + apiBase: selectedModel.apiBase, + apiKey: accessToken ?? undefined, + env: { + apiKeyLocation: (selectedModel as any).apiKeyLocation, + orgScopeId: organizationId, + proxyUrl: undefined, + }, + } + : { + provider: selectedModel.provider as any, + apiKey: selectedModel.apiKey, + apiBase: selectedModel.apiBase, + requestOptions: selectedModel.requestOptions, + env: selectedModel.env, + }; + + const llmApi = constructLlmApi(config); + + if (!llmApi) { + throw new Error("Failed to initialize LLM with persisted model"); + } + + return { + llmApi, + model: selectedModel, + assistant, + authConfig, + }; } } else { // Use default model selection @@ -75,6 +132,8 @@ export class ModelService return { llmApi, model, + assistant, + authConfig, }; } } @@ -89,6 +148,7 @@ export class ModelService logger.debug("Updating ModelService"); try { + // Update instance properties for backward compatibility this.assistant = assistant; this.authConfig = authConfig; this.availableModels = (assistant.models?.filter( @@ -98,9 +158,12 @@ export class ModelService const [llmApi, model] = getLlmApi(assistant, authConfig); + // Ensure state has all necessary data this.setState({ llmApi, model, + assistant, + authConfig, }); logger.debug("ModelService updated successfully", { @@ -150,7 +213,19 @@ export class ModelService name: string; index: number; }> { - return this.availableModels.map((model, index) => ({ + // Get assistant from state to ensure we have the latest data + const { assistant } = this.getState(); + if (!assistant || !assistant.models) { + return []; + } + + // Filter for chat models + const chatModels = (assistant.models.filter( + (model) => + model && (model.roles?.includes("chat") || model.roles === undefined), + ) || []) as ModelConfig[]; + + return chatModels.map((model, index) => ({ provider: model.provider, name: (model as any).name || (model as any).model || "unnamed", index, @@ -161,17 +236,51 @@ export class ModelService * Switch to a different chat model by index */ async switchModel(modelIndex: number): Promise { - if (!this.assistant || !this.authConfig) { - throw new Error("ModelService not initialized"); + // Get assistant and authConfig from state, but fall back to instance properties + // This is needed during initialization when state isn't set yet + const stateValues = this.getState(); + const assistant = stateValues.assistant || this.assistant; + const authConfig = stateValues.authConfig || this.authConfig; + + // Debug logging to understand the state + logger.debug("switchModel: Checking state", { + hasStateAssistant: !!stateValues.assistant, + hasStateAuthConfig: !!stateValues.authConfig, + hasInstanceAssistant: !!this.assistant, + hasInstanceAuthConfig: !!this.authConfig, + isInitialized: this.isReady(), + isReady: this.isReady(), + modelIndex, + }); + + if (!assistant) { + logger.error("switchModel: Missing assistant data", { + assistant: !!assistant, + authConfig: !!authConfig, + stateKeys: Object.keys(stateValues), + currentState: { + hasLlmApi: !!stateValues.llmApi, + hasModel: !!stateValues.model, + hasAssistant: !!stateValues.assistant, + hasAuthConfig: !!stateValues.authConfig, + }, + }); + throw new Error("ModelService not initialized - assistant data missing"); } - if (modelIndex < 0 || modelIndex >= this.availableModels.length) { + // Get available models from assistant in state + const availableModels = (assistant.models?.filter( + (model) => + model && (model.roles?.includes("chat") || model.roles === undefined), + ) || []) as ModelConfig[]; + + if (modelIndex < 0 || modelIndex >= availableModels.length) { throw new Error( - `Invalid model index: ${modelIndex}. Available models: 0-${this.availableModels.length - 1}`, + `Invalid model index: ${modelIndex}. Available models: 0-${availableModels.length - 1}`, ); } - const selectedModel = this.availableModels[modelIndex]; + const selectedModel = availableModels[modelIndex]; logger.debug("Switching to model", { modelIndex, provider: selectedModel.provider, @@ -179,8 +288,8 @@ export class ModelService }); try { - const accessToken = getAccessToken(this.authConfig); - const organizationId = getOrganizationId(this.authConfig); + const accessToken = getAccessToken(authConfig); + const organizationId = getOrganizationId(authConfig); const config: LLMConfig = selectedModel.provider === "continue-proxy" @@ -212,6 +321,8 @@ export class ModelService this.setState({ llmApi, model: selectedModel, + assistant, + authConfig, }); logger.debug("Model switched successfully", { @@ -231,14 +342,21 @@ export class ModelService * Get current model index */ getCurrentModelIndex(): number { - if (!this.currentState.model) { + const state = this.getState(); + if (!state.model || !state.assistant) { return -1; } - return this.availableModels.findIndex( + // Get available models from state + const availableModels = (state.assistant.models?.filter( (model) => - model.provider === this.currentState.model?.provider && - (model as any).name === (this.currentState.model as any).name, + model && (model.roles?.includes("chat") || model.roles === undefined), + ) || []) as ModelConfig[]; + + return availableModels.findIndex( + (model) => + model.provider === state.model?.provider && + (model as any).name === (state.model as any).name, ); } @@ -246,7 +364,18 @@ export class ModelService * Get model index by name and provider */ getModelIndexByName(modelName: string, provider?: string): number { - return this.availableModels.findIndex((model) => { + const state = this.getState(); + if (!state.assistant) { + return -1; + } + + // Get available models from state + const availableModels = (state.assistant.models?.filter( + (model) => + model && (model.roles?.includes("chat") || model.roles === undefined), + ) || []) as ModelConfig[]; + + return availableModels.findIndex((model) => { const name = (model as any).name || (model as any).model; const nameMatches = name === modelName; diff --git a/extensions/cli/src/services/ResourceMonitoringService.test.ts b/extensions/cli/src/services/ResourceMonitoringService.test.ts new file mode 100644 index 000000000..a0ef2017b --- /dev/null +++ b/extensions/cli/src/services/ResourceMonitoringService.test.ts @@ -0,0 +1,108 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + +import { ResourceMonitoringService } from "./ResourceMonitoringService.js"; + +// Mock the logger and BaseService +vi.mock("../util/logger.js", () => ({ + logger: { + debug: vi.fn(), + info: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + }, +})); + +vi.mock("./BaseService.js", () => ({ + BaseService: class MockBaseService { + logger = { + debug: vi.fn(), + info: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + }; + }, +})); + +describe("ResourceMonitoringService", () => { + let service: ResourceMonitoringService; + + beforeEach(async () => { + // Remove process event listeners to prevent interference + process.removeAllListeners("exit"); + process.removeAllListeners("SIGINT"); + process.removeAllListeners("SIGTERM"); + + service = new ResourceMonitoringService(); + await service.initialize(); + }); + + afterEach(async () => { + if (service) { + service.stopMonitoring(); // Ensure monitoring is stopped + await service.cleanup(); + } + }); + + it("should initialize without starting monitoring by default", () => { + expect(service).toBeDefined(); + // Should not be monitoring unless --verbose is passed + const usage = service.getCurrentResourceUsage(); + expect(usage.timestamp).toBeGreaterThan(0); + }); + + it("should collect current resource usage", () => { + const usage = service.getCurrentResourceUsage(); + + expect(usage.timestamp).toBeGreaterThan(0); + expect(usage.memory.rss).toBeGreaterThan(0); + expect(usage.memory.heapTotal).toBeGreaterThan(0); + expect(usage.memory.heapUsed).toBeGreaterThan(0); + expect(usage.cpu.user).toBeGreaterThanOrEqual(0); + expect(usage.cpu.system).toBeGreaterThanOrEqual(0); + expect(usage.system.uptime).toBeGreaterThan(0); + expect(usage.system.totalMemory).toBeGreaterThan(0); + expect(usage.eventLoop.lag).toBeGreaterThanOrEqual(0); + }); + + it("should provide resource summary", () => { + const summary = service.getResourceSummary(); + + expect(summary.current).toBeDefined(); + expect(summary.peak).toBeDefined(); + expect(summary.average).toBeDefined(); + + expect(summary.peak.memory).toBeGreaterThan(0); + expect(summary.peak.cpu).toBeGreaterThanOrEqual(0); + + expect(summary.average.memory).toBeGreaterThan(0); + expect(summary.average.cpu).toBeGreaterThanOrEqual(0); + }); + + it("should start and stop monitoring", async () => { + service.startMonitoring(100); // 100ms interval for test + + // Wait for some data collection + await new Promise((resolve) => setTimeout(resolve, 250)); + + const history = service.getResourceHistory(); + expect(history.length).toBeGreaterThan(0); + + service.stopMonitoring(); + }); + + it("should handle verbose mode initialization", async () => { + // Mock argv to include --verbose + const originalArgv = process.argv; + process.argv = [...originalArgv, "--verbose"]; + + const verboseService = new ResourceMonitoringService(); + await verboseService.initialize(); + + // Should start monitoring automatically + // Note: Testing this properly would require checking internal state + // which isn't directly exposed + + await verboseService.cleanup(); + process.argv = originalArgv; + }); +}); diff --git a/extensions/cli/src/services/ResourceMonitoringService.ts b/extensions/cli/src/services/ResourceMonitoringService.ts new file mode 100644 index 000000000..a114d3027 --- /dev/null +++ b/extensions/cli/src/services/ResourceMonitoringService.ts @@ -0,0 +1,312 @@ +import { exec } from "child_process"; +import * as os from "os"; +import { promisify } from "util"; + +import { logger } from "../util/logger.js"; + +const execAsync = promisify(exec); + +export interface ResourceUsage { + timestamp: number; + memory: { + rss: number; // Resident Set Size + heapTotal: number; + heapUsed: number; + external: number; + arrayBuffers: number; + }; + cpu: { + user: number; + system: number; + percent?: number; // CPU percentage (calculated) + }; + system: { + loadAverage: number[]; + uptime: number; + freeMemory: number; + totalMemory: number; + }; + eventLoop: { + lag: number; + }; + fileDescriptors?: number; +} + +export interface ResourceMonitoringState { + isMonitoring: boolean; + resourceHistory: ResourceUsage[]; +} + +class ResourceMonitoringService { + private isMonitoring = false; + private monitoringInterval?: NodeJS.Timeout; + private intervalMs = 1000; // Default 1 second + private resourceHistory: ResourceUsage[] = []; + private maxHistorySize = 300; // Keep 5 minutes at 1s intervals + private lastCpuUsage = process.cpuUsage(); + private lastTimestamp = Date.now(); + + async initialize(): Promise { + // Start monitoring if verbose mode is enabled + if (process.argv.includes("--verbose")) { + this.startMonitoring(); + } + + // Cleanup on exit + process.on("exit", () => this.cleanup()); + process.on("SIGINT", () => this.cleanup()); + process.on("SIGTERM", () => this.cleanup()); + } + + async cleanup(): Promise { + this.stopMonitoring(); + } + + public startMonitoring(intervalMs = 1000): void { + if (this.isMonitoring) return; + + this.intervalMs = intervalMs; + this.isMonitoring = true; + this.lastCpuUsage = process.cpuUsage(); + this.lastTimestamp = Date.now(); + + this.monitoringInterval = setInterval(() => { + this.collectResourceUsage(); + }, this.intervalMs); + + logger.debug("Resource monitoring started", { intervalMs }); + } + + public stopMonitoring(): void { + if (!this.isMonitoring) return; + + this.isMonitoring = false; + if (this.monitoringInterval) { + clearInterval(this.monitoringInterval); + this.monitoringInterval = undefined; + } + + logger.debug("Resource monitoring stopped"); + } + + public getCurrentResourceUsage(): ResourceUsage { + const now = Date.now(); + const currentCpuUsage = process.cpuUsage(); + const timeDiff = now - this.lastTimestamp; + + // Calculate CPU percentage + const userDiff = currentCpuUsage.user - this.lastCpuUsage.user; + const systemDiff = currentCpuUsage.system - this.lastCpuUsage.system; + const totalDiff = userDiff + systemDiff; + const cpuPercent = timeDiff > 0 ? (totalDiff / (timeDiff * 1000)) * 100 : 0; + + const memoryUsage = process.memoryUsage(); + + const usage: ResourceUsage = { + timestamp: now, + memory: { + rss: memoryUsage.rss, + heapTotal: memoryUsage.heapTotal, + heapUsed: memoryUsage.heapUsed, + external: memoryUsage.external, + arrayBuffers: memoryUsage.arrayBuffers, + }, + cpu: { + user: currentCpuUsage.user, + system: currentCpuUsage.system, + percent: Math.min(cpuPercent, 100), // Cap at 100% + }, + system: { + loadAverage: this.getLoadAverage(), + uptime: this.getProcessUptime(), + freeMemory: this.getFreeMemory(), + totalMemory: this.getTotalMemory(), + }, + eventLoop: { + lag: this.measureEventLoopLag(), + }, + }; + + // Try to get file descriptor count (Unix only) + this.getFileDescriptorCount() + .then((count) => { + if (count !== null) { + usage.fileDescriptors = count; + } + }) + .catch(() => { + // Ignore errors for file descriptor counting + }); + + return usage; + } + + public getResourceHistory(): ResourceUsage[] { + return [...this.resourceHistory]; + } + + public getResourceSummary(): { + current: ResourceUsage; + peak: { + memory: number; + cpu: number; + }; + average: { + memory: number; + cpu: number; + }; + } { + const current = this.getCurrentResourceUsage(); + + if (this.resourceHistory.length === 0) { + return { + current, + peak: { + memory: current.memory.rss, + cpu: current.cpu.percent || 0, + }, + average: { + memory: current.memory.rss, + cpu: current.cpu.percent || 0, + }, + }; + } + + const peakMemory = Math.max( + ...this.resourceHistory.map((r) => r.memory.rss), + ); + const peakCpu = Math.max( + ...this.resourceHistory.map((r) => r.cpu.percent || 0), + ); + + const avgMemory = + this.resourceHistory.reduce((sum, r) => sum + r.memory.rss, 0) / + this.resourceHistory.length; + const avgCpu = + this.resourceHistory.reduce((sum, r) => sum + (r.cpu.percent || 0), 0) / + this.resourceHistory.length; + + return { + current, + peak: { + memory: Math.max(peakMemory, current.memory.rss), + cpu: Math.max(peakCpu, current.cpu.percent || 0), + }, + average: { + memory: avgMemory, + cpu: avgCpu, + }, + }; + } + + private collectResourceUsage(): void { + try { + const usage = this.getCurrentResourceUsage(); + + // Update for next CPU calculation + this.lastCpuUsage = process.cpuUsage(); + this.lastTimestamp = usage.timestamp; + + // Add to history + this.resourceHistory.push(usage); + + // Trim history if too large + if (this.resourceHistory.length > this.maxHistorySize) { + this.resourceHistory = this.resourceHistory.slice(-this.maxHistorySize); + } + + // Check for potential issues and log warnings + this.checkResourceThresholds(usage); + } catch (error) { + logger.error("Error collecting resource usage", error); + } + } + + private checkResourceThresholds(usage: ResourceUsage): void { + const memoryUsageMB = usage.memory.rss / 1024 / 1024; + const cpuPercent = usage.cpu.percent || 0; + + // Memory threshold: 500MB + if (memoryUsageMB > 500) { + logger.warn("High memory usage detected", { + memoryMB: Math.round(memoryUsageMB), + threshold: 500, + }); + } + + // CPU threshold: 80% + if (cpuPercent > 80) { + logger.warn("High CPU usage detected", { + cpuPercent: Math.round(cpuPercent), + threshold: 80, + }); + } + + // Event loop lag threshold: 100ms + if (usage.eventLoop.lag > 100) { + logger.warn("High event loop lag detected", { + lagMs: Math.round(usage.eventLoop.lag), + threshold: 100, + }); + } + } + + private async getFileDescriptorCount(): Promise { + if (process.platform === "win32") { + return null; // Not supported on Windows + } + + try { + const { stdout } = await execAsync(`lsof -p ${process.pid} | wc -l`); + return parseInt(stdout.trim(), 10) - 1; // Subtract 1 for header line + } catch { + return null; + } + } + + private getLoadAverage(): number[] { + try { + return process.platform === "win32" ? [0, 0, 0] : os.loadavg(); + } catch { + return [0, 0, 0]; + } + } + + private getProcessUptime(): number { + try { + return typeof process.uptime === "function" ? process.uptime() : 0; + } catch { + return 0; + } + } + + private getFreeMemory(): number { + try { + return os.freemem(); + } catch { + return 0; + } + } + + private getTotalMemory(): number { + try { + return os.totalmem(); + } catch { + return 1024 * 1024 * 1024; // 1GB default fallback + } + } + + // Synchronous approximation of event loop lag + private measureEventLoopLag(): number { + // Return a simple approximation based on load average on Unix systems + const loadAvg = this.getLoadAverage(); + if (loadAvg[0] > 0) { + // Rough approximation: higher load = higher lag + return Math.min(loadAvg[0] * 10, 200); // Cap at 200ms + } + + return 0; + } +} + +export { ResourceMonitoringService }; diff --git a/extensions/cli/src/services/index.ts b/extensions/cli/src/services/index.ts index d1572c7d4..81b1e7318 100644 --- a/extensions/cli/src/services/index.ts +++ b/extensions/cli/src/services/index.ts @@ -9,6 +9,7 @@ import { FileIndexService } from "./FileIndexService.js"; import { MCPService } from "./MCPService.js"; import { ModelService } from "./ModelService.js"; import { modeService } from "./ModeService.js"; +import { ResourceMonitoringService } from "./ResourceMonitoringService.js"; import { serviceContainer } from "./ServiceContainer.js"; import { ApiClientServiceState, @@ -26,33 +27,35 @@ const modelService = new ModelService(); const apiClientService = new ApiClientService(); const mcpService = new MCPService(); const fileIndexService = new FileIndexService(); +const resourceMonitoringService = new ResourceMonitoringService(); /** * Initialize all services and register them with the service container * Handles onboarding internally for TUI mode unless skipOnboarding is true */ export async function initializeServices( - options: ServiceInitOptions = {}, + initOptions: ServiceInitOptions = {}, ): Promise { logger.debug("Initializing service registry"); let wasOnboarded = false; + const commandOptions = initOptions.options || {}; // Handle onboarding for TUI mode (headless: false) unless explicitly skipped - if (!options.headless && !options.skipOnboarding) { + if (!initOptions.headless && !initOptions.skipOnboarding) { const authConfig = loadAuthConfig(); const onboardingResult = await initializeWithOnboarding( authConfig, - options.configPath, - options.rules, + commandOptions.config, + commandOptions.rule, ); wasOnboarded = onboardingResult.wasOnboarded; } // Handle ANTHROPIC_API_KEY in headless mode when no config path is provided if ( - options.headless && - !options.configPath && + initOptions.headless && + !commandOptions.config && process.env.ANTHROPIC_API_KEY ) { const { createOrUpdateConfig } = await import("../onboarding.js"); @@ -63,19 +66,19 @@ export async function initializeServices( await createOrUpdateConfig(process.env.ANTHROPIC_API_KEY); // Update options to use the created config - options.configPath = CONFIG_PATH; + commandOptions.config = CONFIG_PATH; } // Initialize mode service with tool permission overrides - if (options.toolPermissionOverrides) { - const overrides = { ...options.toolPermissionOverrides }; + if (initOptions.toolPermissionOverrides) { + const overrides = { ...initOptions.toolPermissionOverrides }; // Convert mode to boolean flags for ModeService const initArgs: Parameters[0] = { allow: overrides.allow, ask: overrides.ask, exclude: overrides.exclude, - isHeadless: options.headless, + isHeadless: initOptions.headless, }; // Only set the boolean flag that corresponds to the mode @@ -90,7 +93,7 @@ export async function initializeServices( } else { // Even if no overrides, we need to initialize with defaults await modeService.initialize({ - isHeadless: options.headless, + isHeadless: initOptions.headless, }); } @@ -137,8 +140,8 @@ export async function initializeServices( let finalAuthState = authState; if (authState.authConfig) { finalAuthState = await authService.ensureOrganization( - options.headless ?? false, - options.organizationSlug, + initOptions.headless ?? false, + commandOptions.org, ); // Update the auth service state in container serviceContainer.set(SERVICE_NAMES.AUTH, finalAuthState); @@ -149,11 +152,11 @@ export async function initializeServices( } // Use current config path from ConfigService state if available (for reloads), - // otherwise use initial options.configPath (for first initialization) + // otherwise use initial options.config (for first initialization) // IMPORTANT: Always prefer explicit --config flag over saved state const currentState = configService.getState(); let configPath = - options.configPath || + commandOptions.config || (currentState.configPath === undefined ? undefined : currentState.configPath); @@ -175,7 +178,7 @@ export async function initializeServices( configPath, finalAuthState.organizationId || null, apiClientState.apiClient, - options.rules, + commandOptions, ); }, [SERVICE_NAMES.AUTH, SERVICE_NAMES.API_CLIENT], // Depends on auth and API client @@ -208,7 +211,7 @@ export async function initializeServices( if (!configState.config) { throw new Error("Config not available for MCP service"); } - return mcpService.initialize(configState.config, options.headless); + return mcpService.initialize(configState.config, initOptions.headless); }, [SERVICE_NAMES.CONFIG], // Depends on config ); @@ -219,6 +222,12 @@ export async function initializeServices( [], ); + serviceContainer.register( + SERVICE_NAMES.RESOURCE_MONITORING, + () => resourceMonitoringService.initialize(), + [], + ); + // Eagerly initialize all services to ensure they're ready when needed // This avoids race conditions and "service not ready" errors await serviceContainer.initializeAll(); @@ -261,6 +270,7 @@ export function areServicesReady(): boolean { SERVICE_NAMES.MODEL, SERVICE_NAMES.MCP, SERVICE_NAMES.FILE_INDEX, + SERVICE_NAMES.RESOURCE_MONITORING, ].every((name) => serviceContainer.isReady(name)); } @@ -282,6 +292,7 @@ export const services = { mcp: mcpService, fileIndex: fileIndexService, mode: modeService, + resourceMonitoring: resourceMonitoringService, } as const; // Export the service container for advanced usage diff --git a/extensions/cli/src/services/types.ts b/extensions/cli/src/services/types.ts index 45d0a4599..112611eff 100644 --- a/extensions/cli/src/services/types.ts +++ b/extensions/cli/src/services/types.ts @@ -5,6 +5,7 @@ import { DefaultApiInterface } from "@continuedev/sdk/dist/api/dist/index.js"; import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { AuthConfig } from "../auth/workos.js"; +import { BaseCommandOptions } from "../commands/BaseCommandOptions.js"; import { PermissionMode, ToolPermissions } from "../permissions/types.js"; import { MCPService } from "./MCPService.js"; @@ -51,6 +52,8 @@ export interface ConfigServiceState { export interface ModelServiceState { llmApi: BaseLlmApi | null; model: ModelConfig | null; + assistant: AssistantUnrolled | null; + authConfig: AuthConfig | null; } export type MCPServerStatus = "idle" | "connecting" | "connected" | "error"; @@ -102,15 +105,14 @@ export const SERVICE_NAMES = { API_CLIENT: "apiClient", TOOL_PERMISSIONS: "toolPermissions", FILE_INDEX: "fileIndex", + RESOURCE_MONITORING: "resourceMonitoring", } as const; /** * Service initialization options */ export interface ServiceInitOptions { - configPath?: string; - organizationSlug?: string; // Organization slug to use for this session - rules?: string[]; + options?: BaseCommandOptions; // Command-line options headless?: boolean; skipOnboarding?: boolean; // Skip onboarding check even in TUI mode toolPermissionOverrides?: { diff --git a/extensions/cli/src/session.ts b/extensions/cli/src/session.ts index f843218a6..11e39ccc7 100644 --- a/extensions/cli/src/session.ts +++ b/extensions/cli/src/session.ts @@ -180,7 +180,7 @@ function getSessionDir(): string { /** * Get the session file path for the current session */ -function getSessionFilePath(): string { +export function getSessionFilePath(): string { const sessionId = getSessionId(); const sessionDir = getSessionDir(); return path.join(sessionDir, `${sessionId}.json`); diff --git a/extensions/cli/src/shared-options.ts b/extensions/cli/src/shared-options.ts index 6a68f29b1..9f220aa36 100644 --- a/extensions/cli/src/shared-options.ts +++ b/extensions/cli/src/shared-options.ts @@ -24,6 +24,36 @@ export function addCommonOptions(command: Command): Command { }, [] as string[], ) + .option( + "--mcp ", + "Add an MCP server from the hub (slug in format 'owner/package'). Can be specified multiple times.", + (value: string, previous: string[] | undefined) => { + const array = Array.isArray(previous) ? previous : []; + array.push(value); + return array; + }, + [] as string[], + ) + .option( + "--model ", + "Add a model from the hub (slug in format 'owner/package'). Can be specified multiple times.", + (value: string, previous: string[] | undefined) => { + const array = Array.isArray(previous) ? previous : []; + array.push(value); + return array; + }, + [] as string[], + ) + .option( + "--prompt ", + "Add to the initial user message (can be a file path, hub slug, or string content). Can be specified multiple times.", + (value: string, previous: string[] | undefined) => { + const array = Array.isArray(previous) ? previous : []; + array.push(value); + return array; + }, + [] as string[], + ) .option( "--allow ", "Allow specified tool (overrides default policies). Can be specified multiple times.", @@ -70,6 +100,9 @@ export function mergeParentOptions(parentCommand: Command, options: any): any { "tools", "verbose", "rule", + "mcp", + "model", + "prompt", "allow", "ask", "exclude", diff --git a/extensions/cli/src/slashCommands.test.ts b/extensions/cli/src/slashCommands.test.ts index edb56d844..50185cf33 100644 --- a/extensions/cli/src/slashCommands.test.ts +++ b/extensions/cli/src/slashCommands.test.ts @@ -1,155 +1,231 @@ -// Import after mocking -import { AssistantUnrolled } from "@continuedev/config-yaml"; -import { afterEach, beforeEach, describe, expect, vi, test } from "vitest"; +import type { AssistantUnrolled } from "@continuedev/config-yaml"; +import { + describe, + it, + expect, + vi, + beforeEach, + type MockedFunction, +} from "vitest"; -import * as workos from "./auth/workos.js"; -import * as commands from "./commands/commands.js"; -import { reloadService, SERVICE_NAMES, services } from "./services/index.js"; -import type { AuthServiceState } from "./services/types.js"; +import type { AuthConfig, AuthenticatedConfig } from "./auth/workos.js"; +import type { ConfigServiceState } from "./services/types.js"; import { handleSlashCommands } from "./slashCommands.js"; -// The imports are already mocked via vitest.setup.ts, so we can use them directly +// Mock the services +vi.mock("./services/index.js", () => ({ + services: { + config: { + getState: vi.fn(), + }, + }, + reloadService: vi.fn(), + SERVICE_NAMES: { + AUTH: "AUTH", + }, +})); -// Mock console to avoid output during tests -const originalConsole = console; -const mockConsole = { - info: vi.fn(), - error: vi.fn(), - log: vi.fn(), -}; +// Mock auth functions +vi.mock("./auth/workos.js", () => ({ + isAuthenticated: vi.fn(), + isAuthenticatedConfig: vi.fn(), + loadAuthConfig: vi.fn(), +})); -describe("handleSlashCommands", () => { +// Mock telemetry +vi.mock("./telemetry/posthogService.js", () => ({ + posthogService: { + capture: vi.fn(), + }, +})); + +// Mock commands +vi.mock("./commands/commands.js", () => ({ + getAllSlashCommands: vi.fn(() => []), +})); + +// Mock os and path +vi.mock("os", () => ({ + default: { + homedir: vi.fn(() => "/home/test"), + }, +})); + +vi.mock("path", () => ({ + default: { + join: vi.fn((...parts) => parts.join("/")), + }, + join: vi.fn((...parts) => parts.join("/")), +})); + +// Mock session functions +vi.mock("./session.js", () => ({ + getSessionFilePath: vi.fn( + () => "/home/test/.continue/cli-sessions/continue-cli-pid-12345.json", + ), + hasSession: vi.fn(() => false), +})); + +describe("slashCommands", () => { const mockAssistant: AssistantUnrolled = { name: "test-assistant", version: "1.0.0", - prompts: [{ name: "test", prompt: "Test prompt: " }], }; beforeEach(() => { - Object.assign(console, mockConsole); vi.clearAllMocks(); - - // Since the mock already returns the required value, we don't need to set it - // Just verify it returns what we expect - expect(commands.getAllSlashCommands(mockAssistant)).toEqual( - expect.arrayContaining([ - expect.objectContaining({ name: "help" }), - expect.objectContaining({ name: "login" }), - ]), - ); }); - afterEach(() => { - Object.assign(console, originalConsole); - }); + describe("handleSlashCommands", () => { + it("should handle /info command when not authenticated", async () => { + const { isAuthenticated } = await import("./auth/workos.js"); + const { services } = await import("./services/index.js"); - describe("Automatic Service Cascade Reloading", () => { - test.skip("login command should trigger automatic cascade reload via auth service", async () => { - const newAuthState: AuthServiceState = { - authConfig: { userEmail: "test@example.com" } as any, - isAuthenticated: true, + ( + isAuthenticated as MockedFunction + ).mockReturnValue(false); + ( + services.config.getState as MockedFunction< + typeof services.config.getState + > + ).mockReturnValue({ + config: null, + configPath: "/test/config.yaml", + } as ConfigServiceState); + + const result = await handleSlashCommands("/info", mockAssistant); + + expect(result).toBeDefined(); + expect(result?.output).toContain("Authentication:"); + expect(result?.output).toContain("Not logged in"); + expect(result?.output).toContain("Configuration:"); + expect(result?.output).toContain("/test/config.yaml"); + expect(result?.output).toContain("Session History:"); + expect(result?.output).toContain(".json"); + expect(result?.exit).toBe(false); + }); + + it("should handle /info command when authenticated via environment", async () => { + const { isAuthenticated, loadAuthConfig, isAuthenticatedConfig } = + await import("./auth/workos.js"); + const { services } = await import("./services/index.js"); + + ( + isAuthenticated as MockedFunction + ).mockReturnValue(true); + (loadAuthConfig as MockedFunction).mockReturnValue( + {} as AuthConfig, + ); + (isAuthenticatedConfig as any).mockReturnValue(false); + ( + services.config.getState as MockedFunction< + typeof services.config.getState + > + ).mockReturnValue({ + config: null, + configPath: undefined, + } as ConfigServiceState); + + const result = await handleSlashCommands("/info", mockAssistant); + + expect(result).toBeDefined(); + expect(result?.output).toContain("Authentication:"); + expect(result?.output).toContain( + "Authenticated via environment variable", + ); + expect(result?.output).toContain("Configuration:"); + expect(result?.output).toContain("Config not found"); + expect(result?.exit).toBe(false); + }); + + it("should handle /info command when authenticated with user config", async () => { + const { isAuthenticated, loadAuthConfig, isAuthenticatedConfig } = + await import("./auth/workos.js"); + const { services } = await import("./services/index.js"); + + const mockAuthConfig: AuthenticatedConfig = { + userId: "test-user-id", + userEmail: "test@example.com", + accessToken: "test-token", + refreshToken: "test-refresh-token", + expiresAt: Date.now() + 3600000, + organizationId: "test-org-id", }; - (services.auth.login as any).mockResolvedValue(newAuthState); - (workos.isAuthenticatedConfig as any).mockReturnValue(true); - (reloadService as any).mockResolvedValue(undefined); + ( + isAuthenticated as MockedFunction + ).mockReturnValue(true); + (loadAuthConfig as MockedFunction).mockReturnValue( + mockAuthConfig, + ); + (isAuthenticatedConfig as any).mockReturnValue(true); + ( + services.config.getState as MockedFunction< + typeof services.config.getState + > + ).mockReturnValue({ + config: null, + configPath: "/custom/config.yaml", + } as ConfigServiceState); - const result = await handleSlashCommands("/login", mockAssistant); + const result = await handleSlashCommands("/info", mockAssistant); - expect(result).not.toBeNull(); - expect(result?.output).toContain( - "Login successful! All services updated automatically.", + expect(result).toBeDefined(); + expect(result?.output).toContain("Authentication:"); + expect(result?.output).toContain("test@example.com"); + expect(result?.output).toContain("(no org)"); + expect(result?.output).toContain("Configuration:"); + expect(result?.output).toContain("/custom/config.yaml"); + expect(result?.exit).toBe(false); + }); + + it("should handle config service errors gracefully", async () => { + const { isAuthenticated } = await import("./auth/workos.js"); + const { services } = await import("./services/index.js"); + + ( + isAuthenticated as MockedFunction + ).mockReturnValue(false); + ( + services.config.getState as MockedFunction< + typeof services.config.getState + > + ).mockImplementation(() => { + throw new Error("Service not ready"); + }); + + const result = await handleSlashCommands("/info", mockAssistant); + + expect(result).toBeDefined(); + expect(result?.output).toContain("Configuration service not available"); + }); + + it("should use test session directory when in test mode", async () => { + const { isAuthenticated } = await import("./auth/workos.js"); + const { services } = await import("./services/index.js"); + const { getSessionFilePath } = await import("./session.js"); + + // Mock the session path for this specific test + (getSessionFilePath as any).mockReturnValue( + "/test-home/.continue/cli-sessions/continue-cli-test-123.json", ); - // Verify auth service login was called - expect(services.auth.login).toHaveBeenCalledTimes(1); + ( + isAuthenticated as MockedFunction + ).mockReturnValue(false); + ( + services.config.getState as MockedFunction< + typeof services.config.getState + > + ).mockReturnValue({ + config: null, + configPath: undefined, + } as ConfigServiceState); - // Verify automatic cascade reload was triggered - only auth service reload needed - expect(reloadService).toHaveBeenCalledTimes(1); - expect(reloadService).toHaveBeenCalledWith(SERVICE_NAMES.AUTH); + const result = await handleSlashCommands("/info", mockAssistant); - // Verify manual service reloads are NOT called - expect(reloadService).not.toHaveBeenCalledWith(SERVICE_NAMES.API_CLIENT); - expect(reloadService).not.toHaveBeenCalledWith(SERVICE_NAMES.CONFIG); - }); - - test.skip("login failure should not trigger any reloads", async () => { - const loginError = new Error("Login failed"); - (services.auth.login as any).mockRejectedValue(loginError); - - const result = await handleSlashCommands("/login", mockAssistant); - - expect(result).not.toBeNull(); - expect(result?.output).toContain("Login failed: Login failed"); - - // Verify NO reload was triggered on failure - expect(reloadService).not.toHaveBeenCalled(); - }); - }); - - describe("Other Commands (unchanged behavior)", () => { - test("help command should work normally", async () => { - const result = await handleSlashCommands("/help", mockAssistant); - - expect(result).not.toBeNull(); - expect(result?.output).toContain("Slash commands:"); - expect(result?.output).toContain("/help: Show help"); - expect(result?.output).toContain("/login: Authenticate"); - }); - - test.skip("logout command should exit", async () => { - const logoutState: AuthServiceState = { - authConfig: null, - isAuthenticated: false, - }; - (services.auth.logout as any).mockResolvedValue(logoutState); - - const result = await handleSlashCommands("/logout", mockAssistant); - - expect(result).not.toBeNull(); - expect(result?.exit).toBe(true); - expect(result?.output).toContain("Logged out successfully"); - }); - - test("clear command should work normally", async () => { - const result = await handleSlashCommands("/clear", mockAssistant); - - expect(result).not.toBeNull(); - expect(result?.clear).toBe(true); - expect(result?.output).toBe("Chat history cleared"); - }); - - test("compact command should work normally", async () => { - const result = await handleSlashCommands("/compact", mockAssistant); - - expect(result).not.toBeNull(); - expect(result?.compact).toBe(true); - }); - - test("resume command should open session selector", async () => { - const result = await handleSlashCommands("/resume", mockAssistant); - - expect(result).not.toBeNull(); - expect(result?.openSessionSelector).toBe(true); - }); - - test("non-slash input should return null", async () => { - const result = await handleSlashCommands("regular input", mockAssistant); - expect(result).toBeNull(); - }); - - test("unknown slash command should return error", async () => { - const result = await handleSlashCommands("/unknown", mockAssistant); - - expect(result).not.toBeNull(); - expect(result?.output).toBe("Unknown command: unknown"); - }); - - test("/org command should no longer exist (now merged into /config)", async () => { - const result = await handleSlashCommands("/org list", mockAssistant); - - expect(result).not.toBeNull(); - expect(result?.output).toBe("Unknown command: org"); + expect(result?.output).toContain("/test-home/.continue/cli-sessions/"); + expect(result?.output).toContain(".json"); }); }); }); diff --git a/extensions/cli/src/slashCommands.ts b/extensions/cli/src/slashCommands.ts index daf8c4ff7..dc24c30bc 100644 --- a/extensions/cli/src/slashCommands.ts +++ b/extensions/cli/src/slashCommands.ts @@ -8,6 +8,7 @@ import { } from "./auth/workos.js"; import { getAllSlashCommands } from "./commands/commands.js"; import { reloadService, SERVICE_NAMES, services } from "./services/index.js"; +import { getSessionFilePath } from "./session.js"; import { posthogService } from "./telemetry/posthogService.js"; import { SlashCommandResult } from "./ui/hooks/useChat.types.js"; @@ -96,6 +97,63 @@ function handleWhoami() { } } +async function handleInfo() { + posthogService.capture("useSlashCommand", { name: "info" }); + + const infoLines = []; + + // Auth info + if (isAuthenticated()) { + const config = loadAuthConfig(); + if (config && isAuthenticatedConfig(config)) { + const email = config.userEmail || config.userId; + const org = "(no org)"; // Organization info not available in AuthenticatedConfig + infoLines.push(chalk.white("Authentication:")); + infoLines.push(` Email: ${chalk.green(email)}`); + infoLines.push(` Organization: ${chalk.cyan(org)}`); + } else { + infoLines.push(chalk.white("Authentication:")); + infoLines.push( + ` ${chalk.yellow("Authenticated via environment variable")}`, + ); + } + } else { + infoLines.push(chalk.white("Authentication:")); + infoLines.push(` ${chalk.red("Not logged in")}`); + } + + // Config info + try { + const configState = services.config.getState(); + infoLines.push(""); + infoLines.push(chalk.white("Configuration:")); + if (configState.config) { + infoLines.push(` ${chalk.gray(`Using ${configState.config?.name}`)}`); + } else { + infoLines.push(` ${chalk.red(`Config not found`)}`); + } + if (configState.configPath) { + infoLines.push(` Path: ${chalk.blue(configState.configPath)}`); + } + } catch { + infoLines.push(""); + infoLines.push(chalk.white("Configuration:")); + infoLines.push(` ${chalk.red("Configuration service not available")}`); + } + + // Session history path + infoLines.push(""); + infoLines.push(chalk.white("Session History:")); + const sessionFilePath = getSessionFilePath(); + + infoLines.push(` File: ${chalk.blue(sessionFilePath)}`); + + return { + exit: false, + output: infoLines.join("\n"), + }; +} + const commandHandlers: Record = { help: handleHelp, clear: () => { @@ -113,6 +171,7 @@ const commandHandlers: Record = { login: handleLogin, logout: handleLogout, whoami: handleWhoami, + info: handleInfo, model: () => ({ openModelSelector: true }), compact: () => { posthogService.capture("useSlashCommand", { name: "compact" }); @@ -163,5 +222,16 @@ export async function handleSlashCommands( return { newInput }; } + // Check if this command would match any available commands (same logic as UI) + const allCommands = getAllSlashCommands(assistant); + const hasMatches = allCommands.some((cmd) => + cmd.name.toLowerCase().includes(command.toLowerCase()), + ); + + // If no commands match, treat this as regular text instead of an unknown command + if (!hasMatches) { + return null; + } + return { output: `Unknown command: ${command}` }; } diff --git a/extensions/cli/src/streamChatResponse.autoCompaction.test.ts b/extensions/cli/src/streamChatResponse.autoCompaction.test.ts new file mode 100644 index 000000000..bfc9daae6 --- /dev/null +++ b/extensions/cli/src/streamChatResponse.autoCompaction.test.ts @@ -0,0 +1,225 @@ +import { ChatCompletionMessageParam } from "openai/resources.mjs"; +import { describe, it, expect, vi, beforeEach } from "vitest"; + +import { handleAutoCompaction } from "./streamChatResponse.autoCompaction.js"; + +// Mock dependencies +vi.mock("./compaction.js", () => ({ + compactChatHistory: vi.fn(), +})); + +vi.mock("./session.js", () => ({ + saveSession: vi.fn(), +})); + +vi.mock("./util/tokenizer.js", () => ({ + shouldAutoCompact: vi.fn(), + getAutoCompactMessage: vi.fn(), +})); + +vi.mock("./util/formatError.js", () => ({ + formatError: vi.fn((error) => error.message || String(error)), +})); + +vi.mock("./util/logger.js", () => ({ + logger: { + info: vi.fn(), + debug: vi.fn(), + error: vi.fn(), + warn: vi.fn(), + }, +})); + +describe("handleAutoCompaction", () => { + const mockModel = { + provider: "openai", + name: "gpt-4", + model: "gpt-4", + defaultCompletionOptions: { + contextLength: 8192, + maxTokens: 2048, + }, + } as any; + + const mockLlmApi = {} as any; + const mockChatHistory: ChatCompletionMessageParam[] = [ + { role: "system", content: "You are a helpful assistant." }, + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi there!" }, + ]; + + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("should return original history when auto-compaction is not needed", async () => { + const { shouldAutoCompact } = await import("./util/tokenizer.js"); + vi.mocked(shouldAutoCompact).mockReturnValue(false); + + const result = await handleAutoCompaction( + mockChatHistory, + mockModel, + mockLlmApi, + {}, + ); + + expect(result).toEqual({ + chatHistory: mockChatHistory, + compactionIndex: null, + }); + + expect(shouldAutoCompact).toHaveBeenCalledWith(mockChatHistory, mockModel); + }); + + it("should perform auto-compaction when context limit is approaching", async () => { + const { shouldAutoCompact, getAutoCompactMessage } = await import( + "./util/tokenizer.js" + ); + const { compactChatHistory } = await import("./compaction.js"); + const { saveSession } = await import("./session.js"); + + vi.mocked(shouldAutoCompact).mockReturnValue(true); + vi.mocked(getAutoCompactMessage).mockReturnValue("Auto-compacting..."); + + const mockCompactionResult = { + compactedHistory: [ + { + role: "system", + content: "You are a helpful assistant.", + } as ChatCompletionMessageParam, + { + role: "assistant", + content: "[COMPACTED HISTORY]\nConversation summary...", + } as ChatCompletionMessageParam, + ], + compactionIndex: 1, + compactionContent: "Conversation summary...", + }; + + vi.mocked(compactChatHistory).mockResolvedValue(mockCompactionResult); + + const mockCallbacks = { + onSystemMessage: vi.fn(), + }; + + const result = await handleAutoCompaction( + mockChatHistory, + mockModel, + mockLlmApi, + { + isHeadless: false, + callbacks: mockCallbacks, + }, + ); + + expect(shouldAutoCompact).toHaveBeenCalledWith(mockChatHistory, mockModel); + expect(getAutoCompactMessage).toHaveBeenCalledWith(mockModel); + expect(compactChatHistory).toHaveBeenCalledWith( + mockChatHistory, + mockModel, + mockLlmApi, + expect.any(Object), + ); + expect(saveSession).toHaveBeenCalledWith( + mockCompactionResult.compactedHistory, + ); + + expect(mockCallbacks.onSystemMessage).toHaveBeenCalledWith( + "Auto-compacting...", + ); + expect(mockCallbacks.onSystemMessage).toHaveBeenCalledWith( + "✓ Chat history auto-compacted successfully.", + ); + + expect(result).toEqual({ + chatHistory: mockCompactionResult.compactedHistory, + compactionIndex: mockCompactionResult.compactionIndex, + }); + }); + + it("should handle compaction errors gracefully", async () => { + const { shouldAutoCompact, getAutoCompactMessage } = await import( + "./util/tokenizer.js" + ); + const { compactChatHistory } = await import("./compaction.js"); + const { logger } = await import("./util/logger.js"); + + vi.mocked(shouldAutoCompact).mockReturnValue(true); + vi.mocked(getAutoCompactMessage).mockReturnValue("Auto-compacting..."); + vi.mocked(compactChatHistory).mockRejectedValue( + new Error("Compaction failed"), + ); + + const mockCallbacks = { + onSystemMessage: vi.fn(), + }; + + const result = await handleAutoCompaction( + mockChatHistory, + mockModel, + mockLlmApi, + { + isHeadless: false, + callbacks: mockCallbacks, + }, + ); + + expect(logger.error).toHaveBeenCalledWith( + expect.stringContaining("Auto-compaction error"), + ); + expect(mockCallbacks.onSystemMessage).toHaveBeenCalledWith( + expect.stringContaining("Warning: Auto-compaction error"), + ); + + // Should return original history on error + expect(result).toEqual({ + chatHistory: mockChatHistory, + compactionIndex: null, + }); + }); + + it("should not call system message callback in headless mode", async () => { + const { shouldAutoCompact, getAutoCompactMessage } = await import( + "./util/tokenizer.js" + ); + const { compactChatHistory } = await import("./compaction.js"); + + vi.mocked(shouldAutoCompact).mockReturnValue(true); + vi.mocked(getAutoCompactMessage).mockReturnValue("Auto-compacting..."); + + const mockCompactionResult = { + compactedHistory: [ + { role: "system", content: "System" } as ChatCompletionMessageParam, + ], + compactionIndex: 0, + compactionContent: "Summary", + }; + + vi.mocked(compactChatHistory).mockResolvedValue(mockCompactionResult); + + const mockCallbacks = { + onSystemMessage: vi.fn(), + }; + + await handleAutoCompaction(mockChatHistory, mockModel, mockLlmApi, { + isHeadless: true, + callbacks: mockCallbacks, + }); + + expect(mockCallbacks.onSystemMessage).not.toHaveBeenCalled(); + }); + + it("should handle missing model gracefully", async () => { + const result = await handleAutoCompaction( + mockChatHistory, + null as any, + mockLlmApi, + {}, + ); + + expect(result).toEqual({ + chatHistory: mockChatHistory, + compactionIndex: null, + }); + }); +}); diff --git a/extensions/cli/src/streamChatResponse.autoCompaction.ts b/extensions/cli/src/streamChatResponse.autoCompaction.ts new file mode 100644 index 000000000..ee9336250 --- /dev/null +++ b/extensions/cli/src/streamChatResponse.autoCompaction.ts @@ -0,0 +1,180 @@ +import { ModelConfig } from "@continuedev/config-yaml"; +import { BaseLlmApi } from "@continuedev/openai-adapters"; +import type { ChatCompletionMessageParam } from "openai/resources.mjs"; +import React from "react"; + +import { compactChatHistory } from "./compaction.js"; +import { saveSession } from "./session.js"; +import { DisplayMessage } from "./ui/types.js"; +import { formatError } from "./util/formatError.js"; +import { logger } from "./util/logger.js"; +import { getAutoCompactMessage, shouldAutoCompact } from "./util/tokenizer.js"; + +interface AutoCompactionCallbacks { + // For streaming mode + onSystemMessage?: (message: string) => void; + onContent?: (content: string) => void; + + // For TUI mode + setMessages?: React.Dispatch>; + setChatHistory?: React.Dispatch< + React.SetStateAction + >; + setCompactionIndex?: React.Dispatch>; + + // For headless mode - no callbacks needed, just return values +} + +interface AutoCompactionOptions { + isHeadless?: boolean; + format?: "json"; + callbacks?: AutoCompactionCallbacks; +} + +/** + * Notify user about compaction start + */ +function notifyCompactionStart( + message: string, + isHeadless: boolean, + callbacks?: AutoCompactionCallbacks, +) { + if (isHeadless) return; + + if (callbacks?.onSystemMessage) { + callbacks.onSystemMessage(message); + } else if (callbacks?.setMessages) { + callbacks.setMessages((prev) => [ + ...prev, + { + role: "system", + content: message, + messageType: "system" as const, + }, + ]); + } +} + +/** + * Handle successful compaction state updates + */ +function handleCompactionSuccess( + result: any, + isHeadless: boolean, + callbacks?: AutoCompactionCallbacks, +) { + if (isHeadless) return; + + const successMessage = "✓ Chat history auto-compacted successfully."; + + if (callbacks?.onSystemMessage) { + callbacks.onSystemMessage(successMessage); + } else if ( + callbacks?.setMessages && + callbacks?.setChatHistory && + callbacks?.setCompactionIndex + ) { + callbacks.setChatHistory(result.compactedHistory); + callbacks.setCompactionIndex(result.compactionIndex); + callbacks.setMessages((prev) => [ + ...prev, + { + role: "system", + content: successMessage, + messageType: "system" as const, + }, + ]); + } +} + +/** + * Handle compaction error notification + */ +function handleCompactionError( + error: any, + isHeadless: boolean, + callbacks?: AutoCompactionCallbacks, +) { + const errorMessage = `Auto-compaction error: ${formatError(error)}`; + logger.error(errorMessage); + + if (isHeadless) return; + + const warningMessage = `Warning: ${errorMessage}. Continuing without compaction...`; + + if (callbacks?.onSystemMessage) { + callbacks.onSystemMessage(warningMessage); + } else if (callbacks?.setMessages) { + callbacks.setMessages((prev) => [ + ...prev, + { + role: "system", + content: warningMessage, + messageType: "system" as const, + }, + ]); + } +} + +/** + * Unified auto-compaction handler for all modes (streaming, TUI, headless) + * @param chatHistory Current chat history + * @param model Model configuration + * @param llmApi LLM API instance + * @param options Configuration options for different usage contexts + * @returns Updated chat history and compaction index, or original if no compaction needed + */ +export async function handleAutoCompaction( + chatHistory: ChatCompletionMessageParam[], + model: ModelConfig, + llmApi: BaseLlmApi, + options: AutoCompactionOptions = {}, +): Promise<{ + chatHistory: ChatCompletionMessageParam[]; + compactionIndex: number | null; +}> { + const { isHeadless = false, callbacks } = options; + + if (!model || !shouldAutoCompact(chatHistory, model)) { + return { chatHistory, compactionIndex: null }; + } + + logger.info( + `Auto-compaction triggered${isHeadless ? " in headless mode" : ""}`, + ); + + // Notify about compaction start + notifyCompactionStart(getAutoCompactMessage(model), isHeadless, callbacks); + + try { + // Compact the history + const result = await compactChatHistory( + chatHistory, + model, + llmApi, + isHeadless + ? undefined + : { + onStreamContent: callbacks?.onContent, + onStreamComplete: () => {}, + }, + ); + + // Save the compacted session + saveSession(result.compactedHistory); + + // Handle success notification + handleCompactionSuccess(result, isHeadless, callbacks); + + return { + chatHistory: result.compactedHistory, + compactionIndex: result.compactionIndex, + }; + } catch (error: any) { + // Handle error notification + handleCompactionError(error, isHeadless, callbacks); + + // Continue without compaction on error + return { chatHistory, compactionIndex: null }; + } +} diff --git a/extensions/cli/src/streamChatResponse.ts b/extensions/cli/src/streamChatResponse.ts index fd8cf4b96..ab9d0c507 100644 --- a/extensions/cli/src/streamChatResponse.ts +++ b/extensions/cli/src/streamChatResponse.ts @@ -15,6 +15,7 @@ import { SERVICE_NAMES, } from "./services/index.js"; import type { ToolPermissionServiceState } from "./services/ToolPermissionService.js"; +import { handleAutoCompaction } from "./streamChatResponse.autoCompaction.js"; import { executeStreamedToolCalls, preprocessStreamedToolCalls, @@ -513,6 +514,24 @@ export async function streamChatResponse( return finalResponse || content || fullResponse; } + // Check for auto-compaction after tool execution + if (shouldContinue) { + const { chatHistory: updatedChatHistory, compactionIndex } = + await handleAutoCompaction(chatHistory, model, llmApi, { + isHeadless, + callbacks: { + onSystemMessage: callbacks?.onSystemMessage, + onContent: callbacks?.onContent, + }, + }); + + // Only update chat history if compaction actually occurred + if (compactionIndex !== null && updatedChatHistory !== chatHistory) { + chatHistory.length = 0; + chatHistory.push(...updatedChatHistory); + } + } + // Check if we should continue if (!shouldContinue) { break; diff --git a/extensions/cli/src/streamChatResponse.types.ts b/extensions/cli/src/streamChatResponse.types.ts index 6519e0e48..ff273872a 100644 --- a/extensions/cli/src/streamChatResponse.types.ts +++ b/extensions/cli/src/streamChatResponse.types.ts @@ -15,6 +15,7 @@ export interface StreamCallbacks { requestId: string, preview?: ToolCallPreview[], ) => void; + onSystemMessage?: (message: string) => void; } export function getDefaultCompletionOptions( diff --git a/extensions/cli/src/systemMessage.test.ts b/extensions/cli/src/systemMessage.test.ts index b76f4fb61..895234c9b 100644 --- a/extensions/cli/src/systemMessage.test.ts +++ b/extensions/cli/src/systemMessage.test.ts @@ -11,11 +11,11 @@ vi.mock("./services/ServiceContainer.js", () => ({ }, })); -// Mock processRule to avoid file system operations in tests +// Mock processPromptOrRule to avoid file system operations in tests vi.mock("./args.js", () => ({ - processRule: vi + processPromptOrRule: vi .fn() - .mockImplementation((rule: string) => Promise.resolve(rule)), + .mockImplementation((spec: string) => Promise.resolve(spec)), })); describe("constructSystemMessage", () => { @@ -146,4 +146,105 @@ Rule 3: Third rule`; expect(result).not.toContain("IMPORTANT: You are running in headless mode"); expect(result).not.toContain("Provide ONLY your final answer"); }); + + it("should add JSON format instructions when format is json", async () => { + const result = await constructSystemMessage(undefined, "json"); + + expect(result).toContain("You are an agent in the Continue CLI"); + expect(result).toContain( + "IMPORTANT: You are operating in JSON output mode", + ); + expect(result).toContain("Your final response MUST be valid JSON"); + expect(result).toContain("JSON.parse()"); + }); + + it("should add plan mode instructions when mode is plan", async () => { + const result = await constructSystemMessage( + undefined, + undefined, + false, + "plan", + ); + + expect(result).toContain("You are an agent in the Continue CLI"); + expect(result).toContain("PLAN MODE: You are operating in plan mode"); + expect(result).toContain( + "which means that your goal is to help the user investigate their ideas", + ); + expect(result).toContain("develop a plan before taking action"); + expect(result).toContain("read-only tools"); + expect(result).toContain( + "should not attempt to circumvent them to write / delete / create files", + ); + }); + + it("should not add plan mode instructions when mode is not plan", async () => { + const result = await constructSystemMessage( + undefined, + undefined, + false, + "normal", + ); + + expect(result).toContain("You are an agent in the Continue CLI"); + expect(result).not.toContain("PLAN MODE: You are operating in plan mode"); + expect(result).not.toContain( + "which means that your goal is to help the user investigate their ideas", + ); + }); + + it("should not add plan mode instructions when mode is undefined", async () => { + const result = await constructSystemMessage(); + + expect(result).toContain("You are an agent in the Continue CLI"); + expect(result).not.toContain("PLAN MODE: You are operating in plan mode"); + expect(result).not.toContain( + "which means that your goal is to help the user investigate their ideas", + ); + }); + + it("should include basic plan mode description", async () => { + const result = await constructSystemMessage( + undefined, + undefined, + false, + "plan", + ); + + expect(result).toContain("PLAN MODE: You are operating in plan mode"); + expect(result).toContain("read-only tools"); + expect(result).toContain("write / delete / create files"); + }); + + it("should combine plan mode with headless mode instructions", async () => { + const result = await constructSystemMessage( + undefined, + undefined, + true, + "plan", + ); + + expect(result).toContain("IMPORTANT: You are running in headless mode"); + expect(result).toContain("PLAN MODE: You are operating in plan mode"); + expect(result).toContain( + "which means that your goal is to help the user investigate their ideas", + ); + }); + + it("should combine plan mode with JSON format instructions", async () => { + const result = await constructSystemMessage( + undefined, + "json", + false, + "plan", + ); + + expect(result).toContain( + "IMPORTANT: You are operating in JSON output mode", + ); + expect(result).toContain("PLAN MODE: You are operating in plan mode"); + expect(result).toContain( + "which means that your goal is to help the user investigate their ideas", + ); + }); }); diff --git a/extensions/cli/src/systemMessage.ts b/extensions/cli/src/systemMessage.ts index 1f09ff5c6..77742956d 100644 --- a/extensions/cli/src/systemMessage.ts +++ b/extensions/cli/src/systemMessage.ts @@ -5,7 +5,9 @@ import * as path from "path"; import pkg from "ignore-walk"; import { Minimatch } from "minimatch"; -import { processRule } from "./args.js"; +import { processPromptOrRule } from "./args.js"; +import { PermissionMode } from "./permissions/types.js"; +import { modeService } from "./services/ModeService.js"; import { serviceContainer } from "./services/ServiceContainer.js"; import { ConfigServiceState, SERVICE_NAMES } from "./services/types.js"; const { WalkerSync } = pkg; @@ -116,16 +118,17 @@ async function getConfigYamlRules(): Promise { /** * Load and construct a comprehensive system message with base message and rules section - * @param rulesSystemMessage - The rules system message from the assistant * @param additionalRules - Additional rules from --rule flags * @param format - Output format for headless mode * @param headless - Whether running in headless mode + * @param mode - Current permission mode * @returns The comprehensive system message with base message and rules section */ export async function constructSystemMessage( additionalRules?: string[], format?: "json", headless?: boolean, + mode?: PermissionMode, ): Promise { const agentFiles = ["AGENTS.md", "AGENT.md", "CLAUDE.md", "CODEX.md"]; @@ -150,7 +153,7 @@ export async function constructSystemMessage( if (additionalRules && additionalRules.length > 0) { for (const ruleSpec of additionalRules) { try { - const processedRule = await processRule(ruleSpec); + const processedRule = await processPromptOrRule(ruleSpec); processedRules.push(processedRule); } catch (error: any) { console.warn( @@ -163,6 +166,9 @@ export async function constructSystemMessage( const configYamlRules = await getConfigYamlRules(); processedRules.push(...configYamlRules); + // Get current mode if not provided + const currentMode = mode ?? modeService.getCurrentMode(); + // Construct the comprehensive system message let systemMessage = baseSystemMessage; @@ -185,6 +191,13 @@ Example response format: }`; } + // Add plan mode specific instructions if in plan mode + if (currentMode === "plan") { + systemMessage += ` + +PLAN MODE: You are operating in plan mode, which means that your goal is to help the user investigate their ideas and develop a plan before taking action. You only have access to read-only tools and should not attempt to circumvent them to write / delete / create files.`; + } + // Add rules section if we have any rules or agent content if (agentContent || processedRules.length > 0) { systemMessage += '\n\n'; diff --git a/extensions/cli/src/test-helpers/ui-test-context.ts b/extensions/cli/src/test-helpers/ui-test-context.ts index 5eeda611d..a8eae59f3 100644 --- a/extensions/cli/src/test-helpers/ui-test-context.ts +++ b/extensions/cli/src/test-helpers/ui-test-context.ts @@ -72,7 +72,7 @@ export function createUITestContext( responseStartTime: null, inputMode: true, attachedFiles: [], - handleUserMessage: vi.fn(), + handleUserMessage: vi.fn().mockResolvedValue(undefined), handleInterrupt: vi.fn(), handleFileAttached: vi.fn(), resetChatHistory: vi.fn(), diff --git a/extensions/cli/src/tools/edit.ts b/extensions/cli/src/tools/edit.ts index 39e9ca1f9..a7b31ca10 100644 --- a/extensions/cli/src/tools/edit.ts +++ b/extensions/cli/src/tools/edit.ts @@ -1,5 +1,7 @@ import * as fs from "fs"; +import { throwIfFileIsSecurityConcern } from "core/indexing/ignore.js"; + import { telemetryService } from "../telemetry/telemetryService.js"; import { calculateLinesOfCodeDiff, @@ -80,7 +82,7 @@ parameter is useful if you want to rename a variable for instance.`, new_string, replace_all = false, } = args as EditArgs; - + throwIfFileIsSecurityConcern(file_path); // Check if file has been read if (!readFilesSet.has(file_path)) { throw new Error( diff --git a/extensions/cli/src/tools/multiEdit.ts b/extensions/cli/src/tools/multiEdit.ts index cd0e3ebaf..b0ec1cb26 100644 --- a/extensions/cli/src/tools/multiEdit.ts +++ b/extensions/cli/src/tools/multiEdit.ts @@ -1,6 +1,8 @@ import * as fs from "fs"; import * as path from "path"; +import { throwIfFileIsSecurityConcern } from "core/indexing/ignore.js"; + import { telemetryService } from "../telemetry/telemetryService.js"; import { calculateLinesOfCodeDiff, @@ -237,6 +239,8 @@ If you want to create a new file, use: // Validate and extract arguments const { original_path, file_path, edits } = validateMultiEditArgs(args); + throwIfFileIsSecurityConcern(file_path); + // Validate each edit operation validateEdits(edits); diff --git a/extensions/cli/src/tools/readFile.ts b/extensions/cli/src/tools/readFile.ts index 69e55efec..80a6bbe62 100644 --- a/extensions/cli/src/tools/readFile.ts +++ b/extensions/cli/src/tools/readFile.ts @@ -1,5 +1,7 @@ import * as fs from "fs"; +import { throwIfFileIsSecurityConcern } from "core/indexing/ignore.js"; + import { markFileAsRead } from "./edit.js"; import { formatToolArgument } from "./formatters.js"; import { Tool } from "./types.js"; @@ -18,6 +20,7 @@ export const readFileTool: Tool = { readonly: true, isBuiltIn: true, preprocess: async (args) => { + throwIfFileIsSecurityConcern(args.filepath); return { args, preview: [ @@ -36,6 +39,13 @@ export const readFileTool: Tool = { const content = fs.readFileSync(args.filepath, "utf-8"); // Mark this file as read for the edit tool markFileAsRead(args.filepath); + + const lines = content.split("\n"); + if (lines.length > 5000) { + const truncatedContent = lines.slice(0, 5000).join("\n"); + return `Content of ${args.filepath} (truncated to first 5000 lines of ${lines.length} total):\n${truncatedContent}`; + } + return `Content of ${args.filepath}:\n${content}`; } catch (error) { return `Error reading file: ${ diff --git a/extensions/cli/src/ui/AppRoot.tsx b/extensions/cli/src/ui/AppRoot.tsx index 8f2c1c193..f6cef3c20 100644 --- a/extensions/cli/src/ui/AppRoot.tsx +++ b/extensions/cli/src/ui/AppRoot.tsx @@ -9,6 +9,7 @@ interface AppRootProps { initialPrompt?: string; resume?: boolean; additionalRules?: string[]; + additionalPrompts?: string[]; } /** diff --git a/extensions/cli/src/ui/FreeTrialTransitionUI.tsx b/extensions/cli/src/ui/FreeTrialTransitionUI.tsx index 8b7235895..5a4638e2e 100644 --- a/extensions/cli/src/ui/FreeTrialTransitionUI.tsx +++ b/extensions/cli/src/ui/FreeTrialTransitionUI.tsx @@ -9,8 +9,8 @@ import useSWR from "swr"; import { listUserOrganizations } from "../auth/workos.js"; import { env } from "../env.js"; import { - isValidAnthropicApiKey, getApiKeyValidationError, + isValidAnthropicApiKey, } from "../util/apiKeyValidation.js"; import { updateAnthropicModelInYaml } from "../util/yamlConfigUpdater.js"; @@ -270,7 +270,7 @@ const FreeTrialTransitionUI: React.FC = ({ {errorMessage && {errorMessage}} - Type your API key and press Enter (must start with 'TEST-ant-') + Type your API key and press Enter (must start with 'sk-ant-') ); diff --git a/extensions/cli/src/ui/IntroMessage.test.tsx b/extensions/cli/src/ui/IntroMessage.test.tsx new file mode 100644 index 000000000..fd336bf8b --- /dev/null +++ b/extensions/cli/src/ui/IntroMessage.test.tsx @@ -0,0 +1,166 @@ +import { AssistantUnrolled } from "@continuedev/config-yaml"; +import { render } from "ink-testing-library"; +import React from "react"; +import { describe, expect, it, vi } from "vitest"; + +import { IntroMessage } from "./IntroMessage.js"; + +// Mock the MCPService +vi.mock("../services/MCPService.js", () => ({ + MCPService: vi.fn().mockImplementation(() => ({ + getState: () => ({ prompts: [] }), + })), +})); + +// Mock the model capability check +vi.mock("../utils/modelCapability.js", () => ({ + isModelCapable: vi.fn().mockReturnValue(true), +})); + +describe("IntroMessage", () => { + const mockMcpService = { + getState: () => ({ prompts: [] }), + } as any; + + const mockModel = { + provider: "anthropic", + name: "claude-3-sonnet", + model: "claude-3-sonnet", + } as any; + + it("should not duplicate rules from command line", () => { + // Config with rules that were already injected from command line + // Hub rules are stored as RuleObject with name and rule fields + const config: AssistantUnrolled = { + name: "Test Assistant", + rules: [ + { name: "nate/spanish", rule: "Always respond in Spanish." }, + "Always be helpful", + ], + } as any; + + const { lastFrame } = render( + , + ); + + const output = lastFrame(); + + // Count occurrences of "nate/spanish" in the output + const matches = output?.match(/nate\/spanish/g) || []; + + // Should appear exactly once, not twice + expect(matches.length).toBe(1); + + // Verify the slug is shown, not the content + expect(output).toContain("nate/spanish"); + expect(output).not.toContain("Always respond in Spanish"); + + // Verify plain string rule is shown as-is + expect(output).toContain("Always be helpful"); + }); + + it("should display rules from config correctly", () => { + const config: AssistantUnrolled = { + name: "Test Assistant", + rules: ["Rule 1", { name: "Rule 2" }, "Rule 3"], + } as any; + + const { lastFrame } = render( + , + ); + + const output = lastFrame(); + + expect(output).toContain("Rules:"); + expect(output).toContain("Rule 1"); + expect(output).toContain("Rule 2"); + expect(output).toContain("Rule 3"); + }); + + it("should not show Rules section when no rules exist", () => { + const config: AssistantUnrolled = { + name: "Test Assistant", + } as any; + + const { lastFrame } = render( + , + ); + + const output = lastFrame(); + + expect(output).not.toContain("Rules:"); + }); + + it("should handle rule objects with missing name property", () => { + const config: AssistantUnrolled = { + name: "Test Assistant", + rules: [ + "String rule", + { someOtherProp: "value" }, // Missing 'name' property + ], + } as any; + + const { lastFrame } = render( + , + ); + + const output = lastFrame(); + + expect(output).toContain("String rule"); + expect(output).toContain("Unknown"); // Should show "Unknown" for objects without name + }); + + it("should display hub rule slugs, not their content", () => { + const config: AssistantUnrolled = { + name: "Test Assistant", + rules: [ + { + name: "org/complex-rule", + rule: `--- +alwaysApply: true +--- + +This is a very long rule content that should not be displayed. +It contains multiple lines and complex formatting. +The UI should only show the slug 'org/complex-rule'.`, + }, + { name: "another/rule", rule: "Short content" }, + ], + } as any; + + const { lastFrame } = render( + , + ); + + const output = lastFrame(); + + // Should show slugs only + expect(output).toContain("org/complex-rule"); + expect(output).toContain("another/rule"); + + // Should NOT show the rule content + expect(output).not.toContain("This is a very long rule"); + expect(output).not.toContain("alwaysApply"); + expect(output).not.toContain("Short content"); + }); +}); diff --git a/extensions/cli/src/ui/IntroMessage.tsx b/extensions/cli/src/ui/IntroMessage.tsx index 7aad51014..ca987c1bb 100644 --- a/extensions/cli/src/ui/IntroMessage.tsx +++ b/extensions/cli/src/ui/IntroMessage.tsx @@ -2,7 +2,6 @@ import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml"; import { Box, Text } from "ink"; import React, { useMemo } from "react"; -import { parseArgs } from "../args.js"; import { MCPService } from "../services/MCPService.js"; import { isModelCapable } from "../utils/modelCapability.js"; @@ -24,15 +23,13 @@ const IntroMessage: React.FC = ({ // Memoize expensive operations to avoid running on every resize const { allRules, modelCapable } = useMemo(() => { - // Show all rules in a single section - const args = parseArgs(); - const commandLineRules = args.rules || []; + // Show all rules from config (command-line rules are already merged into config) const configRules = config.rules?.map((rule: any) => typeof rule === "string" ? rule : rule?.name || "Unknown", ) || []; - const allRules = [...commandLineRules, ...configRules]; + const allRules = configRules; // Check if model is capable - now checking both name and model properties const modelCapable = isModelCapable( @@ -85,7 +82,9 @@ const IntroMessage: React.FC = ({ {/* Rules */} {allRules.length > 0 && ( <> - Rules: + + Rules: + {allRules.map((rule, index) => ( - {rule} diff --git a/extensions/cli/src/ui/SessionSelector.tsx b/extensions/cli/src/ui/SessionSelector.tsx index 4e085f197..3ef4d3821 100644 --- a/extensions/cli/src/ui/SessionSelector.tsx +++ b/extensions/cli/src/ui/SessionSelector.tsx @@ -63,7 +63,7 @@ export function SessionSelector({ if (displaySessions[selectedIndex]) { onSelect(displaySessions[selectedIndex].id); } - } else if (key.escape || (key.ctrl && input === "c")) { + } else if (key.escape || (key.ctrl && input === "d")) { onExit(); } }); @@ -73,7 +73,7 @@ export function SessionSelector({ No previous sessions found. Start a new conversation with: cn - Press ESC to exit + Press ESC or Ctrl+D to exit ); } @@ -84,7 +84,7 @@ export function SessionSelector({ Recent Sessions - Use ↑↓ arrows to navigate, Enter to select, ESC to exit + Use ↑↓ arrows to navigate, Enter to select, ESC or Ctrl+D to exit diff --git a/extensions/cli/src/ui/TUIChat.tsx b/extensions/cli/src/ui/TUIChat.tsx index 6ef19ca08..5e39f6e12 100644 --- a/extensions/cli/src/ui/TUIChat.tsx +++ b/extensions/cli/src/ui/TUIChat.tsx @@ -1,5 +1,11 @@ import { Box, Text } from "ink"; -import React, { useMemo, useState } from "react"; +import React, { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from "react"; import { useServices } from "../hooks/useService.js"; import { @@ -9,8 +15,10 @@ import { MCPServiceState, ModelServiceState, } from "../services/types.js"; +import { logger } from "../util/logger.js"; import { BottomStatusBar } from "./components/BottomStatusBar.js"; +import { ResourceDebugBar } from "./components/ResourceDebugBar.js"; import { ScreenContent } from "./components/ScreenContent.js"; import { StaticChatContent } from "./components/StaticChatContent.js"; import { useNavigation } from "./context/NavigationContext.js"; @@ -36,23 +44,61 @@ interface TUIChatProps { initialPrompt?: string; resume?: boolean; additionalRules?: string[]; + additionalPrompts?: string[]; } -const TUIChat: React.FC = ({ - remoteUrl, - configPath, - initialPrompt, - resume, - additionalRules, -}) => { - // Check if we're in remote mode - const isRemoteMode = useMemo(() => { - return !!remoteUrl; - }, [remoteUrl]); +// Helper function to load and set session +async function loadAndSetSession( + sessionId: string, + closeCurrentScreen: () => void, + setChatHistory: (history: any) => void, + setMessages: (messages: any) => void, + setShowIntroMessage: (show: boolean) => void, +) { + try { + // Close the session selector + closeCurrentScreen(); - const repoURlText = useMemo(() => getRepoUrlText(remoteUrl), [remoteUrl]); + // Import session functions + const { loadSessionById } = await import("../session.js"); + + // Load the session history + const sessionHistory = loadSessionById(sessionId); + if (!sessionHistory) { + logger.error(`Session ${sessionId} could not be loaded.`); + return; + } + + // Set the session ID so future operations use this session + process.env.CONTINUE_CLI_TEST_SESSION_ID = sessionId.replace( + "continue-cli-", + "", + ); + + // Directly set the chat history and messages to the loaded session + setChatHistory(sessionHistory); + + // Convert chat history to display messages (exclude system messages) + const displayMessages = sessionHistory + .filter((msg: any) => msg.role !== "system") + .map((msg: any) => ({ + role: msg.role, + content: msg.content as string, + })); + + setMessages(displayMessages); + + // Clear the intro message since we're now showing a resumed session + setShowIntroMessage(false); + } catch (error) { + console.error("Error loading session:", error); + } +} + +// Custom hook to manage services +function useTUIChatServices(remoteUrl?: string) { + const isRemoteMode = useMemo(() => !!remoteUrl, [remoteUrl]); - // Get all services reactively - only in normal mode const { services, allReady: allServicesReady } = useServices<{ auth: AuthServiceState; config: ConfigServiceState; @@ -61,6 +107,57 @@ const TUIChat: React.FC = ({ apiClient: ApiClientServiceState; }>(["auth", "config", "model", "mcp", "apiClient"]); + return { services, allServicesReady, isRemoteMode }; +} + +// Custom hook for chat handlers +function useChatHandlers( + setShowIntroMessage: (show: boolean) => void, + setStaticRefreshTrigger: React.Dispatch>, +) { + // Temporary refs to avoid circular dependency + const resetChatHistoryRef = useRef<(() => void) | null>(null); + + // Handle clearing chat and resetting intro message + const handleClear = useCallback(() => { + setShowIntroMessage(true); + // Trigger static content refresh by incrementing the trigger + setStaticRefreshTrigger((prev) => prev + 1); + }, [setShowIntroMessage, setStaticRefreshTrigger]); + + // Service reload handlers - these will trigger reactive updates + const handleReload = useCallback(async () => { + // Services will automatically update the UI when they reload + // We just need to reset chat history, intro message, and clear the screen + if (resetChatHistoryRef.current) { + resetChatHistoryRef.current(); + } + setShowIntroMessage(false); + process.stdout.write("\x1b[2J\x1b[H"); + }, [setShowIntroMessage]); + + return { + handleClear, + handleReload, + resetChatHistoryRef, + }; +} + +// eslint-disable-next-line complexity +const TUIChat: React.FC = ({ + remoteUrl, + configPath, + initialPrompt, + resume, + additionalRules, + additionalPrompts, +}) => { + // Use custom hook for services + const { services, allServicesReady, isRemoteMode } = + useTUIChatServices(remoteUrl); + + const repoURlText = useMemo(() => getRepoUrlText(remoteUrl), [remoteUrl]); + // Use navigation context const { state: navState, @@ -86,24 +183,14 @@ const TUIChat: React.FC = ({ closeCurrentScreen, ); - // Service reload handlers - these will trigger reactive updates - const handleReload = async () => { - // Services will automatically update the UI when they reload - // We just need to reset chat history, intro message, and clear the screen - resetChatHistory(); - setShowIntroMessage(false); - process.stdout.write("\x1b[2J\x1b[H"); - }; - // State to trigger static content refresh for /clear command const [staticRefreshTrigger, setStaticRefreshTrigger] = useState(0); - // Handle clearing chat and resetting intro message - const handleClear = () => { - setShowIntroMessage(true); - // Trigger static content refresh by incrementing the trigger - setStaticRefreshTrigger((prev) => prev + 1); - }; + // Use chat handlers hook + const { handleClear, handleReload, resetChatHistoryRef } = useChatHandlers( + setShowIntroMessage, + setStaticRefreshTrigger, + ); const { messages, @@ -126,6 +213,7 @@ const TUIChat: React.FC = ({ initialPrompt, resume, additionalRules, + additionalPrompts, onShowConfigSelector: () => navigateTo("config"), onShowModelSelector: () => navigateTo("model"), onShowMCPSelector: () => navigateTo("mcp"), @@ -138,6 +226,11 @@ const TUIChat: React.FC = ({ remoteUrl, }); + // Update ref after useChat returns + useEffect(() => { + resetChatHistoryRef.current = resetChatHistory; + }, [resetChatHistory]); + // Calculate context percentage const contextData = useContextPercentage({ chatHistory, @@ -153,52 +246,27 @@ const TUIChat: React.FC = ({ ); // Session selection handler - const handleSessionSelect = async (sessionId: string) => { - try { - // Close the session selector - closeCurrentScreen(); - - // Import session functions - const { loadSessionById } = await import("../session.js"); - - // Load the session history - const sessionHistory = loadSessionById(sessionId); - if (!sessionHistory) { - console.error(`Session ${sessionId} could not be loaded.`); - return; - } - - // Set the session ID so future operations use this session - process.env.CONTINUE_CLI_TEST_SESSION_ID = sessionId.replace( - "continue-cli-", - "", + const handleSessionSelect = useCallback( + async (sessionId: string) => { + await loadAndSetSession( + sessionId, + closeCurrentScreen, + setChatHistory, + setMessages, + setShowIntroMessage, ); - - // Directly set the chat history and messages to the loaded session - setChatHistory(sessionHistory); - - // Convert chat history to display messages (exclude system messages) - const displayMessages = sessionHistory - .filter((msg) => msg.role !== "system") - .map((msg) => ({ - role: msg.role, - content: msg.content as string, - })); - - setMessages(displayMessages); - - // Clear the intro message since we're now showing a resumed session - setShowIntroMessage(false); - } catch (error) { - console.error("Error loading session:", error); - } - }; + }, + [closeCurrentScreen, setChatHistory, setMessages, setShowIntroMessage], + ); // Determine if input should be disabled // Allow input even when services are loading, but disable for UI overlays const isInputDisabled = navState.currentScreen !== "chat" || !!activePermissionRequest; + // Check if verbose mode is enabled for resource debugging + const isVerboseMode = useMemo(() => process.argv.includes("--verbose"), []); + return ( {/* Chat history - takes up all available space above input */} @@ -265,6 +333,11 @@ const TUIChat: React.FC = ({ isRemoteMode={isRemoteMode} /> + {/* Resource debug bar - only in verbose mode */} + {isVerboseMode && !isRemoteMode && ( + + )} + {/* Free trial status and Continue CLI info - always show */} = ({ } } + // Check if there are any matching commands + const filteredCommands = allCommands.filter((cmd) => + cmd.name.toLowerCase().includes(afterSlash.toLowerCase()), + ); + + // If no commands match, hide the dropdown to allow normal Enter behavior + if (filteredCommands.length === 0) { + setShowSlashCommands(false); + return; + } + // Show selector for partial matches setShowSlashCommands(true); setSlashCommandFilter(afterSlash); @@ -401,6 +412,16 @@ const UserInput: React.FC = ({ return false; }; + // Clear input function + const clearInput = () => { + textBuffer.clear(); + setInputText(""); + setCursorPosition(0); + setShowSlashCommands(false); + setShowFileSearch(false); + inputHistory.resetNavigation(); + }; + useInput((input, key) => { // Don't handle any input when disabled if (disabled) { @@ -416,6 +437,7 @@ const UserInput: React.FC = ({ showSlashCommands, showFileSearch, cycleModes, + clearInput, }) ) { return; diff --git a/extensions/cli/src/ui/components/MemoizedMessage.tsx b/extensions/cli/src/ui/components/MemoizedMessage.tsx index 0e254f23a..68c3923e4 100644 --- a/extensions/cli/src/ui/components/MemoizedMessage.tsx +++ b/extensions/cli/src/ui/components/MemoizedMessage.tsx @@ -20,7 +20,10 @@ export const MemoizedMessage = memo( case "tool-start": return ( - ○ {message.content} + {/* TODO: Change back to empty circle (○) with white color once we want to differentiate in-progress vs completed tool calls */} + + ● {message.content} + ); @@ -87,7 +90,7 @@ export const MemoizedMessage = memo( return ( - ● + ● {isUser ? ( {message.content} diff --git a/extensions/cli/src/ui/components/ResourceDebugBar.tsx b/extensions/cli/src/ui/components/ResourceDebugBar.tsx new file mode 100644 index 000000000..340edc757 --- /dev/null +++ b/extensions/cli/src/ui/components/ResourceDebugBar.tsx @@ -0,0 +1,184 @@ +import { Box, Text } from "ink"; +import React, { useEffect, useState } from "react"; + +import { services } from "../../services/index.js"; +import { ResourceUsage } from "../../services/ResourceMonitoringService.js"; + +interface ResourceDebugBarProps { + visible: boolean; +} + +function formatBytes(bytes: number): string { + const mb = bytes / 1024 / 1024; + return mb >= 1 ? `${mb.toFixed(1)}MB` : `${(bytes / 1024).toFixed(1)}KB`; +} + +function formatPercent(percent: number): string { + return `${Math.round(percent)}%`; +} + +function formatTime(ms: number): string { + if (ms < 1000) return `${Math.round(ms)}ms`; + return `${(ms / 1000).toFixed(1)}s`; +} + +export function ResourceDebugBar({ visible }: ResourceDebugBarProps) { + const [resourceData, setResourceData] = useState(null); + const [isError, setIsError] = useState(false); + + useEffect(() => { + if (!visible) return; + + const updateResourceData = () => { + try { + const usage = services.resourceMonitoring.getCurrentResourceUsage(); + setResourceData(usage); + setIsError(false); + } catch { + setIsError(true); + } + }; + + // Initial update + updateResourceData(); + + // Update every 2 seconds + const intervalId = setInterval(updateResourceData, 2000); + + return () => { + clearInterval(intervalId); + }; + }, [visible]); + + if (!visible) { + return null; + } + + if (isError) { + return ( + + Resource monitoring error + + ); + } + + if (!resourceData) { + return null; + } + + const memoryPercent = + (resourceData.memory.rss / resourceData.system.totalMemory) * 100; + const cpuPercent = resourceData.cpu.percent || 0; + const heapPercent = + (resourceData.memory.heapUsed / resourceData.memory.heapTotal) * 100; + + // Color coding based on usage levels + const getMemoryColor = () => { + if (memoryPercent > 80) return "red"; + if (memoryPercent > 60) return "yellow"; + return "green"; + }; + + const getCpuColor = () => { + if (cpuPercent > 80) return "red"; + if (cpuPercent > 60) return "yellow"; + return "green"; + }; + + const getEventLoopColor = () => { + if (resourceData.eventLoop.lag > 100) return "red"; + if (resourceData.eventLoop.lag > 50) return "yellow"; + return "green"; + }; + + return ( + + Debug: + + + MEM: {formatBytes(resourceData.memory.rss)} + + | + + HEAP: {formatPercent(heapPercent)} + | + + CPU: {formatPercent(cpuPercent)} + | + + + LAG: {formatTime(resourceData.eventLoop.lag)} + + + {resourceData.fileDescriptors && ( + <> + | + FD: {resourceData.fileDescriptors} + + )} + + | + + UP: {formatTime(resourceData.system.uptime * 1000)} + + + ); +} + +export function ResourceDebugDetails({ visible }: { visible: boolean }) { + const [summary, setSummary] = useState(null); + + useEffect(() => { + if (!visible) return; + + const updateData = () => { + try { + const summaryData = services.resourceMonitoring.getResourceSummary(); + setSummary(summaryData); + } catch { + // Handle error silently + } + }; + + updateData(); + const intervalId = setInterval(updateData, 3000); + + return () => clearInterval(intervalId); + }, [visible]); + + if (!visible || !summary) { + return null; + } + + return ( + + + Resource Usage Summary + + + + Current: + {formatBytes(summary.current.memory.rss)} mem, + {formatPercent(summary.current.cpu.percent || 0)} cpu + + + + Peak: + {formatBytes(summary.peak.memory)} mem, + {formatPercent(summary.peak.cpu)} cpu + + + + Average: + {formatBytes(summary.average.memory)} mem, + {formatPercent(summary.average.cpu)} cpu + + + ); +} diff --git a/extensions/cli/src/ui/hooks/useChat.helpers.ts b/extensions/cli/src/ui/hooks/useChat.helpers.ts index 9649fac02..b8d77e028 100644 --- a/extensions/cli/src/ui/hooks/useChat.helpers.ts +++ b/extensions/cli/src/ui/hooks/useChat.helpers.ts @@ -7,7 +7,6 @@ import { posthogService } from "../../telemetry/posthogService.js"; import { telemetryService } from "../../telemetry/telemetryService.js"; import { formatError } from "../../util/formatError.js"; import { logger } from "../../util/logger.js"; -import { shouldAutoCompact } from "../../util/tokenizer.js"; import { DisplayMessage } from "../types.js"; import { SlashCommandResult } from "./useChat.types.js"; @@ -278,13 +277,13 @@ interface HandleAutoCompactionOptions { } /** - * Handle auto-compaction when approaching context limit + * Handle auto-compaction when approaching context limit - TUI wrapper */ export async function handleAutoCompaction({ chatHistory, model, llmApi, - compactionIndex, + compactionIndex: _compactionIndex, setMessages, setChatHistory, setCompactionIndex, @@ -292,69 +291,21 @@ export async function handleAutoCompaction({ currentChatHistory: ChatCompletionMessageParam[]; currentCompactionIndex: number | null; }> { - if (!model || !shouldAutoCompact(chatHistory, model)) { - return { - currentChatHistory: chatHistory, - currentCompactionIndex: compactionIndex, - }; - } + const { handleAutoCompaction: coreAutoCompaction } = await import( + "../../streamChatResponse.autoCompaction.js" + ); - logger.info("Auto-compacting triggered in TUI mode"); - - setMessages((prev) => [ - ...prev, - { - role: "system", - content: "Approaching context limit. Auto-compacting chat history...", - messageType: "system" as const, + const result = await coreAutoCompaction(chatHistory, model, llmApi, { + isHeadless: false, + callbacks: { + setMessages, + setChatHistory, + setCompactionIndex, }, - ]); + }); - try { - if (!llmApi) { - throw new Error("LLM API is not available for auto-compaction"); - } - - // Compact the history WITHOUT the current user message - const result = await compactChatHistory(chatHistory, model, llmApi); - - // Update state - setChatHistory(result.compactedHistory); - setCompactionIndex(result.compactionIndex); - - // Save the compacted session - saveSession(result.compactedHistory); - - setMessages((prev) => [ - ...prev, - { - role: "system", - content: "✓ Chat history auto-compacted successfully.", - messageType: "system" as const, - }, - ]); - - return { - currentChatHistory: result.compactedHistory, - currentCompactionIndex: result.compactionIndex, - }; - } catch (error: any) { - const errorMessage = `Auto-compaction error: ${formatError(error)}`; - logger.error(errorMessage); - - setMessages((prev) => [ - ...prev, - { - role: "system", - content: `Warning: ${errorMessage}. Continuing without compaction...`, - messageType: "system" as const, - }, - ]); - - // Continue without compaction on error - return { - currentChatHistory: chatHistory, - currentCompactionIndex: compactionIndex, - }; - } + return { + currentChatHistory: result.chatHistory, + currentCompactionIndex: result.compactionIndex, + }; } diff --git a/extensions/cli/src/ui/hooks/useChat.stream.helpers.ts b/extensions/cli/src/ui/hooks/useChat.stream.helpers.ts index 810e849e5..d88177811 100644 --- a/extensions/cli/src/ui/hooks/useChat.stream.helpers.ts +++ b/extensions/cli/src/ui/hooks/useChat.stream.helpers.ts @@ -111,6 +111,16 @@ export function createStreamCallbacks( toolCallPreview, }); }, + onSystemMessage: (message: string) => { + setMessages((prev) => [ + ...prev, + { + role: "system", + content: message, + messageType: "system" as const, + }, + ]); + }, }; } diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index 4a75c9a1f..a8b522260 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -42,6 +42,7 @@ export function useChat({ initialPrompt, resume, additionalRules, + additionalPrompts, onShowConfigSelector, onShowModelSelector, onShowMCPSelector, @@ -163,10 +164,27 @@ export function useChat({ useEffect(() => { // Only handle initial prompt after chat history is initialized // This prevents race conditions where the prompt runs before system message is loaded - if (initialPrompt && isChatHistoryInitialized) { - handleUserMessage(initialPrompt); + if ( + (initialPrompt || (additionalPrompts && additionalPrompts.length > 0)) && + isChatHistoryInitialized + ) { + const processPrompts = async () => { + const { processAndCombinePrompts } = await import( + "../../util/promptProcessor.js" + ); + const finalMessage = await processAndCombinePrompts( + additionalPrompts, + initialPrompt, + ); + + if (finalMessage) { + await handleUserMessage(finalMessage); + } + }; + + processPrompts().catch(console.error); } - }, [initialPrompt, isChatHistoryInitialized]); + }, [initialPrompt, additionalPrompts, isChatHistoryInitialized]); const executeStreamingResponse = async ( newHistory: ChatCompletionMessageParam[], diff --git a/extensions/cli/src/ui/hooks/useChat.types.ts b/extensions/cli/src/ui/hooks/useChat.types.ts index f0cca4978..fa752fed8 100644 --- a/extensions/cli/src/ui/hooks/useChat.types.ts +++ b/extensions/cli/src/ui/hooks/useChat.types.ts @@ -11,6 +11,7 @@ export interface UseChatProps { initialPrompt?: string; resume?: boolean; additionalRules?: string[]; + additionalPrompts?: string[]; onShowConfigSelector: () => void; onShowMCPSelector: () => void; onShowModelSelector?: () => void; diff --git a/extensions/cli/src/ui/hooks/useUserInput.ts b/extensions/cli/src/ui/hooks/useUserInput.ts index ae0dea719..ea8799b77 100644 --- a/extensions/cli/src/ui/hooks/useUserInput.ts +++ b/extensions/cli/src/ui/hooks/useUserInput.ts @@ -9,14 +9,28 @@ interface ControlKeysOptions { showSlashCommands: boolean; showFileSearch: boolean; cycleModes: () => Promise; + clearInput?: () => void; } export function handleControlKeys(options: ControlKeysOptions): boolean { - const { input, key, exit, showSlashCommands, showFileSearch, cycleModes } = - options; + const { + input, + key, + exit, + showSlashCommands, + showFileSearch, + cycleModes, + clearInput, + } = options; - // Handle Ctrl+C and Ctrl+D - if (key.ctrl && (input === "c" || input === "d")) { + // Handle Ctrl+C to clear input + if (key.ctrl && input === "c" && clearInput) { + clearInput(); + return true; + } + + // Handle Ctrl+D to exit + if (key.ctrl && input === "d") { exit(); return true; } diff --git a/extensions/cli/src/ui/index.ts b/extensions/cli/src/ui/index.ts index e75f9aa91..d0225b8de 100644 --- a/extensions/cli/src/ui/index.ts +++ b/extensions/cli/src/ui/index.ts @@ -12,9 +12,10 @@ export { MarkdownRenderer } from "./MarkdownRenderer.js"; interface StartTUIChatOptions { initialPrompt?: string; resume?: boolean; - configPath?: string; - organizationSlug?: string; - additionalRules?: string[]; + config?: string; + org?: string; + rule?: string[]; + prompt?: string[]; toolPermissionOverrides?: { allow?: string[]; ask?: string[]; @@ -30,9 +31,10 @@ export async function startTUIChat( const { initialPrompt, resume, - configPath, - organizationSlug, - additionalRules, + config, + org, + rule, + prompt, toolPermissionOverrides, skipOnboarding, customStdin, @@ -41,9 +43,7 @@ export async function startTUIChat( // Initialize services only if not already done (skipOnboarding means already initialized) if (!skipOnboarding) { await initializeServices({ - configPath, - organizationSlug, - rules: additionalRules, + options: { config, org, rule, prompt }, headless: false, toolPermissionOverrides, }); @@ -60,10 +60,11 @@ export async function startTUIChat( const { unmount } = render( React.createElement(ServiceContainerProvider, { children: React.createElement(AppRoot, { - configPath, + configPath: config, initialPrompt, resume, - additionalRules, + additionalRules: rule, + additionalPrompts: prompt, }), }), renderOptions, diff --git a/extensions/cli/src/util/apiKeyValidation.test.ts b/extensions/cli/src/util/apiKeyValidation.test.ts index 3f1802eaa..12f326e91 100644 --- a/extensions/cli/src/util/apiKeyValidation.test.ts +++ b/extensions/cli/src/util/apiKeyValidation.test.ts @@ -1,21 +1,21 @@ import { - isValidAnthropicApiKey, getApiKeyValidationError, + isValidAnthropicApiKey, } from "./apiKeyValidation.js"; describe("isValidAnthropicApiKey", () => { it("should return true for valid API keys", () => { - expect(isValidAnthropicApiKey("TEST-ant-1234567890")).toBe(true); - expect(isValidAnthropicApiKey("TEST-ant-abcdefghijklmnop")).toBe(true); - expect(isValidAnthropicApiKey("TEST-ant-test-key-with-dashes")).toBe(true); + expect(isValidAnthropicApiKey("sk-ant-1234567890")).toBe(true); + expect(isValidAnthropicApiKey("sk-ant-abcdefghijklmnop")).toBe(true); + expect(isValidAnthropicApiKey("sk-ant-test-key-with-dashes")).toBe(true); expect( - isValidAnthropicApiKey("TEST-ant-api03_T3BlbkFJ1234567890abcdef"), + isValidAnthropicApiKey("sk-ant-api03_T3BlbkFJ1234567890abcdef"), ).toBe(true); }); it("should return false for invalid API keys", () => { expect(isValidAnthropicApiKey("")).toBe(false); - expect(isValidAnthropicApiKey("TEST-ant-")).toBe(false); + expect(isValidAnthropicApiKey("sk-ant-")).toBe(false); expect(isValidAnthropicApiKey("TEST-")).toBe(false); expect(isValidAnthropicApiKey("TEST-openai-1234567890")).toBe(false); expect(isValidAnthropicApiKey("invalid-key")).toBe(false); @@ -40,14 +40,14 @@ describe("getApiKeyValidationError", () => { expect(getApiKeyValidationError(null)).toBe("API key is required"); expect(getApiKeyValidationError(undefined)).toBe("API key is required"); expect(getApiKeyValidationError("TEST-")).toBe( - 'API key must start with "TEST-ant-"', + 'API key must start with "sk-ant-"', ); expect(getApiKeyValidationError("TEST-openai-1234")).toBe( - 'API key must start with "TEST-ant-"', + 'API key must start with "sk-ant-"', ); - expect(getApiKeyValidationError("TEST-ant-")).toBe("API key is too short"); + expect(getApiKeyValidationError("sk-ant-")).toBe("API key is too short"); expect(getApiKeyValidationError("invalid")).toBe( - 'API key must start with "TEST-ant-"', + 'API key must start with "sk-ant-"', ); }); }); diff --git a/extensions/cli/src/util/apiKeyValidation.ts b/extensions/cli/src/util/apiKeyValidation.ts index 33ca1e568..f6fbd896c 100644 --- a/extensions/cli/src/util/apiKeyValidation.ts +++ b/extensions/cli/src/util/apiKeyValidation.ts @@ -10,8 +10,8 @@ export function isValidAnthropicApiKey( return false; } - // Anthropic API keys must start with "TEST-ant-" and have additional characters - return apiKey.startsWith("TEST-ant-") && apiKey.length > "TEST-ant-".length; + // Anthropic API keys must start with "sk-ant-" and have additional characters + return apiKey.startsWith("sk-ant-") && apiKey.length > "sk-ant-".length; } /** @@ -26,11 +26,11 @@ export function getApiKeyValidationError( return "API key is required"; } - if (!apiKey.startsWith("TEST-ant-")) { - return 'API key must start with "TEST-ant-"'; + if (!apiKey.startsWith("sk-ant-")) { + return 'API key must start with "sk-ant-"'; } - if (apiKey.length <= "TEST-ant-".length) { + if (apiKey.length <= "sk-ant-".length) { return "API key is too short"; } diff --git a/extensions/cli/src/util/consoleOverride.ts b/extensions/cli/src/util/consoleOverride.ts deleted file mode 100644 index 24ee2e5d0..000000000 --- a/extensions/cli/src/util/consoleOverride.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Console override utility to prevent unwanted output in headless mode - * This ensures that only intentional stdout output reaches the user - */ - -interface ConsoleBackup { - log: typeof console.log; - info: typeof console.info; - warn: typeof console.warn; - error: typeof console.error; - debug: typeof console.debug; -} - -let originalConsole: ConsoleBackup | null = null; -let isHeadlessMode = false; - -/** - * Override console methods to prevent unwanted output in headless mode - * In headless mode, only console.error and explicitly allowed outputs should reach stdout - */ -export function configureConsoleForHeadless(headless: boolean): void { - isHeadlessMode = headless; - - if (headless && !originalConsole) { - // Backup original console methods - originalConsole = { - log: console.log, - info: console.info, - warn: console.warn, - error: console.error, - debug: console.debug, - }; - - // Override console methods to suppress output in headless mode - console.log = () => {}; // Suppress all console.log - console.info = () => {}; // Suppress all console.info - console.warn = () => {}; // Suppress all console.warn - console.debug = () => {}; // Suppress all console.debug - - // Keep console.error for genuine errors, but send to stderr - console.error = (...args: any[]) => { - originalConsole!.error(...args); - }; - } else if (!headless && originalConsole) { - // Restore original console methods - console.log = originalConsole.log; - console.info = originalConsole.info; - console.warn = originalConsole.warn; - console.error = originalConsole.error; - console.debug = originalConsole.debug; - - originalConsole = null; - } -} - -/** - * Safe stdout output that bypasses console overrides - * Use this for intentional output in headless mode - */ -export function safeStdout(message: string): void { - process.stdout.write(message); -} - -/** - * Safe stderr output that bypasses console overrides - * Use this for error messages that should always be visible - */ -export function safeStderr(message: string): void { - process.stderr.write(message); -} - -/** - * Temporarily restore console for a specific operation - * Useful for debugging or when you need original console behavior - */ -export function withOriginalConsole(fn: () => T): T { - if (!originalConsole || !isHeadlessMode) { - return fn(); - } - - // Temporarily restore - const tempConsole = { ...console }; - Object.assign(console, originalConsole); - - try { - return fn(); - } finally { - // Restore overrides - Object.assign(console, tempConsole); - } -} - -/** - * Check if currently in headless mode - */ -export function isInHeadlessMode(): boolean { - return isHeadlessMode; -} - -/** - * Reset console overrides to original state - * Useful for testing to ensure clean state - */ -export function resetConsoleOverrides(): void { - if (originalConsole) { - console.log = originalConsole.log; - console.info = originalConsole.info; - console.warn = originalConsole.warn; - console.error = originalConsole.error; - console.debug = originalConsole.debug; - - originalConsole = null; - } - isHeadlessMode = false; -} diff --git a/extensions/cli/src/util/promptProcessor.test.ts b/extensions/cli/src/util/promptProcessor.test.ts new file mode 100644 index 000000000..4644e17c8 --- /dev/null +++ b/extensions/cli/src/util/promptProcessor.test.ts @@ -0,0 +1,127 @@ +import { describe, it, expect, vi, beforeEach } from "vitest"; + +import * as args from "../args.js"; + +import { processAndCombinePrompts } from "./promptProcessor.js"; + +// Mock the args module +vi.mock("../args.js", () => ({ + processPromptOrRule: vi.fn(), +})); + +// Mock the logger +vi.mock("./logger.js", () => ({ + logger: { + warn: vi.fn(), + }, +})); + +describe("promptProcessor", () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + describe("processAndCombinePrompts", () => { + it("should return initial prompt when no additional prompts", async () => { + const result = await processAndCombinePrompts(undefined, "initial"); + expect(result).toBe("initial"); + }); + + it("should return initial prompt when empty additional prompts array", async () => { + const result = await processAndCombinePrompts([], "initial"); + expect(result).toBe("initial"); + }); + + it("should return undefined when no prompts at all", async () => { + const result = await processAndCombinePrompts(); + expect(result).toBeUndefined(); + }); + + it("should process single additional prompt without initial", async () => { + const mockProcessPromptOrRule = vi.mocked(args.processPromptOrRule); + mockProcessPromptOrRule.mockResolvedValue("processed prompt"); + + const result = await processAndCombinePrompts(["prompt1"]); + + expect(mockProcessPromptOrRule).toHaveBeenCalledWith("prompt1"); + expect(result).toBe("processed prompt"); + }); + + it("should combine multiple processed prompts", async () => { + const mockProcessPromptOrRule = vi.mocked(args.processPromptOrRule); + mockProcessPromptOrRule + .mockResolvedValueOnce("first prompt") + .mockResolvedValueOnce("second prompt"); + + const result = await processAndCombinePrompts(["prompt1", "prompt2"]); + + expect(mockProcessPromptOrRule).toHaveBeenCalledTimes(2); + expect(mockProcessPromptOrRule).toHaveBeenNthCalledWith(1, "prompt1"); + expect(mockProcessPromptOrRule).toHaveBeenNthCalledWith(2, "prompt2"); + expect(result).toBe("first prompt\n\nsecond prompt"); + }); + + it("should combine processed prompts with initial prompt", async () => { + const mockProcessPromptOrRule = vi.mocked(args.processPromptOrRule); + mockProcessPromptOrRule + .mockResolvedValueOnce("processed1") + .mockResolvedValueOnce("processed2"); + + const result = await processAndCombinePrompts( + ["prompt1", "prompt2"], + "initial", + ); + + expect(result).toBe("processed1\n\nprocessed2\n\ninitial"); + }); + + it("should handle processing errors and continue with successful ones", async () => { + const mockProcessPromptOrRule = vi.mocked(args.processPromptOrRule); + mockProcessPromptOrRule + .mockResolvedValueOnce("success1") + .mockRejectedValueOnce(new Error("processing failed")) + .mockResolvedValueOnce("success2"); + + const result = await processAndCombinePrompts(["good1", "bad", "good2"]); + + expect(mockProcessPromptOrRule).toHaveBeenCalledTimes(3); + expect(result).toBe("success1\n\nsuccess2"); + }); + + it("should return initial prompt when all processing fails", async () => { + const mockProcessPromptOrRule = vi.mocked(args.processPromptOrRule); + mockProcessPromptOrRule + .mockRejectedValueOnce(new Error("fail1")) + .mockRejectedValueOnce(new Error("fail2")); + + const result = await processAndCombinePrompts( + ["bad1", "bad2"], + "initial", + ); + + expect(result).toBe("initial"); + }); + + it("should return undefined when all processing fails and no initial", async () => { + const mockProcessPromptOrRule = vi.mocked(args.processPromptOrRule); + mockProcessPromptOrRule.mockRejectedValue(new Error("processing failed")); + + const result = await processAndCombinePrompts(["bad"]); + + expect(result).toBeUndefined(); + }); + + it("should warn when processing fails", async () => { + const mockProcessPromptOrRule = vi.mocked(args.processPromptOrRule); + mockProcessPromptOrRule.mockRejectedValue(new Error("test error")); + + const { logger } = await import("./logger.js"); + + await processAndCombinePrompts(["bad-prompt"]); + + expect(logger.warn).toHaveBeenCalledWith( + 'Failed to process prompt "bad-prompt": test error', + ); + }); + }); +}); diff --git a/extensions/cli/src/util/promptProcessor.ts b/extensions/cli/src/util/promptProcessor.ts new file mode 100644 index 000000000..c6173738f --- /dev/null +++ b/extensions/cli/src/util/promptProcessor.ts @@ -0,0 +1,38 @@ +import { processPromptOrRule } from "../args.js"; + +import { logger } from "./logger.js"; + +/** + * Process additional prompts from --prompt flags and combine with initial prompt + * @param additionalPrompts - Array of prompt specifications to process + * @param initialPrompt - Optional initial prompt to combine with + * @returns Combined prompt string or undefined if no prompts + */ +export async function processAndCombinePrompts( + additionalPrompts?: string[], + initialPrompt?: string, +): Promise { + if (!additionalPrompts || additionalPrompts.length === 0) { + return initialPrompt; + } + + const processedPrompts: string[] = []; + + for (const promptSpec of additionalPrompts) { + try { + const processed = await processPromptOrRule(promptSpec); + processedPrompts.push(processed); + } catch (error: any) { + logger.warn(`Failed to process prompt "${promptSpec}": ${error.message}`); + } + } + + if (processedPrompts.length === 0) { + return initialPrompt; + } + + const combinedPrompts = processedPrompts.join("\n\n"); + return initialPrompt + ? `${combinedPrompts}\n\n${initialPrompt}` + : combinedPrompts; +} diff --git a/extensions/cli/src/util/tokenizer.test.ts b/extensions/cli/src/util/tokenizer.test.ts new file mode 100644 index 000000000..97ed9418a --- /dev/null +++ b/extensions/cli/src/util/tokenizer.test.ts @@ -0,0 +1,292 @@ +import { ModelConfig } from "@continuedev/config-yaml"; +import { ChatCompletionMessageParam } from "openai/resources.mjs"; +import { beforeEach, describe, expect, it, vi } from "vitest"; + +import { logger } from "./logger.js"; +import { + AUTO_COMPACT_THRESHOLD, + calculateContextUsagePercentage, + countChatHistoryTokens, + countMessageTokens, + getModelContextLimit, + shouldAutoCompact, +} from "./tokenizer.js"; + +// Mock the logger +vi.mock("./logger.js", () => ({ + logger: { + debug: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + }, +})); + +// Mock gpt-tokenizer +vi.mock("gpt-tokenizer", () => ({ + encode: (text: string) => new Array(Math.ceil(text.length / 4)), // Rough 4 chars per token +})); + +describe("tokenizer", () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + describe("getModelContextLimit", () => { + it("should return contextLength from model config", () => { + const model: ModelConfig = { + name: "test-model", + model: "test", + provider: "openai", + defaultCompletionOptions: { + contextLength: 8192, + }, + }; + + expect(getModelContextLimit(model)).toBe(8192); + }); + + it("should return default when no contextLength specified", () => { + const model: ModelConfig = { + name: "test-model", + model: "test", + provider: "openai", + }; + + expect(getModelContextLimit(model)).toBe(200_000); + }); + }); + + describe("countMessageTokens", () => { + it("should count tokens for string content", () => { + const message: ChatCompletionMessageParam = { + role: "user", + content: "Hello world", // 11 chars -> ~3 tokens + 2 for role = 5 + }; + + const tokenCount = countMessageTokens(message); + expect(tokenCount).toBeGreaterThan(0); + expect(tokenCount).toBe(5); // 3 content tokens + 2 role tokens + }); + + it("should count tokens for array content", () => { + const message: ChatCompletionMessageParam = { + role: "user", + content: [ + { type: "text", text: "Hello" }, // 5 chars -> ~2 tokens + { type: "image_url", image_url: { url: "test.jpg" } }, // +85 tokens + ], + }; + + const tokenCount = countMessageTokens(message); + expect(tokenCount).toBe(89); // 2 + 85 + 2 role tokens + }); + + it("should count tokens for tool calls", () => { + const message: ChatCompletionMessageParam = { + role: "assistant", + content: "I'll help you", + tool_calls: [ + { + id: "call_1", + type: "function", + function: { + name: "test_function", // ~3 tokens + 10 overhead + arguments: '{"param": "value"}', // ~5 tokens + }, + }, + ], + }; + + const tokenCount = countMessageTokens(message); + expect(tokenCount).toBeGreaterThan(20); + }); + + it("should handle errors gracefully", () => { + // We'll skip this test for now since mocking gpt-tokenizer is complex + // The error handling is tested implicitly by the fallback behavior + expect(true).toBe(true); + }); + }); + + describe("countChatHistoryTokens", () => { + it("should count tokens for multiple messages", () => { + const chatHistory: ChatCompletionMessageParam[] = [ + { role: "system", content: "You are helpful" }, + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi there" }, + ]; + + const tokenCount = countChatHistoryTokens(chatHistory); + expect(tokenCount).toBeGreaterThan(0); + // Should include message overhead (3 * 3 = 9 tokens) + expect(tokenCount).toBeGreaterThan(9); + }); + + it("should handle empty chat history", () => { + const tokenCount = countChatHistoryTokens([]); + expect(tokenCount).toBe(0); + }); + }); + + describe("calculateContextUsagePercentage", () => { + it("should calculate percentage correctly", () => { + const model: ModelConfig = { + name: "test-model", + model: "test", + provider: "openai", + defaultCompletionOptions: { + contextLength: 1000, + }, + }; + + expect(calculateContextUsagePercentage(800, model)).toBe(80); + expect(calculateContextUsagePercentage(500, model)).toBe(50); + expect(calculateContextUsagePercentage(1200, model)).toBe(100); // Capped at 100% + }); + }); + + describe("shouldAutoCompact", () => { + const createModel = ( + contextLength: number, + maxTokens?: number, + ): ModelConfig => ({ + name: "test-model", + model: "test", + provider: "openai", + defaultCompletionOptions: { + contextLength, + maxTokens, + }, + }); + + const createChatHistory = ( + tokenCount: number, + ): ChatCompletionMessageParam[] => { + // Create a message that will result in approximately the desired token count + const content = "x".repeat(tokenCount * 4); // 4 chars per token + return [{ role: "user", content }]; + }; + + it("should compact when input tokens exceed threshold with maxTokens", () => { + const model = createModel(1000, 200); // 1000 context, 200 max output + // Available for input: 1000 - 200 = 800 + // Threshold: 800 * 0.8 = 640 + const chatHistory = createChatHistory(650); // Above threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(true); + }); + + it("should not compact when input tokens are below threshold with maxTokens", () => { + const model = createModel(1000, 200); // 1000 context, 200 max output + // Available for input: 1000 - 200 = 800 + // Threshold: 800 * 0.8 = 640 + const chatHistory = createChatHistory(600); // Below threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(false); + }); + + it("should use 35% default reservation when maxTokens is not set", () => { + const model = createModel(1000); // No maxTokens + // Reserved: 1000 * 0.35 = 350 + // Available for input: 1000 - 350 = 650 + // Threshold: 650 * 0.8 = 520 + const chatHistory = createChatHistory(530); // Above threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(true); + }); + + it("should not compact when below default threshold without maxTokens", () => { + const model = createModel(1000); // No maxTokens + // Available for input: 1000 - 350 = 650 + // Threshold: 650 * 0.8 = 520 + const chatHistory = createChatHistory(500); // Below threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(false); + }); + + it("should throw error when maxTokens >= contextLength", () => { + const model = createModel(1000, 1000); // maxTokens equals contextLength + const chatHistory = createChatHistory(1); // Minimal input + + expect(() => shouldAutoCompact(chatHistory, model)).toThrow( + "max_tokens is larger than context_length, which should not be possible. Please check your configuration.", + ); + }); + + it("should throw error when maxTokens > contextLength", () => { + const model = createModel(1000, 1200); // maxTokens exceeds contextLength + const chatHistory = createChatHistory(1); // Minimal input + + expect(() => shouldAutoCompact(chatHistory, model)).toThrow( + "max_tokens is larger than context_length, which should not be possible. Please check your configuration.", + ); + }); + + it("should handle edge case with very small context limit", () => { + const model = createModel(100, 50); // Small context + // Available: 100 - 50 = 50 + // Threshold: 50 * 0.8 = 40 + const chatHistory = createChatHistory(45); // Above threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(true); + }); + + it("should log debug information correctly", () => { + const model = createModel(1000, 200); + const chatHistory = createChatHistory(600); + + shouldAutoCompact(chatHistory, model); + + expect(logger.debug).toHaveBeenCalledWith("Context usage check", { + inputTokens: expect.any(Number), + contextLimit: 1000, + maxTokens: 200, + reservedForOutput: 200, + availableForInput: 800, + usage: expect.any(String), + threshold: `${Math.round(AUTO_COMPACT_THRESHOLD * 100)}%`, + shouldCompact: expect.any(Boolean), + }); + }); + + it("should handle model with zero maxTokens correctly", () => { + const model = createModel(1000, 0); // Explicit zero + // Should use default 35% reservation: 1000 * 0.35 = 350 + const chatHistory = createChatHistory(530); // Above threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(true); + }); + + describe("real-world scenarios", () => { + it("should prevent Claude 3.5 Sonnet context overflow", () => { + // Claude 3.5 Sonnet: 200k context, often uses 4k max_tokens + const model = createModel(200_000, 4_000); + // Available: 200k - 4k = 196k + // Threshold: 196k * 0.8 = 156.8k + const chatHistory = createChatHistory(160_000); // Above threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(true); + }); + + it("should prevent GPT-4 context overflow", () => { + // GPT-4: 128k context, often uses 4k max_tokens + const model = createModel(128_000, 4_000); + // Available: 128k - 4k = 124k + // Threshold: 124k * 0.8 = 99.2k + const chatHistory = createChatHistory(100_000); // Above threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(true); + }); + + it("should handle models with very high max_tokens", () => { + // Some models allow very high max_tokens (e.g., 64k like in the error message) + const model = createModel(200_000, 64_000); + // Available: 200k - 64k = 136k + // Threshold: 136k * 0.8 = 108.8k + const chatHistory = createChatHistory(110_000); // Above threshold + + expect(shouldAutoCompact(chatHistory, model)).toBe(true); + }); + }); + }); +}); diff --git a/extensions/cli/src/util/tokenizer.ts b/extensions/cli/src/util/tokenizer.ts index 7dc53e809..5bf0117a4 100644 --- a/extensions/cli/src/util/tokenizer.ts +++ b/extensions/cli/src/util/tokenizer.ts @@ -117,20 +117,39 @@ export function calculateContextUsagePercentage( /** * Check if the chat history exceeds the auto-compact threshold * @param chatHistory The chat history to check - * @param modelName The model name + * @param model The model configuration * @returns Whether auto-compacting should be triggered */ export function shouldAutoCompact( chatHistory: ChatCompletionMessageParam[], model: ModelConfig, ): boolean { - const tokenCount = countChatHistoryTokens(chatHistory); - const limit = getModelContextLimit(model); - const usage = tokenCount / limit; + const inputTokens = countChatHistoryTokens(chatHistory); + const contextLimit = getModelContextLimit(model); + const maxTokens = model.defaultCompletionOptions?.maxTokens || 0; + + // Calculate available space considering max_tokens reservation + // If maxTokens is not set, reserve 35% of context for output as a safe default + // (64k/200k with claude = 32%, round up to give a buffer) + const reservedForOutput = + maxTokens > 0 ? maxTokens : Math.ceil(contextLimit * 0.35); + const availableForInput = contextLimit - reservedForOutput; + + // Ensure we have positive space available for input + if (availableForInput <= 0) { + throw new Error( + `max_tokens is larger than context_length, which should not be possible. Please check your configuration.`, + ); + } + + const usage = inputTokens / availableForInput; logger.debug("Context usage check", { - tokenCount, - limit, + inputTokens, + contextLimit, + maxTokens, + reservedForOutput, + availableForInput, usage: `${Math.round(usage * 100)}%`, threshold: `${Math.round(AUTO_COMPACT_THRESHOLD * 100)}%`, shouldCompact: usage >= AUTO_COMPACT_THRESHOLD, @@ -138,3 +157,13 @@ export function shouldAutoCompact( return usage >= AUTO_COMPACT_THRESHOLD; } + +/** + * Get a descriptive message for auto-compaction that shows the context limit + * @param model The model configuration + * @returns A descriptive message explaining why compaction is needed + */ +export function getAutoCompactMessage(model: ModelConfig): string { + const limit = getModelContextLimit(model); + return `Approaching context limit (${(limit / 1000).toFixed(0)}K tokens). Auto-compacting chat history...`; +} diff --git a/extensions/cli/src/util/yamlConfigUpdater.test.ts b/extensions/cli/src/util/yamlConfigUpdater.test.ts index c7f740cd1..cb65b6b9e 100644 --- a/extensions/cli/src/util/yamlConfigUpdater.test.ts +++ b/extensions/cli/src/util/yamlConfigUpdater.test.ts @@ -3,7 +3,7 @@ import { parse } from "yaml"; import { updateAnthropicModelInYaml } from "./yamlConfigUpdater.js"; describe("updateAnthropicModelInYaml", () => { - const testApiKey = "TEST-ant-test123456789"; + const testApiKey = "sk-ant-test123456789"; describe("empty or invalid input", () => { it("should create new config from empty string", () => { @@ -13,7 +13,7 @@ describe("updateAnthropicModelInYaml", () => { expect(result).toContain("version: 1.0.0"); expect(result).toContain("schema: v1"); expect(result).toContain("uses: anthropic/claude-4-sonnet"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); }); it("should create new config from invalid YAML", () => { @@ -22,7 +22,7 @@ describe("updateAnthropicModelInYaml", () => { expect(result).toContain("name: Local Config"); expect(result).toContain("uses: anthropic/claude-4-sonnet"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); }); }); @@ -45,7 +45,7 @@ models: expect(result).toContain("# List of available models"); expect(result).toContain("uses: openai/gpt-4"); expect(result).toContain("uses: anthropic/claude-4-sonnet"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); }); it("should preserve comments when updating existing model", () => { @@ -65,7 +65,7 @@ models: expect(result).toContain("# My Continue config"); expect(result).toContain("# List of available models"); expect(result).toContain("uses: anthropic/claude-4-sonnet"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); expect(result).not.toContain("old-key"); }); }); @@ -85,7 +85,7 @@ models: expect(result).toContain("uses: openai/gpt-4"); expect(result).toContain("uses: anthropic/claude-4-sonnet"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); expect(result).toContain("OPENAI_API_KEY: TEST-openai-test"); }); @@ -106,7 +106,7 @@ models: expect(result).toContain("uses: anthropic/claude-4-sonnet"); expect(result).toContain("uses: openai/gpt-4"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); expect(result).toContain("OPENAI_API_KEY: TEST-openai-test"); expect(result).not.toContain("old-anthropic-key"); @@ -131,7 +131,7 @@ schema: v1 expect(result).toContain("name: Local Config"); expect(result).toContain("models:"); expect(result).toContain("uses: anthropic/claude-4-sonnet"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); }); it("should handle config with empty models array", () => { @@ -148,7 +148,7 @@ models: [] expect(result).toContain("name: Local Config"); expect(result).toContain("uses: anthropic/claude-4-sonnet"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); }); }); @@ -190,14 +190,14 @@ models: "not an array" const result = updateAnthropicModelInYaml(malformedConfig, testApiKey); expect(result).toContain("uses: anthropic/claude-4-sonnet"); - expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789"); + expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789"); }); it("should handle different API key formats", () => { const differentKeys = [ - "TEST-ant-1234567890", - "TEST-ant-abcdefghijklmnop", - "TEST-ant-test-key-with-dashes", + "sk-ant-1234567890", + "sk-ant-abcdefghijklmnop", + "sk-ant-test-key-with-dashes", ]; differentKeys.forEach((key) => { diff --git a/extensions/cli/stubs/react-devtools-core.js b/extensions/cli/stubs/react-devtools-core.js new file mode 100644 index 000000000..7f0803496 --- /dev/null +++ b/extensions/cli/stubs/react-devtools-core.js @@ -0,0 +1,6 @@ +// Stub for react-devtools-core to prevent errors when it's not installed +export default { + connectToDevTools: () => { + // No-op - devtools not available in production bundle + }, +}; diff --git a/extensions/cli/test-fixtures/model-switch-test-config.yaml b/extensions/cli/test-fixtures/model-switch-test-config.yaml new file mode 100644 index 000000000..70dc69a91 --- /dev/null +++ b/extensions/cli/test-fixtures/model-switch-test-config.yaml @@ -0,0 +1,18 @@ +name: Model Switch Test Config +version: 1.0.0 + +models: + - name: GPT-4 + provider: openai + model: gpt-4 + apiKey: test-api-key-1 + + - name: GPT-3.5 + provider: openai + model: gpt-3.5-turbo + apiKey: test-api-key-2 + + - name: Claude 3 + provider: anthropic + model: claude-3-opus + apiKey: test-api-key-3 \ No newline at end of file diff --git a/extensions/cli/validate-aliases.mjs b/extensions/cli/validate-aliases.mjs new file mode 100755 index 000000000..2f714a9dd --- /dev/null +++ b/extensions/cli/validate-aliases.mjs @@ -0,0 +1,188 @@ +#!/usr/bin/env node + +import { readFileSync, existsSync } from "fs"; +import { resolve, dirname } from "path"; +import { fileURLToPath } from "url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +// Colors for output +const colors = { + green: "\x1b[32m", + red: "\x1b[31m", + yellow: "\x1b[33m", + blue: "\x1b[34m", + reset: "\x1b[0m", +}; + +/** + * Parse the build.mjs file to extract defined aliases + */ +function getDefinedAliases() { + const buildPath = resolve(__dirname, "build.mjs"); + const buildContent = readFileSync(buildPath, "utf8"); + + // Find the alias object in the build file + const aliasMatch = buildContent.match(/alias:\s*{([^}]+)}/s); + if (!aliasMatch) { + console.warn(`${colors.yellow}Warning: No aliases found in build.mjs${colors.reset}`); + return new Set(); + } + + // Extract package names from the alias definitions + // Split by lines and filter out comments + const aliasBlock = aliasMatch[1]; + const lines = aliasBlock.split('\n'); + const aliases = new Set(); + + for (const line of lines) { + // Skip commented lines + if (line.trim().startsWith('//')) { + continue; + } + + // Look for package names in non-commented lines + // Match both quoted and unquoted keys + const quotedMatch = line.match(/"([^"]+)":/); + const unquotedMatch = line.match(/\s+([a-zA-Z@][a-zA-Z0-9@\/_-]*)\s*:/); + + if (quotedMatch) { + aliases.add(quotedMatch[1]); + } else if (unquotedMatch && !unquotedMatch[1].includes('__dirname') && unquotedMatch[1] !== 'js') { + aliases.add(unquotedMatch[1]); + } + } + + return aliases; +} + +/** + * Find all local packages referenced with file: in package.json files + */ +function findLocalPackages(startPath, visited = new Set()) { + const localPackages = new Set(); + + function scanPackageJson(packageJsonPath, depth = 0) { + // Avoid infinite recursion + if (visited.has(packageJsonPath) || depth > 10) { + return; + } + visited.add(packageJsonPath); + + if (!existsSync(packageJsonPath)) { + return; + } + + try { + const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")); + const packageDir = dirname(packageJsonPath); + + // Check both dependencies and devDependencies + const allDeps = { + ...packageJson.dependencies, + ...packageJson.devDependencies, + }; + + for (const [depName, depVersion] of Object.entries(allDeps)) { + if (typeof depVersion === "string" && depVersion.startsWith("file:")) { + // This is a local package + localPackages.add(depName); + + // Recursively check this package's dependencies + const depPath = resolve(packageDir, depVersion.replace("file:", "")); + const depPackageJson = resolve(depPath, "package.json"); + + if (existsSync(depPackageJson)) { + scanPackageJson(depPackageJson, depth + 1); + } + } + } + } catch (error) { + console.error(`${colors.red}Error reading ${packageJsonPath}: ${error.message}${colors.reset}`); + } + } + + // Start from the CLI's package.json + scanPackageJson(startPath); + + return localPackages; +} + +/** + * Main validation function + */ +function validateAliases() { + console.log(`${colors.blue}🔍 Validating esbuild aliases...${colors.reset}\n`); + + // Get defined aliases from build.mjs + const definedAliases = getDefinedAliases(); + console.log(`Found ${definedAliases.size} aliases in build.mjs:`); + definedAliases.forEach(alias => { + console.log(` ✓ ${alias}`); + }); + console.log(); + + // Find all local packages that need aliases + const cliPackageJson = resolve(__dirname, "package.json"); + const localPackages = findLocalPackages(cliPackageJson); + console.log(`Found ${localPackages.size} local package dependencies:`); + localPackages.forEach(pkg => { + console.log(` • ${pkg}`); + }); + console.log(); + + // Check for missing aliases + const missingAliases = []; + for (const pkg of localPackages) { + if (!definedAliases.has(pkg)) { + missingAliases.push(pkg); + } + } + + // Check for unnecessary aliases (defined but not used) + const unnecessaryAliases = []; + for (const alias of definedAliases) { + if (!localPackages.has(alias)) { + unnecessaryAliases.push(alias); + } + } + + // Report results + if (missingAliases.length > 0) { + console.log(`${colors.red}❌ Missing aliases (WILL CAUSE RUNTIME ERRORS):${colors.reset}`); + missingAliases.forEach(pkg => { + console.log(` ✗ ${pkg}`); + }); + console.log(); + console.log(`${colors.red}Add these to the alias section in build.mjs:${colors.reset}`); + missingAliases.forEach(pkg => { + const packageName = pkg.replace("@continuedev/", "").replace(/-/g, "_"); + console.log(` "${pkg}": resolve(__dirname, "../../packages/${pkg.replace("@continuedev/", "")}/dist/index.js"),`); + }); + console.log(); + } + + if (unnecessaryAliases.length > 0) { + console.log(`${colors.yellow}⚠️ Potentially unnecessary aliases:${colors.reset}`); + unnecessaryAliases.forEach(alias => { + console.log(` ? ${alias}`); + }); + console.log(); + } + + // Exit with appropriate code + if (missingAliases.length > 0) { + console.log(`${colors.red}✗ Validation failed! Missing ${missingAliases.length} required alias(es).${colors.reset}`); + console.log(`${colors.red}This would cause runtime errors in the bundled CLI.${colors.reset}`); + process.exit(1); + } else if (unnecessaryAliases.length > 0) { + console.log(`${colors.yellow}✓ Validation passed with warnings.${colors.reset}`); + process.exit(0); + } else { + console.log(`${colors.green}✅ All aliases are correctly configured!${colors.reset}`); + process.exit(0); + } +} + +// Run validation +validateAliases(); \ No newline at end of file diff --git a/extensions/cli/vitest.setup.ts b/extensions/cli/vitest.setup.ts index c7ad30ec3..886bd6ca0 100644 --- a/extensions/cli/vitest.setup.ts +++ b/extensions/cli/vitest.setup.ts @@ -1,6 +1,6 @@ import { vi } from "vitest"; -import { resetConsoleOverrides } from "./src/util/consoleOverride.js"; +import { resetConsoleOverrides } from "./src/init.js"; // Disable telemetry for tests process.env.CONTINUE_CLI_ENABLE_TELEMETRY = "0"; diff --git a/extensions/intellij/build.gradle.kts b/extensions/intellij/build.gradle.kts index 6cd36e473..811dc4d05 100644 --- a/extensions/intellij/build.gradle.kts +++ b/extensions/intellij/build.gradle.kts @@ -15,7 +15,6 @@ plugins { id("org.jetbrains.intellij.platform") version "2.7.2" id("org.jetbrains.changelog") version "2.1.2" id("org.jetbrains.qodana") version "0.1.13" - id("org.jetbrains.kotlinx.kover") version "0.7.3" id("io.sentry.jvm.gradle") version "5.8.0" } @@ -78,12 +77,6 @@ qodana { showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false) } -koverReport { - defaults { - xml { onCheck = true } - } -} - intellijPlatformTesting { runIde { register("runIdeForUiTests") { diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 50c52640c..e09d46b1e 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -1,5 +1,5 @@ pluginGroup=com.github.continuedev.continueintellijextension -pluginVersion=1.0.38 +pluginVersion=1.0.40 platformVersion=2024.1 kotlin.stdlib.default.dependency=false org.gradle.configuration-cache=true diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 76e958b38..b4d581f9e 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.71", + "version": "1.1.79", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.71", + "version": "1.1.79", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "file:../../packages/config-types", @@ -111,6 +111,11 @@ "@modelcontextprotocol/sdk": "^1.12.0", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.1.1", + "@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", "@typescript-eslint/eslint-plugin": "^7.8.0", "@xenova/transformers": "2.14.0", "adf-to-md": "^1.1.0", @@ -143,7 +148,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", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 4a321af0c..af10a7043 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.79", + "version": "1.3.1", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/extensions/vscode/src/activation/NextEditWindowManager.ts b/extensions/vscode/src/activation/NextEditWindowManager.ts index e451d72dd..1279a95da 100644 --- a/extensions/vscode/src/activation/NextEditWindowManager.ts +++ b/extensions/vscode/src/activation/NextEditWindowManager.ts @@ -122,6 +122,11 @@ export class NextEditWindowManager { private editableRegionStartLine: number = 0; private editableRegionEndLine: number = 0; + // State tracking for key reservation. + // By default it is set to free, and is only set to reserved when the transition is done. + private keyReservationState: "free" | "reserved" | "transitioning" = "free"; + private latestOperationId = 0; + // Disposables private disposables: vscode.Disposable[] = []; @@ -170,20 +175,71 @@ export class NextEditWindowManager { this.loggingService = NextEditLoggingService.getInstance(); } + // This is an implementation of last-action-wins. + // For each action that fires setKeyReservation, it keeps its own operationId while incrementing latestOperationId. + // When an action completes, checking for operationId === latestOperationId will determine which one came last. + private async setKeyReservation(reserve: boolean): Promise { + // Increment and capture this operation's ID. + const operationId = ++this.latestOperationId; + + // Return early when already in desired state. + if ( + (reserve && this.keyReservationState === "reserved") || + (!reserve && this.keyReservationState === "free") + ) { + return; + } + + try { + await this.performKeyReservation(reserve); + + // Only update state if we're still the latest operation. + if (operationId === this.latestOperationId) { + this.keyReservationState = reserve ? "reserved" : "free"; + } + } catch (err) { + console.error(`Failed to set nextEditWindowActive to ${reserve}: ${err}`); + + // Only reset to free if we're still the latest operation. + if (operationId === this.latestOperationId) { + this.keyReservationState = "free"; + } + throw err; + } + } + + public async resetKeyReservation(): Promise { + // Reset internal tracking. + this.keyReservationState = "free"; + this.latestOperationId = 0; + + // Ensure VS Code context matches. + try { + await this.performKeyReservation(false); + } catch (err) { + console.error(`Failed to reset nextEditWindowActive context: ${err}`); + } + } + + private async performKeyReservation(reserve: boolean): Promise { + try { + await vscode.commands.executeCommand( + "setContext", + "nextEditWindowActive", + reserve, + ); + } catch (err) { + console.error(`Failed to set nextEditWindowActive to ${reserve}: ${err}`); + throw err; + } + } + public static async reserveTabAndEsc() { - await vscode.commands.executeCommand( - "setContext", - "nextEditWindowActive", - true, - ); + await NextEditWindowManager.getInstance().setKeyReservation(true); } public static async freeTabAndEsc() { - await vscode.commands.executeCommand( - "setContext", - "nextEditWindowActive", - false, - ); + await NextEditWindowManager.getInstance().setKeyReservation(false); } /** @@ -202,7 +258,8 @@ export class NextEditWindowManager { // Set nextEditWindowActive to false to free esc and tab, // letting them return to their original behaviors. - await NextEditWindowManager.freeTabAndEsc(); + await this.resetKeyReservation(); + // await NextEditWindowManager.freeTabAndEsc(); // Register HIDE_TOOLTIP_COMMAND and ACCEPT_NEXT_EDIT_COMMAND with their corresponding callbacks. this.registerCommandSafely(HIDE_NEXT_EDIT_SUGGESTION_COMMAND, async () => { @@ -353,14 +410,21 @@ export class NextEditWindowManager { // Create and apply decoration with the text. if (newEditRangeSlice !== "") { - await this.renderWindow( - editor, - currCursorPos, - oldEditRangeSlice, - newEditRangeSlice, - this.editableRegionStartLine, - diffLines, - ); + try { + await this.renderWindow( + editor, + currCursorPos, + oldEditRangeSlice, + newEditRangeSlice, + this.editableRegionStartLine, + diffLines, + ); + } catch (error) { + console.error("Failed to render window:", error); + // Clean up and reset state. + await this.hideAllNextEditWindows(); + return; + } } const diffChars = myersCharDiff(oldEditRangeSlice, newEditRangeSlice); @@ -368,14 +432,26 @@ export class NextEditWindowManager { this.renderDeletions(editor, diffChars); // Reserve tab and esc to either accept or reject the displayed next edit contents. - await NextEditWindowManager.reserveTabAndEsc(); + try { + await NextEditWindowManager.reserveTabAndEsc(); + } catch (err) { + console.error( + `Error reserving Tab/Esc after showing decorations: ${err}`, + ); + await this.hideAllNextEditWindows(); + return; + } } /** * Hide all tooltips in all editors. */ public async hideAllNextEditWindows() { - await NextEditWindowManager.freeTabAndEsc(); + try { + await NextEditWindowManager.freeTabAndEsc(); + } catch (err) { + console.error(`Error freeing Tab/Esc while hiding: ${err}`); + } if (this.currentDecoration) { vscode.window.visibleTextEditors.forEach((editor) => { @@ -502,6 +578,10 @@ export class NextEditWindowManager { * Dispose of the NextEditWindowManager. */ public dispose() { + void this.resetKeyReservation().catch((err) => + console.error(`Failed to reset keys on dispose: ${err}`), + ); + // Dispose current decoration. if (this.currentDecoration) { this.currentDecoration.dispose(); diff --git a/extensions/vscode/src/activation/NextEditWindowManager.vitest.ts b/extensions/vscode/src/activation/NextEditWindowManager.vitest.ts new file mode 100644 index 000000000..9766955cc --- /dev/null +++ b/extensions/vscode/src/activation/NextEditWindowManager.vitest.ts @@ -0,0 +1,970 @@ +import { + afterEach, + beforeEach, + describe, + expect, + it, + MockedFunction, + vi, +} from "vitest"; + +// Mock all modules FIRST with inline factories (no external references) +vi.mock("vscode", () => ({ + commands: { + executeCommand: vi.fn(), + registerCommand: vi.fn(), + }, + window: { + activeTextEditor: undefined, + visibleTextEditors: [], + createTextEditorDecorationType: vi.fn(), + onDidChangeTextEditorSelection: vi.fn(() => ({ dispose: vi.fn() })), + onDidChangeVisibleTextEditors: vi.fn(() => ({ dispose: vi.fn() })), + onDidChangeActiveColorTheme: vi.fn(() => ({ dispose: vi.fn() })), + showInformationMessage: vi.fn(), + }, + workspace: { + getConfiguration: vi.fn(() => ({ + get: vi.fn((key: string) => { + const config: Record = { + fontSize: 14, + fontFamily: "monospace", + showInlineTip: true, + }; + return config[key]; + }), + })), + onDidChangeConfiguration: vi.fn(() => ({ dispose: vi.fn() })), + }, + Position: class { + constructor( + public line: number, + public character: number, + ) {} + }, + Range: class { + constructor( + public start: any, + public end: any, + ) {} + }, + Selection: class { + constructor( + public anchor: any, + public active: any, + ) {} + }, + Uri: { + parse: vi.fn((str: string) => ({ toString: () => str, scheme: "file" })), + }, + DecorationRangeBehavior: { + ClosedClosed: 1, + }, + MarkdownString: class { + value: string = ""; + isTrusted: boolean = false; + supportHtml: boolean = false; + constructor(value: string) { + this.value = value; + } + }, + ExtensionContext: class { + subscriptions: any[] = []; + }, + ViewColumn: { + One: 1, + Two: 2, + }, +})); + +vi.mock("core/control-plane/env", () => ({ + EXTENSION_NAME: "continue", +})); + +vi.mock("../util/getTheme", () => ({ + getThemeString: vi.fn(() => "dark"), +})); + +vi.mock("core/codeRenderer/CodeRenderer", () => ({ + CodeRenderer: { + getInstance: vi.fn(() => ({ + setTheme: vi.fn(), + getDataUri: vi.fn().mockResolvedValue("data:image/svg+xml;base64,mock"), + })), + }, +})); + +vi.mock("core/nextEdit/NextEditProvider", () => ({ + NextEditProvider: { + getInstance: vi.fn(() => ({ + deleteChain: vi.fn(), + })), + }, +})); + +vi.mock("core/nextEdit/NextEditLoggingService", () => ({ + NextEditLoggingService: { + getInstance: vi.fn(() => ({ + cancelRejectionTimeout: vi.fn(), + cancelRejectionTimeoutButKeepCompletionId: vi.fn(), + })), + }, +})); + +vi.mock("core/diff/myers", () => ({ + myersCharDiff: vi.fn(() => []), +})); + +vi.mock("core/nextEdit/diff/diff", () => ({ + getOffsetPositionAtLastNewLine: vi.fn(() => ({ line: 0, character: 0 })), +})); + +// Import after mocks are set up +import * as vscode from "vscode"; + +import { + ACCEPT_NEXT_EDIT_SUGGESTION_COMMAND, + HIDE_NEXT_EDIT_SUGGESTION_COMMAND, + NextEditWindowManager, +} from "./NextEditWindowManager"; + +const mockVscode = vi.mocked(vscode); + +describe("NextEditWindowManager", () => { + let manager: NextEditWindowManager; + let mockEditor: any; + let mockDocument: any; + let mockContext: any; + + beforeEach(() => { + vi.clearAllMocks(); + + // Clear singleton instance + NextEditWindowManager.clearInstance(); + + // Create mock document + mockDocument = { + uri: { toString: () => "file:///test.ts", scheme: "file" }, + version: 1, + lineCount: 10, + lineAt: vi.fn((line: number) => ({ + text: `line ${line} content`, + range: new mockVscode.Range( + new mockVscode.Position(line, 0), + new mockVscode.Position(line, 20), + ), + })), + }; + + // Create mock editor + mockEditor = { + document: mockDocument, + selection: { + active: new mockVscode.Position(0, 0), + }, + setDecorations: vi.fn(), + edit: vi.fn((callback: any) => { + callback({ + replace: vi.fn(), + delete: vi.fn(), + }); + return Promise.resolve(true); + }), + }; + + // Create mock context + mockContext = { + subscriptions: [], + }; + + // Setup default mock implementations + ( + mockVscode.commands.executeCommand as MockedFunction + ).mockResolvedValue(undefined); + (mockVscode.commands.registerCommand as MockedFunction) + //@ts-ignore + .mockImplementation((command: string, callback: any) => ({ + dispose: vi.fn(), + })); + ( + mockVscode.window.createTextEditorDecorationType as MockedFunction + ).mockReturnValue({ + dispose: vi.fn(), + }); + + // Get manager instance + manager = NextEditWindowManager.getInstance(); + }); + + afterEach(() => { + NextEditWindowManager.clearInstance(); + }); + + describe("Singleton Pattern", () => { + it("should return the same instance", () => { + const instance1 = NextEditWindowManager.getInstance(); + const instance2 = NextEditWindowManager.getInstance(); + expect(instance1).toBe(instance2); + }); + + it("should properly clear instance", () => { + const instance1 = NextEditWindowManager.getInstance(); + NextEditWindowManager.clearInstance(); + const instance2 = NextEditWindowManager.getInstance(); + expect(instance1).not.toBe(instance2); + }); + }); + + describe("Key Reservation State Management", () => { + beforeEach(async () => { + await manager.setupNextEditWindowManager(mockContext); + }); + + it("should start with keys in free state", () => { + expect(manager["keyReservationState"]).toBe("free"); + }); + + it("should reserve keys when showing window", async () => { + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(0, 0), + 0, + 0, + "old", + "new", + [], + ); + + expect(mockVscode.commands.executeCommand).toHaveBeenCalledWith( + "setContext", + "nextEditWindowActive", + true, + ); + expect(manager["keyReservationState"]).toBe("reserved"); + }); + + it("should free keys when hiding windows", async () => { + // First show a window + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(0, 0), + 0, + 0, + "old", + "new", + [], + ); + + // Then hide it + await manager.hideAllNextEditWindows(); + + expect(mockVscode.commands.executeCommand).toHaveBeenCalledWith( + "setContext", + "nextEditWindowActive", + false, + ); + expect(manager["keyReservationState"]).toBe("free"); + }); + + it("should handle sequential reserve/free operations", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await NextEditWindowManager.reserveTabAndEsc(); + expect(manager["keyReservationState"]).toBe("reserved"); + + await NextEditWindowManager.freeTabAndEsc(); + expect(manager["keyReservationState"]).toBe("free"); + + await NextEditWindowManager.reserveTabAndEsc(); + expect(manager["keyReservationState"]).toBe("reserved"); + + // Should have been called 3 times + 1 from beforeEach + expect(executeCommand).toHaveBeenCalledTimes(4); + }); + + it("should skip redundant reserve operations", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await NextEditWindowManager.reserveTabAndEsc(); + executeCommand.mockClear(); + + // Try to reserve again + await NextEditWindowManager.reserveTabAndEsc(); + + // Should not have called executeCommand again + expect(executeCommand).not.toHaveBeenCalled(); + expect(manager["keyReservationState"]).toBe("reserved"); + }); + + it("should skip redundant free operations", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + executeCommand.mockClear(); + + // Already free, try to free again + await NextEditWindowManager.freeTabAndEsc(); + + // Should not have called executeCommand + expect(executeCommand).not.toHaveBeenCalled(); + expect(manager["keyReservationState"]).toBe("free"); + }); + }); + + describe("Race Condition Prevention", () => { + beforeEach(async () => { + await manager.setupNextEditWindowManager(mockContext); + }); + + it("should handle concurrent operations with random delays and last-write-wins", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + let completedOperations: string[] = []; + + // Reset key reservation to ensure clean state + await manager.resetKeyReservation(); + + // Start from reserved state so first free() will proceed + manager["keyReservationState"] = "reserved"; + executeCommand.mockClear(); + + // Make executeCommand take random time and track completions + executeCommand.mockImplementation((cmd, key, value) => { + const operationId = `${value ? "reserve" : "free"}-${Date.now()}-${Math.random()}`; + return new Promise((resolve) => { + setTimeout(() => { + completedOperations.push(operationId); + // Immediately update state to ensure next operation proceeds + // This simulates fast state changes + manager["keyReservationState"] = value ? "reserved" : "free"; + resolve(undefined); + }, Math.random() * 50); + }); + }); + + // Fire multiple operations concurrently + const operations = [ + NextEditWindowManager.reserveTabAndEsc(), // operation 1: reserve (skipped - already reserved) + NextEditWindowManager.freeTabAndEsc(), // operation 2: free (proceeds) + NextEditWindowManager.reserveTabAndEsc(), // operation 3: reserve (proceeds after 2 completes) + NextEditWindowManager.freeTabAndEsc(), // operation 4: free (proceeds after 3 completes) + ]; + + await Promise.all(operations); + + // Count how many actually proceeded (those that didn't early return) + const actualCalls = executeCommand.mock.calls.length; + + // The state should match the last operation's intent + // But the actual number of calls depends on timing and early returns + expect(manager["latestOperationId"]).toBeGreaterThanOrEqual(actualCalls); + }); + + it("should ignore stale operations", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await manager.resetKeyReservation(); + executeCommand.mockClear(); + + // Create deferred promises with guaranteed resolvers + const createDeferred = () => { + let resolve: Function; + const promise = new Promise((res) => { + resolve = res; + }); + return { promise, resolve: resolve! }; + }; + + const deferred1 = createDeferred(); + const deferred2 = createDeferred(); + + // Control when each operation completes + executeCommand + .mockImplementationOnce(() => deferred1.promise) + .mockImplementationOnce(() => deferred2.promise); + + // Start operations + const op1 = NextEditWindowManager.reserveTabAndEsc(); + const op2 = NextEditWindowManager.freeTabAndEsc(); + + // Complete op2 first (even though op1 started first) + deferred2.resolve(undefined); + await op2; + + // State should be free (from op2) + expect(manager["keyReservationState"]).toBe("free"); + expect(manager["latestOperationId"]).toBe(2); + + // Now complete op1 (should be ignored as stale) + deferred1.resolve(undefined); + await op1; + + // State should still be free (op1 was ignored) + expect(manager["keyReservationState"]).toBe("free"); + expect(manager["latestOperationId"]).toBe(2); + }); + + it("should handle rapid fire operations correctly (loop)", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await manager.resetKeyReservation(); + executeCommand.mockClear(); + + // Make operations instant + executeCommand.mockResolvedValue(undefined); + + // Fire many operations rapidly + const operations = []; + for (let i = 0; i < 20; i++) { + operations.push( + i % 2 === 0 + ? NextEditWindowManager.reserveTabAndEsc() + : NextEditWindowManager.freeTabAndEsc(), + ); + } + + await Promise.all(operations); + + // Last operation (i=19) was free (odd number) + expect(manager["keyReservationState"]).toBe("free"); + expect(manager["latestOperationId"]).toBe(20); + }); + + it("should handle alternating reserve/free with delays", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await manager.resetKeyReservation(); + executeCommand.mockClear(); + + // Track actual VS Code context values set + const contextValues: boolean[] = []; + executeCommand.mockImplementation((cmd, key, value) => { + if (cmd === "setContext") { + //@ts-ignore + contextValues.push(value); + } + return Promise.resolve(undefined); + }); + + // Alternating operations + await NextEditWindowManager.reserveTabAndEsc(); + expect(manager["keyReservationState"]).toBe("reserved"); + + await NextEditWindowManager.freeTabAndEsc(); + expect(manager["keyReservationState"]).toBe("free"); + + await NextEditWindowManager.reserveTabAndEsc(); + expect(manager["keyReservationState"]).toBe("reserved"); + + // Check that context was set correctly each time + expect(contextValues).toEqual([true, false, true]); + }); + + it("should handle rapid alternations correctly", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await manager.resetKeyReservation(); + executeCommand.mockClear(); + + // Track all setContext calls + const contextCalls: boolean[] = []; + executeCommand.mockImplementation((cmd, key, value) => { + if (cmd === "setContext" && key === "nextEditWindowActive") { + //@ts-ignore + contextCalls.push(value); + } + return Promise.resolve(); + }); + + // Simulate rapid SEQUENTIAL user interactions: + // These need to be sequential to ensure state changes between calls + await NextEditWindowManager.reserveTabAndEsc(); // free -> reserved + await NextEditWindowManager.freeTabAndEsc(); // reserved -> free + await NextEditWindowManager.reserveTabAndEsc(); // free -> reserved + await NextEditWindowManager.freeTabAndEsc(); // reserved -> free + + // Should end in free state (last operation) + expect(manager["keyReservationState"]).toBe("free"); + + // Should have made all 4 calls since state alternates + expect(contextCalls).toEqual([true, false, true, false]); + }); + + it("should handle concurrent duplicate operations efficiently", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await manager.resetKeyReservation(); + executeCommand.mockClear(); + + // Track all setContext calls + const contextCalls: boolean[] = []; + executeCommand.mockImplementation((cmd, key, value) => { + if (cmd === "setContext" && key === "nextEditWindowActive") { + //@ts-ignore + contextCalls.push(value); + } + return Promise.resolve(); + }); + + // When multiple reserve operations happen concurrently (e.g., multiple completions) + // Only the first should actually make the call + const operations = [ + NextEditWindowManager.reserveTabAndEsc(), + NextEditWindowManager.reserveTabAndEsc(), + NextEditWindowManager.reserveTabAndEsc(), + ]; + + await Promise.all(operations); + + // Should have made only the necessary calls + // Since all start with state "free", all will proceed to call setContext + // This is because they all check state before any completes + expect(contextCalls.length).toBeGreaterThan(0); + expect(manager["keyReservationState"]).toBe("reserved"); + + // All calls should be trying to reserve (true) + expect(contextCalls.every((call) => call === true)).toBe(true); + }); + + it("should handle truly concurrent mixed operations", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await manager.resetKeyReservation(); + // Start in reserved state + await NextEditWindowManager.reserveTabAndEsc(); + executeCommand.mockClear(); + + // Track all setContext calls + const contextCalls: boolean[] = []; + executeCommand.mockImplementation((cmd, key, value) => { + if (cmd === "setContext" && key === "nextEditWindowActive") { + //@ts-ignore + contextCalls.push(value); + // Add small delay to simulate real async behavior + return new Promise((resolve) => setTimeout(resolve, 5)); + } + return Promise.resolve(); + }); + + // Mix of operations starting from "reserved" state + const operations = [ + NextEditWindowManager.freeTabAndEsc(), // Will proceed (reserved -> free) + NextEditWindowManager.freeTabAndEsc(), // Will proceed (checks while first is in flight) + NextEditWindowManager.reserveTabAndEsc(), // Will proceed (different operation) + ]; + + await Promise.all(operations); + + // The last operation to complete wins (but order is non-deterministic) + // State should be either "free" or "reserved" depending on completion order + expect(["free", "reserved"]).toContain(manager["keyReservationState"]); + + // Should have made at least some calls + expect(contextCalls.length).toBeGreaterThan(0); + }); + + it("should maintain correct state with stale operations", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + await manager.resetKeyReservation(); + executeCommand.mockClear(); + + // Create a controlled execution order + let resolveFirst: () => void; + let resolveSecond: () => void; + + const firstPromise = new Promise((resolve) => { + resolveFirst = resolve; + }); + + const secondPromise = new Promise((resolve) => { + resolveSecond = resolve; + }); + + executeCommand + .mockImplementationOnce(() => firstPromise) + .mockImplementationOnce(() => secondPromise); + + // Start operations + const op1 = NextEditWindowManager.reserveTabAndEsc(); + const op2 = NextEditWindowManager.freeTabAndEsc(); + + // Complete second operation first (out of order) + resolveSecond!(); + await op2; + + // State should be free (last operation to start, even though it completed first) + expect(manager["keyReservationState"]).toBe("free"); + + // Complete first operation + resolveFirst!(); + await op1; + + // State should still be free (op1 was stale) + expect(manager["keyReservationState"]).toBe("free"); + }); + }); + + describe("Error Recovery", () => { + beforeEach(async () => { + await manager.setupNextEditWindowManager(mockContext); + }); + + it("should recover from failed key reservation", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + // Make reservation fail + executeCommand.mockRejectedValueOnce(new Error("VS Code busy")); + + await expect(NextEditWindowManager.reserveTabAndEsc()).rejects.toThrow( + "VS Code busy", + ); + + // State should reset to free + expect(manager["keyReservationState"]).toBe("free"); + + // Should be able to try again + executeCommand.mockResolvedValueOnce(undefined); + await NextEditWindowManager.reserveTabAndEsc(); + expect(manager["keyReservationState"]).toBe("reserved"); + }); + + it("should recover from failed key freeing", async () => { + const executeCommand = mockVscode.commands + .executeCommand as MockedFunction; + + // First reserve successfully + await NextEditWindowManager.reserveTabAndEsc(); + expect(manager["keyReservationState"]).toBe("reserved"); + + // Make freeing fail + executeCommand.mockRejectedValueOnce(new Error("VS Code busy")); + + await expect(NextEditWindowManager.freeTabAndEsc()).rejects.toThrow( + "VS Code busy", + ); + + // State should still reset to free (safety mechanism) + expect(manager["keyReservationState"]).toBe("free"); + }); + + it("should handle decoration creation failure", async () => { + const createDecoration = mockVscode.window + .createTextEditorDecorationType as MockedFunction; + createDecoration.mockImplementationOnce(() => { + throw new Error("Failed to create decoration"); + }); + + // Should not throw, but should clean up + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(0, 0), + 0, + 0, + "old", + "new", + [], + ); + + // Keys should be freed due to error + expect(manager["keyReservationState"]).toBe("free"); + expect(manager["currentDecoration"]).toBeNull(); + }); + }); + + describe("Command Registration", () => { + it("should register hide command", async () => { + await manager.setupNextEditWindowManager(mockContext); + + expect(mockVscode.commands.registerCommand).toHaveBeenCalledWith( + HIDE_NEXT_EDIT_SUGGESTION_COMMAND, + expect.any(Function), + ); + }); + + it("should register accept command", async () => { + await manager.setupNextEditWindowManager(mockContext); + + expect(mockVscode.commands.registerCommand).toHaveBeenCalledWith( + ACCEPT_NEXT_EDIT_SUGGESTION_COMMAND, + expect.any(Function), + ); + }); + + it("should handle command registration failure gracefully", async () => { + const registerCommand = mockVscode.commands + .registerCommand as MockedFunction; + registerCommand.mockImplementationOnce(() => { + throw new Error("Command already registered"); + }); + + // Should not throw + await expect( + manager.setupNextEditWindowManager(mockContext), + ).resolves.not.toThrow(); + }); + }); + + describe("Window Management", () => { + beforeEach(async () => { + await manager.setupNextEditWindowManager(mockContext); + }); + + it("should store tooltip text when showing window", async () => { + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(0, 0), + 0, + 2, + "old code", + "new code", + [], + ); + + expect(manager["currentTooltipText"]).toBe("new code"); + expect(manager["activeEditor"]).toBe(mockEditor); + }); + + it("should clear tooltip text when hiding windows", async () => { + // Show first + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(0, 0), + 0, + 2, + "old", + "new", + [], + ); + + // Then hide + await manager.hideAllNextEditWindows(); + + expect(manager["currentTooltipText"]).toBeNull(); + expect(manager["activeEditor"]).toBeNull(); + }); + + it("should handle line deletion case", async () => { + mockEditor.document.lineAt = vi.fn((lineNumber: number) => ({ + text: "line to delete", + })); + + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(1, 0), + 1, + 1, + "line to delete", + "", // Empty means deletion + [{ type: "old", line: "line to delete" }], + ); + + expect(manager["isLineDelete"]).toBe(true); + // Final cursor should be at end of previous line + expect(manager["finalCursorPos"]?.line).toBe(0); + }); + + it("should skip rendering for excluded URIs", async () => { + mockEditor.document.uri = { + toString: () => "output://test", + scheme: "output", + }; + + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(0, 0), + 0, + 0, + "old", + "new", + [], + ); + + // Should not create decoration for excluded URI + expect( + mockVscode.window.createTextEditorDecorationType, + ).not.toHaveBeenCalled(); + expect(manager["currentDecoration"]).toBeNull(); + }); + }); + + describe("Accept/Reject Flow", () => { + beforeEach(async () => { + await manager.setupNextEditWindowManager(mockContext); + }); + + it("should apply text when accepting", async () => { + // Show window first + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(0, 0), + 0, + 0, + "old", + "new text", + [], + ); + + // Get the accept command callback + const registerCalls = ( + mockVscode.commands.registerCommand as MockedFunction + ).mock.calls; + const acceptCall = registerCalls.find( + (call) => call[0] === ACCEPT_NEXT_EDIT_SUGGESTION_COMMAND, + ); + //@ts-ignore + const acceptCallback = acceptCall[1]; + + // Call accept + //@ts-ignore + await acceptCallback(); + + // Should have called edit + expect(mockEditor.edit).toHaveBeenCalled(); + + // Should have cleared the decoration + expect(manager["currentTooltipText"]).toBeNull(); + expect(manager["keyReservationState"]).toBe("free"); + }); + + it("should not accept when no active window", async () => { + // Get the accept command callback + const registerCalls = ( + mockVscode.commands.registerCommand as MockedFunction + ).mock.calls; + const acceptCall = registerCalls.find( + (call) => call[0] === ACCEPT_NEXT_EDIT_SUGGESTION_COMMAND, + ); + //@ts-ignore + const acceptCallback = acceptCall[1]; + + // Call accept without showing window + //@ts-ignore + await acceptCallback(); + + // Should not have called edit + expect(mockEditor.edit).not.toHaveBeenCalled(); + }); + + it("should hide window when rejecting", async () => { + // Show window first + await manager.showNextEditWindow( + mockEditor, + new mockVscode.Position(0, 0), + 0, + 0, + "old", + "new", + [], + ); + + // Get the hide command callback + const registerCalls = ( + mockVscode.commands.registerCommand as MockedFunction + ).mock.calls; + const hideCall = registerCalls.find( + (call) => call[0] === HIDE_NEXT_EDIT_SUGGESTION_COMMAND, + ); + //@ts-ignore + const hideCallback = hideCall[1]; + + // Call hide + //@ts-ignore + await hideCallback(); + + // Should have cleared everything + expect(manager["currentTooltipText"]).toBeNull(); + expect(manager["activeEditor"]).toBeNull(); + expect(manager["keyReservationState"]).toBe("free"); + }); + }); + + describe("Disposal", () => { + it("should free keys on disposal", async () => { + await manager.setupNextEditWindowManager(mockContext); + + // Reserve keys first + await NextEditWindowManager.reserveTabAndEsc(); + expect(manager["keyReservationState"]).toBe("reserved"); + + // Dispose + manager.dispose(); + + // Should attempt to free keys + expect(mockVscode.commands.executeCommand).toHaveBeenCalledWith( + "setContext", + "nextEditWindowActive", + false, + ); + }); + + it("should dispose decorations on disposal", async () => { + await manager.setupNextEditWindowManager(mockContext); + + const mockDecoration = { dispose: vi.fn() }; + const mockDisposable1 = { dispose: vi.fn() }; + const mockDisposable2 = { dispose: vi.fn() }; + + manager["currentDecoration"] = mockDecoration as any; + manager["disposables"] = [mockDisposable1, mockDisposable2]; + + manager.dispose(); + + expect(mockDecoration.dispose).toHaveBeenCalled(); + expect(mockDisposable1.dispose).toHaveBeenCalled(); + expect(mockDisposable2.dispose).toHaveBeenCalled(); + }); + }); + + describe("Configuration Changes", () => { + it("should update on theme change", async () => { + await manager.setupNextEditWindowManager(mockContext); + + // Get the configuration change listener + const onDidChange = mockVscode.workspace + .onDidChangeConfiguration as MockedFunction; + const changeCallback = onDidChange.mock.calls[0][0]; + + // Simulate theme change + //@ts-ignore + await changeCallback({ + affectsConfiguration: (key: string) => key === "workbench.colorTheme", + }); + + // Should have updated theme + const { getThemeString } = await import("../util/getTheme"); + expect(getThemeString).toHaveBeenCalled(); + }); + + it("should update on font size change", async () => { + await manager.setupNextEditWindowManager(mockContext); + + const onDidChange = mockVscode.workspace + .onDidChangeConfiguration as MockedFunction; + const changeCallback = onDidChange.mock.calls[0][0]; + + // Change font size + ( + mockVscode.workspace.getConfiguration as MockedFunction + ).mockReturnValueOnce({ + get: (key: string) => (key === "fontSize" ? 16 : "monospace"), + }); + + //@ts-ignore + await changeCallback({ + affectsConfiguration: (key: string) => key === "editor.fontSize", + }); + + expect(manager["fontSize"]).toBe(16); + }); + }); +}); diff --git a/extensions/vscode/src/apply/ApplyManager.ts b/extensions/vscode/src/apply/ApplyManager.ts index 1ca79a25f..c880fbf3f 100644 --- a/extensions/vscode/src/apply/ApplyManager.ts +++ b/extensions/vscode/src/apply/ApplyManager.ts @@ -50,45 +50,36 @@ export class ApplyManager { toolCallId, }); - try { - const hasExistingDocument = !!activeTextEditor.document.getText().trim(); + const hasExistingDocument = !!activeTextEditor.document.getText().trim(); + if (hasExistingDocument) { + // Currently `isSearchAndReplace` will always provide a full file rewrite + // as the contents of `text`, so we can just instantly apply + if (isSearchAndReplace) { + const diffLinesGenerator = generateLines( + myersDiff(activeTextEditor.document.getText(), text), + ); - if (hasExistingDocument) { - // Currently `isSearchAndReplace` will always provide a full file rewrite - // as the contents of `text`, so we can just instantly apply - if (isSearchAndReplace) { - const diffLinesGenerator = generateLines( - myersDiff(activeTextEditor.document.getText(), text), - ); - - await this.verticalDiffManager.streamDiffLines( - diffLinesGenerator, - true, - streamId, - toolCallId, - ); - } else { - await this.handleExistingDocument( - activeTextEditor, - text, - streamId, - toolCallId, - ); - } + await this.verticalDiffManager.streamDiffLines( + diffLinesGenerator, + true, + streamId, + toolCallId, + ); } else { - await this.handleEmptyDocument( + await this.handleExistingDocument( activeTextEditor, text, streamId, toolCallId, ); } - } finally { - await this.webviewProtocol.request("updateApplyState", { + } else { + await this.handleEmptyDocument( + activeTextEditor, + text, streamId, - status: "done", toolCallId, - }); + ); } } diff --git a/extensions/vscode/src/autocomplete/RecentlyVisitedRangesService.ts b/extensions/vscode/src/autocomplete/RecentlyVisitedRangesService.ts index bd55278d6..d1f5b8ef2 100644 --- a/extensions/vscode/src/autocomplete/RecentlyVisitedRangesService.ts +++ b/extensions/vscode/src/autocomplete/RecentlyVisitedRangesService.ts @@ -3,6 +3,7 @@ import { AutocompleteCodeSnippet, AutocompleteSnippetType, } from "core/autocomplete/snippets/types"; +import { isSecurityConcern } from "core/indexing/ignore"; import { PosthogFeatureFlag, Telemetry } from "core/util/posthog"; import { LRUCache } from "lru-cache"; import * as vscode from "vscode"; @@ -51,6 +52,10 @@ export class RecentlyVisitedRangesService { private cacheCurrentSelectionContext = async ( event: vscode.TextEditorSelectionChangeEvent, ) => { + const fsPath = event.textEditor.document.fileName; + if (isSecurityConcern(fsPath)) { + return; + } const filepath = event.textEditor.document.uri.toString(); const line = event.selections[0].active.line; const startLine = Math.max(0, line - this.numSurroundingLines); diff --git a/extensions/vscode/src/diff/vertical/manager.ts b/extensions/vscode/src/diff/vertical/manager.ts index e30f898c0..1731b176d 100644 --- a/extensions/vscode/src/diff/vertical/manager.ts +++ b/extensions/vscode/src/diff/vertical/manager.ts @@ -141,7 +141,16 @@ export class VerticalDiffManager { this.disableDocumentChangeListener(); - vscode.commands.executeCommand("setContext", "continue.diffVisible", false); + void vscode.commands.executeCommand( + "setContext", + "continue.diffVisible", + false, + ); + + void this.webviewProtocol.request( + "focusContinueInputWithoutClear", + undefined, + ); } async acceptRejectVerticalDiffBlock( diff --git a/gui/package-lock.json b/gui/package-lock.json index 4528607ec..8e4bfb7d9 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -27,10 +27,12 @@ "@tiptap/react": "^2.1.13", "@tiptap/starter-kit": "^2.1.13", "@tiptap/suggestion": "^2.1.13", + "@types/diff": "^7.0.2", "@types/uuid": "^10.0.0", "anser": "^2.3.2", "clsx": "^2.1.1", "core": "file:../core", + "diff": "^8.0.2", "dompurify": "^3.0.6", "downshift": "^7.6.0", "escape-carriage": "^1.3.1", @@ -129,7 +131,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", @@ -148,7 +149,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", @@ -209,6 +210,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", @@ -3865,6 +3868,12 @@ "@types/ms": "*" } }, + "node_modules/@types/diff": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@types/diff/-/diff-7.0.2.tgz", + "integrity": "sha512-JSWRMozjFKsGlEjiiKajUjIJVKuKdE3oVy2DNtK+fUo8q82nhFZ2CPQwicAIkXrofahDXrWJ7mjelvZphMS98Q==", + "license": "MIT" + }, "node_modules/@types/dompurify": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.2.0.tgz", @@ -5094,6 +5103,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "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==", + "dev": true, + "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", @@ -6180,6 +6203,15 @@ "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", "dev": true }, + "node_modules/diff": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.2.tgz", + "integrity": "sha512-sSuxWU5j5SR9QQji/o2qMvqRNYRDOcBTgsJ/DeCf4iSN4gW+gNMXM7wFIP+fdXZxoNiAnHUTGjCr+TSWXdRDKg==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/direction": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/direction/-/direction-1.0.4.tgz", @@ -6257,6 +6289,21 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" }, + "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==", + "dev": true, + "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", @@ -6374,13 +6421,11 @@ } }, "node_modules/es-define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", "dev": true, - "dependencies": { - "get-intrinsic": "^1.2.4" - }, + "license": "MIT", "engines": { "node": ">= 0.4" } @@ -6421,10 +6466,11 @@ } }, "node_modules/es-object-atoms": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", - "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", + "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==", "dev": true, + "license": "MIT", "dependencies": { "es-errors": "^1.3.0" }, @@ -6433,14 +6479,16 @@ } }, "node_modules/es-set-tostringtag": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.3.tgz", - "integrity": "sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==", + "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==", "dev": true, + "license": "MIT", "dependencies": { - "get-intrinsic": "^1.2.4", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", - "hasown": "^2.0.1" + "hasown": "^2.0.2" }, "engines": { "node": ">= 0.4" @@ -7371,13 +7419,16 @@ } }, "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==", "dev": true, + "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": { @@ -7468,16 +7519,22 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", - "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", "dev": true, + "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", - "has-proto": "^1.0.1", - "has-symbols": "^1.0.3", - "hasown": "^2.0.0" + "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" @@ -7486,6 +7543,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "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==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/get-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", @@ -7568,12 +7639,13 @@ } }, "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", "dev": true, - "dependencies": { - "get-intrinsic": "^1.1.3" + "license": "MIT", + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -7688,10 +7760,11 @@ } }, "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -9430,6 +9503,16 @@ "node": ">= 20" } }, + "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==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/mdast-util-definitions": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-4.0.0.tgz", diff --git a/gui/package.json b/gui/package.json index ab83efb22..6cb45030c 100644 --- a/gui/package.json +++ b/gui/package.json @@ -36,10 +36,12 @@ "@tiptap/react": "^2.1.13", "@tiptap/starter-kit": "^2.1.13", "@tiptap/suggestion": "^2.1.13", + "@types/diff": "^7.0.2", "@types/uuid": "^10.0.0", "anser": "^2.3.2", "clsx": "^2.1.1", "core": "file:../core", + "diff": "^8.0.2", "dompurify": "^3.0.6", "downshift": "^7.6.0", "escape-carriage": "^1.3.1", diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions.tsx index 1214b9e24..9b7ba953d 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions.tsx @@ -11,7 +11,7 @@ interface ApplyActionsProps { applyState?: ApplyState; onClickAccept: () => void; onClickReject: () => void; - onClickApply: () => void; + onClickApply?: () => void; } export function ApplyActions(props: ApplyActionsProps) { diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo.tsx index 550d1fd28..c288c7cd0 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo.tsx @@ -1,10 +1,11 @@ import { getLastNPathParts } from "core/util/uri"; +import { MouseEventHandler } from "react"; import FileIcon from "../../FileIcon"; import { ToolTip } from "../../gui/Tooltip"; export interface FileInfoProps { filepath: string; - onClick?: () => void; + onClick?: MouseEventHandler; range?: string; } diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx index e97c13061..f9d268ccc 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx @@ -96,7 +96,7 @@ export function StepContainerPreToolbar({ toolCallState?.status === "errored" || toolCallState?.status === "done") ? (
{ if (toolCallState.output) { ideMessenger.post("showVirtualFile", { diff --git a/gui/src/components/UnifiedTerminal/UnifiedTerminal.tsx b/gui/src/components/UnifiedTerminal/UnifiedTerminal.tsx new file mode 100644 index 000000000..00e34114b --- /dev/null +++ b/gui/src/components/UnifiedTerminal/UnifiedTerminal.tsx @@ -0,0 +1,555 @@ +import { ChevronDownIcon } from "@heroicons/react/24/outline"; +import Anser, { AnserJsonEntry } from "anser"; +import { ToolCallState } from "core"; +import { escapeCarriageReturn } from "escape-carriage"; +import { useMemo, useState } from "react"; +import styled, { keyframes } from "styled-components"; +import { useAppDispatch } from "../../redux/hooks"; +import { moveTerminalProcessToBackground } from "../../redux/thunks/moveTerminalProcessToBackground"; +import { getFontSize } from "../../util"; +import { + defaultBorderRadius, + vscBackground, + vscEditorBackground, + vscForeground, +} from "../index"; +import { CopyButton } from "../StyledMarkdownPreview/StepContainerPreToolbar/CopyButton"; +import { RunInTerminalButton } from "../StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton"; +import { ButtonContent, SpoilerButton } from "../ui/SpoilerButton"; + +const blinkCursor = keyframes` + 0%, 50% { opacity: 1; } + 51%, 100% { opacity: 0; } +`; + +const BlinkingCursor = styled.span` + &::after { + content: "█"; + animation: ${blinkCursor} 1s infinite; + color: ${vscForeground}; + } +`; + +const AnsiSpan = styled.span<{ + bg?: string; + fg?: string; + decoration?: string; +}>` + ${({ bg }) => bg && `background-color: rgb(${bg});`} + ${({ fg }) => fg && `color: rgb(${fg});`} + ${({ decoration }) => { + switch (decoration) { + case "bold": + return "font-weight: bold;"; + case "dim": + return "opacity: 0.5;"; + case "italic": + return "font-style: italic;"; + case "hidden": + return "visibility: hidden;"; + case "strikethrough": + return "text-decoration: line-through;"; + case "underline": + return "text-decoration: underline;"; + case "blink": + return "text-decoration: blink;"; + default: + return ""; + } + }} +`; + +const AnsiLink = styled.a` + color: var(--vscode-textLink-foreground, #3794ff); + text-decoration: none; + &:hover { + text-decoration: underline; + } +`; + +const StyledTerminalContainer = styled.div<{ + fontSize?: number; + bgColor: string; +}>` + background-color: ${(props) => props.bgColor}; + font-family: + var(--vscode-font-family), + system-ui, + -apple-system, + BlinkMacSystemFont, + "Segoe UI", + Roboto, + Oxygen, + Ubuntu, + Cantarell, + "Open Sans", + "Helvetica Neue", + sans-serif; + font-size: ${(props) => props.fontSize || getFontSize()}px; + color: ${vscForeground}; + line-height: 1.5; + + > *:last-child { + margin-bottom: 0; + } +`; + +const TerminalContent = styled.div` + pre { + white-space: pre-wrap; + background-color: ${vscEditorBackground}; + border-radius: ${defaultBorderRadius}; + border: 1px solid + var(--vscode-editorWidget-border, rgba(127, 127, 127, 0.3)); + max-width: calc(100vw - 24px); + overflow-x: scroll; + overflow-y: hidden; + padding: 8px; + margin: 0; + } + + code { + span.line:empty { + display: none; + } + word-wrap: break-word; + border-radius: ${defaultBorderRadius}; + background-color: ${vscEditorBackground}; + font-size: ${getFontSize() - 2}px; + font-family: var(--vscode-editor-font-family); + } + + code:not(pre > code) { + font-family: var(--vscode-editor-font-family); + color: var(--vscode-input-placeholderForeground); + } +`; + +const ToolbarContainer = styled.div<{ isExpanded: boolean }>` + font-size: ${getFontSize() - 2}px; +`; + +const CommandLine = styled.div` + padding-bottom: 0.5rem; + color: var(--vscode-terminal-ansiGreen, #0dbc79); +`; + +function ansiToJSON( + input: string, + use_classes: boolean = false, +): AnserJsonEntry[] { + input = escapeCarriageReturn(fixBackspace(input)); + return Anser.ansiToJson(input, { + json: true, + remove_empty: true, + use_classes, + }); +} + +function createClass(bundle: AnserJsonEntry): string | null { + let classNames: string = ""; + + if (bundle.bg) { + classNames += `${bundle.bg}-bg `; + } + if (bundle.fg) { + classNames += `${bundle.fg}-fg `; + } + if (bundle.decoration) { + classNames += `ansi-${bundle.decoration} `; + } + + if (classNames === "") { + return null; + } + + classNames = classNames.substring(0, classNames.length - 1); + return classNames; +} + +function convertBundleIntoReact( + linkify: boolean, + useClasses: boolean, + bundle: AnserJsonEntry, + key: number, +): JSX.Element { + const className = useClasses ? createClass(bundle) : null; + const decorationProp = bundle.decoration + ? String(bundle.decoration) + : undefined; + + if (!linkify) { + return ( + + {bundle.content} + + ); + } + + const content: React.ReactNode[] = []; + const linkRegex = + /(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g; + + let index = 0; + let match: RegExpExecArray | null; + while ((match = linkRegex.exec(bundle.content)) !== null) { + const [, pre, url] = match; + + const startIndex = match.index + pre.length; + if (startIndex > index) { + content.push(bundle.content.substring(index, startIndex)); + } + + const href = url.startsWith("www.") ? `http://${url}` : url; + + content.push( + + {url} + , + ); + + index = linkRegex.lastIndex; + } + + if (index < bundle.content.length) { + content.push(bundle.content.substring(index)); + } + + return ( + + {content} + + ); +} + +function fixBackspace(txt: string) { + let tmp = txt; + do { + txt = tmp; + tmp = txt.replace(/[^\n]\x08/gm, ""); + } while (tmp.length < txt.length); + return txt; +} + +function AnsiRenderer({ + children, + linkify = false, +}: { + children?: string; + linkify?: boolean; +}) { + const ansiContent = ansiToJSON(children ?? "", false).map((bundle, i) => + convertBundleIntoReact(linkify, false, bundle, i), + ); + + return <>{ansiContent}; +} + +interface StatusIconProps { + status: "running" | "completed" | "failed" | "background"; +} + +function StatusIcon({ status }: StatusIconProps) { + const getStatusColor = () => { + switch (status) { + case "running": + return "bg-success"; + case "completed": + return "bg-success"; + case "background": + return "bg-accent"; + case "failed": + return "bg-error"; + default: + return "bg-success"; + } + }; + + return ( + + ); +} + +interface IndicatorOnlyProps { + hiddenLinesCount: number; + isExpanded: boolean; + onToggle: () => void; +} + +function IndicatorOnly({ + hiddenLinesCount, + isExpanded, + onToggle, +}: IndicatorOnlyProps) { + return ( +
+ + + + {isExpanded ? "Collapse" : `+${hiddenLinesCount} more lines`} + + + + +
+ ); +} + +interface CollapsibleOutputContainerProps { + limitedContent: string; + fullContent: string; + isExpanded: boolean; + onToggle: () => void; +} + +function CollapsibleOutputContainer({ + limitedContent, + fullContent, + isExpanded, + onToggle, +}: CollapsibleOutputContainerProps) { + return ( +
+ {/* Gradient overlay when collapsed */} + {!isExpanded && ( +
+ )} + +
+
+ + {isExpanded ? fullContent : limitedContent} + +
+
+
+ ); +} + +interface UnifiedTerminalCommandProps { + command: string; + output?: string; + status?: "running" | "completed" | "failed" | "background"; + statusMessage?: string; + toolCallState?: ToolCallState; + toolCallId?: string; + displayLines?: number; +} + +export function UnifiedTerminalCommand({ + command, + output = "", + status = "completed", + statusMessage = "", + toolCallState, + toolCallId, + displayLines = 15, +}: UnifiedTerminalCommandProps) { + const dispatch = useAppDispatch(); + const [isExpanded, setIsExpanded] = useState(true); + const [outputExpanded, setOutputExpanded] = useState(false); + + // Determine running state + const isRunning = toolCallState?.status === "calling" || status === "running"; + const hasOutput = output.length > 0; + + // Process terminal content for line limiting + const processedTerminalContent = useMemo(() => { + if (!output) { + return { + fullContent: "", + limitedContent: "", + totalLines: 0, + isLimited: false, + hiddenLinesCount: 0, + }; + } + + const lines = output.split("\n"); + const totalLines = lines.length; + + if (totalLines > displayLines) { + const lastLines = lines.slice(-displayLines); + return { + fullContent: output, + limitedContent: lastLines.join("\n"), + totalLines, + isLimited: true, + hiddenLinesCount: totalLines - displayLines, + }; + } + + return { + fullContent: output, + limitedContent: output, + totalLines, + isLimited: false, + hiddenLinesCount: 0, + }; + }, [output, displayLines]); + + // Determine status type + let statusType: "running" | "completed" | "failed" | "background" = status; + if (isRunning) { + statusType = "running"; + } else if (statusMessage?.includes("failed")) { + statusType = "failed"; + } else if (statusMessage?.includes("background")) { + statusType = "background"; + } + + const handleMoveToBackground = () => { + if (toolCallId) { + void dispatch( + moveTerminalProcessToBackground({ + toolCallId, + }), + ); + } + }; + + // Create combined content for copying (command + output) + const copyContent = useMemo(() => { + let content = `$ ${command}`; + if (hasOutput) { + content += `\n\n${output}`; + } + return content; + }, [command, output, hasOutput]); + + return ( + +
+ {/* Toolbar */} +
+
+ setIsExpanded(!isExpanded)} + className={`text-lightgray h-3.5 w-3.5 flex-shrink-0 cursor-pointer hover:brightness-125 ${ + isExpanded ? "rotate-0" : "-rotate-90" + }`} + /> + Terminal +
+ +
+ {!isRunning && ( +
+ + +
+ )} +
+
+ + {/* Content */} + {isExpanded && ( + +
+              
+                {/* Command is always visible */}
+                
+ $ {command} +
+ + {/* Running state with cursor */} + {isRunning && !hasOutput && ( +
+ +
+ )} + + {/* Output with optional collapsible functionality */} + {hasOutput && ( +
+ {/* Expand/Collapse indicator positioned between command and output */} + {processedTerminalContent.isLimited && ( + setOutputExpanded(!outputExpanded)} + /> + )} + +
+ {processedTerminalContent.isLimited ? ( + setOutputExpanded(!outputExpanded)} + /> + ) : ( +
+ + {processedTerminalContent.fullContent} + +
+ )} +
+
+ )} +
+
+
+ )} + + {/* Status information */} + {(statusMessage || isRunning) && ( + + )} +
+
+ ); +} diff --git a/gui/src/components/ansiTerminal/Ansi.tsx b/gui/src/components/ansiTerminal/Ansi.tsx deleted file mode 100644 index 35d4b0a43..000000000 --- a/gui/src/components/ansiTerminal/Ansi.tsx +++ /dev/null @@ -1,279 +0,0 @@ -import Anser, { AnserJsonEntry } from "anser"; -import { escapeCarriageReturn } from "escape-carriage"; -import * as React from "react"; -import styled from "styled-components"; -import { - defaultBorderRadius, - vscBackground, - vscEditorBackground, - vscForeground, -} from "../../components"; -import { getFontSize } from "../../util"; - -const AnsiSpan = styled.span<{ - bg?: string; - fg?: string; - decoration?: string; -}>` - ${({ bg }) => bg && `background-color: rgb(${bg});`} - ${({ fg }) => fg && `color: rgb(${fg});`} - ${({ decoration }) => { - switch (decoration) { - case "bold": - return "font-weight: bold;"; - case "dim": - return "opacity: 0.5;"; - case "italic": - return "font-style: italic;"; - case "hidden": - return "visibility: hidden;"; - case "strikethrough": - return "text-decoration: line-through;"; - case "underline": - return "text-decoration: underline;"; - case "blink": - return "text-decoration: blink;"; - default: - return ""; - } - }} -`; - -const AnsiLink = styled.a` - color: var(--vscode-textLink-foreground, #3794ff); - text-decoration: none; - &:hover { - text-decoration: underline; - } -`; - -// Using the same styled component structure as StyledMarkdown -const StyledAnsi = styled.div<{ - fontSize?: number; - whiteSpace: string; - bgColor: string; -}>` - pre { - white-space: ${(props) => props.whiteSpace}; - background-color: ${vscEditorBackground}; - border-radius: ${defaultBorderRadius}; - border: 1px solid - var(--vscode-editorWidget-border, rgba(127, 127, 127, 0.3)); - max-width: calc(100vw - 24px); - overflow-x: scroll; - overflow-y: hidden; - padding: 8px; - } - - code { - span.line:empty { - display: none; - } - word-wrap: break-word; - border-radius: ${defaultBorderRadius}; - background-color: ${vscEditorBackground}; - font-size: ${getFontSize() - 2}px; - font-family: var(--vscode-editor-font-family); - } - - code:not(pre > code) { - font-family: var(--vscode-editor-font-family); - color: var(--vscode-input-placeholderForeground); - } - - background-color: ${(props) => props.bgColor}; - font-family: - var(--vscode-font-family), - system-ui, - -apple-system, - BlinkMacSystemFont, - "Segoe UI", - Roboto, - Oxygen, - Ubuntu, - Cantarell, - "Open Sans", - "Helvetica Neue", - sans-serif; - font-size: ${(props) => props.fontSize || getFontSize()}px; - padding-left: 8px; - padding-right: 8px; - color: ${vscForeground}; - line-height: 1.5; - - > *:last-child { - margin-bottom: 0; - } -`; - -/** - * Converts ANSI strings into JSON output. - * @name ansiToJSON - * @function - * @param {String} input The input string. - * @param {boolean} use_classes If `true`, HTML classes will be appended - * to the HTML output. - * @return {Array} The parsed input. - */ -function ansiToJSON( - input: string, - use_classes: boolean = false, -): AnserJsonEntry[] { - input = escapeCarriageReturn(fixBackspace(input)); - return Anser.ansiToJson(input, { - json: true, - remove_empty: true, - use_classes, - }); -} - -/** - * Create a class string. - * @name createClass - * @function - * @param {AnserJsonEntry} bundle - * @return {String} class name(s) - */ -function createClass(bundle: AnserJsonEntry): string | null { - let classNames: string = ""; - - if (bundle.bg) { - classNames += `${bundle.bg}-bg `; - } - if (bundle.fg) { - classNames += `${bundle.fg}-fg `; - } - if (bundle.decoration) { - classNames += `ansi-${bundle.decoration} `; - } - - if (classNames === "") { - return null; - } - - classNames = classNames.substring(0, classNames.length - 1); - return classNames; -} - -/** - * Converts an Anser bundle into a React Node. - * @param linkify whether links should be converting into clickable anchor tags. - * @param useClasses should render the span with a class instead of style. - * @param bundle Anser output. - * @param key - */ - -function convertBundleIntoReact( - linkify: boolean, - useClasses: boolean, - bundle: AnserJsonEntry, - key: number, -): JSX.Element { - const className = useClasses ? createClass(bundle) : null; - // Convert bundle.decoration to string or undefined (not null) to match the prop type - const decorationProp = bundle.decoration - ? String(bundle.decoration) - : undefined; - - if (!linkify) { - return ( - - {bundle.content} - - ); - } - - const content: React.ReactNode[] = []; - const linkRegex = - /(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g; - - let index = 0; - let match: RegExpExecArray | null; - while ((match = linkRegex.exec(bundle.content)) !== null) { - const [, pre, url] = match; - - const startIndex = match.index + pre.length; - if (startIndex > index) { - content.push(bundle.content.substring(index, startIndex)); - } - - // Make sure the href we generate from the link is fully qualified. We assume http - // if it starts with a www because many sites don't support https - const href = url.startsWith("www.") ? `http://${url}` : url; - - content.push( - - {url} - , - ); - - index = linkRegex.lastIndex; - } - - if (index < bundle.content.length) { - content.push(bundle.content.substring(index)); - } - - return ( - - {content} - - ); -} - -declare interface Props { - children?: string; - linkify?: boolean; - className?: string; - useClasses?: boolean; -} - -export default function Ansi(props: Props): JSX.Element { - const { className, useClasses, children, linkify } = props; - - // Create the ANSI content - const ansiContent = ansiToJSON(children ?? "", useClasses ?? false).map( - (bundle, i) => - convertBundleIntoReact(linkify ?? false, useClasses ?? false, bundle, i), - ); - - return ( - -
-        {ansiContent}
-      
-
- ); -} - -// This is copied from the Jupyter Classic source code -// notebook/static/base/js/utils.js to handle \b in a way -// that is **compatible with Jupyter classic**. One can -// argue that this behavior is questionable: -// https://stackoverflow.com/questions/55440152/multiple-b-doesnt-work-as-expected-in-jupyter# -function fixBackspace(txt: string) { - let tmp = txt; - do { - txt = tmp; - // Cancel out anything-but-newline followed by backspace - tmp = txt.replace(/[^\n]\x08/gm, ""); - } while (tmp.length < txt.length); - return txt; -} diff --git a/gui/src/components/mainInput/Lump/EditBlockButton.tsx b/gui/src/components/mainInput/Lump/EditBlockButton.tsx index 19780e875..b73e2b372 100644 --- a/gui/src/components/mainInput/Lump/EditBlockButton.tsx +++ b/gui/src/components/mainInput/Lump/EditBlockButton.tsx @@ -6,7 +6,7 @@ import { IdeMessengerContext } from "../../../context/IdeMessenger"; type SectionKey = Exclude< keyof ConfigYaml, - "name" | "version" | "schema" | "metadata" + "name" | "version" | "schema" | "metadata" | "env" >; interface EditBlockButtonProps { @@ -42,10 +42,10 @@ export default function EditBlockButton({ element: { sourceFile }, }); } else if (block && isUsesBlock(block)) { - openUrl(`${block.uses}/new-version`); + void openUrl(`${block.uses}/new-version`); } else if (selectedProfile?.fullSlug) { const slug = `${selectedProfile.fullSlug.ownerSlug}/${selectedProfile.fullSlug.packageSlug}`; - openUrl(`${slug}/new-version`); + void openUrl(`${slug}/new-version`); } }; diff --git a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx b/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx index f20dbb53b..1505b25b4 100644 --- a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx @@ -253,7 +253,7 @@ function MCPSection() { })); }, [servers, selectedProfile]); - if (disableMcp) { + if (true) { return (
diff --git a/gui/src/components/mainInput/belowMainInput/ThinkingBlockPeek.tsx b/gui/src/components/mainInput/belowMainInput/ThinkingBlockPeek.tsx index ba423bbc4..3dea83d0e 100644 --- a/gui/src/components/mainInput/belowMainInput/ThinkingBlockPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/ThinkingBlockPeek.tsx @@ -5,38 +5,10 @@ import { ChatHistoryItem } from "core"; import { useEffect, useState } from "react"; import styled from "styled-components"; -import { defaultBorderRadius, lightGray, vscBackground } from "../.."; -import { getFontSize } from "../../../util"; +import { vscBackground } from "../.."; import { AnimatedEllipsis } from "../../AnimatedEllipsis"; import StyledMarkdownPreview from "../../StyledMarkdownPreview"; - -const SpoilerButton = styled.div` - background-color: ${vscBackground}; - width: fit-content; - margin: 8px 6px 0px 2px; - font-size: ${getFontSize() - 2}px; - border: 0.5px solid ${lightGray}; - border-radius: ${defaultBorderRadius}; - padding: 4px 8px; - color: ${lightGray}; - cursor: pointer; - box-shadow: - 0 4px 6px rgba(0, 0, 0, 0.1), - 0 1px 3px rgba(0, 0, 0, 0.08); - transition: box-shadow 0.3s ease; - - &:hover { - box-shadow: - 0 6px 8px rgba(0, 0, 0, 0.15), - 0 3px 6px rgba(0, 0, 0, 0.1); - } -`; - -const ButtonContent = styled.div` - display: flex; - align-items: center; - gap: 6px; -`; +import { ButtonContent, SpoilerButton } from "../../ui/SpoilerButton"; const ThinkingTextContainer = styled.span` display: inline-block; diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index 5aa221609..3108e7089 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -37,6 +37,7 @@ interface Option { title: string; apiKey?: string; sourceFile?: string; + isAutoDetected?: boolean; } function modelSelectTitle(model: any): string { @@ -75,8 +76,15 @@ function ModelOption({ {option.title} + {option.isAutoDetected && ( + + (autodetected) + + )} {showMissingApiKeyMsg && ( - (Missing API key) + + (Missing API key) + )}
@@ -132,6 +140,7 @@ function ModelSelect() { title: modelSelectTitle(model), apiKey: model.apiKey, sourceFile: model.sourceFile, + isAutoDetected: model.isFromAutoDetect, }; }), ); diff --git a/gui/src/components/ui/SpoilerButton.tsx b/gui/src/components/ui/SpoilerButton.tsx new file mode 100644 index 000000000..66b74bca9 --- /dev/null +++ b/gui/src/components/ui/SpoilerButton.tsx @@ -0,0 +1,31 @@ +import styled from "styled-components"; +import { defaultBorderRadius, lightGray, vscBackground } from "../index"; +import { getFontSize } from "../../util"; + +export const SpoilerButton = styled.div` + background-color: ${vscBackground}; + width: fit-content; + margin: 8px 6px 0px 2px; + font-size: ${getFontSize() - 2}px; + border: 0.5px solid ${lightGray}; + border-radius: ${defaultBorderRadius}; + padding: 4px 8px; + color: ${lightGray}; + cursor: pointer; + box-shadow: + 0 4px 6px rgba(0, 0, 0, 0.1), + 0 1px 3px rgba(0, 0, 0, 0.08); + transition: box-shadow 0.3s ease; + + &:hover { + box-shadow: + 0 6px 8px rgba(0, 0, 0, 0.15), + 0 3px 6px rgba(0, 0, 0, 0.1); + } +`; + +export const ButtonContent = styled.div` + display: flex; + align-items: center; + gap: 6px; +`; diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index 1c90477f4..9f5875202 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -1,14 +1,10 @@ import { useCallback, useContext, useEffect, useRef } from "react"; import { IdeMessengerContext } from "../context/IdeMessenger"; -import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; import { FromCoreProtocol } from "core/protocol"; import { useAppDispatch, useAppSelector } from "../redux/hooks"; import { setConfigLoading, setConfigResult } from "../redux/slices/configSlice"; -import { - setLastNonEditSessionEmpty, - updateEditStateApplyState, -} from "../redux/slices/editState"; +import { setLastNonEditSessionEmpty } from "../redux/slices/editState"; import { updateIndexingStatus } from "../redux/slices/indexingSlice"; import { initializeProfilePreferences, @@ -17,27 +13,21 @@ import { setSelectedProfile, } from "../redux/slices/profilesSlice"; import { - acceptToolCall, addContextItemsAtIndex, setHasReasoningEnabled, setIsSessionMetadataLoading, - updateApplyState, } from "../redux/slices/sessionSlice"; import { setTTSActive } from "../redux/slices/uiSlice"; -import { exitEdit } from "../redux/thunks/edit"; -import { streamResponseAfterToolCall } from "../redux/thunks/streamResponseAfterToolCall"; -import { store } from "../redux/store"; import { cancelStream } from "../redux/thunks/cancelStream"; +import { handleApplyStateUpdate } from "../redux/thunks/handleApplyStateUpdate"; import { refreshSessionMetadata } from "../redux/thunks/session"; import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols"; -import { findToolCallById, logToolUsage } from "../redux/util"; import { setDocumentStylesFromLocalStorage, setDocumentStylesFromTheme, } from "../styles/theme"; import { isJetBrains } from "../util"; -import { logAgentModeEditOutcome } from "../util/editOutcomeLogger"; import { setLocalStorage } from "../util/localStorage"; import { migrateLocalStorage } from "../util/migrateLocalStorage"; import { useWebviewListener } from "./useWebviewListener"; @@ -51,9 +41,7 @@ function ParallelListeners() { (store) => store.profiles.selectedProfileId, ); const hasDoneInitialConfigLoad = useRef(false); - const autoAcceptEditToolDiffs = useAppSelector( - (store) => store.config.config.ui?.autoAcceptEditToolDiffs, - ); + // Load symbols for chat on any session change const sessionId = useAppSelector((state) => state.session.id); @@ -235,83 +223,9 @@ function ParallelListeners() { useWebviewListener( "updateApplyState", async (state) => { - if (state.streamId === EDIT_MODE_STREAM_ID) { - dispatch(updateEditStateApplyState(state)); - - if (state.status === "closed") { - const toolCallState = findToolCallById( - store.getState().session.history, - state.toolCallId!, - ); - if (toolCallState) { - logToolUsage(toolCallState, true, true, ideMessenger); - } - void dispatch(exitEdit({})); - } - } else { - // chat or agent - dispatch(updateApplyState(state)); - - // Handle apply status updates - use toolCallId from event payload - if (state.toolCallId) { - if (state.status === "done" && autoAcceptEditToolDiffs) { - ideMessenger.post("acceptDiff", { - streamId: state.streamId, - filepath: state.filepath, - }); - } - if (state.status === "closed") { - // Find the tool call to check if it was canceled - const toolCallState = findToolCallById( - store.getState().session.history, - state.toolCallId, - ); - - if (toolCallState) { - const accepted = toolCallState.status !== "canceled"; - - logToolUsage(toolCallState, accepted, true, ideMessenger); - - // Log edit outcome for Agent Mode - const applyState = store - .getState() - .session.codeBlockApplyStates.states.find( - (s) => s.streamId === state.streamId, - ); - - if (applyState) { - void logAgentModeEditOutcome( - toolCallState, - applyState, - accepted, - ideMessenger, - ); - } - - if (accepted) { - dispatch( - acceptToolCall({ - toolCallId: state.toolCallId, - }), - ); - void dispatch( - streamResponseAfterToolCall({ - toolCallId: state.toolCallId, - }), - ); - } - } - // const output: ContextItem = { - // name: "Edit tool output", - // content: "Completed edit", - // description: "", - // }; - // dispatch(setToolCallOutput([])); - } - } - } + void dispatch(handleApplyStateUpdate(state)); }, - [autoAcceptEditToolDiffs, ideMessenger], + [], ); useEffect(() => { diff --git a/gui/src/hooks/TelemetryProviders.tsx b/gui/src/hooks/TelemetryProviders.tsx index 1a692417d..142d8eae4 100644 --- a/gui/src/hooks/TelemetryProviders.tsx +++ b/gui/src/hooks/TelemetryProviders.tsx @@ -29,7 +29,8 @@ const TelemetryProviders = ({ children }: PropsWithChildren) => { ); useEffect(() => { - if (allowAnonymousTelemetry && hasContinueEmail) { + // PostHog depends only on allowAnonymousTelemetry + if (allowAnonymousTelemetry) { // Initialize PostHog (existing logic) posthog.init("phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs", { api_host: "https://app.posthog.com", @@ -41,7 +42,13 @@ const TelemetryProviders = ({ children }: PropsWithChildren) => { }); posthog.identify(window.vscMachineId); posthog.opt_in_capturing(); + } else { + // Disable PostHog + posthog.opt_out_capturing(); + } + // Sentry depends on both allowAnonymousTelemetry and hasContinueEmail + if (allowAnonymousTelemetry && hasContinueEmail) { // Initialize Sentry (new for GUI - enhanced React setup) Sentry.init({ dsn: SENTRY_DSN, @@ -95,9 +102,6 @@ const TelemetryProviders = ({ children }: PropsWithChildren) => { }); Sentry.setUser(anonymizedUser); } else { - // Disable PostHog - posthog.opt_out_capturing(); - // Disable Sentry properly - close the client to stop all network requests try { const client = Sentry.getClient(); diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx index dbab7a18d..3cbcab061 100644 --- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -17,7 +17,7 @@ export function EditFile(props: EditToolCallProps) { return null; } - const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath)} ${props.relativeFilePath}\n${props.changes}\n\`\`\``; + const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath)} ${props.relativeFilePath}${props.changes ? "\n" + props.changes + "\n" : ""}\`\`\``; return ( ({ + IdeMessengerContext: { + _currentValue: { post: vi.fn() }, + }, +})); + +vi.mock("../../../redux/hooks", () => ({ + useAppSelector: vi.fn(), +})); + +vi.mock("../../../components/ui", () => ({ + useFontSize: () => 14, +})); + +vi.mock("../../../util/clientTools/findAndReplaceUtils", () => ({ + performFindAndReplace: vi.fn(), +})); + +vi.mock("./utils", () => ({ + getStatusIcon: vi.fn(() =>
✓
), +})); + +vi.mock("react", async () => { + const actual = await vi.importActual("react"); + return { + ...actual, + useContext: () => ({ post: vi.fn() }), + }; +}); + +// Import mocked modules +import { useAppSelector } from "../../../redux/hooks"; +import { performFindAndReplace } from "../../../util/clientTools/findAndReplaceUtils"; + +const mockPost = vi.fn(); +const mockUseAppSelector = useAppSelector as any; +const mockPerformFindAndReplace = performFindAndReplace as any; + +describe("FindAndReplaceDisplay", () => { + const defaultProps = { + fileUri: "file:///test/file.ts", + relativeFilePath: "test/file.ts", + editingFileContents: "const old = 'value';\nconst other = 'test';", + edits: [ + { + old_string: "const old = 'value';", + new_string: "const new = 'value';", + replace_all: false, + }, + ] as EditOperation[], + toolCallId: "test-tool-call-id", + historyIndex: 0, + }; + + const mockToolCallState = { + status: "done" as const, + output: null, + }; + + const mockConfig = { + ui: { + showChatScrollbar: true, + codeWrap: false, + }, + }; + + beforeEach(() => { + vi.clearAllMocks(); + + mockUseAppSelector.mockImplementation((selector: any) => { + const mockState = { + config: { config: mockConfig }, + session: { + history: [], + codeBlockApplyStates: { states: [] }, + }, + }; + + if (selector.toString().includes("selectApplyStateByToolCallId")) { + return undefined; // No apply state by default + } + if (selector.toString().includes("selectToolCallById")) { + return mockToolCallState; + } + + return selector(mockState); + }); + + mockPerformFindAndReplace.mockImplementation( + (content: string, oldStr: string, newStr: string) => { + return content.replace(oldStr, newStr); + }, + ); + }); + + describe("basic rendering", () => { + it("should render with collapsed state by default", () => { + render(); + + expect(screen.getByText("file.ts")).toBeInTheDocument(); + expect( + screen.getByTestId("toggle-find-and-replace-diff"), + ).toBeInTheDocument(); + + // Should not show diff content when collapsed + const diffContent = screen.queryByText("-"); + expect(diffContent).not.toBeInTheDocument(); + }); + + it("should display file name from fileUri", () => { + render(); + expect(screen.getByText("file.ts")).toBeInTheDocument(); + }); + + it("should display file name from relativeFilePath when no fileUri", () => { + render( + , + ); + expect(screen.getByText("test.tsx")).toBeInTheDocument(); + }); + + it("should handle missing file paths gracefully", () => { + render( + , + ); + + // Should still render the component structure + expect( + screen.getByTestId("toggle-find-and-replace-diff"), + ).toBeInTheDocument(); + }); + }); + + describe("expand/collapse functionality", () => { + it("should expand when clicked", () => { + render(); + + const toggleButton = screen.getByTestId("toggle-find-and-replace-diff"); + fireEvent.click(toggleButton); + + // Should show diff content when expanded + expect(screen.getByText("-")).toBeInTheDocument(); + expect(screen.getByText("+")).toBeInTheDocument(); + }); + + it("should show content when tool call status is 'generated'", () => { + mockUseAppSelector.mockImplementation((selector: any) => { + const mockState = { + config: { config: mockConfig }, + session: { + history: [], + codeBlockApplyStates: { states: [] }, + }, + }; + + if (selector.toString().includes("selectToolCallById")) { + return { ...mockToolCallState, status: "generated" }; + } + if (selector.toString().includes("selectApplyStateByToolCallId")) { + return undefined; + } + + return selector(mockState); + }); + + render(); + + // Should show diff content without expanding + expect(screen.getByText("-")).toBeInTheDocument(); + expect(screen.getByText("+")).toBeInTheDocument(); + }); + }); + + describe("diff generation", () => { + it("should generate and display diff correctly", () => { + render(); + + const toggleButton = screen.getByTestId("toggle-find-and-replace-diff"); + fireEvent.click(toggleButton); + + // Should show removed line + expect(screen.getByText("const old = 'value';")).toBeInTheDocument(); + + // Should show added line + expect(screen.getByText("const new = 'value';")).toBeInTheDocument(); + + // Should show unchanged line + expect(screen.getByText("const other = 'test';")).toBeInTheDocument(); + }); + + it("should handle multiple edits", () => { + const multipleEdits = [ + { + old_string: "const old = 'value';", + new_string: "const new = 'value';", + replace_all: false, + }, + { + old_string: "const other = 'test';", + new_string: "const other = 'updated';", + replace_all: false, + }, + ] as EditOperation[]; + + mockPerformFindAndReplace + .mockReturnValueOnce("const new = 'value';\nconst other = 'test';") + .mockReturnValueOnce("const new = 'value';\nconst other = 'updated';"); + + render(); + + const toggleButton = screen.getByTestId("toggle-find-and-replace-diff"); + fireEvent.click(toggleButton); + + expect(mockPerformFindAndReplace).toHaveBeenCalledTimes(2); + }); + + it("should handle diff generation errors", () => { + mockPerformFindAndReplace.mockImplementation(() => { + throw new Error("Test error"); + }); + + render(); + + const toggleButton = screen.getByTestId("toggle-find-and-replace-diff"); + fireEvent.click(toggleButton); + + expect(screen.getByText("Error generating diff")).toBeInTheDocument(); + expect(screen.getByText("Test error")).toBeInTheDocument(); + }); + + it("should show 'No changes to display' when diff is empty", () => { + // Mock the function to return the exact same content (no changes) + mockPerformFindAndReplace.mockReturnValue( + defaultProps.editingFileContents, + ); + + render(); + + const toggleButton = screen.getByTestId("toggle-find-and-replace-diff"); + fireEvent.click(toggleButton); + + expect(screen.getByText("No changes to display")).toBeInTheDocument(); + }); + }); + + describe("apply actions", () => { + const mockApplyState: ApplyState = { + streamId: "test-stream-id", + status: "streaming", + numDiffs: 1, + fileContent: "test content", + }; + + beforeEach(() => { + mockUseAppSelector.mockImplementation((selector: any) => { + const mockState = { + config: { config: mockConfig }, + session: { + history: [], + codeBlockApplyStates: { states: [mockApplyState] }, + }, + }; + + if (selector.toString().includes("selectApplyStateByToolCallId")) { + return mockApplyState; + } + if (selector.toString().includes("selectToolCallById")) { + return mockToolCallState; + } + + return selector(mockState); + }); + }); + + it("should show apply actions when applyState exists", () => { + render(); + + // ApplyActions component should be rendered (we can test by looking for its structure) + // Since we don't have the exact structure, we test that the container is there + expect( + screen.getByTestId("toggle-find-and-replace-diff"), + ).toBeInTheDocument(); + }); + + it("should handle accept action", () => { + render(); + + // This would need more detailed testing if ApplyActions was properly mocked + // For now, we verify the component renders without errors + expect( + screen.getByTestId("toggle-find-and-replace-diff"), + ).toBeInTheDocument(); + }); + }); + + describe("content handling", () => { + it("should use editingFileContents when provided", () => { + render(); + + const toggleButton = screen.getByTestId("toggle-find-and-replace-diff"); + fireEvent.click(toggleButton); + + expect(mockPerformFindAndReplace).toHaveBeenCalledWith( + "const old = 'value';\nconst other = 'test';", + "const old = 'value';", + "const new = 'value';", + false, + 0, + ); + }); + + it("should fallback to edit old_strings when no editingFileContents", () => { + render( + , + ); + + const toggleButton = screen.getByTestId("toggle-find-and-replace-diff"); + fireEvent.click(toggleButton); + + expect(mockPerformFindAndReplace).toHaveBeenCalledWith( + "const old = 'value';", + "const old = 'value';", + "const new = 'value';", + false, + 0, + ); + }); + }); +}); diff --git a/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx b/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx new file mode 100644 index 000000000..18d995601 --- /dev/null +++ b/gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx @@ -0,0 +1,274 @@ +import { ChevronDownIcon } from "@heroicons/react/24/outline"; +import { ApplyState } from "core"; +import { EditOperation } from "core/tools/definitions/multiEdit"; +import { renderContextItems } from "core/util/messageContent"; +import { getLastNPathParts, getUriPathBasename } from "core/util/uri"; +import { diffLines } from "diff"; +import { useContext, useMemo, useState } from "react"; +import { ApplyActions } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions"; +import { FileInfo } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo"; +import { useFontSize } from "../../../components/ui"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { useAppSelector } from "../../../redux/hooks"; +import { + selectApplyStateByToolCallId, + selectToolCallById, +} from "../../../redux/selectors/selectToolCalls"; +import { performFindAndReplace } from "../../../util/clientTools/findAndReplaceUtils"; +import { getStatusIcon } from "./utils"; + +interface FindAndReplaceDisplayProps { + fileUri?: string; + editingFileContents?: string; + relativeFilePath?: string; + edits: EditOperation[]; + toolCallId: string; + historyIndex: number; +} + +export function FindAndReplaceDisplay({ + fileUri, + relativeFilePath, + editingFileContents, + edits, + toolCallId, + historyIndex, +}: FindAndReplaceDisplayProps) { + const [isExpanded, setIsExpanded] = useState(false); + const ideMessenger = useContext(IdeMessengerContext); + const applyState: ApplyState | undefined = useAppSelector((state) => + selectApplyStateByToolCallId(state, toolCallId), + ); + const fontSize = useFontSize(); + const toolCallState = useAppSelector((state) => + selectToolCallById(state, toolCallId), + ); + const config = useAppSelector((state) => state.config.config); + + const displayName = useMemo(() => { + if (fileUri) { + return getUriPathBasename(fileUri); + } + if (relativeFilePath) { + return getLastNPathParts(relativeFilePath, 1); + } + return ""; + }, [fileUri, relativeFilePath]); + + // Get file content from tool call state instead of reading file + const currentFileContent = useMemo(() => { + if (editingFileContents) { + return editingFileContents; + } + return edits?.map((edit) => edit.old_string ?? "").join("\n"); + }, [editingFileContents, edits]); + + const diffResult = useMemo(() => { + if (!currentFileContent) { + return null; + } + + try { + // Apply all edits sequentially + let newContent = currentFileContent; + for (let i = 0; i < edits.length; i++) { + const { + old_string: oldString, + new_string: newString, + replace_all: replaceAll, + } = edits[i]; + newContent = performFindAndReplace( + newContent, + oldString, + newString, + replaceAll, + i, + ); + } + + // Generate diff between original and final content + const diff = diffLines(currentFileContent, newContent); + return { diff, newContent, error: null }; + } catch (error) { + return { + diff: null, + newContent: null, + error: error instanceof Error ? error.message : "Unknown error", + }; + } + }, [currentFileContent, edits]); + + const statusIcon = useMemo(() => { + const status = toolCallState?.status; + if (status) { + if (status === "canceled" || status === "errored" || status === "done") { + return ( +
{ + if (toolCallState.output) { + e.stopPropagation(); + ideMessenger.post("showVirtualFile", { + name: "Edit output", + content: renderContextItems(toolCallState.output), + }); + } + }} + > + {getStatusIcon(toolCallState.status)} +
+ ); + } + } + }, [toolCallState?.status, toolCallState?.output]); + + // Unified container component that always renders the same structure + const renderContainer = (content: React.ReactNode) => ( +
+
{ + setIsExpanded((prev) => !prev); + }} + > +
+ {statusIcon} + + { + if (!fileUri) { + return; + } + e.stopPropagation(); + ideMessenger.post("openFile", { path: fileUri }); + }} + /> +
+ + {applyState && ( + { + ideMessenger.post(`acceptDiff`, { + filepath: fileUri, + streamId: applyState.streamId, + }); + }} + onClickReject={() => { + ideMessenger.post(`rejectDiff`, { + filepath: fileUri, + streamId: applyState.streamId, + }); + }} + disableManualApply={true} + applyState={applyState} + /> + )} +
+ {toolCallState?.status === "generated" || isExpanded ? content : null} +
+ ); + + if (diffResult?.error) { + return renderContainer( +
+ Error generating diff {diffResult.error} +
, + ); + } + + if ( + !diffResult?.diff || + (diffResult.diff.length === 1 && + !diffResult.diff[0].added && + !diffResult.diff[0].removed) + ) { + return renderContainer( +
No changes to display
, + ); + } + + return renderContainer( +
+
+        {diffResult.diff.map((part, index) => {
+          if (part.removed) {
+            return (
+              
+ {part.value.split("\n").map((line, lineIndex) => { + if ( + line === "" && + lineIndex === part.value.split("\n").length - 1 + ) + return null; + return ( +
+ - + {line} +
+ ); + })} +
+ ); + } else if (part.added) { + return ( +
+ {part.value.split("\n").map((line, lineIndex) => { + if ( + line === "" && + lineIndex === part.value.split("\n").length - 1 + ) + return null; + return ( +
+ + + {line} +
+ ); + })} +
+ ); + } else { + return ( +
+ {part.value.split("\n").map((line, lineIndex) => { + if ( + line === "" && + lineIndex === part.value.split("\n").length - 1 + ) + return null; + return ( +
+ + {" "} + + {line} +
+ ); + })} +
+ ); + } + })} +
+
, + ); +} diff --git a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx index 52c03fd85..0fcdc0fc1 100644 --- a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx +++ b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx @@ -1,7 +1,9 @@ import { ToolCallState } from "core"; import { BuiltInToolNames } from "core/tools/builtIn"; +import { EditOperation } from "core/tools/definitions/multiEdit"; import { CreateFile } from "./CreateFile"; import { EditFile } from "./EditFile"; +import { FindAndReplaceDisplay } from "./FindAndReplace"; import { RunTerminalCommand } from "./RunTerminalCommand"; function FunctionSpecificToolCallDiv({ @@ -33,9 +35,9 @@ function FunctionSpecificToolCallDiv({ /> ); case BuiltInToolNames.SearchAndReplaceInFile: - const changes = args.diffs + const changes = args?.diffs ? Array.isArray(args.diffs) - ? args.diffs.join("\n\n---\n\n") + ? args.diffs?.join("\n\n---\n\n") : args.diffs : ""; @@ -49,6 +51,35 @@ function FunctionSpecificToolCallDiv({ historyIndex={historyIndex} /> ); + case BuiltInToolNames.SingleFindAndReplace: + const edits: EditOperation[] = [ + { + old_string: args?.old_string ?? "", + new_string: args?.new_string ?? "", + replace_all: args?.replace_all, + }, + ]; + return ( + + ); + case BuiltInToolNames.MultiEdit: + return ( + + ); case BuiltInToolNames.RunTerminalCommand: return ( { - switch (status) { - case "running": - return "bg-success"; - case "completed": - return "bg-success"; - case "background": - return "bg-accent"; - case "failed": - return "bg-error"; - default: - return "bg-success"; - } - }; - - return ( - - ); -} - export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) { - const dispatch = useAppDispatch(); - // Find the terminal output from context items if available const terminalItem = props.toolCallState.output?.find( (item) => item.name === "Terminal", @@ -52,43 +16,6 @@ export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) { const terminalContent = terminalItem?.content || ""; const statusMessage = terminalItem?.status || ""; const isRunning = props.toolCallState.status === "calling"; - const hasOutput = terminalContent.length > 0; - - const displayLines = 15; - - // Process terminal content for line limiting - const processedTerminalContent = useMemo(() => { - if (!terminalContent) - return { - fullContent: "", - limitedContent: "", - totalLines: 0, - isLimited: false, - hiddenLinesCount: 0, - }; - - const lines = terminalContent.split("\n"); - const totalLines = lines.length; - - if (totalLines > displayLines) { - const lastTwentyLines = lines.slice(-displayLines); - return { - fullContent: terminalContent, - limitedContent: lastTwentyLines.join("\n"), - totalLines, - isLimited: true, - hiddenLinesCount: totalLines - displayLines, - }; - } - - return { - fullContent: terminalContent, - limitedContent: terminalContent, - totalLines, - isLimited: false, - hiddenLinesCount: 0, - }; - }, [terminalContent]); // Determine status type let statusType: "running" | "completed" | "failed" | "background" = @@ -102,55 +29,13 @@ export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) { } return ( -
- {/* Command */} - - - {/* Terminal output with ANSI support */} - {isRunning && !hasOutput && ( -
Waiting for output...
- )} - {hasOutput && ( - {processedTerminalContent.limitedContent} - } - expandedContent={{processedTerminalContent.fullContent}} - /> - )} - - {/* Status information */} - {(statusMessage || isRunning) && ( - - )} -
+ ); } diff --git a/gui/src/pages/gui/ToolCallDiv/index.tsx b/gui/src/pages/gui/ToolCallDiv/index.tsx index 12556998e..31f50f471 100644 --- a/gui/src/pages/gui/ToolCallDiv/index.tsx +++ b/gui/src/pages/gui/ToolCallDiv/index.tsx @@ -54,7 +54,11 @@ export function ToolCallDiv({ // Obviously missing the truncate and args buttons // All the info from args is displayed here // But we'd need a nicer place to put the truncate button and the X icon when tool call fails - if (functionName === BuiltInToolNames.SearchAndReplaceInFile) { + if ( + functionName === BuiltInToolNames.SearchAndReplaceInFile || + functionName === BuiltInToolNames.SingleFindAndReplace || + functionName === BuiltInToolNames.MultiEdit + ) { return (
{ - expect(messengerPostSpy).toHaveBeenCalledWith("applyToFile", { + expect(messengerRequestSpy).toHaveBeenCalledWith("applyToFile", { streamId: expect.any(String), filepath: EDIT_FILE_URI, text: EDIT_CHANGES, @@ -101,7 +99,7 @@ test( }); // Extract stream ID and initiate mock streaming - const streamId = messengerPostSpy.mock.calls.find( + const streamId = messengerRequestSpy.mock.calls.find( (call) => call[0] === "applyToFile", )?.[1]?.streamId; expect(streamId).toBeDefined(); @@ -172,6 +170,7 @@ test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => { ideMessenger.responses["getWorkspaceDirs"] = [EDIT_WORKSPACE_DIR]; const messengerPostSpy = vi.spyOn(ideMessenger, "post"); + const messengerRequestSpy = vi.spyOn(ideMessenger, "request"); addAndSelectMockLlm(store, ideMessenger); @@ -219,7 +218,7 @@ test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => { ); // Tool call, check that applyToFile was called for edit await waitFor(() => { - expect(messengerPostSpy).toHaveBeenCalledWith("applyToFile", { + expect(messengerRequestSpy).toHaveBeenCalledWith("applyToFile", { streamId: expect.any(String), filepath: EDIT_FILE_URI, text: EDIT_CHANGES, @@ -228,7 +227,7 @@ test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => { }); // Extract stream ID and initiate mock streaming - const streamId = messengerPostSpy.mock.calls.find( + const streamId = messengerRequestSpy.mock.calls.find( (call) => call[0] === "applyToFile", )?.[1]?.streamId; expect(streamId).toBeDefined(); diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 3ec2fe27b..7251b04ac 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -849,6 +849,21 @@ export const sessionSlice = createSlice({ ); } }, + setToolCallArgs: ( + state, + action: PayloadAction<{ + toolCallId: string; + newArgs: Record; + }>, + ) => { + const toolCallState = findToolCallById( + state.history, + action.payload.toolCallId, + ); + if (toolCallState) { + toolCallState.parsedArgs = action.payload.newArgs; + } + }, cancelToolCall: ( state, action: PayloadAction<{ @@ -1024,6 +1039,7 @@ export const { acceptToolCall, setToolGenerated, updateToolCallOutput, + setToolCallArgs, setMode, setIsSessionMetadataLoading, setAllSessionMetadata, diff --git a/gui/src/redux/thunks/enhanceParsedArgs.ts b/gui/src/redux/thunks/enhanceParsedArgs.ts new file mode 100644 index 000000000..75141abb8 --- /dev/null +++ b/gui/src/redux/thunks/enhanceParsedArgs.ts @@ -0,0 +1,53 @@ +import { BuiltInToolNames } from "core/tools/builtIn"; +import { resolveRelativePathInDir } from "core/util/ideUtils"; +import { getUriPathBasename } from "core/util/uri"; +import { IIdeMessenger } from "../../context/IdeMessenger"; +import { setToolCallArgs } from "../slices/sessionSlice"; +import { AppThunkDispatch } from "../store"; + +export async function enhanceParsedArgs( + ideMessenger: IIdeMessenger, + dispatch: AppThunkDispatch, + toolName: string | undefined, + toolCallId: string, + currentArgs: undefined | Record, +) { + // Add file content to parsedArgs for find/replace tools + let enhancedArgs = { ...currentArgs }; + if ( + (toolName === BuiltInToolNames.SingleFindAndReplace || + toolName === BuiltInToolNames.MultiEdit || + toolName === BuiltInToolNames.SearchAndReplaceInFile) && + currentArgs?.filepath && + !currentArgs?.editingFileContents + ) { + try { + const fileUri = await resolveRelativePathInDir( + currentArgs.filepath, + ideMessenger.ide, + ); + if (!fileUri) { + throw new Error(`File ${currentArgs.filepath} not found`); + } + const baseName = getUriPathBasename(fileUri); + const fileContent = await ideMessenger.ide.readFile(fileUri); + enhancedArgs = { + ...currentArgs, + fileUri, + baseName, + editingFileContents: fileContent, + }; + dispatch( + setToolCallArgs({ + toolCallId, + newArgs: enhancedArgs, + }), + ); + } catch (error) { + // If we can't read the file, let the tool handle the error + console.warn( + `Failed to enhance args: failed to read file ${currentArgs?.filepath}`, + ); + } + } +} diff --git a/gui/src/redux/thunks/handleApplyStateUpdate.test.ts b/gui/src/redux/thunks/handleApplyStateUpdate.test.ts new file mode 100644 index 000000000..46ae54c35 --- /dev/null +++ b/gui/src/redux/thunks/handleApplyStateUpdate.test.ts @@ -0,0 +1,762 @@ +import { ApplyState, ApplyToFilePayload, ToolCallState } from "core"; +import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { logAgentModeEditOutcome } from "../../util/editOutcomeLogger"; +import { + selectApplyStateByToolCallId, + selectToolCallById, +} from "../selectors/selectToolCalls"; +import { updateEditStateApplyState } from "../slices/editState"; +import { + acceptToolCall, + errorToolCall, + updateApplyState, + updateToolCallOutput, +} from "../slices/sessionSlice"; +import { findToolCallById, logToolUsage } from "../util"; +import { exitEdit } from "./edit"; +import { + applyForEditTool, + handleApplyStateUpdate, +} from "./handleApplyStateUpdate"; +import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall"; + +// Mock dependencies +vi.mock("../../util/editOutcomeLogger", () => ({ + logAgentModeEditOutcome: vi.fn(), +})); + +vi.mock("../selectors/selectToolCalls", () => ({ + selectApplyStateByToolCallId: vi.fn(), + selectToolCallById: vi.fn(), +})); + +vi.mock("../slices/editState", () => ({ + updateEditStateApplyState: vi.fn(() => ({ + type: "editState/updateApplyState", + })), +})); + +vi.mock("../slices/sessionSlice", () => ({ + acceptToolCall: vi.fn(() => ({ type: "session/acceptToolCall" })), + errorToolCall: vi.fn(() => ({ type: "session/errorToolCall" })), + updateApplyState: vi.fn(() => ({ type: "session/updateApplyState" })), + updateToolCallOutput: vi.fn(() => ({ type: "session/updateToolCallOutput" })), +})); + +vi.mock("../util", () => ({ + findToolCallById: vi.fn(), + logToolUsage: vi.fn(), +})); + +vi.mock("./edit", () => ({ + exitEdit: vi.fn(() => ({ type: "edit/exitEdit" })), +})); + +vi.mock("./streamResponseAfterToolCall", () => ({ + streamResponseAfterToolCall: vi.fn(() => ({ + type: "session/streamResponseAfterToolCall", + })), +})); + +const UNUSED_TOOL_CALL_PARAMS = { + toolCall: { + id: "name", + function: { + name: "unused", + arguments: "unused", + }, + type: "function" as const, + }, + parsedArgs: {}, +}; + +describe("handleApplyStateUpdate", () => { + let mockDispatch: any; + let mockGetState: any; + let mockExtra: any; + + beforeEach(() => { + vi.clearAllMocks(); + mockDispatch = vi.fn(); + mockGetState = vi.fn(); + mockExtra = { + ideMessenger: { + post: vi.fn(), + request: vi.fn(), + }, + }; + }); + + describe("edit mode handling", () => { + it("should handle edit mode apply state updates", async () => { + const applyState: ApplyState = { + streamId: EDIT_MODE_STREAM_ID, + toolCallId: "test-tool-call", + status: "streaming", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(updateEditStateApplyState).toHaveBeenCalledWith(applyState); + expect(mockDispatch).toHaveBeenCalledWith( + expect.objectContaining({ type: "editState/updateApplyState" }), + ); + }); + + it("should exit edit mode when status is closed", async () => { + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "done", + ...UNUSED_TOOL_CALL_PARAMS, + }; + vi.mocked(findToolCallById).mockReturnValue(toolCallState); + + mockGetState.mockReturnValue({ + session: { history: [] }, + }); + + const applyState: ApplyState = { + streamId: EDIT_MODE_STREAM_ID, + toolCallId: "test-tool-call", + status: "closed", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(logToolUsage).toHaveBeenCalledWith( + toolCallState, + true, + true, + mockExtra.ideMessenger, + ); + expect(exitEdit).toHaveBeenCalledWith({}); + expect(mockDispatch).toHaveBeenCalledWith( + expect.objectContaining({ type: "edit/exitEdit" }), + ); + }); + }); + + describe("chat/agent mode handling", () => { + it("should handle non-edit mode apply state updates", async () => { + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status: "streaming", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(updateApplyState).toHaveBeenCalledWith(applyState); + expect(mockDispatch).toHaveBeenCalledWith( + expect.objectContaining({ type: "session/updateApplyState" }), + ); + }); + + it("should auto-accept diffs when configured and status is done", async () => { + mockGetState.mockReturnValue({ + config: { + config: { + ui: { + autoAcceptEditToolDiffs: true, + }, + }, + }, + session: { history: [] }, + }); + + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status: "done", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(mockExtra.ideMessenger.post).toHaveBeenCalledWith("acceptDiff", { + streamId: "chat-stream", + filepath: "test.txt", + }); + }); + + it("should not auto-accept when config is disabled", async () => { + mockGetState.mockReturnValue({ + config: { + config: { + ui: { + autoAcceptEditToolDiffs: false, + }, + }, + }, + session: { history: [] }, + }); + + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status: "done", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(mockExtra.ideMessenger.post).not.toHaveBeenCalled(); + }); + }); + + describe("closed status handling", () => { + it("should handle accepted tool call closure", async () => { + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "done", + ...UNUSED_TOOL_CALL_PARAMS, + }; + const newApplyState = { streamId: "chat-stream" }; + + vi.mocked(findToolCallById).mockReturnValue(toolCallState); + mockGetState.mockReturnValue({ + session: { + history: [], + codeBlockApplyStates: { + states: [newApplyState], + }, + }, + config: { config: {} }, + }); + + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status: "closed", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(logToolUsage).toHaveBeenCalledWith( + toolCallState, + true, + true, + mockExtra.ideMessenger, + ); + expect(logAgentModeEditOutcome).toHaveBeenCalledWith( + [], + {}, + toolCallState, + newApplyState, + true, + mockExtra.ideMessenger, + ); + expect(acceptToolCall).toHaveBeenCalledWith({ + toolCallId: "test-tool-call", + }); + expect(streamResponseAfterToolCall).toHaveBeenCalledWith({ + toolCallId: "test-tool-call", + }); + }); + + it("should handle canceled tool call closure", async () => { + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "canceled", + ...UNUSED_TOOL_CALL_PARAMS, + }; + const newApplyState = { streamId: "chat-stream" }; + + vi.mocked(findToolCallById).mockReturnValue(toolCallState); + mockGetState.mockReturnValue({ + session: { + history: [], + codeBlockApplyStates: { + states: [newApplyState], + }, + }, + config: { config: {} }, + }); + + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status: "closed", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(logToolUsage).toHaveBeenCalledWith( + toolCallState, + false, + true, + mockExtra.ideMessenger, + ); + expect(logAgentModeEditOutcome).toHaveBeenCalledWith( + [], + {}, + toolCallState, + newApplyState, + false, + mockExtra.ideMessenger, + ); + expect(acceptToolCall).not.toHaveBeenCalled(); + expect(streamResponseAfterToolCall).not.toHaveBeenCalled(); + }); + + it("should handle errored tool call closure", async () => { + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "errored", + ...UNUSED_TOOL_CALL_PARAMS, + }; + const newApplyState = { streamId: "chat-stream" }; + + vi.mocked(findToolCallById).mockReturnValue(toolCallState); + mockGetState.mockReturnValue({ + session: { + history: [], + codeBlockApplyStates: { + states: [newApplyState], + }, + }, + config: { config: {} }, + }); + + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status: "closed", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(acceptToolCall).not.toHaveBeenCalled(); + expect(streamResponseAfterToolCall).toHaveBeenCalledWith({ + toolCallId: "test-tool-call", + }); + }); + + it("should handle closure when no tool call found", async () => { + vi.mocked(findToolCallById).mockReturnValue(undefined); + mockGetState.mockReturnValue({ + session: { + history: [], + codeBlockApplyStates: { + states: [], + }, + }, + }); + + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status: "closed", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(logToolUsage).not.toHaveBeenCalled(); + expect(acceptToolCall).not.toHaveBeenCalled(); + expect(streamResponseAfterToolCall).not.toHaveBeenCalled(); + }); + + it("should handle closure when no apply state found", async () => { + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "done", + ...UNUSED_TOOL_CALL_PARAMS, + }; + + vi.mocked(findToolCallById).mockReturnValue(toolCallState); + mockGetState.mockReturnValue({ + session: { + history: [], + codeBlockApplyStates: { + states: [], + }, + }, + config: { config: {} }, + }); + + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status: "closed", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(logAgentModeEditOutcome).not.toHaveBeenCalled(); + expect(acceptToolCall).toHaveBeenCalledWith({ + toolCallId: "test-tool-call", + }); + }); + }); + + describe("edge cases", () => { + it("should handle apply state without toolCallId", async () => { + const applyState: ApplyState = { + streamId: "chat-stream", + status: "streaming", + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(updateApplyState).toHaveBeenCalledWith(applyState); + expect(acceptToolCall).not.toHaveBeenCalled(); + expect(streamResponseAfterToolCall).not.toHaveBeenCalled(); + }); + + it("should handle different status values", async () => { + const statusValues: ApplyState["status"][] = [ + "not-started", + "streaming", + "done", + "closed", + ]; + + for (const status of statusValues) { + vi.clearAllMocks(); + + const applyState: ApplyState = { + streamId: "chat-stream", + toolCallId: "test-tool-call", + status, + filepath: "test.txt", + numDiffs: 1, + }; + + const thunk = handleApplyStateUpdate(applyState); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(updateApplyState).toHaveBeenCalledWith(applyState); + } + }); + }); +}); + +describe("applyForEditTool", () => { + let mockDispatch: any; + let mockGetState: any; + let mockExtra: any; + + beforeEach(() => { + vi.clearAllMocks(); + mockDispatch = vi.fn(); + mockGetState = vi.fn(); + mockExtra = { + ideMessenger: { + request: vi.fn(), + }, + }; + }); + + describe("successful application", () => { + it("should successfully apply changes to file", async () => { + const payload: ApplyToFilePayload & { toolCallId: string } = { + toolCallId: "test-tool-call", + streamId: "test-stream", + filepath: "test.txt", + text: "new content", + isSearchAndReplace: true, + }; + + mockExtra.ideMessenger.request.mockResolvedValue({ status: "success" }); + + const thunk = applyForEditTool(payload); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(updateApplyState).toHaveBeenCalledWith({ + streamId: "test-stream", + toolCallId: "test-tool-call", + status: "not-started", + }); + expect(mockDispatch).toHaveBeenCalledWith( + expect.objectContaining({ type: "session/updateApplyState" }), + ); + expect(mockExtra.ideMessenger.request).toHaveBeenCalledWith( + "applyToFile", + payload, + ); + }); + }); + + describe("error handling", () => { + it("should handle IDE messenger request failure", async () => { + const payload: ApplyToFilePayload & { toolCallId: string } = { + toolCallId: "test-tool-call", + streamId: "test-stream", + filepath: "test.txt", + text: "new content", + isSearchAndReplace: true, + }; + + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "calling", + ...UNUSED_TOOL_CALL_PARAMS, + }; + const applyState: ApplyState = { + status: "streaming", + streamId: "test-stream", + }; + + vi.mocked(selectToolCallById).mockReturnValue(toolCallState); + vi.mocked(selectApplyStateByToolCallId).mockReturnValue(applyState); + mockGetState.mockReturnValue({}); + + mockExtra.ideMessenger.request.mockRejectedValue( + new Error("Request failed"), + ); + + const thunk = applyForEditTool(payload); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(errorToolCall).toHaveBeenCalledWith({ + toolCallId: "test-tool-call", + }); + expect(updateToolCallOutput).toHaveBeenCalledWith({ + toolCallId: "test-tool-call", + contextItems: [ + { + icon: "problems", + name: "Apply Error", + description: "Failed to apply changes", + content: `Error editing file: failed to apply changes to file.\n\nPlease try again with correct args or notify the user and request further instructions.`, + hidden: false, + }, + ], + }); + }); + + it("should handle IDE messenger error response", async () => { + const payload: ApplyToFilePayload & { toolCallId: string } = { + toolCallId: "test-tool-call", + streamId: "test-stream", + filepath: "test.txt", + text: "new content", + isSearchAndReplace: true, + }; + + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "calling", + ...UNUSED_TOOL_CALL_PARAMS, + }; + const applyState: ApplyState = { + status: "streaming", + streamId: "test-stream", + }; + + vi.mocked(selectToolCallById).mockReturnValue(toolCallState); + vi.mocked(selectApplyStateByToolCallId).mockReturnValue(applyState); + mockGetState.mockReturnValue({}); + + mockExtra.ideMessenger.request.mockResolvedValue({ status: "error" }); + + const thunk = applyForEditTool(payload); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(errorToolCall).toHaveBeenCalledWith({ + toolCallId: "test-tool-call", + }); + expect(updateToolCallOutput).toHaveBeenCalledWith({ + toolCallId: "test-tool-call", + contextItems: [ + { + icon: "problems", + name: "Apply Error", + description: "Failed to apply changes", + content: `Error editing file: failed to apply changes to file.\n\nPlease try again with correct args or notify the user and request further instructions.`, + hidden: false, + }, + ], + }); + }); + + it("should not error if tool call is not in calling state", async () => { + const payload: ApplyToFilePayload & { toolCallId: string } = { + toolCallId: "test-tool-call", + streamId: "test-stream", + filepath: "test.txt", + text: "new content", + isSearchAndReplace: true, + }; + + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "done", + ...UNUSED_TOOL_CALL_PARAMS, + }; + const applyState: ApplyState = { + status: "streaming", + streamId: "test-stream", + }; + + vi.mocked(selectToolCallById).mockReturnValue(toolCallState); + vi.mocked(selectApplyStateByToolCallId).mockReturnValue(applyState); + mockGetState.mockReturnValue({}); + + mockExtra.ideMessenger.request.mockRejectedValue( + new Error("Request failed"), + ); + + const thunk = applyForEditTool(payload); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(errorToolCall).not.toHaveBeenCalled(); + expect(updateToolCallOutput).not.toHaveBeenCalled(); + }); + + it("should not error if apply state is closed", async () => { + const payload: ApplyToFilePayload & { toolCallId: string } = { + toolCallId: "test-tool-call", + streamId: "test-stream", + filepath: "test.txt", + text: "new content", + isSearchAndReplace: true, + }; + + const toolCallState: ToolCallState = { + toolCallId: "test-tool-call", + status: "calling", + ...UNUSED_TOOL_CALL_PARAMS, + }; + const applyState: ApplyState = { + status: "closed", + streamId: "test-stream", + }; // Already closed + + vi.mocked(selectToolCallById).mockReturnValue(toolCallState); + vi.mocked(selectApplyStateByToolCallId).mockReturnValue(applyState); + mockGetState.mockReturnValue({}); + + mockExtra.ideMessenger.request.mockRejectedValue( + new Error("Request failed"), + ); + + const thunk = applyForEditTool(payload); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(errorToolCall).not.toHaveBeenCalled(); + expect(updateToolCallOutput).not.toHaveBeenCalled(); + }); + + it("should not error if tool call state is not found", async () => { + const payload: ApplyToFilePayload & { toolCallId: string } = { + toolCallId: "test-tool-call", + streamId: "test-stream", + filepath: "test.txt", + text: "new content", + isSearchAndReplace: true, + }; + + vi.mocked(selectToolCallById).mockReturnValue(undefined); // Tool call not found + vi.mocked(selectApplyStateByToolCallId).mockReturnValue({ + status: "streaming", + streamId: "test-stream", + }); + mockGetState.mockReturnValue({}); + + mockExtra.ideMessenger.request.mockRejectedValue( + new Error("Request failed"), + ); + + const thunk = applyForEditTool(payload); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(errorToolCall).not.toHaveBeenCalled(); + expect(updateToolCallOutput).not.toHaveBeenCalled(); + }); + + it("should not error if apply state is not found", async () => { + const payload: ApplyToFilePayload & { toolCallId: string } = { + toolCallId: "test-tool-call", + streamId: "test-stream", + filepath: "test.txt", + text: "new content", + isSearchAndReplace: true, + }; + + vi.mocked(selectApplyStateByToolCallId).mockReturnValue(undefined); // Apply state not found + mockGetState.mockReturnValue({}); + + mockExtra.ideMessenger.request.mockRejectedValue( + new Error("Request failed"), + ); + + const thunk = applyForEditTool(payload); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(errorToolCall).not.toHaveBeenCalled(); + expect(updateToolCallOutput).not.toHaveBeenCalled(); + }); + }); + + describe("edge cases", () => { + it("should handle different payload types", async () => { + const payloads: (ApplyToFilePayload & { toolCallId: string })[] = [ + { + toolCallId: "test-1", + streamId: "stream-1", + filepath: "file1.txt", + text: "content 1", + isSearchAndReplace: false, + }, + { + toolCallId: "test-2", + streamId: "stream-2", + filepath: "file2.js", + text: "content 2", + isSearchAndReplace: true, + }, + ]; + + for (const payload of payloads) { + vi.clearAllMocks(); + mockExtra.ideMessenger.request.mockResolvedValue({ status: "success" }); + + const thunk = applyForEditTool(payload); + await thunk(mockDispatch, mockGetState, mockExtra); + + expect(mockExtra.ideMessenger.request).toHaveBeenCalledWith( + "applyToFile", + payload, + ); + expect(updateApplyState).toHaveBeenCalledWith({ + streamId: payload.streamId, + toolCallId: payload.toolCallId, + status: "not-started", + }); + } + }); + }); +}); diff --git a/gui/src/redux/thunks/handleApplyStateUpdate.ts b/gui/src/redux/thunks/handleApplyStateUpdate.ts new file mode 100644 index 000000000..25532e750 --- /dev/null +++ b/gui/src/redux/thunks/handleApplyStateUpdate.ts @@ -0,0 +1,170 @@ +import { createAsyncThunk } from "@reduxjs/toolkit"; +import { ApplyState, ApplyToFilePayload } from "core"; +import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; +import { logAgentModeEditOutcome } from "../../util/editOutcomeLogger"; +import { + selectApplyStateByToolCallId, + selectToolCallById, +} from "../selectors/selectToolCalls"; +import { updateEditStateApplyState } from "../slices/editState"; +import { + acceptToolCall, + errorToolCall, + updateApplyState, + updateToolCallOutput, +} from "../slices/sessionSlice"; +import { ThunkApiType } from "../store"; +import { findToolCallById, logToolUsage } from "../util"; +import { exitEdit } from "./edit"; +import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall"; + +export const handleApplyStateUpdate = createAsyncThunk< + void, + ApplyState, + ThunkApiType +>( + "apply/handleStateUpdate", + async (applyState, { dispatch, getState, extra }) => { + if (applyState.streamId === EDIT_MODE_STREAM_ID) { + dispatch(updateEditStateApplyState(applyState)); + + if (applyState.status === "closed") { + const toolCallState = findToolCallById( + getState().session.history, + applyState.toolCallId!, + ); + if (toolCallState) { + logToolUsage(toolCallState, true, true, extra.ideMessenger); + } + void dispatch(exitEdit({})); + } + } else { + // chat or agent + dispatch(updateApplyState(applyState)); + + // Handle apply status updates - use toolCallId from event payload + if (applyState.toolCallId) { + if ( + applyState.status === "done" && + getState().config.config?.ui?.autoAcceptEditToolDiffs + ) { + extra.ideMessenger.post("acceptDiff", { + streamId: applyState.streamId, + filepath: applyState.filepath, + }); + } + if (applyState.status === "closed") { + // Find the tool call to check if it was canceled + const toolCallState = findToolCallById( + getState().session.history, + applyState.toolCallId, + ); + + if (toolCallState) { + const accepted = toolCallState.status !== "canceled"; + + logToolUsage(toolCallState, accepted, true, extra.ideMessenger); + + // Log edit outcome for Agent Mode + const newApplyState = + getState().session.codeBlockApplyStates.states.find( + (s) => s.streamId === applyState.streamId, + ); + const newState = getState(); + if (newApplyState) { + void logAgentModeEditOutcome( + newState.session.history, + newState.config.config, + toolCallState, + newApplyState, + accepted, + extra.ideMessenger, + ); + } + + if (accepted) { + if (toolCallState.status !== "errored") { + dispatch( + acceptToolCall({ + toolCallId: applyState.toolCallId, + }), + ); + } + + void dispatch( + streamResponseAfterToolCall({ + toolCallId: applyState.toolCallId, + }), + ); + } + } + // TODO return output from edit tools so the model knows the result + } + } + } + }, +); + +export const applyForEditTool = createAsyncThunk< + void, + ApplyToFilePayload & { toolCallId: string }, + ThunkApiType +>("apply/editTool", async (payload, { dispatch, getState, extra }) => { + const { toolCallId, streamId } = payload; + dispatch( + updateApplyState({ + streamId, + toolCallId, + status: "not-started", + }), + ); + + let didError = false; + try { + const response = await extra.ideMessenger.request("applyToFile", payload); + if (response.status === "error") { + didError = true; + } + } catch (e) { + didError = true; + } + if (didError) { + const state = getState(); + + const toolCallState = selectToolCallById(state, toolCallId); + const applyState = selectApplyStateByToolCallId(state, toolCallId); + if ( + toolCallState && + applyState && + applyState.status !== "closed" && + toolCallState.status === "calling" + ) { + dispatch( + errorToolCall({ + toolCallId, + }), + ); + dispatch( + updateToolCallOutput({ + toolCallId, + contextItems: [ + { + icon: "problems", + name: "Apply Error", + description: "Failed to apply changes", + content: `Error editing file: failed to apply changes to file.\n\nPlease try again with correct args or notify the user and request further instructions.`, + hidden: false, + }, + ], + }), + ); + void dispatch( + handleApplyStateUpdate({ + status: "closed", + streamId: applyState.streamId, + toolCallId, + }), + ); + } + } +}); diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 218883cb9..dbd322357 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -1,8 +1,7 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit"; -import { LLMFullCompletionOptions, ModelDescription, Tool } from "core"; +import { LLMFullCompletionOptions, Tool } from "core"; import { getRuleId } from "core/llm/rules/getSystemMessageWithRules"; import { ToCoreProtocol } from "core/protocol"; -import { BuiltInToolNames } from "core/tools/builtIn"; import { selectActiveTools } from "../selectors/selectActiveTools"; import { selectUseSystemMessageTools } from "../selectors/selectUseSystemMessageTools"; import { selectSelectedChatModel } from "../slices/configSlice"; @@ -29,6 +28,7 @@ import { selectCurrentToolCalls } from "../selectors/selectToolCalls"; import { DEFAULT_TOOL_SETTING } from "../slices/uiSlice"; import { getBaseSystemMessage } from "../util/getBaseSystemMessage"; import { callToolById } from "./callToolById"; +import { enhanceParsedArgs } from "./enhanceParsedArgs"; /** * Handles the execution of tool calls that may be automatically accepted. * Sets all tools as generated first, then executes auto-approved tool calls. @@ -86,49 +86,6 @@ async function handleToolCallExecution( } } -/** - * Filters tools based on the selected model's capabilities. - * Returns either the edit file tool or search and replace tool, but not both. - */ -function filterToolsForModel( - tools: Tool[], - selectedModel: ModelDescription, -): Tool[] { - const editFileTool = tools.find( - (tool) => tool.function.name === BuiltInToolNames.EditExistingFile, - ); - const searchAndReplaceTool = tools.find( - (tool) => tool.function.name === BuiltInToolNames.SearchAndReplaceInFile, - ); - - // If we don't have both tools, return tools as-is - if (!editFileTool || !searchAndReplaceTool) { - return tools; - } - - // Determine which tool to use based on the model - const shouldUseFindReplace = shouldUseFindReplaceEdits(selectedModel); - - // Filter out the unwanted tool - return tools.filter((tool) => { - if (tool.function.name === BuiltInToolNames.EditExistingFile) { - return !shouldUseFindReplace; - } - if (tool.function.name === BuiltInToolNames.SearchAndReplaceInFile) { - return shouldUseFindReplace; - } - return true; - }); -} - -/** - * Determines whether to use search and replace tool instead of edit file - * Right now we only know that this is reliable with Claude models - */ -function shouldUseFindReplaceEdits({ model }: ModelDescription): boolean { - return model.includes("claude") || model.includes("gpt-5"); -} - export const streamNormalInput = createAsyncThunk< void, { @@ -146,8 +103,8 @@ export const streamNormalInput = createAsyncThunk< } // Get tools and filter them based on the selected model - const allActiveTools = selectActiveTools(state); - const activeTools = filterToolsForModel(allActiveTools, selectedChatModel); + const activeTools = selectActiveTools(state); + const supportsNativeTools = modelSupportsNativeTools(selectedChatModel); // Use the centralized selector to determine if system message tools should be used @@ -297,6 +254,19 @@ export const streamNormalInput = createAsyncThunk< const newState = getState(); const toolSettings = newState.ui.toolSettings; const allToolCallStates = selectCurrentToolCalls(newState); + + await Promise.all( + allToolCallStates.map((tcState) => + enhanceParsedArgs( + extra.ideMessenger, + dispatch, + tcState?.toolCall.function.name, + tcState.toolCallId, + tcState.parsedArgs, + ), + ), + ); + const generatingToolCalls = allToolCallStates.filter( (toolCallState) => toolCallState.status === "generating", ); diff --git a/gui/src/util/clientTools/callClientTool.ts b/gui/src/util/clientTools/callClientTool.ts index b5ac685d3..755be6e73 100644 --- a/gui/src/util/clientTools/callClientTool.ts +++ b/gui/src/util/clientTools/callClientTool.ts @@ -3,7 +3,9 @@ import { BuiltInToolNames } from "core/tools/builtIn"; import { IIdeMessenger } from "../../context/IdeMessenger"; import { AppThunkDispatch, RootState } from "../../redux/store"; import { editToolImpl } from "./editImpl"; +import { multiEditImpl } from "./multiEditImpl"; import { searchReplaceToolImpl } from "./searchReplaceImpl"; +import { singleFindAndReplaceImpl } from "./singleFindAndReplaceImpl"; export interface ClientToolExtras { getState: () => RootState; @@ -40,6 +42,16 @@ export async function callClientTool( case BuiltInToolNames.SearchAndReplaceInFile: output = await searchReplaceToolImpl(parsedArgs, toolCall.id, extras); break; + case BuiltInToolNames.SingleFindAndReplace: + output = await singleFindAndReplaceImpl( + parsedArgs, + toolCall.id, + extras, + ); + break; + case BuiltInToolNames.MultiEdit: + output = await multiEditImpl(parsedArgs, toolCall.id, extras); + break; default: throw new Error(`Invalid client tool name ${toolCall.function.name}`); } diff --git a/gui/src/util/clientTools/editImpl.ts b/gui/src/util/clientTools/editImpl.ts index a6f56e7c9..4dec61a65 100644 --- a/gui/src/util/clientTools/editImpl.ts +++ b/gui/src/util/clientTools/editImpl.ts @@ -1,5 +1,6 @@ import { resolveRelativePathInDir } from "core/util/ideUtils"; import { v4 as uuid } from "uuid"; +import { applyForEditTool } from "../../redux/thunks/handleApplyStateUpdate"; import { ClientToolImpl } from "./callClientTool"; export const editToolImpl: ClientToolImpl = async ( args, @@ -19,12 +20,14 @@ export const editToolImpl: ClientToolImpl = async ( throw new Error(`${args.filepath} does not exist`); } const streamId = uuid(); - extras.ideMessenger.post("applyToFile", { - streamId, - text: args.changes, - toolCallId, - filepath: firstUriMatch, - }); + void extras.dispatch( + applyForEditTool({ + streamId, + text: args.changes, + toolCallId, + filepath: firstUriMatch, + }), + ); return { respondImmediately: false, diff --git a/gui/src/util/clientTools/findAndReplaceUtils.test.ts b/gui/src/util/clientTools/findAndReplaceUtils.test.ts new file mode 100644 index 000000000..68ab333b9 --- /dev/null +++ b/gui/src/util/clientTools/findAndReplaceUtils.test.ts @@ -0,0 +1,456 @@ +import { EditOperation } from "core/tools/definitions/multiEdit"; +import { describe, expect, it } from "vitest"; +import { + EMPTY_NON_FIRST_EDIT_MESSAGE, + FOUND_MULTIPLE_FIND_STRINGS_ERROR, + performFindAndReplace, + validateCreatingForMultiEdit, + validateSingleEdit, +} from "./findAndReplaceUtils"; + +describe("performFindAndReplace", () => { + describe("normal cases", () => { + it("should replace single occurrence by default", () => { + const content = "Hello world\nThis is a test file\nGoodbye"; + const result = performFindAndReplace(content, "Hello", "Hi"); + + expect(result).toBe("Hi world\nThis is a test file\nGoodbye"); + }); + + it("should replace single occurrence when replaceAll is false", () => { + const content = "Hello world\nHello again"; + const result = performFindAndReplace( + content, + "Hello world", + "Hi world", + false, + ); + + expect(result).toBe("Hi world\nHello again"); + }); + + it("should replace all occurrences when replaceAll is true", () => { + const content = "Hello world\nHello again\nHello there"; + const result = performFindAndReplace(content, "Hello", "Hi", true); + + expect(result).toBe("Hi world\nHi again\nHi there"); + }); + + it("should handle empty new string (deletion)", () => { + const content = "Hello world"; + const result = performFindAndReplace(content, "Hello ", ""); + + expect(result).toBe("world"); + }); + + it("should handle empty old string replacement (insertion at start)", () => { + const content = ""; + const result = performFindAndReplace(content, "", "Hello world"); + + expect(result).toBe("Hello world"); + }); + + it("should preserve whitespace and indentation", () => { + const content = + "function test() {\n const value = 'old';\n return value;\n}"; + const result = performFindAndReplace( + content, + " const value = 'old';", + " const value = 'new';", + ); + + expect(result).toBe( + "function test() {\n const value = 'new';\n return value;\n}", + ); + }); + + it("should handle multiline strings", () => { + const content = "line1\nline2\nline3"; + const result = performFindAndReplace( + content, + "line1\nline2", + "newline1\nnewline2", + ); + + expect(result).toBe("newline1\nnewline2\nline3"); + }); + }); + + describe("special character handling", () => { + it("should handle regex special characters in old string", () => { + const content = "const regex = /[a-z]+/g;"; + const result = performFindAndReplace(content, "/[a-z]+/g", "/[A-Z]+/g"); + + expect(result).toBe("const regex = /[A-Z]+/g;"); + }); + + it("should handle dollar signs in strings", () => { + const content = 'const text = "Hello $world"'; + const result = performFindAndReplace( + content, + '"Hello $world"', + '"Hi $universe"', + ); + + expect(result).toBe('const text = "Hi $universe"'); + }); + + it("should handle backslashes", () => { + const content = 'const path = "C:\\Users\\test"'; + const result = performFindAndReplace( + content, + "C:\\Users\\test", + "D:\\Users\\test", + ); + + expect(result).toBe('const path = "D:\\Users\\test"'); + }); + + it("should handle parentheses", () => { + const content = "function test() { return 'old'; }"; + const result = performFindAndReplace( + content, + "() { return 'old'; }", + "() { return 'new'; }", + ); + + expect(result).toBe("function test() { return 'new'; }"); + }); + + it("should handle square brackets", () => { + const content = "const arr = [1, 2, 3];"; + const result = performFindAndReplace(content, "[1, 2, 3]", "[4, 5, 6]"); + + expect(result).toBe("const arr = [4, 5, 6];"); + }); + }); + + describe("replaceAll behavior", () => { + it("should replace all occurrences including partial matches", () => { + const content = "test testing tested test"; + const result = performFindAndReplace(content, "test", "exam", true); + + expect(result).toBe("exam examing examed exam"); + }); + + it("should replace all occurrences with empty string", () => { + const content = "remove this remove that remove everything"; + const result = performFindAndReplace(content, "remove ", "", true); + + expect(result).toBe("this that everything"); + }); + + it("should handle overlapping patterns correctly", () => { + const content = "aaaa"; + const result = performFindAndReplace(content, "aa", "b", true); + + expect(result).toBe("bb"); + }); + }); + + describe("error cases", () => { + it("should throw error when string not found", () => { + const content = "Hello world"; + + expect(() => { + performFindAndReplace(content, "xyz", "abc"); + }).toThrow('string not found in file: "xyz"'); + }); + + it("should throw error with edit context when string not found", () => { + const content = "Hello world"; + + expect(() => { + performFindAndReplace(content, "xyz", "abc", false, 2); + }).toThrow('edit at index 2: string not found in file: "xyz"'); + }); + + it("should throw error when multiple occurrences exist and replaceAll is false", () => { + const content = "Hello world\nHello again\nHello there"; + + expect(() => { + performFindAndReplace(content, "Hello", "Hi", false); + }).toThrow( + `String "Hello" appears 3 times in the file. ${FOUND_MULTIPLE_FIND_STRINGS_ERROR}`, + ); + }); + + it("should throw error with edit context for multiple occurrences", () => { + const content = "test test test"; + + expect(() => { + performFindAndReplace(content, "test", "exam", false, 1); + }).toThrow( + `edit at index 1: String "test" appears 3 times in the file. ${FOUND_MULTIPLE_FIND_STRINGS_ERROR}`, + ); + }); + }); + + describe("edge cases", () => { + it("should handle single character replacement", () => { + const content = "a b c"; + const result = performFindAndReplace(content, "b", "x"); + + expect(result).toBe("a x c"); + }); + + it("should handle very long strings", () => { + const longString = "a".repeat(10000); + const content = `start${longString}end`; + const result = performFindAndReplace(content, longString, "short"); + + expect(result).toBe("startshortend"); + }); + + it("should handle strings at beginning of content", () => { + const content = "start middle end"; + const result = performFindAndReplace(content, "start", "begin"); + + expect(result).toBe("begin middle end"); + }); + + it("should handle strings at end of content", () => { + const content = "start middle end"; + const result = performFindAndReplace(content, "end", "finish"); + + expect(result).toBe("start middle finish"); + }); + + it("should handle entire content replacement", () => { + const content = "replace everything"; + const result = performFindAndReplace( + content, + "replace everything", + "new content", + ); + + expect(result).toBe("new content"); + }); + }); +}); + +describe("validateSingleEdit", () => { + describe("valid inputs", () => { + it("should not throw for valid non-empty strings", () => { + expect(() => { + validateSingleEdit("old", "new"); + }).not.toThrow(); + }); + + it("should allow empty old_string for file creation", () => { + expect(() => { + validateSingleEdit("", "new content"); + }).not.toThrow(); + }); + + it("should allow empty new_string for deletion", () => { + expect(() => { + validateSingleEdit("delete me", ""); + }).not.toThrow(); + }); + + it("should allow multiline strings", () => { + expect(() => { + validateSingleEdit("line1\nline2", "newline1\nnewline2"); + }).not.toThrow(); + }); + + it("should allow special characters", () => { + expect(() => { + validateSingleEdit("/[a-z]+/g", "/[A-Z]+/g"); + }).not.toThrow(); + }); + }); + + describe("invalid inputs", () => { + it("should throw error when old_string is null", () => { + expect(() => { + validateSingleEdit(null as any, "new"); + }).toThrow("old_string is required"); + }); + + it("should throw error when old_string is undefined", () => { + expect(() => { + validateSingleEdit(undefined as any, "new"); + }).toThrow("old_string is required"); + }); + + it("should throw error when new_string is undefined", () => { + expect(() => { + validateSingleEdit("old", undefined as any); + }).toThrow("new_string is required"); + }); + + it("should throw error when old_string and new_string are identical", () => { + expect(() => { + validateSingleEdit("same", "same"); + }).toThrow("old_string and new_string must be different"); + }); + + it("should throw error when both are empty strings", () => { + expect(() => { + validateSingleEdit("", ""); + }).toThrow("old_string and new_string must be different"); + }); + }); + + describe("error messages with context", () => { + it("should include edit number in error messages when index provided", () => { + expect(() => { + validateSingleEdit(null as any, "new", 2); + }).toThrow("edit at index 2: old_string is required"); + }); + + it("should include edit number for new_string errors", () => { + expect(() => { + validateSingleEdit("old", undefined as any, 0); + }).toThrow("edit at index 0: new_string is required"); + }); + + it("should include edit number for identical strings error", () => { + expect(() => { + validateSingleEdit("same", "same", 4); + }).toThrow( + "edit at index 4: old_string and new_string must be different", + ); + }); + + it("should not include context when index not provided", () => { + expect(() => { + validateSingleEdit("same", "same"); + }).toThrow("old_string and new_string must be different"); + }); + }); +}); + +describe("validateCreatingForMultiEdit", () => { + describe("single edit scenarios", () => { + it("should return true for creating with single edit", () => { + const edits: EditOperation[] = [ + { old_string: "", new_string: "new file content" }, + ]; + + const isCreating = validateCreatingForMultiEdit(edits); + expect(isCreating).toBe(true); + }); + + it("should return false for editing with single edit", () => { + const edits: EditOperation[] = [{ old_string: "old", new_string: "new" }]; + + const isCreating = validateCreatingForMultiEdit(edits); + expect(isCreating).toBe(false); + }); + }); + + describe("multiple edit scenarios - editing existing file", () => { + it("should return false for multiple edits on existing file", () => { + const edits: EditOperation[] = [ + { old_string: "old1", new_string: "new1" }, + { old_string: "old2", new_string: "new2" }, + { old_string: "old3", new_string: "new3" }, + ]; + + const isCreating = validateCreatingForMultiEdit(edits); + expect(isCreating).toBe(false); + }); + + it("should allow multiple valid edits on existing file", () => { + const edits: EditOperation[] = [ + { old_string: "import old", new_string: "import new" }, + { old_string: "function old()", new_string: "function new()" }, + { old_string: "return old;", new_string: "return new;" }, + ]; + + expect(() => validateCreatingForMultiEdit(edits)).not.toThrow(); + expect(validateCreatingForMultiEdit(edits)).toBe(false); + }); + }); + + describe("error cases", () => { + it("should throw error when trying to make subsequent edits on file creation", () => { + const edits: EditOperation[] = [ + { old_string: "", new_string: "new file content" }, + { old_string: "old", new_string: "new" }, + ]; + + expect(() => { + validateCreatingForMultiEdit(edits); + }).toThrow("cannot make subsequent edits on a file you are creating"); + }); + + it("should throw error when empty old_string appears in non-first edit", () => { + const edits: EditOperation[] = [ + { old_string: "old1", new_string: "new1" }, + { old_string: "", new_string: "new2" }, + ]; + + expect(() => { + validateCreatingForMultiEdit(edits); + }).toThrow(`edit at index 1: ${EMPTY_NON_FIRST_EDIT_MESSAGE}`); + }); + + it("should throw error with correct edit number for empty old_string", () => { + const edits: EditOperation[] = [ + { old_string: "old1", new_string: "new1" }, + { old_string: "old2", new_string: "new2" }, + { old_string: "", new_string: "new3" }, + ]; + + expect(() => { + validateCreatingForMultiEdit(edits); + }).toThrow(`edit at index 2: ${EMPTY_NON_FIRST_EDIT_MESSAGE}`); + }); + + it("should throw error for multiple empty old_strings in subsequent edits", () => { + const edits: EditOperation[] = [ + { old_string: "old1", new_string: "new1" }, + { old_string: "", new_string: "new2" }, + { old_string: "", new_string: "new3" }, + ]; + + expect(() => { + validateCreatingForMultiEdit(edits); + }).toThrow(`edit at index 1: ${EMPTY_NON_FIRST_EDIT_MESSAGE}`); + }); + }); + + describe("edge cases", () => { + it("should handle empty edits array gracefully", () => { + const edits: EditOperation[] = []; + + // This should not throw, but would likely cause issues elsewhere + // The function doesn't explicitly handle empty arrays + expect(() => { + validateCreatingForMultiEdit(edits); + }).toThrow(); // Will throw because edits[0] is undefined + }); + + it("should handle complex edit operations", () => { + const edits: EditOperation[] = [ + { + old_string: "function oldFunction() {\n return 'old';\n}", + new_string: "function newFunction() {\n return 'new';\n}", + replace_all: false, + }, + { + old_string: "const OLD_CONSTANT", + new_string: "const NEW_CONSTANT", + replace_all: true, + }, + ]; + + expect(() => validateCreatingForMultiEdit(edits)).not.toThrow(); + expect(validateCreatingForMultiEdit(edits)).toBe(false); + }); + + it("should handle edits with replace_all flags", () => { + const edits: EditOperation[] = [ + { old_string: "old", new_string: "new", replace_all: true }, + { old_string: "test", new_string: "exam", replace_all: false }, + ]; + + expect(() => validateCreatingForMultiEdit(edits)).not.toThrow(); + expect(validateCreatingForMultiEdit(edits)).toBe(false); + }); + }); +}); diff --git a/gui/src/util/clientTools/findAndReplaceUtils.ts b/gui/src/util/clientTools/findAndReplaceUtils.ts new file mode 100644 index 000000000..6828e1695 --- /dev/null +++ b/gui/src/util/clientTools/findAndReplaceUtils.ts @@ -0,0 +1,97 @@ +import { EditOperation } from "core/tools/definitions/multiEdit"; + +export const FOUND_MULTIPLE_FIND_STRINGS_ERROR = + "Either provide a more specific string with surrounding context to make it unique, or use replace_all=true to replace all occurrences."; + +/** + * Performs a find and replace operation on text content with proper handling of special characters + */ +export function performFindAndReplace( + content: string, + oldString: string, + newString: string, + replaceAll: boolean = false, + index?: number, // For error messages +): string { + const errorContext = index !== undefined ? `edit at index ${index}: ` : ""; + // Check if old_string exists in current content + if (!content.includes(oldString)) { + throw new Error(`${errorContext}string not found in file: "${oldString}"`); + } + + if (replaceAll) { + // Replace all occurrences using replaceAll for proper handling of special characters + return content.replaceAll(oldString, newString); + } else { + // Handle empty oldString case (insertion) + if (oldString === "") { + return newString + content; + } + + // Count occurrences using indexOf for proper handling of special characters + let count = 0; + let searchIndex = content.indexOf(oldString); + while (searchIndex !== -1) { + count++; + searchIndex = content.indexOf(oldString, searchIndex + 1); + } + + if (count > 1) { + throw new Error( + `${errorContext}String "${oldString}" appears ${count} times in the file. ${FOUND_MULTIPLE_FIND_STRINGS_ERROR}`, + ); + } + + // Replace only the first occurrence + const firstIndex = content.indexOf(oldString); + return ( + content.substring(0, firstIndex) + + newString + + content.substring(firstIndex + oldString.length) + ); + } +} + +/** + * Validates a single edit operation + */ +export function validateSingleEdit( + oldString: string, + newString: string, + index?: number, +): void { + const context = index !== undefined ? `edit at index ${index}: ` : ""; + + if (!oldString && oldString !== "") { + throw new Error(`${context}old_string is required`); + } + if (newString === undefined) { + throw new Error(`${context}new_string is required`); + } + if (oldString === newString) { + throw new Error(`${context}old_string and new_string must be different`); + } +} + +export const EMPTY_NON_FIRST_EDIT_MESSAGE = + "contains empty old_string. Only the first edit can contain an empty old_string, which is only used for file creation."; +export function validateCreatingForMultiEdit(edits: EditOperation[]) { + const isCreating = edits[0].old_string === ""; + if (edits.length > 1) { + if (isCreating) { + throw new Error( + "cannot make subsequent edits on a file you are creating", + ); + } else { + for (let i = 1; i < edits.length; i++) { + if (edits[i].old_string === "") { + throw new Error( + `edit at index ${i}: ${EMPTY_NON_FIRST_EDIT_MESSAGE}`, + ); + } + } + } + } + + return isCreating; +} diff --git a/gui/src/util/clientTools/multiEditImpl.test.ts b/gui/src/util/clientTools/multiEditImpl.test.ts new file mode 100644 index 000000000..7c262cb82 --- /dev/null +++ b/gui/src/util/clientTools/multiEditImpl.test.ts @@ -0,0 +1,359 @@ +import * as ideUtils from "core/util/ideUtils"; +import { beforeEach, describe, expect, it, Mock, vi } from "vitest"; +import { applyForEditTool } from "../../redux/thunks/handleApplyStateUpdate"; +import { ClientToolExtras } from "./callClientTool"; +import { FOUND_MULTIPLE_FIND_STRINGS_ERROR } from "./findAndReplaceUtils"; +import { multiEditImpl } from "./multiEditImpl"; + +vi.mock("uuid", () => ({ + v4: vi.fn(() => "test-uuid"), +})); + +vi.mock("core/util/ideUtils", () => ({ + resolveRelativePathInDir: vi.fn(), + inferResolvedUriFromRelativePath: vi.fn(), +})); + +vi.mock("../../redux/thunks/handleApplyStateUpdate", () => ({ + applyForEditTool: vi.fn(), +})); + +describe("multiEditImpl", () => { + let mockExtras: ClientToolExtras; + let mockResolveRelativePathInDir: Mock; + let mockInferResolvedUriFromRelativePath: Mock; + let mockApplyForEditTool: Mock; + + beforeEach(() => { + vi.clearAllMocks(); + + mockResolveRelativePathInDir = vi.mocked(ideUtils.resolveRelativePathInDir); + mockInferResolvedUriFromRelativePath = vi.mocked( + ideUtils.inferResolvedUriFromRelativePath, + ); + mockApplyForEditTool = vi.mocked(applyForEditTool); + + mockExtras = { + getState: vi.fn(() => ({ + config: { config: { allowAnonymousTelemetry: false } }, + })) as any, + dispatch: vi.fn() as any, + ideMessenger: { + ide: { + readFile: vi.fn(), + getWorkspaceDirs: vi.fn().mockResolvedValue(["dir1"]), + }, + request: vi.fn(), + } as any, + }; + }); + + describe("argument validation", () => { + it("should throw if filepath is missing", async () => { + await expect( + multiEditImpl({ edits: [] }, "id", mockExtras), + ).rejects.toThrow("filepath is required"); + }); + + it("should throw if edits array is empty", async () => { + await expect( + multiEditImpl({ filepath: "test.txt", edits: [] }, "id", mockExtras), + ).rejects.toThrow( + "edits array is required and must contain at least one edit", + ); + }); + + it("should throw if edit has invalid old_string", async () => { + await expect( + multiEditImpl( + { + filepath: "test.txt", + edits: [{ old_string: null, new_string: "test" }], + }, + "id", + mockExtras, + ), + ).rejects.toThrow("edit at index 0: old_string is required"); + }); + + it("should throw if edit has undefined new_string", async () => { + await expect( + multiEditImpl( + { + filepath: "test.txt", + edits: [{ old_string: "test", new_string: undefined }], + }, + "id", + mockExtras, + ), + ).rejects.toThrow("edit at index 0: new_string is required"); + }); + + it("should throw if old_string equals new_string", async () => { + await expect( + multiEditImpl( + { + filepath: "test.txt", + edits: [{ old_string: "same", new_string: "same" }], + }, + "id", + mockExtras, + ), + ).rejects.toThrow( + "edit at index 0: old_string and new_string must be different", + ); + }); + }); + + describe("sequential edits", () => { + beforeEach(() => { + mockResolveRelativePathInDir.mockResolvedValue( + "file:///dir/test/file.txt", + ); + }); + + it("should apply single edit", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("Hello world"); + + await multiEditImpl( + { + filepath: "file.txt", + edits: [{ old_string: "Hello", new_string: "Hi" }], + }, + "id", + mockExtras, + ); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "id", + text: "Hi world", + filepath: "file:///dir/test/file.txt", + isSearchAndReplace: true, + }); + }); + + it("should apply multiple edits sequentially", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("Hello world\nGoodbye world"); + + await multiEditImpl( + { + filepath: "file.txt", + edits: [ + { old_string: "Hello", new_string: "Hi" }, + { old_string: "world", new_string: "universe", replace_all: true }, + ], + }, + "id", + mockExtras, + ); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "id", + text: "Hi universe\nGoodbye universe", + filepath: "file:///dir/test/file.txt", + isSearchAndReplace: true, + }); + }); + + it("should handle edits that depend on previous edits", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("const x = 1;"); + + await multiEditImpl( + { + filepath: "file.txt", + edits: [ + { old_string: "const x", new_string: "let x" }, + { old_string: "let x = 1;", new_string: "let x = 2;" }, + ], + }, + "id", + mockExtras, + ); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "id", + text: "let x = 2;", + filepath: "file:///dir/test/file.txt", + isSearchAndReplace: true, + }); + }); + + it("should throw if string not found in edit sequence", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("Hello world"); + + await expect( + multiEditImpl( + { + filepath: "file.txt", + edits: [ + { old_string: "Hello", new_string: "Hi" }, + { old_string: "not found", new_string: "test" }, + ], + }, + "id", + mockExtras, + ), + ).rejects.toThrow( + 'edit at index 1: string not found in file: "not found"', + ); + }); + + it("should throw if multiple occurrences without replace_all", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("test test test"); + + await expect( + multiEditImpl( + { + filepath: "file.txt", + edits: [{ old_string: "test", new_string: "replaced" }], + }, + "id", + mockExtras, + ), + ).rejects.toThrow( + `edit at index 0: String "test" appears 3 times in the file. ${FOUND_MULTIPLE_FIND_STRINGS_ERROR}`, + ); + }); + }); + + describe("file creation", () => { + it("should create new file with empty old_string", async () => { + mockResolveRelativePathInDir.mockResolvedValue(null); + mockInferResolvedUriFromRelativePath.mockResolvedValue( + "file:///infered/new.txt", + ); + + await multiEditImpl( + { + filepath: "new.txt", + edits: [{ old_string: "", new_string: "New content\nLine 2" }], + }, + "id", + mockExtras, + ); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "id", + text: "New content\nLine 2", + filepath: "file:///infered/new.txt", + isSearchAndReplace: true, + }); + }); + }); + + describe("replace_all functionality", () => { + beforeEach(() => { + mockResolveRelativePathInDir.mockResolvedValue( + "file:///dir/test/file.txt", + ); + }); + + it("should replace all occurrences when specified", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("foo bar foo baz foo"); + + await multiEditImpl( + { + filepath: "file.txt", + edits: [{ old_string: "foo", new_string: "qux", replace_all: true }], + }, + "id", + mockExtras, + ); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "id", + text: "qux bar qux baz qux", + filepath: "file:///dir/test/file.txt", + isSearchAndReplace: true, + }); + }); + + it("should handle mixed replace_all settings", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("x y x z x"); + + await multiEditImpl( + { + filepath: "file.txt", + edits: [ + { old_string: "x", new_string: "a", replace_all: true }, + { old_string: "y", new_string: "b" }, + ], + }, + "id", + mockExtras, + ); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "id", + text: "a b a z a", + filepath: "file:///dir/test/file.txt", + isSearchAndReplace: true, + }); + }); + }); + + describe("error handling", () => { + it("should wrap readFile errors", async () => { + mockResolveRelativePathInDir.mockResolvedValue( + "file:///dir/test/file.txt", + ); + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockRejectedValue(new Error("Read failed")); + + await expect( + multiEditImpl( + { + filepath: "file.txt", + edits: [{ old_string: "test", new_string: "new" }], + }, + "id", + mockExtras, + ), + ).rejects.toThrow("Read failed"); + }); + }); + + describe("return value", () => { + it("should return correct structure", async () => { + mockResolveRelativePathInDir.mockResolvedValue( + "file:///dir/test/file.txt", + ); + mockExtras.ideMessenger.ide.readFile = vi.fn().mockResolvedValue("test"); + + const result = await multiEditImpl( + { + filepath: "file.txt", + edits: [{ old_string: "test", new_string: "new" }], + }, + "id", + mockExtras, + ); + + expect(result).toEqual({ + respondImmediately: false, + output: undefined, + }); + }); + }); +}); diff --git a/gui/src/util/clientTools/multiEditImpl.ts b/gui/src/util/clientTools/multiEditImpl.ts new file mode 100644 index 000000000..8b12109e5 --- /dev/null +++ b/gui/src/util/clientTools/multiEditImpl.ts @@ -0,0 +1,99 @@ +import { + inferResolvedUriFromRelativePath, + resolveRelativePathInDir, +} from "core/util/ideUtils"; +import { v4 as uuid } from "uuid"; +import { applyForEditTool } from "../../redux/thunks/handleApplyStateUpdate"; +import { ClientToolImpl } from "./callClientTool"; +import { + performFindAndReplace, + validateCreatingForMultiEdit, + validateSingleEdit, +} from "./findAndReplaceUtils"; + +export const multiEditImpl: ClientToolImpl = async ( + args, + toolCallId, + extras, +) => { + const { filepath, edits, editingFileContents } = args; + + const streamId = uuid(); + + // Validate arguments + if (!filepath) { + throw new Error("filepath is required"); + } + if (!edits || !Array.isArray(edits) || edits.length === 0) { + throw new Error( + "edits array is required and must contain at least one edit", + ); + } + + // Validate each edit operation + for (let i = 0; i < edits.length; i++) { + const edit = edits[i]; + validateSingleEdit(edit.old_string, edit.new_string, i); + } + + // Check if this is creating a new file (first edit has empty old_string) + const isCreatingNewFile = validateCreatingForMultiEdit(edits); + const resolvedUri = await resolveRelativePathInDir( + filepath, + extras.ideMessenger.ide, + ); + + let newContent: string; + let fileUri: string; + if (isCreatingNewFile) { + if (resolvedUri) { + throw new Error( + `file ${filepath} already exists, cannot create new file`, + ); + } + newContent = edits[0].new_string; + const dirs = await extras.ideMessenger.ide.getWorkspaceDirs(); + fileUri = await inferResolvedUriFromRelativePath( + filepath, + extras.ideMessenger.ide, + dirs, + ); + } else { + if (!resolvedUri) { + throw new Error( + `file ${filepath} does not exist. If you are trying to edit it, correct the filepath. If you are trying to create it, you must pass old_string=""`, + ); + } + newContent = + editingFileContents ?? + (await extras.ideMessenger.ide.readFile(resolvedUri)); + fileUri = resolvedUri; + for (let i = 0; i < edits.length; i++) { + const { old_string, new_string, replace_all } = edits[i]; + newContent = performFindAndReplace( + newContent, + old_string, + new_string, + replace_all, + i, + ); + } + } + + // Apply the changes to the file + void extras.dispatch( + applyForEditTool({ + streamId, + toolCallId, + text: newContent, + filepath: fileUri, + isSearchAndReplace: true, + }), + ); + + // Return success - applyToFile will handle the completion state + return { + respondImmediately: false, // Let apply state handle completion + output: undefined, + }; +}; diff --git a/gui/src/util/clientTools/searchReplaceImpl.test.ts b/gui/src/util/clientTools/searchReplaceImpl.test.ts index a8eb74d77..69423a130 100644 --- a/gui/src/util/clientTools/searchReplaceImpl.test.ts +++ b/gui/src/util/clientTools/searchReplaceImpl.test.ts @@ -2,6 +2,7 @@ import { findSearchMatch } from "core/edit/searchAndReplace/findSearchMatch"; import { parseAllSearchReplaceBlocks } from "core/edit/searchAndReplace/parseSearchReplaceBlock"; import { resolveRelativePathInDir } from "core/util/ideUtils"; import { beforeEach, describe, expect, it, vi } from "vitest"; +import { applyForEditTool } from "../../redux/thunks/handleApplyStateUpdate"; import { ClientToolExtras } from "./callClientTool"; import { searchReplaceToolImpl } from "./searchReplaceImpl"; @@ -12,10 +13,14 @@ vi.mock("core/util/ideUtils"); vi.mock("uuid", () => ({ v4: vi.fn(() => "test-stream-id"), })); +vi.mock("../../redux/thunks/handleApplyStateUpdate", () => ({ + applyForEditTool: vi.fn(), +})); const mockFindSearchMatch = vi.mocked(findSearchMatch); const mockParseAllSearchReplaceBlocks = vi.mocked(parseAllSearchReplaceBlocks); const mockResolveRelativePathInDir = vi.mocked(resolveRelativePathInDir); +const mockApplyForEditTool = vi.mocked(applyForEditTool); describe("searchReplaceToolImpl", () => { let mockExtras: ClientToolExtras; @@ -144,8 +149,6 @@ describe("searchReplaceToolImpl", () => { endIndex, strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); - const result = await searchReplaceToolImpl( { filepath: "test.js", diffs: ["mock diff content"] }, "tool-call-id", @@ -159,7 +162,7 @@ describe("searchReplaceToolImpl", () => { }); // Verify applyToFile was called with correct parameters - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: expectedFinalContent, streamId: "test-stream-id", filepath: "/resolved/path/test.js", @@ -202,8 +205,6 @@ describe("searchReplaceToolImpl", () => { endIndex, strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); - const result = await searchReplaceToolImpl( { filepath: "test.js", diffs: ["mock diff content"] }, "tool-call-id", @@ -217,7 +218,7 @@ describe("searchReplaceToolImpl", () => { }); // Verify applyToFile was called with correct parameters - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: expectedFinalContent, streamId: "test-stream-id", filepath: "/resolved/path/test.js", @@ -283,8 +284,6 @@ const c = 3;`; strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); - const result = await searchReplaceToolImpl( { filepath: "test.js", diffs: ["mock diff content"] }, "tool-call-id", @@ -310,7 +309,7 @@ const c = 3;`; "const b = 2;", ); // Verify final applyToFile call - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: expectedFinalContent, streamId: "test-stream-id", filepath: "/resolved/path/test.js", @@ -379,8 +378,6 @@ const c = 3;`; strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); - const result = await searchReplaceToolImpl( { filepath: "test.js", diffs: ["first diff", "second diff"] }, "tool-call-id", @@ -405,7 +402,7 @@ const c = 3;`; ); // Verify final applyToFile call - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: expectedFinalContent, streamId: "test-stream-id", filepath: "/resolved/path/test.js", @@ -440,7 +437,6 @@ keep this too`; endIndex: 26, // End of "remove this line" strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); const result = await searchReplaceToolImpl( { filepath: "test.txt", diffs: ["mock diff content"] }, @@ -453,7 +449,7 @@ keep this too`; output: undefined, }); - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: expectedFinalContent, streamId: "test-stream-id", filepath: "/resolved/path/test.txt", @@ -480,15 +476,13 @@ keep this too`; endIndex: 11, strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); - await searchReplaceToolImpl( { filepath: "test.txt", diffs: ["mock diff content"] }, "tool-call-id", mockExtras, ); - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: expectedFinalContent, streamId: "test-stream-id", filepath: "/resolved/path/test.txt", @@ -581,32 +575,6 @@ keep this too`; ), ).rejects.toThrow("Failed to apply search and replace: File read error"); }); - - it("should handle applyToFile errors", async () => { - mockResolveRelativePathInDir.mockResolvedValue("/resolved/path/test.txt"); - mockParseAllSearchReplaceBlocks.mockReturnValue([ - { - isComplete: true, - searchContent: "content", - replaceContent: "replacement", - }, - ]); - mockIdeMessenger.ide.readFile.mockResolvedValue("content"); - mockFindSearchMatch.mockReturnValue({ - startIndex: 0, - endIndex: 7, - strategyName: "exactMatch", - }); - mockIdeMessenger.request.mockRejectedValue(new Error("Apply failed")); - - await expect( - searchReplaceToolImpl( - { filepath: "test.txt", diffs: ["mock diff content"] }, - "tool-call-id", - mockExtras, - ), - ).rejects.toThrow("Failed to apply search and replace: Apply failed"); - }); }); describe("edge cases", () => { @@ -628,15 +596,13 @@ keep this too`; endIndex: 0, strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); - await searchReplaceToolImpl( { filepath: "test.txt", diffs: ["mock diff content"] }, "tool-call-id", mockExtras, ); - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: expectedFinalContent, streamId: "test-stream-id", filepath: "/resolved/path/test.txt", @@ -663,7 +629,6 @@ keep this too`; endIndex: originalContent.length, strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); await searchReplaceToolImpl( { filepath: "test.txt", diffs: ["mock diff content"] }, @@ -671,7 +636,7 @@ keep this too`; mockExtras, ); - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: expectedFinalContent, streamId: "test-stream-id", filepath: "/resolved/path/test.txt", @@ -699,7 +664,6 @@ keep this too`; endIndex: 4, strategyName: "exactMatch", }); - mockIdeMessenger.request.mockResolvedValue({ status: "success" }); await searchReplaceToolImpl( { filepath: "relative/test.txt", diffs: ["mock diff content"] }, @@ -719,7 +683,7 @@ keep this too`; "/resolved/path/test.txt", ); expect(mockFindSearchMatch).toHaveBeenCalledWith(originalContent, "test"); - expect(mockIdeMessenger.request).toHaveBeenCalledWith("applyToFile", { + expect(mockApplyForEditTool).toHaveBeenCalledWith({ text: "updated content", streamId: "test-stream-id", filepath: "/resolved/path/test.txt", diff --git a/gui/src/util/clientTools/searchReplaceImpl.ts b/gui/src/util/clientTools/searchReplaceImpl.ts index 1fcf649e5..5b750b26f 100644 --- a/gui/src/util/clientTools/searchReplaceImpl.ts +++ b/gui/src/util/clientTools/searchReplaceImpl.ts @@ -3,6 +3,7 @@ import { parseAllSearchReplaceBlocks } from "core/edit/searchAndReplace/parseSea import { resolveRelativePathInDir } from "core/util/ideUtils"; import posthog from "posthog-js"; import { v4 as uuid } from "uuid"; +import { applyForEditTool } from "../../redux/thunks/handleApplyStateUpdate"; import { ClientToolImpl } from "./callClientTool"; export const searchReplaceToolImpl: ClientToolImpl = async ( @@ -10,7 +11,7 @@ export const searchReplaceToolImpl: ClientToolImpl = async ( toolCallId, extras, ) => { - const { filepath, diffs } = args; + const { filepath, diffs, editingFileContents } = args; const state = extras.getState(); const allowAnonymousTelemetry = state.config.config.allowAnonymousTelemetry; @@ -45,7 +46,8 @@ export const searchReplaceToolImpl: ClientToolImpl = async ( try { // Read the current file content const originalContent = - await extras.ideMessenger.ide.readFile(resolvedFilepath); + editingFileContents ?? + (await extras.ideMessenger.ide.readFile(resolvedFilepath)); let currentContent = originalContent; // Apply all replacements sequentially to build the final content @@ -81,14 +83,16 @@ export const searchReplaceToolImpl: ClientToolImpl = async ( // Single applyToFile call with all accumulated changes // This works becaues of our logic in `applyCodeBlock` that determines // that the full file rewrite here can be applied instantly, so the diff - // lines are just st - await extras.ideMessenger.request("applyToFile", { - streamId, - toolCallId, - text: currentContent, - filepath: resolvedFilepath, - isSearchAndReplace: true, - }); + // lines are generated with meyers diff and streamed instantaneously + void extras.dispatch( + applyForEditTool({ + streamId, + toolCallId, + text: currentContent, + filepath: resolvedFilepath, + isSearchAndReplace: true, + }), + ); // Return success - applyToFile will handle the completion state return { diff --git a/gui/src/util/clientTools/singleFindAndReplaceImpl.test.ts b/gui/src/util/clientTools/singleFindAndReplaceImpl.test.ts new file mode 100644 index 000000000..e6e8201b9 --- /dev/null +++ b/gui/src/util/clientTools/singleFindAndReplaceImpl.test.ts @@ -0,0 +1,334 @@ +import * as ideUtils from "core/util/ideUtils"; +import { beforeEach, describe, expect, it, Mock, vi } from "vitest"; +import { applyForEditTool } from "../../redux/thunks/handleApplyStateUpdate"; +import { ClientToolExtras } from "./callClientTool"; +import { singleFindAndReplaceImpl } from "./singleFindAndReplaceImpl"; +vi.mock("uuid", () => ({ + v4: vi.fn(() => "test-uuid"), +})); + +vi.mock("core/util/ideUtils", () => ({ + resolveRelativePathInDir: vi.fn(), +})); + +vi.mock("../../redux/thunks/handleApplyStateUpdate", () => ({ + applyForEditTool: vi.fn(), +})); + +describe("singleFindAndReplaceImpl", () => { + let mockExtras: ClientToolExtras; + let mockResolveRelativePathInDir: Mock; + let mockApplyForEditTool: Mock; + + beforeEach(() => { + vi.clearAllMocks(); + + mockResolveRelativePathInDir = vi.mocked(ideUtils.resolveRelativePathInDir); + mockApplyForEditTool = vi.mocked(applyForEditTool); + + mockExtras = { + getState: vi.fn(() => ({ + config: { + config: { + allowAnonymousTelemetry: false, + }, + }, + })) as any, + dispatch: vi.fn() as any, + ideMessenger: { + ide: { + readFile: vi.fn(), + }, + request: vi.fn(), + } as any, + }; + }); + + describe("argument validation", () => { + it("should throw error if filepath is missing", async () => { + const args = { + old_string: "test", + new_string: "replacement", + }; + + await expect( + singleFindAndReplaceImpl(args, "tool-call-id", mockExtras), + ).rejects.toThrow("filepath is required"); + }); + + it("should throw error if old_string is missing", async () => { + const args = { + filepath: "test.txt", + new_string: "replacement", + }; + + await expect( + singleFindAndReplaceImpl(args, "tool-call-id", mockExtras), + ).rejects.toThrow("old_string is required"); + }); + + it("should throw error if new_string is missing", async () => { + const args = { + filepath: "test.txt", + old_string: "test", + }; + + await expect( + singleFindAndReplaceImpl(args, "tool-call-id", mockExtras), + ).rejects.toThrow("new_string is required"); + }); + + it("should throw error if old_string and new_string are the same", async () => { + const args = { + filepath: "test.txt", + old_string: "same", + new_string: "same", + }; + + await expect( + singleFindAndReplaceImpl(args, "tool-call-id", mockExtras), + ).rejects.toThrow("old_string and new_string must be different"); + }); + }); + + describe("file resolution", () => { + it("should throw error if file does not exist", async () => { + mockResolveRelativePathInDir.mockResolvedValue(null); + + const args = { + filepath: "nonexistent.txt", + old_string: "test", + new_string: "replacement", + }; + + await expect( + singleFindAndReplaceImpl(args, "tool-call-id", mockExtras), + ).rejects.toThrow("File nonexistent.txt does not exist"); + }); + + it("should resolve relative file paths", async () => { + mockResolveRelativePathInDir.mockResolvedValue("/absolute/path/test.txt"); + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("test content"); + + const args = { + filepath: "test.txt", + old_string: "test", + new_string: "replacement", + }; + + await singleFindAndReplaceImpl(args, "tool-call-id", mockExtras); + + expect(mockResolveRelativePathInDir).toHaveBeenCalledWith( + "test.txt", + mockExtras.ideMessenger.ide, + ); + expect(mockExtras.ideMessenger.ide.readFile).toHaveBeenCalledWith( + "/absolute/path/test.txt", + ); + }); + }); + + describe("string replacement", () => { + beforeEach(() => { + mockResolveRelativePathInDir.mockResolvedValue("/test/file.txt"); + }); + + it("should throw error if old_string is not found in file", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("different content"); + + const args = { + filepath: "file.txt", + old_string: "not found", + new_string: "replacement", + }; + + await expect( + singleFindAndReplaceImpl(args, "tool-call-id", mockExtras), + ).rejects.toThrow(`string not found in file: "not found"`); + }); + + it("should replace single occurrence", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("Hello world\nThis is a test file\nGoodbye world"); + + const args = { + filepath: "file.txt", + old_string: "Hello world", + new_string: "Hi there", + }; + + await singleFindAndReplaceImpl(args, "tool-call-id", mockExtras); + + // Check that the dispatch was called with the applyForEditTool thunk + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "tool-call-id", + text: "Hi there\nThis is a test file\nGoodbye world", + filepath: "/test/file.txt", + isSearchAndReplace: true, + }); + }); + + it("should throw error if old_string appears multiple times and replace_all is false", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("Hello world\nThis is a test file\nGoodbye world"); + + const args = { + filepath: "file.txt", + old_string: "world", + new_string: "universe", + replace_all: false, + }; + + await expect( + singleFindAndReplaceImpl(args, "tool-call-id", mockExtras), + ).rejects.toThrow( + 'String "world" appears 2 times in the file. Either provide a more specific string with surrounding context to make it unique, or use replace_all=true to replace all occurrences.', + ); + }); + + it("should replace all occurrences when replace_all is true", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("Hello world\nThis is a test file\nGoodbye world"); + + const args = { + filepath: "file.txt", + old_string: "world", + new_string: "universe", + replace_all: true, + }; + + await singleFindAndReplaceImpl(args, "tool-call-id", mockExtras); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "tool-call-id", + text: "Hello universe\nThis is a test file\nGoodbye universe", + filepath: "/test/file.txt", + isSearchAndReplace: true, + }); + }); + + it("should handle empty new_string (deletion)", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("Hello world\nThis is a test file"); + + const args = { + filepath: "file.txt", + old_string: "Hello ", + new_string: "", + }; + + await singleFindAndReplaceImpl(args, "tool-call-id", mockExtras); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "tool-call-id", + text: "world\nThis is a test file", + filepath: "/test/file.txt", + isSearchAndReplace: true, + }); + }); + + it("should handle special characters in strings", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue( + 'const regex = /[a-z]+/g;\nconst text = "Hello $world"', + ); + + const args = { + filepath: "file.txt", + old_string: '"Hello $world"', + new_string: '"Hi $universe"', + }; + + await singleFindAndReplaceImpl(args, "tool-call-id", mockExtras); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "tool-call-id", + text: 'const regex = /[a-z]+/g;\nconst text = "Hi $universe"', + filepath: "/test/file.txt", + isSearchAndReplace: true, + }); + }); + + it("should preserve whitespace and indentation", async () => { + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue( + "function test() {\n const value = 'old';\n return value;\n}", + ); + + const args = { + filepath: "file.txt", + old_string: " const value = 'old';", + new_string: " const value = 'new';", + }; + + await singleFindAndReplaceImpl(args, "tool-call-id", mockExtras); + + expect(mockApplyForEditTool).toHaveBeenCalledWith({ + streamId: "test-uuid", + toolCallId: "tool-call-id", + text: "function test() {\n const value = 'new';\n return value;\n}", + filepath: "/test/file.txt", + isSearchAndReplace: true, + }); + }); + }); + + describe("return value", () => { + it("should return correct response structure", async () => { + mockResolveRelativePathInDir.mockResolvedValue("/test/file.txt"); + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockResolvedValue("test content"); + + const args = { + filepath: "file.txt", + old_string: "test", + new_string: "replacement", + }; + + const result = await singleFindAndReplaceImpl( + args, + "tool-call-id", + mockExtras, + ); + + expect(result).toEqual({ + respondImmediately: false, + output: undefined, + }); + }); + }); + + describe("error handling", () => { + it("should wrap and rethrow errors from readFile", async () => { + mockResolveRelativePathInDir.mockResolvedValue("/test/file.txt"); + mockExtras.ideMessenger.ide.readFile = vi + .fn() + .mockRejectedValue(new Error("Permission denied")); + + const args = { + filepath: "file.txt", + old_string: "test", + new_string: "replacement", + }; + + await expect( + singleFindAndReplaceImpl(args, "tool-call-id", mockExtras), + ).rejects.toThrow("Permission denied"); + }); + }); +}); diff --git a/gui/src/util/clientTools/singleFindAndReplaceImpl.ts b/gui/src/util/clientTools/singleFindAndReplaceImpl.ts new file mode 100644 index 000000000..92c3da178 --- /dev/null +++ b/gui/src/util/clientTools/singleFindAndReplaceImpl.ts @@ -0,0 +1,69 @@ +import { resolveRelativePathInDir } from "core/util/ideUtils"; +import { v4 as uuid } from "uuid"; +import { applyForEditTool } from "../../redux/thunks/handleApplyStateUpdate"; +import { ClientToolImpl } from "./callClientTool"; +import { + performFindAndReplace, + validateSingleEdit, +} from "./findAndReplaceUtils"; + +export const singleFindAndReplaceImpl: ClientToolImpl = async ( + args, + toolCallId, + extras, +) => { + const { + filepath, + old_string, + new_string, + replace_all = false, + editingFileContents, + } = args; + + const streamId = uuid(); + + // Validate arguments + if (!filepath) { + throw new Error("filepath is required"); + } + validateSingleEdit(old_string, new_string); + + // Resolve the file path + const resolvedFilepath = await resolveRelativePathInDir( + filepath, + extras.ideMessenger.ide, + ); + if (!resolvedFilepath) { + throw new Error(`File ${filepath} does not exist`); + } + + // Read the current file content + const originalContent = + editingFileContents ?? + (await extras.ideMessenger.ide.readFile(resolvedFilepath)); + + // Perform the find and replace operation + const newContent = performFindAndReplace( + originalContent, + old_string, + new_string, + replace_all, + ); + + // Apply the changes to the file + void extras.dispatch( + applyForEditTool({ + streamId, + toolCallId, + text: newContent, + filepath: resolvedFilepath, + isSearchAndReplace: true, + }), + ); + + // Return success - applyToFile will handle the completion state + return { + respondImmediately: false, // Let apply state handle completion + output: undefined, + }; +}; diff --git a/gui/src/util/editOutcomeLogger.test.ts b/gui/src/util/editOutcomeLogger.test.ts index 92c2263eb..f34f6572c 100644 --- a/gui/src/util/editOutcomeLogger.test.ts +++ b/gui/src/util/editOutcomeLogger.test.ts @@ -1,5 +1,10 @@ -import { ApplyState, ToolCallState } from "core"; +import { + ApplyState, + BrowserSerializedContinueConfig, + ToolCallState, +} from "core"; import { describe, expect, it, vi } from "vitest"; +import { EMPTY_CONFIG } from "../redux/slices/configSlice"; import { assembleEditOutcomeData } from "./editOutcomeLogger"; vi.mock("../redux/store", () => ({ @@ -17,6 +22,19 @@ vi.mock("../redux/store", () => ({ }, })); +const EMPTY_CONFIG_WITH_TEST_MODEL_SELECTED: BrowserSerializedContinueConfig = { + ...EMPTY_CONFIG, + selectedModelByRole: { + ...EMPTY_CONFIG.selectedModelByRole, + chat: { + provider: "test", + model: "test-model", + title: "Test model", + underlyingProviderName: "provider", + }, + }, +}; + describe("assembleEditOutcomeData", () => { it("should assemble complete edit outcome data correctly", () => { const toolCallState: ToolCallState = { @@ -37,7 +55,13 @@ describe("assembleEditOutcomeData", () => { fileContent: "const new = 2;\nconst another = 3;", }; - const result = assembleEditOutcomeData(toolCallState, applyState, true); + const result = assembleEditOutcomeData( + [], + EMPTY_CONFIG_WITH_TEST_MODEL_SELECTED, + toolCallState, + applyState, + true, + ); console.log(result); expect(result).toMatchObject({ @@ -71,7 +95,13 @@ describe("assembleEditOutcomeData", () => { fileContent: "", }; - const result = assembleEditOutcomeData(toolCallState, applyState, false); + const result = assembleEditOutcomeData( + [], + EMPTY_CONFIG_WITH_TEST_MODEL_SELECTED, + toolCallState, + applyState, + false, + ); expect(result.previousCodeLines).toBe(0); expect(result.newCodeLines).toBe(0); diff --git a/gui/src/util/editOutcomeLogger.ts b/gui/src/util/editOutcomeLogger.ts index 124f11ed3..e7e51bb49 100644 --- a/gui/src/util/editOutcomeLogger.ts +++ b/gui/src/util/editOutcomeLogger.ts @@ -1,18 +1,23 @@ -import { ApplyState, ToolCallState } from "core"; +import { + ApplyState, + BrowserSerializedContinueConfig, + ToolCallState, +} from "core"; import { IIdeMessenger } from "../context/IdeMessenger"; -import { store } from "../redux/store"; +import { ChatHistoryItemWithMessageId } from "../redux/slices/sessionSlice"; /** * Extract model information from tool call state */ -function extractModelInfo(toolCallState: ToolCallState): { +function extractModelInfo( + history: ChatHistoryItemWithMessageId[], + config: BrowserSerializedContinueConfig, + toolCallState: ToolCallState, +): { modelProvider: string; modelName: string; modelTitle: string; } { - // Get the conversation history to find the model info - const history = store.getState().session.history; - // Find the assistant message that contains this tool call const assistantMessage = history.find( (item) => @@ -35,7 +40,6 @@ function extractModelInfo(toolCallState: ToolCallState): { } // Fallback to config if not found in message - const config = store.getState().config.config; const chatModel = config?.selectedModelByRole?.chat; return { @@ -48,12 +52,13 @@ function extractModelInfo(toolCallState: ToolCallState): { /** * Extract prompt and completion from tool call state */ -function extractPromptAndCompletion(toolCallState: ToolCallState): { +function extractPromptAndCompletion( + history: ChatHistoryItemWithMessageId[], + toolCallState: ToolCallState, +): { prompt: string; completion: string; } { - const history = store.getState().session.history; - // Find the assistant message with this tool call const assistantMessageIndex = history.findIndex( (item) => @@ -144,12 +149,17 @@ function extractCodeChanges(applyState: ApplyState): { * Assemble complete edit outcome data from tool call and apply state */ export function assembleEditOutcomeData( + history: ChatHistoryItemWithMessageId[], + config: BrowserSerializedContinueConfig, toolCallState: ToolCallState, applyState: ApplyState, accepted: boolean, ) { - const modelInfo = extractModelInfo(toolCallState); - const promptAndCompletion = extractPromptAndCompletion(toolCallState); + const modelInfo = extractModelInfo(history, config, toolCallState); + const promptAndCompletion = extractPromptAndCompletion( + history, + toolCallState, + ); const codeChanges = extractCodeChanges(applyState); return { @@ -174,6 +184,8 @@ export function assembleEditOutcomeData( * Log Agent Mode edit outcome to editOutcome.jsonl */ export async function logAgentModeEditOutcome( + history: ChatHistoryItemWithMessageId[], + config: BrowserSerializedContinueConfig, toolCallState: ToolCallState, applyState: ApplyState, accepted: boolean, @@ -182,6 +194,8 @@ export async function logAgentModeEditOutcome( // Use the original file content stored in applyState, captured before edits were applied const editOutcomeData = assembleEditOutcomeData( + history, + config, toolCallState, applyState, accepted, diff --git a/package-lock.json b/package-lock.json index b4289d422..6981243e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "continue", + "name": "wt-mcp-flag", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/packages/config-yaml/src/load/merge.ts b/packages/config-yaml/src/load/merge.ts index eeea12ab8..568650b93 100644 --- a/packages/config-yaml/src/load/merge.ts +++ b/packages/config-yaml/src/load/merge.ts @@ -13,6 +13,7 @@ export function mergePackages( rules: [...(current.rules ?? []), ...(incoming.rules ?? [])], prompts: [...(current.prompts ?? []), ...(incoming.prompts ?? [])], docs: [...(current.docs ?? []), ...(incoming.docs ?? [])], + env: { ...current.env, ...incoming.env }, }; } @@ -29,5 +30,6 @@ export function mergeUnrolledAssistants( data: [...(current.data ?? []), ...(incoming.data ?? [])], mcpServers: [...(current.mcpServers ?? []), ...(incoming.mcpServers ?? [])], prompts: [...(current.prompts ?? []), ...(incoming.prompts ?? [])], + env: { ...current.env, ...incoming.env }, }; } diff --git a/packages/config-yaml/src/load/unroll.ts b/packages/config-yaml/src/load/unroll.ts index c2e524c4c..4de10b63b 100644 --- a/packages/config-yaml/src/load/unroll.ts +++ b/packages/config-yaml/src/load/unroll.ts @@ -321,7 +321,7 @@ export async function unrollBlocks( const sections: (keyof Omit< ConfigYaml, - "name" | "version" | "rules" | "schema" | "metadata" + "name" | "version" | "rules" | "schema" | "metadata" | "env" >)[] = ["models", "context", "data", "mcpServers", "prompts", "docs"]; // Process all sections in parallel diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index e15a5655d..8e1c73224 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -105,11 +105,17 @@ export const commonMetadataSchema = z.object({ iconUrl: z.string().optional(), }); +const envRecord = z.record( + z.string(), + z.union([z.string(), z.number(), z.boolean()]), +); + export const baseConfigYamlSchema = z.object({ name: z.string(), version: z.string(), schema: z.string().optional(), metadata: z.record(z.string()).and(commonMetadataSchema.partial()).optional(), + env: envRecord.optional(), }); const modelsUsesSchema = z @@ -254,6 +260,7 @@ export const configSchema = z.object({ proxy: z.string().optional(), api_base: z.string().optional(), api_key: z.string().optional(), + env: envRecord.optional(), }); export type Config = z.infer; diff --git a/packages/continue-sdk/package-lock.json b/packages/continue-sdk/package-lock.json index 7bae25f24..651df69e9 100644 --- a/packages/continue-sdk/package-lock.json +++ b/packages/continue-sdk/package-lock.json @@ -1124,13 +1124,15 @@ } }, "node_modules/form-data": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", - "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", + "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": { diff --git a/packages/continue-sdk/typescript/package-lock.json b/packages/continue-sdk/typescript/package-lock.json index 0e5fb590f..c50af4a50 100644 --- a/packages/continue-sdk/typescript/package-lock.json +++ b/packages/continue-sdk/typescript/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/sdk", - "version": "0.0.12", + "version": "0.0.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/sdk", - "version": "0.0.12", + "version": "0.0.13", "license": "Apache-2.0", "dependencies": { "openai": "^4.96.2" @@ -1963,14 +1963,15 @@ } }, "node_modules/form-data": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", - "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", + "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": { diff --git a/packages/openai-adapters/package-lock.json b/packages/openai-adapters/package-lock.json index 048286095..806a98f2a 100644 --- a/packages/openai-adapters/package-lock.json +++ b/packages/openai-adapters/package-lock.json @@ -32,6 +32,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", @@ -1369,7 +1370,7 @@ "version": "1.0.14", "license": "Apache-2.0", "dependencies": { - "zod": "^3.24.2" + "zod": "^3.23.8" } }, "node_modules/@continuedev/config-yaml": { @@ -4021,13 +4022,13 @@ "dev": true }, "node_modules/@types/node": { - "version": "24.1.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz", - "integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==", + "version": "24.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.0.tgz", + "integrity": "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~7.8.0" + "undici-types": "~7.10.0" } }, "node_modules/@types/normalize-package-data": { @@ -12527,6 +12528,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -12549,9 +12551,9 @@ } }, "node_modules/undici-types": { - "version": "7.8.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz", - "integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz", + "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==", "dev": true, "license": "MIT" }, diff --git a/packages/openai-adapters/package.json b/packages/openai-adapters/package.json index 8e9aac7ef..5cde75e96 100644 --- a/packages/openai-adapters/package.json +++ b/packages/openai-adapters/package.json @@ -35,6 +35,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",