diff --git a/.changeset/bright-apples-protect.md b/.changeset/bright-apples-protect.md new file mode 100644 index 00000000..55111778 --- /dev/null +++ b/.changeset/bright-apples-protect.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Detect Ctrl+C termination of terminal activity on long running commands diff --git a/.changeset/eight-ears-flash.md b/.changeset/eight-ears-flash.md new file mode 100644 index 00000000..efea297d --- /dev/null +++ b/.changeset/eight-ears-flash.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +Add a delete button to the Cline Rules modal to delete rule files diff --git a/.changeset/fast-readers-care.md b/.changeset/fast-readers-care.md new file mode 100644 index 00000000..5fecc2c3 --- /dev/null +++ b/.changeset/fast-readers-care.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +Added chunking to terminal outputs diff --git a/.changeset/late-mice-double.md b/.changeset/late-mice-double.md new file mode 100644 index 00000000..794d7ad5 --- /dev/null +++ b/.changeset/late-mice-double.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +gRPC over vscode message bus to make messaging better diff --git a/.changeset/nasty-gifts-look.md b/.changeset/nasty-gifts-look.md new file mode 100644 index 00000000..bec99690 --- /dev/null +++ b/.changeset/nasty-gifts-look.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Allow user to modify a previous message to continue chat diff --git a/.changeset/nasty-months-wave.md b/.changeset/nasty-months-wave.md new file mode 100644 index 00000000..4afac9c0 --- /dev/null +++ b/.changeset/nasty-months-wave.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Add command to focus chat input diff --git a/.changeset/pretty-eels-breathe.md b/.changeset/pretty-eels-breathe.md new file mode 100644 index 00000000..5059a11e --- /dev/null +++ b/.changeset/pretty-eels-breathe.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +fix vertexai token count diff --git a/.changeset/rare-starfishes-design.md b/.changeset/rare-starfishes-design.md new file mode 100644 index 00000000..8b595caa --- /dev/null +++ b/.changeset/rare-starfishes-design.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Allow user to send context with an option selection diff --git a/.changeset/rich-pens-buy.md b/.changeset/rich-pens-buy.md new file mode 100644 index 00000000..e772cdb7 --- /dev/null +++ b/.changeset/rich-pens-buy.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Safer check for xAI reasoning content diff --git a/.changeset/six-birds-move.md b/.changeset/six-birds-move.md new file mode 100644 index 00000000..055f352d --- /dev/null +++ b/.changeset/six-birds-move.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +Add an edit button to the Cline Rules toggle modal to open rule files diff --git a/.changeset/ten-bananas-begin.md b/.changeset/ten-bananas-begin.md new file mode 100644 index 00000000..764b7ee7 --- /dev/null +++ b/.changeset/ten-bananas-begin.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Readme update diff --git a/.changeset/twelve-eyes-teach.md b/.changeset/twelve-eyes-teach.md new file mode 100644 index 00000000..9478e7bf --- /dev/null +++ b/.changeset/twelve-eyes-teach.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Add OpenAI o3 & 4o-mini diff --git a/.changeset/twelve-meals-applaud.md b/.changeset/twelve-meals-applaud.md new file mode 100644 index 00000000..85482ce9 --- /dev/null +++ b/.changeset/twelve-meals-applaud.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +Add modal UI for toggling Cline Rules diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 00000000..e3bbac8b --- /dev/null +++ b/.codespellrc @@ -0,0 +1,6 @@ +[codespell] +# Ref: https://github.com/codespell-project/codespell#using-a-config-file +skip = .git*,*.svg,package-lock.json,*.css,.codespellrc,locales +check-hidden = true +ignore-regex = (\b(optIn|isTaller)\b|https://\S+) +# ignore-words-list = diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 00000000..4156d4e5 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,25 @@ +# Codespell configuration is within .codespellrc +--- +name: Codespell + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Annotate locations with typos + uses: codespell-project/codespell-problem-matcher@v1 + - name: Codespell + uses: codespell-project/actions-codespell@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index fd54a744..c7699af9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [3.12.3] + +- Add copy button to MermaidBlock component (Thanks @cacosub7!) +- Add the ability to fetch from global cline rules files +- Add icon to indicate when a file outside of the users workspace is edited + +## [3.12.2] + +- Add gpt-4.1 + ## [3.12.1] - Use visual checkpoint indicator to make it clear when checkpoints are created @@ -48,7 +58,7 @@ - Add recommended models for Cline provider - Add ability to detect when user edits files manually so Cline knows to re-read, leading to reduced diff edit errors - Add improvements to file mention searching for faster searching -- Add scoring logic to file mentions to sort and exlcude results based on relevance +- Add scoring logic to file mentions to sort and exclude results based on relevance - Add Support for Bytedance Doubao (Thanks Tunixer!) - Fix to prevent duplicate BOM (Thanks bamps53!) @@ -526,7 +536,7 @@ - Adds "Always allow read-only operations" setting to let Claude read files and view directories without needing approval (off by default) - Implement sliding window context management to keep tasks going past 200k tokens - Adds Google Cloud Vertex AI support and updates Claude 3.5 Sonnet max output to 8192 tokens for all providers. -- Improves system prompt to gaurd against lazy edits (less "//rest of code here") +- Improves system prompt to guard against lazy edits (less "//rest of code here") ## [1.3.0] diff --git a/evals/.gitignore b/evals/.gitignore new file mode 100644 index 00000000..4a67796a --- /dev/null +++ b/evals/.gitignore @@ -0,0 +1,3 @@ +repositories + +results/evals.db \ No newline at end of file diff --git a/evals/README.md b/evals/README.md new file mode 100644 index 00000000..418f05fb --- /dev/null +++ b/evals/README.md @@ -0,0 +1,162 @@ +# Cline Evaluation System + +This directory contains the evaluation system for benchmarking Cline against various coding evaluation frameworks. + +## Overview + +The Cline Evaluation System allows you to: + +1. Run Cline against standardized coding benchmarks +2. Collect comprehensive metrics on performance +3. Generate detailed reports on evaluation results +4. Compare performance across different models and benchmarks + +## Architecture + +The evaluation system consists of two main components: + +1. **Test Server**: Enhanced HTTP server in `src/services/test/TestServer.ts` that provides detailed task results +2. **CLI Tool**: Command-line interface in `evals/cli/` for orchestrating evaluations + +## Directory Structure + +``` +cline-repo/ +├── src/ +│ ├── services/ +│ │ ├── test/ +│ │ │ ├── TestServer.ts # Enhanced HTTP server for task execution +│ │ │ ├── GitHelper.ts # Git utilities for file tracking +│ │ │ └── ... +│ │ └── ... +│ └── ... +├── evals/ # Main directory for evaluation system +│ ├── cli/ # CLI tool for orchestrating evaluations +│ │ ├── src/ +│ │ │ ├── index.ts # CLI entry point +│ │ │ ├── commands/ # CLI commands (setup, run, report) +│ │ │ ├── adapters/ # Benchmark adapters +│ │ │ ├── db/ # Database management +│ │ │ └── utils/ # Utility functions +│ │ ├── package.json +│ │ └── tsconfig.json +│ ├── repositories/ # Cloned benchmark repositories +│ │ ├── exercism/ # Modified Exercism (from pashpashpash/evals) +│ │ ├── swe-bench/ # SWE-Bench repository +│ │ ├── swelancer/ # SWELancer repository +│ │ └── multi-swe/ # Multi-SWE-Bench repository +│ ├── results/ # Evaluation results storage +│ │ ├── runs/ # Individual run results +│ │ └── reports/ # Generated reports +│ └── README.md # This file +└── ... +``` + +## Getting Started + +### Prerequisites + +- Node.js 16+ +- VSCode with Cline extension installed +- Git + +### Installation + +1. Build the CLI tool: + +```bash +cd evals/cli +npm install +npm run build +``` + +### Usage + +#### Setting Up Benchmarks + +```bash +cd evals/cli +node dist/index.js setup +``` + +This will clone and set up all benchmark repositories. You can specify specific benchmarks: + +```bash +node dist/index.js setup --benchmarks exercism +``` + +#### Running Evaluations + +```bash +node dist/index.js run --model claude-3-opus-20240229 --benchmark exercism +``` + +Options: +- `--model`: The model to evaluate (default: claude-3-opus-20240229) +- `--benchmark`: Specific benchmark to run (default: all) +- `--count`: Number of tasks to run (default: all) + +#### Generating Reports + +```bash +node dist/index.js report +``` + +Options: +- `--format`: Report format (json, markdown) (default: markdown) +- `--output`: Output path for the report + +## Benchmarks + +### Exercism + +Modified Exercism exercises from the [pashpashpash/evals](https://github.com/pashpashpash/evals) repository. These are small, focused programming exercises in various languages. + +### SWE-Bench (Coming Soon) + +Real-world software engineering tasks from the [SWE-bench](https://github.com/SWE-bench/SWE-bench) repository. + +### SWELancer (Coming Soon) + +Freelance-style programming tasks from the SWELancer benchmark. + +### Multi-SWE-Bench (Coming Soon) + +Multi-file software engineering tasks from the Multi-SWE-Bench repository. + +## Metrics + +The evaluation system collects the following metrics: + +- **Token Usage**: Input and output tokens +- **Cost**: Estimated cost of API calls +- **Duration**: Time taken to complete tasks +- **Tool Usage**: Number of tool calls and failures +- **Success Rate**: Percentage of tasks completed successfully +- **Functional Correctness**: Percentage of tests passed + +## Reports + +Reports are generated in Markdown or JSON format and include: + +- Overall summary +- Benchmark-specific results +- Model-specific results +- Tool usage statistics +- Charts and visualizations + +## Development + +### Adding a New Benchmark + +1. Create a new adapter in `evals/cli/src/adapters/` +2. Implement the `BenchmarkAdapter` interface +3. Register the adapter in `evals/cli/src/adapters/index.ts` + +### Extending Metrics + +To add new metrics: + +1. Update the database schema in `evals/cli/src/db/schema.ts` +2. Add collection logic in `evals/cli/src/utils/results.ts` +3. Update report generation in `evals/cli/src/commands/report.ts` diff --git a/evals/cli/package-lock.json b/evals/cli/package-lock.json new file mode 100644 index 00000000..c4f70759 --- /dev/null +++ b/evals/cli/package-lock.json @@ -0,0 +1,2455 @@ +{ + "name": "cline-evaluation-cli", + "version": "0.1.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "cline-evaluation-cli", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "better-sqlite3": "^8.0.0", + "chalk": "^4.1.2", + "commander": "^9.4.1", + "execa": "^5.1.1", + "node-fetch": "^2.7.0", + "ora": "^5.4.1", + "sqlite": "^4.1.2", + "uuid": "^9.0.0", + "yargs": "^17.6.2" + }, + "devDependencies": { + "@types/better-sqlite3": "^7.6.3", + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.12", + "@types/uuid": "^9.0.0", + "@types/yargs": "^17.0.19", + "ts-node": "^10.9.1", + "typescript": "^4.9.4" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "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==", + "dev": true + }, + "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, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "node_modules/@types/better-sqlite3": { + "version": "7.6.13", + "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.13.tgz", + "integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "18.19.86", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.86.tgz", + "integrity": "sha512-fifKayi175wLyKyc5qUfyENhQ1dCNI1UNjp653d8kuYcPQN5JhX3dGuP/XmvPTg/xRBn1VTLpbmi+H/Mr7tLfQ==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "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==", + "dev": true, + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "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==", + "dev": true + }, + "node_modules/@types/yargs": { + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", + "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true + }, + "node_modules/acorn": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", + "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "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==", + "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==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/better-sqlite3": { + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.7.0.tgz", + "integrity": "sha512-99jZU4le+f3G6aIl6PmmV0cxUIWqKieHxsiF7G34CVFiE+/UabpYqkU0NJIkY/96mQKikHeBjtR27vFfs5JpEw==", + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.5.0", + "prebuild-install": "^7.1.1" + } + }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "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, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "node_modules/cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dependencies": { + "restore-cursor": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "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==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "engines": { + "node": ">=0.8" + } + }, + "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==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "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==" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "engines": { + "node": "^12.20.0 || >=14" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "dependencies": { + "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/detect-libc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "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, + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "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==" + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, + "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==", + "dev": true, + "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==", + "dev": true, + "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==", + "dev": true, + "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==", + "dev": true, + "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/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, + "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==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "node_modules/function-bind": { + "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" + } + }, + "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==", + "engines": { + "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==", + "dev": true, + "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-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, + "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", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" + }, + "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, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "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==", + "dev": true, + "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==", + "dev": true, + "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" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, + "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==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "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, + "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", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + }, + "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, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "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, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, + "node_modules/napi-build-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz", + "integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==" + }, + "node_modules/node-abi": { + "version": "3.74.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.74.0.tgz", + "integrity": "sha512-c5XK0MjkGBrQPGYG24GBADZud0NCbznxNx0ZkS+ebUTrmV1qTDxPxSL8zEAPURXSbLRWVexxmP4986BziahL5w==", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "dependencies": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/prebuild-install": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", + "integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==", + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^2.0.0", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/pump": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", + "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/require-directory": { + "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==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "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==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "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==" + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "node_modules/sqlite": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sqlite/-/sqlite-4.2.1.tgz", + "integrity": "sha512-Tll0Ndvnwkuv5Hn6WIbh26rZiYQORuH1t5m/or9LUpSmDmmyFG89G9fKrSeugMPxwmEIXoVxqTun4LbizTs4uw==" + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "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==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "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==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar-fs": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.2.tgz", + "integrity": "sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "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 + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "node_modules/wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "dependencies": { + "defaults": "^1.0.3" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "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==", + "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/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "engines": { + "node": ">=12" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + } + }, + "dependencies": { + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true + }, + "@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==", + "dev": true + }, + "@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, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "@types/better-sqlite3": { + "version": "7.6.13", + "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.13.tgz", + "integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "18.19.86", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.86.tgz", + "integrity": "sha512-fifKayi175wLyKyc5qUfyENhQ1dCNI1UNjp653d8kuYcPQN5JhX3dGuP/XmvPTg/xRBn1VTLpbmi+H/Mr7tLfQ==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } + }, + "@types/node-fetch": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.12.tgz", + "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==", + "dev": true, + "requires": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "@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==", + "dev": true + }, + "@types/yargs": { + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", + "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true + }, + "acorn": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", + "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "dev": true + }, + "acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "requires": { + "acorn": "^8.11.0" + } + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, + "better-sqlite3": { + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.7.0.tgz", + "integrity": "sha512-99jZU4le+f3G6aIl6PmmV0cxUIWqKieHxsiF7G34CVFiE+/UabpYqkU0NJIkY/96mQKikHeBjtR27vFfs5JpEw==", + "requires": { + "bindings": "^1.5.0", + "prebuild-install": "^7.1.1" + } + }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "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, + "requires": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "requires": { + "restore-cursor": "^3.1.0" + } + }, + "cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==" + }, + "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==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + } + }, + "clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==" + }, + "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==", + "requires": { + "color-name": "~1.1.4" + } + }, + "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==" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==" + }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, + "defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "requires": { + "clone": "^1.0.2" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true + }, + "detect-libc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==" + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "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, + "requires": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + } + }, + "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==" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, + "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==", + "dev": true + }, + "es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true + }, + "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==", + "dev": true, + "requires": { + "es-errors": "^1.3.0" + } + }, + "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==", + "dev": true, + "requires": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + } + }, + "escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==" + }, + "execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + } + }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" + }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, + "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==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "mime-types": "^2.1.12" + } + }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true + }, + "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==" + }, + "get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, + "requires": { + "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" + } + }, + "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, + "requires": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + } + }, + "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==" + }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" + }, + "gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true + }, + "has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.3" + } + }, + "hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "requires": { + "function-bind": "^1.1.2" + } + }, + "human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, + "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==" + }, + "is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==" + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" + }, + "is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + } + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "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 + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + }, + "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 + }, + "mime-types": { + "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, + "requires": { + "mime-db": "1.52.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + }, + "minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" + }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, + "napi-build-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz", + "integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==" + }, + "node-abi": { + "version": "3.74.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.74.0.tgz", + "integrity": "sha512-c5XK0MjkGBrQPGYG24GBADZud0NCbznxNx0ZkS+ebUTrmV1qTDxPxSL8zEAPURXSbLRWVexxmP4986BziahL5w==", + "requires": { + "semver": "^7.3.5" + } + }, + "node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "requires": { + "whatwg-url": "^5.0.0" + } + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "requires": { + "path-key": "^3.0.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "requires": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "prebuild-install": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", + "integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==", + "requires": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^2.0.0", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + } + }, + "pump": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", + "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + } + }, + "readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "require-directory": { + "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==" + }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==" + }, + "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==", + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "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==" + }, + "simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" + }, + "simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "requires": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "sqlite": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sqlite/-/sqlite-4.2.1.tgz", + "integrity": "sha512-Tll0Ndvnwkuv5Hn6WIbh26rZiYQORuH1t5m/or9LUpSmDmmyFG89G9fKrSeugMPxwmEIXoVxqTun4LbizTs4uw==" + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + }, + "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==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==" + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + }, + "tar-fs": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.2.tgz", + "integrity": "sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==", + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true + }, + "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 + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" + }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "requires": { + "defaults": "^1.0.3" + } + }, + "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==" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + }, + "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==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" + }, + "yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "requires": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + } + }, + "yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==" + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + } + } +} diff --git a/evals/cli/package.json b/evals/cli/package.json new file mode 100644 index 00000000..14f21d40 --- /dev/null +++ b/evals/cli/package.json @@ -0,0 +1,39 @@ +{ + "name": "cline-evaluation-cli", + "version": "0.1.0", + "description": "CLI tool for orchestrating Cline evaluations across multiple benchmarks", + "main": "dist/index.js", + "scripts": { + "build": "tsc", + "start": "node dist/index.js", + "dev": "ts-node src/index.ts", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "cline", + "evaluation", + "benchmark" + ], + "author": "", + "license": "MIT", + "dependencies": { + "better-sqlite3": "^8.0.0", + "chalk": "^4.1.2", + "commander": "^9.4.1", + "execa": "^5.1.1", + "node-fetch": "^2.7.0", + "ora": "^5.4.1", + "sqlite": "^4.1.2", + "uuid": "^9.0.0", + "yargs": "^17.6.2" + }, + "devDependencies": { + "@types/better-sqlite3": "^7.6.3", + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.12", + "@types/uuid": "^9.0.0", + "@types/yargs": "^17.0.19", + "ts-node": "^10.9.1", + "typescript": "^4.9.4" + } +} diff --git a/evals/cli/src/adapters/exercism.ts b/evals/cli/src/adapters/exercism.ts new file mode 100644 index 00000000..4016ffef --- /dev/null +++ b/evals/cli/src/adapters/exercism.ts @@ -0,0 +1,190 @@ +import * as path from "path" +import * as fs from "fs" +import execa from "execa" +import { BenchmarkAdapter, Task, VerificationResult } from "./types" + +const EVALS_DIR = path.resolve(__dirname, "../../../") + +/** + * Adapter for the modified Exercism benchmark + */ +export class ExercismAdapter implements BenchmarkAdapter { + name = "exercism" + + /** + * Set up the Exercism benchmark repository + */ + async setup(): Promise { + // Clone repository if needed + const exercismDir = path.join(EVALS_DIR, "repositories", "exercism") + + if (!fs.existsSync(exercismDir)) { + console.log(`Cloning Exercism repository to ${exercismDir}...`) + await execa("git", ["clone", "https://github.com/pashpashpash/evals.git", exercismDir]) + console.log("Exercism repository cloned successfully") + } else { + console.log(`Exercism repository already exists at ${exercismDir}`) + + // Pull latest changes + console.log("Pulling latest changes...") + await execa("git", ["pull"], { cwd: exercismDir }) + console.log("Repository updated successfully") + } + } + + /** + * List all available tasks in the Exercism benchmark + */ + async listTasks(): Promise { + const tasks: Task[] = [] + const exercisesDir = path.join(EVALS_DIR, "repositories", "exercism") + + // Ensure the repository exists + if (!fs.existsSync(exercisesDir)) { + throw new Error(`Exercism repository not found at ${exercisesDir}. Run setup first.`) + } + + // Read language directories + const languages = fs + .readdirSync(exercisesDir) + .filter((dir) => fs.statSync(path.join(exercisesDir, dir)).isDirectory()) + .filter((dir) => !dir.startsWith(".") && !["node_modules", ".git"].includes(dir)) + + for (const language of languages) { + const languageDir = path.join(exercisesDir, language) + + // Read exercise directories + const exercises = fs.readdirSync(languageDir).filter((dir) => fs.statSync(path.join(languageDir, dir)).isDirectory()) + + for (const exercise of exercises) { + const exerciseDir = path.join(languageDir, exercise) + + // Read instructions + let description = "" + const instructionsPath = path.join(exerciseDir, "docs", "instructions.md") + if (fs.existsSync(instructionsPath)) { + description = fs.readFileSync(instructionsPath, "utf-8") + } + + // Determine test commands based on language + let testCommands: string[] = [] + switch (language) { + case "javascript": + testCommands = ["npm install", "npm test"] + break + case "python": + testCommands = ["python -m pytest -o markers=task *_test.py"] + break + case "go": + testCommands = ["go test"] + break + case "java": + testCommands = ["./gradlew test"] + break + case "rust": + testCommands = ["cargo test"] + break + default: + testCommands = [] + } + + tasks.push({ + id: `exercism-${language}-${exercise}`, + name: exercise, + description, + workspacePath: exerciseDir, + setupCommands: [], + verificationCommands: testCommands, + metadata: { + language, + type: "exercism", + }, + }) + } + } + + return tasks + } + + /** + * Prepare a specific task for execution + * @param taskId The ID of the task to prepare + */ + async prepareTask(taskId: string): Promise { + const tasks = await this.listTasks() + const task = tasks.find((t) => t.id === taskId) + + if (!task) { + throw new Error(`Task ${taskId} not found`) + } + + // Check if Git repository is already initialized + const gitDirExists = fs.existsSync(path.join(task.workspacePath, ".git")) + + try { + // Initialize Git repository if needed + if (!gitDirExists) { + await execa("git", ["init"], { cwd: task.workspacePath }) + } + + // Create a dummy file to ensure there's something to commit + const dummyFilePath = path.join(task.workspacePath, ".eval-timestamp") + fs.writeFileSync(dummyFilePath, new Date().toISOString()) + + // Add all files and commit + await execa("git", ["add", "."], { cwd: task.workspacePath }) + + try { + await execa("git", ["commit", "-m", "Initial commit"], { cwd: task.workspacePath }) + } catch (error: any) { + // If commit fails because there are no changes, that's okay + if (!error.stderr?.includes("nothing to commit")) { + throw error + } + } + } catch (error: any) { + console.warn(`Warning: Git operations failed: ${error.message}`) + console.warn("Continuing without Git initialization") + } + + return task + } + + /** + * Verify the result of a task execution + * @param task The task that was executed + * @param result The result of the task execution + */ + async verifyResult(task: Task, result: any): Promise { + // Run verification commands + let success = true + let output = "" + + for (const command of task.verificationCommands) { + try { + const [cmd, ...args] = command.split(" ") + const { stdout } = await execa(cmd, args, { cwd: task.workspacePath }) + output += stdout + "\n" + } catch (error: any) { + success = false + if (error.stdout) output += error.stdout + "\n" + if (error.stderr) output += error.stderr + "\n" + } + } + + // Parse test results + const testsPassed = (output.match(/PASS/g) || []).length + const testsFailed = (output.match(/FAIL/g) || []).length + const testsTotal = testsPassed + testsFailed + + return { + success, + metrics: { + testsPassed, + testsFailed, + testsTotal, + functionalCorrectness: testsTotal > 0 ? testsPassed / testsTotal : 0, + }, + } + } +} diff --git a/evals/cli/src/adapters/index.ts b/evals/cli/src/adapters/index.ts new file mode 100644 index 00000000..0165ee06 --- /dev/null +++ b/evals/cli/src/adapters/index.ts @@ -0,0 +1,47 @@ +import { BenchmarkAdapter } from "./types" +import { ExercismAdapter } from "./exercism" +import { SWEBenchAdapter } from "./swe-bench" +import { SWELancerAdapter } from "./swelancer" +import { MultiSWEAdapter } from "./multi-swe" + +// Registry of all available adapters +const adapters: Record = { + // Exercism is the primary adapter with real implementation + exercism: new ExercismAdapter(), + + // Dummy adapters for testing + "swe-bench": new SWEBenchAdapter(), + swelancer: new SWELancerAdapter(), + "multi-swe": new MultiSWEAdapter(), +} + +/** + * Get a specific adapter by name + * @param name The name of the adapter to get + * @returns The requested adapter + * @throws Error if the adapter is not found + */ +export function getAdapter(name: string): BenchmarkAdapter { + const adapter = adapters[name] + if (!adapter) { + throw new Error(`Adapter for benchmark '${name}' not found`) + } + return adapter +} + +/** + * Get all available adapters + * @returns Array of all registered adapters + */ +export function getAllAdapters(): BenchmarkAdapter[] { + return Object.values(adapters) +} + +/** + * Register a new adapter + * @param name The name to register the adapter under + * @param adapter The adapter to register + */ +export function registerAdapter(name: string, adapter: BenchmarkAdapter): void { + adapters[name] = adapter +} diff --git a/evals/cli/src/adapters/multi-swe.ts b/evals/cli/src/adapters/multi-swe.ts new file mode 100644 index 00000000..6b83a1c7 --- /dev/null +++ b/evals/cli/src/adapters/multi-swe.ts @@ -0,0 +1,192 @@ +import * as path from "path" +import * as fs from "fs" +import execa from "execa" +import { BenchmarkAdapter, Task, VerificationResult } from "./types" + +const EVALS_DIR = path.resolve(__dirname, "../../../") + +/** + * Dummy adapter for the Multi-SWE-Bench benchmark + */ +export class MultiSWEAdapter implements BenchmarkAdapter { + name = "multi-swe" + + /** + * Set up the Multi-SWE-Bench benchmark repository (dummy implementation) + */ + async setup(): Promise { + console.log("Multi-SWE-Bench dummy setup completed") + + // Create repositories directory if it doesn't exist + const repoDir = path.join(EVALS_DIR, "repositories", "multi-swe") + if (!fs.existsSync(repoDir)) { + fs.mkdirSync(repoDir, { recursive: true }) + console.log(`Created dummy Multi-SWE-Bench directory at ${repoDir}`) + } + } + + /** + * List all available tasks in the Multi-SWE-Bench benchmark (dummy implementation) + */ + async listTasks(): Promise { + return [ + { + id: "multi-swe-task-1", + name: "Multi-Language API Integration", + description: + "Implement a system that integrates a Python backend with a TypeScript frontend and a Rust processing service.", + workspacePath: path.join(EVALS_DIR, "repositories", "multi-swe"), + setupCommands: [], + verificationCommands: [], + metadata: { + languages: ["python", "typescript", "rust"], + complexity: "high", + type: "multi-swe", + }, + }, + { + id: "multi-swe-task-2", + name: "Cross-Platform Mobile App", + description: "Create a cross-platform mobile app using React Native with native modules in Swift and Kotlin.", + workspacePath: path.join(EVALS_DIR, "repositories", "multi-swe"), + setupCommands: [], + verificationCommands: [], + metadata: { + languages: ["javascript", "swift", "kotlin"], + complexity: "medium", + type: "multi-swe", + }, + }, + { + id: "multi-swe-task-3", + name: "Microservice Architecture", + description: "Design and implement a microservice architecture with services written in Go, Node.js, and Java.", + workspacePath: path.join(EVALS_DIR, "repositories", "multi-swe"), + setupCommands: [], + verificationCommands: [], + metadata: { + languages: ["go", "javascript", "java"], + complexity: "high", + type: "multi-swe", + }, + }, + ] + } + + /** + * Prepare a specific task for execution (dummy implementation) + * @param taskId The ID of the task to prepare + */ + async prepareTask(taskId: string): Promise { + const tasks = await this.listTasks() + const task = tasks.find((t) => t.id === taskId) + + if (!task) { + throw new Error(`Task ${taskId} not found`) + } + + // Create a dummy workspace for the task + const taskDir = path.join(task.workspacePath, taskId) + if (!fs.existsSync(taskDir)) { + fs.mkdirSync(taskDir, { recursive: true }) + + // Create a dummy file for the task + fs.writeFileSync( + path.join(taskDir, "README.md"), + `# ${task.name}\n\n${task.description}\n\nThis is a dummy task for testing purposes.`, + ) + + // Create additional dummy files based on task type + if (task.id === "multi-swe-task-1") { + // Python backend + fs.mkdirSync(path.join(taskDir, "backend"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "backend", "app.py"), + `# TODO: Implement Python backend\nfrom flask import Flask\n\napp = Flask(__name__)\n\n@app.route('/')\ndef hello():\n return "Hello, World!"\n`, + ) + + // TypeScript frontend + fs.mkdirSync(path.join(taskDir, "frontend"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "frontend", "app.ts"), + `// TODO: Implement TypeScript frontend\nconsole.log('Frontend starting...');\n`, + ) + + // Rust processing service + fs.mkdirSync(path.join(taskDir, "processor"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "processor", "main.rs"), + `// TODO: Implement Rust processing service\nfn main() {\n println!("Processor starting...");\n}\n`, + ) + } else if (task.id === "multi-swe-task-2") { + // React Native app + fs.mkdirSync(path.join(taskDir, "app"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "app", "App.js"), + `// TODO: Implement React Native app\nimport React from 'react';\nimport { View, Text } from 'react-native';\n\nexport default function App() {\n return (\n \n Hello, World!\n \n );\n}\n`, + ) + + // Swift native module + fs.mkdirSync(path.join(taskDir, "ios"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "ios", "NativeModule.swift"), + `// TODO: Implement Swift native module\nimport Foundation\n\n@objc(NativeModule)\nclass NativeModule: NSObject {\n @objc\n func hello() -> String {\n return "Hello from Swift"\n }\n}\n`, + ) + + // Kotlin native module + fs.mkdirSync(path.join(taskDir, "android"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "android", "NativeModule.kt"), + `// TODO: Implement Kotlin native module\npackage com.example.app\n\nclass NativeModule {\n fun hello(): String {\n return "Hello from Kotlin"\n }\n}\n`, + ) + } else if (task.id === "multi-swe-task-3") { + // Go service + fs.mkdirSync(path.join(taskDir, "service-go"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "service-go", "main.go"), + `// TODO: Implement Go service\npackage main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println("Go service starting...")\n}\n`, + ) + + // Node.js service + fs.mkdirSync(path.join(taskDir, "service-node"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "service-node", "server.js"), + `// TODO: Implement Node.js service\nconsole.log('Node.js service starting...');\n`, + ) + + // Java service + fs.mkdirSync(path.join(taskDir, "service-java"), { recursive: true }) + fs.writeFileSync( + path.join(taskDir, "service-java", "Main.java"), + `// TODO: Implement Java service\npublic class Main {\n public static void main(String[] args) {\n System.out.println("Java service starting...");\n }\n}\n`, + ) + } + } + + // Update the task's workspace path to the task-specific directory + return { + ...task, + workspacePath: taskDir, + } + } + + /** + * Verify the result of a task execution (dummy implementation) + * @param task The task that was executed + * @param result The result of the task execution + */ + async verifyResult(task: Task, result: any): Promise { + // Always return success for dummy implementation + return { + success: true, + metrics: { + testsPassed: 1, + testsFailed: 0, + testsTotal: 1, + functionalCorrectness: 1.0, + crossLanguageIntegration: 0.9, // Dummy metric specific to Multi-SWE + architectureQuality: 0.85, // Dummy metric specific to Multi-SWE + }, + } + } +} diff --git a/evals/cli/src/adapters/swe-bench.ts b/evals/cli/src/adapters/swe-bench.ts new file mode 100644 index 00000000..0dcbfc24 --- /dev/null +++ b/evals/cli/src/adapters/swe-bench.ts @@ -0,0 +1,125 @@ +import * as path from "path" +import * as fs from "fs" +import execa from "execa" +import { BenchmarkAdapter, Task, VerificationResult } from "./types" + +const EVALS_DIR = path.resolve(__dirname, "../../../") + +/** + * Dummy adapter for the SWE-Bench benchmark + */ +export class SWEBenchAdapter implements BenchmarkAdapter { + name = "swe-bench" + + /** + * Set up the SWE-Bench benchmark repository (dummy implementation) + */ + async setup(): Promise { + console.log("SWE-Bench dummy setup completed") + + // Create repositories directory if it doesn't exist + const repoDir = path.join(EVALS_DIR, "repositories", "swe-bench") + if (!fs.existsSync(repoDir)) { + fs.mkdirSync(repoDir, { recursive: true }) + console.log(`Created dummy SWE-Bench directory at ${repoDir}`) + } + } + + /** + * List all available tasks in the SWE-Bench benchmark (dummy implementation) + */ + async listTasks(): Promise { + return [ + { + id: "swe-bench-task-1", + name: "Fix React Component Bug", + description: "Fix a bug in a React component where the state is not properly updated.", + workspacePath: path.join(EVALS_DIR, "repositories", "swe-bench"), + setupCommands: [], + verificationCommands: [], + metadata: { + repository: "facebook/react", + issue: "#12345", + type: "swe-bench", + }, + }, + { + id: "swe-bench-task-2", + name: "Optimize Database Query", + description: "Optimize a slow database query in a Django application.", + workspacePath: path.join(EVALS_DIR, "repositories", "swe-bench"), + setupCommands: [], + verificationCommands: [], + metadata: { + repository: "django/django", + issue: "#6789", + type: "swe-bench", + }, + }, + { + id: "swe-bench-task-3", + name: "Fix Memory Leak", + description: "Fix a memory leak in a Node.js application.", + workspacePath: path.join(EVALS_DIR, "repositories", "swe-bench"), + setupCommands: [], + verificationCommands: [], + metadata: { + repository: "nodejs/node", + issue: "#9876", + type: "swe-bench", + }, + }, + ] + } + + /** + * Prepare a specific task for execution (dummy implementation) + * @param taskId The ID of the task to prepare + */ + async prepareTask(taskId: string): Promise { + const tasks = await this.listTasks() + const task = tasks.find((t) => t.id === taskId) + + if (!task) { + throw new Error(`Task ${taskId} not found`) + } + + // Create a dummy workspace for the task + const taskDir = path.join(task.workspacePath, taskId) + if (!fs.existsSync(taskDir)) { + fs.mkdirSync(taskDir, { recursive: true }) + + // Create a dummy file for the task + fs.writeFileSync( + path.join(taskDir, "README.md"), + `# ${task.name}\n\n${task.description}\n\nThis is a dummy task for testing purposes.`, + ) + } + + // Update the task's workspace path to the task-specific directory + return { + ...task, + workspacePath: taskDir, + } + } + + /** + * Verify the result of a task execution (dummy implementation) + * @param task The task that was executed + * @param result The result of the task execution + */ + async verifyResult(task: Task, result: any): Promise { + // Always return success for dummy implementation + return { + success: true, + metrics: { + testsPassed: 1, + testsFailed: 0, + testsTotal: 1, + functionalCorrectness: 1.0, + performanceImprovement: 0.25, // Dummy metric specific to SWE-Bench + codeQuality: 0.9, // Dummy metric specific to SWE-Bench + }, + } + } +} diff --git a/evals/cli/src/adapters/swelancer.ts b/evals/cli/src/adapters/swelancer.ts new file mode 100644 index 00000000..7611cac7 --- /dev/null +++ b/evals/cli/src/adapters/swelancer.ts @@ -0,0 +1,143 @@ +import * as path from "path" +import * as fs from "fs" +import execa from "execa" +import { BenchmarkAdapter, Task, VerificationResult } from "./types" + +const EVALS_DIR = path.resolve(__dirname, "../../../") + +/** + * Dummy adapter for the SWELancer benchmark + */ +export class SWELancerAdapter implements BenchmarkAdapter { + name = "swelancer" + + /** + * Set up the SWELancer benchmark repository (dummy implementation) + */ + async setup(): Promise { + console.log("SWELancer dummy setup completed") + + // Create repositories directory if it doesn't exist + const repoDir = path.join(EVALS_DIR, "repositories", "swelancer") + if (!fs.existsSync(repoDir)) { + fs.mkdirSync(repoDir, { recursive: true }) + console.log(`Created dummy SWELancer directory at ${repoDir}`) + } + } + + /** + * List all available tasks in the SWELancer benchmark (dummy implementation) + */ + async listTasks(): Promise { + return [ + { + id: "swelancer-task-1", + name: "Create Landing Page", + description: "Create a responsive landing page for a new product using HTML, CSS, and JavaScript.", + workspacePath: path.join(EVALS_DIR, "repositories", "swelancer"), + setupCommands: [], + verificationCommands: [], + metadata: { + client: "TechStartup Inc.", + difficulty: "medium", + type: "swelancer", + }, + }, + { + id: "swelancer-task-2", + name: "Build REST API", + description: "Create a RESTful API for a blog application using Node.js and Express.", + workspacePath: path.join(EVALS_DIR, "repositories", "swelancer"), + setupCommands: [], + verificationCommands: [], + metadata: { + client: "BlogCo", + difficulty: "hard", + type: "swelancer", + }, + }, + { + id: "swelancer-task-3", + name: "Fix CSS Layout Issues", + description: "Fix layout issues in a responsive website across different screen sizes.", + workspacePath: path.join(EVALS_DIR, "repositories", "swelancer"), + setupCommands: [], + verificationCommands: [], + metadata: { + client: "DesignAgency", + difficulty: "easy", + type: "swelancer", + }, + }, + ] + } + + /** + * Prepare a specific task for execution (dummy implementation) + * @param taskId The ID of the task to prepare + */ + async prepareTask(taskId: string): Promise { + const tasks = await this.listTasks() + const task = tasks.find((t) => t.id === taskId) + + if (!task) { + throw new Error(`Task ${taskId} not found`) + } + + // Create a dummy workspace for the task + const taskDir = path.join(task.workspacePath, taskId) + if (!fs.existsSync(taskDir)) { + fs.mkdirSync(taskDir, { recursive: true }) + + // Create a dummy file for the task + fs.writeFileSync( + path.join(taskDir, "README.md"), + `# ${task.name}\n\n${task.description}\n\nThis is a dummy task for testing purposes.`, + ) + + // Create additional dummy files based on task type + if (task.id === "swelancer-task-1") { + fs.writeFileSync( + path.join(taskDir, "index.html"), + `\n\n\n Landing Page\n\n\n \n\n`, + ) + } else if (task.id === "swelancer-task-2") { + fs.writeFileSync( + path.join(taskDir, "server.js"), + `// TODO: Implement REST API\nconsole.log('Server starting...');`, + ) + } else if (task.id === "swelancer-task-3") { + fs.writeFileSync( + path.join(taskDir, "styles.css"), + `/* TODO: Fix layout issues */\nbody {\n margin: 0;\n padding: 0;\n}`, + ) + } + } + + // Update the task's workspace path to the task-specific directory + return { + ...task, + workspacePath: taskDir, + } + } + + /** + * Verify the result of a task execution (dummy implementation) + * @param task The task that was executed + * @param result The result of the task execution + */ + async verifyResult(task: Task, result: any): Promise { + // Always return success for dummy implementation + return { + success: true, + metrics: { + testsPassed: 1, + testsFailed: 0, + testsTotal: 1, + functionalCorrectness: 1.0, + clientSatisfaction: 0.95, // Dummy metric specific to SWELancer + timeEfficiency: 0.85, // Dummy metric specific to SWELancer + }, + } + } +} diff --git a/evals/cli/src/adapters/types.ts b/evals/cli/src/adapters/types.ts new file mode 100644 index 00000000..a585a2ac --- /dev/null +++ b/evals/cli/src/adapters/types.ts @@ -0,0 +1,31 @@ +/** + * Represents a task to be executed + */ +export interface Task { + id: string + name: string + description: string + workspacePath: string + setupCommands: string[] + verificationCommands: string[] + metadata: Record +} + +/** + * Result of verifying a task execution + */ +export interface VerificationResult { + success: boolean + metrics: Record +} + +/** + * Interface for benchmark adapters + */ +export interface BenchmarkAdapter { + name: string + setup(): Promise + listTasks(): Promise + prepareTask(taskId: string): Promise + verifyResult(task: Task, result: any): Promise +} diff --git a/evals/cli/src/commands/report.ts b/evals/cli/src/commands/report.ts new file mode 100644 index 00000000..c7877ffb --- /dev/null +++ b/evals/cli/src/commands/report.ts @@ -0,0 +1,237 @@ +import * as fs from "fs" +import * as path from "path" +import chalk from "chalk" +import ora from "ora" +import { ResultsDatabase } from "../db" +import { generateMarkdownReport } from "../utils/markdown" + +interface ReportOptions { + format?: "json" | "markdown" + output?: string +} + +/** + * Handler for the report command + * @param options Command options + */ +export async function reportHandler(options: ReportOptions): Promise { + const format = options.format || "markdown" + const db = new ResultsDatabase() + + try { + const spinner = ora("Generating report...").start() + + // Get all runs + const runs = db.getRuns() + + console.log(chalk.blue(`Found ${runs.length} evaluation runs`)) + + if (runs.length === 0) { + spinner.fail("No evaluation runs found") + return + } + + // Generate summary report + const summary = { + runs: runs.length, + models: [...new Set(runs.map((run) => run.model))], + benchmarks: [...new Set(runs.map((run) => run.benchmark))], + tasks: 0, + successRate: 0, + averageTokens: 0, + averageCost: 0, + averageDuration: 0, + totalToolCalls: 0, + totalToolFailures: 0, + toolSuccessRate: 0, + toolUsage: {} as Record, + } + + let totalTasks = 0 + let successfulTasks = 0 + let totalTokens = 0 + let totalCost = 0 + let totalDuration = 0 + let totalToolCalls = 0 + let totalToolFailures = 0 + + for (const run of runs) { + const tasks = db.getRunTasks(run.id) + totalTasks += tasks.length + + for (const task of tasks) { + if (task.success) { + successfulTasks++ + } + + const metrics = db.getTaskMetrics(task.id) + + const tokensIn = metrics.find((m) => m.name === "tokensIn")?.value || 0 + const tokensOut = metrics.find((m) => m.name === "tokensOut")?.value || 0 + totalTokens += tokensIn + tokensOut + + totalCost += metrics.find((m) => m.name === "cost")?.value || 0 + totalDuration += metrics.find((m) => m.name === "duration")?.value || 0 + + // Collect tool call metrics + totalToolCalls += task.total_tool_calls || 0 + totalToolFailures += task.total_tool_failures || 0 + + // Get detailed tool usage + const toolCalls = db.getTaskToolCalls(task.id) + + for (const toolCall of toolCalls) { + if (!summary.toolUsage[toolCall.tool_name]) { + summary.toolUsage[toolCall.tool_name] = { + calls: 0, + failures: 0, + } + } + + summary.toolUsage[toolCall.tool_name].calls += toolCall.call_count + summary.toolUsage[toolCall.tool_name].failures += toolCall.failure_count + } + } + } + + // Calculate tool success rate + summary.totalToolCalls = totalToolCalls + summary.totalToolFailures = totalToolFailures + summary.toolSuccessRate = totalToolCalls > 0 ? 1 - totalToolFailures / totalToolCalls : 1.0 + + summary.tasks = totalTasks + summary.successRate = totalTasks > 0 ? successfulTasks / totalTasks : 0 + summary.averageTokens = totalTasks > 0 ? totalTokens / totalTasks : 0 + summary.averageCost = totalTasks > 0 ? totalCost / totalTasks : 0 + summary.averageDuration = totalTasks > 0 ? totalDuration / totalTasks : 0 + + // Generate benchmark-specific reports + const benchmarkReports: Record = {} + + for (const benchmark of summary.benchmarks) { + const benchmarkRuns = runs.filter((run) => run.benchmark === benchmark) + const benchmarkSummary = { + runs: benchmarkRuns.length, + models: [...new Set(benchmarkRuns.map((run) => run.model))], + tasks: 0, + successRate: 0, + averageTokens: 0, + averageCost: 0, + averageDuration: 0, + } + + let benchmarkTasks = 0 + let benchmarkSuccessfulTasks = 0 + let benchmarkTotalTokens = 0 + let benchmarkTotalCost = 0 + let benchmarkTotalDuration = 0 + + for (const run of benchmarkRuns) { + const tasks = db.getRunTasks(run.id) + benchmarkTasks += tasks.length + + for (const task of tasks) { + if (task.success) { + benchmarkSuccessfulTasks++ + } + + const metrics = db.getTaskMetrics(task.id) + + const tokensIn = metrics.find((m) => m.name === "tokensIn")?.value || 0 + const tokensOut = metrics.find((m) => m.name === "tokensOut")?.value || 0 + benchmarkTotalTokens += tokensIn + tokensOut + + benchmarkTotalCost += metrics.find((m) => m.name === "cost")?.value || 0 + benchmarkTotalDuration += metrics.find((m) => m.name === "duration")?.value || 0 + } + } + + benchmarkSummary.tasks = benchmarkTasks + benchmarkSummary.successRate = benchmarkTasks > 0 ? benchmarkSuccessfulTasks / benchmarkTasks : 0 + benchmarkSummary.averageTokens = benchmarkTasks > 0 ? benchmarkTotalTokens / benchmarkTasks : 0 + benchmarkSummary.averageCost = benchmarkTasks > 0 ? benchmarkTotalCost / benchmarkTasks : 0 + benchmarkSummary.averageDuration = benchmarkTasks > 0 ? benchmarkTotalDuration / benchmarkTasks : 0 + + benchmarkReports[benchmark] = benchmarkSummary + } + + // Generate model-specific reports + const modelReports: Record = {} + + for (const model of summary.models) { + const modelRuns = runs.filter((run) => run.model === model) + const modelSummary = { + runs: modelRuns.length, + benchmarks: [...new Set(modelRuns.map((run) => run.benchmark))], + tasks: 0, + successRate: 0, + averageTokens: 0, + averageCost: 0, + averageDuration: 0, + } + + let modelTasks = 0 + let modelSuccessfulTasks = 0 + let modelTotalTokens = 0 + let modelTotalCost = 0 + let modelTotalDuration = 0 + + for (const run of modelRuns) { + const tasks = db.getRunTasks(run.id) + modelTasks += tasks.length + + for (const task of tasks) { + if (task.success) { + modelSuccessfulTasks++ + } + + const metrics = db.getTaskMetrics(task.id) + + const tokensIn = metrics.find((m) => m.name === "tokensIn")?.value || 0 + const tokensOut = metrics.find((m) => m.name === "tokensOut")?.value || 0 + modelTotalTokens += tokensIn + tokensOut + + modelTotalCost += metrics.find((m) => m.name === "cost")?.value || 0 + modelTotalDuration += metrics.find((m) => m.name === "duration")?.value || 0 + } + } + + modelSummary.tasks = modelTasks + modelSummary.successRate = modelTasks > 0 ? modelSuccessfulTasks / modelTasks : 0 + modelSummary.averageTokens = modelTasks > 0 ? modelTotalTokens / modelTasks : 0 + modelSummary.averageCost = modelTasks > 0 ? modelTotalCost / modelTasks : 0 + modelSummary.averageDuration = modelTasks > 0 ? modelTotalDuration / modelTasks : 0 + + modelReports[model] = modelSummary + } + + // Save reports + const reportDir = path.join(path.resolve(__dirname, "../../../"), "results", "reports") + fs.mkdirSync(reportDir, { recursive: true }) + + const timestamp = new Date().toISOString().replace(/:/g, "-") + + if (format === "json") { + // Save JSON reports + fs.writeFileSync(path.join(reportDir, `summary-${timestamp}.json`), JSON.stringify(summary, null, 2)) + + fs.writeFileSync(path.join(reportDir, `benchmarks-${timestamp}.json`), JSON.stringify(benchmarkReports, null, 2)) + + fs.writeFileSync(path.join(reportDir, `models-${timestamp}.json`), JSON.stringify(modelReports, null, 2)) + + spinner.succeed(`JSON reports generated in ${reportDir}`) + } else { + // Generate markdown report + const outputPath = options.output || path.join(reportDir, `report-${timestamp}.md`) + + generateMarkdownReport(summary, benchmarkReports, modelReports, outputPath) + + spinner.succeed(`Markdown report generated at ${outputPath}`) + } + } catch (error: any) { + console.error(chalk.red(`Error generating report: ${error.message}`)) + console.error(error.stack) + } finally { + db.close() + } +} diff --git a/evals/cli/src/commands/run.ts b/evals/cli/src/commands/run.ts new file mode 100644 index 00000000..b0fbf971 --- /dev/null +++ b/evals/cli/src/commands/run.ts @@ -0,0 +1,133 @@ +import * as path from "path" +import { v4 as uuidv4 } from "uuid" +import chalk from "chalk" +import ora from "ora" +import { getAdapter } from "../adapters" +import { ResultsDatabase } from "../db" +import { spawnVSCode, cleanupVSCode } from "../utils/vscode" +import { sendTaskToServer } from "../utils/task" +import { storeTaskResult } from "../utils/results" + +interface RunOptions { + benchmark?: string + model: string + count?: number + apiKey?: string +} + +/** + * Handler for the run command + * @param options Command options + */ +export async function runHandler(options: RunOptions): Promise { + // Determine which benchmarks to run + const benchmarks = options.benchmark ? [options.benchmark] : ["exercism"] // Default to exercism for now + const model = options.model + const count = options.count || Infinity + + console.log(chalk.blue(`Running evaluations for model: ${model}`)) + console.log(chalk.blue(`Benchmarks: ${benchmarks.join(", ")}`)) + + // Create a run for each benchmark + for (const benchmark of benchmarks) { + const runId = uuidv4() + const db = new ResultsDatabase() + + console.log(chalk.green(`\nStarting run for benchmark: ${benchmark}`)) + + // Create run in database + db.createRun(runId, model, benchmark) + + // Get adapter for this benchmark + try { + const adapter = getAdapter(benchmark) + + // List tasks + const spinner = ora("Listing tasks...").start() + const tasks = await adapter.listTasks() + spinner.succeed(`Found ${tasks.length} tasks for ${benchmark}`) + + // Limit number of tasks if specified + const tasksToRun = tasks.slice(0, count) + + console.log(chalk.blue(`Running ${tasksToRun.length} tasks...`)) + + // Run each task + for (let i = 0; i < tasksToRun.length; i++) { + const task = tasksToRun[i] + + console.log(chalk.cyan(`\nTask ${i + 1}/${tasksToRun.length}: ${task.name}`)) + + // Prepare task + const prepareSpinner = ora("Preparing task...").start() + const preparedTask = await adapter.prepareTask(task.id) + prepareSpinner.succeed("Task prepared") + + // Spawn VSCode + console.log("Spawning VSCode...") + await spawnVSCode(preparedTask.workspacePath) + + // Send task to server + const sendSpinner = ora("Sending task to server...").start() + try { + const result = await sendTaskToServer(preparedTask.description, options.apiKey) + sendSpinner.succeed("Task completed") + + // Verify result + const verifySpinner = ora("Verifying result...").start() + const verification = await adapter.verifyResult(preparedTask, result) + + if (verification.success) { + verifySpinner.succeed( + `Verification successful: ${verification.metrics.testsPassed}/${verification.metrics.testsTotal} tests passed`, + ) + } else { + verifySpinner.fail( + `Verification failed: ${verification.metrics.testsPassed}/${verification.metrics.testsTotal} tests passed`, + ) + } + + // Store result + const storeSpinner = ora("Storing result...").start() + await storeTaskResult(runId, preparedTask, result, verification) + storeSpinner.succeed("Result stored") + + console.log(chalk.green(`Task completed. Success: ${verification.success}`)) + + // Clean up VS Code and temporary files + const cleanupSpinner = ora("Cleaning up...").start() + try { + await cleanupVSCode(preparedTask.workspacePath) + cleanupSpinner.succeed("Cleanup completed") + } catch (cleanupError: any) { + cleanupSpinner.fail(`Cleanup failed: ${cleanupError.message}`) + console.error(chalk.yellow(cleanupError.stack)) + } + } catch (error: any) { + sendSpinner.fail(`Task failed: ${error.message}`) + console.error(chalk.red(error.stack)) + + // Clean up VS Code and temporary files even if the task failed + const cleanupSpinner = ora("Cleaning up...").start() + try { + await cleanupVSCode(preparedTask.workspacePath) + cleanupSpinner.succeed("Cleanup completed") + } catch (cleanupError: any) { + cleanupSpinner.fail(`Cleanup failed: ${cleanupError.message}`) + console.error(chalk.yellow(cleanupError.stack)) + } + } + } + + // Mark run as complete + db.completeRun(runId) + + console.log(chalk.green(`\nRun complete for benchmark: ${benchmark}`)) + } catch (error: any) { + console.error(chalk.red(`Error running benchmark ${benchmark}: ${error.message}`)) + console.error(error.stack) + } + } + + console.log(chalk.green("\nAll evaluations complete")) +} diff --git a/evals/cli/src/commands/setup.ts b/evals/cli/src/commands/setup.ts new file mode 100644 index 00000000..8a084ecd --- /dev/null +++ b/evals/cli/src/commands/setup.ts @@ -0,0 +1,72 @@ +import * as path from "path" +import * as fs from "fs" +import execa from "execa" +import chalk from "chalk" +import ora from "ora" +import { getAllAdapters } from "../adapters/index" +import { BenchmarkAdapter } from "../adapters/types" + +interface SetupOptions { + benchmarks: string +} + +/** + * Handler for the setup command + * @param options Command options + */ +export async function setupHandler(options: SetupOptions): Promise { + const benchmarks = options.benchmarks.split(",") + + console.log(chalk.blue(`Setting up benchmarks: ${benchmarks.join(", ")}`)) + + // Create directories + const evalsDir = path.resolve(__dirname, "../../../") + const reposDir = path.join(evalsDir, "repositories") + const resultsDir = path.join(evalsDir, "results") + + const spinner = ora("Creating directory structure").start() + + try { + fs.mkdirSync(reposDir, { recursive: true }) + fs.mkdirSync(resultsDir, { recursive: true }) + fs.mkdirSync(path.join(resultsDir, "runs"), { recursive: true }) + fs.mkdirSync(path.join(resultsDir, "reports"), { recursive: true }) + spinner.succeed("Directory structure created") + } catch (error) { + spinner.fail(`Failed to create directory structure: ${(error as Error).message}`) + throw error + } + + // Set up each benchmark + try { + const adapters = getAllAdapters().filter((adapter: BenchmarkAdapter) => benchmarks.includes(adapter.name)) + + if (adapters.length === 0) { + console.warn(chalk.yellow("No valid benchmarks specified. Available benchmarks:")) + console.warn( + chalk.yellow( + getAllAdapters() + .map((a: BenchmarkAdapter) => a.name) + .join(", "), + ), + ) + return + } + + for (const adapter of adapters) { + const setupSpinner = ora(`Setting up ${adapter.name}...`).start() + try { + await adapter.setup() + setupSpinner.succeed(`${adapter.name} setup complete`) + } catch (error) { + setupSpinner.fail(`Failed to set up ${adapter.name}: ${(error as Error).message}`) + throw error + } + } + + console.log(chalk.green("Setup complete")) + } catch (error) { + console.error(chalk.red(`Setup failed: ${(error as Error).message}`)) + throw error + } +} diff --git a/evals/cli/src/db/index.ts b/evals/cli/src/db/index.ts new file mode 100644 index 00000000..4a66a26b --- /dev/null +++ b/evals/cli/src/db/index.ts @@ -0,0 +1,211 @@ +import * as path from "path" +import * as fs from "fs" +import Database from "better-sqlite3" +import { SCHEMA } from "./schema" + +const EVALS_DIR = path.resolve(__dirname, "../../../") + +/** + * Database class for storing evaluation results + */ +export class ResultsDatabase { + db: Database.Database + + constructor() { + // Ensure results directory exists + const resultsDir = path.join(EVALS_DIR, "results") + fs.mkdirSync(resultsDir, { recursive: true }) + + // Create database file + const dbPath = path.join(resultsDir, "evals.db") + this.db = new Database(dbPath) + + // Initialize schema + this.initSchema() + } + + /** + * Initialize the database schema + */ + private initSchema(): void { + this.db.exec(SCHEMA) + } + + /** + * Create a new evaluation run + * @param id Run ID + * @param model Model name + * @param benchmark Benchmark name + */ + createRun(id: string, model: string, benchmark: string): void { + const stmt = this.db.prepare(` + INSERT INTO runs (id, timestamp, model, benchmark) + VALUES (?, ?, ?, ?) + `) + + stmt.run(id, Date.now(), model, benchmark) + } + + /** + * Mark a run as completed + * @param id Run ID + */ + completeRun(id: string): void { + const stmt = this.db.prepare(` + UPDATE runs SET completed = 1 WHERE id = ? + `) + + stmt.run(id) + } + + /** + * Create a new task + * @param id Task ID + * @param runId Run ID + * @param taskId Original task ID + */ + createTask(id: string, runId: string, taskId: string): void { + const stmt = this.db.prepare(` + INSERT INTO tasks (id, run_id, task_id, timestamp) + VALUES (?, ?, ?, ?) + `) + + stmt.run(id, runId, taskId, Date.now()) + } + + /** + * Mark a task as completed + * @param id Task ID + * @param success Whether the task was successful + * @param toolCalls Total tool calls + * @param toolFailures Total tool failures + */ + completeTask(id: string, success: boolean, toolCalls: number = 0, toolFailures: number = 0): void { + const stmt = this.db.prepare(` + UPDATE tasks + SET success = ?, total_tool_calls = ?, total_tool_failures = ? + WHERE id = ? + `) + + stmt.run(success ? 1 : 0, toolCalls, toolFailures, id) + } + + /** + * Add a metric to a task + * @param taskId Task ID + * @param name Metric name + * @param value Metric value + */ + addMetric(taskId: string, name: string, value: number): void { + const stmt = this.db.prepare(` + INSERT INTO metrics (task_id, name, value) + VALUES (?, ?, ?) + `) + + stmt.run(taskId, name, value) + } + + /** + * Add a tool call record + * @param taskId Task ID + * @param toolName Tool name + * @param callCount Number of calls + * @param failureCount Number of failures + */ + addToolCall(taskId: string, toolName: string, callCount: number, failureCount: number): void { + const stmt = this.db.prepare(` + INSERT INTO tool_calls (task_id, tool_name, call_count, failure_count) + VALUES (?, ?, ?, ?) + `) + + stmt.run(taskId, toolName, callCount, failureCount) + } + + /** + * Add a file record + * @param taskId Task ID + * @param filePath File path + * @param status File status (created, modified, deleted) + */ + addFile(taskId: string, filePath: string, status: "created" | "modified" | "deleted"): void { + const stmt = this.db.prepare(` + INSERT INTO files (task_id, path, status) + VALUES (?, ?, ?) + `) + + stmt.run(taskId, filePath, status) + } + + /** + * Get all runs + * @returns Array of runs + */ + getRuns(): any[] { + const stmt = this.db.prepare(` + SELECT * FROM runs ORDER BY timestamp DESC + `) + + return stmt.all() + } + + /** + * Get all tasks for a run + * @param runId Run ID + * @returns Array of tasks + */ + getRunTasks(runId: string): any[] { + const stmt = this.db.prepare(` + SELECT * FROM tasks WHERE run_id = ? ORDER BY timestamp ASC + `) + + return stmt.all(runId) + } + + /** + * Get all metrics for a task + * @param taskId Task ID + * @returns Array of metrics + */ + getTaskMetrics(taskId: string): any[] { + const stmt = this.db.prepare(` + SELECT name, value FROM metrics WHERE task_id = ? + `) + + return stmt.all(taskId) + } + + /** + * Get all tool calls for a task + * @param taskId Task ID + * @returns Array of tool calls + */ + getTaskToolCalls(taskId: string): any[] { + const stmt = this.db.prepare(` + SELECT tool_name, call_count, failure_count + FROM tool_calls + WHERE task_id = ? + `) + + return stmt.all(taskId) + } + + /** + * Get all files for a task + * @param taskId Task ID + * @returns Array of files + */ + getTaskFiles(taskId: string): any[] { + const stmt = this.db.prepare(` + SELECT path, status FROM files WHERE task_id = ? + `) + + return stmt.all(taskId) + } + + /** + * Close the database connection + */ + close(): void { + this.db.close() + } +} diff --git a/evals/cli/src/db/schema.ts b/evals/cli/src/db/schema.ts new file mode 100644 index 00000000..ca55a463 --- /dev/null +++ b/evals/cli/src/db/schema.ts @@ -0,0 +1,48 @@ +/** + * SQL schema for the evaluation database + */ +export const SCHEMA = ` +CREATE TABLE IF NOT EXISTS runs ( + id TEXT PRIMARY KEY, + timestamp INTEGER NOT NULL, + model TEXT NOT NULL, + benchmark TEXT NOT NULL, + completed INTEGER NOT NULL DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS tasks ( + id TEXT PRIMARY KEY, + run_id TEXT NOT NULL, + task_id TEXT NOT NULL, + timestamp INTEGER NOT NULL, + success INTEGER NOT NULL DEFAULT 0, + total_tool_calls INTEGER DEFAULT 0, + total_tool_failures INTEGER DEFAULT 0, + FOREIGN KEY (run_id) REFERENCES runs(id) +); + +CREATE TABLE IF NOT EXISTS metrics ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + task_id TEXT NOT NULL, + name TEXT NOT NULL, + value REAL NOT NULL, + FOREIGN KEY (task_id) REFERENCES tasks(id) +); + +CREATE TABLE IF NOT EXISTS tool_calls ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + task_id TEXT NOT NULL, + tool_name TEXT NOT NULL, + call_count INTEGER NOT NULL, + failure_count INTEGER NOT NULL, + FOREIGN KEY (task_id) REFERENCES tasks(id) +); + +CREATE TABLE IF NOT EXISTS files ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + task_id TEXT NOT NULL, + path TEXT NOT NULL, + status TEXT NOT NULL, + FOREIGN KEY (task_id) REFERENCES tasks(id) +); +` diff --git a/evals/cli/src/index.ts b/evals/cli/src/index.ts new file mode 100644 index 00000000..18e5fabf --- /dev/null +++ b/evals/cli/src/index.ts @@ -0,0 +1,70 @@ +#!/usr/bin/env node +import { Command } from "commander" +import chalk from "chalk" +import { setupHandler } from "./commands/setup" +import { runHandler } from "./commands/run" +import { reportHandler } from "./commands/report" + +// Create the CLI program +const program = new Command() + +// Set up CLI metadata +program.name("cline-eval").description("CLI tool for orchestrating Cline evaluations across multiple benchmarks").version("0.1.0") + +// Setup command +program + .command("setup") + .description("Clone and set up benchmark repositories") + .option( + "-b, --benchmarks ", + "Comma-separated list of benchmarks to set up", + "exercism,swe-bench,swelancer,multi-swe", + ) + .action(async (options) => { + try { + await setupHandler(options) + } catch (error) { + console.error(chalk.red(`Error during setup: ${error instanceof Error ? error.message : String(error)}`)) + process.exit(1) + } + }) + +// Run command +program + .command("run") + .description("Run evaluations") + .option("-b, --benchmark ", "Specific benchmark to run") + .option("-m, --model ", "Model to evaluate", "claude-3-opus-20240229") + .option("-c, --count ", "Number of tasks to run", parseInt) + .option("-k, --api-key ", "Cline API key to use for evaluations") + .action(async (options) => { + try { + await runHandler(options) + } catch (error) { + console.error(chalk.red(`Error during run: ${error instanceof Error ? error.message : String(error)}`)) + process.exit(1) + } + }) + +// Report command +program + .command("report") + .description("Generate reports") + .option("-f, --format ", "Report format (json, markdown)", "markdown") + .option("-o, --output ", "Output path for the report") + .action(async (options) => { + try { + await reportHandler(options) + } catch (error) { + console.error(chalk.red(`Error generating report: ${error instanceof Error ? error.message : String(error)}`)) + process.exit(1) + } + }) + +// Parse command line arguments +program.parse(process.argv) + +// If no arguments provided, show help +if (process.argv.length === 2) { + program.help() +} diff --git a/evals/cli/src/utils/extensions.ts b/evals/cli/src/utils/extensions.ts new file mode 100644 index 00000000..cc49ff8d --- /dev/null +++ b/evals/cli/src/utils/extensions.ts @@ -0,0 +1,131 @@ +import execa from "execa" +import * as fs from "fs" +import * as path from "path" +import * as os from "os" + +/** + * List of VSCode extensions to install for evaluation environments + * These extensions provide language support and other useful features + */ +export const REQUIRED_EXTENSIONS = [ + "golang.go", // Go language support + "dbaeumer.vscode-eslint", // ESLint support + "redhat.java", // Java support + "ms-python.python", // Python support + "rust-lang.rust-analyzer", // Rust support + "ms-vscode.cpptools", // C/C++ support +] + +/** + * Install required VSCode extensions in the specified extensions directory + * @param extensionsDir The directory where extensions should be installed + * @returns Promise that resolves when all extensions are installed + */ +export async function installRequiredExtensions(extensionsDir: string): Promise { + console.log("Installing required VSCode extensions...") + + // Create the extensions directory if it doesn't exist + if (!fs.existsSync(extensionsDir)) { + fs.mkdirSync(extensionsDir, { recursive: true }) + } + + // Install each extension + for (const extension of REQUIRED_EXTENSIONS) { + try { + console.log(`Installing extension: ${extension}...`) + await execa("code", ["--extensions-dir", extensionsDir, "--install-extension", extension, "--force"]) + console.log(`✅ Extension ${extension} installed successfully`) + } catch (error: any) { + console.warn(`⚠️ Failed to install extension ${extension}: ${error.message}`) + // Continue with other extensions even if one fails + } + } + + console.log("✅ All required extensions installed") +} + +/** + * Check if a VSCode extension is installed in the specified directory + * @param extensionsDir The directory to check for installed extensions + * @param extensionId The ID of the extension to check + * @returns True if the extension is installed, false otherwise + */ +export function isExtensionInstalled(extensionsDir: string, extensionId: string): boolean { + // Extensions are installed in directories named publisher.name-version + // We need to check if any directory starts with the extensionId + const extensionPrefix = extensionId.toLowerCase() + "-" + + try { + const files = fs.readdirSync(extensionsDir) + return files.some((file) => { + const lowerCaseFile = file.toLowerCase() + return lowerCaseFile === extensionId.toLowerCase() || lowerCaseFile.startsWith(extensionPrefix) + }) + } catch (error) { + return false + } +} + +/** + * Get the path to the VSCode settings file in the specified user data directory + * @param userDataDir The VSCode user data directory + * @returns The path to the settings.json file + */ +export function getSettingsPath(userDataDir: string): string { + const settingsDir = path.join(userDataDir, "User") + fs.mkdirSync(settingsDir, { recursive: true }) + return path.join(settingsDir, "settings.json") +} + +/** + * Configure extension settings in the VSCode user data directory + * @param userDataDir The VSCode user data directory + */ +export function configureExtensionSettings(userDataDir: string): void { + const settingsPath = getSettingsPath(userDataDir) + + // Read existing settings if they exist + let settings = {} + if (fs.existsSync(settingsPath)) { + try { + settings = JSON.parse(fs.readFileSync(settingsPath, "utf8")) + } catch (error) { + console.warn(`Error reading settings file: ${error}`) + } + } + + // Add or update extension-specific settings + const updatedSettings = { + ...settings, + // Go extension settings + "go.toolsManagement.autoUpdate": false, + "go.survey.prompt": false, + + // ESLint settings + "eslint.enable": true, + "eslint.run": "onSave", + + // Java settings + "java.configuration.checkProjectSettingsExclusions": false, + "java.configure.checkForOutdatedExtensions": false, + "java.help.firstView": false, + + // Python settings + "python.experiments.enabled": false, + "python.showStartPage": false, + + // Rust settings + "rust-analyzer.checkOnSave.command": "check", + + // C/C++ settings + "C_Cpp.intelliSenseEngine": "default", + + // General extension settings + "extensions.autoUpdate": false, + "extensions.ignoreRecommendations": true, + } + + // Write updated settings + fs.writeFileSync(settingsPath, JSON.stringify(updatedSettings, null, 2)) + console.log("✅ Extension settings configured") +} diff --git a/evals/cli/src/utils/markdown.ts b/evals/cli/src/utils/markdown.ts new file mode 100644 index 00000000..48659346 --- /dev/null +++ b/evals/cli/src/utils/markdown.ts @@ -0,0 +1,109 @@ +import * as fs from "fs" +import * as path from "path" + +/** + * Generate a markdown report from evaluation results + * @param summary Overall summary + * @param benchmarkReports Benchmark-specific reports + * @param modelReports Model-specific reports + * @param outputPath Output file path + */ +export function generateMarkdownReport( + summary: any, + benchmarkReports: Record, + modelReports: Record, + outputPath: string, +): void { + let markdown = `# Cline Evaluation Report\n\n` + + // Generate summary section + markdown += `## Summary\n\n` + markdown += `- **Total Runs:** ${summary.runs}\n` + markdown += `- **Models:** ${summary.models.join(", ")}\n` + markdown += `- **Benchmarks:** ${summary.benchmarks.join(", ")}\n` + markdown += `- **Total Tasks:** ${summary.tasks}\n` + markdown += `- **Success Rate:** ${(summary.successRate * 100).toFixed(2)}%\n` + markdown += `- **Average Tokens:** ${Math.round(summary.averageTokens)}\n` + markdown += `- **Average Cost:** $${summary.averageCost.toFixed(4)}\n` + markdown += `- **Average Duration:** ${(summary.averageDuration / 1000).toFixed(2)}s\n` + markdown += `- **Total Tool Calls:** ${summary.totalToolCalls}\n` + markdown += `- **Tool Success Rate:** ${(summary.toolSuccessRate * 100).toFixed(2)}%\n\n` + + // Generate tool usage section + markdown += `## Tool Usage\n\n` + markdown += `| Tool | Calls | Failures | Success Rate |\n` + markdown += `| ---- | ----- | -------- | ------------ |\n` + + for (const [toolName, metrics] of Object.entries(summary.toolUsage)) { + const calls = (metrics as any).calls + const failures = (metrics as any).failures + const successRate = calls > 0 ? (1 - failures / calls) * 100 : 100 + + markdown += `| ${toolName} | ${calls} | ${failures} | ${successRate.toFixed(2)}% |\n` + } + + // Generate benchmark results section + markdown += `\n## Benchmark Results\n\n` + + for (const [benchmark, report] of Object.entries(benchmarkReports)) { + markdown += `### ${benchmark}\n\n` + markdown += `- **Runs:** ${report.runs}\n` + markdown += `- **Models:** ${report.models.join(", ")}\n` + markdown += `- **Tasks:** ${report.tasks}\n` + markdown += `- **Success Rate:** ${(report.successRate * 100).toFixed(2)}%\n` + markdown += `- **Average Tokens:** ${Math.round(report.averageTokens)}\n` + markdown += `- **Average Cost:** $${report.averageCost.toFixed(4)}\n` + markdown += `- **Average Duration:** ${(report.averageDuration / 1000).toFixed(2)}s\n\n` + } + + // Generate model results section + markdown += `## Model Results\n\n` + + for (const [model, report] of Object.entries(modelReports)) { + markdown += `### ${model}\n\n` + markdown += `- **Runs:** ${report.runs}\n` + markdown += `- **Benchmarks:** ${report.benchmarks.join(", ")}\n` + markdown += `- **Tasks:** ${report.tasks}\n` + markdown += `- **Success Rate:** ${(report.successRate * 100).toFixed(2)}%\n` + markdown += `- **Average Tokens:** ${Math.round(report.averageTokens)}\n` + markdown += `- **Average Cost:** $${report.averageCost.toFixed(4)}\n` + markdown += `- **Average Duration:** ${(report.averageDuration / 1000).toFixed(2)}s\n\n` + } + + // Add charts using Mermaid + markdown += `## Charts\n\n` + + // Success rate by benchmark chart + markdown += `### Success Rate by Benchmark\n\n` + markdown += "```mermaid\n" + markdown += "graph TD\n" + markdown += " title[Success Rate by Benchmark]\n" + markdown += " style title fill:none,stroke:none\n\n" + + for (const [benchmark, report] of Object.entries(benchmarkReports)) { + const successRate = (report.successRate * 100).toFixed(2) + markdown += ` ${benchmark}[${benchmark}: ${successRate}%]\n` + } + + markdown += "```\n\n" + + // Success rate by model chart + markdown += `### Success Rate by Model\n\n` + markdown += "```mermaid\n" + markdown += "graph TD\n" + markdown += " title[Success Rate by Model]\n" + markdown += " style title fill:none,stroke:none\n\n" + + for (const [model, report] of Object.entries(modelReports)) { + const successRate = (report.successRate * 100).toFixed(2) + markdown += ` ${model.replace(/[-\.]/g, "_")}[${model}: ${successRate}%]\n` + } + + markdown += "```\n\n" + + // Add timestamp + markdown += `\n\n---\n\nReport generated on ${new Date().toISOString()}\n` + + // Write markdown to file + fs.writeFileSync(outputPath, markdown) +} diff --git a/evals/cli/src/utils/results.ts b/evals/cli/src/utils/results.ts new file mode 100644 index 00000000..438ed181 --- /dev/null +++ b/evals/cli/src/utils/results.ts @@ -0,0 +1,79 @@ +import { v4 as uuidv4 } from "uuid" +import { ResultsDatabase } from "../db" +import { Task } from "../adapters/types" + +/** + * Store task result in the database + * @param runId The run ID + * @param task The task that was executed + * @param result The result from the test server + * @param verification The verification result + */ +export async function storeTaskResult(runId: string, task: Task, result: any, verification: any): Promise { + const db = new ResultsDatabase() + const taskId = uuidv4() + + try { + // Extract metrics from the result + const { metrics } = result + const totalToolCalls = metrics?.totalToolCalls || 0 + const totalToolFailures = metrics?.totalToolFailures || 0 + + // Create task with tool metrics + db.createTask(taskId, runId, task.id) + db.completeTask(taskId, verification.success, totalToolCalls, totalToolFailures) + + // Store metrics + if (metrics) { + // Store token metrics + if (metrics.tokensIn) db.addMetric(taskId, "tokensIn", metrics.tokensIn) + if (metrics.tokensOut) db.addMetric(taskId, "tokensOut", metrics.tokensOut) + if (metrics.cost) db.addMetric(taskId, "cost", metrics.cost) + if (metrics.duration) db.addMetric(taskId, "duration", metrics.duration) + + // Store tool call metrics + if (metrics.toolCalls) { + for (const [toolName, callCount] of Object.entries(metrics.toolCalls)) { + const failureCount = metrics.toolFailures?.[toolName] || 0 + db.addToolCall(taskId, toolName, callCount as number, failureCount) + } + } + } + + // Store verification metrics + if (verification.metrics) { + for (const [key, value] of Object.entries(verification.metrics)) { + if (typeof value === "number") { + db.addMetric(taskId, key, value) + } + } + } + + // Store file changes + if (result.files) { + // Store created files + if (result.files.created) { + for (const file of result.files.created) { + db.addFile(taskId, file, "created") + } + } + + // Store modified files + if (result.files.modified) { + for (const file of result.files.modified) { + db.addFile(taskId, file, "modified") + } + } + + // Store deleted files + if (result.files.deleted) { + for (const file of result.files.deleted) { + db.addFile(taskId, file, "deleted") + } + } + } + } finally { + // Close the database connection + db.close() + } +} diff --git a/evals/cli/src/utils/task.ts b/evals/cli/src/utils/task.ts new file mode 100644 index 00000000..8e5970e3 --- /dev/null +++ b/evals/cli/src/utils/task.ts @@ -0,0 +1,52 @@ +import fetch from "node-fetch" +import chalk from "chalk" + +/** + * Send a task to the Cline test server + * @param task The task description to send + * @param apiKey Optional Cline API key to use for the task + * @returns The result of the task execution + */ +export async function sendTaskToServer(task: string, apiKey?: string): Promise { + const SERVER_URL = "http://localhost:9876/task" + + try { + console.log(chalk.blue(`Sending task to server: ${task.substring(0, 100)}${task.length > 100 ? "..." : ""}`)) + + const response = await fetch(SERVER_URL, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + task, + apiKey, + }), + }) + + if (!response.ok) { + const errorText = await response.text() + throw new Error(`Server responded with status ${response.status}: ${errorText}`) + } + + const result = await response.json() + + if (!result.success) { + throw new Error(`Task execution failed: ${result.error || "Unknown error"}`) + } + + if (result.timeout) { + throw new Error("Task execution timed out") + } + + return result + } catch (error: any) { + if (error.code === "ECONNREFUSED") { + throw new Error( + "Could not connect to the test server. Make sure VSCode is running with the Cline extension and the test server is active.", + ) + } + + throw error + } +} diff --git a/evals/cli/src/utils/vscode.ts b/evals/cli/src/utils/vscode.ts new file mode 100644 index 00000000..ceaedf1e --- /dev/null +++ b/evals/cli/src/utils/vscode.ts @@ -0,0 +1,570 @@ +import execa from "execa" +import * as path from "path" +import * as fs from "fs" +import fetch from "node-fetch" +import * as os from "os" +import * as child_process from "child_process" +import { installRequiredExtensions, configureExtensionSettings } from "./extensions" + +// Store temporary directories for cleanup +interface VSCodeResources { + tempUserDataDir: string + tempExtensionsDir: string + vscodePid?: number +} + +// Global map to track resources for each workspace +const workspaceResources = new Map() + +/** + * Spawn a VSCode instance with the Cline extension + * @param workspacePath The workspace path to open + * @param vsixPath Optional path to a VSIX file to install + * @returns The resources created for this VS Code instance + */ +export async function spawnVSCode(workspacePath: string, vsixPath?: string): Promise { + // Ensure the workspace path exists + if (!fs.existsSync(workspacePath)) { + throw new Error(`Workspace path does not exist: ${workspacePath}`) + } + + // If no VSIX path is provided, build one with IS_TEST=true + if (!vsixPath) { + try { + // Build the VSIX with IS_TEST=true + console.log("Building test VSIX...") + const clineRoot = path.resolve(process.cwd(), "..", "..") + await execa("npx", ["vsce", "package"], { + cwd: clineRoot, + env: { + IS_TEST: "true", + }, + stdio: "inherit", + }) + + // Find the generated VSIX file + const files = fs.readdirSync(clineRoot) + const vsixFile = files.find((file) => file.endsWith(".vsix")) + if (vsixFile) { + vsixPath = path.join(clineRoot, vsixFile) + console.log(`Using built VSIX: ${vsixPath}`) + } else { + console.warn("Could not find generated VSIX file") + } + } catch (error) { + console.warn("Failed to build test VSIX:", error) + } + } + + // Create a temporary user data directory for this VS Code instance + const tempUserDataDir = path.join(os.tmpdir(), `vscode-cline-eval-${Date.now()}`) + fs.mkdirSync(tempUserDataDir, { recursive: true }) + console.log(`Created temporary user data directory: ${tempUserDataDir}`) + + // Create a temporary extensions directory to ensure no other extensions are loaded + const tempExtensionsDir = path.join(os.tmpdir(), `vscode-cline-eval-ext-${Date.now()}`) + fs.mkdirSync(tempExtensionsDir, { recursive: true }) + console.log(`Created temporary extensions directory: ${tempExtensionsDir}`) + + // Create settings.json in the temporary user data directory to disable workspace trust + // and configure Cline to auto-open on startup + const settingsDir = path.join(tempUserDataDir, "User") + fs.mkdirSync(settingsDir, { recursive: true }) + const settingsPath = path.join(settingsDir, "settings.json") + const settings = { + // Disable workspace trust + "security.workspace.trust.enabled": false, + "security.workspace.trust.startupPrompt": "never", + "security.workspace.trust.banner": "never", + "security.workspace.trust.emptyWindow": true, + + // Configure startup behavior + "workbench.startupEditor": "none", + + // Auto-open Cline on startup + "cline.autoOpenOnStartup": true, + + // Show the activity bar and sidebar + "workbench.activityBar.visible": true, + "workbench.sideBar.visible": true, + "workbench.view.extension.saoudrizwan.claude-dev-ActivityBar.visible": true, + "workbench.view.alwaysShowHeaderActions": true, + "workbench.editor.openSideBySideDirection": "right", + + // Disable GitLens from opening automatically + "gitlens.views.repositories.autoReveal": false, + "gitlens.views.fileHistory.autoReveal": false, + "gitlens.views.lineHistory.autoReveal": false, + "gitlens.views.compare.autoReveal": false, + "gitlens.views.search.autoReveal": false, + "gitlens.showWelcomeOnInstall": false, + "gitlens.showWhatsNewAfterUpgrades": false, + + // Disable other extensions that might compete for startup focus + "extensions.autoUpdate": false, + } + fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2)) + console.log(`Created settings.json to disable workspace trust and auto-open Cline`) + + // Create keybindings.json to automatically open Cline on startup + const keybindingsPath = path.join(settingsDir, "keybindings.json") + const keybindings = [ + { + key: "alt+c", + command: "workbench.view.extension.saoudrizwan.claude-dev-ActivityBar", + when: "viewContainer.workbench.view.extension.saoudrizwan.claude-dev-ActivityBar.enabled", + }, + { + key: "alt+shift+c", + command: "cline.openInNewTab", + when: "viewContainer.workbench.view.extension.saoudrizwan.claude-dev-ActivityBar.enabled", + }, + ] + fs.writeFileSync(keybindingsPath, JSON.stringify(keybindings, null, 2)) + console.log(`Created keybindings.json to help with Cline activation`) + + // Build the command arguments with custom user data directory + const args = [ + // Use a custom user data directory to isolate this instance + "--user-data-dir", + tempUserDataDir, + // Use a custom extensions directory to ensure only our extension is loaded + "--extensions-dir", + tempExtensionsDir, + // Disable workspace trust + "--disable-workspace-trust", + "-n", + workspacePath, + // Force the extension to be activated on startup + "--start-up-extension", + "saoudrizwan.claude-dev", + // Run a command on startup to open Cline + "--command", + "workbench.view.extension.saoudrizwan.claude-dev-ActivityBar", + // Additional flags to help with extension activation + "--disable-gpu=false", + "--max-memory=4096", + ] + + // Create a startup script to run commands after VS Code launches + const startupScriptPath = path.join(settingsDir, "startup.js") + const startupScript = ` + // This script will be executed when VS Code starts + setTimeout(() => { + // Try to open Cline in the sidebar + require('vscode').commands.executeCommand('workbench.view.extension.saoudrizwan.claude-dev-ActivityBar'); + + // Also try to open Cline in a tab as a fallback + setTimeout(() => { + require('vscode').commands.executeCommand('cline.openInNewTab'); + }, 5000); + }, 5000); + ` + fs.writeFileSync(startupScriptPath, startupScript) + console.log(`Created startup script to activate Cline`) + + // If a VSIX is provided, install it + if (vsixPath) { + if (!fs.existsSync(vsixPath)) { + throw new Error(`VSIX file does not exist: ${vsixPath}`) + } + args.unshift("--install-extension", vsixPath) + } + + // Install required extensions + console.log("Installing required VSCode extensions...") + await installRequiredExtensions(tempExtensionsDir) + + // Configure extension settings + console.log("Configuring extension settings...") + configureExtensionSettings(tempUserDataDir) + + // Execute the command + try { + // We don't need to install extensions globally anymore since we're using a custom user data directory + // The VSIX will be installed in the isolated environment if provided in the args + + // Launch VS Code + console.log("Launching VS Code...") + await execa("code", args, { + stdio: "inherit", + }) + + // Wait longer for VSCode to initialize and extension to load + console.log("Waiting for VS Code to initialize...") + await new Promise((resolve) => setTimeout(resolve, 30000)) + + // Create a JavaScript file that will be loaded as a VS Code extension + const extensionDir = path.join(tempExtensionsDir, "cline-activator") + fs.mkdirSync(extensionDir, { recursive: true }) + + // Create package.json for the extension + const packageJsonPath = path.join(extensionDir, "package.json") + const packageJson = { + name: "cline-activator", + displayName: "Cline Activator", + description: "Activates Cline and starts the test server", + version: "0.0.1", + engines: { + vscode: "^1.60.0", + }, + main: "./extension.js", + activationEvents: ["*"], + contributes: { + commands: [ + { + command: "cline-activator.activate", + title: "Activate Cline", + }, + ], + }, + } + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)) + + // Create extension.js + const extensionJsPath = path.join(extensionDir, "extension.js") + const extensionJs = ` + const vscode = require('vscode'); + + /** + * @param {vscode.ExtensionContext} context + */ + function activate(context) { + console.log('Cline Activator is now active!'); + + // Register the command to activate Cline + let disposable = vscode.commands.registerCommand('cline-activator.activate', async function () { + try { + // Make sure the Cline extension is activated + const extension = vscode.extensions.getExtension('saoudrizwan.claude-dev'); + if (!extension) { + console.error('Cline extension not found'); + return; + } + + if (!extension.isActive) { + console.log('Activating Cline extension...'); + await extension.activate(); + } + + // Show the Cline sidebar + console.log('Opening Cline sidebar...'); + await vscode.commands.executeCommand('workbench.view.extension.saoudrizwan.claude-dev-ActivityBar'); + + // Wait a moment for the sidebar to initialize + await new Promise(resolve => setTimeout(resolve, 2000)); + + // Also open Cline in a tab as a fallback + console.log('Opening Cline in a tab...'); + await vscode.commands.executeCommand('cline.openInNewTab'); + + // Wait a moment for the tab to initialize + await new Promise(resolve => setTimeout(resolve, 2000)); + + // Create the test server if it doesn't exist + console.log('Creating test server...'); + + // Get the visible webview instance + const clineRootPath = '${path.resolve(process.cwd(), "..", "..")}'; + const visibleWebview = require(path.join(clineRootPath, 'src', 'core', 'webview')).WebviewProvider.getVisibleInstance(); + if (visibleWebview) { + require(path.join(clineRootPath, 'src', 'services', 'test', 'TestServer')).createTestServer(visibleWebview); + console.log('Test server created successfully'); + } else { + console.error('No visible webview instance found'); + } + } catch (error) { + console.error('Error activating Cline:', error); + } + }); + + context.subscriptions.push(disposable); + + // Automatically run the command after a delay + setTimeout(() => { + vscode.commands.executeCommand('cline-activator.activate'); + }, 5000); + } + + function deactivate() {} + + module.exports = { + activate, + deactivate + } + ` + fs.writeFileSync(extensionJsPath, extensionJs) + console.log(`Created Cline Activator extension`) + + // Try multiple approaches to activate the extension + let serverStarted = false + + // Create an activation script to run in VS Code + const activationScriptPath = path.join(settingsDir, "activate-cline.js") + const activationScript = ` + // This script will be executed to activate Cline and start the test server + const vscode = require('vscode'); + + // Execute the cline-activator.activate command + vscode.commands.executeCommand('cline-activator.activate'); + ` + fs.writeFileSync(activationScriptPath, activationScript) + console.log(`Created activation script to run in VS Code`) + + // Execute the activation script + try { + console.log("Executing activation script to start Cline and test server...") + await execa( + "code", + [ + "--user-data-dir", + tempUserDataDir, + "--extensions-dir", + tempExtensionsDir, + "--folder-uri", + `file://${workspacePath}`, + "--execute", + activationScriptPath, + ], + { + stdio: "inherit", + }, + ) + + // Wait for the test server to start + console.log("Waiting for test server to start...") + for (let i = 0; i < 30; i++) { + try { + // Try to connect to the test server + const response = await fetch("http://localhost:9876/task", { + method: "OPTIONS", + headers: { + "Content-Type": "application/json", + }, + }) + + if (response.status === 204) { + console.log("Test server is running!") + serverStarted = true + break + } + } catch (error) { + // Server not started yet, wait and try again + await new Promise((resolve) => setTimeout(resolve, 1000)) + } + } + } catch (error) { + console.warn("Failed to execute activation script:", error) + } + + if (!serverStarted) { + console.warn("Test server did not start after multiple attempts") + console.log("You may need to manually open the Cline extension in VS Code") + } + + // Store the resources for this workspace + const resources: VSCodeResources = { + tempUserDataDir, + tempExtensionsDir, + } + + // Store in the global map + workspaceResources.set(workspacePath, resources) + + // Return the resources + return resources + } catch (error: any) { + throw new Error(`Failed to spawn VSCode: ${error.message}`) + } +} + +/** + * Clean up VS Code resources and shut down the test server + * @param workspacePath The workspace path to clean up resources for + */ +export async function cleanupVSCode(workspacePath: string): Promise { + console.log(`Cleaning up VS Code resources for workspace: ${workspacePath}`) + + // Get the resources for this workspace + const resources = workspaceResources.get(workspacePath) + if (!resources) { + console.log(`No resources found for workspace: ${workspacePath}`) + return + } + + // Try to shut down the test server + try { + console.log("Shutting down test server...") + await fetch("http://localhost:9876/shutdown", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }).catch(() => { + // Ignore errors, the server might already be down + }) + } catch (error) { + console.warn(`Error shutting down test server: ${error}`) + } + + // Try to gracefully close VS Code instead of killing it + try { + console.log("Attempting to gracefully close VS Code...") + + // Create a settings file that will disable the crash reporter and the exit confirmation dialog + const settingsDir = path.join(resources.tempUserDataDir, "User") + const settingsPath = path.join(settingsDir, "settings.json") + + // Read existing settings if they exist + let settings = {} + if (fs.existsSync(settingsPath)) { + try { + settings = JSON.parse(fs.readFileSync(settingsPath, "utf8")) + } catch (error) { + console.warn(`Error reading settings file: ${error}`) + } + } + + // Update settings to disable crash reporter and exit confirmation + settings = { + ...settings, + "window.confirmBeforeClose": "never", + "telemetry.enableCrashReporter": false, + "window.restoreWindows": "none", + "window.newWindowDimensions": "default", + } + + // Write updated settings + fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2)) + + // On macOS, use AppleScript to quit VS Code gracefully + if (process.platform === "darwin") { + try { + // First try AppleScript to quit VS Code gracefully + await execa("osascript", ["-e", 'tell application "Visual Studio Code" to quit']) + + // Wait a moment for VS Code to close + await new Promise((resolve) => setTimeout(resolve, 2000)) + } catch (appleScriptError) { + console.warn(`Error using AppleScript to quit VS Code: ${appleScriptError}`) + } + } else if (process.platform === "win32") { + // On Windows, try to use taskkill without /F first + try { + await execa("taskkill", ["/IM", "code.exe"]) + + // Wait a moment for VS Code to close + await new Promise((resolve) => setTimeout(resolve, 2000)) + } catch (taskkillError) { + console.warn(`Error using taskkill to quit VS Code: ${taskkillError}`) + } + } else { + // On Linux, try to use SIGTERM first + try { + // Find VS Code processes + const { stdout } = await execa("ps", ["aux"]) + const lines = stdout.split("\n") + + for (const line of lines) { + if (line.includes(resources.tempUserDataDir)) { + const parts = line.trim().split(/\s+/) + const pid = parseInt(parts[1]) + + if (pid && !isNaN(pid)) { + console.log(`Sending SIGTERM to VS Code process with PID: ${pid}`) + try { + // Use SIGTERM instead of SIGKILL for a graceful shutdown + process.kill(pid, "SIGTERM") + } catch (killError) { + console.warn(`Failed to terminate process ${pid}: ${killError}`) + } + } + } + } + + // Wait a moment for VS Code to close + await new Promise((resolve) => setTimeout(resolve, 2000)) + } catch (psError) { + console.warn(`Error listing processes: ${psError}`) + } + } + + // If graceful methods failed, fall back to forceful termination as a last resort + // Check if VS Code is still running with the temp user data dir + let vsCodeStillRunning = false + + if (process.platform !== "win32") { + try { + const { stdout } = await execa("ps", ["aux"]) + vsCodeStillRunning = stdout.split("\n").some((line) => line.includes(resources.tempUserDataDir)) + } catch (error) { + console.warn(`Error checking if VS Code is still running: ${error}`) + } + } else { + try { + const { stdout } = await execa("tasklist", ["/FI", `IMAGENAME eq code.exe`]) + vsCodeStillRunning = stdout.includes("code.exe") + } catch (error) { + console.warn(`Error checking if VS Code is still running: ${error}`) + } + } + + // If VS Code is still running, use forceful termination as a last resort + if (vsCodeStillRunning) { + console.log("Graceful shutdown failed, falling back to forceful termination...") + + if (process.platform === "win32") { + try { + await execa("taskkill", ["/IM", "code.exe", "/F"]) + } catch (error) { + console.warn(`Error forcefully terminating VS Code: ${error}`) + } + } else { + try { + const { stdout } = await execa("ps", ["aux"]) + const lines = stdout.split("\n") + + for (const line of lines) { + if (line.includes(resources.tempUserDataDir)) { + const parts = line.trim().split(/\s+/) + const pid = parseInt(parts[1]) + + if (pid && !isNaN(pid)) { + console.log(`Forcefully killing VS Code process with PID: ${pid}`) + try { + process.kill(pid, "SIGKILL") + } catch (killError) { + console.warn(`Failed to kill process ${pid}: ${killError}`) + } + } + } + } + } catch (error) { + console.warn(`Error forcefully terminating VS Code: ${error}`) + } + } + } + } catch (error) { + console.warn(`Error closing VS Code: ${error}`) + } + + // Clean up temporary directories + try { + console.log(`Removing temporary user data directory: ${resources.tempUserDataDir}`) + fs.rmSync(resources.tempUserDataDir, { recursive: true, force: true }) + } catch (error) { + console.warn(`Error removing temporary user data directory: ${error}`) + } + + try { + console.log(`Removing temporary extensions directory: ${resources.tempExtensionsDir}`) + fs.rmSync(resources.tempExtensionsDir, { recursive: true, force: true }) + } catch (error) { + console.warn(`Error removing temporary extensions directory: ${error}`) + } + + // Remove from the global map + workspaceResources.delete(workspacePath) + + console.log("Cleanup completed") +} diff --git a/evals/cli/tsconfig.json b/evals/cli/tsconfig.json new file mode 100644 index 00000000..7e4efc07 --- /dev/null +++ b/evals/cli/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "lib": ["ES2020"], + "declaration": true, + "outDir": "dist", + "rootDir": "src", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} diff --git a/package-lock.json b/package-lock.json index 8e0d5987..cc536b29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,22 @@ { "name": "cline-shengsuan", - "version": "3.12.0", + "version": "3.12.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "claude-dev", - "version": "3.12.0", + "version": "3.12.3", "license": "Apache-2.0", "dependencies": { "@anthropic-ai/bedrock-sdk": "^0.12.4", "@anthropic-ai/sdk": "^0.37.0", "@anthropic-ai/vertex-sdk": "^0.6.4", "@aws-sdk/client-bedrock-runtime": "^3.758.0", + "@bufbuild/protobuf": "^2.2.5", "@google-cloud/vertexai": "^1.9.3", "@google/generative-ai": "^0.18.0", + "@grpc/grpc-js": "^1.9.15", "@mistralai/mistralai": "^1.5.0", "@modelcontextprotocol/sdk": "^1.7.0", "@opentelemetry/api": "^1.4.1", @@ -79,15 +81,18 @@ "@vscode/test-cli": "^0.0.9", "@vscode/test-electron": "^2.4.0", "chai": "^4.3.10", + "chalk": "^5.3.0", "esbuild": "^0.25.0", "eslint": "^8.57.0", "husky": "^9.1.7", "npm-run-all": "^4.1.5", "prettier": "^3.3.3", + "protoc-gen-ts": "^0.8.7", "proxyquire": "^2.1.3", "should": "^13.2.3", "sinon": "^19.0.2", "ts-node": "^10.9.2", + "ts-proto": "^2.6.1", "typescript": "^5.4.5" }, "engines": { @@ -3957,6 +3962,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@bufbuild/protobuf": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.2.5.tgz", + "integrity": "sha512-/g5EzJifw5GF8aren8wZ/G5oMuPoGeS6MQD3ca8ddcvdXR5UELUfdTZITCGNhNXynY/AYl3Z4plmxdj/tRl/hQ==", + "license": "(Apache-2.0 AND BSD-3-Clause)" + }, "node_modules/@changesets/apply-release-plan": { "version": "7.0.8", "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-7.0.8.tgz", @@ -5566,6 +5577,7 @@ "version": "1.9.15", "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.15.tgz", "integrity": "sha512-nqE7Hc0AzI+euzUwDAy0aY5hCp10r734gMGRdU+qOPX0XSceI2ULrcXB5U2xSc5VkWwalCj4M7GzCAygZl2KoQ==", + "license": "Apache-2.0", "dependencies": { "@grpc/proto-loader": "^0.7.8", "@types/node": ">=12.12.47" @@ -9919,6 +9931,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/case-anything": { + "version": "2.1.13", + "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.13.tgz", + "integrity": "sha512-zlOQ80VrQ2Ue+ymH5OuM/DlDq64mEm+B9UTdHULv5osUMD6HalNTblf2b1u/m6QecjsnOkBpqVZ+XPwIVsy7Ng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.13" + }, + "funding": { + "url": "https://github.com/sponsors/mesqueeb" + } + }, "node_modules/chai": { "version": "4.3.10", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", @@ -9938,35 +9963,18 @@ } }, "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", + "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", "dev": true, "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, "engines": { - "node": ">=10" + "node": "^12.17.0 || ^14.13 || >=16.0.0" }, "funding": { "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/chalk/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", @@ -10612,6 +10620,19 @@ "node": ">=8" } }, + "node_modules/detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "detect-libc": "bin/detect-libc.js" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/devtools-protocol": { "version": "0.0.1342118", "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1342118.tgz", @@ -10722,6 +10743,16 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dprint-node": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/dprint-node/-/dprint-node-1.0.8.tgz", + "integrity": "sha512-iVKnUtYfGrYcW1ZAlfR/F59cUVL8QIhWoBJoSjkkdua/dkWIgjZfiLMeTjiB06X0ZLkQ0M2C1VbUj/CxkIf1zg==", + "dev": true, + "license": "MIT", + "dependencies": { + "detect-libc": "^1.0.3" + } + }, "node_modules/duck": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/duck/-/duck-0.1.12.tgz", @@ -11192,6 +11223,23 @@ "concat-map": "0.0.1" } }, + "node_modules/eslint/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/eslint/node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -11240,6 +11288,19 @@ "node": ">=8" } }, + "node_modules/eslint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/espree": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", @@ -13659,6 +13720,36 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/log-symbols/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/log-symbols/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/long": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/long/-/long-5.2.4.tgz", @@ -14768,19 +14859,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/ora/node_modules/chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "node_modules/ora/node_modules/emoji-regex": { "version": "10.3.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.3.0.tgz", @@ -15366,6 +15444,20 @@ "node": ">=12.0.0" } }, + "node_modules/protoc-gen-ts": { + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/protoc-gen-ts/-/protoc-gen-ts-0.8.7.tgz", + "integrity": "sha512-jr4VJey2J9LVYCV7EVyVe53g1VMw28cCmYJhBe5e3YX5wiyiDwgxWxeDf9oTqAe4P1bN/YGAkW2jhlH8LohwiQ==", + "dev": true, + "license": "MIT", + "bin": { + "protoc-gen-ts": "protoc-gen-ts.js" + }, + "funding": { + "type": "individual", + "url": "https://www.buymeacoffee.com/thesayyn" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -16970,6 +17062,42 @@ "node": ">=0.3.1" } }, + "node_modules/ts-poet": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/ts-poet/-/ts-poet-6.11.0.tgz", + "integrity": "sha512-r5AGF8vvb+GjBsnqiTqbLhN1/U2FJt6BI+k0dfCrkKzWvUhNlwMmq9nDHuucHs45LomgHjZPvYj96dD3JawjJA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "dprint-node": "^1.0.8" + } + }, + "node_modules/ts-proto": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/ts-proto/-/ts-proto-2.7.0.tgz", + "integrity": "sha512-BGHjse2wTOeswOqnnPKinpxmbaRd882so/e1En6ww59YMG7AO9Kg4vPpJcbVfrpBixPRDqHafXD/RDyd2T99GA==", + "dev": true, + "license": "ISC", + "dependencies": { + "@bufbuild/protobuf": "^2.0.0", + "case-anything": "^2.1.13", + "ts-poet": "^6.7.0", + "ts-proto-descriptors": "2.0.0" + }, + "bin": { + "protoc-gen-ts_proto": "protoc-gen-ts_proto" + } + }, + "node_modules/ts-proto-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ts-proto-descriptors/-/ts-proto-descriptors-2.0.0.tgz", + "integrity": "sha512-wHcTH3xIv11jxgkX5OyCSFfw27agpInAd6yh89hKG6zqIXnjW9SYqSER2CVQxdPj4czeOhGagNvZBEbJPy7qkw==", + "dev": true, + "license": "ISC", + "dependencies": { + "@bufbuild/protobuf": "^2.0.0" + } + }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", diff --git a/package.json b/package.json index 1c0628c2..894e2937 100644 --- a/package.json +++ b/package.json @@ -118,6 +118,11 @@ "command": "clineShengsuan.fixWithCline", "title": "使用 Cline 修改", "category": "ClineShengsuan" + }, + { + "command": "clineShengsuan.focusChatInput", + "title": "跳转到对话窗口", + "category": "ClineShengsuan" } ], "keybindings": [ @@ -292,6 +297,7 @@ "watch:esbuild:test": "IS_TEST=true node esbuild.js --watch", "watch:tsc": "tsc --noEmit --watch --project tsconfig.json", "package": "npm run build:webview && npm run check-types && npm run lint && node esbuild.js --production", + "protos": "node proto/build-proto.js && prettier src/shared/proto --write && prettier src/core/controller --write", "package:test": "IS_TEST=true npm run build:webview:test && npm run check-types && npm run lint && IS_TEST=true node esbuild.js --production", "build:webview:test": "cd webview-ui && IS_TEST=true npm run build", "watch:test": "IS_TEST=true npm-run-all -p watch:tsc watch:esbuild:test", @@ -336,15 +342,18 @@ "@vscode/test-cli": "^0.0.9", "@vscode/test-electron": "^2.4.0", "chai": "^4.3.10", + "chalk": "^5.3.0", "esbuild": "^0.25.0", "eslint": "^8.57.0", "husky": "^9.1.7", "npm-run-all": "^4.1.5", "prettier": "^3.3.3", + "protoc-gen-ts": "^0.8.7", "proxyquire": "^2.1.3", "should": "^13.2.3", "sinon": "^19.0.2", "ts-node": "^10.9.2", + "ts-proto": "^2.6.1", "typescript": "^5.4.5" }, "dependencies": { @@ -352,8 +361,10 @@ "@anthropic-ai/sdk": "^0.37.0", "@anthropic-ai/vertex-sdk": "^0.6.4", "@aws-sdk/client-bedrock-runtime": "^3.758.0", + "@bufbuild/protobuf": "^2.2.5", "@google-cloud/vertexai": "^1.9.3", "@google/generative-ai": "^0.18.0", + "@grpc/grpc-js": "^1.9.15", "@mistralai/mistralai": "^1.5.0", "@modelcontextprotocol/sdk": "^1.7.0", "@opentelemetry/api": "^1.4.1", diff --git a/proto/browser.proto b/proto/browser.proto new file mode 100644 index 00000000..cf7d0efd --- /dev/null +++ b/proto/browser.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package cline; + +import "common.proto"; + +service BrowserService { + rpc getBrowserConnectionInfo(EmptyRequest) returns (BrowserConnectionInfo); + rpc testBrowserConnection(StringRequest) returns (BrowserConnection); +} + +message BrowserConnectionInfo { + bool is_connected = 1; + bool is_remote = 2; + optional string host = 3; +} + +message BrowserConnection { + bool success = 1; + string message = 2; + optional string endpoint = 3; +} diff --git a/proto/build-proto.js b/proto/build-proto.js new file mode 100755 index 00000000..ca4b17bc --- /dev/null +++ b/proto/build-proto.js @@ -0,0 +1,157 @@ +#!/usr/bin/env node + +import * as fs from "fs/promises" +import * as path from "path" +import { execSync } from "child_process" +import { globby } from "globby" +import chalk from "chalk" + +// Get script directory and root directory +const SCRIPT_DIR = path.dirname(new URL(import.meta.url).pathname) +const ROOT_DIR = path.resolve(SCRIPT_DIR, "..") + +async function main() { + console.log(chalk.bold.blue("Starting Protocol Buffer code generation...")) + + // Check if protoc is installed + try { + const options = { stdio: "ignore" } + execSync("protoc --version", options) + } catch (error) { + console.warn(chalk.yellow("Warning: protoc is not installed. Skipping proto generation.")) + console.warn(chalk.yellow("To install Protocol Buffers compiler, visit: https://grpc.io/docs/protoc-installation/")) + process.exit(0) // Exit with success as requested + } + + // Check if ts-proto plugin is available + const TS_PROTO_PLUGIN = path.join(ROOT_DIR, "node_modules", ".bin", "protoc-gen-ts_proto") + try { + await fs.access(TS_PROTO_PLUGIN) + } catch (error) { + console.error(chalk.red("Error: ts-proto plugin not found at"), TS_PROTO_PLUGIN) + console.error(chalk.red('Please run "npm install" to install the required dependencies.')) + process.exit(1) + } + + // Define output directories + const TS_OUT_DIR = path.join(ROOT_DIR, "src", "shared", "proto") + + // Create output directory if it doesn't exist + await fs.mkdir(TS_OUT_DIR, { recursive: true }) + + // Clean up existing generated files + console.log(chalk.cyan("Cleaning up existing generated TypeScript files...")) + const existingFiles = await globby("**/*.ts", { cwd: TS_OUT_DIR }) + for (const file of existingFiles) { + await fs.unlink(path.join(TS_OUT_DIR, file)) + } + + // Process all proto files + console.log(chalk.cyan("Processing proto files from"), SCRIPT_DIR) + const protoFiles = await globby("**/*.proto", { cwd: SCRIPT_DIR }) + + for (const protoFile of protoFiles) { + console.log(chalk.cyan(`Generating TypeScript code for ${protoFile}...`)) + + // Build the protoc command with proper path handling for cross-platform + const protocCommand = [ + "protoc", + `--plugin=protoc-gen-ts_proto="${TS_PROTO_PLUGIN}"`, + `--ts_proto_out="${TS_OUT_DIR}"`, + "--ts_proto_opt=outputServices=generic-definitions,env=node,esModuleInterop=true,useDate=false,useOptionals=messages", + `--proto_path="${SCRIPT_DIR}"`, + `"${path.join(SCRIPT_DIR, protoFile)}"`, + ].join(" ") + + try { + const execOptions = { + stdio: "inherit", + } + execSync(protocCommand, execOptions) + } catch (error) { + console.error(chalk.red(`Error generating TypeScript for ${protoFile}:`), error) + process.exit(1) + } + } + + console.log(chalk.green("Protocol Buffer code generation completed successfully.")) + console.log(chalk.green(`TypeScript files generated in: ${TS_OUT_DIR}`)) + + // Generate method registration files + await generateMethodRegistrations() + + // Make the script executable + try { + await fs.chmod(path.join(SCRIPT_DIR, "build-proto.js"), 0o755) + } catch (error) { + console.warn(chalk.yellow("Warning: Could not make script executable:"), error) + } +} + +async function generateMethodRegistrations() { + console.log(chalk.cyan("Generating method registration files...")) + + const serviceDirs = [ + path.join(ROOT_DIR, "src", "core", "controller", "browser"), + // Add more service directories here as needed + ] + + for (const serviceDir of serviceDirs) { + try { + await fs.access(serviceDir) + } catch (error) { + console.log(chalk.gray(`Skipping ${serviceDir} - directory does not exist`)) + continue + } + + const serviceName = path.basename(serviceDir) + const registryFile = path.join(serviceDir, "methods.ts") + + console.log(chalk.cyan(`Generating method registrations for ${serviceName}...`)) + + // Get all TypeScript files in the service directory + const files = await globby("*.ts", { cwd: serviceDir }) + + // Filter out index.ts and methods.ts + const implementationFiles = files.filter((file) => file !== "index.ts" && file !== "methods.ts") + + // Create the output file with header + let content = `// AUTO-GENERATED FILE - DO NOT MODIFY DIRECTLY +// Generated by proto/build-proto.js + +// Import all method implementations +import { registerMethod } from "./index"\n` + + // Add imports for all implementation files + for (const file of implementationFiles) { + const baseName = path.basename(file, ".ts") + content += `import { ${baseName} } from "./${baseName}"\n` + } + + // Add registration function + content += `\n// Register all ${serviceName} service methods +export function registerAllMethods(): void { +\t// Register each method with the registry\n` + + // Add registration statements + for (const file of implementationFiles) { + const baseName = path.basename(file, ".ts") + content += `\tregisterMethod("${baseName}", ${baseName})\n` + } + + // Close the function + content += `}` + + // Write the file + await fs.writeFile(registryFile, content) + console.log(chalk.green(`Generated ${registryFile}`)) + } + + console.log(chalk.green("Method registration files generated successfully.")) +} + +// Run the main function +main().catch((error) => { + console.error(chalk.red("Error:"), error) + process.exit(1) +}) diff --git a/proto/common.proto b/proto/common.proto new file mode 100644 index 00000000..34e93587 --- /dev/null +++ b/proto/common.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package cline; + +message Metadata { +} + +message EmptyRequest { + Metadata metadata = 1; +} + +message Empty { +} + +message StringRequest { + Metadata metadata = 1; + string value = 2; +} + +message String { + string value = 1; +} + +message Int64Request { + Metadata metadata = 1; + int64 value = 2; +} + +message Int64 { + int64 value = 1; +} + +message BytesRequest { + Metadata metadata = 1; + bytes value = 2; +} + +message Bytes { + bytes value = 1; +} diff --git a/proto/package.json b/proto/package.json new file mode 100644 index 00000000..bedb411a --- /dev/null +++ b/proto/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/src/api/providers/openai-native.ts b/src/api/providers/openai-native.ts index b81b5d6a..2acc8793 100644 --- a/src/api/providers/openai-native.ts +++ b/src/api/providers/openai-native.ts @@ -12,7 +12,7 @@ import { import { convertToOpenAiMessages } from "../transform/openai-format" import { calculateApiCostOpenAI } from "../../utils/cost" import { ApiStream } from "../transform/stream" -import { ChatCompletionReasoningEffort } from "openai/resources/chat/completions.mjs" +import type { ChatCompletionReasoningEffort } from "openai/resources/chat/completions" export class OpenAiNativeHandler implements ApiHandler { private options: ApiHandlerOptions @@ -50,7 +50,7 @@ export class OpenAiNativeHandler implements ApiHandler { case "o1": case "o1-preview": case "o1-mini": { - // o1 doesnt support streaming, non-1 temp, or system prompt + // o1 doesn't support streaming, non-1 temp, or system prompt const response = await this.client.chat.completions.create({ model: model.id, messages: [{ role: "user", content: systemPrompt }, ...convertToOpenAiMessages(messages)], @@ -64,6 +64,8 @@ export class OpenAiNativeHandler implements ApiHandler { break } + case "o4-mini": + case "o3": case "o3-mini": { const stream = await this.client.chat.completions.create({ model: model.id, diff --git a/src/api/providers/openai.ts b/src/api/providers/openai.ts index afcd4922..fcd9bae6 100644 --- a/src/api/providers/openai.ts +++ b/src/api/providers/openai.ts @@ -6,7 +6,7 @@ import { ApiHandler } from "../index" import { convertToOpenAiMessages } from "../transform/openai-format" import { ApiStream } from "../transform/stream" import { convertToR1Format } from "../transform/r1-format" -import { ChatCompletionReasoningEffort } from "openai/resources/chat/completions.mjs" +import type { ChatCompletionReasoningEffort } from "openai/resources/chat/completions" export class OpenAiHandler implements ApiHandler { private options: ApiHandlerOptions @@ -21,11 +21,13 @@ export class OpenAiHandler implements ApiHandler { baseURL: this.options.openAiBaseUrl, apiKey: this.options.openAiApiKey, apiVersion: this.options.azureApiVersion || azureOpenAiDefaultApiVersion, + defaultHeaders: this.options.openAiHeaders, }) } else { this.client = new OpenAI({ baseURL: this.options.openAiBaseUrl, apiKey: this.options.openAiApiKey, + defaultHeaders: this.options.openAiHeaders, }) } } @@ -35,7 +37,7 @@ export class OpenAiHandler implements ApiHandler { const modelId = this.options.openAiModelId ?? "" const isDeepseekReasoner = modelId.includes("deepseek-reasoner") const isR1FormatRequired = this.options.openAiModelInfo?.isR1FormatRequired ?? false - const isO3Mini = modelId.includes("o3-mini") + const isReasoningModelFamily = modelId.includes("o3") || modelId.includes("o4") let openAiMessages: OpenAI.Chat.ChatCompletionMessageParam[] = [ { role: "system", content: systemPrompt }, @@ -55,7 +57,7 @@ export class OpenAiHandler implements ApiHandler { openAiMessages = convertToR1Format([{ role: "user", content: systemPrompt }, ...messages]) } - if (isO3Mini) { + if (isReasoningModelFamily) { openAiMessages = [{ role: "developer", content: systemPrompt }, ...convertToOpenAiMessages(messages)] temperature = undefined // does not support temperature reasoningEffort = (this.options.o3MiniReasoningEffort as ChatCompletionReasoningEffort) || "medium" diff --git a/src/api/providers/types.ts b/src/api/providers/types.ts index c90dc7c5..929b260c 100644 --- a/src/api/providers/types.ts +++ b/src/api/providers/types.ts @@ -1,6 +1,13 @@ // For the following openrouter error type sources, see the docs here: // https://openrouter.ai/docs/api-reference/errors +export interface LanguageModelChatSelector { + vendor?: string + family?: string + version?: string + id?: string +} + export type OpenRouterErrorResponse = { error: { message: string diff --git a/src/api/providers/vertex.ts b/src/api/providers/vertex.ts index 3a4fc06f..74de4da4 100644 --- a/src/api/providers/vertex.ts +++ b/src/api/providers/vertex.ts @@ -5,6 +5,7 @@ import { ApiHandler } from "../" import { ApiHandlerOptions, ModelInfo, vertexDefaultModelId, VertexModelId, vertexModels } from "../../shared/api" import { ApiStream } from "../transform/stream" import { VertexAI } from "@google-cloud/vertexai" +import { calculateApiCostOpenAI } from "../../utils/cost" // https://docs.anthropic.com/en/api/claude-on-vertex-ai export class VertexHandler implements ApiHandler { @@ -266,6 +267,17 @@ export class VertexHandler implements ApiHandler { } } } + // Handle token usage metadata + const { usageMetadata } = await streamingResult.response + if (usageMetadata) { + const { promptTokenCount = 0, candidatesTokenCount = 0 } = usageMetadata + yield { + type: "usage", + inputTokens: promptTokenCount, + outputTokens: candidatesTokenCount, + totalCost: calculateApiCostOpenAI(model.info, promptTokenCount, candidatesTokenCount, 0, 0), + } + } } } diff --git a/src/api/providers/vscode-lm.ts b/src/api/providers/vscode-lm.ts index 33a78e54..db75197f 100644 --- a/src/api/providers/vscode-lm.ts +++ b/src/api/providers/vscode-lm.ts @@ -6,6 +6,7 @@ import { ApiStream } from "../transform/stream" import { convertToVsCodeLmMessages } from "../transform/vscode-lm-format" import { SELECTOR_SEPARATOR, stringifyVsCodeLmModelSelector } from "../../shared/vsCodeSelectorUtils" import { ApiHandlerOptions, ModelInfo, openAiModelInfoSaneDefaults } from "../../shared/api" +import type { LanguageModelChatSelector as LanguageModelChatSelectorFromTypes } from "./types" // Cline does not update VSCode type definitions or engine requirements to maintain compatibility. // This declaration (as seen in src/integrations/TerminalManager.ts) provides types for the Language Model API in newer versions of VSCode. @@ -19,12 +20,7 @@ declare module "vscode" { Auto = 1, Required = 2, } - interface LanguageModelChatSelector { - vendor?: string - family?: string - version?: string - id?: string - } + interface LanguageModelChatSelector extends LanguageModelChatSelectorFromTypes {} interface LanguageModelChatTool { name: string description: string diff --git a/src/api/providers/xai.ts b/src/api/providers/xai.ts index 28fcca36..ed58cdda 100644 --- a/src/api/providers/xai.ts +++ b/src/api/providers/xai.ts @@ -4,7 +4,7 @@ import { ApiHandler } from "../" import { ApiHandlerOptions, XAIModelId, ModelInfo, xaiDefaultModelId, xaiModels } from "../../shared/api" import { convertToOpenAiMessages } from "../transform/openai-format" import { ApiStream } from "../transform/stream" -import { ChatCompletionReasoningEffort } from "openai/resources/chat/completions.mjs" +import { ChatCompletionReasoningEffort } from "openai/resources/chat/completions" export class XAIHandler implements ApiHandler { private options: ApiHandlerOptions @@ -34,6 +34,7 @@ export class XAIHandler implements ApiHandler { temperature: 0, messages: [{ role: "system", content: systemPrompt }, ...convertToOpenAiMessages(messages)], stream: true, + stream_options: { include_usage: true }, reasoning_effort: reasoningEffort, }) @@ -46,7 +47,7 @@ export class XAIHandler implements ApiHandler { } } - if ("reasoning_content" in delta && delta.reasoning_content) { + if (delta && "reasoning_content" in delta && delta.reasoning_content) { yield { type: "reasoning", // @ts-ignore-next-line diff --git a/src/api/transform/vscode-lm-format.test.ts b/src/api/transform/vscode-lm-format.test.ts new file mode 100644 index 00000000..8c9bbb30 --- /dev/null +++ b/src/api/transform/vscode-lm-format.test.ts @@ -0,0 +1,211 @@ +// This file contains `declare module "vscode"` so we must import it. +import "../providers/vscode-lm" +import { describe, it } from "mocha" +import "should" +import * as vscode from "vscode" +import { Anthropic } from "@anthropic-ai/sdk" +import { asObjectSafe, convertToAnthropicRole, convertToVsCodeLmMessages, convertToAnthropicMessage } from "./vscode-lm-format" + +describe("asObjectSafe", () => { + it("should handle falsy values", () => { + asObjectSafe(0).should.deepEqual({}) + asObjectSafe("").should.deepEqual({}) + asObjectSafe(null).should.deepEqual({}) + asObjectSafe(undefined).should.deepEqual({}) + }) + + it("should parse valid JSON strings", () => { + asObjectSafe('{"key": "value"}').should.deepEqual({ key: "value" }) + }) + + it("should return an empty object for invalid JSON strings", () => { + asObjectSafe("invalid json").should.deepEqual({}) + }) + + it("should convert objects to plain objects", () => { + const input = { prop: "value" } + asObjectSafe(input).should.deepEqual(input) + asObjectSafe(input).should.not.equal(input) // Should be a new object + }) + + it("should convert arrays to plain objects", () => { + const input = ["hello world"] + asObjectSafe(input).should.deepEqual({ 0: "hello world" }) + }) +}) + +describe("convertToAnthropicRole", () => { + it("should convert VSCode roles to Anthropic roles", () => { + // @ts-expect-error(Testing with an invalid role) + const unknownRole = "unknown" as vscode.LanguageModelChatMessageRole + ;(convertToAnthropicRole(vscode.LanguageModelChatMessageRole.Assistant) === "assistant").should.be.true() + ;(convertToAnthropicRole(vscode.LanguageModelChatMessageRole.User) === "user").should.be.true() + ;(convertToAnthropicRole(unknownRole) === null).should.be.true() + }) +}) + +describe("convertToVsCodeLmMessages", () => { + it("should convert simple string messages", () => { + const anthropicMessages: Anthropic.Messages.MessageParam[] = [ + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi there" }, + ] + + const result = convertToVsCodeLmMessages(anthropicMessages) + + result.should.have.length(2) + result[0].role.should.equal(vscode.LanguageModelChatMessageRole.User) + result[0].content[0].should.be.instanceof(vscode.LanguageModelTextPart) + const textPart0 = result[0].content[0] as vscode.LanguageModelTextPart + textPart0.should.have.property("value", "Hello") + + result[1].role.should.equal(vscode.LanguageModelChatMessageRole.Assistant) + result[1].content[0].should.be.instanceof(vscode.LanguageModelTextPart) + const textPart1 = result[1].content[0] as vscode.LanguageModelTextPart + textPart1.should.have.property("value", "Hi there") + }) + + it("should convert complex user messages with tool results", () => { + const anthropicMessages: Anthropic.Messages.MessageParam[] = [ + { + role: "user", + content: [ + { type: "text", text: "User text" }, + { + type: "tool_result", + tool_use_id: "tool-123", + content: [{ type: "text", text: "Tool result" }], + }, + ], + }, + ] + + const result = convertToVsCodeLmMessages(anthropicMessages) + + result.should.have.length(1) + result[0].role.should.equal(vscode.LanguageModelChatMessageRole.User) + result[0].content.should.have.length(2) + + // Check that the first content part is a ToolResultPart + result[0].content[0].should.be.instanceof(vscode.LanguageModelToolResultPart) + const toolResultPart = result[0].content[0] as vscode.LanguageModelToolResultPart + toolResultPart.should.have.property("callId", "tool-123") + + // Skip detailed testing of internal structure as it may vary + // Just verify it's the right type with the right ID + + // Check the second content part is a TextPart + result[0].content[1].should.be.instanceof(vscode.LanguageModelTextPart) + const textPart = result[0].content[1] as vscode.LanguageModelTextPart + textPart.should.have.property("value", "User text") + }) + + it("should convert complex assistant messages with tool calls", () => { + const anthropicMessages: Anthropic.Messages.MessageParam[] = [ + { + role: "assistant", + content: [ + { type: "text", text: "Assistant text" }, + { + type: "tool_use", + id: "tool-123", + name: "testTool", + input: { param: "value" }, + }, + ], + }, + ] + + const result = convertToVsCodeLmMessages(anthropicMessages) + + result.should.have.length(1) + result[0].role.should.equal(vscode.LanguageModelChatMessageRole.Assistant) + result[0].content.should.have.length(2) + + result[0].content[0].should.be.instanceof(vscode.LanguageModelToolCallPart) + const toolCallPart = result[0].content[0] as vscode.LanguageModelToolCallPart + toolCallPart.should.have.property("callId", "tool-123") + toolCallPart.should.have.property("name", "testTool") + toolCallPart.should.have.property("input") + toolCallPart.input.should.deepEqual({ param: "value" }) + + result[0].content[1].should.be.instanceof(vscode.LanguageModelTextPart) + const textPart = result[0].content[1] as vscode.LanguageModelTextPart + textPart.should.have.property("value", "Assistant text") + }) + + it("should handle image blocks with appropriate placeholders", () => { + const anthropicMessages: Anthropic.Messages.MessageParam[] = [ + { + role: "user", + content: [ + { + type: "image", + source: { + type: "base64", + media_type: "image/jpeg", + data: "base64data", + }, + }, + ], + }, + ] + + const result = convertToVsCodeLmMessages(anthropicMessages) + + result.should.have.length(1) + result[0].content[0].should.be.instanceof(vscode.LanguageModelTextPart) + const textPart = result[0].content[0] as vscode.LanguageModelTextPart + textPart.should.have.property("value") + textPart.value.should.match(/Image \(base64\): image\/jpeg not supported by VSCode LM API/) + }) +}) + +describe("convertToAnthropicMessage", () => { + it("should convert VSCode assistant messages to Anthropic format", () => { + const vsCodeMsg = vscode.LanguageModelChatMessage.Assistant([ + new vscode.LanguageModelTextPart("Test message"), + new vscode.LanguageModelToolCallPart("tool-id", "testTool", { param: "value" }), + ]) + + const result = convertToAnthropicMessage(vsCodeMsg) + + result.should.have.property("role", "assistant") + result.should.have.property("content").which.is.an.Array() + result.content.should.have.length(2) + + // Check properties carefully to avoid null reference errors + if (result.content && result.content.length >= 1) { + const textContent = result.content[0] + if (textContent) { + textContent.should.have.property("type", "text") + if (textContent.type === "text") { + textContent.should.have.property("text", "Test message") + } + } + } + + if (result.content && result.content.length >= 2) { + const toolContent = result.content[1] + if (toolContent) { + toolContent.should.have.property("type", "tool_use") + if (toolContent.type === "tool_use") { + toolContent.should.have.property("id", "tool-id") + toolContent.should.have.property("name", "testTool") + toolContent.should.have.property("input").which.deepEqual({ param: "value" }) + } + } + } + }) + + it("should throw an error for non-assistant messages", () => { + const vsCodeMsg = vscode.LanguageModelChatMessage.User("User message") + + try { + convertToAnthropicMessage(vsCodeMsg) + throw new Error("Should have thrown an error") + } catch (error: any) { + error.message.should.match(/Only assistant messages are supported/) + } + }) +}) diff --git a/src/api/transform/vscode-lm-format.ts b/src/api/transform/vscode-lm-format.ts index 04d7245b..ae6d7c49 100644 --- a/src/api/transform/vscode-lm-format.ts +++ b/src/api/transform/vscode-lm-format.ts @@ -4,7 +4,7 @@ import * as vscode from "vscode" /** * Safely converts a value into a plain object. */ -function asObjectSafe(value: any): object { +export function asObjectSafe(value: any): object { // Handle null/undefined if (!value) { return {} @@ -145,7 +145,9 @@ export function convertToVsCodeLmMessages( return vsCodeLmMessages } -export function convertToAnthropicRole(vsCodeLmMessageRole: vscode.LanguageModelChatMessageRole): string | null { +export function convertToAnthropicRole( + vsCodeLmMessageRole: vscode.LanguageModelChatMessageRole, +): Anthropic.Messages.MessageParam["role"] | null { switch (vsCodeLmMessageRole) { case vscode.LanguageModelChatMessageRole.Assistant: return "assistant" @@ -156,10 +158,8 @@ export function convertToAnthropicRole(vsCodeLmMessageRole: vscode.LanguageModel } } -export async function convertToAnthropicMessage( - vsCodeLmMessage: vscode.LanguageModelChatMessage, -): Promise { - const anthropicRole: string | null = convertToAnthropicRole(vsCodeLmMessage.role) +export function convertToAnthropicMessage(vsCodeLmMessage: vscode.LanguageModelChatMessage): Anthropic.Messages.Message { + const anthropicRole = convertToAnthropicRole(vsCodeLmMessage.role) if (anthropicRole !== "assistant") { throw new Error("Cline : Only assistant messages are supported.") } diff --git a/src/core/assistant-message/parse-assistant-message.ts b/src/core/assistant-message/parse-assistant-message.ts index 819a4bc3..3d8cfead 100644 --- a/src/core/assistant-message/parse-assistant-message.ts +++ b/src/core/assistant-message/parse-assistant-message.ts @@ -123,7 +123,7 @@ export function parseAssistantMessage(assistantMessage: string) { contentBlocks.push(currentToolUse) } - // Note: it doesnt matter if check for currentToolUse or currentTextContent, only one of them will be defined since only one can be partial at a time + // Note: it doesn't matter if check for currentToolUse or currentTextContent, only one of them will be defined since only one can be partial at a time if (currentTextContent) { // stream did not complete text content, add it as partial contentBlocks.push(currentTextContent) diff --git a/src/core/context/context-management/ContextManager.ts b/src/core/context/context-management/ContextManager.ts index e26e80f3..5a22f2bf 100644 --- a/src/core/context/context-management/ContextManager.ts +++ b/src/core/context/context-management/ContextManager.ts @@ -537,7 +537,7 @@ export class ContextManager { // we can assume that thisExistingFileReads does not have many entries if (!thisExistingFileReads.includes(filePath)) { - // meaning we havent already replaced this file read + // meaning we haven't already replaced this file read const entireMatch = match[0] // The entire matched string @@ -590,7 +590,7 @@ export class ContextManager { ) { const pattern = new RegExp(`()[\\s\\S]*?()`) - // check if this exists in the text, it wont exist if the user rejects the file change for example + // check if this exists in the text, it won't exist if the user rejects the file change for example if (pattern.test(secondBlockText)) { const replacementText = secondBlockText.replace(pattern, `$1 ${formatResponse.duplicateFileReadNotice()} $2`) const indices = fileReadIndices.get(filePath) || [] @@ -741,7 +741,7 @@ export class ContextManager { let totalCharactersSaved = 0 for (let i = startIndex; i < endIndex; i++) { - // looping over the outer indicies of messages + // looping over the outer indices of messages const message = apiMessages[i] if (!message.content) { @@ -782,7 +782,7 @@ export class ContextManager { totalCharCount += originalTextLength } else { - // meaning there was an update to this text previously, but we didnt just alter it + // meaning there was an update to this text previously, but we didn't just alter it totalCharCount += latestUpdate[2][0].length } } else { @@ -790,7 +790,7 @@ export class ContextManager { totalCharCount += block.text.length } } else { - // reach here if there's no alterations for this outer index, meaning each inner index wont have any changes either + // reach here if there's no alterations for this outer index, meaning each inner index won't have any changes either totalCharCount += block.text.length } } else if (block.type === "image" && block.source) { diff --git a/src/core/context/instructions/user-instructions/cline-rules.ts b/src/core/context/instructions/user-instructions/cline-rules.ts index fe2b73ed..3f19c54b 100644 --- a/src/core/context/instructions/user-instructions/cline-rules.ts +++ b/src/core/context/instructions/user-instructions/cline-rules.ts @@ -1,10 +1,42 @@ import path from "path" -import { GlobalFileNames } from "../../../storage/disk" +import { ensureRulesDirectoryExists, GlobalFileNames } from "../../../storage/disk" import { fileExistsAtPath, isDirectory, readDirectory } from "../../../../utils/fs" import { formatResponse } from "../../../prompts/responses" import fs from "fs/promises" +import { ClineRulesToggles } from "../../../../shared/cline-rules" +import { getGlobalState, getWorkspaceState, updateGlobalState, updateWorkspaceState } from "../../../storage/state" +import * as vscode from "vscode" -export const getClineRules = async (cwd: string) => { +export const getGlobalClineRules = async (globalClineRulesFilePath: string, toggles: ClineRulesToggles) => { + if (await fileExistsAtPath(globalClineRulesFilePath)) { + if (await isDirectory(globalClineRulesFilePath)) { + try { + const rulesFilePaths = await readDirectory(globalClineRulesFilePath) + const rulesFilesTotalContent = await getClineRulesFilesTotalContent( + rulesFilePaths, + globalClineRulesFilePath, + toggles, + ) + if (rulesFilesTotalContent) { + const clineRulesFileInstructions = formatResponse.clineRulesGlobalDirectoryInstructions( + globalClineRulesFilePath, + rulesFilesTotalContent, + ) + return clineRulesFileInstructions + } + } catch { + console.error(`Failed to read .clinerules directory at ${globalClineRulesFilePath}`) + } + } else { + console.error(`${globalClineRulesFilePath} is not a directory`) + return undefined + } + } + + return undefined +} + +export const getLocalClineRules = async (cwd: string, toggles: ClineRulesToggles) => { const clineRulesFilePath = path.resolve(cwd, GlobalFileNames.clineRules) let clineRulesFileInstructions: string | undefined @@ -12,17 +44,21 @@ export const getClineRules = async (cwd: string) => { if (await fileExistsAtPath(clineRulesFilePath)) { if (await isDirectory(clineRulesFilePath)) { try { - const rulesFilePaths = await readDirectory(path.join(cwd, GlobalFileNames.clineRules)) - const rulesFilesTotalContent = await getClineRulesFilesTotalContent(rulesFilePaths, cwd) - clineRulesFileInstructions = formatResponse.clineRulesDirectoryInstructions(cwd, rulesFilesTotalContent) + const rulesFilePaths = await readDirectory(clineRulesFilePath) + const rulesFilesTotalContent = await getClineRulesFilesTotalContent(rulesFilePaths, cwd, toggles) + if (rulesFilesTotalContent) { + clineRulesFileInstructions = formatResponse.clineRulesLocalDirectoryInstructions(cwd, rulesFilesTotalContent) + } } catch { console.error(`Failed to read .clinerules directory at ${clineRulesFilePath}`) } } else { try { - const ruleFileContent = (await fs.readFile(clineRulesFilePath, "utf8")).trim() - if (ruleFileContent) { - clineRulesFileInstructions = formatResponse.clineRulesFileInstructions(cwd, ruleFileContent) + if (clineRulesFilePath in toggles && toggles[clineRulesFilePath] !== false) { + const ruleFileContent = (await fs.readFile(clineRulesFilePath, "utf8")).trim() + if (ruleFileContent) { + clineRulesFileInstructions = formatResponse.clineRulesLocalFileInstructions(cwd, ruleFileContent) + } } } catch { console.error(`Failed to read .clinerules file at ${clineRulesFilePath}`) @@ -33,13 +69,153 @@ export const getClineRules = async (cwd: string) => { return clineRulesFileInstructions } -const getClineRulesFilesTotalContent = async (rulesFilePaths: string[], cwd: string) => { +const getClineRulesFilesTotalContent = async (rulesFilePaths: string[], basePath: string, toggles: ClineRulesToggles) => { const ruleFilesTotalContent = await Promise.all( rulesFilePaths.map(async (filePath) => { - const ruleFilePath = path.resolve(cwd, filePath) - const ruleFilePathRelative = path.relative(cwd, ruleFilePath) + const ruleFilePath = path.resolve(basePath, filePath) + const ruleFilePathRelative = path.relative(basePath, ruleFilePath) + + if (ruleFilePath in toggles && toggles[ruleFilePath] === false) { + return null + } + return `${ruleFilePathRelative}\n` + (await fs.readFile(ruleFilePath, "utf8")).trim() }), - ).then((contents) => contents.join("\n\n")) + ).then((contents) => contents.filter(Boolean).join("\n\n")) return ruleFilesTotalContent } + +export async function synchronizeRuleToggles( + rulesDirectoryPath: string, + currentToggles: ClineRulesToggles, +): Promise { + // Create a copy of toggles to modify + const updatedToggles = { ...currentToggles } + + try { + const pathExists = await fileExistsAtPath(rulesDirectoryPath) + + if (pathExists) { + const isDir = await isDirectory(rulesDirectoryPath) + + if (isDir) { + // DIRECTORY CASE + const filePaths = await readDirectory(rulesDirectoryPath) + const existingRulePaths = new Set() + + for (const filePath of filePaths) { + const ruleFilePath = path.resolve(rulesDirectoryPath, filePath) + existingRulePaths.add(ruleFilePath) + + const pathHasToggle = ruleFilePath in updatedToggles + if (!pathHasToggle) { + updatedToggles[ruleFilePath] = true + } + } + + // Clean up toggles for non-existent files + for (const togglePath in updatedToggles) { + const pathExists = existingRulePaths.has(togglePath) + if (!pathExists) { + delete updatedToggles[togglePath] + } + } + } else { + // FILE CASE + // Add toggle for this file + const pathHasToggle = rulesDirectoryPath in updatedToggles + if (!pathHasToggle) { + updatedToggles[rulesDirectoryPath] = true + } + + // Remove toggles for any other paths + for (const togglePath in updatedToggles) { + if (togglePath !== rulesDirectoryPath) { + delete updatedToggles[togglePath] + } + } + } + } else { + // PATH DOESN'T EXIST CASE + // Clear all toggles since the path doesn't exist + for (const togglePath in updatedToggles) { + delete updatedToggles[togglePath] + } + } + } catch (error) { + console.error(`Failed to synchronize rule toggles for path: ${rulesDirectoryPath}`, error) + } + + return updatedToggles +} + +export async function refreshClineRulesToggles( + context: vscode.ExtensionContext, + workingDirectory: string, +): Promise<{ + globalToggles: ClineRulesToggles + localToggles: ClineRulesToggles +}> { + // Global toggles + const globalClineRulesToggles = ((await getGlobalState(context, "globalClineRulesToggles")) as ClineRulesToggles) || {} + const globalClineRulesFilePath = await ensureRulesDirectoryExists() + const updatedGlobalToggles = await synchronizeRuleToggles(globalClineRulesFilePath, globalClineRulesToggles) + await updateGlobalState(context, "globalClineRulesToggles", updatedGlobalToggles) + + // Local toggles + const localClineRulesToggles = ((await getWorkspaceState(context, "localClineRulesToggles")) as ClineRulesToggles) || {} + const localClineRulesFilePath = path.resolve(workingDirectory, GlobalFileNames.clineRules) + const updatedLocalToggles = await synchronizeRuleToggles(localClineRulesFilePath, localClineRulesToggles) + await updateWorkspaceState(context, "localClineRulesToggles", updatedLocalToggles) + + return { + globalToggles: updatedGlobalToggles, + localToggles: updatedLocalToggles, + } +} + +export async function deleteRuleFile( + context: vscode.ExtensionContext, + rulePath: string, + isGlobal: boolean, +): Promise<{ success: boolean; message: string }> { + try { + // Check if file exists + const fileExists = await fileExistsAtPath(rulePath) + if (!fileExists) { + return { + success: false, + message: `Rule file does not exist: ${rulePath}`, + } + } + + // Delete the file from disk + await fs.unlink(rulePath) + + // Get the filename for messages + const fileName = path.basename(rulePath) + + // Update the appropriate toggles + if (isGlobal) { + const toggles = ((await getGlobalState(context, "globalClineRulesToggles")) as ClineRulesToggles) || {} + delete toggles[rulePath] + await updateGlobalState(context, "globalClineRulesToggles", toggles) + } else { + const toggles = ((await getWorkspaceState(context, "localClineRulesToggles")) as ClineRulesToggles) || {} + delete toggles[rulePath] + await updateWorkspaceState(context, "localClineRulesToggles", toggles) + } + + return { + success: true, + message: `Rule file "${fileName}" deleted successfully`, + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + console.error(`Error deleting rule file: ${errorMessage}`, error) + return { + success: false, + message: `Failed to delete rule file.`, + } + } +} diff --git a/src/core/controller/browser/getBrowserConnectionInfo.ts b/src/core/controller/browser/getBrowserConnectionInfo.ts new file mode 100644 index 00000000..821bd5f6 --- /dev/null +++ b/src/core/controller/browser/getBrowserConnectionInfo.ts @@ -0,0 +1,47 @@ +import { BrowserConnectionInfo } from "../../../shared/proto/browser" +import { EmptyRequest } from "../../../shared/proto/common" +import { Controller } from "../index" +import { getAllExtensionState } from "../../storage/state" + +/** + * Get information about the current browser connection + * @param controller The controller instance + * @param request The request message + * @returns The browser connection info + */ +export async function getBrowserConnectionInfo(controller: Controller, request: EmptyRequest): Promise { + try { + // Get browser settings from extension state + const { browserSettings } = await getAllExtensionState(controller.context) + + // Check if there's an active browser session by using the controller's handleWebviewMessage approach + // This is similar to what's done in controller/index.ts for the "getBrowserConnectionInfo" message + if (controller.task?.browserSession) { + // Access the browser session through the controller's task property + // Using indexer notation to access private property + const browserSession = controller.task.browserSession + const connectionInfo = browserSession.getConnectionInfo() + + // Convert from BrowserSession.BrowserConnectionInfo to proto.BrowserConnectionInfo + return { + isConnected: connectionInfo.isConnected, + isRemote: connectionInfo.isRemote, + host: connectionInfo.host || "", // Ensure host is never undefined + } + } + + // Fallback to browser settings if no active browser session + return { + isConnected: false, + isRemote: !!browserSettings.remoteBrowserEnabled, + host: browserSettings.remoteBrowserHost || "", + } + } catch (error: unknown) { + console.error("Error getting browser connection info:", error) + return { + isConnected: false, + isRemote: false, + host: "", + } + } +} diff --git a/src/core/controller/browser/index.ts b/src/core/controller/browser/index.ts new file mode 100644 index 00000000..5e67c4c2 --- /dev/null +++ b/src/core/controller/browser/index.ts @@ -0,0 +1,15 @@ +import { createServiceRegistry, ServiceMethodHandler } from "../grpc-service" +import { registerAllMethods } from "./methods" + +// Create browser service registry +const browserService = createServiceRegistry("browser") + +// Export the method handler type and registration function +export type BrowserMethodHandler = ServiceMethodHandler +export const registerMethod = browserService.registerMethod + +// Export the request handler +export const handleBrowserServiceRequest = browserService.handleRequest + +// Register all browser methods +registerAllMethods() diff --git a/src/core/controller/browser/methods.ts b/src/core/controller/browser/methods.ts new file mode 100644 index 00000000..1c09be29 --- /dev/null +++ b/src/core/controller/browser/methods.ts @@ -0,0 +1,14 @@ +// AUTO-GENERATED FILE - DO NOT MODIFY DIRECTLY +// Generated by proto/build-proto.js + +// Import all method implementations +import { registerMethod } from "./index" +import { getBrowserConnectionInfo } from "./getBrowserConnectionInfo" +import { testBrowserConnection } from "./testBrowserConnection" + +// Register all browser service methods +export function registerAllMethods(): void { + // Register each method with the registry + registerMethod("getBrowserConnectionInfo", getBrowserConnectionInfo) + registerMethod("testBrowserConnection", testBrowserConnection) +} diff --git a/src/core/controller/browser/testBrowserConnection.ts b/src/core/controller/browser/testBrowserConnection.ts new file mode 100644 index 00000000..ee762627 --- /dev/null +++ b/src/core/controller/browser/testBrowserConnection.ts @@ -0,0 +1,63 @@ +import { BrowserConnection } from "../../../shared/proto/browser" +import { StringRequest } from "../../../shared/proto/common" +import { Controller } from "../index" +import { getAllExtensionState } from "../../storage/state" +import { BrowserSession } from "../../../services/browser/BrowserSession" +import { discoverChromeInstances } from "../../../services/browser/BrowserDiscovery" + +/** + * Test connection to a browser instance + * @param controller The controller instance + * @param request The request message + * @returns The browser connection result + */ +export async function testBrowserConnection(controller: Controller, request: StringRequest): Promise { + try { + const { browserSettings } = await getAllExtensionState(controller.context) + const browserSession = new BrowserSession(controller.context, browserSettings) + const text = request.value || "" + + // If no text is provided, try auto-discovery + if (!text) { + try { + const discoveredHost = await discoverChromeInstances() + if (discoveredHost) { + // Test the connection to the discovered host + const result = await browserSession.testConnection(discoveredHost) + return { + success: result.success, + message: `Auto-discovered and tested connection to Chrome at ${discoveredHost}: ${result.message}`, + endpoint: result.endpoint || "", + } + } else { + return { + success: false, + message: + "No Chrome instances found on the network. Make sure Chrome is running with remote debugging enabled (--remote-debugging-port=9222).", + endpoint: "", + } + } + } catch (error) { + return { + success: false, + message: `Error during auto-discovery: ${error instanceof Error ? error.message : String(error)}`, + endpoint: "", + } + } + } else { + // Test the provided URL + const result = await browserSession.testConnection(text) + return { + success: result.success, + message: result.message, + endpoint: result.endpoint || "", + } + } + } catch (error) { + return { + success: false, + message: `Error testing connection: ${error instanceof Error ? error.message : String(error)}`, + endpoint: "", + } + } +} diff --git a/src/core/controller/grpc-handler.ts b/src/core/controller/grpc-handler.ts new file mode 100644 index 00000000..4b8ff623 --- /dev/null +++ b/src/core/controller/grpc-handler.ts @@ -0,0 +1,81 @@ +import { Controller } from "./index" +import { handleBrowserServiceRequest } from "./browser/index" +import { ExtensionMessage } from "../../shared/ExtensionMessage" + +/** + * Handles gRPC requests from the webview + */ +export class GrpcHandler { + constructor(private controller: Controller) {} + + /** + * Handle a gRPC request from the webview + * @param service The service name + * @param method The method name + * @param message The request message + * @param requestId The request ID for response correlation + * @returns The response message or error + */ + async handleRequest( + service: string, + method: string, + message: any, + requestId: string, + ): Promise<{ + message?: any + error?: string + request_id: string + }> { + try { + // Handle BrowserService requests + if (service === "cline.BrowserService") { + return { + message: await handleBrowserServiceRequest(this.controller, method, message), + request_id: requestId, + } + } + + throw new Error(`Unknown service: ${service}`) + } catch (error) { + return { + error: error instanceof Error ? error.message : String(error), + request_id: requestId, + } + } + } +} + +/** + * Handle a gRPC request from the webview + * @param controller The controller instance + * @param request The gRPC request + */ +export async function handleGrpcRequest( + controller: Controller, + request: { + service: string + method: string + message: any + request_id: string + }, +) { + try { + const grpcHandler = new GrpcHandler(controller) + const response = await grpcHandler.handleRequest(request.service, request.method, request.message, request.request_id) + + // Send the response back to the webview + await controller.postMessageToWebview({ + type: "grpc_response", + grpc_response: response, + }) + } catch (error) { + // Send error response + await controller.postMessageToWebview({ + type: "grpc_response", + grpc_response: { + error: error instanceof Error ? error.message : String(error), + request_id: request.request_id, + }, + }) + } +} diff --git a/src/core/controller/grpc-service.ts b/src/core/controller/grpc-service.ts new file mode 100644 index 00000000..876f6afd --- /dev/null +++ b/src/core/controller/grpc-service.ts @@ -0,0 +1,65 @@ +import { Controller } from "./index" + +/** + * Generic type for service method handlers + */ +export type ServiceMethodHandler = (controller: Controller, message: any) => Promise + +/** + * Generic service registry for gRPC services + */ +export class ServiceRegistry { + private serviceName: string + private methodRegistry: Record = {} + + /** + * Create a new service registry + * @param serviceName The name of the service (used for logging) + */ + constructor(serviceName: string) { + this.serviceName = serviceName + } + + /** + * Register a method handler + * @param methodName The name of the method to register + * @param handler The handler function for the method + */ + registerMethod(methodName: string, handler: ServiceMethodHandler): void { + this.methodRegistry[methodName] = handler + console.log(`Registered ${this.serviceName} method: ${methodName}`) + } + + /** + * Handle a service request + * @param controller The controller instance + * @param method The method name + * @param message The request message + * @returns The response message + */ + async handleRequest(controller: Controller, method: string, message: any): Promise { + const handler = this.methodRegistry[method] + + if (!handler) { + throw new Error(`Unknown ${this.serviceName} method: ${method}`) + } + + return handler(controller, message) + } +} + +/** + * Create a service registry factory function + * @param serviceName The name of the service + * @returns An object with register and handle functions + */ +export function createServiceRegistry(serviceName: string) { + const registry = new ServiceRegistry(serviceName) + + return { + registerMethod: (methodName: string, handler: ServiceMethodHandler) => registry.registerMethod(methodName, handler), + + handleRequest: (controller: Controller, method: string, message: any) => + registry.handleRequest(controller, method, message), + } +} diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index 94cf1460..fe478106 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -2,13 +2,12 @@ import { Anthropic } from "@anthropic-ai/sdk" import axios from "axios" import type { AxiosRequestConfig } from "axios" import crypto from "crypto" -import { execa } from "execa" import fs from "fs/promises" import { setTimeout as setTimeoutPromise } from "node:timers/promises" -import os from "os" import pWaitFor from "p-wait-for" import * as path from "path" import * as vscode from "vscode" +import { handleGrpcRequest } from "./grpc-handler" import { buildApiHandler } from "../../api" import { cleanupLegacyCheckpoints } from "../../integrations/checkpoints/CheckpointMigration" import { downloadTask } from "../../integrations/misc/export-markdown" @@ -36,19 +35,22 @@ import { searchCommits } from "../../utils/git" import { getWorkspacePath } from "../../utils/path" import { getTotalTasksSize } from "../../utils/storage" import { openMention } from "../mentions" -import { GlobalFileNames } from "../storage/disk" +import { ensureMcpServersDirectoryExists, ensureSettingsDirectoryExists, GlobalFileNames } from "../storage/disk" import { getAllExtensionState, getGlobalState, getSecret, + getWorkspaceState, resetExtensionState, storeSecret, updateApiConfiguration, updateGlobalState, + updateWorkspaceState, } from "../storage/state" -import { Task } from "../task" +import { Task, cwd } from "../task" +import { ClineRulesToggles } from "../../shared/cline-rules" +import { deleteRuleFile, refreshClineRulesToggles } from "../context/instructions/user-instructions/cline-rules" import { SSYAccountService } from "../../services/account/SSYAccountService" - /* https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts @@ -59,7 +61,7 @@ export class Controller { private postMessage: (message: ExtensionMessage) => Thenable | undefined private disposables: vscode.Disposable[] = [] - private task?: Task + task?: Task workspaceTracker: WorkspaceTracker mcpHub: McpHub accountService: SSYAccountService @@ -75,8 +77,8 @@ export class Controller { this.workspaceTracker = new WorkspaceTracker((msg) => this.postMessageToWebview(msg)) this.mcpHub = new McpHub( - () => this.ensureMcpServersDirectoryExists(), - () => this.ensureSettingsDirectoryExists(), + () => ensureMcpServersDirectoryExists(), + () => ensureSettingsDirectoryExists(this.context), (msg) => this.postMessageToWebview(msg), this.context.extension?.packageJSON?.version ?? "1.0.0", ) @@ -257,6 +259,13 @@ export class Controller { telemetryService.updateTelemetryState(isOptedIn) }) break + case "showChatView": { + this.postMessageToWebview({ + type: "action", + action: "chatButtonClicked", + }) + break + } case "newTask": // Code that should run in response to the hello message command //vscode.window.showInformationMessage(message.text!) @@ -302,88 +311,6 @@ export class Controller { await this.postStateToWebview() } break - case "getBrowserConnectionInfo": - try { - // Get the current browser session from Cline if it exists - if (this.task?.browserSession) { - const connectionInfo = this.task.browserSession.getConnectionInfo() - await this.postMessageToWebview({ - type: "browserConnectionInfo", - isConnected: connectionInfo.isConnected, - isRemote: connectionInfo.isRemote, - host: connectionInfo.host, - }) - } else { - // If no active browser session, just return the settings - const { browserSettings } = await getAllExtensionState(this.context) - await this.postMessageToWebview({ - type: "browserConnectionInfo", - isConnected: false, - isRemote: !!browserSettings.remoteBrowserEnabled, - host: browserSettings.remoteBrowserHost, - }) - } - } catch (error) { - console.error("Error getting browser connection info:", error) - await this.postMessageToWebview({ - type: "browserConnectionInfo", - isConnected: false, - isRemote: false, - }) - } - break - case "testBrowserConnection": - try { - const { browserSettings } = await getAllExtensionState(this.context) - const browserSession = new BrowserSession(this.context, browserSettings) - // If no text is provided, try auto-discovery - if (!message.text) { - try { - const discoveredHost = await discoverChromeInstances() - if (discoveredHost) { - // Test the connection to the discovered host - const result = await browserSession.testConnection(discoveredHost) - // Send the result back to the webview - await this.postMessageToWebview({ - type: "browserConnectionResult", - success: result.success, - text: `Auto-discovered and tested connection to Chrome at ${discoveredHost}: ${result.message}`, - endpoint: result.endpoint, - }) - } else { - await this.postMessageToWebview({ - type: "browserConnectionResult", - success: false, - text: "No Chrome instances found on the network. Make sure Chrome is running with remote debugging enabled (--remote-debugging-port=9222).", - }) - } - } catch (error) { - await this.postMessageToWebview({ - type: "browserConnectionResult", - success: false, - text: `Error during auto-discovery: ${error instanceof Error ? error.message : String(error)}`, - }) - } - } else { - // Test the provided URL - const result = await browserSession.testConnection(message.text) - - // Send the result back to the webview - await this.postMessageToWebview({ - type: "browserConnectionResult", - success: result.success, - text: result.message, - endpoint: result.endpoint, - }) - } - } catch (error) { - await this.postMessageToWebview({ - type: "browserConnectionResult", - success: false, - text: `Error testing connection: ${error instanceof Error ? error.message : String(error)}`, - }) - } - break case "discoverBrowser": try { const discoveredHost = await discoverChromeInstances() @@ -502,6 +429,10 @@ export class Controller { const openAiModels = await this.getOpenAiModels(apiConfiguration.openAiBaseUrl, apiConfiguration.openAiApiKey) this.postMessageToWebview({ type: "openAiModels", openAiModels }) break + case "refreshClineRules": + await refreshClineRulesToggles(this.context, cwd) + await this.postStateToWebview() + break case "openImage": openImage(message.text!) break @@ -529,7 +460,7 @@ export class Controller { break } case "checkpointRestore": { - await this.cancelTask() // we cannot alter message history say if the task is active, as it could be in the middle of editing a file or running a command, which expect the ask to be responded to rather than being superceded by a new message eg add deleted_api_reqs + await this.cancelTask() // we cannot alter message history say if the task is active, as it could be in the middle of editing a file or running a command, which expect the ask to be responded to rather than being superseded by a new message eg add deleted_api_reqs // cancel task waits for any open editor to be reverted and starts a new cline instance if (message.number) { // wait for messages to be loaded @@ -539,7 +470,7 @@ export class Controller { console.error("Failed to init new cline instance") }) // NOTE: cancelTask awaits abortTask, which awaits diffViewProvider.revertChanges, which reverts any edited files, allowing us to reset to a checkpoint rather than running into a state where the revertChanges function is called alongside or after the checkpoint reset - await this.task?.restoreCheckpoint(message.number, message.text! as ClineCheckpointRestore) + await this.task?.restoreCheckpoint(message.number, message.text! as ClineCheckpointRestore, message.offset) } break } @@ -696,6 +627,48 @@ export class Controller { } break } + case "toggleClineRule": { + const { isGlobal, rulePath, enabled } = message + if (rulePath && typeof enabled === "boolean" && typeof isGlobal === "boolean") { + if (isGlobal) { + const toggles = + ((await getGlobalState(this.context, "globalClineRulesToggles")) as ClineRulesToggles) || {} + toggles[rulePath] = enabled + await updateGlobalState(this.context, "globalClineRulesToggles", toggles) + } else { + const toggles = + ((await getWorkspaceState(this.context, "localClineRulesToggles")) as ClineRulesToggles) || {} + toggles[rulePath] = enabled + await updateWorkspaceState(this.context, "localClineRulesToggles", toggles) + } + await this.postStateToWebview() + } else { + console.error("toggleClineRule: Missing or invalid parameters", { + rulePath, + isGlobal: typeof isGlobal === "boolean" ? isGlobal : `Invalid: ${typeof isGlobal}`, + enabled: typeof enabled === "boolean" ? enabled : `Invalid: ${typeof enabled}`, + }) + } + break + } + case "deleteClineRule": { + const { isGlobal, rulePath } = message + if (rulePath && typeof isGlobal === "boolean") { + const result = await deleteRuleFile(this.context, rulePath, isGlobal) + if (result.success) { + await refreshClineRulesToggles(this.context, cwd) + await this.postStateToWebview() + } else { + console.error("Failed to delete rule file:", result.message) + } + } else { + console.error("deleteClineRule: Missing or invalid parameters", { + rulePath, + isGlobal: typeof isGlobal === "boolean" ? isGlobal : `Invalid: ${typeof isGlobal}`, + }) + } + break + } case "requestTotalTasksSize": { this.refreshTotalTasksSize() break @@ -930,6 +903,12 @@ export class Controller { } break } + case "grpc_request": { + if (message.grpc_request) { + await handleGrpcRequest(this, message.grpc_request) + } + break + } // Add more switch case statements here as more webview message commands // are created within the webview context (i.e. inside media/main.js) } @@ -975,6 +954,7 @@ export class Controller { case "openai-native": case "qwen": case "deepseek": + case "xai": case "shengsuanyun": await updateGlobalState(this.context, "previousModeModelId", apiConfiguration.apiModelId) break @@ -1124,61 +1104,6 @@ export class Controller { } } - // MCP - - async getDocumentsPath(): Promise { - if (process.platform === "win32") { - try { - const { stdout: docsPath } = await execa("powershell", [ - "-NoProfile", // Ignore user's PowerShell profile(s) - "-Command", - "[System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::MyDocuments)", - ]) - const trimmedPath = docsPath.trim() - if (trimmedPath) { - return trimmedPath - } - } catch (err) { - console.error("Failed to retrieve Windows Documents path. Falling back to homedir/Documents.") - } - } else if (process.platform === "linux") { - try { - // First check if xdg-user-dir exists - await execa("which", ["xdg-user-dir"]) - - // If it exists, try to get XDG documents path - const { stdout } = await execa("xdg-user-dir", ["DOCUMENTS"]) - const trimmedPath = stdout.trim() - if (trimmedPath) { - return trimmedPath - } - } catch { - // Log error but continue to fallback - console.error("Failed to retrieve XDG Documents path. Falling back to homedir/Documents.") - } - } - - // Default fallback for all platforms - return path.join(os.homedir(), "Documents") - } - - async ensureMcpServersDirectoryExists(): Promise { - const userDocumentsPath = await this.getDocumentsPath() - const mcpServersDir = path.join(userDocumentsPath, "ClineShengsuan", "MCP") - try { - await fs.mkdir(mcpServersDir, { recursive: true }) - } catch (error) { - return "~/Documents/ClineShengsuan/MCP" // in case creating a directory in documents fails for whatever reason (e.g. permissions) - this is fine since this path is only ever used in the system prompt - } - return mcpServersDir - } - - async ensureSettingsDirectoryExists(): Promise { - const settingsDir = path.join(this.context.globalStorageUri.fsPath, "settings") - await fs.mkdir(settingsDir, { recursive: true }) - return settingsDir - } - // VSCode LM API private async getVsCodeLmModels() { @@ -1932,7 +1857,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont } } // if we tried to get a task that doesn't exist, remove it from state - // FIXME: this seems to happen sometimes when the json file doesnt save to disk for some reason + // FIXME: this seems to happen sometimes when the json file doesn't save to disk for some reason await this.deleteTaskFromState(id) throw new Error("Task not found") } @@ -2064,8 +1989,12 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont mcpMarketplaceEnabled, telemetrySetting, planActSeparateModelsSetting, + globalClineRulesToggles, } = await getAllExtensionState(this.context) + const localClineRulesToggles = + ((await getWorkspaceState(this.context, "localClineRulesToggles")) as ClineRulesToggles) || {} + return { version: this.context.extension?.packageJSON?.version ?? "", apiConfiguration, @@ -2088,6 +2017,8 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont telemetrySetting, planActSeparateModelsSetting, vscMachineId: vscode.env.machineId, + globalClineRulesToggles: globalClineRulesToggles || {}, + localClineRulesToggles: localClineRulesToggles || {}, } } @@ -2109,7 +2040,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont // conversation history to send in API requests /* - It seems that some API messages do not comply with vscode state requirements. Either the Anthropic library is manipulating these values somehow in the backend in a way thats creating cyclic references, or the API returns a function or a Symbol as part of the message content. + It seems that some API messages do not comply with vscode state requirements. Either the Anthropic library is manipulating these values somehow in the backend in a way that's creating cyclic references, or the API returns a function or a Symbol as part of the message content. VSCode docs about state: "The value must be JSON-stringifyable ... value — A value. MUST not contain cyclic references." For now we'll store the conversation history in memory, and if we need to store in state directly we'd need to do a manual conversion to ensure proper json stringification. */ diff --git a/src/core/prompts/responses.ts b/src/core/prompts/responses.ts index 31720bb9..6a4a9c21 100644 --- a/src/core/prompts/responses.ts +++ b/src/core/prompts/responses.ts @@ -204,10 +204,13 @@ Otherwise, if you have not completed the task and do not need additional informa clineIgnoreInstructions: (content: string) => `# .clineignore\n\n(The following is provided by a root-level .clineignore file where the user has specified files and directories that should not be accessed. When using list_files, you'll notice a ${LOCK_TEXT_SYMBOL} next to files that are blocked. Attempting to access the file's contents e.g. through read_file will result in an error.)\n\n${content}\n.clineignore`, - clineRulesDirectoryInstructions: (cwd: string, content: string) => + clineRulesGlobalDirectoryInstructions: (globalClineRulesFilePath: string, content: string) => + `# .clinerules/\n\nThe following is provided by a global .clinerules/ directory, located at ${globalClineRulesFilePath.toPosix()}, where the user has specified instructions for all working directories:\n\n${content}`, + + clineRulesLocalDirectoryInstructions: (cwd: string, content: string) => `# .clinerules/\n\nThe following is provided by a root-level .clinerules/ directory where the user has specified instructions for this working directory (${cwd.toPosix()})\n\n${content}`, - clineRulesFileInstructions: (cwd: string, content: string) => + clineRulesLocalFileInstructions: (cwd: string, content: string) => `# .clinerules\n\nThe following is provided by a root-level .clinerules file where the user has specified instructions for this working directory (${cwd.toPosix()})\n\n${content}`, } diff --git a/src/core/prompts/system.ts b/src/core/prompts/system.ts index 08f63502..c9db816b 100644 --- a/src/core/prompts/system.ts +++ b/src/core/prompts/system.ts @@ -619,7 +619,8 @@ You accomplish a given task iteratively, breaking it down into clear steps and w export function addUserInstructions( settingsCustomInstructions?: string, - clineRulesFileInstructions?: string, + globalClineRulesFileInstructions?: string, + localClineRulesFileInstructions?: string, clineIgnoreInstructions?: string, preferredLanguageInstructions?: string, ) { @@ -630,8 +631,11 @@ export function addUserInstructions( if (settingsCustomInstructions) { customInstructions += settingsCustomInstructions + "\n\n" } - if (clineRulesFileInstructions) { - customInstructions += clineRulesFileInstructions + "\n\n" + if (globalClineRulesFileInstructions) { + customInstructions += globalClineRulesFileInstructions + "\n\n" + } + if (localClineRulesFileInstructions) { + customInstructions += localClineRulesFileInstructions + "\n\n" } if (clineIgnoreInstructions) { customInstructions += clineIgnoreInstructions diff --git a/src/core/storage/disk.ts b/src/core/storage/disk.ts index 92bcf972..80d06482 100644 --- a/src/core/storage/disk.ts +++ b/src/core/storage/disk.ts @@ -5,6 +5,9 @@ import { Anthropic } from "@anthropic-ai/sdk" import { fileExistsAtPath } from "../../utils/fs" import { ClineMessage } from "../../shared/ExtensionMessage" import { TaskMetadata } from "../context/context-tracking/ContextTrackerTypes" +import os from "os" +import { execa } from "execa" + export const GlobalFileNames = { apiConversationHistory: "api_conversation_history.json", contextHistory: "context_history.json", @@ -15,6 +18,42 @@ export const GlobalFileNames = { taskMetadata: "task_metadata.json", } +export async function getDocumentsPath(): Promise { + if (process.platform === "win32") { + try { + const { stdout: docsPath } = await execa("powershell", [ + "-NoProfile", // Ignore user's PowerShell profile(s) + "-Command", + "[System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::MyDocuments)", + ]) + const trimmedPath = docsPath.trim() + if (trimmedPath) { + return trimmedPath + } + } catch (err) { + console.error("Failed to retrieve Windows Documents path. Falling back to homedir/Documents.") + } + } else if (process.platform === "linux") { + try { + // First check if xdg-user-dir exists + await execa("which", ["xdg-user-dir"]) + + // If it exists, try to get XDG documents path + const { stdout } = await execa("xdg-user-dir", ["DOCUMENTS"]) + const trimmedPath = stdout.trim() + if (trimmedPath) { + return trimmedPath + } + } catch { + // Log error but continue to fallback + console.error("Failed to retrieve XDG Documents path. Falling back to homedir/Documents.") + } + } + + // Default fallback for all platforms + return path.join(os.homedir(), "Documents") +} + export async function ensureTaskDirectoryExists(context: vscode.ExtensionContext, taskId: string): Promise { const globalStoragePath = context.globalStorageUri.fsPath const taskDir = path.join(globalStoragePath, "tasks", taskId) @@ -22,6 +61,34 @@ export async function ensureTaskDirectoryExists(context: vscode.ExtensionContext return taskDir } +export async function ensureRulesDirectoryExists(): Promise { + const userDocumentsPath = await getDocumentsPath() + const clineRulesDir = path.join(userDocumentsPath, "Cline", "Rules") + try { + await fs.mkdir(clineRulesDir, { recursive: true }) + } catch (error) { + return path.join(os.homedir(), "Documents", "Cline", "Rules") // in case creating a directory in documents fails for whatever reason (e.g. permissions) - this is fine because we will fail gracefully with a path that does not exist + } + return clineRulesDir +} + +export async function ensureMcpServersDirectoryExists(): Promise { + const userDocumentsPath = await getDocumentsPath() + const mcpServersDir = path.join(userDocumentsPath, "Cline", "MCP") + try { + await fs.mkdir(mcpServersDir, { recursive: true }) + } catch (error) { + return "~/Documents/Cline/MCP" // in case creating a directory in documents fails for whatever reason (e.g. permissions) - this is fine since this path is only ever used in the system prompt + } + return mcpServersDir +} + +export async function ensureSettingsDirectoryExists(context: vscode.ExtensionContext): Promise { + const settingsDir = path.join(context.globalStorageUri.fsPath, "settings") + await fs.mkdir(settingsDir, { recursive: true }) + return settingsDir +} + export async function getSavedApiConversationHistory( context: vscode.ExtensionContext, taskId: string, diff --git a/src/core/storage/state-keys.ts b/src/core/storage/state-keys.ts index 759a664b..48478002 100644 --- a/src/core/storage/state-keys.ts +++ b/src/core/storage/state-keys.ts @@ -38,6 +38,7 @@ export type GlobalStateKey = | "openAiBaseUrl" | "openAiModelId" | "openAiModelInfo" + | "openAiHeaders" | "ollamaModelId" | "ollamaBaseUrl" | "ollamaApiOptionsCtxNum" @@ -49,6 +50,7 @@ export type GlobalStateKey = | "openRouterModelInfo" | "openRouterProviderSorting" | "autoApprovalSettings" + | "globalClineRulesToggles" | "browserSettings" | "chatSettings" | "vsCodeLmModelSelector" @@ -74,3 +76,4 @@ export type GlobalStateKey = | "planActSeparateModelsSetting" | "favoritedModelIds" | "shengsuanyunToken" +export type LocalStateKey = "localClineRulesToggles" diff --git a/src/core/storage/state.ts b/src/core/storage/state.ts index cc2b647f..bbd17ecf 100644 --- a/src/core/storage/state.ts +++ b/src/core/storage/state.ts @@ -10,6 +10,7 @@ import { BrowserSettings } from "../../shared/BrowserSettings" import { ChatSettings } from "../../shared/ChatSettings" import { TelemetrySetting } from "../../shared/TelemetrySetting" import { UserInfo } from "../../shared/UserInfo" +import { ClineRulesToggles } from "../../shared/cline-rules" /* Storage https://dev.to/kompotkot/how-to-use-secretstorage-in-your-vscode-extensions-2hco @@ -72,6 +73,7 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) { openAiApiKey, openAiModelId, openAiModelInfo, + openAiHeaders, ollamaModelId, ollamaBaseUrl, ollamaApiOptionsCtxNum, @@ -123,6 +125,7 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) { shengsuanyunToken, planActSeparateModelsSettingRaw, favoritedModelIds, + globalClineRulesToggles, ] = await Promise.all([ getGlobalState(context, "apiProvider") as Promise, getGlobalState(context, "apiModelId") as Promise, @@ -144,6 +147,7 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) { getSecret(context, "openAiApiKey") as Promise, getGlobalState(context, "openAiModelId") as Promise, getGlobalState(context, "openAiModelInfo") as Promise, + getGlobalState(context, "openAiHeaders") as Promise | undefined>, getGlobalState(context, "ollamaModelId") as Promise, getGlobalState(context, "ollamaBaseUrl") as Promise, getGlobalState(context, "ollamaApiOptionsCtxNum") as Promise, @@ -195,6 +199,7 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) { getGlobalState(context, "shengsuanyunToken") as Promise, getGlobalState(context, "planActSeparateModelsSetting") as Promise, getGlobalState(context, "favoritedModelIds") as Promise, + getGlobalState(context, "globalClineRulesToggles") as Promise, ]) let apiProvider: ApiProvider @@ -211,6 +216,8 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) { } } + const localClineRulesToggles = (await getWorkspaceState(context, "localClineRulesToggles")) as ClineRulesToggles + const o3MiniReasoningEffort = vscode.workspace .getConfiguration("clineShengsuan.modelSettings.o3Mini") .get("reasoningEffort", "medium") @@ -257,6 +264,7 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) { openAiApiKey, openAiModelId, openAiModelInfo, + openAiHeaders: openAiHeaders || {}, ollamaModelId, ollamaBaseUrl, ollamaApiOptionsCtxNum, @@ -299,6 +307,8 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) { customInstructions, taskHistory, autoApprovalSettings: autoApprovalSettings || DEFAULT_AUTO_APPROVAL_SETTINGS, // default value can be 0 or empty string + globalClineRulesToggles: globalClineRulesToggles || {}, + localClineRulesToggles: localClineRulesToggles || {}, browserSettings: { ...DEFAULT_BROWSER_SETTINGS, ...browserSettings }, // this will ensure that older versions of browserSettings (e.g. before remoteBrowserEnabled was added) are merged with the default values (false for remoteBrowserEnabled) chatSettings: chatSettings || DEFAULT_CHAT_SETTINGS, userInfo, @@ -335,6 +345,7 @@ export async function updateApiConfiguration(context: vscode.ExtensionContext, a openAiApiKey, openAiModelId, openAiModelInfo, + openAiHeaders, ollamaModelId, ollamaBaseUrl, ollamaApiOptionsCtxNum, @@ -392,6 +403,7 @@ export async function updateApiConfiguration(context: vscode.ExtensionContext, a await storeSecret(context, "openAiApiKey", openAiApiKey) await updateGlobalState(context, "openAiModelId", openAiModelId) await updateGlobalState(context, "openAiModelInfo", openAiModelInfo) + await updateGlobalState(context, "openAiHeaders", openAiHeaders || {}) await updateGlobalState(context, "ollamaModelId", ollamaModelId) await updateGlobalState(context, "ollamaBaseUrl", ollamaBaseUrl) await updateGlobalState(context, "ollamaApiOptionsCtxNum", ollamaApiOptionsCtxNum) diff --git a/src/core/task/index.ts b/src/core/task/index.ts index a1666f8d..7f72d21b 100644 --- a/src/core/task/index.ts +++ b/src/core/task/index.ts @@ -55,7 +55,7 @@ import { DEFAULT_LANGUAGE_SETTINGS, getLanguageKey, LanguageDisplay } from "../. import { ClineAskResponse, ClineCheckpointRestore } from "../../shared/WebviewMessage" import { calculateApiCostAnthropic } from "../../utils/cost" import { fileExistsAtPath } from "../../utils/fs" -import { arePathsEqual, getReadablePath } from "../../utils/path" +import { arePathsEqual, getReadablePath, isLocatedInWorkspace } from "../../utils/path" import { fixModelHtmlEscaping, removeInvalidChars } from "../../utils/string" import { AssistantMessageContent, parseAssistantMessage, ToolParamName, ToolUseName } from ".././assistant-message" import { constructNewFileContent } from ".././assistant-message/diff" @@ -70,21 +70,27 @@ import { checkIsAnthropicContextWindowError, checkIsOpenRouterContextWindowError, } from "../context/context-management/context-error-handling" -import WorkspaceTracker from "../../integrations/workspace/WorkspaceTracker" -import { McpHub } from "../../services/mcp/McpHub" import { ContextManager } from "../context/context-management/ContextManager" -import { getClineRules } from "../context/instructions/user-instructions/cline-rules" import { loadMcpDocumentation } from "../prompts/loadMcpDocumentation" import { + ensureRulesDirectoryExists, ensureTaskDirectoryExists, getSavedApiConversationHistory, getSavedClineMessages, saveApiConversationHistory, saveClineMessages, } from "../storage/disk" +import { + getGlobalClineRules, + getLocalClineRules, + refreshClineRulesToggles, +} from "../context/instructions/user-instructions/cline-rules" import { getGlobalState } from "../storage/state" +import WorkspaceTracker from "../../integrations/workspace/WorkspaceTracker" +import { McpHub } from "../../services/mcp/McpHub" -const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? path.join(os.homedir(), "Desktop") // may or may not exist but fs checking existence would immediately ask for permission which would be bad UX, need to come up with a better solution +export const cwd = + vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? path.join(os.homedir(), "Desktop") // may or may not exist but fs checking existence would immediately ask for permission which would be bad UX, need to come up with a better solution type ToolResponse = string | Array type UserContent = Array @@ -301,9 +307,13 @@ export class Task { } } - async restoreCheckpoint(messageTs: number, restoreType: ClineCheckpointRestore) { - const messageIndex = this.clineMessages.findIndex((m) => m.ts === messageTs) + async restoreCheckpoint(messageTs: number, restoreType: ClineCheckpointRestore, offset?: number) { + const messageIndex = this.clineMessages.findIndex((m) => m.ts === messageTs) - (offset || 0) + // Find the last message before messageIndex that has a lastCheckpointHash + const lastHashIndex = findLastIndex(this.clineMessages.slice(0, messageIndex), (m) => m.lastCheckpointHash !== undefined) const message = this.clineMessages[messageIndex] + const lastMessageWithHash = this.clineMessages[lastHashIndex] + if (!message) { console.error("Message not found", this.clineMessages) return @@ -336,6 +346,14 @@ export class Task { vscode.window.showErrorMessage("Failed to restore checkpoint: " + errorMessage) didWorkspaceRestoreFail = true } + } else if (offset && lastMessageWithHash.lastCheckpointHash && this.checkpointTracker) { + try { + await this.checkpointTracker.resetHead(lastMessageWithHash.lastCheckpointHash) + } catch (error) { + const errorMessage = error instanceof Error ? error.message : "Unknown error" + vscode.window.showErrorMessage("Failed to restore offsetcheckpoint: " + errorMessage) + didWorkspaceRestoreFail = true + } } break } @@ -433,7 +451,7 @@ export class Task { return } - // TODO: handle if this is called from outside original workspace, in which case we need to show user error message we cant show diff outside of workspace? + // TODO: handle if this is called from outside original workspace, in which case we need to show user error message we can't show diff outside of workspace? if (!this.checkpointTracker && !this.checkpointTrackerErrorMessage) { try { this.checkpointTracker = await CheckpointTracker.create(this.taskId, this.context.globalStorageUri.fsPath) @@ -878,7 +896,7 @@ export class Task { await this.overwriteClineMessages(modifiedClineMessages) this.clineMessages = await getSavedClineMessages(this.getContext(), this.taskId) - // Now present the cline messages to the user and ask if they want to resume (NOTE: we ran into a bug before where the apiconversationhistory wouldnt be initialized when opening a old task, and it was because we were waiting for resume) + // Now present the cline messages to the user and ask if they want to resume (NOTE: we ran into a bug before where the apiconversationhistory wouldn't be initialized when opening a old task, and it was because we were waiting for resume) // This is important in case the user deletes messages without resuming the task first this.apiConversationHistory = await getSavedApiConversationHistory(this.getContext(), this.taskId) @@ -1119,34 +1137,85 @@ export class Task { let userFeedback: { text?: string; images?: string[] } | undefined let didContinue = false - const sendCommandOutput = async (line: string): Promise => { + + // Chunked terminal output buffering + const CHUNK_LINE_COUNT = 20 + const CHUNK_BYTE_SIZE = 2048 // 2KB + const CHUNK_DEBOUNCE_MS = 100 + + let outputBuffer: string[] = [] + let outputBufferSize: number = 0 + let chunkTimer: NodeJS.Timeout | null = null + let chunkEnroute = false + + const flushBuffer = async (force = false) => { + if (chunkEnroute || outputBuffer.length === 0) { + if (force && !chunkEnroute && outputBuffer.length > 0) { + // If force is true and no chunkEnroute, flush anyway + } else { + return + } + } + const chunk = outputBuffer.join("\n") + outputBuffer = [] + outputBufferSize = 0 + chunkEnroute = true try { - const { response, text, images } = await this.ask("command_output", line) + const { response, text, images } = await this.ask("command_output", chunk) if (response === "yesButtonClicked") { // proceed while running } else { userFeedback = { text, images } } didContinue = true - process.continue() // continue past the await + process.continue() } catch { - // This can only happen if this ask promise was ignored, so ignore this error + // ask promise was ignored + } finally { + chunkEnroute = false + // If more output accumulated while chunkEnroute, flush again + if (outputBuffer.length > 0) { + await flushBuffer() + } } } + const scheduleFlush = () => { + if (chunkTimer) { + clearTimeout(chunkTimer) + } + chunkTimer = setTimeout(() => flushBuffer(), CHUNK_DEBOUNCE_MS) + } + let result = "" process.on("line", (line) => { result += line + "\n" + if (!didContinue) { - sendCommandOutput(line) + outputBuffer.push(line) + outputBufferSize += Buffer.byteLength(line, "utf8") + // Flush if buffer is large enough + if (outputBuffer.length >= CHUNK_LINE_COUNT || outputBufferSize >= CHUNK_BYTE_SIZE) { + flushBuffer() + } else { + scheduleFlush() + } } else { this.say("command_output", line) } }) let completed = false - process.once("completed", () => { + process.once("completed", async () => { completed = true + // Flush any remaining buffered output + if (!didContinue && outputBuffer.length > 0) { + if (chunkTimer) { + clearTimeout(chunkTimer) + chunkTimer = null + } + await flushBuffer(true) + } }) process.once("no_shell_integration", async () => { @@ -1279,7 +1348,12 @@ export class Task { ? `# Preferred Language\n\nSpeak in ${preferredLanguage}.` : "" - const clineRulesFileInstructions = await getClineRules(cwd) + const { globalToggles, localToggles } = await refreshClineRulesToggles(this.getContext(), cwd) + + const globalClineRulesFilePath = await ensureRulesDirectoryExists() + const globalClineRulesFileInstructions = await getGlobalClineRules(globalClineRulesFilePath, globalToggles) + + const localClineRulesFileInstructions = await getLocalClineRules(cwd, localToggles) const clineIgnoreContent = this.clineIgnoreController.clineIgnoreContent let clineIgnoreInstructions: string | undefined @@ -1289,14 +1363,16 @@ export class Task { if ( settingsCustomInstructions || - clineRulesFileInstructions || + globalClineRulesFileInstructions || + localClineRulesFileInstructions || clineIgnoreInstructions || preferredLanguageInstructions ) { // altering the system prompt mid-task will break the prompt cache, but in the grand scheme this will not change often so it's better to not pollute user messages with it the way we have to with systemPrompt += addUserInstructions( settingsCustomInstructions, - clineRulesFileInstructions, + globalClineRulesFileInstructions, + localClineRulesFileInstructions, clineIgnoreInstructions, preferredLanguageInstructions, ) @@ -1749,6 +1825,7 @@ export class Task { tool: fileExists ? "editedExistingFile" : "newFileCreated", path: getReadablePath(cwd, removeClosingTag("path", relPath)), content: diff || content, + operationIsLocatedInWorkspace: isLocatedInWorkspace(relPath), } if (block.partial) { @@ -1812,6 +1889,7 @@ export class Task { const completeMessage = JSON.stringify({ ...sharedMessageProps, content: diff || content, + operationIsLocatedInWorkspace: isLocatedInWorkspace(relPath), // ? formatResponse.createPrettyPatch( // relPath, // this.diffViewProvider.originalContent, @@ -1937,6 +2015,7 @@ export class Task { const partialMessage = JSON.stringify({ ...sharedMessageProps, content: undefined, + operationIsLocatedInWorkspace: isLocatedInWorkspace(relPath), } satisfies ClineSayTool) if (this.shouldAutoApproveToolWithPath(block.name, block.params.path)) { this.removeLastPartialMessageIfExistsWithType("ask", "tool") @@ -1967,6 +2046,7 @@ export class Task { const completeMessage = JSON.stringify({ ...sharedMessageProps, content: absolutePath, + operationIsLocatedInWorkspace: isLocatedInWorkspace(relPath), } satisfies ClineSayTool) if (this.shouldAutoApproveToolWithPath(block.name, block.params.path)) { this.removeLastPartialMessageIfExistsWithType("ask", "tool") @@ -2014,6 +2094,7 @@ export class Task { const partialMessage = JSON.stringify({ ...sharedMessageProps, content: "", + operationIsLocatedInWorkspace: isLocatedInWorkspace(block.params.path), } satisfies ClineSayTool) if (this.shouldAutoApproveToolWithPath(block.name, block.params.path)) { this.removeLastPartialMessageIfExistsWithType("ask", "tool") @@ -2045,6 +2126,7 @@ export class Task { const completeMessage = JSON.stringify({ ...sharedMessageProps, content: result, + operationIsLocatedInWorkspace: isLocatedInWorkspace(block.params.path), } satisfies ClineSayTool) if (this.shouldAutoApproveToolWithPath(block.name, block.params.path)) { this.removeLastPartialMessageIfExistsWithType("ask", "tool") @@ -2084,6 +2166,7 @@ export class Task { const partialMessage = JSON.stringify({ ...sharedMessageProps, content: "", + operationIsLocatedInWorkspace: isLocatedInWorkspace(block.params.path), } satisfies ClineSayTool) if (this.shouldAutoApproveToolWithPath(block.name, block.params.path)) { this.removeLastPartialMessageIfExistsWithType("ask", "tool") @@ -2112,6 +2195,7 @@ export class Task { const completeMessage = JSON.stringify({ ...sharedMessageProps, content: result, + operationIsLocatedInWorkspace: isLocatedInWorkspace(block.params.path), } satisfies ClineSayTool) if (this.shouldAutoApproveToolWithPath(block.name, block.params.path)) { this.removeLastPartialMessageIfExistsWithType("ask", "tool") @@ -2155,6 +2239,7 @@ export class Task { const partialMessage = JSON.stringify({ ...sharedMessageProps, content: "", + operationIsLocatedInWorkspace: isLocatedInWorkspace(block.params.path), } satisfies ClineSayTool) if (this.shouldAutoApproveToolWithPath(block.name, block.params.path)) { this.removeLastPartialMessageIfExistsWithType("ask", "tool") @@ -2191,6 +2276,7 @@ export class Task { const completeMessage = JSON.stringify({ ...sharedMessageProps, content: results, + operationIsLocatedInWorkspace: isLocatedInWorkspace(block.params.path), } satisfies ClineSayTool) if (this.shouldAutoApproveToolWithPath(block.name, block.params.path)) { this.removeLastPartialMessageIfExistsWithType("ask", "tool") @@ -2402,7 +2488,7 @@ export class Task { try { if (block.partial) { if (this.shouldAutoApproveTool(block.name)) { - // since depending on an upcoming parameter, requiresApproval this may become an ask - we cant partially stream a say prematurely. So in this particular case we have to wait for the requiresApproval parameter to be completed before presenting it. + // since depending on an upcoming parameter, requiresApproval this may become an ask - we can't partially stream a say prematurely. So in this particular case we have to wait for the requiresApproval parameter to be completed before presenting it. // await this.say( // "command", // removeClosingTag("command", command), @@ -2448,7 +2534,7 @@ export class Task { let didAutoApprove = false - // If the model says this command is safe and auto aproval for safe commands is true, execute the command + // If the model says this command is safe and auto approval for safe commands is true, execute the command // If the model says the command is risky, but *BOTH* auto approve settings are true, execute the command const autoApproveResult = this.shouldAutoApproveTool(block.name) const [autoApproveSafe, autoApproveAll] = Array.isArray(autoApproveResult) @@ -2972,7 +3058,7 @@ export class Task { ) } else { // last message is completion_result - // we have command string, which means we have the result as well, so finish it (doesnt have to exist yet) + // we have command string, which means we have the result as well, so finish it (doesn't have to exist yet) await this.say("completion_result", removeClosingTag("result", result), undefined, false) await this.saveCheckpoint(true) await addNewChangesFlagToLastCompletionResultMessage() @@ -3008,7 +3094,7 @@ export class Task { let commandResult: ToolResponse | undefined if (command) { if (lastMessage && lastMessage.ask !== "command") { - // havent sent a command message yet so first send completion_result then command + // haven't sent a command message yet so first send completion_result then command await this.say("completion_result", result, undefined, false) await this.saveCheckpoint(true) await addNewChangesFlagToLastCompletionResultMessage() @@ -3377,7 +3463,7 @@ export class Task { if (this.didRejectTool) { // userContent has a tool rejection, so interrupt the assistant's response to present the user's feedback assistantMessage += "\n\n[Response interrupted by user feedback]" - // this.userMessageContentReady = true // instead of setting this premptively, we allow the present iterator to finish and set userMessageContentReady when its ready + // this.userMessageContentReady = true // instead of setting this preemptively, we allow the present iterator to finish and set userMessageContentReady when its ready break } @@ -3432,7 +3518,7 @@ export class Task { partialBlocks.forEach((block) => { block.partial = false }) - // this.assistantMessageContent.forEach((e) => (e.partial = false)) // cant just do this bc a tool could be in the middle of executing () + // this.assistantMessageContent.forEach((e) => (e.partial = false)) // can't just do this bc a tool could be in the middle of executing () if (partialBlocks.length > 0) { this.presentAssistantMessage() // if there is content to update then it will complete and update this.userMessageContentReady to true, which we pwaitfor before making the next request. all this is really doing is presenting the last partial message that we just set to complete } diff --git a/src/core/webview/index.ts b/src/core/webview/index.ts index 646e2697..8dae0206 100644 --- a/src/core/webview/index.ts +++ b/src/core/webview/index.ts @@ -193,7 +193,7 @@ export class WebviewProvider implements vscode.WebviewViewProvider { /* content security policy of your webview to only allow scripts that have a specific nonce create a content security policy meta tag so that only loading scripts with a nonce is allowed - As your extension grows you will likely want to add custom styles, fonts, and/or images to your webview. If you do, you will need to update the content security policy meta tag to explicity allow for these resources. E.g. + As your extension grows you will likely want to add custom styles, fonts, and/or images to your webview. If you do, you will need to update the content security policy meta tag to explicitly allow for these resources. E.g. - 'unsafe-inline' is required for styles due to vscode-webview-toolkit's dynamic style injection - since we pass base64 images to the webview, we need to specify img-src ${webview.cspSource} data:; diff --git a/src/extension.ts b/src/extension.ts index c10ed55a..cfbcc38d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -390,19 +390,40 @@ export function activate(context: vscode.ExtensionContext) { // Register the command handler context.subscriptions.push( - vscode.commands.registerCommand("clineShengsuan.fixWithCline", async (range: vscode.Range, diagnostics: any[]) => { - const editor = vscode.window.activeTextEditor - if (!editor) { - return + vscode.commands.registerCommand( + "clineShengsuan.fixWithCline", + async (range: vscode.Range, diagnostics: vscode.Diagnostic[]) => { + const editor = vscode.window.activeTextEditor + if (!editor) { + return + } + + const selectedText = editor.document.getText(range) + const filePath = editor.document.uri.fsPath + const languageId = editor.document.languageId + + // Send to sidebar provider with diagnostics + const visibleWebview = WebviewProvider.getVisibleInstance() + await visibleWebview?.controller.fixWithCline(selectedText, filePath, languageId, diagnostics) + }, + ), + ) + + // Register the focusChatInput command handler + context.subscriptions.push( + vscode.commands.registerCommand("cline.focusChatInput", () => { + let visibleWebview = WebviewProvider.getVisibleInstance() + if (!visibleWebview) { + vscode.commands.executeCommand("claude-dev.SidebarProvider.focus") + visibleWebview = WebviewProvider.getSidebarInstance() + // showing the extension will call didBecomeVisible which focuses it already + // but it doesn't focus if a tab is selected which focusChatInput accounts for } - const selectedText = editor.document.getText(range) - const filePath = editor.document.uri.fsPath - const languageId = editor.document.languageId - - // Send to sidebar provider with diagnostics - const visibleWebview = WebviewProvider.getVisibleInstance() - await visibleWebview?.controller.fixWithCline(selectedText, filePath, languageId, diagnostics) + visibleWebview?.controller.postMessageToWebview({ + type: "action", + action: "focusChatInput", + }) }), ) diff --git a/src/integrations/diagnostics/DiagnosticsMonitor.ts b/src/integrations/diagnostics/DiagnosticsMonitor.ts index 67735674..0cd3add1 100644 --- a/src/integrations/diagnostics/DiagnosticsMonitor.ts +++ b/src/integrations/diagnostics/DiagnosticsMonitor.ts @@ -61,7 +61,7 @@ class DiagnosticsMonitor { return currentDiagnostics } - let timeout = 300 // only way this happens is if theres no errors + let timeout = 300 // only way this happens is if there's no errors // if diagnostics contain existing errors (since the check above didn't trigger) then it's likely cline just did something that should have fixed the error, so we'll give a longer grace period for diagnostics to catch up const hasErrors = currentDiagnostics.some(([_, diagnostics]) => diff --git a/src/integrations/editor/DiffViewProvider.ts b/src/integrations/editor/DiffViewProvider.ts index 9a059970..3b2a1b4d 100644 --- a/src/integrations/editor/DiffViewProvider.ts +++ b/src/integrations/editor/DiffViewProvider.ts @@ -289,7 +289,7 @@ export class DiffViewProvider { updatedDocument.positionAt(updatedDocument.getText().length), ) edit.replace(updatedDocument.uri, fullRange, this.originalContent ?? "") - // Apply the edit and save, since contents shouldnt have changed this wont show in local history unless of course the user made changes and saved during the edit + // Apply the edit and save, since contents shouldn't have changed this won't show in local history unless of course the user made changes and saved during the edit await vscode.workspace.applyEdit(edit) await updatedDocument.save() console.log(`File ${absolutePath} has been reverted to its original content.`) diff --git a/src/integrations/misc/open-file.ts b/src/integrations/misc/open-file.ts index 9cd88708..3c69a611 100644 --- a/src/integrations/misc/open-file.ts +++ b/src/integrations/misc/open-file.ts @@ -13,7 +13,7 @@ export async function openImage(dataUri: string) { const imageBuffer = Buffer.from(base64Data, "base64") const tempFilePath = path.join(os.tmpdir(), `temp_image_${Date.now()}.${format}`) try { - await vscode.workspace.fs.writeFile(vscode.Uri.file(tempFilePath), imageBuffer) + await vscode.workspace.fs.writeFile(vscode.Uri.file(tempFilePath), new Uint8Array(imageBuffer)) await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(tempFilePath)) } catch (error) { vscode.window.showErrorMessage(`Error opening image: ${error}`) diff --git a/src/integrations/terminal/TerminalProcess.ts b/src/integrations/terminal/TerminalProcess.ts index c0cf6e49..0528503d 100644 --- a/src/integrations/terminal/TerminalProcess.ts +++ b/src/integrations/terminal/TerminalProcess.ts @@ -94,8 +94,17 @@ export class TerminalProcess extends EventEmitter { data = stripAnsi(data) } + // Ctrl+C detection: if user presses Ctrl+C, treat as command terminated + if (data.includes("^C") || data.includes("\u0003")) { + if (this.hotTimer) { + clearTimeout(this.hotTimer) + } + this.isHot = false + break + } + // first few chunks could be the command being echoed back, so we must ignore - // note this means that 'echo' commands wont work + // note this means that 'echo' commands won't work if (!didOutputNonCommand) { const lines = data.split("\n") for (let i = 0; i < lines.length; i++) { @@ -145,7 +154,7 @@ export class TerminalProcess extends EventEmitter { isCompiling ? PROCESS_HOT_TIMEOUT_COMPILING : PROCESS_HOT_TIMEOUT_NORMAL, ) - // For non-immediately returning commands we want to show loading spinner right away but this wouldnt happen until it emits a line break, so as soon as we get any output we emit "" to let webview know to show spinner + // For non-immediately returning commands we want to show loading spinner right away but this wouldn't happen until it emits a line break, so as soon as we get any output we emit "" to let webview know to show spinner if (!didEmitEmptyLine && !this.fullOutput && data) { this.emit("line", "") // empty line to indicate start of command output stream didEmitEmptyLine = true diff --git a/src/services/search/file-search.ts b/src/services/search/file-search.ts index 9f55028b..947ba2da 100644 --- a/src/services/search/file-search.ts +++ b/src/services/search/file-search.ts @@ -120,7 +120,7 @@ export async function searchWorkspaceFiles( limit: limit * 2, }) - // The min threshold value will require some testing and tuning as the scores are exponential, and exagerated + // The min threshold value will require some testing and tuning as the scores are exponential, and exaggerated const MIN_SCORE_THRESHOLD = 100 // Filter results by score and map to original items diff --git a/src/services/telemetry/TelemetryService.ts b/src/services/telemetry/TelemetryService.ts index b266ee47..27fa2c46 100644 --- a/src/services/telemetry/TelemetryService.ts +++ b/src/services/telemetry/TelemetryService.ts @@ -3,6 +3,7 @@ import * as vscode from "vscode" import { version as extensionVersion } from "../../../package.json" import type { TaskFeedbackType } from "../../shared/WebviewMessage" +import type { BrowserSettings } from "../../shared/BrowserSettings" /** * PostHogClient handles telemetry event tracking for the Cline extension @@ -474,7 +475,7 @@ class PostHogClient { * @param taskId Unique identifier for the task * @param browserSettings The browser settings being used */ - public captureBrowserToolStart(taskId: string, browserSettings: any) { + public captureBrowserToolStart(taskId: string, browserSettings: BrowserSettings) { this.capture({ event: PostHogClient.EVENTS.TASK.BROWSER_TOOL_START, properties: { diff --git a/src/services/test/GitHelper.ts b/src/services/test/GitHelper.ts new file mode 100644 index 00000000..6f65ab62 --- /dev/null +++ b/src/services/test/GitHelper.ts @@ -0,0 +1,245 @@ +import * as path from "path" +import * as vscode from "vscode" +import { execa } from "execa" +import { Logger } from "../../services/logging/Logger" +import { WebviewProvider } from "../../core/webview" + +/** + * Gets a valid workspace path for Git operations + * @param visibleWebview The visible webview instance + * @returns A valid workspace path + */ +export function getWorkspacePath(visibleWebview: WebviewProvider): string { + // First try to get the path from the controller's state + let workspacePath = visibleWebview.controller.context.workspaceState.get("cwd") || "" + + // If workspace path is empty, try to get it from the active workspace folder + if (!workspacePath) { + const workspaceFolders = vscode.workspace.workspaceFolders + if (workspaceFolders && workspaceFolders.length > 0) { + workspacePath = workspaceFolders[0].uri.fsPath + Logger.log(`Using workspace folder path: ${workspacePath}`) + } else { + // If no workspace folder is open, use the extension directory as a fallback + workspacePath = path.join(__dirname, "..", "..", "..") + Logger.log(`No workspace folder found, using extension directory: ${workspacePath}`) + } + } + + return workspacePath +} + +/** + * Validates that the workspace path is valid and writable for Git operations + * @param workspacePath The workspace path to validate + * @throws Error if the workspace path is invalid or not writable + */ +export async function validateWorkspacePath(workspacePath: string): Promise { + // Check if workspace path is valid + if (!workspacePath || workspacePath === "/") { + throw new Error(`Invalid workspace path: ${workspacePath}. Cannot initialize Git repository.`) + } + + // Check if the directory exists + try { + const { stdout } = await execa("test", ["-d", workspacePath]) + } catch (error) { + throw new Error(`Workspace path does not exist or is not a directory: ${workspacePath}`) + } + + // Check if the directory is writable + try { + const testFile = path.join(workspacePath, ".cline_write_test") + await execa("touch", [testFile]) + await execa("rm", [testFile]) + } catch (error) { + throw new Error(`Workspace path is not writable: ${workspacePath}. Error: ${error.message}`) + } + + Logger.log(`Validated workspace path: ${workspacePath}`) +} + +/** + * Cleans up any existing Git repository in the specified workspace path + * @param workspacePath The workspace path to clean up + */ +export async function cleanupPreviousGit(workspacePath: string): Promise { + const gitDir = path.join(workspacePath, ".git") + + try { + // Check if .git directory exists using execa since we're already using it + try { + await execa("test", ["-d", gitDir]) + // If we get here, the directory exists + Logger.log(`Removing existing Git repository in ${workspacePath}`) + + // Use rm -rf to remove the directory + await execa("rm", ["-rf", gitDir]) + Logger.log(`Removed existing Git repository`) + } catch (error) { + // Directory doesn't exist, which is fine + Logger.log(`No existing Git repository found in ${workspacePath}`) + } + } catch (error) { + Logger.log(`Warning: Failed to remove existing Git repository: ${error.message}`) + } +} + +/** + * Initializes a Git repository in the specified workspace path + * @param workspacePath The workspace path to initialize Git in + * @returns True if the repository was newly initialized + */ +export async function initializeGitRepository(workspacePath: string): Promise { + // Validate workspace path before proceeding + await validateWorkspacePath(workspacePath) + + // Clean up any existing Git repository + await cleanupPreviousGit(workspacePath) + + // Initialize a new Git repository + Logger.log(`Initializing Git repository in ${workspacePath}`) + try { + await execa("git", ["init"], { cwd: workspacePath }) + await execa("git", ["config", "user.name", "Cline Evaluation"], { cwd: workspacePath }) + await execa("git", ["config", "user.email", "cline@example.com"], { cwd: workspacePath }) + + // Try to create an initial commit, but don't fail if there are no files to commit + try { + // Check if there are any files to commit + const { stdout: statusOutput } = await execa("git", ["status", "--porcelain"], { cwd: workspacePath }) + + if (statusOutput.trim()) { + // There are files to commit + await execa("git", ["add", "."], { cwd: workspacePath }) + await execa("git", ["commit", "-m", "Initial commit for evaluation"], { cwd: workspacePath }) + Logger.log("Created initial Git commit in " + workspacePath) + } else { + // No files to commit, create an empty commit + Logger.log("No files to commit, creating empty initial commit") + try { + // Create an empty commit with --allow-empty + await execa("git", ["commit", "--allow-empty", "-m", "Initial empty commit for evaluation"], { + cwd: workspacePath, + }) + Logger.log("Created empty initial commit in " + workspacePath) + } catch (emptyCommitError) { + // Even empty commit failed, but we'll continue anyway + Logger.log(`Warning: Failed to create empty commit: ${emptyCommitError.message}`) + } + } + } catch (commitError) { + // Initial commit failed, but Git is still initialized + Logger.log(`Warning: Failed to create initial commit: ${commitError.message}`) + Logger.log("Continuing without initial commit") + } + + return true + } catch (gitError) { + // Only throw if Git initialization itself failed + const errorMessage = `Failed to initialize Git repository: ${gitError.message}` + Logger.log(errorMessage) + throw new Error(errorMessage) + } +} + +/** + * Gets the file changes between the current state and the initial state + * @param workspacePath The workspace path to check for changes + * @returns Object containing lists of created, modified, and deleted files, plus the full diff + */ +export async function getFileChanges(workspacePath: string): Promise<{ + created: string[] + modified: string[] + deleted: string[] + diff: string +}> { + // Validate workspace path before proceeding + await validateWorkspacePath(workspacePath) + + // Make sure all changes are staged so they appear in the diff + Logger.log(`Staging all changes in ${workspacePath} for diff`) + try { + // First check if there are any untracked files + const { stdout: untrackedOutput } = await execa("git", ["ls-files", "--others", "--exclude-standard"], { + cwd: workspacePath, + }) + if (untrackedOutput.trim()) { + Logger.log(`Found untracked files: ${untrackedOutput}`) + } + + // Stage all changes including untracked files + await execa("git", ["add", "-A"], { cwd: workspacePath }) + Logger.log("Staged all changes for diff") + } catch (error) { + Logger.log(`Warning: Failed to stage changes: ${error.message}`) + } + + try { + // Get list of changed files + const { stdout: statusOutput } = await execa("git", ["status", "--porcelain"], { cwd: workspacePath }) + Logger.log(`Git status output: ${statusOutput || "(empty)"}`) + + const created: string[] = [] + const modified: string[] = [] + const deleted: string[] = [] + + // Parse git status output + statusOutput + .split("\n") + .filter(Boolean) + .forEach((line) => { + const status = line.substring(0, 2).trim() + const file = line.substring(3) + + if (status === "A" || status === "??") { + created.push(file) + } else if (status === "M") { + modified.push(file) + } else if (status === "D") { + deleted.push(file) + } + }) + + // Get the full diff - include both staged and unstaged changes + const { stdout: diffOutput } = await execa("git", ["diff", "--staged"], { cwd: workspacePath }) + Logger.log(`Git diff output length: ${diffOutput.length} characters`) + + // If there's no diff, try getting the diff of unstaged changes + let finalDiff = diffOutput + if (!finalDiff) { + const { stdout: unstaged } = await execa("git", ["diff"], { cwd: workspacePath }) + finalDiff = unstaged + Logger.log(`Unstaged git diff output length: ${unstaged.length} characters`) + } + + return { + created, + modified, + deleted, + diff: finalDiff, + } + } catch (error) { + // Throw the error instead of returning a fallback + const errorMessage = `Error getting file changes: ${error.message}` + Logger.log(errorMessage) + throw new Error(errorMessage) + } +} + +/** + * Calculates the tool success rate based on calls and failures + * @param toolCalls Record of tool calls by name + * @param toolFailures Record of tool failures by name + * @returns The success rate as a number between 0 and 1 + */ +export function calculateToolSuccessRate(toolCalls: Record, toolFailures: Record): number { + const totalCalls = Object.values(toolCalls).reduce((a, b) => a + b, 0) + const totalFailures = Object.values(toolFailures).reduce((a, b) => a + b, 0) + + if (totalCalls === 0) { + return 1.0 // No calls means no failures + } + + return 1.0 - totalFailures / totalCalls +} diff --git a/src/services/test/TestServer.ts b/src/services/test/TestServer.ts index 401fccd0..a86f8c5f 100644 --- a/src/services/test/TestServer.ts +++ b/src/services/test/TestServer.ts @@ -1,11 +1,66 @@ import * as http from "http" import * as vscode from "vscode" +import * as path from "path" +import { execa } from "execa" import { Logger } from "../../services/logging/Logger" import { WebviewProvider } from "../../core/webview" import { AutoApprovalSettings } from "../../shared/AutoApprovalSettings" -import { updateGlobalState, getAllExtensionState } from "../../core/storage/state" +import { + getWorkspacePath, + validateWorkspacePath, + initializeGitRepository, + getFileChanges, + calculateToolSuccessRate, +} from "./GitHelper" +import { updateGlobalState, getAllExtensionState, updateApiConfiguration, storeSecret } from "../../core/storage/state" import { ClineAsk, ExtensionMessage } from "../../shared/ExtensionMessage" +import { ApiProvider } from "../../shared/api" import { WebviewMessage } from "../../shared/WebviewMessage" +import { HistoryItem } from "../../shared/HistoryItem" +import { getSavedClineMessages, getSavedApiConversationHistory } from "../../core/storage/disk" + +/** + * Creates a tracker to monitor tool calls and failures during task execution + * @param webviewProvider The webview provider instance + * @returns Object tracking tool calls and failures + */ +function createToolCallTracker(webviewProvider: WebviewProvider): { + toolCalls: Record + toolFailures: Record +} { + const tracker = { + toolCalls: {} as Record, + toolFailures: {} as Record, + } + + // Intercept messages to track tool usage + const originalPostMessageToWebview = webviewProvider.controller.postMessageToWebview + webviewProvider.controller.postMessageToWebview = async (message: ExtensionMessage) => { + // Track tool calls + if (message.type === "partialMessage" && message.partialMessage?.say === "tool") { + const toolName = (message.partialMessage.text as any)?.tool + if (toolName) { + tracker.toolCalls[toolName] = (tracker.toolCalls[toolName] || 0) + 1 + } + } + + // Track tool failures + if (message.type === "partialMessage" && message.partialMessage?.say === "error") { + const errorText = message.partialMessage.text + if (errorText && errorText.includes("Error executing tool")) { + const match = errorText.match(/Error executing tool: (\w+)/) + if (match && match[1]) { + const toolName = match[1] + tracker.toolFailures[toolName] = (tracker.toolFailures[toolName] || 0) + 1 + } + } + } + + return originalPostMessageToWebview.call(webviewProvider.controller, message) + } + + return tracker +} // Task completion tracking let taskCompletionResolver: (() => void) | null = null @@ -74,6 +129,13 @@ async function updateAutoApprovalSettings(context: vscode.ExtensionContext, prov * @returns The created HTTP server instance */ export function createTestServer(webviewProvider?: WebviewProvider): http.Server { + // Try to show the Cline sidebar + Logger.log("[createTestServer] Opening Cline in sidebar...") + vscode.commands.executeCommand("workbench.view.claude-dev-ActivityBar") + + // Then ensure the webview is focused/loaded + vscode.commands.executeCommand("claude-dev.SidebarProvider.focus") + // Update auto approval settings if webviewProvider is available if (webviewProvider?.controller?.context) { updateAutoApprovalSettings(webviewProvider.controller.context, webviewProvider) @@ -93,6 +155,19 @@ export function createTestServer(webviewProvider?: WebviewProvider): http.Server return } + // Handle shutdown request + if (req.method === "POST" && req.url === "/shutdown") { + res.writeHead(200) + res.end(JSON.stringify({ success: true, message: "Server shutting down" })) + + // Shut down the server after sending the response + setTimeout(() => { + shutdownTestServer() + }, 100) + + return + } + // Only handle POST requests to /task if (req.method !== "POST" || req.url !== "/task") { res.writeHead(404) @@ -109,7 +184,7 @@ export function createTestServer(webviewProvider?: WebviewProvider): http.Server req.on("end", async () => { try { // Parse the JSON body - const { task } = JSON.parse(body) + const { task, apiKey } = JSON.parse(body) if (!task) { res.writeHead(400) @@ -129,9 +204,76 @@ export function createTestServer(webviewProvider?: WebviewProvider): http.Server Logger.log(`Test server initiating task: ${task}`) try { + // Get and validate the workspace path + const workspacePath = getWorkspacePath(visibleWebview) + Logger.log(`Using workspace path: ${workspacePath}`) + + // Validate workspace path before proceeding with any operations + try { + await validateWorkspacePath(workspacePath) + } catch (error) { + Logger.log(`Workspace validation failed: ${error.message}`) + res.writeHead(500) + res.end( + JSON.stringify({ + error: `Workspace validation failed: ${error.message}. Please open a workspace folder in VSCode before running the test.`, + workspacePath, + }), + ) + return + } + + // Initialize Git repository before starting the task + try { + const wasNewlyInitialized = await initializeGitRepository(workspacePath) + if (wasNewlyInitialized) { + Logger.log(`Initialized new Git repository in ${workspacePath} before task start`) + } else { + Logger.log(`Using existing Git repository in ${workspacePath} before task start`) + } + + // Log directory contents before task start + try { + const { stdout: lsOutput } = await execa("ls", ["-la", workspacePath]) + Logger.log(`Directory contents before task start:\n${lsOutput}`) + } catch (lsError) { + Logger.log(`Warning: Failed to list directory contents: ${lsError.message}`) + } + } catch (gitError) { + Logger.log(`Warning: Git initialization failed: ${gitError.message}`) + Logger.log("Continuing without Git initialization") + } + // Clear any existing task await visibleWebview.controller.clearTask() + // If API key is provided, update the API configuration + if (apiKey) { + Logger.log("API key provided, updating API configuration") + + // Get current API configuration + const { apiConfiguration } = await getAllExtensionState(visibleWebview.controller.context) + + // Update API configuration with API key + const updatedConfig = { + ...apiConfiguration, + apiProvider: "cline" as ApiProvider, + clineApiKey: apiKey, + } + + // Store the API key securely + await storeSecret(visibleWebview.controller.context, "clineApiKey", apiKey) + + // Update the API configuration + await updateApiConfiguration(visibleWebview.controller.context, updatedConfig) + + // Update global state to use cline provider + await updateGlobalState(visibleWebview.controller.context, "apiProvider", "cline" as ApiProvider) + + // Post state to webview to reflect changes + await visibleWebview.controller.postStateToWebview() + } + // Ensure we're in Act mode before initiating the task const { chatSettings } = await visibleWebview.controller.getStateToPostToWebview() if (chatSettings.mode === "plan") { @@ -139,8 +281,47 @@ export function createTestServer(webviewProvider?: WebviewProvider): http.Server await visibleWebview.controller.togglePlanActModeWithChatSettings({ mode: "act" }) } + // Initialize tool call tracker + const toolTracker = createToolCallTracker(visibleWebview) + + // Record task start time + const taskStartTime = Date.now() + // Initiate the new task - const taskId = await visibleWebview.controller.initTask(task) + const result = await visibleWebview.controller.initTask(task) + + // Try to get the task ID directly from the result or from the state + let taskId: string | undefined + + if (typeof result === "string") { + // If initTask returns the task ID directly + taskId = result + } else { + // Wait a moment for the state to update + await new Promise((resolve) => setTimeout(resolve, 1000)) + + // Try to get the task ID from the controller's state + const state = await visibleWebview.controller.getStateToPostToWebview() + taskId = state.currentTaskItem?.id + + // If still not found, try polling a few times + if (!taskId) { + for (let i = 0; i < 5; i++) { + await new Promise((resolve) => setTimeout(resolve, 500)) + const updatedState = await visibleWebview.controller.getStateToPostToWebview() + taskId = updatedState.currentTaskItem?.id + if (taskId) { + break + } + } + } + } + + if (!taskId) { + throw new Error("Failed to get task ID after initiating task") + } + + Logger.log(`Task initiated with ID: ${taskId}`) // Create a completion tracker for this task const completionPromise = createTaskCompletionTracker() @@ -154,13 +335,110 @@ export function createTestServer(webviewProvider?: WebviewProvider): http.Server // Wait for either completion or timeout await Promise.race([completionPromise, timeoutPromise]) - // Return success response with the task ID + // Get task history and metrics + const taskHistory = await visibleWebview.controller.getStateToPostToWebview() + const taskData = taskHistory.taskHistory?.find((t: HistoryItem) => t.id === taskId) + + // Get messages and API conversation history + let messages: any[] = [] + let apiConversationHistory: any[] = [] + try { + if (typeof taskId === "string") { + messages = await getSavedClineMessages(visibleWebview.controller.context, taskId) + } + } catch (error) { + Logger.log(`Error getting saved Cline messages: ${error}`) + } + + try { + if (typeof taskId === "string") { + apiConversationHistory = await getSavedApiConversationHistory( + visibleWebview.controller.context, + taskId, + ) + } + } catch (error) { + Logger.log(`Error getting saved API conversation history: ${error}`) + } + + // Get file changes + let fileChanges + try { + // Get the workspace path using our helper function + const workspacePath = getWorkspacePath(visibleWebview) + Logger.log(`Getting file changes from workspace path: ${workspacePath}`) + + // Log directory contents for debugging + try { + const { stdout: lsOutput } = await execa("ls", ["-la", workspacePath]) + Logger.log(`Directory contents after task completion:\n${lsOutput}`) + } catch (lsError) { + Logger.log(`Warning: Failed to list directory contents: ${lsError.message}`) + } + + // Get file changes using Git + fileChanges = await getFileChanges(workspacePath) + + // If no changes were detected, use a fallback method + if (!fileChanges.created.length && !fileChanges.modified.length && !fileChanges.deleted.length) { + Logger.log("No changes detected by Git, using fallback directory scan") + + // Try to get a list of all files in the directory + try { + const { stdout: findOutput } = await execa("find", [ + workspacePath, + "-type", + "f", + "-not", + "-path", + "*/.*", + "-not", + "-path", + "*/node_modules/*", + ]) + const files = findOutput.split("\n").filter(Boolean) + + // Add all files as "created" since we can't determine which ones are new + fileChanges.created = files.map((file) => path.relative(workspacePath, file)) + Logger.log(`Fallback found ${fileChanges.created.length} files`) + } catch (findError) { + Logger.log(`Warning: Fallback directory scan failed: ${findError.message}`) + } + } + } catch (fileChangeError) { + Logger.log(`Error getting file changes: ${fileChangeError.message}`) + throw new Error(`Error getting file changes: ${fileChangeError.message}`) + } + + // Get tool metrics + const toolMetrics = { + toolCalls: toolTracker.toolCalls, + toolFailures: toolTracker.toolFailures, + totalToolCalls: Object.values(toolTracker.toolCalls).reduce((a, b) => a + b, 0), + totalToolFailures: Object.values(toolTracker.toolFailures).reduce((a, b) => a + b, 0), + toolSuccessRate: calculateToolSuccessRate(toolTracker.toolCalls, toolTracker.toolFailures), + } + + // Calculate task duration + const taskDuration = Date.now() - taskStartTime + + // Return comprehensive response with all metrics and data res.writeHead(200, { "Content-Type": "application/json" }) res.end( JSON.stringify({ success: true, taskId, completed: true, + metrics: { + tokensIn: taskData?.tokensIn || 0, + tokensOut: taskData?.tokensOut || 0, + cost: taskData?.totalCost || 0, + duration: taskDuration, + ...toolMetrics, + }, + messages, + apiConversationHistory, + files: fileChanges, }), ) } catch (timeoutError) { diff --git a/src/services/tree-sitter/index.ts b/src/services/tree-sitter/index.ts index e6c57aa8..90ed28c9 100644 --- a/src/services/tree-sitter/index.ts +++ b/src/services/tree-sitter/index.ts @@ -157,7 +157,7 @@ async function parseFile( formattedOutput += "|----\n" } // Only add the first line of the definition - // query captures includes the definition name and the definition implementation, but we only want the name (I found discrepencies in the naming structure for various languages, i.e. javascript names would be 'name' and typescript names would be 'name.definition) + // query captures includes the definition name and the definition implementation, but we only want the name (I found discrepancies in the naming structure for various languages, i.e. javascript names would be 'name' and typescript names would be 'name.definition) if (name.includes("name") && lines[startLine]) { formattedOutput += `│${lines[startLine]}\n` } diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index 95aa2bc6..6a368c0f 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -9,6 +9,7 @@ import { HistoryItem } from "./HistoryItem" import { McpServer, McpMarketplaceCatalog, McpMarketplaceItem, McpDownloadResponse, McpViewTab } from "./mcp" import { TelemetrySetting } from "./TelemetrySetting" import type { BalanceResponse, UsageTransaction, PaymentTransaction } from "../shared/ClineAccount" +import { ClineRulesToggles } from "./cline-rules" // webview will hold state export interface ExtensionMessage { @@ -43,12 +44,12 @@ export interface ExtensionMessage { | "totalTasksSize" | "addToInput" | "browserConnectionResult" - | "browserConnectionInfo" | "detectedChromePath" | "scrollToSettings" | "browserRelaunchResult" | "relativePathsResponse" // Handles single and multiple path responses | "fileSearchResults" + | "grpc_response" // New type for gRPC responses | "fetchUSDRate" | "ssyModels" text?: string @@ -62,6 +63,7 @@ export interface ExtensionMessage { | "accountLoginClicked" | "accountLogoutClicked" | "accountButtonClicked" + | "focusChatInput" invoke?: Invoke state?: ExtensionState images?: string[] @@ -112,6 +114,11 @@ export interface ExtensionMessage { error?: string } tab?: McpViewTab + grpc_response?: { + message?: any // JSON serialized protobuf message + request_id: string // Same ID as the request + error?: string // Optional error message + } ssyModels?: Record } @@ -141,6 +148,8 @@ export interface ExtensionState { userInfo?: any version: string vscMachineId: string + globalClineRulesToggles: ClineRulesToggles + localClineRulesToggles: ClineRulesToggles } export interface ClineMessage { @@ -154,6 +163,7 @@ export interface ClineMessage { partial?: boolean lastCheckpointHash?: string isCheckpointCheckedOut?: boolean + isOperationOutsideWorkspace?: boolean conversationHistoryIndex?: number conversationHistoryDeletedRange?: [number, number] // for when conversation history is truncated for API requests } @@ -215,6 +225,7 @@ export interface ClineSayTool { content?: string regex?: string filePattern?: string + operationIsLocatedInWorkspace?: boolean } // must keep in sync with system prompt @@ -234,12 +245,6 @@ export type BrowserActionResult = { currentMousePosition?: string } -export interface BrowserConnectionInfo { - isConnected: boolean - isRemote: boolean - host?: string -} - export interface ClineAskUseMcpServer { serverName: string type: "use_mcp_tool" | "access_mcp_resource" diff --git a/src/shared/WebviewMessage.ts b/src/shared/WebviewMessage.ts index 302d8a79..1531c6d3 100644 --- a/src/shared/WebviewMessage.ts +++ b/src/shared/WebviewMessage.ts @@ -29,17 +29,17 @@ export interface WebviewMessage { | "openFile" | "openMention" | "cancelTask" + | "showChatView" | "refreshOpenRouterModels" | "refreshRequestyModels" | "refreshOpenAiModels" + | "refreshClineRules" | "openMcpSettings" | "restartMcpServer" | "deleteMcpServer" | "autoApprovalSettings" | "browserSettings" | "discoverBrowser" - | "testBrowserConnection" - | "browserConnectionResult" | "browserRelaunchResult" | "togglePlanActMode" | "checkpointDiff" @@ -74,17 +74,19 @@ export interface WebviewMessage { | "requestTotalTasksSize" | "relaunchChromeDebugMode" | "taskFeedback" - | "getBrowserConnectionInfo" | "getDetectedChromePath" | "detectedChromePath" | "scrollToSettings" | "getRelativePaths" // Handles single and multiple URI resolution | "searchFiles" | "toggleFavoriteModel" + | "grpc_request" + | "toggleClineRule" + | "deleteClineRule" + // | "relaunchChromeDebugMode" | "fetchUSDRate" | "accountLoginClickedSSY" | "accountLogoutClickedSSY" - // | "relaunchChromeDebugMode" | "ssyModels" text?: string uris?: string[] // Used for getRelativePaths @@ -122,6 +124,17 @@ export interface WebviewMessage { query?: string // For toggleFavoriteModel modelId?: string + grpc_request?: { + service: string + method: string + message: any // JSON serialized protobuf message + request_id: string // For correlating requests and responses + } + // For toggleClineRule + isGlobal?: boolean + rulePath?: string + enabled?: boolean + offset?: number } export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse" diff --git a/src/shared/api.ts b/src/shared/api.ts index 0daa156c..84e69d16 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -1,3 +1,5 @@ +import type { LanguageModelChatSelector } from "../api/providers/types" + export type ApiProvider = | "anthropic" | "openrouter" @@ -31,6 +33,7 @@ export interface ApiHandlerOptions { liteLlmModelId?: string liteLlmApiKey?: string liteLlmUsePromptCache?: boolean + openAiHeaders?: Record // Custom headers for OpenAI requests anthropicBaseUrl?: string openRouterApiKey?: string openRouterModelId?: string @@ -68,7 +71,7 @@ export interface ApiHandlerOptions { doubaoApiKey?: string mistralApiKey?: string azureApiVersion?: string - vsCodeLmModelSelector?: any + vsCodeLmModelSelector?: LanguageModelChatSelector o3MiniReasoningEffort?: string qwenApiLine?: string asksageApiUrl?: string @@ -606,8 +609,53 @@ export const geminiModels = { // OpenAI Native // https://openai.com/api/pricing/ export type OpenAiNativeModelId = keyof typeof openAiNativeModels -export const openAiNativeDefaultModelId: OpenAiNativeModelId = "gpt-4o" +export const openAiNativeDefaultModelId: OpenAiNativeModelId = "gpt-4.1" export const openAiNativeModels = { + o3: { + maxTokens: 100_000, + contextWindow: 200_000, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 10.0, + outputPrice: 40.0, + cacheReadsPrice: 2.5, + }, + "o4-mini": { + maxTokens: 100_000, + contextWindow: 200_000, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 1.1, + outputPrice: 4.4, + cacheReadsPrice: 0.275, + }, + "gpt-4.1": { + maxTokens: 32_768, + contextWindow: 1_047_576, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 2, + outputPrice: 8, + cacheReadsPrice: 0.5, + }, + "gpt-4.1-mini": { + maxTokens: 32_768, + contextWindow: 1_047_576, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 0.4, + outputPrice: 1.6, + cacheReadsPrice: 0.1, + }, + "gpt-4.1-nano": { + maxTokens: 32_768, + contextWindow: 1_047_576, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 0.1, + outputPrice: 0.4, + cacheReadsPrice: 0.025, + }, "o3-mini": { maxTokens: 100_000, contextWindow: 200_000, @@ -1561,6 +1609,22 @@ export const sambanovaModels = { }, } as const satisfies Record +// Requesty +// https://requesty.ai/models +export const requestyDefaultModelId = "anthropic/claude-3-7-sonnet-latest" +export const requestyDefaultModelInfo: ModelInfo = { + maxTokens: 8192, + contextWindow: 200_000, + supportsImages: true, + supportsComputerUse: false, + supportsPromptCache: true, + inputPrice: 3.0, + outputPrice: 15.0, + cacheWritesPrice: 3.75, + cacheReadsPrice: 0.3, + description: "Anthropic's most intelligent model. Highest level of intelligence and capability.", +} + // ShengSuanYun // https://router.shengsuanyun.com/model export type ShengSuanYunModelId = keyof typeof shengsuanyunModels @@ -1666,19 +1730,3 @@ export const shengsuanyunModels = { outputPrice: 0.3, }, } as const satisfies Record - -// Requesty -// https://requesty.ai/models -export const requestyDefaultModelId = "anthropic/claude-3-7-sonnet-latest" -export const requestyDefaultModelInfo: ModelInfo = { - maxTokens: 8192, - contextWindow: 200_000, - supportsImages: true, - supportsComputerUse: false, - supportsPromptCache: true, - inputPrice: 3.0, - outputPrice: 15.0, - cacheWritesPrice: 3.75, - cacheReadsPrice: 0.3, - description: "Anthropic's most intelligent model. Highest level of intelligence and capability.", -} diff --git a/src/shared/cline-rules.ts b/src/shared/cline-rules.ts new file mode 100644 index 00000000..74adb1a3 --- /dev/null +++ b/src/shared/cline-rules.ts @@ -0,0 +1 @@ +export type ClineRulesToggles = Record // filepath -> enabled/disabled diff --git a/src/shared/proto/browser.ts b/src/shared/proto/browser.ts new file mode 100644 index 00000000..0f4d02c4 --- /dev/null +++ b/src/shared/proto/browser.ts @@ -0,0 +1,261 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.7.0 +// protoc v6.30.1 +// source: browser.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire" +import { EmptyRequest, StringRequest } from "./common" + +export const protobufPackage = "cline" + +export interface BrowserConnectionInfo { + isConnected: boolean + isRemote: boolean + host?: string | undefined +} + +export interface BrowserConnection { + success: boolean + message: string + endpoint?: string | undefined +} + +function createBaseBrowserConnectionInfo(): BrowserConnectionInfo { + return { isConnected: false, isRemote: false, host: undefined } +} + +export const BrowserConnectionInfo: MessageFns = { + encode(message: BrowserConnectionInfo, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.isConnected !== false) { + writer.uint32(8).bool(message.isConnected) + } + if (message.isRemote !== false) { + writer.uint32(16).bool(message.isRemote) + } + if (message.host !== undefined) { + writer.uint32(26).string(message.host) + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): BrowserConnectionInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseBrowserConnectionInfo() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 8) { + break + } + + message.isConnected = reader.bool() + continue + } + case 2: { + if (tag !== 16) { + break + } + + message.isRemote = reader.bool() + continue + } + case 3: { + if (tag !== 26) { + break + } + + message.host = reader.string() + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): BrowserConnectionInfo { + return { + isConnected: isSet(object.isConnected) ? globalThis.Boolean(object.isConnected) : false, + isRemote: isSet(object.isRemote) ? globalThis.Boolean(object.isRemote) : false, + host: isSet(object.host) ? globalThis.String(object.host) : undefined, + } + }, + + toJSON(message: BrowserConnectionInfo): unknown { + const obj: any = {} + if (message.isConnected !== false) { + obj.isConnected = message.isConnected + } + if (message.isRemote !== false) { + obj.isRemote = message.isRemote + } + if (message.host !== undefined) { + obj.host = message.host + } + return obj + }, + + create, I>>(base?: I): BrowserConnectionInfo { + return BrowserConnectionInfo.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): BrowserConnectionInfo { + const message = createBaseBrowserConnectionInfo() + message.isConnected = object.isConnected ?? false + message.isRemote = object.isRemote ?? false + message.host = object.host ?? undefined + return message + }, +} + +function createBaseBrowserConnection(): BrowserConnection { + return { success: false, message: "", endpoint: undefined } +} + +export const BrowserConnection: MessageFns = { + encode(message: BrowserConnection, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.success !== false) { + writer.uint32(8).bool(message.success) + } + if (message.message !== "") { + writer.uint32(18).string(message.message) + } + if (message.endpoint !== undefined) { + writer.uint32(26).string(message.endpoint) + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): BrowserConnection { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseBrowserConnection() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 8) { + break + } + + message.success = reader.bool() + continue + } + case 2: { + if (tag !== 18) { + break + } + + message.message = reader.string() + continue + } + case 3: { + if (tag !== 26) { + break + } + + message.endpoint = reader.string() + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): BrowserConnection { + return { + success: isSet(object.success) ? globalThis.Boolean(object.success) : false, + message: isSet(object.message) ? globalThis.String(object.message) : "", + endpoint: isSet(object.endpoint) ? globalThis.String(object.endpoint) : undefined, + } + }, + + toJSON(message: BrowserConnection): unknown { + const obj: any = {} + if (message.success !== false) { + obj.success = message.success + } + if (message.message !== "") { + obj.message = message.message + } + if (message.endpoint !== undefined) { + obj.endpoint = message.endpoint + } + return obj + }, + + create, I>>(base?: I): BrowserConnection { + return BrowserConnection.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): BrowserConnection { + const message = createBaseBrowserConnection() + message.success = object.success ?? false + message.message = object.message ?? "" + message.endpoint = object.endpoint ?? undefined + return message + }, +} + +export type BrowserServiceDefinition = typeof BrowserServiceDefinition +export const BrowserServiceDefinition = { + name: "BrowserService", + fullName: "cline.BrowserService", + methods: { + getBrowserConnectionInfo: { + name: "getBrowserConnectionInfo", + requestType: EmptyRequest, + requestStream: false, + responseType: BrowserConnectionInfo, + responseStream: false, + options: {}, + }, + testBrowserConnection: { + name: "testBrowserConnection", + requestType: StringRequest, + requestStream: false, + responseType: BrowserConnection, + responseStream: false, + options: {}, + }, + }, +} as const + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined + +export type DeepPartial = T extends Builtin + ? T + : T extends globalThis.Array + ? globalThis.Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial + +type KeysOfUnion = T extends T ? keyof T : never +export type Exact = P extends Builtin + ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never } + +function isSet(value: any): boolean { + return value !== null && value !== undefined +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter + decode(input: BinaryReader | Uint8Array, length?: number): T + fromJSON(object: any): T + toJSON(message: T): unknown + create, I>>(base?: I): T + fromPartial, I>>(object: I): T +} diff --git a/src/shared/proto/common.ts b/src/shared/proto/common.ts new file mode 100644 index 00000000..48699ef4 --- /dev/null +++ b/src/shared/proto/common.ts @@ -0,0 +1,644 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.7.0 +// protoc v6.30.1 +// source: common.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire" + +export const protobufPackage = "cline" + +export interface Metadata {} + +export interface EmptyRequest { + metadata?: Metadata | undefined +} + +export interface Empty {} + +export interface StringRequest { + metadata?: Metadata | undefined + value: string +} + +export interface String { + value: string +} + +export interface Int64Request { + metadata?: Metadata | undefined + value: number +} + +export interface Int64 { + value: number +} + +export interface BytesRequest { + metadata?: Metadata | undefined + value: Buffer +} + +export interface Bytes { + value: Buffer +} + +function createBaseMetadata(): Metadata { + return {} +} + +export const Metadata: MessageFns = { + encode(_: Metadata, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Metadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseMetadata() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(_: any): Metadata { + return {} + }, + + toJSON(_: Metadata): unknown { + const obj: any = {} + return obj + }, + + create, I>>(base?: I): Metadata { + return Metadata.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(_: I): Metadata { + const message = createBaseMetadata() + return message + }, +} + +function createBaseEmptyRequest(): EmptyRequest { + return { metadata: undefined } +} + +export const EmptyRequest: MessageFns = { + encode(message: EmptyRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(10).fork()).join() + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EmptyRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseEmptyRequest() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break + } + + message.metadata = Metadata.decode(reader, reader.uint32()) + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): EmptyRequest { + return { metadata: isSet(object.metadata) ? Metadata.fromJSON(object.metadata) : undefined } + }, + + toJSON(message: EmptyRequest): unknown { + const obj: any = {} + if (message.metadata !== undefined) { + obj.metadata = Metadata.toJSON(message.metadata) + } + return obj + }, + + create, I>>(base?: I): EmptyRequest { + return EmptyRequest.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): EmptyRequest { + const message = createBaseEmptyRequest() + message.metadata = + object.metadata !== undefined && object.metadata !== null ? Metadata.fromPartial(object.metadata) : undefined + return message + }, +} + +function createBaseEmpty(): Empty { + return {} +} + +export const Empty: MessageFns = { + encode(_: Empty, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Empty { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseEmpty() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(_: any): Empty { + return {} + }, + + toJSON(_: Empty): unknown { + const obj: any = {} + return obj + }, + + create, I>>(base?: I): Empty { + return Empty.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(_: I): Empty { + const message = createBaseEmpty() + return message + }, +} + +function createBaseStringRequest(): StringRequest { + return { metadata: undefined, value: "" } +} + +export const StringRequest: MessageFns = { + encode(message: StringRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(10).fork()).join() + } + if (message.value !== "") { + writer.uint32(18).string(message.value) + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): StringRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseStringRequest() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break + } + + message.metadata = Metadata.decode(reader, reader.uint32()) + continue + } + case 2: { + if (tag !== 18) { + break + } + + message.value = reader.string() + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): StringRequest { + return { + metadata: isSet(object.metadata) ? Metadata.fromJSON(object.metadata) : undefined, + value: isSet(object.value) ? globalThis.String(object.value) : "", + } + }, + + toJSON(message: StringRequest): unknown { + const obj: any = {} + if (message.metadata !== undefined) { + obj.metadata = Metadata.toJSON(message.metadata) + } + if (message.value !== "") { + obj.value = message.value + } + return obj + }, + + create, I>>(base?: I): StringRequest { + return StringRequest.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): StringRequest { + const message = createBaseStringRequest() + message.metadata = + object.metadata !== undefined && object.metadata !== null ? Metadata.fromPartial(object.metadata) : undefined + message.value = object.value ?? "" + return message + }, +} + +function createBaseString(): String { + return { value: "" } +} + +export const String: MessageFns = { + encode(message: String, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.value !== "") { + writer.uint32(10).string(message.value) + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): String { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseString() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break + } + + message.value = reader.string() + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): String { + return { value: isSet(object.value) ? globalThis.String(object.value) : "" } + }, + + toJSON(message: String): unknown { + const obj: any = {} + if (message.value !== "") { + obj.value = message.value + } + return obj + }, + + create, I>>(base?: I): String { + return String.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): String { + const message = createBaseString() + message.value = object.value ?? "" + return message + }, +} + +function createBaseInt64Request(): Int64Request { + return { metadata: undefined, value: 0 } +} + +export const Int64Request: MessageFns = { + encode(message: Int64Request, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(10).fork()).join() + } + if (message.value !== 0) { + writer.uint32(16).int64(message.value) + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Int64Request { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseInt64Request() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break + } + + message.metadata = Metadata.decode(reader, reader.uint32()) + continue + } + case 2: { + if (tag !== 16) { + break + } + + message.value = longToNumber(reader.int64()) + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): Int64Request { + return { + metadata: isSet(object.metadata) ? Metadata.fromJSON(object.metadata) : undefined, + value: isSet(object.value) ? globalThis.Number(object.value) : 0, + } + }, + + toJSON(message: Int64Request): unknown { + const obj: any = {} + if (message.metadata !== undefined) { + obj.metadata = Metadata.toJSON(message.metadata) + } + if (message.value !== 0) { + obj.value = Math.round(message.value) + } + return obj + }, + + create, I>>(base?: I): Int64Request { + return Int64Request.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): Int64Request { + const message = createBaseInt64Request() + message.metadata = + object.metadata !== undefined && object.metadata !== null ? Metadata.fromPartial(object.metadata) : undefined + message.value = object.value ?? 0 + return message + }, +} + +function createBaseInt64(): Int64 { + return { value: 0 } +} + +export const Int64: MessageFns = { + encode(message: Int64, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.value !== 0) { + writer.uint32(8).int64(message.value) + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Int64 { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseInt64() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 8) { + break + } + + message.value = longToNumber(reader.int64()) + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): Int64 { + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 } + }, + + toJSON(message: Int64): unknown { + const obj: any = {} + if (message.value !== 0) { + obj.value = Math.round(message.value) + } + return obj + }, + + create, I>>(base?: I): Int64 { + return Int64.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): Int64 { + const message = createBaseInt64() + message.value = object.value ?? 0 + return message + }, +} + +function createBaseBytesRequest(): BytesRequest { + return { metadata: undefined, value: Buffer.alloc(0) } +} + +export const BytesRequest: MessageFns = { + encode(message: BytesRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(10).fork()).join() + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value) + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): BytesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseBytesRequest() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break + } + + message.metadata = Metadata.decode(reader, reader.uint32()) + continue + } + case 2: { + if (tag !== 18) { + break + } + + message.value = Buffer.from(reader.bytes()) + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): BytesRequest { + return { + metadata: isSet(object.metadata) ? Metadata.fromJSON(object.metadata) : undefined, + value: isSet(object.value) ? Buffer.from(bytesFromBase64(object.value)) : Buffer.alloc(0), + } + }, + + toJSON(message: BytesRequest): unknown { + const obj: any = {} + if (message.metadata !== undefined) { + obj.metadata = Metadata.toJSON(message.metadata) + } + if (message.value.length !== 0) { + obj.value = base64FromBytes(message.value) + } + return obj + }, + + create, I>>(base?: I): BytesRequest { + return BytesRequest.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): BytesRequest { + const message = createBaseBytesRequest() + message.metadata = + object.metadata !== undefined && object.metadata !== null ? Metadata.fromPartial(object.metadata) : undefined + message.value = object.value ?? Buffer.alloc(0) + return message + }, +} + +function createBaseBytes(): Bytes { + return { value: Buffer.alloc(0) } +} + +export const Bytes: MessageFns = { + encode(message: Bytes, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.value.length !== 0) { + writer.uint32(10).bytes(message.value) + } + return writer + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Bytes { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input) + let end = length === undefined ? reader.len : reader.pos + length + const message = createBaseBytes() + while (reader.pos < end) { + const tag = reader.uint32() + switch (tag >>> 3) { + case 1: { + if (tag !== 10) { + break + } + + message.value = Buffer.from(reader.bytes()) + continue + } + } + if ((tag & 7) === 4 || tag === 0) { + break + } + reader.skip(tag & 7) + } + return message + }, + + fromJSON(object: any): Bytes { + return { value: isSet(object.value) ? Buffer.from(bytesFromBase64(object.value)) : Buffer.alloc(0) } + }, + + toJSON(message: Bytes): unknown { + const obj: any = {} + if (message.value.length !== 0) { + obj.value = base64FromBytes(message.value) + } + return obj + }, + + create, I>>(base?: I): Bytes { + return Bytes.fromPartial(base ?? ({} as any)) + }, + fromPartial, I>>(object: I): Bytes { + const message = createBaseBytes() + message.value = object.value ?? Buffer.alloc(0) + return message + }, +} + +function bytesFromBase64(b64: string): Uint8Array { + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")) +} + +function base64FromBytes(arr: Uint8Array): string { + return globalThis.Buffer.from(arr).toString("base64") +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined + +export type DeepPartial = T extends Builtin + ? T + : T extends globalThis.Array + ? globalThis.Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial + +type KeysOfUnion = T extends T ? keyof T : never +export type Exact = P extends Builtin + ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never } + +function longToNumber(int64: { toString(): string }): number { + const num = globalThis.Number(int64.toString()) + if (num > globalThis.Number.MAX_SAFE_INTEGER) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER") + } + if (num < globalThis.Number.MIN_SAFE_INTEGER) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER") + } + return num +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter + decode(input: BinaryReader | Uint8Array, length?: number): T + fromJSON(object: any): T + toJSON(message: T): unknown + create, I>>(base?: I): T + fromPartial, I>>(object: I): T +} diff --git a/src/utils/fs.ts b/src/utils/fs.ts index 23e0cd89..c591e465 100644 --- a/src/utils/fs.ts +++ b/src/utils/fs.ts @@ -75,6 +75,13 @@ export async function getFileSizeInKB(filePath: string): Promise { } } +// Common OS-generated files that would appear in an otherwise clean directory +const OS_GENERATED_FILES = [ + ".DS_Store", // macOS Finder + "Thumbs.db", // Windows Explorer thumbnails + "desktop.ini", // Windows folder settings +] + /** * Recursively reads a directory and returns an array of absolute file paths. * @@ -86,7 +93,8 @@ export const readDirectory = async (directoryPath: string) => { try { const filePaths = await fs .readdir(directoryPath, { withFileTypes: true, recursive: true }) - .then((files) => files.filter((file) => file.isFile())) + .then((entries) => entries.filter((entry) => !OS_GENERATED_FILES.includes(entry.name))) + .then((entries) => entries.filter((entry) => entry.isFile())) .then((files) => files.map((file) => path.resolve(file.parentPath, file.name))) return filePaths } catch { diff --git a/src/utils/path.ts b/src/utils/path.ts index c7dacbd4..17b7ad70 100644 --- a/src/utils/path.ts +++ b/src/utils/path.ts @@ -1,6 +1,7 @@ import * as path from "path" import os from "os" import * as vscode from "vscode" +import { realpathSync } from "fs" /* The Node.js 'path' module resolves and normalizes paths differently depending on the platform: @@ -110,3 +111,24 @@ export const getWorkspacePath = (defaultCwdPath = "") => { } return cwdPath } + +export const isLocatedInWorkspace = (pathToCheck: string = ""): boolean => { + const workspacePath = getWorkspacePath() + + // Handle long paths in Windows + if (pathToCheck.startsWith("\\\\?\\") || workspacePath.startsWith("\\\\?\\")) { + return pathToCheck.startsWith(workspacePath) + } + + const resolvedPath = path.resolve(workspacePath, pathToCheck) + + // Using realpathSync to resolve any symbolic links + try { + const realWorkspacePath = realpathSync(workspacePath) + const realPath = realpathSync(resolvedPath) + return realPath.startsWith(realWorkspacePath) + } catch (error) { + console.error("Error resolving paths:", error) + return false + } +} diff --git a/src/utils/shell.ts b/src/utils/shell.ts index 2f7ffb3a..22a916f0 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -91,7 +91,7 @@ function getWindowsShellFromVSCode(): string | null { // If the profile name indicates PowerShell, do version-based detection. // In testing it was found these typically do not have a path, and this - // implementation manages to deductively get the corect version of PowerShell + // implementation manages to deductively get the correct version of PowerShell if (defaultProfileName.toLowerCase().includes("powershell")) { if (profile?.path) { // If there's an explicit PowerShell path, return that diff --git a/webview-ui/package-lock.json b/webview-ui/package-lock.json index b231b967..41299af1 100644 --- a/webview-ui/package-lock.json +++ b/webview-ui/package-lock.json @@ -27,7 +27,8 @@ "react-use": "^17.6.0", "react-virtuoso": "^4.12.3", "rehype-highlight": "^7.0.1", - "styled-components": "^6.1.15" + "styled-components": "^6.1.15", + "uuid": "^9.0.1" }, "devDependencies": { "@eslint/js": "^9.17.0", @@ -40,6 +41,7 @@ "@types/node": "^22.13.4", "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", + "@types/uuid": "^9.0.8", "@types/vscode-webview": "^1.57.5", "@vitejs/plugin-react-swc": "^3.5.0", "@vitest/coverage-v8": "^3.0.9", @@ -3539,6 +3541,13 @@ "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "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==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/vscode-webview": { "version": "1.57.5", "resolved": "https://registry.npmjs.org/@types/vscode-webview/-/vscode-webview-1.57.5.tgz", @@ -6936,18 +6945,6 @@ "uuid": "^9.0.1" } }, - "node_modules/mermaid/node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/micromark": { "version": "2.11.4", "resolved": "https://registry.npmjs.org/micromark/-/micromark-2.11.4.tgz", @@ -8836,6 +8833,19 @@ } } }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/vfile": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", diff --git a/webview-ui/package.json b/webview-ui/package.json index 006e5f98..9515a452 100644 --- a/webview-ui/package.json +++ b/webview-ui/package.json @@ -33,7 +33,8 @@ "react-use": "^17.6.0", "react-virtuoso": "^4.12.3", "rehype-highlight": "^7.0.1", - "styled-components": "^6.1.15" + "styled-components": "^6.1.15", + "uuid": "^9.0.1" }, "devDependencies": { "@eslint/js": "^9.17.0", @@ -46,6 +47,7 @@ "@types/node": "^22.13.4", "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", + "@types/uuid": "^9.0.8", "@types/vscode-webview": "^1.57.5", "@vitejs/plugin-react-swc": "^3.5.0", "@vitest/coverage-v8": "^3.0.9", diff --git a/webview-ui/src/App.tsx b/webview-ui/src/App.tsx index ac9f8546..25170f94 100644 --- a/webview-ui/src/App.tsx +++ b/webview-ui/src/App.tsx @@ -16,6 +16,7 @@ import { SsyAuthProvider } from "./context/SsyAuthContext" const AppContent = () => { const { didHydrateState, showWelcome, shouldShowAnnouncement, telemetrySetting, vscMachineId } = useExtensionState() const [showSettings, setShowSettings] = useState(false) + const hideSettings = useCallback(() => setShowSettings(false), []) const [showHistory, setShowHistory] = useState(false) const [showMcp, setShowMcp] = useState(false) const [showAccount, setShowAccount] = useState(false) @@ -93,7 +94,7 @@ const AppContent = () => { ) : ( <> - {showSettings && setShowSettings(false)} />} + {showSettings && } {showHistory && setShowHistory(false)} />} {showMcp && setShowMcp(false)} />} {showAccount && setShowAccount(false)} />} diff --git a/webview-ui/src/components/browser/BrowserSettingsMenu.tsx b/webview-ui/src/components/browser/BrowserSettingsMenu.tsx index b4988276..74a7091b 100644 --- a/webview-ui/src/components/browser/BrowserSettingsMenu.tsx +++ b/webview-ui/src/components/browser/BrowserSettingsMenu.tsx @@ -3,6 +3,8 @@ import { useEffect, useRef, useState } from "react" import styled from "styled-components" import { useExtensionState } from "@/context/ExtensionStateContext" import { vscode } from "@/utils/vscode" +import { CODE_BLOCK_BG_COLOR } from "../common/CodeBlock" +import { BrowserServiceClient } from "../../services/grpc-client" interface ConnectionInfo { isConnected: boolean @@ -21,29 +23,25 @@ export const BrowserSettingsMenu = () => { }) const popoverRef = useRef(null) - // Get actual connection info from the browser session + // Get actual connection info from the browser session using gRPC useEffect(() => { - // Request connection info when component mounts - vscode.postMessage({ - type: "getBrowserConnectionInfo", - }) - - // Listen for connection info updates - const handleMessage = (event: MessageEvent) => { - const message = event.data - if (message.type === "browserConnectionInfo") { + // Function to fetch connection info + ;(async () => { + try { + console.log("[DEBUG] SENDING BROWSER CONNECTION INFO REQUEST") + const info = await BrowserServiceClient.getBrowserConnectionInfo({}) + console.log("[DEBUG] GOT BROWSER REPLY:", info, typeof info) setConnectionInfo({ - isConnected: message.isConnected, - isRemote: message.isRemote, - host: message.host, + isConnected: info.isConnected, + isRemote: info.isRemote, + host: info.host, }) + } catch (error) { + console.error("Error fetching browser connection info:", error) } - } + })() - window.addEventListener("message", handleMessage) - return () => { - window.removeEventListener("message", handleMessage) - } + // No need for message event listeners anymore! }, [browserSettings.remoteBrowserHost, browserSettings.remoteBrowserEnabled]) // Close popover when clicking outside @@ -84,11 +82,22 @@ export const BrowserSettingsMenu = () => { const toggleInfoPopover = () => { setShowInfoPopover(!showInfoPopover) - // Request updated connection info when opening the popover + // Request updated connection info when opening the popover using gRPC if (!showInfoPopover) { - vscode.postMessage({ - type: "getBrowserConnectionInfo", - }) + const fetchConnectionInfo = async () => { + try { + const info = await BrowserServiceClient.getBrowserConnectionInfo({}) + setConnectionInfo({ + isConnected: info.isConnected, + isRemote: info.isRemote, + host: info.host, + }) + } catch (error) { + console.error("Error fetching browser connection info:", error) + } + } + + fetchConnectionInfo() } } @@ -112,19 +121,27 @@ export const BrowserSettingsMenu = () => { } } - // Check connection status every second to keep icon in sync + // Check connection status every second to keep icon in sync using gRPC useEffect(() => { + // Function to fetch connection info + const fetchConnectionInfo = async () => { + try { + const info = await BrowserServiceClient.getBrowserConnectionInfo({}) + setConnectionInfo({ + isConnected: info.isConnected, + isRemote: info.isRemote, + host: info.host, + }) + } catch (error) { + console.error("Error fetching browser connection info:", error) + } + } + // Request connection info immediately - vscode.postMessage({ - type: "getBrowserConnectionInfo", - }) + fetchConnectionInfo() // Set up interval to refresh every second - const intervalId = setInterval(() => { - vscode.postMessage({ - type: "getBrowserConnectionInfo", - }) - }, 1000) + const intervalId = setInterval(fetchConnectionInfo, 1000) return () => clearInterval(intervalId) }, []) diff --git a/webview-ui/src/components/chat/Announcement.tsx b/webview-ui/src/components/chat/Announcement.tsx index 0eb86951..8017c17f 100644 --- a/webview-ui/src/components/chat/Announcement.tsx +++ b/webview-ui/src/components/chat/Announcement.tsx @@ -29,7 +29,7 @@ const linkContainerStyle: CSSProperties = { margin: "0" } const linkStyle: CSSProperties = { display: "inline" } /* -You must update the latestAnnouncementId in ClineProvider for new announcements to show to users. This new id will be compared with whats in state for the 'last announcement shown', and if it's different then the announcement will render. As soon as an announcement is shown, the id will be updated in state. This ensures that announcements are not shown more than once, even if the user doesn't close it themselves. +You must update the latestAnnouncementId in ClineProvider for new announcements to show to users. This new id will be compared with what's in state for the 'last announcement shown', and if it's different then the announcement will render. As soon as an announcement is shown, the id will be updated in state. This ensures that announcements are not shown more than once, even if the user doesn't close it themselves. */ const Announcement = ({ version, hideAnnouncement }: AnnouncementProps) => { const minorVersion = version.split(".").slice(0, 2).join(".") // 2.0.0 -> 2.0 diff --git a/webview-ui/src/components/chat/BrowserSessionRow.tsx b/webview-ui/src/components/chat/BrowserSessionRow.tsx index 09f62aed..de7185e2 100644 --- a/webview-ui/src/components/chat/BrowserSessionRow.tsx +++ b/webview-ui/src/components/chat/BrowserSessionRow.tsx @@ -192,7 +192,12 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { // Reset for next page currentStateMessages = [] nextActionMessages = [] - } else if (message.say === "api_req_started" || message.say === "text" || message.say === "browser_action") { + } else if ( + message.say === "api_req_started" || + message.say === "text" || + message.say === "reasoning" || + message.say === "browser_action" + ) { // These messages lead to the next result, so they should always go in nextActionMessages nextActionMessages.push(message) } else { @@ -511,6 +516,7 @@ const BrowserSessionRowContent = ({ switch (message.say) { case "api_req_started": case "text": + case "reasoning": return (
void + inputValue?: string + sendMessageFromChatRow?: (text: string, images: string[]) => void } interface ChatRowContentProps extends Omit {} @@ -84,7 +87,7 @@ const Markdown = memo(({ markdown }: { markdown?: string }) => { const ChatRow = memo( (props: ChatRowProps) => { - const { isLast, onHeightChange, message, lastModifiedMessage } = props + const { isLast, onHeightChange, message, lastModifiedMessage, inputValue } = props // Store the previous height to compare with the current height // This allows us to detect changes without causing re-renders const prevHeightRef = useRef(0) @@ -117,7 +120,15 @@ const ChatRow = memo( export default ChatRow -export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifiedMessage, isLast }: ChatRowContentProps) => { +export const ChatRowContent = ({ + message, + isExpanded, + onToggleExpand, + lastModifiedMessage, + isLast, + inputValue, + sendMessageFromChatRow, +}: ChatRowContentProps) => { const { mcpServers, mcpMarketplaceCatalog } = useExtensionState() const [seeNewChangesDisabled, setSeeNewChangesDisabled] = useState(false) @@ -328,13 +339,20 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi }, [message.ask, message.say, message.text]) if (tool) { - const toolIcon = (name: string) => ( + const colorMap = { + red: "var(--vscode-errorForeground)", + yellow: "var(--vscode-editorWarning-foreground)", + green: "var(--vscode-charts-green)", + } + const toolIcon = (name: string, color?: string, rotation?: number, title?: string) => ( + transform: rotation ? `rotate(${rotation}deg)` : undefined, + }} + title={title}> ) switch (tool.tool) { @@ -343,6 +361,7 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi <>
{toolIcon("edit")} + {!tool.operationIsLocatedInWorkspace && toolIcon("sign-out", "yellow", -90, "该文件不在你的工作目录")} Cline 需要编辑这个文件:
{toolIcon("new-file")} + {!tool.operationIsLocatedInWorkspace && toolIcon("sign-out", "yellow", -90, "该文件不在你的工作目录")} Cline 需要创建新文件:
{toolIcon("file-code")} + {!tool.operationIsLocatedInWorkspace && toolIcon("sign-out", "yellow", -90, "该文件不在你的工作目录")} {/* {message.type === "ask" ? "" : "Cline read this file:"} */} Cline 需要读取这个文件: @@ -433,6 +454,7 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi <>
{toolIcon("folder-opened")} + {!tool.operationIsLocatedInWorkspace && toolIcon("sign-out", "yellow", -90, "该文件不在你的工作目录")} {message.type === "ask" ? "Cline 需要查看这个目录:" : "Cline 在这个目录找到的文件:"} @@ -451,6 +473,7 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi <>
{toolIcon("folder-opened")} + {!tool.operationIsLocatedInWorkspace && toolIcon("sign-out", "yellow", -90, "该文件不在你的工作目录")} {message.type === "ask" ? "Cline 需要迭代列举这个目录的文件:" @@ -471,6 +494,7 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi <>
{toolIcon("file-code")} + {!tool.operationIsLocatedInWorkspace && toolIcon("sign-out", "yellow", -90, "该文件不在你的工作目录")} {message.type === "ask" ? "Cline 需要查看此目录中使用的源代码定义名称:" @@ -490,6 +514,7 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi <>
{toolIcon("search")} + {!tool.operationIsLocatedInWorkspace && toolIcon("sign-out", "yellow", -90, "该文件不在你的工作目录")} Cline 需要查找这个目录 {tool.regex}: @@ -841,20 +866,12 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi ) case "user_feedback": return ( -
- {highlightMentions(message.text)} - {message.images && message.images.length > 0 && ( - - )} -
+ ) case "user_feedback_diff": const tool = JSON.parse(message.text || "{}") as ClineSayTool @@ -1222,6 +1239,7 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi options={options} selected={selected} isActive={isLast && lastModifiedMessage?.ask === "followup"} + inputValue={inputValue} />
@@ -1261,6 +1279,7 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi options={options} selected={selected} isActive={isLast && lastModifiedMessage?.ask === "plan_mode_respond"} + inputValue={inputValue} />
) diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index ab0a408e..8107ea12 100644 --- a/webview-ui/src/components/chat/ChatTextArea.tsx +++ b/webview-ui/src/components/chat/ChatTextArea.tsx @@ -26,6 +26,7 @@ import { MAX_IMAGES_PER_MESSAGE } from "@/components/chat/ChatView" import ContextMenu from "@/components/chat/ContextMenu" import { ChatSettings } from "@shared/ChatSettings" import ServersToggleModal from "./ServersToggleModal" +import ClineRulesToggleModal from "../cline-rules/ClineRulesToggleModal" interface ChatTextAreaProps { inputValue: string @@ -1153,7 +1154,7 @@ const ChatTextArea = forwardRef( display: "flex", alignItems: "flex-center", height: textAreaBaseHeight || 31, - bottom: 9.5, // should be 10 but doesnt look good on mac + bottom: 9.5, // should be 10 but doesn't look good on mac zIndex: 2, }}>
( + diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 7a0a8b91..acb83443 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -461,6 +461,13 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie textAreaRef.current?.focus() } break + case "focusChatInput": + textAreaRef.current?.focus() + if (isHidden) { + // Send message back to extension to show chat view + vscode.postMessage({ type: "showChatView" }) + } + break } break case "selectedImages": @@ -568,6 +575,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie "browser_action", "browser_action_result", "checkpoint_created", + "reasoning", ].includes(message.say!) } return false @@ -789,10 +797,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie lastModifiedMessage={modifiedMessages.at(-1)} isLast={index === groupedMessages.length - 1} onHeightChange={handleRowHeightChange} + inputValue={inputValue} + sendMessageFromChatRow={handleSendMessage} /> ) }, - [expandedRows, modifiedMessages, groupedMessages.length, toggleRowExpansion, handleRowHeightChange], + [expandedRows, modifiedMessages, groupedMessages.length, toggleRowExpansion, handleRowHeightChange, inputValue], ) return ( diff --git a/webview-ui/src/components/chat/OptionsButtons.tsx b/webview-ui/src/components/chat/OptionsButtons.tsx index 43158237..cc8bccde 100644 --- a/webview-ui/src/components/chat/OptionsButtons.tsx +++ b/webview-ui/src/components/chat/OptionsButtons.tsx @@ -26,10 +26,12 @@ export const OptionsButtons = ({ options, selected, isActive, + inputValue, }: { options?: string[] selected?: string isActive?: boolean + inputValue?: string }) => { if (!options?.length) return null @@ -58,7 +60,7 @@ export const OptionsButtons = ({ } vscode.postMessage({ type: "optionsResponse", - text: option, + text: option + (inputValue ? `: ${inputValue?.trim()}` : ""), }) }}> {option} diff --git a/webview-ui/src/components/chat/ServersToggleModal.tsx b/webview-ui/src/components/chat/ServersToggleModal.tsx index eda911af..b7932df1 100644 --- a/webview-ui/src/components/chat/ServersToggleModal.tsx +++ b/webview-ui/src/components/chat/ServersToggleModal.tsx @@ -74,7 +74,7 @@ const ServersToggleModal: React.FC = () => { />
-
MCP 服务
+
MCP 服务
{ diff --git a/webview-ui/src/components/chat/UserMessage.tsx b/webview-ui/src/components/chat/UserMessage.tsx new file mode 100644 index 00000000..0bc2be51 --- /dev/null +++ b/webview-ui/src/components/chat/UserMessage.tsx @@ -0,0 +1,185 @@ +import React, { useState, useRef, forwardRef, useCallback } from "react" +import Thumbnails from "@/components/common/Thumbnails" +import { highlightMentions } from "./TaskHeader" +import { vscode } from "@/utils/vscode" +import DynamicTextArea from "react-textarea-autosize" +import { useExtensionState } from "@/context/ExtensionStateContext" + +interface UserMessageProps { + text?: string + images?: string[] + messageTs?: number // Timestamp for the message, needed for checkpoint restore + sendMessageFromChatRow?: (text: string, images: string[]) => void +} + +const UserMessage: React.FC = ({ text, images, messageTs, sendMessageFromChatRow }) => { + const [isEditing, setIsEditing] = useState(false) + const [editedText, setEditedText] = useState(text || "") + const textAreaRef = useRef(null) + const { checkpointTrackerErrorMessage } = useExtensionState() + + // Create refs for the buttons to check in the blur handler + const restoreAllButtonRef = useRef(null) + const restoreChatButtonRef = useRef(null) + + const handleClick = () => { + if (!isEditing) { + setIsEditing(true) + } + } + + // Select all text when entering edit mode + React.useEffect(() => { + if (isEditing && textAreaRef.current) { + textAreaRef.current.select() + } + }, [isEditing]) + + const handleRestoreWorkspace = (type: string) => { + const delay = type === "task" ? 500 : 1000 // Delay for task and workspace restore + setIsEditing(false) + + if (text === editedText) { + return + } + + vscode.postMessage({ + type: "checkpointRestore", + number: messageTs, + text: type, + offset: 1, + }) + + setTimeout(() => { + sendMessageFromChatRow?.(editedText, images || []) + }, delay) + } + + const handleBlur = (e: React.FocusEvent) => { + // Check if focus is moving to one of our button elements + if (e.relatedTarget === restoreAllButtonRef.current || e.relatedTarget === restoreChatButtonRef.current) { + // Don't close edit mode if focus is moving to one of our buttons + return + } + + // Otherwise, close edit mode + setIsEditing(false) + } + + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === "Escape") { + setIsEditing(false) + } else if (e.key === "Enter" && e.metaKey && !checkpointTrackerErrorMessage) { + handleRestoreWorkspace("taskAndWorkspace") + } else if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault() + handleRestoreWorkspace("task") + } + } + + return ( +
+ {isEditing ? ( + <> + setEditedText(e.target.value)} + onBlur={(e) => handleBlur(e)} + onKeyDown={handleKeyDown} + autoFocus + style={{ + width: "100%", + backgroundColor: "var(--vscode-input-background)", + color: "var(--vscode-input-foreground)", + borderColor: "var(--vscode-input-border)", + border: "1px solid", + borderRadius: "2px", + padding: "6px", + fontFamily: "inherit", + fontSize: "inherit", + lineHeight: "inherit", + boxSizing: "border-box", + resize: "none", + overflowX: "hidden", + overflowY: "scroll", + scrollbarWidth: "none", + }} + /> +
+ {!checkpointTrackerErrorMessage && ( + + )} + +
+ + ) : ( + {highlightMentions(editedText || text)} + )} + {images && images.length > 0 && } +
+ ) +} + +// Reusable button component for restore actions +interface RestoreButtonProps { + type: string + label: string + isPrimary: boolean + onClick: (type: string) => void + title?: string +} + +const RestoreButton = forwardRef(({ type, label, isPrimary, onClick, title }, ref) => { + const handleClick = (e: React.MouseEvent) => { + e.stopPropagation() + onClick(type) + } + + return ( + + ) +}) + +export default UserMessage diff --git a/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx b/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx new file mode 100644 index 00000000..fb07f6c7 --- /dev/null +++ b/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx @@ -0,0 +1,135 @@ +import React, { useRef, useState, useEffect } from "react" +import { useClickAway, useWindowSize } from "react-use" +import { useExtensionState } from "@/context/ExtensionStateContext" +import { CODE_BLOCK_BG_COLOR } from "@/components/common/CodeBlock" +import { vscode } from "@/utils/vscode" +import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" +import RulesToggleList from "./RulesToggleList" + +const ClineRulesToggleModal: React.FC = () => { + const { globalClineRulesToggles = {}, localClineRulesToggles = {} } = useExtensionState() + const [isVisible, setIsVisible] = useState(false) + const buttonRef = useRef(null) + const modalRef = useRef(null) + const { width: viewportWidth, height: viewportHeight } = useWindowSize() + const [arrowPosition, setArrowPosition] = useState(0) + const [menuPosition, setMenuPosition] = useState(0) + + useEffect(() => { + if (isVisible) { + vscode.postMessage({ type: "refreshClineRules" }) + } + }, [isVisible]) + + // Format global rules for display with proper typing + const globalRules = Object.entries(globalClineRulesToggles || {}) + .map(([path, enabled]): [string, boolean] => [path, enabled as boolean]) + .sort(([a], [b]) => a.localeCompare(b)) + + // Format local rules for display with proper typing + const localRules = Object.entries(localClineRulesToggles || {}) + .map(([path, enabled]): [string, boolean] => [path, enabled as boolean]) + .sort(([a], [b]) => a.localeCompare(b)) + + // Handle toggle rule + const toggleRule = (isGlobal: boolean, rulePath: string, enabled: boolean) => { + vscode.postMessage({ + type: "toggleClineRule", + isGlobal, + rulePath, + enabled, + }) + } + + // Close modal when clicking outside + useClickAway(modalRef, () => { + setIsVisible(false) + }) + + // Calculate positions for modal and arrow + useEffect(() => { + if (isVisible && buttonRef.current) { + const buttonRect = buttonRef.current.getBoundingClientRect() + const buttonCenter = buttonRect.left + buttonRect.width / 2 + const rightPosition = document.documentElement.clientWidth - buttonCenter - 5 + + setArrowPosition(rightPosition) + setMenuPosition(buttonRect.top + 1) + } + }, [isVisible, viewportWidth, viewportHeight]) + + return ( +
+
+ setIsVisible(!isVisible)} + style={{ padding: "0px 0px", height: "20px" }}> +
+ +
+
+
+ + {isVisible && ( +
+
+ +
+
Cline Rules
+ + { + vscode.postMessage({ + type: "openExtensionSettings", + }) + setIsVisible(false) + }}> + {/* */} + +
+ + {/* Global Rules Section */} +
+
Global Rules
+ toggleRule(true, rulePath, enabled)} + isGlobal={true} + listGap="small" + /> +
+ + {/* Local Rules Section */} +
+
Workspace Rules
+ toggleRule(false, rulePath, enabled)} + isGlobal={false} + listGap="small" + /> +
+
+ )} +
+ ) +} + +export default ClineRulesToggleModal diff --git a/webview-ui/src/components/cline-rules/RuleRow.tsx b/webview-ui/src/components/cline-rules/RuleRow.tsx new file mode 100644 index 00000000..3f43fd2d --- /dev/null +++ b/webview-ui/src/components/cline-rules/RuleRow.tsx @@ -0,0 +1,84 @@ +import { vscode } from "@/utils/vscode" +import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" + +const RuleRow: React.FC<{ + rulePath: string + enabled: boolean + isGlobal: boolean + toggleRule: (rulePath: string, enabled: boolean) => void +}> = ({ rulePath, enabled, isGlobal, toggleRule }) => { + // Get the filename from the path for display + const displayName = rulePath.split("/").pop() || rulePath + + const handleEditClick = () => { + vscode.postMessage({ + type: "openFile", + text: rulePath, + }) + } + + const handleDeleteClick = () => { + vscode.postMessage({ + type: "deleteClineRule", + rulePath: rulePath, + isGlobal: isGlobal, + }) + } + + return ( +
+
+ + {displayName} + + + {/* Toggle Switch */} +
+
toggleRule(rulePath, !enabled)} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault() + toggleRule(rulePath, !enabled) + } + }}> +
+
+ + + + + + +
+
+
+ ) +} + +export default RuleRow diff --git a/webview-ui/src/components/cline-rules/RulesToggleList.tsx b/webview-ui/src/components/cline-rules/RulesToggleList.tsx new file mode 100644 index 00000000..930ceb24 --- /dev/null +++ b/webview-ui/src/components/cline-rules/RulesToggleList.tsx @@ -0,0 +1,33 @@ +import RuleRow from "./RuleRow" + +const RulesToggleList = ({ + rules, + toggleRule, + isGlobal, + listGap = "medium", +}: { + rules: [string, boolean][] + toggleRule: (rulePath: string, enabled: boolean) => void + isGlobal: boolean + listGap?: "small" | "medium" | "large" +}) => { + const gapClasses = { + small: "gap-0", + medium: "gap-2.5", + large: "gap-5", + } + + const gapClass = gapClasses[listGap] + + return rules.length > 0 ? ( +
+ {rules.map(([rulePath, enabled]) => ( + + ))} +
+ ) : ( +
No rules found
+ ) +} + +export default RulesToggleList diff --git a/webview-ui/src/components/common/MarkdownBlock.tsx b/webview-ui/src/components/common/MarkdownBlock.tsx index 33edfabf..bacf9dc2 100644 --- a/webview-ui/src/components/common/MarkdownBlock.tsx +++ b/webview-ui/src/components/common/MarkdownBlock.tsx @@ -4,6 +4,7 @@ import { useRemark } from "react-remark" import rehypeHighlight, { Options } from "rehype-highlight" import styled from "styled-components" import { visit } from "unist-util-visit" +import type { Node } from "unist" import { useExtensionState } from "@/context/ExtensionStateContext" import { CODE_BLOCK_BG_COLOR } from "@/components/common/CodeBlock" import MermaidBlock from "@/components/common/MermaidBlock" @@ -21,7 +22,7 @@ interface MarkdownBlockProps { * This caused the entire content to disappear because the structure became invalid. */ const remarkUrlToLink = () => { - return (tree: any) => { + return (tree: Node) => { // Visit all "text" nodes in the markdown AST (Abstract Syntax Tree) visit(tree, "text", (node: any, index, parent) => { const urlRegex = /https?:\/\/[^\s<>)"]+/g diff --git a/webview-ui/src/components/common/MermaidBlock.tsx b/webview-ui/src/components/common/MermaidBlock.tsx index f491584a..e520d2b6 100644 --- a/webview-ui/src/components/common/MermaidBlock.tsx +++ b/webview-ui/src/components/common/MermaidBlock.tsx @@ -3,6 +3,7 @@ import mermaid from "mermaid" import { useDebounceEffect } from "@/utils/useDebounceEffect" import styled from "styled-components" import { vscode } from "@/utils/vscode" +import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" const MERMAID_THEME = { background: "#1e1e1e", // VS Code dark theme background @@ -139,11 +140,22 @@ export default function MermaidBlock({ code }: MermaidBlockProps) { } } + const handleCopyCode = async () => { + try { + await navigator.clipboard.writeText(code) + } catch (err) { + console.error("Copy failed", err) + } + } + return ( {isLoading && Generating mermaid diagram...} - - {/* The container for the final or raw code. */} + + + + + ) @@ -209,6 +221,19 @@ const MermaidBlockContainer = styled.div` margin: 8px 0; ` +const ButtonContainer = styled.div` + position: absolute; + top: 8px; + right: 8px; + z-index: 1; + opacity: 0.6; + transition: opacity 0.2s ease; + + &:hover { + opacity: 1; + } +` + const LoadingMessage = styled.div` padding: 8px 0; color: var(--vscode-descriptionForeground); @@ -228,3 +253,34 @@ const SvgContainer = styled.div` display: flex; justify-content: center; ` + +const StyledVSCodeButton = styled(VSCodeButton)` + padding: 4px; + height: 24px; + width: 24px; + min-width: unset; + background-color: var(--vscode-button-secondaryBackground); + color: var(--vscode-button-secondaryForeground); + border: 1px solid var(--vscode-button-border); + border-radius: 3px; + display: flex; + align-items: center; + justify-content: center; + transition: all 0.2s ease; + + .codicon { + font-size: 14px; + } + + &:hover { + background-color: var(--vscode-button-secondaryHoverBackground); + border-color: var(--vscode-button-border); + transform: translateY(-1px); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + } + + &:active { + transform: translateY(0); + box-shadow: none; + } +` diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index 66bd7922..546b68c8 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -1,4 +1,5 @@ import { + VSCodeButton, VSCodeCheckbox, VSCodeDropdown, VSCodeLink, @@ -116,7 +117,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is }) // If the field is the provider, save it immediately - // Neccesary for favorite model selection to work without undoing provider changes + // Necessary for favorite model selection to work without undoing provider changes if (field === "apiProvider") { vscode.postMessage({ type: "apiConfiguration", @@ -803,7 +804,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
@@ -811,7 +812,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is @@ -819,11 +820,91 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is Model ID + + {/* OpenAI Compatible Custom Headers */} + {(() => { + const headerEntries = Object.entries(apiConfiguration?.openAiHeaders ?? {}) + return ( +
+
+ Custom Headers + { + const currentHeaders = { ...(apiConfiguration?.openAiHeaders || {}) } + const headerCount = Object.keys(currentHeaders).length + const newKey = `header${headerCount + 1}` + currentHeaders[newKey] = "" + handleInputChange("openAiHeaders")({ + target: { + value: currentHeaders, + }, + }) + }}> + Add Header + +
+
+ {headerEntries.map(([key, value], index) => ( +
+ { + const currentHeaders = apiConfiguration?.openAiHeaders ?? {} + const newValue = e.target.value + if (newValue && newValue !== key) { + const { [key]: _, ...rest } = currentHeaders + handleInputChange("openAiHeaders")({ + target: { + value: { + ...rest, + [newValue]: value, + }, + }, + }) + } + }} + /> + { + handleInputChange("openAiHeaders")({ + target: { + value: { + ...(apiConfiguration?.openAiHeaders ?? {}), + [key]: e.target.value, + }, + }, + }) + }} + /> + { + const { [key]: _, ...rest } = apiConfiguration?.openAiHeaders ?? {} + handleInputChange("openAiHeaders")({ + target: { + value: rest, + }, + }) + }}> + Remove + +
+ ))} +
+
+ ) + })()} + { diff --git a/webview-ui/src/components/settings/BrowserSettingsSection.tsx b/webview-ui/src/components/settings/BrowserSettingsSection.tsx index c16dca5b..24e764c1 100644 --- a/webview-ui/src/components/settings/BrowserSettingsSection.tsx +++ b/webview-ui/src/components/settings/BrowserSettingsSection.tsx @@ -5,6 +5,7 @@ import { BROWSER_VIEWPORT_PRESETS } from "../../../../src/shared/BrowserSettings import { useExtensionState } from "../../context/ExtensionStateContext" import { vscode } from "../../utils/vscode" import styled from "styled-components" +import { BrowserServiceClient } from "../../services/grpc-client" const ConnectionStatusIndicator = ({ isChecking, @@ -93,10 +94,24 @@ export const BrowserSettingsSection: React.FC = () => { if (browserSettings.remoteBrowserEnabled) { setIsCheckingConnection(true) setConnectionStatus(null) - vscode.postMessage({ - type: browserSettings.remoteBrowserHost ? "testBrowserConnection" : "discoverBrowser", - text: browserSettings.remoteBrowserHost, - }) + if (browserSettings.remoteBrowserHost) { + // Use gRPC for testBrowserConnection + BrowserServiceClient.testBrowserConnection({ value: browserSettings.remoteBrowserHost }) + .then((result) => { + setConnectionStatus(result.success) + setIsCheckingConnection(false) + }) + .catch((error) => { + console.error("Error testing browser connection:", error) + setConnectionStatus(false) + setIsCheckingConnection(false) + }) + } else { + // Use old message passing for discoverBrowser (not yet migrated) + vscode.postMessage({ + type: "discoverBrowser", + }) + } } }, 1000), [browserSettings.remoteBrowserEnabled, browserSettings.remoteBrowserHost], @@ -153,10 +168,22 @@ export const BrowserSettingsSection: React.FC = () => { const checkConnectionOnce = useCallback(() => { // Don't show the spinner for every check to avoid UI flicker // We'll rely on the response to update the connectionStatus - vscode.postMessage({ - type: browserSettings.remoteBrowserHost ? "testBrowserConnection" : "discoverBrowser", - text: browserSettings.remoteBrowserHost, - }) + if (browserSettings.remoteBrowserHost) { + // Use gRPC for testBrowserConnection + BrowserServiceClient.testBrowserConnection({ value: browserSettings.remoteBrowserHost }) + .then((result) => { + setConnectionStatus(result.success) + }) + .catch((error) => { + console.error("Error testing browser connection:", error) + setConnectionStatus(false) + }) + } else { + // Use old message passing for discoverBrowser (not yet migrated) + vscode.postMessage({ + type: "discoverBrowser", + }) + } }, [browserSettings.remoteBrowserHost]) // Setup continuous polling for connection status when remote browser is enabled diff --git a/webview-ui/src/components/settings/OpenRouterModelPicker.tsx b/webview-ui/src/components/settings/OpenRouterModelPicker.tsx index e3d8ffc9..6c818656 100644 --- a/webview-ui/src/components/settings/OpenRouterModelPicker.tsx +++ b/webview-ui/src/components/settings/OpenRouterModelPicker.tsx @@ -51,8 +51,8 @@ const featuredModels = [ label: "Trending", }, { - id: "meta-llama/llama-4-maverick", - description: "Efficient performance at lower cost", + id: "openai/gpt-4.1", + description: "1M context window, blazing fast", label: "New", }, ] diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index 4a7321b5..4ae9338e 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -145,55 +145,16 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { } return ( -
-
-

设置

+
+
+

设置

handleSubmit(false)}>确定
-
+
{/* Tabs container */} {planActSeparateModelsSetting ? ( -
-
+
+
handleTabChange("plan")}> 计划模式 @@ -203,7 +164,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
{/* Content container */} -
+
{ /> )} -
+
setCustomInstructions(e.target?.value ?? "")}> - 自定义提示词 + 自定义提示词 -

+

这些说明将添加到随每个请求发送的系统提示符的末尾。

-
+
{ const checked = e.target.checked === true @@ -251,20 +207,15 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { }}> 对 计划模式 和 执行模式 模式使用不同的模型 -

+

在计划和执行模式之间切换将保留之前模式中使用的 API 和模型。这可能是 例如,当使用强推理模型来构建更便宜的编码模型计划时,这很有帮助。

-
+
{ const checked = e.target.checked === true @@ -272,12 +223,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { }}> 允许匿名错误和使用情况报告 -

+

通过发送匿名使用数据和错误报告来帮助改进 Cline。无代码、提示或个人 信息。查看我们的{" "} 概述 @@ -292,18 +238,10 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { {/* Browser Settings Section */} -

+
vscode.postMessage({ type: "openExtensionSettings" })} - style={{ - margin: "0 0 16px 0", - }}> + className="mt-0 mr-0 mb-4 ml-0"> 高级设置 @@ -311,49 +249,24 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { {IS_DEV && ( <> -
调试
- +
调试
+ 重置 -

+

这将重置扩展中的所有全局 state 和 secret 存储。

)} -
-

+

+

如果您有任何问题或反馈,请随时在{" "} - + https://github.com/cline/cline

-

- v{version} -

+

v{version}

diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index c354e542..75d1389e 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -17,11 +17,11 @@ import { vscode } from "../utils/vscode" import { DEFAULT_BROWSER_SETTINGS } from "@shared/BrowserSettings" import { DEFAULT_CHAT_SETTINGS } from "@shared/ChatSettings" import { TelemetrySetting } from "@shared/TelemetrySetting" - +import { ClineRulesToggles } from "@shared/cline-rules" interface ExtensionStateContextType extends ExtensionState { didHydrateState: boolean showWelcome: boolean - theme: any + theme: Record | undefined openRouterModels: Record openAiModels: string[] requestyModels: Record @@ -53,10 +53,12 @@ export const ExtensionStateContextProvider: React.FC<{ telemetrySetting: "unset", vscMachineId: "", planActSeparateModelsSetting: true, + globalClineRulesToggles: {}, + localClineRulesToggles: {}, }) const [didHydrateState, setDidHydrateState] = useState(false) const [showWelcome, setShowWelcome] = useState(false) - const [theme, setTheme] = useState(undefined) + const [theme, setTheme] = useState>() const [filePaths, setFilePaths] = useState([]) const [openRouterModels, setOpenRouterModels] = useState>({ [openRouterDefaultModelId]: openRouterDefaultModelInfo, @@ -130,6 +132,7 @@ export const ExtensionStateContextProvider: React.FC<{ }) break } + case "openRouterModels": { const updatedModels = message.openRouterModels ?? {} setOpenRouterModels({ @@ -186,6 +189,8 @@ export const ExtensionStateContextProvider: React.FC<{ mcpMarketplaceCatalog, filePaths, totalTasksSize, + globalClineRulesToggles: state.globalClineRulesToggles || {}, + localClineRulesToggles: state.localClineRulesToggles || {}, setApiConfiguration: (value) => setState((prevState) => ({ ...prevState, diff --git a/webview-ui/src/services/grpc-client.ts b/webview-ui/src/services/grpc-client.ts new file mode 100644 index 00000000..f7d3041b --- /dev/null +++ b/webview-ui/src/services/grpc-client.ts @@ -0,0 +1,100 @@ +import { vscode } from "../utils/vscode" +import { v4 as uuidv4 } from "uuid" +import { BrowserServiceDefinition } from "@shared/proto/browser" +import { EmptyRequest } from "@shared/proto/common" + +// Generic type for any protobuf service definition +type ProtoService = { + name: string + fullName: string + methods: { + [key: string]: { + name: string + requestType: any + responseType: any + requestStream: boolean + responseStream: boolean + options: any + } + } +} + +// Define a generic type that extracts method signatures from a service definition +type GrpcClientType = { + [K in keyof T["methods"]]: ( + request: InstanceType, + ) => Promise> +} + +// Create a client for any protobuf service with inferred types +function createGrpcClient(service: T): GrpcClientType { + const client = {} as GrpcClientType + + // For each method in the service + Object.values(service.methods).forEach((method) => { + // Create a function that matches the method signature + client[method.name as keyof GrpcClientType] = ((request: any) => { + return new Promise((resolve, reject) => { + const requestId = uuidv4() + + // Set up one-time listener for this specific request + const handleResponse = (event: MessageEvent) => { + const message = event.data + if (message.type === "grpc_response" && message.grpc_response?.request_id === requestId) { + // Remove listener once we get our response + window.removeEventListener("message", handleResponse) + + if (message.grpc_response.error) { + reject(new Error(message.grpc_response.error)) + } else { + // Convert JSON back to protobuf message + const responseType = method.responseType + const response = responseType.fromJSON(message.grpc_response.message) + console.log("[DEBUG] grpc-client sending response:", response) + resolve(response) + } + } + } + + window.addEventListener("message", handleResponse) + + let encodedRequest = {} + + // Handle different types of requests + if (request === null || request === undefined) { + // Empty request + encodedRequest = {} + } else if (typeof request.toJSON === "function") { + // Proper protobuf object + encodedRequest = request.toJSON() + } else if (typeof request === "object") { + // Plain JavaScript object + encodedRequest = { ...request } + } else { + // Fallback + encodedRequest = { value: request } + } + + // Send the request + vscode.postMessage({ + type: "grpc_request", + grpc_request: { + service: service.fullName, + method: method.name, + message: encodedRequest, // Convert protobuf to JSON + request_id: requestId, + }, + }) + }) + }) as any + }) + + return client +} + +// Create the Browser Service Client singleton with inferred types +// No need for manual interface definition - types are inferred from the service definition +const BrowserServiceClient = createGrpcClient(BrowserServiceDefinition) + +// Export the Browser Service Client as a static object +export { BrowserServiceClient } diff --git a/webview-ui/src/utils/useDebounceEffect.ts b/webview-ui/src/utils/useDebounceEffect.ts index 4a8e1da6..8f52284a 100644 --- a/webview-ui/src/utils/useDebounceEffect.ts +++ b/webview-ui/src/utils/useDebounceEffect.ts @@ -1,4 +1,5 @@ import { useEffect, useRef } from "react" +import type { DependencyList } from "react" type VoidFn = () => void @@ -6,7 +7,7 @@ type VoidFn = () => void * Runs `effectRef.current()` after `delay` ms whenever any of the `deps` change, * but cancels/re-schedules if they change again before the delay. */ -export function useDebounceEffect(effect: VoidFn, delay: number, deps: any[]) { +export function useDebounceEffect(effect: VoidFn, delay: number, deps: DependencyList) { const callbackRef = useRef(effect) const timeoutRef = useRef(null) diff --git a/webview-ui/src/utils/vscode.ts b/webview-ui/src/utils/vscode.ts index 7c754c5c..0f84c918 100644 --- a/webview-ui/src/utils/vscode.ts +++ b/webview-ui/src/utils/vscode.ts @@ -27,7 +27,7 @@ class VSCodeAPIWrapper { * @remarks When running webview code inside a web browser, postMessage will instead * log the given message to the console. * - * @param message Abitrary data (must be JSON serializable) to send to the extension context. + * @param message Arbitrary data (must be JSON serializable) to send to the extension context. */ public postMessage(message: WebviewMessage) { if (this.vsCodeApi) {