From bc7954c9ef0507801e19872f6eec6bedd6a607b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 04:10:36 +0000 Subject: [PATCH 01/58] chore(deps): bump @nestjs/common and @openapitools/openapi-generator-cli Bumps [@nestjs/common](https://github.com/nestjs/nest/tree/HEAD/packages/common) to 11.0.20 and updates ancestor dependency [@openapitools/openapi-generator-cli](https://github.com/OpenAPITools/openapi-generator-cli). These dependencies need to be updated together. Updates `@nestjs/common` from 10.4.6 to 11.0.20 - [Release notes](https://github.com/nestjs/nest/releases) - [Commits](https://github.com/nestjs/nest/commits/v11.0.20/packages/common) Updates `@openapitools/openapi-generator-cli` from 2.15.3 to 2.20.0 - [Release notes](https://github.com/OpenAPITools/openapi-generator-cli/releases) - [Changelog](https://github.com/OpenAPITools/openapi-generator-cli/blob/master/.releaserc) - [Commits](https://github.com/OpenAPITools/openapi-generator-cli/compare/v2.15.3...v2.20.0) --- updated-dependencies: - dependency-name: "@nestjs/common" dependency-version: 11.0.20 dependency-type: indirect - dependency-name: "@openapitools/openapi-generator-cli" dependency-version: 2.20.0 dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- extensions/vscode/package-lock.json | 421 +++++++++++++++------------- extensions/vscode/package.json | 2 +- 2 files changed, 224 insertions(+), 199 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index f0968956e..207a877dc 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -64,7 +64,7 @@ "devDependencies": { "@biomejs/biome": "1.6.4", "@nestjs/common": "^11.0.16", - "@openapitools/openapi-generator-cli": "^2.5.2", + "@openapitools/openapi-generator-cli": "^2.20.0", "@types/chai": "^5.0.1", "@types/cors": "^2.8.17", "@types/express": "^4.17.21", @@ -1442,14 +1442,28 @@ "resolved": "https://registry.npmjs.org/@neon-rs/load/-/load-0.0.74.tgz", "integrity": "sha512-/cPZD907UNz55yrc/ud4wDgQKtU1TvkD9jeqZWG6J4IMmZkp6zgjkQcKA8UvpkZlcpPHvc8J17sGzLFbP/LUYg==" }, + "node_modules/@nestjs/axios": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-4.0.0.tgz", + "integrity": "sha512-1cB+Jyltu/uUPNQrpUimRHEQHrnQrpLzVj6dU3dgn6iDDDdahr10TgHFGTmw5VuJ9GzKZsCLDL78VSwJAs/9JQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@nestjs/common": "^10.0.0 || ^11.0.0", + "axios": "^1.3.1", + "rxjs": "^7.0.0" + } + }, "node_modules/@nestjs/common": { - "version": "11.0.16", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.0.16.tgz", - "integrity": "sha512-agvuQ8su4aZ+PVxAmY89odG1eR97HEQvxPmTMdDqyvDWzNerl7WQhUEd+j4/UyNWcF1or1UVcrtPj52x+eUSsA==", + "version": "11.0.20", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.0.20.tgz", + "integrity": "sha512-/GH8NDCczjn6+6RNEtSNAts/nq/wQE8L1qZ9TRjqjNqEsZNE1vpFuRIhmcO2isQZ0xY5rySnpaRdrOAul3gQ3A==", "dev": true, "license": "MIT", "dependencies": { + "file-type": "20.4.1", "iterare": "1.2.1", + "load-esm": "1.0.2", "tslib": "2.8.1", "uid": "2.0.2" }, @@ -1460,7 +1474,6 @@ "peerDependencies": { "class-transformer": "*", "class-validator": "*", - "file-type": "^20.4.1", "reflect-metadata": "^0.1.12 || ^0.2.0", "rxjs": "^7.1.0" }, @@ -1473,6 +1486,58 @@ } } }, + "node_modules/@nestjs/core": { + "version": "11.0.20", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.0.20.tgz", + "integrity": "sha512-yUkEzBGiRNSEThVl6vMCXgoA9sDGWoRbJsTLdYdCC7lg7PE1iXBnna1FiBfQjT995pm0fjyM1e3WsXmyWeJXbw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "@nuxt/opencollective": "0.4.1", + "fast-safe-stringify": "2.1.1", + "iterare": "1.2.1", + "path-to-regexp": "8.2.0", + "tslib": "2.8.1", + "uid": "2.0.2" + }, + "engines": { + "node": ">= 20" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "@nestjs/common": "^11.0.0", + "@nestjs/microservices": "^11.0.0", + "@nestjs/platform-express": "^11.0.0", + "@nestjs/websockets": "^11.0.0", + "reflect-metadata": "^0.1.12 || ^0.2.0", + "rxjs": "^7.1.0" + }, + "peerDependenciesMeta": { + "@nestjs/microservices": { + "optional": true + }, + "@nestjs/platform-express": { + "optional": true + }, + "@nestjs/websockets": { + "optional": true + } + } + }, + "node_modules/@nestjs/core/node_modules/path-to-regexp": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", + "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1565,11 +1630,29 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@nuxt/opencollective": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@nuxt/opencollective/-/opencollective-0.4.1.tgz", + "integrity": "sha512-GXD3wy50qYbxCJ652bDrDzgMr3NFEkIS374+IgFQKkCvk9yiYcLvX2XDYr7UyQxf4wK0e+yqDYRubZ0DtOxnmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "consola": "^3.2.3" + }, + "bin": { + "opencollective": "bin/opencollective.js" + }, + "engines": { + "node": "^14.18.0 || >=16.10.0", + "npm": ">=5.10.0" + } + }, "node_modules/@nuxtjs/opencollective": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz", "integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.1.0", "consola": "^2.15.0", @@ -1583,11 +1666,19 @@ "npm": ">=5.0.0" } }, + "node_modules/@nuxtjs/opencollective/node_modules/consola": { + "version": "2.15.3", + "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", + "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==", + "dev": true, + "license": "MIT" + }, "node_modules/@nuxtjs/opencollective/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==", "dev": true, + "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -1607,48 +1698,52 @@ "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@nuxtjs/opencollective/node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true + "dev": true, + "license": "BSD-2-Clause" }, "node_modules/@nuxtjs/opencollective/node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, + "license": "MIT", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, "node_modules/@openapitools/openapi-generator-cli": { - "version": "2.15.3", - "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.15.3.tgz", - "integrity": "sha512-2UBnsDlMt36thhdXxisbA1qReVtbCaw+NCvXoslRXlaJBL4qkAmZUhNeDLNu3LCbwA2PASMWhJSqeLwgwMCitw==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.20.0.tgz", + "integrity": "sha512-Amtd7/9Lodaxnmfsru8R5n0CW9lyWOI40UsppGMfuNFkFFbabq51/VAJFsOHkNnDRwVUc7AGKWjN5icphDGlTQ==", "dev": true, "hasInstallScript": true, + "license": "Apache-2.0", "dependencies": { - "@nestjs/axios": "3.1.1", - "@nestjs/common": "10.4.6", - "@nestjs/core": "10.4.6", + "@nestjs/axios": "4.0.0", + "@nestjs/common": "11.0.20", + "@nestjs/core": "11.0.20", "@nuxtjs/opencollective": "0.3.2", - "axios": "1.7.7", + "axios": "1.8.4", "chalk": "4.1.2", "commander": "8.3.0", "compare-versions": "4.1.4", "concurrently": "6.5.1", "console.table": "0.10.0", - "fs-extra": "10.1.0", + "fs-extra": "11.3.0", "glob": "9.3.5", "inquirer": "8.2.6", "lodash": "4.17.21", - "proxy-agent": "6.4.0", - "reflect-metadata": "0.1.13", - "rxjs": "7.8.1", + "proxy-agent": "6.5.0", + "reflect-metadata": "0.2.2", + "rxjs": "7.8.2", "tslib": "2.8.1" }, "bin": { @@ -1662,97 +1757,6 @@ "url": "https://opencollective.com/openapi_generator" } }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/axios": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.1.1.tgz", - "integrity": "sha512-ySoxrzqX80P1q6LKLKGcgyBd2utg4gbC+4FsJNpXYvILorMlxss/ECNogD9EXLCE4JS5exVFD5ez0nK5hXcNTQ==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0", - "axios": "^1.3.1", - "rxjs": "^6.0.0 || ^7.0.0" - } - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/common": { - "version": "10.4.6", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.4.6.tgz", - "integrity": "sha512-KkezkZvU9poWaNq4L+lNvx+386hpOxPJkfXBBeSMrcqBOx8kVr36TGN2uYkF4Ta4zNu1KbCjmZbc0rhHSg296g==", - "dev": true, - "dependencies": { - "iterare": "1.2.1", - "tslib": "2.7.0", - "uid": "2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nest" - }, - "peerDependencies": { - "class-transformer": "*", - "class-validator": "*", - "reflect-metadata": "^0.1.12 || ^0.2.0", - "rxjs": "^7.1.0" - }, - "peerDependenciesMeta": { - "class-transformer": { - "optional": true - }, - "class-validator": { - "optional": true - } - } - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/common/node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", - "dev": true - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/core": { - "version": "10.4.6", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.4.6.tgz", - "integrity": "sha512-zXVPxCNRfO6gAy0yvEDjUxE/8gfZICJFpsl2lZAUH31bPb6m+tXuhUq2mVCTEltyMYQ+DYtRe+fEYM2v152N1g==", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "@nuxtjs/opencollective": "0.3.2", - "fast-safe-stringify": "2.1.1", - "iterare": "1.2.1", - "path-to-regexp": "3.3.0", - "tslib": "2.7.0", - "uid": "2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nest" - }, - "peerDependencies": { - "@nestjs/common": "^10.0.0", - "@nestjs/microservices": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "@nestjs/websockets": "^10.0.0", - "reflect-metadata": "^0.1.12 || ^0.2.0", - "rxjs": "^7.1.0" - }, - "peerDependenciesMeta": { - "@nestjs/microservices": { - "optional": true - }, - "@nestjs/platform-express": { - "optional": true - }, - "@nestjs/websockets": { - "optional": true - } - } - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/core/node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", - "dev": true - }, "node_modules/@openapitools/openapi-generator-cli/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -1762,6 +1766,21 @@ "balanced-match": "^1.0.0" } }, + "node_modules/@openapitools/openapi-generator-cli/node_modules/fs-extra": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.0.tgz", + "integrity": "sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, "node_modules/@openapitools/openapi-generator-cli/node_modules/glob": { "version": "9.3.5", "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz", @@ -1804,18 +1823,6 @@ "node": ">=8" } }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/path-to-regexp": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.3.0.tgz", - "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==", - "dev": true - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/reflect-metadata": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", - "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", - "dev": true - }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -1957,7 +1964,6 @@ "integrity": "sha512-MADQgmZT1eKjp06jpI2yozxaU9uVs4GzzgSL+uEq7bVcJ9V1ZXQkeGNql1fsSI0gMy1vhvNTNbUqrx+pZfJVmg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "debug": "^4.4.0", "fflate": "^0.8.2", @@ -1977,7 +1983,6 @@ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ms": "^2.1.3" }, @@ -1995,8 +2000,7 @@ "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@tootallnate/once": { "version": "2.0.0", @@ -2010,7 +2014,8 @@ "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/body-parser": { "version": "1.19.5", @@ -3076,12 +3081,10 @@ } }, "node_modules/agent-base": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", - "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", - "dependencies": { - "debug": "^4.3.4" - }, + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "license": "MIT", "engines": { "node": ">= 14" } @@ -3341,6 +3344,7 @@ "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", "dev": true, + "license": "MIT", "dependencies": { "tslib": "^2.0.1" }, @@ -3375,9 +3379,10 @@ "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==" }, "node_modules/axios": { - "version": "1.7.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", - "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "version": "1.8.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz", + "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==", + "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -3432,6 +3437,7 @@ "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.5.tgz", "integrity": "sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==", "dev": true, + "license": "MIT", "engines": { "node": ">=10.0.0" } @@ -4604,10 +4610,14 @@ } }, "node_modules/consola": { - "version": "2.15.3", - "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", - "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==", - "dev": true + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", + "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.10.0" + } }, "node_modules/console-control-strings": { "version": "1.1.0", @@ -4970,6 +4980,7 @@ "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", "dev": true, + "license": "MIT", "dependencies": { "ast-types": "^0.13.4", "escodegen": "^2.1.0", @@ -5458,6 +5469,7 @@ "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "esprima": "^4.0.1", "estraverse": "^5.2.0", @@ -5479,6 +5491,7 @@ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } @@ -5647,6 +5660,7 @@ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true, + "license": "BSD-2-Clause", "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -5954,7 +5968,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/fastq": { "version": "1.17.1", @@ -5999,8 +6014,7 @@ "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/figures": { "version": "3.2.0", @@ -6044,7 +6058,6 @@ "integrity": "sha512-hw9gNZXUfZ02Jo0uafWLaFVPter5/k2rfcrjFJJHX/77xtSDOfJuEFb6oKlFV86FLP1SuyHMW1PSk0U9M5tKkQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@tokenizer/inflate": "^0.2.6", "strtok3": "^10.2.0", @@ -6489,15 +6502,15 @@ } }, "node_modules/get-uri": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.3.tgz", - "integrity": "sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw==", + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.4.tgz", + "integrity": "sha512-E1b1lFFLvLgak2whF2xDBcOy6NLVGZBqqjJjsIhvopKfWWEi64pLVTWWehV8KlLerZkfNTA95sTe2OdJKm1OzQ==", "dev": true, + "license": "MIT", "dependencies": { "basic-ftp": "^5.0.2", "data-uri-to-buffer": "^6.0.2", - "debug": "^4.3.4", - "fs-extra": "^11.2.0" + "debug": "^4.3.4" }, "engines": { "node": ">= 14" @@ -6508,24 +6521,11 @@ "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 14" } }, - "node_modules/get-uri/node_modules/fs-extra": { - "version": "11.2.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", - "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -6984,11 +6984,12 @@ } }, "node_modules/https-proxy-agent": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", - "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "license": "MIT", "dependencies": { - "agent-base": "^7.0.2", + "agent-base": "^7.1.2", "debug": "4" }, "engines": { @@ -7919,6 +7920,26 @@ "uc.micro": "^1.0.1" } }, + "node_modules/load-esm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/load-esm/-/load-esm-1.0.2.tgz", + "integrity": "sha512-nVAvWk/jeyrWyXEAs84mpQCYccxRqgKY4OznLuJhJCa0XsPSfdOIr2zvBZEj3IHEHbX97jjscKRRV539bW0Gpw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + }, + { + "type": "buymeacoffee", + "url": "https://buymeacoffee.com/borewit" + } + ], + "license": "MIT", + "engines": { + "node": ">=13.2.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -9265,6 +9286,7 @@ "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4.0" } @@ -9963,31 +9985,33 @@ } }, "node_modules/pac-proxy-agent": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.2.tgz", - "integrity": "sha512-BFi3vZnO9X5Qt6NRz7ZOaPja3ic0PhlsmCRYLOpN11+mWBCR6XJDqW5RF3j8jm4WGGQZtBA+bTfxYzeKW73eHg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz", + "integrity": "sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA==", "dev": true, + "license": "MIT", "dependencies": { "@tootallnate/quickjs-emscripten": "^0.23.0", - "agent-base": "^7.0.2", + "agent-base": "^7.1.2", "debug": "^4.3.4", "get-uri": "^6.0.1", "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.5", + "https-proxy-agent": "^7.0.6", "pac-resolver": "^7.0.1", - "socks-proxy-agent": "^8.0.4" + "socks-proxy-agent": "^8.0.5" }, "engines": { "node": ">= 14" } }, "node_modules/pac-proxy-agent/node_modules/socks-proxy-agent": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.4.tgz", - "integrity": "sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw==", + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", + "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", "dev": true, + "license": "MIT", "dependencies": { - "agent-base": "^7.1.1", + "agent-base": "^7.1.2", "debug": "^4.3.4", "socks": "^2.8.3" }, @@ -10000,6 +10024,7 @@ "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz", "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==", "dev": true, + "license": "MIT", "dependencies": { "degenerator": "^5.0.0", "netmask": "^2.0.2" @@ -10192,7 +10217,6 @@ "integrity": "sha512-nri2TO5JE3/mRryik9LlHFT53cgHfRK0Lt0BAZQXku/AW3E6XLt2GaY8siWi7dvW/m1z0ecn+J+bpDa9ZN3IsQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=18" }, @@ -10678,19 +10702,20 @@ } }, "node_modules/proxy-agent": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.4.0.tgz", - "integrity": "sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.5.0.tgz", + "integrity": "sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A==", "dev": true, + "license": "MIT", "dependencies": { - "agent-base": "^7.0.2", + "agent-base": "^7.1.2", "debug": "^4.3.4", "http-proxy-agent": "^7.0.1", - "https-proxy-agent": "^7.0.3", + "https-proxy-agent": "^7.0.6", "lru-cache": "^7.14.1", - "pac-proxy-agent": "^7.0.1", + "pac-proxy-agent": "^7.1.0", "proxy-from-env": "^1.1.0", - "socks-proxy-agent": "^8.0.2" + "socks-proxy-agent": "^8.0.5" }, "engines": { "node": ">= 14" @@ -10701,17 +10726,19 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", "dev": true, + "license": "ISC", "engines": { "node": ">=12" } }, "node_modules/proxy-agent/node_modules/socks-proxy-agent": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.4.tgz", - "integrity": "sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw==", + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", + "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", "dev": true, + "license": "MIT", "dependencies": { - "agent-base": "^7.1.1", + "agent-base": "^7.1.2", "debug": "^4.3.4", "socks": "^2.8.3" }, @@ -11075,11 +11102,11 @@ } }, "node_modules/reflect-metadata": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz", - "integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", + "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==", "dev": true, - "peer": true + "license": "Apache-2.0" }, "node_modules/regenerator-runtime": { "version": "0.14.1", @@ -11416,10 +11443,11 @@ "integrity": "sha512-cLgakCUf6PedEu15t8kbsjnwIFFR2D4RfL+W3iWFJ4iac7z4B0ZI8fxy4R3J956kAI68HclCFGL8MPoUVC3qVA==" }, "node_modules/rxjs": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", - "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", "dev": true, + "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" } @@ -12166,7 +12194,6 @@ "integrity": "sha512-Xt18+h4s7Z8xyZ0tmBoRmzxcop97R4BAh+dXouUDCYn+Em+1P3qpkUfI5ueWLT8ynC5hZ+q4iPEmGG1urvQGBg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@tokenizer/token": "^0.3.0", "peek-readable": "^7.0.0" @@ -12822,7 +12849,6 @@ "integrity": "sha512-lbDrTLVsHhOMljPscd0yitpozq7Ga2M5Cvez5AjGg8GASBjtt6iERCAJ93yommPmz62fb45oFIXHEZ3u9bfJEA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" @@ -13080,7 +13106,6 @@ "integrity": "sha512-ZPtzy0hu4cZjv3z5NW9gfKnNLjoz4y6uv4HlelAjDK7sY/xOkKZv9xK/WQpcsBB3jEybChz9DPC2U/+cusjJVQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=18" }, diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 4ea6bddfd..a70995944 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -631,7 +631,7 @@ "devDependencies": { "@biomejs/biome": "1.6.4", "@nestjs/common": "^11.0.16", - "@openapitools/openapi-generator-cli": "^2.5.2", + "@openapitools/openapi-generator-cli": "^2.20.0", "@types/chai": "^5.0.1", "@types/cors": "^2.8.17", "@types/express": "^4.17.21", From e3de63ef6c0cf7faf81b889849f6205c85acca94 Mon Sep 17 00:00:00 2001 From: liuk Date: Sat, 17 May 2025 17:45:54 +0800 Subject: [PATCH 02/58] style: update button styles and background color --- gui/src/components/index.ts | 2 +- .../components/mainInput/Lump/sections/ExploreBlocksButton.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index 036f912c8..89cca7220 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -158,7 +158,7 @@ export const GhostButton = styled.button` border: none; color: ${vscForeground}; - background-color: rgba(255, 255, 255, 0.08); + background-color: rgba(128, 128, 128, 0.4); &:disabled { color: gray; pointer-events: none; diff --git a/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx b/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx index a79d05a56..0a24e8fcf 100644 --- a/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx +++ b/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx @@ -49,7 +49,7 @@ export function ExploreBlocksButton(props: { blockType: string }) { return ( Date: Fri, 2 May 2025 20:48:57 -0500 Subject: [PATCH 03/58] feat: add support for multiple MCP server types (stdio, sse, websocket) in the YAML configuration schema, ensuring backward compatibility with legacy configurations --- core/config/workspace/workspaceBlocks.ts | 6 ++ core/config/yaml/loadYaml.test.ts | 107 ++++++++++++++++++++++ core/config/yaml/loadYaml.ts | 42 +++++++-- docs/docs/customize/deep-dives/mcp.mdx | 10 ++ docs/docs/reference.md | 14 ++- packages/config-yaml/src/converter.ts | 46 ++++++++-- packages/config-yaml/src/schemas/index.ts | 46 ++++++++-- 7 files changed, 246 insertions(+), 25 deletions(-) create mode 100644 core/config/yaml/loadYaml.test.ts diff --git a/core/config/workspace/workspaceBlocks.ts b/core/config/workspace/workspaceBlocks.ts index 009e3cdff..1bd66bdd5 100644 --- a/core/config/workspace/workspaceBlocks.ts +++ b/core/config/workspace/workspaceBlocks.ts @@ -53,10 +53,16 @@ function getContentsForNewBlock(blockType: BlockType): ConfigYaml { configYaml.mcpServers = [ { name: "New MCP server", + type: "stdio", command: "npx", args: ["-y", ""], env: {}, }, + { + name: "New MCP server", + type: "sse", + url: "https://example.org/sse" + }, ]; break; } diff --git a/core/config/yaml/loadYaml.test.ts b/core/config/yaml/loadYaml.test.ts new file mode 100644 index 000000000..600b94eef --- /dev/null +++ b/core/config/yaml/loadYaml.test.ts @@ -0,0 +1,107 @@ +import { MCPServer } from "@continuedev/config-yaml"; +import { convertYamlMcpToContinueMcp } from "./loadYaml"; + +describe("MCP Server Configuration Tests", () => { + test("should convert stdio MCP server correctly", () => { + const stdioServer: MCPServer = { + name: "Test Stdio Server", + type: "stdio", + command: "uvx", + args: ["mcp-server-sqlite", "--db-path", "/test.db"], + env: { TEST_ENV: "value" }, + connectionTimeout: 5000 + }; + + const result = convertYamlMcpToContinueMcp(stdioServer); + + expect(result).toEqual({ + transport: { + type: "stdio", + command: "uvx", + args: ["mcp-server-sqlite", "--db-path", "/test.db"], + env: { TEST_ENV: "value" } + }, + timeout: 5000 + }); + }); + + test("should convert SSE MCP server correctly", () => { + const sseServer: MCPServer = { + name: "Test SSE Server", + type: "sse", + url: "http://localhost:8150/cosmos/mcp/v1/sse", + connectionTimeout: 3000 + }; + + const result = convertYamlMcpToContinueMcp(sseServer); + + expect(result).toEqual({ + transport: { + type: "sse", + url: "http://localhost:8150/cosmos/mcp/v1/sse" + }, + timeout: 3000 + }); + }); + + test("should convert WebSocket MCP server correctly", () => { + const wsServer: MCPServer = { + name: "Test WebSocket Server", + type: "websocket", + url: "ws://localhost:8150/cosmos/mcp/v1/ws", + connectionTimeout: 10000 + }; + + const result = convertYamlMcpToContinueMcp(wsServer); + + expect(result).toEqual({ + transport: { + type: "websocket", + url: "ws://localhost:8150/cosmos/mcp/v1/ws" + }, + timeout: 10000 + }); + }); + + test("should handle legacy MCP server format for backward compatibility", () => { + // Test with old format that doesn't have a type field + const legacyServer = { + name: "Legacy Server", + command: "old-command", + args: ["--legacy"], + connectionTimeout: 2000 + } as any; + + const result = convertYamlMcpToContinueMcp(legacyServer); + + expect(result).toEqual({ + transport: { + type: "stdio", + command: "old-command", + args: ["--legacy"], + env: undefined + }, + timeout: 2000 + }); + }); + + test("should handle missing optional fields", () => { + const minimalServer: MCPServer = { + name: "Minimal Server", + type: "stdio", + command: "minimal" + }; + + const result = convertYamlMcpToContinueMcp(minimalServer); + + expect(result).toEqual({ + transport: { + type: "stdio", + command: "minimal", + args: [], + env: undefined + }, + timeout: undefined + }); + }); +}); \ No newline at end of file diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index e667415d2..0e8399113 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -63,17 +63,42 @@ function convertYamlRuleToContinueRule(rule: Rule): RuleWithSource { } } -function convertYamlMcpToContinueMcp( +export function convertYamlMcpToContinueMcp( server: MCPServer, ): ExperimentalMCPOptions { + const transportConfig = (() => { + switch (server.type) { + case "stdio": + return { + type: "stdio" as const, + command: server.command, + args: server.args ?? [], + env: server.env, + }; + case "sse": + return { + type: "sse" as const, + url: server.url, + }; + case "websocket": + return { + type: "websocket" as const, + url: server.url, + }; + default: + // Default to stdio for backward compatibility + return { + type: "stdio" as const, + command: (server as any).command, + args: (server as any).args ?? [], + env: (server as any).env, + }; + } + })(); + return { - transport: { - type: "stdio", - command: server.command, - args: server.args ?? [], - env: server.env, - }, - timeout: server.connectionTimeout, + transport: transportConfig, + timeout: server.connectionTimeout }; } @@ -457,7 +482,6 @@ async function configYamlToContinueConfig(options: { id: server.name, name: server.name, transport: { - type: "stdio", args: [], ...server, }, diff --git a/docs/docs/customize/deep-dives/mcp.mdx b/docs/docs/customize/deep-dives/mcp.mdx index e4e828520..7f241d094 100644 --- a/docs/docs/customize/deep-dives/mcp.mdx +++ b/docs/docs/customize/deep-dives/mcp.mdx @@ -20,11 +20,15 @@ To set up your own MCP server, read the [MCP quickstart](https://modelcontextpro ```yaml title="config.yaml" mcpServers: - name: My MCP Server + type: stdio command: uvx args: - mcp-server-sqlite - --db-path - /Users/NAME/test.db + - name: My MCP Server with SSE + type: sse + url: "https://example.com/mcp-server/sse" ``` @@ -38,6 +42,12 @@ To set up your own MCP server, read the [MCP quickstart](https://modelcontextpro "command": "uvx", "args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"] } + }, + { + "transport": { + "type": "sse", + "url": "https://example.com/mcp-server/sse" + } } ] } diff --git a/docs/docs/reference.md b/docs/docs/reference.md index e8b915813..afda6eb94 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -379,21 +379,33 @@ prompts, context, and tool use. Continue supports any MCP server with the MCP co **Properties:** - `name` (**required**): The name of the MCP server. +- `type"` (**required**): The type of the MCP server. Can be "stdio", "sse", or "websocket. + +**Stdio type** + - `command` (**required**): The command used to start the server. - `args`: An optional array of arguments for the command. - `env`: An optional map of environment variables for the server process. - `connectionTimeout`: An optional connection timeout number to the server in milliseconds. +**SSE or Websocket type** + +- `url` (**required**): The URL of the MCP server. + **Example:** ```yaml title="config.yaml" mcpServers: - - name: My MCP Server + - name: My MCP Server with stdio + type: stdio command: uvx args: - mcp-server-sqlite - --db-path - /Users/NAME/test.db + - name: My MCP Server with SSE + type: sse + url: "https://example.com/mcp-server/sse" ``` ### `data` diff --git a/packages/config-yaml/src/converter.ts b/packages/config-yaml/src/converter.ts index 40e1f226a..334e6c699 100644 --- a/packages/config-yaml/src/converter.ts +++ b/packages/config-yaml/src/converter.ts @@ -128,14 +128,48 @@ function convertCustomCommand( function convertMcp(mcp: any): NonNullable[number] { const { transport } = mcp; - const { command, args, env, server_name } = transport; + const { type } = transport; - return { - command, - args, - env, - name: server_name || "MCP Server", + // Common properties for all server types + const baseServer: any = { + name: mcp.name, + type: type, }; + + if (mcp.faviconUrl) { + baseServer.faviconUrl = mcp.faviconUrl + } + if (mcp.connectionTimeout) { + baseServer.connectionTimeout = mcp.connectionTimeout + } + + // Type-specific properties + switch (type) { + case "stdio": + const stdioServer = { + ...baseServer, + command: transport.command, + }; + + if (transport.args) { + stdioServer.args = transport.args + } + if (transport.env) { + stdioServer.env = transport.env + } + + return stdioServer; + + case "sse": + case "websocket": + return { + ...baseServer, + url: transport.url + }; + + default: + throw new Error(`Unknown MCP server type: ${type}`); + } } function convertDoc( diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 35e110206..fa1f47e04 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -9,14 +9,31 @@ export const contextSchema = z.object({ params: z.any().optional(), }); -const mcpServerSchema = z.object({ - name: z.string(), - command: z.string(), - faviconUrl: z.string().optional(), - args: z.array(z.string()).optional(), - env: z.record(z.string()).optional(), - connectionTimeout: z.number().gt(0).optional() -}); +const mcpServerSchema = z.discriminatedUnion("type", [ + z.object({ + name: z.string(), + type: z.literal("stdio"), + command: z.string(), + faviconUrl: z.string().optional(), + args: z.array(z.string()).optional(), + env: z.record(z.string()).optional(), + connectionTimeout: z.number().gt(0).optional() + }), + z.object({ + name: z.string(), + type: z.literal("sse"), + url: z.string(), + faviconUrl: z.string().optional(), + connectionTimeout: z.number().gt(0).optional() + }), + z.object({ + name: z.string(), + type: z.literal("websocket"), + url: z.string(), + faviconUrl: z.string().optional(), + connectionTimeout: z.number().gt(0).optional() + }) +]); export type MCPServer = z.infer; @@ -63,6 +80,17 @@ export const blockOrSchema = ( usesSchema: z.ZodTypeAny = defaultUsesSchema, ) => z.union([schema, blockItemWrapperSchema(schema, usesSchema)]); +export const blockOrDiscriminatedUnionSchema = ( + schema: T, + usesSchema: z.ZodTypeAny = defaultUsesSchema, +) => z.union([schema, z.object({ + uses: usesSchema, + with: z.record(z.string()).optional(), + // For a discriminated union, we can't easily create a partial version + // So we'll use any for the override + override: z.any().optional(), +})]); + export const commonMetadataSchema = z.object({ tags: z.string().optional(), sourceCodeUrl: z.string().optional(), @@ -98,7 +126,7 @@ export const configYamlSchema = baseConfigYamlSchema.extend({ .optional(), context: z.array(blockOrSchema(contextSchema)).optional(), data: z.array(blockOrSchema(dataSchema)).optional(), - mcpServers: z.array(blockOrSchema(mcpServerSchema)).optional(), + mcpServers: z.array(blockOrDiscriminatedUnionSchema(mcpServerSchema)).optional(), rules: z .array( z.union([ From 0356b0dd3a277d2d213d321a2e1028ce0ceb3f98 Mon Sep 17 00:00:00 2001 From: 04cfb1ed <12877898+04cfb1ed@users.noreply.github.com> Date: Sun, 18 May 2025 20:58:12 -0500 Subject: [PATCH 04/58] refactor: move blockOrDiscriminatedUnionSchema logic inside of blockOrSchema --- packages/config-yaml/src/schemas/index.ts | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index fa1f47e04..ce7ffaa4f 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -78,18 +78,17 @@ export const blockItemWrapperSchema = ( export const blockOrSchema = ( schema: T, usesSchema: z.ZodTypeAny = defaultUsesSchema, -) => z.union([schema, blockItemWrapperSchema(schema, usesSchema)]); - -export const blockOrDiscriminatedUnionSchema = ( - schema: T, - usesSchema: z.ZodTypeAny = defaultUsesSchema, -) => z.union([schema, z.object({ - uses: usesSchema, - with: z.record(z.string()).optional(), - // For a discriminated union, we can't easily create a partial version - // So we'll use any for the override - override: z.any().optional(), -})]); + isDiscriminatedUnion?: boolean, +) => { + if (isDiscriminatedUnion) { + return z.union([schema, z.object({ + uses: usesSchema, + with: z.record(z.string()).optional(), + override: z.any().optional(), + })]); + } + return z.union([schema, blockItemWrapperSchema(schema, usesSchema)]); +}; export const commonMetadataSchema = z.object({ tags: z.string().optional(), @@ -126,7 +125,7 @@ export const configYamlSchema = baseConfigYamlSchema.extend({ .optional(), context: z.array(blockOrSchema(contextSchema)).optional(), data: z.array(blockOrSchema(dataSchema)).optional(), - mcpServers: z.array(blockOrDiscriminatedUnionSchema(mcpServerSchema)).optional(), + mcpServers: z.array(blockOrSchema(mcpServerSchema as any, defaultUsesSchema, true)).optional(), rules: z .array( z.union([ @@ -251,4 +250,4 @@ export const configSchema = z.object({ api_key: z.string().optional(), }); -export type Config = z.infer; +export type Config = z.infer; \ No newline at end of file From 7fa43a1be3c09e4be29b5372f8df6c9bd2a02104 Mon Sep 17 00:00:00 2001 From: 04cfb1ed <12877898+04cfb1ed@users.noreply.github.com> Date: Sun, 18 May 2025 21:17:41 -0500 Subject: [PATCH 05/58] docs: add missing quote --- docs/docs/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference.md b/docs/docs/reference.md index afda6eb94..1496657e1 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -379,7 +379,7 @@ prompts, context, and tool use. Continue supports any MCP server with the MCP co **Properties:** - `name` (**required**): The name of the MCP server. -- `type"` (**required**): The type of the MCP server. Can be "stdio", "sse", or "websocket. +- `type"` (**required**): The type of the MCP server. Can be "stdio", "sse", or "websocket". **Stdio type** From 99b1ab2ebe51b4678722703922ecca023afa911c Mon Sep 17 00:00:00 2001 From: 04cfb1ed <12877898+04cfb1ed@users.noreply.github.com> Date: Sun, 18 May 2025 21:40:17 -0500 Subject: [PATCH 06/58] fix: ensure template variables are only processed for stdio MCP servers --- core/config/yaml/loadYaml.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 0e8399113..c411e0b3f 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -270,7 +270,7 @@ async function configYamlToContinueConfig(options: { config.mcpServers?.forEach((mcpServer) => { const mcpArgVariables = - mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? []; + (mcpServer.type === "stdio" ? mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) : []) ?? []; if (mcpArgVariables.length === 0) { return; From 71b969d1e091eebfe211fdeb1c6abb0b568d5b38 Mon Sep 17 00:00:00 2001 From: DERHauck Date: Mon, 19 May 2025 09:47:40 +0200 Subject: [PATCH 07/58] #5728 add regex to allow for openai o-series models and rename method to stay descriptive of new functionality --- core/llm/llms/OpenAI.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index f6dbc2bf3..59c76d037 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -77,8 +77,8 @@ class OpenAI extends BaseLLM { return model; } - private isO3orO1Model(model?: string): boolean { - return !!model && (model.startsWith("o1") || model.startsWith("o3")); + private isOSeriesModel(model?: string): boolean { + return !!model && model.match(/^o[0-9]+/); } private isFireworksAiModel(model?: string): boolean { @@ -139,7 +139,7 @@ class OpenAI extends BaseLLM { finalOptions.stop = options.stop?.slice(0, this.getMaxStopWords()); // OpenAI o1-preview and o1-mini or o3-mini: - if (this.isO3orO1Model(options.model)) { + if (this.isOSeriesModel(options.model)) { // a) use max_completion_tokens instead of max_tokens finalOptions.max_completion_tokens = options.maxTokens; finalOptions.max_tokens = undefined; @@ -241,7 +241,7 @@ class OpenAI extends BaseLLM { body.stop = body.stop?.slice(0, this.getMaxStopWords()); // OpenAI o1-preview and o1-mini or o3-mini: - if (this.isO3orO1Model(body.model)) { + if (this.isOSeriesModel(body.model)) { // a) use max_completion_tokens instead of max_tokens body.max_completion_tokens = body.max_tokens; body.max_tokens = undefined; From c30e143100b65ea55efa3588b73f8aff411c34c5 Mon Sep 17 00:00:00 2001 From: DERHauck Date: Mon, 19 May 2025 09:54:31 +0200 Subject: [PATCH 08/58] #5728 fix missing boolean check --- core/llm/llms/OpenAI.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index 59c76d037..06108793b 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -78,7 +78,7 @@ class OpenAI extends BaseLLM { } private isOSeriesModel(model?: string): boolean { - return !!model && model.match(/^o[0-9]+/); + return !!model && !!model.match(/^o[0-9]+/); } private isFireworksAiModel(model?: string): boolean { From 359a59fe2672616abf5f30de7af1294b01af3a28 Mon Sep 17 00:00:00 2001 From: Saim Date: Tue, 20 May 2025 08:52:21 +0530 Subject: [PATCH 09/58] Fix: improve command extraction in RunInTerminalButton (#5724) --- .../RunInTerminalButton.tsx | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx index 6154b3452..98deb4879 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx @@ -18,14 +18,38 @@ export function RunInTerminalButton({ command }: RunInTerminalButtonProps) { // Extract just the command line (the line after $ or the first line) function extractCommand(cmd: string): string { - // If the command contains a $ prompt, extract the line after it + // First handle the $ prompt case, extract the line after it if (cmd.includes("$")) { const match = cmd.match(/\$\s*([^\n]+)/); - return match ? match[1].trim() : ""; + if (match) { + return match[1].trim(); + } } - // Otherwise, just take the first line - return cmd.split("\n")[0].trim(); + // Process all lines, filtering out comments and empty lines + const lines = cmd.split("\n") + .map(line => line.trim()) + .filter(line => + line && + !line.startsWith("#") && + !line.startsWith("//") && + !line.startsWith("/*") + ); + + // Handle multi-line commands + let result = ""; + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + result += line; + + // Add space for command continuation + if (line.endsWith("&&") || line.endsWith("|") || line.endsWith("\\")) { + result += " "; + } else if (i < lines.length - 1) { + result += " "; + } + } + return result.trim(); } function runInTerminal() { From 4c957c0039c746f049f6a8b236120109b9ccbdc4 Mon Sep 17 00:00:00 2001 From: Piotr Czekaj Date: Tue, 20 May 2025 10:19:55 +0200 Subject: [PATCH 10/58] Fix config merging if using remote config and local json config then without this fix only http providers from remote config are used due to the fact that providers have the same name "http". --- core/config/load.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 5a74aa6bb..de08ecfc7 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -101,7 +101,14 @@ export function resolveSerializedConfig( const configMergeKeys = { models: (a: any, b: any) => a.title === b.title, - contextProviders: (a: any, b: any) => a.name === b.name, + contextProviders: (a: any, b: any) => { + // If not HTTP providers, use the name only + if (a.name !== "http" || b.name !== "http") { + return a.name === b.name; + } + // For HTTP providers, consider them different if they have different URLs + return a.name === b.name && a.params?.url === b.params?.url; + }, slashCommands: (a: any, b: any) => a.name === b.name, customCommands: (a: any, b: any) => a.name === b.name, }; @@ -970,6 +977,5 @@ export { finalToBrowserConfig, intermediateToFinalConfig, loadContinueConfigFromJson, - type BrowserSerializedContinueConfig + type BrowserSerializedContinueConfig, }; - From 6222824cf4db2d15064bbb26a94b0f3725ae48a0 Mon Sep 17 00:00:00 2001 From: DERHauck Date: Tue, 20 May 2025 11:46:51 +0200 Subject: [PATCH 11/58] #5728 add tests for isOSeriesModel and make method public in OpenAI class for easier testing --- core/llm/llms/OpenAI.test.ts | 34 ++++++++++++++++++++++++++++++++++ core/llm/llms/OpenAI.ts | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 core/llm/llms/OpenAI.test.ts diff --git a/core/llm/llms/OpenAI.test.ts b/core/llm/llms/OpenAI.test.ts new file mode 100644 index 000000000..a050a430e --- /dev/null +++ b/core/llm/llms/OpenAI.test.ts @@ -0,0 +1,34 @@ +import OpenAI from "./OpenAI"; + +describe("OpenAI", () => { + test("should identify correct o-series models", () => { + const openai = new OpenAI({ + model: "o3-mini", + }); + expect(openai.isOSeriesModel("o4-mini")).toBeTruthy(); + expect(openai.isOSeriesModel("o3-mini")).toBeTruthy(); + expect(openai.isOSeriesModel("o1-mini")).toBeTruthy(); + expect(openai.isOSeriesModel("o1")).toBeTruthy(); + expect(openai.isOSeriesModel("o3")).toBeTruthy(); + + // artificially correct samples for future models + expect(openai.isOSeriesModel("o5-mini")).toBeTruthy(); + expect(openai.isOSeriesModel("o6")).toBeTruthy(); + expect(openai.isOSeriesModel("o77")).toBeTruthy(); + expect(openai.isOSeriesModel("o54-mini")).toBeTruthy(); + }); + test("should identify incorrect o-series models", () => { + const openai = new OpenAI({ + model: "o3-mini", + }); + expect(openai.isOSeriesModel("gpt-o4-mini")).toBeFalsy(); + expect(openai.isOSeriesModel("gpt-4.5")).toBeFalsy(); + expect(openai.isOSeriesModel("gpt-4.5")).toBeFalsy(); + + // artificially wrong samples + expect(openai.isOSeriesModel("os1")).toBeFalsy(); + expect(openai.isOSeriesModel("so1")).toBeFalsy(); + expect(openai.isOSeriesModel("o3s1")).toBeFalsy(); + expect(openai.isOSeriesModel("os1")).toBeFalsy(); + }); +}); diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index 06108793b..2297f9efd 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -77,7 +77,7 @@ class OpenAI extends BaseLLM { return model; } - private isOSeriesModel(model?: string): boolean { + public isOSeriesModel(model?: string): boolean { return !!model && !!model.match(/^o[0-9]+/); } From 22aa3ac2219ca7a59ca1cf35af0a1728a4d829b4 Mon Sep 17 00:00:00 2001 From: DERHauck Date: Tue, 20 May 2025 11:58:50 +0200 Subject: [PATCH 12/58] #5728 Update negative test cases in isOSeriesModel unit tests to improve coverage and accuracy --- core/llm/llms/OpenAI.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/llm/llms/OpenAI.test.ts b/core/llm/llms/OpenAI.test.ts index a050a430e..46c8b4e23 100644 --- a/core/llm/llms/OpenAI.test.ts +++ b/core/llm/llms/OpenAI.test.ts @@ -23,12 +23,12 @@ describe("OpenAI", () => { }); expect(openai.isOSeriesModel("gpt-o4-mini")).toBeFalsy(); expect(openai.isOSeriesModel("gpt-4.5")).toBeFalsy(); - expect(openai.isOSeriesModel("gpt-4.5")).toBeFalsy(); + expect(openai.isOSeriesModel("gpt-4.1")).toBeFalsy(); // artificially wrong samples expect(openai.isOSeriesModel("os1")).toBeFalsy(); expect(openai.isOSeriesModel("so1")).toBeFalsy(); - expect(openai.isOSeriesModel("o3s1")).toBeFalsy(); - expect(openai.isOSeriesModel("os1")).toBeFalsy(); + expect(openai.isOSeriesModel("ao31")).toBeFalsy(); + expect(openai.isOSeriesModel("1os")).toBeFalsy(); }); }); From 90d895e2e22ee40033c524a109b5777b5c3bf6cd Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 09:48:04 -0700 Subject: [PATCH 13/58] feat: cleanup inline edit code --- binary/package-lock.json | 2 + .../continue/ApplyToFileHandler.kt | 4 +- .../continue/IdeProtocolClient.kt | 2 +- .../editor/EditorUtils.kt | 25 ++++--- .../editor/InlineEditAction.kt | 40 ++++------- .../editor/RangeInFileWithContents.kt | 70 ++++++++++++++++--- extensions/vscode/package-lock.json | 6 +- gui/package-lock.json | 2 + 8 files changed, 97 insertions(+), 54 deletions(-) diff --git a/binary/package-lock.json b/binary/package-lock.json index acb5b9fea..bb15529ae 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -93,6 +93,7 @@ "p-limit": "^6.1.0", "partial-json": "^0.1.7", "pg": "^8.11.3", + "plist": "^3.1.0", "posthog-node": "^3.6.3", "puppeteer": "^22.4.0", "puppeteer-chromium-resolver": "^23.0.0", @@ -129,6 +130,7 @@ "@types/mustache": "^4.2.5", "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", + "@types/plist": "^3.0.5", "@types/request": "^2.48.12", "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt index a8edd5527..755b16d85 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt @@ -121,10 +121,10 @@ class ApplyToFileHandler( val prompt = buildApplyPrompt() // Extract the code ranges (highlighted or full document) - val (prefix, highlighted, suffix) = editorUtils.extractCodeRanges() + val (prefix, highlighted, suffix) = editorUtils.getHighlightedRangeTriplet() // Get the line range for the diff stream - val rif = editorUtils.getHighlightedCode() + val rif = editorUtils.getHighlightedRIF() val startLine = rif?.range?.start?.line ?: 0 val endLine = rif?.range?.end?.line ?: (editorUtils.getLineCount() - 1) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index cc9f018fa..732810427 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -493,7 +493,7 @@ class IdeProtocolClient( fun sendHighlightedCode(edit: Boolean = false) { val editor = EditorUtils.getEditor(project) - val rif = editor?.getHighlightedCode() ?: return + val rif = editor?.getHighlightedRIF() ?: return continuePluginService.sendToWebview( "highlightedCode", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorUtils.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorUtils.kt index 23b1b1bcd..857c0104f 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorUtils.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/EditorUtils.kt @@ -1,7 +1,5 @@ package com.github.continuedev.continueintellijextension.editor -import com.github.continuedev.continueintellijextension.Position -import com.github.continuedev.continueintellijextension.Range import com.github.continuedev.continueintellijextension.utils.toUriOrNull import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.command.WriteCommandAction @@ -72,28 +70,33 @@ class EditorUtils(val editor: Editor) { editor.scrollingModel.scrollTo(logicalPosition, ScrollType.CENTER_UP) } + /** + * Remove the selected range in a thread-safe manner + */ + fun removeSelection() { + ApplicationManager.getApplication().invokeLater { + editor.selectionModel.removeSelection() + } + } /** * Extracts code ranges from the editor: (prefix, highlighted/selected text, suffix) */ - fun extractCodeRanges(): Triple { - val rif = getHighlightedCode() + fun getHighlightedRangeTriplet(): Triple { + val rif = getHighlightedRIF() return if (rif == null) { // If no highlight, use the whole document as highlighted Triple("", editor.document.text, "") } else { // Use the RangeInFileWithContents to get absolute offsets - val startOffset = rif.getStartOffset(editor.document) - val endOffset = rif.getEndOffset(editor.document) + val (startOffset, endOffset) = rif.offsets + val prefix = editor.document.getText(TextRange(0, startOffset)) val highlighted = rif.contents val suffix = editor.document.getText(TextRange(endOffset, editor.document.textLength)) - // Remove the selection after processing - ApplicationManager.getApplication().invokeLater { - editor.selectionModel.removeSelection() - } + removeSelection() Triple(prefix, highlighted, suffix) } @@ -103,7 +106,7 @@ class EditorUtils(val editor: Editor) { * Gets the selected code from the current editor. * Returns null if there is no selection. */ - fun getHighlightedCode(): RangeInFileWithContents? { + fun getHighlightedRIF(): RangeInFileWithContents? { return ApplicationManager.getApplication().runReadAction { val virtualFile = FileDocumentManager.getInstance().getFile(editor.document) ?: return@runReadAction null diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index 9e597b621..423e91951 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -119,8 +119,10 @@ fun makePanel( fun openInlineEdit(project: Project?, editor: Editor) { if (project == null) return + val editorUtils = EditorUtils(editor) + // Don't open in terminal - if (EditorUtils(editor).isTerminal()) { + if (editorUtils.isTerminal()) { return } @@ -148,34 +150,15 @@ fun openInlineEdit(project: Project?, editor: Editor) { Thread.sleep(20) } - // Get highlighted range - val selectionModel = editor.selectionModel - val startOffset = selectionModel.selectionStart - val endOffset = selectionModel.selectionEnd - val startLineNumber = editor.document.getLineNumber(startOffset) - var endLineNumber = editor.document.getLineNumber(endOffset) + val highlightedRIF = editorUtils.getHighlightedRIF() ?: return + val (startLineNumber, endLineNumber) = highlightedRIF.lines + val (highlightedStartOffset, highlightedEndOffset) = highlightedRIF.offsets - // Doesn't seem to be any built-in methods to check for a line selection that contains trailing - // newlines. - // The only case this matters is when a user double-clicks to highlight a full line. Without this - // check. - // the highlighted range will continue to the following line. - val isSingleLineSelection = - endLineNumber > startLineNumber && - endLineNumber < editor.document.lineCount && - editor.document.getLineStartOffset(endLineNumber) == endOffset - if (isSingleLineSelection) { - endLineNumber-- - } - - val prefix = editor.document.getText(TextRange(0, startOffset)) - val highlighted = editor.document.getText(TextRange(startOffset, endOffset)) - val suffix = editor.document.getText(TextRange(endOffset, editor.document.textLength)) + val (prefix, highlighted, suffix) = editorUtils.getHighlightedRangeTriplet() val lineNumber = if (startLineNumber == 0) 0 else max(0, startLineNumber - 1) - // Un-highlight the selected text - selectionModel.removeSelection() + editorUtils.removeSelection() // Get indentation width in pixels val indentationLineNum = if (startLineNumber == 0) 0 else lineNumber + 1 @@ -239,7 +222,7 @@ fun openInlineEdit(project: Project?, editor: Editor) { { onEnter() }, { diffStreamService.reject(editor) - selectionModel.setSelection(startOffset, endOffset) + editorUtils.editor.selectionModel.setSelection(highlightedStartOffset, highlightedEndOffset) }, { diffStreamService.accept(editor) @@ -270,7 +253,10 @@ fun openInlineEdit(project: Project?, editor: Editor) { when (e.keyCode) { KeyEvent.VK_ESCAPE -> { diffStreamService.reject(editor) - selectionModel.setSelection(startOffset, endOffset) + editorUtils.editor.selectionModel.setSelection( + highlightedStartOffset, + highlightedEndOffset + ) } KeyEvent.VK_ENTER -> { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/RangeInFileWithContents.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/RangeInFileWithContents.kt index 98d2041d0..61eacc6fc 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/RangeInFileWithContents.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/RangeInFileWithContents.kt @@ -12,22 +12,43 @@ import com.intellij.openapi.util.TextRange class RangeInFileWithContents( val filepath: String, val range: Range, - val contents: String + val contents: String, + val document: Document + ) { /** - * Returns the absolute document offset for the start position + * The absolute document offset for the start position */ - fun getStartOffset(document: Document): Int { - return document.getLineStartOffset(range.start.line) + range.start.character - } + val startOffset: Int + get() = document.getLineStartOffset(range.start.line) + range.start.character /** - * Returns the absolute document offset for the end position + * The absolute document offset for the end position */ - fun getEndOffset(document: Document): Int { - return document.getLineStartOffset(range.end.line) + range.end.character - } + val endOffset: Int + get() = document.getLineStartOffset(range.end.line) + range.end.character + /** + * The line number where the highlighted range starts (zero-based) + */ + val startLine: Int + get() = range.start.line + + /** + * The line number where the highlighted range ends (zero-based) + * This already accounts for proper line ending calculations. + */ + val endLine: Int + get() = range.end.line + + /** + * Both the start and end line numbers of the highlighted range as a pair + */ + val lines: Pair + get() = Pair(startLine, endLine) + + val offsets: Pair + get() = Pair(startOffset, endOffset) companion object { /** @@ -45,6 +66,13 @@ class RangeInFileWithContents( val startChar = selectionStart - document.getLineStartOffset(startLine) val endChar = selectionEnd - document.getLineStartOffset(endLine) + // Adjust end line if it's a single line selection with trailing newlines + val adjustedEndLine = if (isSelectionWithTrailingNewline(document, selectionStart, selectionEnd)) { + endLine - 1 + } else { + endLine + } + val selectedText = document.getText( TextRange(selectionStart, selectionEnd) ) @@ -53,10 +81,30 @@ class RangeInFileWithContents( filepath, Range( Position(startLine, startChar), - Position(endLine, endChar) + Position(adjustedEndLine, endChar) ), - selectedText + selectedText, + document ) } + + /** + * Checks if the selection spans to the next line only because of trailing newlines. + * This matters when a user double-clicks to highlight a full line. + * + * @return true if the selection is actually a single line selection with trailing newline + */ + fun isSelectionWithTrailingNewline( + document: Document, + selectionStart: Int, + selectionEnd: Int + ): Boolean { + val startLine = document.getLineNumber(selectionStart) + val endLine = document.getLineNumber(selectionEnd) + + return endLine > startLine && + endLine < document.lineCount && + document.getLineStartOffset(endLine) == selectionEnd + } } } \ No newline at end of file diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 09ee927d9..bdd37caf7 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.35", + "version": "1.1.36", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.35", + "version": "1.1.36", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", @@ -148,6 +148,7 @@ "p-limit": "^6.1.0", "partial-json": "^0.1.7", "pg": "^8.11.3", + "plist": "^3.1.0", "posthog-node": "^3.6.3", "puppeteer": "^22.4.0", "puppeteer-chromium-resolver": "^23.0.0", @@ -184,6 +185,7 @@ "@types/mustache": "^4.2.5", "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", + "@types/plist": "^3.0.5", "@types/request": "^2.48.12", "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", diff --git a/gui/package-lock.json b/gui/package-lock.json index 579d35a6a..8c95b8f38 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -152,6 +152,7 @@ "p-limit": "^6.1.0", "partial-json": "^0.1.7", "pg": "^8.11.3", + "plist": "^3.1.0", "posthog-node": "^3.6.3", "puppeteer": "^22.4.0", "puppeteer-chromium-resolver": "^23.0.0", @@ -188,6 +189,7 @@ "@types/mustache": "^4.2.5", "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", + "@types/plist": "^3.0.5", "@types/request": "^2.48.12", "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", From a21d350ea14a98cf16904ae678de64a83775da7c Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Tue, 20 May 2025 12:36:01 -0700 Subject: [PATCH 14/58] feat: markdown rules fix: parsing --- core/config/loadLocalAssistants.ts | 4 +- core/config/markdown/loadMarkdownRules.ts | 49 ++++++ .../config/markdown/parseMarkdownRule.test.ts | 154 ++++++++++++++++++ core/config/markdown/parseMarkdownRule.ts | 68 ++++++++ core/config/profile/doLoadConfig.ts | 7 + core/tools/implementations/createRuleBlock.ts | 45 +++-- 6 files changed, 315 insertions(+), 12 deletions(-) create mode 100644 core/config/markdown/loadMarkdownRules.ts create mode 100644 core/config/markdown/parseMarkdownRule.test.ts create mode 100644 core/config/markdown/parseMarkdownRule.ts diff --git a/core/config/loadLocalAssistants.ts b/core/config/loadLocalAssistants.ts index 18e24f58d..7f012e6db 100644 --- a/core/config/loadLocalAssistants.ts +++ b/core/config/loadLocalAssistants.ts @@ -13,7 +13,7 @@ export const ASSISTANTS = "assistants"; export const ASSISTANTS_FOLDER = `.continue/${ASSISTANTS}`; export function isLocalAssistantFile(uri: string): boolean { - if (!uri.endsWith(".yaml") && !uri.endsWith(".yml")) { + if (!uri.endsWith(".yaml") && !uri.endsWith(".yml") && !uri.endsWith(".md")) { return false; } @@ -41,7 +41,7 @@ export async function listYamlFilesInDir( source: "get assistant files", }); const assistantFilePaths = uris.filter( - (p) => p.endsWith(".yaml") || p.endsWith(".yml"), + (p) => p.endsWith(".yaml") || p.endsWith(".yml") || p.endsWith(".md"), ); const results = assistantFilePaths.map(async (uri) => { const content = await ide.readFile(uri); // make a try catch diff --git a/core/config/markdown/loadMarkdownRules.ts b/core/config/markdown/loadMarkdownRules.ts new file mode 100644 index 000000000..24cd0caac --- /dev/null +++ b/core/config/markdown/loadMarkdownRules.ts @@ -0,0 +1,49 @@ +import { IDE, RuleWithSource } from "../.."; +import { getAllDotContinueYamlFiles } from "../loadLocalAssistants"; +import { convertMarkdownRuleToContinueRule } from "./parseMarkdownRule"; +import { ConfigValidationError } from "@continuedev/config-yaml"; + +/** + * Loads rules from markdown files in the .continue/rules directory + */ +export async function loadMarkdownRules( + ide: IDE +): Promise<{ + rules: RuleWithSource[]; + errors: ConfigValidationError[]; +}> { + const errors: ConfigValidationError[] = []; + const rules: RuleWithSource[] = []; + + try { + // Get all .md files from .continue/rules + const markdownFiles = await getAllDotContinueYamlFiles( + ide, + { includeGlobal: true, includeWorkspace: true }, + "rules" + ); + + // Filter to just .md files + const mdFiles = markdownFiles.filter(file => file.path.endsWith('.md')); + + // Process each markdown file + for (const file of mdFiles) { + try { + const rule = convertMarkdownRuleToContinueRule(file.path, file.content); + rules.push(rule); + } catch (e) { + errors.push({ + fatal: false, + message: `Failed to parse markdown rule file ${file.path}: ${e instanceof Error ? e.message : e}` + }); + } + } + } catch (e) { + errors.push({ + fatal: false, + message: `Error loading markdown rule files: ${e instanceof Error ? e.message : e}` + }); + } + + return { rules, errors }; +} \ No newline at end of file diff --git a/core/config/markdown/parseMarkdownRule.test.ts b/core/config/markdown/parseMarkdownRule.test.ts new file mode 100644 index 000000000..a34f8814d --- /dev/null +++ b/core/config/markdown/parseMarkdownRule.test.ts @@ -0,0 +1,154 @@ +import { + convertMarkdownRuleToContinueRule, + parseMarkdownRule, +} from "./parseMarkdownRule"; + +describe("parseMarkdownRule", () => { + it("should correctly parse markdown with YAML frontmatter", () => { + const content = `--- +globs: "**/test/**/*.kt" +--- + +# Test Rule + +This is a test rule.`; + + const result = parseMarkdownRule(content); + expect(result.frontmatter).toEqual({ globs: "**/test/**/*.kt" }); + expect(result.markdown).toBe("# Test Rule\n\nThis is a test rule."); + }); + + it("should handle missing frontmatter", () => { + const content = `# Test Rule + +This is a test rule without frontmatter.`; + + const result = parseMarkdownRule(content); + expect(result.frontmatter).toEqual({}); + expect(result.markdown).toBe(content); + }); + + it("should handle empty frontmatter", () => { + const content = `--- +--- + +# Test Rule + +This is a test rule with empty frontmatter.`; + + const result = parseMarkdownRule(content); + + // Log exact strings for debugging + console.log("Actual:", JSON.stringify(result.markdown)); + console.log( + "Expected:", + JSON.stringify( + "# Test Rule\n\nThis is a test rule with empty frontmatter.", + ), + ); + + expect(result.frontmatter).toEqual({}); + expect(result.markdown).toBe( + "# Test Rule\n\nThis is a test rule with empty frontmatter.", + ); + }); + + it("should handle frontmatter with whitespace", () => { + const content = `--- +globs: "**/test/**/*.kt" +--- + +# Test Rule + +This is a test rule.`; + + const result = parseMarkdownRule(content); + expect(result.frontmatter).toEqual({ globs: "**/test/**/*.kt" }); + expect(result.markdown).toBe("# Test Rule\n\nThis is a test rule."); + }); + + it("should handle Windows line endings (CRLF)", () => { + // Using \r\n for CRLF line endings + const content = `---\r +globs: "**/test/**/*.kt"\r +---\r +\r +# Test Rule\r +\r +This is a test rule.`; + + const result = parseMarkdownRule(content); + expect(result.frontmatter).toEqual({ globs: "**/test/**/*.kt" }); + // The result should be normalized to \n + expect(result.markdown).toBe("# Test Rule\n\nThis is a test rule."); + }); + + it("should handle malformed frontmatter", () => { + const content = `--- +globs: - "**/test/**/*.kt" +invalid: yaml: content +--- + +# Test Rule + +This is a test rule.`; + + // Should treat as only markdown when frontmatter is malformed + const result = parseMarkdownRule(content); + expect(result.frontmatter).toEqual({}); + expect(result.markdown).toBe(content); + }); +}); + +describe("convertMarkdownRuleToContinueRule", () => { + it("should convert markdown with frontmatter to a rule", () => { + const content = `--- +globs: "**/test/**/*.kt" +name: Custom Name +--- + +# Test Rule + +This is a test rule.`; + + const result = convertMarkdownRuleToContinueRule( + "/path/to/rule.md", + content, + ); + expect(result.rule).toBe("# Test Rule\n\nThis is a test rule."); + expect(result.globs).toBe("**/test/**/*.kt"); + expect(result.name).toBe("Custom Name"); + expect(result.source).toBe("rules-block"); + expect(result.ruleFile).toBe("/path/to/rule.md"); + }); + + it("should use the first heading as name if not in frontmatter", () => { + const content = `--- +globs: "**/test/**/*.kt" +--- + +# Test Rule Title + +This is a test rule.`; + + const result = convertMarkdownRuleToContinueRule( + "/path/to/rule.md", + content, + ); + expect(result.name).toBe("Test Rule Title"); + }); + + it("should use filename as name if no heading or frontmatter name", () => { + const content = `--- +globs: "**/test/**/*.kt" +--- + +This is a test rule without a heading.`; + + const result = convertMarkdownRuleToContinueRule( + "/path/to/custom-rule.md", + content, + ); + expect(result.name).toBe("custom-rule"); + }); +}); diff --git a/core/config/markdown/parseMarkdownRule.ts b/core/config/markdown/parseMarkdownRule.ts new file mode 100644 index 000000000..a876bced2 --- /dev/null +++ b/core/config/markdown/parseMarkdownRule.ts @@ -0,0 +1,68 @@ +import { basename } from "path"; +import * as YAML from "yaml"; +import { RuleWithSource } from "../.."; + +/** + * Parses markdown content with YAML frontmatter + */ +export function parseMarkdownRule(content: string): { + frontmatter: Record; + markdown: string; +} { + // Normalize line endings to \n + const normalizedContent = content.replace(/\r\n/g, "\n"); + + // More reliable frontmatter detection + const parts = normalizedContent.split(/^---\s*$/m); + + // If we have at least 3 parts (before ---, frontmatter, after ---), we have frontmatter + if (parts.length >= 3) { + const frontmatterStr = parts[1]; + // Join the remaining parts back together (in case there are more --- in the markdown) + const markdownContent = parts.slice(2).join("---"); + + try { + // Parse YAML frontmatter + const frontmatter = YAML.parse(frontmatterStr) || {}; // Handle empty frontmatter + return { frontmatter, markdown: markdownContent.trim() }; + } catch (e) { + // Error parsing frontmatter, treat as markdown only + console.warn("Error parsing markdown frontmatter:", e); + return { frontmatter: {}, markdown: normalizedContent }; + } + } + + // No frontmatter found + return { frontmatter: {}, markdown: normalizedContent }; +} + +/** + * Converts a markdown file with YAML frontmatter to a RuleWithSource object + */ +export function convertMarkdownRuleToContinueRule( + path: string, + content: string, +): RuleWithSource { + const { frontmatter, markdown } = parseMarkdownRule(content); + + // Try to extract title from first heading if no name in frontmatter + let name = frontmatter.name; + if (!name) { + // Look for a heading in the markdown + const headingMatch = markdown.match(/^#\s+(.+)$/m); + if (headingMatch) { + name = headingMatch[1].trim(); + } else { + // Fall back to filename + name = basename(path).replace(/\.md$/, ""); + } + } + + return { + rule: markdown, + globs: frontmatter.globs, + name, + source: "rules-block", + ruleFile: path, + }; +} diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 1308ca2a0..cc1b98e49 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -32,6 +32,7 @@ import { Telemetry } from "../../util/posthog"; import { TTS } from "../../util/tts"; import { getWorkspaceContinueRuleDotFiles } from "../getWorkspaceContinueRuleDotFiles"; import { loadContinueConfigFromJson } from "../load"; +import { loadMarkdownRules } from "../markdown/loadMarkdownRules"; import { migrateJsonSharedConfig } from "../migrateSharedConfig"; import { rectifySelectedModelsFromGlobalContext } from "../selectedModels"; import { loadContinueConfigFromYaml } from "../yaml/loadYaml"; @@ -128,6 +129,12 @@ export default async function doLoadConfig(options: { newConfig.rules.unshift(...rules); errors.push(...continueRulesErrors); + // Add rules from markdown files in .continue/rules + const { rules: markdownRules, errors: markdownRulesErrors } = + await loadMarkdownRules(ide); + newConfig.rules.unshift(...markdownRules); + errors.push(...markdownRulesErrors); + // Rectify model selections for each role newConfig = rectifySelectedModelsFromGlobalContext(newConfig, profileId); diff --git a/core/tools/implementations/createRuleBlock.ts b/core/tools/implementations/createRuleBlock.ts index 87702e866..ea2514709 100644 --- a/core/tools/implementations/createRuleBlock.ts +++ b/core/tools/implementations/createRuleBlock.ts @@ -7,6 +7,7 @@ export interface CreateRuleBlockArgs { name: string; rule: string; globs?: string; + format?: "yaml" | "markdown"; // Add format option with yaml as default } export const createRuleBlockImpl: ToolImpl = async ( @@ -19,30 +20,54 @@ export const createRuleBlockImpl: ToolImpl = async ( .replace(/[^a-z0-9\s-]/g, "") .replace(/\s+/g, "-"); + // Default to YAML format + const format = args.format ?? "yaml"; + const fileExtension = format === "markdown" ? "md" : "yaml"; + const ruleObject = { name: args.name, rule: args.rule, ...(args.globs ? { globs: args.globs.trim() } : {}), }; - const ruleBlock: ConfigYaml = { - name: args.name, - version: "0.0.1", - schema: "v1", - rules: [ruleObject], - }; + let fileContent: string; - const ruleYaml = YAML.stringify(ruleBlock); + if (format === "markdown") { + // Generate markdown format with frontmatter + const frontmatter = { + ...(args.globs ? { globs: args.globs.trim() } : {}), + }; + + const frontmatterYaml = YAML.stringify(frontmatter).trim(); + fileContent = `--- +${frontmatterYaml} +--- + +# ${args.name} + +${args.rule} +`; + } else { + // Generate YAML format + const ruleBlock: ConfigYaml = { + name: args.name, + version: "0.0.1", + schema: "v1", + rules: [ruleObject], + }; + + fileContent = YAML.stringify(ruleBlock); + } const [localContinueDir] = await extras.ide.getWorkspaceDirs(); const rulesDirUri = joinPathsToUri( localContinueDir, ".continue", "rules", - `${safeRuleName}.yaml`, + `${safeRuleName}.${fileExtension}`, ); - await extras.ide.writeFile(rulesDirUri, ruleYaml); + await extras.ide.writeFile(rulesDirUri, fileContent); await extras.ide.openFile(rulesDirUri); return [ @@ -53,7 +78,7 @@ export const createRuleBlockImpl: ToolImpl = async ( type: "file", value: rulesDirUri, }, - content: "Rule created successfully", + content: `Rule created successfully in ${format} format`, }, ]; }; From ba3984290ddb875608845904d31c5a5d57b1bf03 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Tue, 20 May 2025 13:24:33 -0700 Subject: [PATCH 15/58] fix: naming --- core/config/ConfigHandler.ts | 4 ++-- core/config/loadLocalAssistants.ts | 6 +++--- core/config/markdown/loadMarkdownRules.ts | 22 ++++++++++------------ core/config/yaml/loadYaml.ts | 4 ++-- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index deae7da38..0d4d81b30 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -19,7 +19,7 @@ import { getControlPlaneEnv } from "../control-plane/env.js"; import { logger } from "../util/logger.js"; import { ASSISTANTS, - getAllDotContinueYamlFiles, + getAllDotContinueDefinitionFiles, LoadAssistantFilesOptions, } from "./loadLocalAssistants.js"; import LocalProfileLoader from "./profile/LocalProfileLoader.js"; @@ -284,7 +284,7 @@ export class ConfigHandler { } if (options.includeWorkspace) { - const assistantFiles = await getAllDotContinueYamlFiles( + const assistantFiles = await getAllDotContinueDefinitionFiles( this.ide, options, ASSISTANTS, diff --git a/core/config/loadLocalAssistants.ts b/core/config/loadLocalAssistants.ts index 7f012e6db..90c5922a2 100644 --- a/core/config/loadLocalAssistants.ts +++ b/core/config/loadLocalAssistants.ts @@ -21,7 +21,7 @@ export function isLocalAssistantFile(uri: string): boolean { return normalizedUri.includes(`/${ASSISTANTS_FOLDER}/`); } -export async function listYamlFilesInDir( +async function getDefinitionFilesInDir( ide: IDE, dir: string, ): Promise<{ path: string; content: string }[]> { @@ -86,7 +86,7 @@ export function getDotContinueSubDirs( * This method searches in both ~/.continue and workspace .continue * for all YAML files in the specified subdirctory, for example .continue/assistants or .continue/prompts */ -export async function getAllDotContinueYamlFiles( +export async function getAllDotContinueDefinitionFiles( ide: IDE, options: LoadAssistantFilesOptions, subDirName: string, @@ -103,7 +103,7 @@ export async function getAllDotContinueYamlFiles( // Get all assistant files from the directories const assistantFiles = ( - await Promise.all(fullDirs.map((dir) => listYamlFilesInDir(ide, dir))) + await Promise.all(fullDirs.map((dir) => getDefinitionFilesInDir(ide, dir))) ).flat(); return await Promise.all( diff --git a/core/config/markdown/loadMarkdownRules.ts b/core/config/markdown/loadMarkdownRules.ts index 24cd0caac..b0bbb8005 100644 --- a/core/config/markdown/loadMarkdownRules.ts +++ b/core/config/markdown/loadMarkdownRules.ts @@ -1,14 +1,12 @@ -import { IDE, RuleWithSource } from "../.."; -import { getAllDotContinueYamlFiles } from "../loadLocalAssistants"; -import { convertMarkdownRuleToContinueRule } from "./parseMarkdownRule"; import { ConfigValidationError } from "@continuedev/config-yaml"; +import { IDE, RuleWithSource } from "../.."; +import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; +import { convertMarkdownRuleToContinueRule } from "./parseMarkdownRule"; /** * Loads rules from markdown files in the .continue/rules directory */ -export async function loadMarkdownRules( - ide: IDE -): Promise<{ +export async function loadMarkdownRules(ide: IDE): Promise<{ rules: RuleWithSource[]; errors: ConfigValidationError[]; }> { @@ -17,14 +15,14 @@ export async function loadMarkdownRules( try { // Get all .md files from .continue/rules - const markdownFiles = await getAllDotContinueYamlFiles( + const markdownFiles = await getAllDotContinueDefinitionFiles( ide, { includeGlobal: true, includeWorkspace: true }, - "rules" + "rules", ); // Filter to just .md files - const mdFiles = markdownFiles.filter(file => file.path.endsWith('.md')); + const mdFiles = markdownFiles.filter((file) => file.path.endsWith(".md")); // Process each markdown file for (const file of mdFiles) { @@ -34,16 +32,16 @@ export async function loadMarkdownRules( } catch (e) { errors.push({ fatal: false, - message: `Failed to parse markdown rule file ${file.path}: ${e instanceof Error ? e.message : e}` + message: `Failed to parse markdown rule file ${file.path}: ${e instanceof Error ? e.message : e}`, }); } } } catch (e) { errors.push({ fatal: false, - message: `Error loading markdown rule files: ${e instanceof Error ? e.message : e}` + message: `Error loading markdown rule files: ${e instanceof Error ? e.message : e}`, }); } return { rules, errors }; -} \ No newline at end of file +} diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 8c926faab..7c18aec00 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -42,7 +42,7 @@ import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; import { getControlPlaneEnvSync } from "../../control-plane/env"; import { getCleanUriPath } from "../../util/uri"; -import { getAllDotContinueYamlFiles } from "../loadLocalAssistants"; +import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; import { LocalPlatformClient } from "./LocalPlatformClient"; import { llmsFromModelConfig } from "./models"; @@ -96,7 +96,7 @@ async function loadConfigYaml(options: { // Add local .continue blocks const allLocalBlocks: PackageIdentifier[] = []; for (const blockType of BLOCK_TYPES) { - const localBlocks = await getAllDotContinueYamlFiles( + const localBlocks = await getAllDotContinueDefinitionFiles( ide, { includeGlobal: true, includeWorkspace: true }, blockType, From 16cbe9499431d7eec64d0695821a223302d980cb Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 13:52:22 -0700 Subject: [PATCH 16/58] feat: promote reject diff action --- .../actions/ContinueActionPromote.kt | 23 ++-- .../actions/ContinuePluginActions.kt | 60 ++++------ .../actions/utils.kt | 39 +++++++ .../editor/DiffStreamHandler.kt | 1 - ...InlineEditAction.kt => InlineEditPanel.kt} | 110 +++++++++--------- .../src/main/resources/META-INF/plugin.xml | 6 +- 6 files changed, 138 insertions(+), 101 deletions(-) create mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/utils.kt rename extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/{InlineEditAction.kt => InlineEditPanel.kt} (92%) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt index ae26033e5..503f680a8 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt @@ -11,15 +11,24 @@ import org.jetbrains.annotations.NotNull class ContinueActionPromote : ActionPromoter { override fun promote(@NotNull actions: List, @NotNull context: DataContext): List? { - - if (actions.none { it is AcceptAutocompleteAction }) { - return null - } else { + // For autocomplete actions + if (actions.any { it is AcceptAutocompleteAction }) { val settings = ServiceManager.getService(ContinueExtensionSettings::class.java) - if (!settings.continueState.showIDECompletionSideBySide) { - return null; + if (settings.continueState.showIDECompletionSideBySide) { + return actions.filterIsInstance() } - return actions.filterIsInstance() } + + // For RejectDiffAction + val rejectDiffActions = actions.filter { action -> + action.javaClass.name.contains("RejectDiffAction") || + (action.toString().contains("continue.rejectDiff")) + } + + if (rejectDiffActions.isNotEmpty()) { + return rejectDiffActions + } + + return null } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt index 27e4aebe2..b629a21e1 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt @@ -1,25 +1,15 @@ package com.github.continuedev.continueintellijextension.actions import com.github.continuedev.continueintellijextension.editor.DiffStreamService -import com.github.continuedev.continueintellijextension.services.ContinuePluginService +import com.github.continuedev.continueintellijextension.editor.openInlineEdit +import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.PlatformDataKeys -import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.components.service import com.intellij.openapi.fileEditor.FileEditorManager -import com.intellij.openapi.project.Project -import com.intellij.openapi.wm.ToolWindowManager +import com.intellij.openapi.project.DumbAware -fun getPluginService(project: Project?): ContinuePluginService? { - if (project == null) { - return null - } - return ServiceManager.getService( - project, - ContinuePluginService::class.java - ) -} class AcceptDiffAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { @@ -29,7 +19,7 @@ class AcceptDiffAction : AnAction() { private fun acceptHorizontalDiff(e: AnActionEvent) { val continuePluginService = getPluginService(e.project) ?: return - continuePluginService?.diffManager?.acceptDiff(null) + continuePluginService.diffManager?.acceptDiff(null) } private fun acceptVerticalDiff(e: AnActionEvent) { @@ -61,28 +51,6 @@ class RejectDiffAction : AnAction() { } } -fun getContinuePluginService(project: Project?): ContinuePluginService? { - if (project != null) { - val toolWindowManager = ToolWindowManager.getInstance(project) - val toolWindow = toolWindowManager.getToolWindow("Continue") - - if (toolWindow != null) { - if (!toolWindow.isVisible) { - toolWindow.activate(null) - } - } - } - - return getPluginService(project) -} - -fun focusContinueInput(project: Project?) { - val continuePluginService = getContinuePluginService(project) ?: return - continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus() - continuePluginService.sendToWebview("focusContinueInputWithoutClear", null) - - continuePluginService.ideProtocolClient?.sendHighlightedCode() -} class FocusContinueInputWithoutClearAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { @@ -134,8 +102,26 @@ class OpenLogsAction : AnAction() { if (logFile.exists()) { val virtualFile = com.intellij.openapi.vfs.LocalFileSystem.getInstance().findFileByIoFile(logFile) if (virtualFile != null) { - com.intellij.openapi.fileEditor.FileEditorManager.getInstance(project).openFile(virtualFile, true) + FileEditorManager.getInstance(project).openFile(virtualFile, true) } } } } + +class InlineEditAction : AnAction(), DumbAware { + override fun update(e: AnActionEvent) { + e.presentation.isEnabled = true + e.presentation.isVisible = true + } + + override fun getActionUpdateThread(): ActionUpdateThread { + return ActionUpdateThread.EDT + } + + override fun actionPerformed(e: AnActionEvent) { + val editor = e.getData(PlatformDataKeys.EDITOR) ?: return + val project = e.getData(PlatformDataKeys.PROJECT) ?: return + openInlineEdit(project, editor) + } +} + diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/utils.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/utils.kt new file mode 100644 index 000000000..1bd31c463 --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/utils.kt @@ -0,0 +1,39 @@ +package com.github.continuedev.continueintellijextension.actions + +import com.github.continuedev.continueintellijextension.services.ContinuePluginService +import com.intellij.openapi.components.ServiceManager +import com.intellij.openapi.project.Project +import com.intellij.openapi.wm.ToolWindowManager + +fun getContinuePluginService(project: Project?): ContinuePluginService? { + if (project != null) { + val toolWindowManager = ToolWindowManager.getInstance(project) + val toolWindow = toolWindowManager.getToolWindow("Continue") + + if (toolWindow != null) { + if (!toolWindow.isVisible) { + toolWindow.activate(null) + } + } + } + + return getPluginService(project) +} + +fun focusContinueInput(project: Project?) { + val continuePluginService = getContinuePluginService(project) ?: return + continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus() + continuePluginService.sendToWebview("focusContinueInputWithoutClear", null) + + continuePluginService.ideProtocolClient?.sendHighlightedCode() +} + +fun getPluginService(project: Project?): ContinuePluginService? { + if (project == null) { + return null + } + return ServiceManager.getService( + project, + ContinuePluginService::class.java + ) +} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index b4c9d14ca..5593ebba6 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -337,6 +337,5 @@ class DiffStreamHandler( private fun setClosed() { sendUpdate(ApplyStateStatus.CLOSED) resetState() - onClose() } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt similarity index 92% rename from extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt rename to extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt index 423e91951..39e5cec6b 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt @@ -7,16 +7,11 @@ import com.github.continuedev.continueintellijextension.utils.castNestedOrNull import com.github.continuedev.continueintellijextension.utils.getMetaKeyLabel import com.github.continuedev.continueintellijextension.utils.getShiftKeyLabel import com.intellij.openapi.Disposable -import com.intellij.openapi.actionSystem.ActionUpdateThread -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.components.service import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.editor.colors.EditorFontType import com.intellij.openapi.editor.impl.EditorImpl -import com.intellij.openapi.project.DumbAware import com.intellij.openapi.project.Project import com.intellij.openapi.util.IconLoader import com.intellij.openapi.util.Ref @@ -40,8 +35,45 @@ import org.jdesktop.swingx.JXPanel import org.jdesktop.swingx.JXTextArea const val MAIN_FONT_SIZE = 13 - const val DOWN_ARROW = " ▾" +const val MAX_MODEL_WAIT_TIME = 1500 + +/** + * Fetches and combines available model titles from both "edit" and "chat" roles. + * Edit models are prioritized and appear first in the returned list. + * Handles duplicate models by only including them once (prioritizing edit role). + * + * @param continuePluginService The service used to fetch config information + * @return List of model titles with edit models first, duplicates removed + * @throws No exceptions, but will return empty list if request fails or times out after 1.5 seconds + */ +fun getModelTitles(continuePluginService: ContinuePluginService): List { + val modelTitles = mutableListOf() + + continuePluginService.coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response -> + val modelsByRole = + response.castNestedOrNull>("content", "result", "config", "modelsByRole") ?: return@request + + // Get edit models first + val editModels = modelsByRole.castNestedOrNull>("edit") + ?.mapNotNull { it.castNestedOrNull("title") } ?: emptyList() + + // Then get chat models + val chatModels = modelsByRole.castNestedOrNull>("chat") + ?.mapNotNull { it.castNestedOrNull("title") } ?: emptyList() + + // Add edit models first, then chat models (avoiding duplicates) + modelTitles.addAll(editModels) + modelTitles.addAll(chatModels.filter { it !in editModels }) + } + + val startTime = System.currentTimeMillis() + while (modelTitles.isEmpty() && System.currentTimeMillis() - startTime < MAX_MODEL_WAIT_TIME) { + Thread.sleep(20) + } + + return modelTitles +} fun makeTextArea(): JTextArea { val textArea = @@ -128,27 +160,8 @@ fun openInlineEdit(project: Project?, editor: Editor) { val manager = EditorComponentInlaysManager.from(editor, true) - // Get list of model titles val continuePluginService = project.service() - val modelTitles = mutableListOf() - - continuePluginService.coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response -> - val modelsByRole = - response.castNestedOrNull>("content", "result", "config", "modelsByRole") ?: return@request - val role = if (modelsByRole.containsKey("edit")) "edit" else "chat" - modelsByRole.castNestedOrNull>(role) - ?.mapNotNull { it.castNestedOrNull("title") } - ?.let(modelTitles::addAll) - } - - // This is a hacky way to not complicate getting model titles with coroutines - // 1500 feels like way upper limit of "would be weird if panel showed up after that long" - // And should always allow enough time to load config - val maxWaitTime = 1500 - val startTime = System.currentTimeMillis() - while (modelTitles.isEmpty() && System.currentTimeMillis() - startTime < maxWaitTime) { - Thread.sleep(20) - } + val modelTitles = getModelTitles(continuePluginService) val highlightedRIF = editorUtils.getHighlightedRIF() ?: return val (startLineNumber, endLineNumber) = highlightedRIF.lines @@ -271,18 +284,29 @@ fun openInlineEdit(project: Project?, editor: Editor) { } } } + +// KeyEvent.VK_DELETE, KeyEvent.VK_BACK_SPACE -> { // Add this section +// if ((e.modifiersEx and KeyEvent.META_DOWN_MASK) != 0 && +// (e.modifiersEx and KeyEvent.SHIFT_DOWN_MASK) != 0 +// ) { +// diffStreamService.reject(editor) +// inlayRef.get().dispose() +// e.consume() +// } +// } } } + // TODO: Uncomment, this isnt the problem // We need this because backspace/delete is not registering properly on keyPressed for an // unknown reason - override fun keyReleased(e: KeyEvent) { - if (e.keyCode == KeyEvent.VK_BACK_SPACE || e.keyCode == KeyEvent.VK_DELETE) { - if (customPanelRef.get().isFinished) { - customPanelRef.get().setup() - } - } - } +// override fun keyReleased(e: KeyEvent) { +// if (e.keyCode == KeyEvent.VK_BACK_SPACE || e.keyCode == KeyEvent.VK_DELETE) { +// if (customPanelRef.get().isFinished) { +// customPanelRef.get().setup() +// } +// } +// } }) // Listen for changes to textarea line count @@ -314,26 +338,6 @@ fun openInlineEdit(project: Project?, editor: Editor) { textArea.requestFocus() } -/** - * Adapted from - * https://github.com/cursive-ide/component-inlay-example/blob/master/src/main/kotlin/inlays/InlineEditAction.kt - */ -class InlineEditAction : AnAction(), DumbAware { - override fun update(e: AnActionEvent) { - e.presentation.isEnabled = true - e.presentation.isVisible = true - } - - override fun getActionUpdateThread(): ActionUpdateThread { - return ActionUpdateThread.EDT - } - - override fun actionPerformed(e: AnActionEvent) { - val editor = e.getData(PlatformDataKeys.EDITOR) ?: return - val project = e.getData(PlatformDataKeys.PROJECT) ?: return - openInlineEdit(project, editor) - } -} class CustomPanel( layout: MigLayout, diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index 0e856be4c..7f9fa1bff 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -53,7 +53,7 @@ - @@ -78,9 +78,9 @@ class="com.github.continuedev.continueintellijextension.actions.RejectDiffAction" text="Reject Diff" description="Reject Diff"> + first-keystroke="shift ctrl BACK_SPACE"/> + first-keystroke="shift meta BACK_SPACE"/> From cd97833be88ecaf3c2860dc41ca57c9e2b18ad48 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 15:15:22 -0700 Subject: [PATCH 17/58] fix: remove stale code --- .../actions/ContinueActionPromote.kt | 8 +---- .../actions/ContinuePluginActions.kt | 22 ++++++++++++++ .../autocomplete/AcceptAutocompleteAction.kt | 15 ---------- .../autocomplete/AutocompleteActionGroup.kt | 29 ------------------- .../src/main/resources/META-INF/plugin.xml | 18 ++++++------ manual-testing-sandbox/test.ts | 2 ++ 6 files changed, 34 insertions(+), 60 deletions(-) delete mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteActionGroup.kt diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt index 503f680a8..e38be2130 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt @@ -1,6 +1,5 @@ package com.github.continuedev.continueintellijextension.actions -import com.github.continuedev.continueintellijextension.autocomplete.AcceptAutocompleteAction import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.intellij.openapi.actionSystem.ActionPromoter import com.intellij.openapi.actionSystem.AnAction @@ -19,12 +18,7 @@ class ContinueActionPromote : ActionPromoter { } } - // For RejectDiffAction - val rejectDiffActions = actions.filter { action -> - action.javaClass.name.contains("RejectDiffAction") || - (action.toString().contains("continue.rejectDiff")) - } - + val rejectDiffActions = actions.filterIsInstance() if (rejectDiffActions.isNotEmpty()) { return rejectDiffActions } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt index b629a21e1..17a1c162a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt @@ -1,12 +1,19 @@ package com.github.continuedev.continueintellijextension.actions +import com.github.continuedev.continueintellijextension.autocomplete.AutocompleteService import com.github.continuedev.continueintellijextension.editor.DiffStreamService import com.github.continuedev.continueintellijextension.editor.openInlineEdit import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.DataContext import com.intellij.openapi.actionSystem.PlatformDataKeys +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.service +import com.intellij.openapi.editor.Caret +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.editor.actionSystem.EditorAction +import com.intellij.openapi.editor.actionSystem.EditorActionHandler import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.project.DumbAware @@ -125,3 +132,18 @@ class InlineEditAction : AnAction(), DumbAware { } } +class AcceptAutocompleteAction : EditorAction(object : EditorActionHandler() { + override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) { + ApplicationManager.getApplication().runWriteAction { + editor.project?.service()?.accept() + } + } + + override fun isEnabledForCaret(editor: Editor, caret: Caret, dataContext: DataContext?): Boolean { + val autocompleteService = editor.project?.service(); + val enabled = editor == autocompleteService?.pendingCompletion?.editor +// && caret.offset == autocompleteService.pendingCompletion?.offset + && autocompleteService.pendingCompletion?.text != null + return enabled + } +}) \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt index 03b91e87c..05fbb88f7 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt @@ -8,18 +8,3 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.actionSystem.EditorAction import com.intellij.openapi.editor.actionSystem.EditorActionHandler -class AcceptAutocompleteAction : EditorAction(object : EditorActionHandler() { - override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) { - ApplicationManager.getApplication().runWriteAction { - editor.project?.service()?.accept() - } - } - - override fun isEnabledForCaret(editor: Editor, caret: Caret, dataContext: DataContext?): Boolean { - val autocompleteService = editor.project?.service(); - val enabled = editor == autocompleteService?.pendingCompletion?.editor -// && caret.offset == autocompleteService.pendingCompletion?.offset - && autocompleteService.pendingCompletion?.text != null - return enabled - } -}) \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteActionGroup.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteActionGroup.kt deleted file mode 100644 index 75f0d3aff..000000000 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteActionGroup.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.github.continuedev.continueintellijextension.autocomplete - -import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings -import com.intellij.openapi.actionSystem.ActionUpdateThread -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.DefaultActionGroup -import com.intellij.openapi.components.service - -class AutocompleteActionGroup : DefaultActionGroup() { - override fun getActionUpdateThread(): ActionUpdateThread { - return ActionUpdateThread.EDT - } - - override fun update(e: AnActionEvent) { - super.update(e) - removeAll() - - val continueSettingsService = service() - if (continueSettingsService.continueState.enableTabAutocomplete) { - addAll( - DisableTabAutocompleteAction(), - ) - } else { - addAll( - EnableTabAutocompleteAction(), - ) - } - } -} \ No newline at end of file diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index 7f9fa1bff..b22385382 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -18,7 +18,7 @@ + implementation="com.github.continuedev.continueintellijextension.actions.AutocompleteEditorListener"/> + serviceImplementation="com.github.continuedev.continueintellijextension.actions.AutocompleteLookupListener"/> @@ -166,21 +166,21 @@ - - - diff --git a/manual-testing-sandbox/test.ts b/manual-testing-sandbox/test.ts index 9cf524421..317fa4d13 100644 --- a/manual-testing-sandbox/test.ts +++ b/manual-testing-sandbox/test.ts @@ -10,6 +10,8 @@ class Calculator { return this; } + + subtract(number: number): Calculator { this.result -= number; return this; From 93efac09686abf385dc46dc60acb79e347855b86 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 15:16:23 -0700 Subject: [PATCH 18/58] Delete AcceptAutocompleteAction.kt --- .../autocomplete/AcceptAutocompleteAction.kt | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt deleted file mode 100644 index 05fbb88f7..000000000 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.github.continuedev.continueintellijextension.autocomplete - -import com.intellij.openapi.actionSystem.DataContext -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.service -import com.intellij.openapi.editor.Caret -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.actionSystem.EditorAction -import com.intellij.openapi.editor.actionSystem.EditorActionHandler - From de26681c9c4a5782f0848153e7eca776929bc157 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 20 May 2025 16:15:57 -0700 Subject: [PATCH 19/58] bump --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 3772dd79d..2657b6258 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.37", + "version": "1.1.38", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 7a44a38c860cfbd0eeab35d8fdb3cb198edad680 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 16:42:05 -0700 Subject: [PATCH 20/58] fix: revert file changes --- .../actions/ContinueActionPromote.kt | 1 + .../actions/ContinuePluginActions.kt | 30 ------------------- .../autocomplete/AcceptAutocompleteAction.kt | 25 ++++++++++++++++ .../editor/InlineEditAction.kt | 24 +++++++++++++++ .../editor/InlineEditPanel.kt | 25 +++++----------- .../src/main/resources/META-INF/plugin.xml | 18 +++++------ manual-testing-sandbox/test.ts | 4 +-- 7 files changed, 67 insertions(+), 60 deletions(-) create mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt create mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt index e38be2130..8c046c342 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinueActionPromote.kt @@ -1,5 +1,6 @@ package com.github.continuedev.continueintellijextension.actions +import com.github.continuedev.continueintellijextension.autocomplete.AcceptAutocompleteAction import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.intellij.openapi.actionSystem.ActionPromoter import com.intellij.openapi.actionSystem.AnAction diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt index 17a1c162a..81fbc89b9 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt @@ -115,35 +115,5 @@ class OpenLogsAction : AnAction() { } } -class InlineEditAction : AnAction(), DumbAware { - override fun update(e: AnActionEvent) { - e.presentation.isEnabled = true - e.presentation.isVisible = true - } - override fun getActionUpdateThread(): ActionUpdateThread { - return ActionUpdateThread.EDT - } - override fun actionPerformed(e: AnActionEvent) { - val editor = e.getData(PlatformDataKeys.EDITOR) ?: return - val project = e.getData(PlatformDataKeys.PROJECT) ?: return - openInlineEdit(project, editor) - } -} - -class AcceptAutocompleteAction : EditorAction(object : EditorActionHandler() { - override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) { - ApplicationManager.getApplication().runWriteAction { - editor.project?.service()?.accept() - } - } - - override fun isEnabledForCaret(editor: Editor, caret: Caret, dataContext: DataContext?): Boolean { - val autocompleteService = editor.project?.service(); - val enabled = editor == autocompleteService?.pendingCompletion?.editor -// && caret.offset == autocompleteService.pendingCompletion?.offset - && autocompleteService.pendingCompletion?.text != null - return enabled - } -}) \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt new file mode 100644 index 000000000..03b91e87c --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt @@ -0,0 +1,25 @@ +package com.github.continuedev.continueintellijextension.autocomplete + +import com.intellij.openapi.actionSystem.DataContext +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.components.service +import com.intellij.openapi.editor.Caret +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.editor.actionSystem.EditorAction +import com.intellij.openapi.editor.actionSystem.EditorActionHandler + +class AcceptAutocompleteAction : EditorAction(object : EditorActionHandler() { + override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) { + ApplicationManager.getApplication().runWriteAction { + editor.project?.service()?.accept() + } + } + + override fun isEnabledForCaret(editor: Editor, caret: Caret, dataContext: DataContext?): Boolean { + val autocompleteService = editor.project?.service(); + val enabled = editor == autocompleteService?.pendingCompletion?.editor +// && caret.offset == autocompleteService.pendingCompletion?.offset + && autocompleteService.pendingCompletion?.text != null + return enabled + } +}) \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt new file mode 100644 index 000000000..4caac4ffd --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -0,0 +1,24 @@ +package com.github.continuedev.continueintellijextension.editor + +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.PlatformDataKeys +import com.intellij.openapi.project.DumbAware + +class InlineEditAction : AnAction(), DumbAware { + override fun update(e: AnActionEvent) { + e.presentation.isEnabled = true + e.presentation.isVisible = true + } + + override fun getActionUpdateThread(): ActionUpdateThread { + return ActionUpdateThread.EDT + } + + override fun actionPerformed(e: AnActionEvent) { + val editor = e.getData(PlatformDataKeys.EDITOR) ?: return + val project = e.getData(PlatformDataKeys.PROJECT) ?: return + openInlineEdit(project, editor) + } +} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt index 39e5cec6b..028f3f185 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt @@ -284,29 +284,18 @@ fun openInlineEdit(project: Project?, editor: Editor) { } } } - -// KeyEvent.VK_DELETE, KeyEvent.VK_BACK_SPACE -> { // Add this section -// if ((e.modifiersEx and KeyEvent.META_DOWN_MASK) != 0 && -// (e.modifiersEx and KeyEvent.SHIFT_DOWN_MASK) != 0 -// ) { -// diffStreamService.reject(editor) -// inlayRef.get().dispose() -// e.consume() -// } -// } } } - // TODO: Uncomment, this isnt the problem // We need this because backspace/delete is not registering properly on keyPressed for an // unknown reason -// override fun keyReleased(e: KeyEvent) { -// if (e.keyCode == KeyEvent.VK_BACK_SPACE || e.keyCode == KeyEvent.VK_DELETE) { -// if (customPanelRef.get().isFinished) { -// customPanelRef.get().setup() -// } -// } -// } + override fun keyReleased(e: KeyEvent) { + if (e.keyCode == KeyEvent.VK_BACK_SPACE || e.keyCode == KeyEvent.VK_DELETE) { + if (customPanelRef.get().isFinished) { + customPanelRef.get().setup() + } + } + } }) // Listen for changes to textarea line count diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index b22385382..7f9fa1bff 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -18,7 +18,7 @@ + implementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteEditorListener"/> + serviceImplementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteLookupListener"/> @@ -166,21 +166,21 @@ - - - diff --git a/manual-testing-sandbox/test.ts b/manual-testing-sandbox/test.ts index 317fa4d13..2146463e7 100644 --- a/manual-testing-sandbox/test.ts +++ b/manual-testing-sandbox/test.ts @@ -9,9 +9,7 @@ class Calculator { this.result += number; return this; } - - subtract(number: number): Calculator { this.result -= number; return this; @@ -40,4 +38,4 @@ class Calculator { } } -export default Calculator; \ No newline at end of file +export default Calculator; From 1b82d39ac5b8e0cfb990a4968b3e8bc81af768ce Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 16:47:47 -0700 Subject: [PATCH 21/58] fix: remove unused imports --- .../actions/ContinuePluginActions.kt | 10 ---------- .../intellij/src/main/resources/META-INF/plugin.xml | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt index 81fbc89b9..863bbec56 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt @@ -1,21 +1,11 @@ package com.github.continuedev.continueintellijextension.actions -import com.github.continuedev.continueintellijextension.autocomplete.AutocompleteService import com.github.continuedev.continueintellijextension.editor.DiffStreamService -import com.github.continuedev.continueintellijextension.editor.openInlineEdit -import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.DataContext import com.intellij.openapi.actionSystem.PlatformDataKeys -import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.service -import com.intellij.openapi.editor.Caret -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.actionSystem.EditorAction -import com.intellij.openapi.editor.actionSystem.EditorActionHandler import com.intellij.openapi.fileEditor.FileEditorManager -import com.intellij.openapi.project.DumbAware class AcceptDiffAction : AnAction() { diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index 7f9fa1bff..92005ffdc 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -53,7 +53,7 @@ - From b7c71719e55e728f944399789f6749e493d5d13e Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 17:49:39 -0700 Subject: [PATCH 22/58] feat: update btn colors --- .../continueintellijextension/editor/InlineEditPanel.kt | 8 ++++++-- .../continueintellijextension/editor/VerticalDiffBlock.kt | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt index 028f3f185..f2d5eb152 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt @@ -478,13 +478,17 @@ class CustomPanel( val leftButton = CustomButton("Reject All (${getMetaKeyLabel()}${getShiftKeyLabel()}⌫)") { onReject() } .apply { - background = JBColor(0x30FF0000, 0x30FF0000) + foreground = JBColor(0xFFFFFF, 0xFFFFFF) + background = JBColor(0xFF0000, 0xFF0000) + + } val rightButton = CustomButton("Accept All (${getMetaKeyLabel()}${getShiftKeyLabel()}⏎)") { onAccept() } .apply { - background = JBColor(0x3000FF00, 0x3000FF00) + foreground = JBColor(0xFFFFFF, 0xFFFFFF) + background = JBColor(0x00BB00, 0x00BB00) } val rightPanel = diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt index ad902a8b9..616702466 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt @@ -166,7 +166,7 @@ class VerticalDiffBlock( val rejectBtn = createButton( "${getAltKeyLabel()}${getShiftKeyLabel()}N", - JBColor(0x77FF0000, 0x77FF0000) + JBColor(0xFF0000, 0xFF0000) ).apply { addActionListener { handleReject() @@ -178,13 +178,14 @@ class VerticalDiffBlock( createButton( "${getAltKeyLabel()}${ getShiftKeyLabel() - }Y", JBColor(0x7700BB00, 0x7700BB00) + }Y", JBColor(0x00BB00, 0x00BB00) ).apply { addActionListener { handleAccept() } } + return Pair(acceptBtn, rejectBtn) } From 64fb928b8ff9c0f7753a8b8d374abc179de1f4d5 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Tue, 20 May 2025 18:06:56 -0700 Subject: [PATCH 23/58] fix: matching context code --- .../rules/getSystemMessageWithRules.test.ts | 65 +++++++++++++++++++ .../utils/extractPathsFromCodeBlocks.test.ts | 35 ++++++++++ core/llm/utils/extractPathsFromCodeBlocks.ts | 42 ++++++++---- 3 files changed, 129 insertions(+), 13 deletions(-) create mode 100644 core/llm/utils/extractPathsFromCodeBlocks.test.ts diff --git a/core/llm/rules/getSystemMessageWithRules.test.ts b/core/llm/rules/getSystemMessageWithRules.test.ts index c1a7765ee..cad93e8d7 100644 --- a/core/llm/rules/getSystemMessageWithRules.test.ts +++ b/core/llm/rules/getSystemMessageWithRules.test.ts @@ -25,6 +25,14 @@ describe("getSystemMessageWithRules", () => { source: "rules-block", }; + // JavaScript rule + const jsRule: RuleWithSource = { + name: "JavaScript Rule", + rule: "Follow JavaScript best practices", + globs: "**/*.js", + source: "rules-block", + }; + it("should not include pattern-matched rules when no file paths are mentioned", () => { const result = getSystemMessageWithRules({ baseSystemMessage, @@ -198,4 +206,61 @@ describe("getSystemMessageWithRules", () => { // Should not match any file paths expect(result).toBe(baseSystemMessage); }); + + // New test for code block with filename only (no language) + it("should handle code blocks with filename only (no language identifier)", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```test.js\nclass Calculator { /* code */ }\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [jsRule, tsRule, generalRule], + }); + + // Should include JS rule and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // New test for code blocks with line ranges + it("should handle code blocks with line ranges", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```js test.js (19-25)\ndivide(number) { /* code */ }\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [jsRule, tsRule, generalRule], + }); + + // Should include JS rule and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // New test for mixed code block formats + it("should handle mixed code block formats in the same message", () => { + const userMessage: UserChatMessage = { + role: "user", + content: + "```test.js\nclass Calculator { /* code */ }\n```\n" + + "```js utils.js (19-25)\ndivide(number) { /* code */ }\n```\n" + + "```ts config/settings.ts\nconst config = {};\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [jsRule, tsRule, generalRule], + }); + + // Should include JS rule, TS rule, and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${tsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); }); diff --git a/core/llm/utils/extractPathsFromCodeBlocks.test.ts b/core/llm/utils/extractPathsFromCodeBlocks.test.ts new file mode 100644 index 000000000..93959a392 --- /dev/null +++ b/core/llm/utils/extractPathsFromCodeBlocks.test.ts @@ -0,0 +1,35 @@ +import { extractPathsFromCodeBlocks } from "./extractPathsFromCodeBlocks"; + +describe("extractPathsFromCodeBlocks", () => { + it("should extract paths from code blocks with language and filepath", () => { + const content = "```typescript src/main.ts\nconst x = 1;\n```"; + expect(extractPathsFromCodeBlocks(content)).toEqual(["src/main.ts"]); + }); + + it("should extract paths from code blocks with filepath only (no language)", () => { + const content = "```test.js\nclass Calculator { }\n```"; + expect(extractPathsFromCodeBlocks(content)).toEqual(["test.js"]); + }); + + it("should extract paths from code blocks with line ranges", () => { + const content = "```js test.js (19-25)\nfunction test() {}\n```"; + expect(extractPathsFromCodeBlocks(content)).toEqual(["test.js"]); + }); + + it("should handle multiple code blocks with different formats", () => { + const content = + "```typescript src/main.ts\nconst x = 1;\n```\n" + + "```test.js\nclass Calculator { }\n```\n" + + "```js utils.js (19-25)\nfunction test() {}\n```"; + const result = extractPathsFromCodeBlocks(content); + expect(result).toContain("src/main.ts"); + expect(result).toContain("test.js"); + expect(result).toContain("utils.js"); + expect(result.length).toBe(3); + }); + + it("should not extract paths from code blocks without file paths", () => { + const content = "```typescript\nconst x = 1;\n```"; + expect(extractPathsFromCodeBlocks(content)).toEqual([]); + }); +}); \ No newline at end of file diff --git a/core/llm/utils/extractPathsFromCodeBlocks.ts b/core/llm/utils/extractPathsFromCodeBlocks.ts index 7573a1f6f..00f723c7a 100644 --- a/core/llm/utils/extractPathsFromCodeBlocks.ts +++ b/core/llm/utils/extractPathsFromCodeBlocks.ts @@ -2,21 +2,37 @@ * Extracts file paths from markdown code blocks */ export function extractPathsFromCodeBlocks(content: string): string[] { - // Match: - // 1. Starting ``` - // 2. Optional language identifier - // 3. Required whitespace - // 4. File path (captured) that must contain a dot and extension - const codeBlockRegex = /```(?:[\w-+#]+)?\s+([^\s\n()]+\.[a-zA-Z0-9]+)/g; - const paths: string[] = []; - let match; + console.log("CONTENT", content); - while ((match = codeBlockRegex.exec(content)) !== null) { - const path = match[1]; - if (path && !path.startsWith("```")) { - paths.push(path); + const paths: string[] = []; + + // Match code block opening patterns: + // 1. ```language filepath + // 2. ```filepath + // 3. ```language filepath (range) + + // First match all code block starts + const codeBlockStarts = content.match(/```[^\n]+/g) || []; + + for (const blockStart of codeBlockStarts) { + // Try to extract a valid filename with extension + const filenameMatches = blockStart.match(/([^\s()```]+\.[a-zA-Z0-9]+)/); + + if (filenameMatches && filenameMatches[1]) { + const filename = filenameMatches[1]; + + // Verify this is a legitimate filename (not part of something else) + if ( + // Check if valid extension + /\.[a-zA-Z0-9]+$/.test(filename) && + // Make sure it's not a URL + !filename.includes("://") && + // Avoid duplicates + !paths.includes(filename) + ) { + paths.push(filename); + } } } - return paths; } From 08e98e7eee9b05f63cc8fad7d428e8b79ba94eb5 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 18:14:21 -0700 Subject: [PATCH 24/58] Update InlineEditPanel.kt --- .../editor/InlineEditPanel.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt index f2d5eb152..ee0499067 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditPanel.kt @@ -437,8 +437,8 @@ class CustomPanel( val rightButton = CustomButton("⏎ Enter") { onEnter() } .apply { - background = globalScheme.defaultForeground - foreground = globalScheme.defaultBackground + background = JBColor.namedColor("Button.startBackground") + foreground = JBColor.namedColor("Button.foreground") border = JBUI.Borders.empty(2, 6) } @@ -478,17 +478,17 @@ class CustomPanel( val leftButton = CustomButton("Reject All (${getMetaKeyLabel()}${getShiftKeyLabel()}⌫)") { onReject() } .apply { - foreground = JBColor(0xFFFFFF, 0xFFFFFF) - background = JBColor(0xFF0000, 0xFF0000) - - + background = Color(0, 0, 0, 0) + foreground = JBColor.foreground() + border = JBUI.Borders.empty(2, 6) } val rightButton = CustomButton("Accept All (${getMetaKeyLabel()}${getShiftKeyLabel()}⏎)") { onAccept() } .apply { - foreground = JBColor(0xFFFFFF, 0xFFFFFF) - background = JBColor(0x00BB00, 0x00BB00) + background = JBColor.namedColor("Button.startBackground") + foreground = JBColor.namedColor("Button.foreground") + border = JBUI.Borders.empty(2, 6) } val rightPanel = From ade64a5cf93a010a920b9156031ec69ba8cd3fd8 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 20 May 2025 20:53:20 -0700 Subject: [PATCH 25/58] vscode theme updates --- extensions/vscode/package-lock.json | 4 +- gui/src/App.tsx | 5 + .../StyledMarkdownPreview/SymbolLink.tsx | 9 +- gui/src/components/TabBar/TabBar.tsx | 65 ++--- gui/src/components/dialogs/index.tsx | 6 +- gui/src/components/find/FindWidget.tsx | 4 +- gui/src/components/gui/Alert.tsx | 2 +- gui/src/components/index.ts | 131 ++-------- .../components/ExpandableToolbarPreview.tsx | 2 +- .../modelSelection/platform/shared.tsx | 2 +- gui/src/context/VscTheme.tsx | 2 +- gui/src/hooks/ParallelListeners.tsx | 38 +-- gui/src/index.css | 4 +- gui/src/pages/config/HelpCenterSection.tsx | 12 + gui/src/pages/config/KeyboardShortcuts.tsx | 2 +- gui/src/styles/ThemePage.tsx | 136 +++++++++++ gui/src/styles/theme.ts | 225 ++++++++++++++++++ gui/src/styles/utils.ts | 45 ++++ gui/src/util/navigation.ts | 1 + gui/tailwind.config.cjs | 87 +++++-- 20 files changed, 573 insertions(+), 209 deletions(-) create mode 100644 gui/src/styles/ThemePage.tsx create mode 100644 gui/src/styles/theme.ts create mode 100644 gui/src/styles/utils.ts diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index bdd37caf7..681895a55 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.36", + "version": "1.1.37", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.36", + "version": "1.1.37", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", diff --git a/gui/src/App.tsx b/gui/src/App.tsx index 03b6fb05a..6fc120707 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -9,6 +9,7 @@ import ErrorPage from "./pages/error"; import Chat from "./pages/gui"; import History from "./pages/history"; import Stats from "./pages/stats"; +import ThemePage from "./styles/ThemePage"; import { ROUTES } from "./util/navigation"; const router = createMemoryRouter([ @@ -37,6 +38,10 @@ const router = createMemoryRouter([ path: ROUTES.CONFIG, element: , }, + { + path: ROUTES.THEME, + element: , + }, ], }, ]); diff --git a/gui/src/components/StyledMarkdownPreview/SymbolLink.tsx b/gui/src/components/StyledMarkdownPreview/SymbolLink.tsx index 40ca69708..8224af794 100644 --- a/gui/src/components/StyledMarkdownPreview/SymbolLink.tsx +++ b/gui/src/components/StyledMarkdownPreview/SymbolLink.tsx @@ -44,14 +44,7 @@ function SymbolLink({ symbol, content }: SymbolLinkProps) { data-tooltip-id={id} data-tooltip-delay-show={500} > - - {content} - + {content}
{processedContent ?? symbol.filepath}
diff --git a/gui/src/components/TabBar/TabBar.tsx b/gui/src/components/TabBar/TabBar.tsx index 3b87a23c6..2fe905674 100644 --- a/gui/src/components/TabBar/TabBar.tsx +++ b/gui/src/components/TabBar/TabBar.tsx @@ -13,13 +13,25 @@ import { } from "../../redux/slices/tabsSlice"; import { AppDispatch, RootState } from "../../redux/store"; import { loadSession, saveCurrentSession } from "../../redux/thunks/session"; +import { varWithFallback } from "../../styles/theme"; + +// Haven't set up theme colors for tabs yet +// Will keep it simple and choose from existing ones. Comments show vars we could use +const tabBorderVar = varWithFallback("border"); // --vscode-tab-border +const tabBackgroundVar = varWithFallback("background"); // --vscode-tab-inactiveBackground +const tabForegroundVar = varWithFallback("foreground"); // --vscode-tab-inactiveForeground +const tabHoverBackgroundVar = varWithFallback("list-hover"); // --vscode-tab-hoverBackground +const tabHoverForegroundVar = varWithFallback("foreground"); // --vscode-tab-hoverForeground +const tabSelectedBackgroundVar = varWithFallback("list-hover"); // --vscode-tab-activeBackground +const tabSelectedForegroundVar = varWithFallback("list-active-foreground"); // --vscode-tab-activeForeground +const tabAccentVar = varWithFallback("accent"); // --vscode-tab-activeBorderTop const TabBarContainer = styled.div` display: flex; flex-wrap: wrap; flex-shrink: 0; flex-grow: 0; - background-color: var(--vscode-tab-inactiveBackground); + background-color: ${tabBackgroundVar}; border-bottom: none; position: relative; margin-top: 2px; @@ -41,24 +53,18 @@ const Tab = styled.div<{ isActive: boolean }>` max-width: 150px; height: 25px; background-color: ${(props) => - props.isActive - ? "var(--vscode-tab-activeBackground)" - : "var(--vscode-tab-inactiveBackground)"}; + props.isActive ? tabSelectedBackgroundVar : tabBackgroundVar}; color: ${(props) => - props.isActive - ? "var(--vscode-tab-activeForeground)" - : "var(--vscode-tab-inactiveForeground)"}; + props.isActive ? tabSelectedForegroundVar : tabForegroundVar}; cursor: pointer; - border: 1px solid var(--vscode-tab-border); + border: 1px solid ${tabBorderVar}; border-bottom: ${(props) => - props.isActive ? "none" : `1px solid var(--vscode-tab-border)`}; + props.isActive ? "none" : `1px solid ${tabBorderVar}`}; user-select: none; position: relative; transition: background-color 0.2s; border-top: ${(props) => - props.isActive - ? `1px solid var(--vscode-tab-activeBorderTop, --vscode-tab-border)` - : `1px solid var(--vscode-tab-border)`}; + props.isActive ? `1px solid ${tabAccentVar}` : `1px solid ${tabBorderVar}`}; &:first-child { border-left: none; } @@ -68,13 +74,9 @@ const Tab = styled.div<{ isActive: boolean }>` &:hover { background-color: ${(props) => - props.isActive - ? "var(--vscode-tab-activeBackground)" - : "var(--vscode-tab-hoverBackground)"}; + props.isActive ? tabSelectedBackgroundVar : tabHoverBackgroundVar}; color: ${(props) => - props.isActive - ? "var(--vscode-tab-activeForeground)" - : "var(--vscode-tab-hoverForeground)"}; + props.isActive ? tabSelectedForegroundVar : tabHoverForegroundVar}; } `; @@ -104,7 +106,7 @@ const CloseButton = styled.button` &:hover { opacity: 1; - background-color: var(--vscode-tab-hoverBackground); + background-color: ${tabHoverBackgroundVar}; } ${Tab}:hover & { @@ -119,33 +121,12 @@ const CloseButton = styled.button` const TabBarSpace = styled.div` flex: 1; display: flex; - border-bottom: 1px solid var(--vscode-tab-border); - background-color: var(--vscode-tab-inactiveBackground); -`; - -const NewTabButton = styled.button` - display: flex; - align-items: center; - justify-content: center; - width: 35px; - height: 100%; - border: none; - background: transparent; - color: var(--vscode-tab-inactiveForeground); - cursor: pointer; - opacity: 0.7; - transition: opacity 0.2s; - - &:hover { - opacity: 1; - background-color: var(--vscode-tab-hoverBackground); - color: var(--vscode-tab-hoverForeground); - } + border-bottom: 1px solid ${tabBorderVar}; + background-color: ${tabBackgroundVar}; `; export function TabBar() { const dispatch = useDispatch(); - const currentSession = useSelector((state: RootState) => state.session); const currentSessionId = useSelector((state: RootState) => state.session.id); const currentSessionTitle = useSelector( (state: RootState) => state.session.title, diff --git a/gui/src/components/dialogs/index.tsx b/gui/src/components/dialogs/index.tsx index 5acf040b6..c4a80e0b4 100644 --- a/gui/src/components/dialogs/index.tsx +++ b/gui/src/components/dialogs/index.tsx @@ -4,12 +4,12 @@ import ReactMarkdown from "react-markdown"; import styled from "styled-components"; import { CloseButton, - VSC_BACKGROUND_VAR, defaultBorderRadius, - parseColorForHex, vscBackground, vscForeground, } from ".."; +import { THEME_COLORS } from "../../styles/theme"; +import { parseColorForHex } from "../../styles/utils"; interface TextDialogProps { showDialog: boolean; @@ -22,7 +22,7 @@ const ScreenCover = styled.div` position: fixed; width: 100%; height: 100%; - background-color: ${parseColorForHex(VSC_BACKGROUND_VAR)}aa; + background-color: ${parseColorForHex(THEME_COLORS["background"].var)}aa; z-index: 100000; flex-direction: column; `; diff --git a/gui/src/components/find/FindWidget.tsx b/gui/src/components/find/FindWidget.tsx index fd174f59c..c5a245d8f 100644 --- a/gui/src/components/find/FindWidget.tsx +++ b/gui/src/components/find/FindWidget.tsx @@ -12,8 +12,8 @@ import { useState, } from "react"; import { HeaderButton, Input } from ".."; -import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; import { useAppSelector } from "../../redux/hooks"; +import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; interface SearchMatch { index: number; @@ -41,7 +41,7 @@ const HighlightOverlay = (props: HighlightOverlayProps) => { const { isCurrent, top, left, width, height } = props; return (
+
6) { - hexColor = hexColor.slice(0, 6); - } - - const r = parseInt(hexColor.substring(0, 2), 16); - const g = parseInt(hexColor.substring(2, 4), 16); - const b = parseInt(hexColor.substring(4, 6), 16); - - return { r, g, b }; -} - -export function parseColorForHex(colorVar: string): string { - const value = getComputedStyle(document.documentElement).getPropertyValue( - colorVar, - ); - if (value.startsWith("#")) { - return value.slice(0, 7); - } - - // Parse rgb/rgba - const rgbValues = value - .slice(value.startsWith("rgba") ? 5 : 4, -1) - .split(",") - .map((x) => x.trim()) - .filter((_, i) => i < 3) // Only take the first 3 values (RGB, ignore alpha) - .map((x) => parseInt(x, 10)); - - let hex = - "#" + - rgbValues - .map((x) => x.toString(16)) - .map((x) => (x.length === 1 ? "0" + x : x)) - .join(""); - - return hex; -} +export const vscInputBackground = varWithFallback("input-background"); +export const vscQuickInputBackground = varWithFallback("input-background"); +export const vscBackground = varWithFallback("background"); +export const vscForeground = varWithFallback("foreground"); +export const vscButtonBackground = varWithFallback("primary-background"); +export const vscButtonForeground = varWithFallback("primary-foreground"); +export const vscEditorBackground = varWithFallback("editor"); +export const vscListActiveBackground = varWithFallback("list-active"); +export const vscFocusBorder = varWithFallback("border-focus"); +export const vscListActiveForeground = varWithFallback( + "list-active-foreground", +); +export const vscInputBorder = varWithFallback("input-border"); +export const vscInputBorderFocus = varWithFallback("border-focus"); +export const vscBadgeBackground = varWithFallback("badge"); +export const vscBadgeForeground = varWithFallback("badge-foreground"); +export const vscCommandCenterActiveBorder = varWithFallback( + "command-border-focus", +); +export const vscCommandCenterInactiveBorder = varWithFallback("command-border"); export const Button = styled.button` padding: 6px 12px; @@ -226,10 +143,6 @@ export const Input = styled.input` } `; -export const Label = styled.label<{ fontSize?: number }>` - font-size: ${(props) => props.fontSize || getFontSize()}px; -`; - export const HeaderButton = styled.button<{ inverted: boolean | undefined; backgroundColor?: string; diff --git a/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx b/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx index a5b89d0f4..3b8359e96 100644 --- a/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx @@ -159,7 +159,7 @@ export function ExpandableToolbarPreview(props: ExpandableToolbarPreviewProps) { contentEditable={false} >
diff --git a/gui/src/context/VscTheme.tsx b/gui/src/context/VscTheme.tsx index 2ca1dac59..8a0195141 100644 --- a/gui/src/context/VscTheme.tsx +++ b/gui/src/context/VscTheme.tsx @@ -1,6 +1,6 @@ import { createContext, useContext, useState } from "react"; -import { parseHexColor } from "../components"; import { useWebviewListener } from "../hooks/useWebviewListener"; +import { parseHexColor } from "../styles/utils"; const hljsToTextMate: Record = { ".hljs-comment": ["comment"], diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index 1b609ce39..a0a2fd209 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -1,5 +1,4 @@ import { useCallback, useContext, useEffect, useRef } from "react"; -import { VSC_THEME_COLOR_VARS } from "../components"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; @@ -29,6 +28,7 @@ import { cancelStream } from "../redux/thunks/cancelStream"; import { refreshSessionMetadata } from "../redux/thunks/session"; import { streamResponseThunk } from "../redux/thunks/streamResponse"; import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols"; +import { THEME_COLORS } from "../styles/theme"; import { isJetBrains } from "../util"; import { setLocalStorage } from "../util/localStorage"; import { useWebviewListener } from "./useWebviewListener"; @@ -139,20 +139,21 @@ function ParallelListeners() { dispatch(cancelStream()); const jetbrains = isJetBrains(); - for (const colorVar of VSC_THEME_COLOR_VARS) { + for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { + const cssVarName = themeVals.var; if (jetbrains) { - const cached = localStorage.getItem(colorVar); + const cached = localStorage.getItem(colorName); if (cached) { - document.body.style.setProperty(colorVar, cached); + document.body.style.setProperty(cssVarName, cached); } } // Remove alpha channel from colors const value = getComputedStyle(document.documentElement).getPropertyValue( - colorVar, + cssVarName, ); - if (colorVar.startsWith("#") && value.length > 7) { - document.body.style.setProperty(colorVar, value.slice(0, 7)); + if (value.startsWith("#") && value.length > 7) { + document.body.style.setProperty(cssVarName, value.slice(0, 7)); } } @@ -160,9 +161,11 @@ function ParallelListeners() { // Save theme colors to local storage for immediate loading in JetBrains ideMessenger.request("jetbrains/getColors", undefined).then((result) => { if (result.status === "success") { - Object.entries(result.content).forEach(([key, value]) => { - document.body.style.setProperty(key, value); - document.documentElement.style.setProperty(key, value); + Object.entries(result.content).forEach(([colorName, value]) => { + const cssVarName = + THEME_COLORS[colorName as keyof typeof THEME_COLORS]?.var; + document.body.style.setProperty(cssVarName, value); + document.documentElement.style.setProperty(cssVarName, value); }); } }); @@ -181,12 +184,10 @@ function ParallelListeners() { (window as any).vscMediaUrl = msg.vscMediaUrl; }); - for (const colorVar of VSC_THEME_COLOR_VARS) { - if (document.body.style.getPropertyValue(colorVar)) { - localStorage.setItem( - colorVar, - document.body.style.getPropertyValue(colorVar), - ); + for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { + const currentVal = document.body.style.getPropertyValue(themeVals.var); + if (currentVal) { + localStorage.setItem(colorName, currentVal); } } } @@ -196,8 +197,9 @@ function ParallelListeners() { "jetbrains/setColors", async (data) => { Object.entries(data).forEach(([key, value]) => { - document.body.style.setProperty(key, value); - document.documentElement.style.setProperty(key, value); + const cssVarName = THEME_COLORS[key as keyof typeof THEME_COLORS]?.var; + document.body.style.setProperty(cssVarName, value); + document.documentElement.style.setProperty(cssVarName, value); }); }, [], diff --git a/gui/src/index.css b/gui/src/index.css index 6ef5e902e..34d0d004f 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -25,7 +25,7 @@ body, #root { height: 100%; line-height: 1.3; - background-color: var(--vscode-editor-background); + background-color: var(--vscode-sideBar-background); font-family: system-ui, -apple-system, @@ -42,7 +42,7 @@ body, body { padding: 0; - color: var(--vscode-editor-foreground); + color: var(--vscode-sideBar-foreground); padding: 0px; margin: 0px; height: 100%; diff --git a/gui/src/pages/config/HelpCenterSection.tsx b/gui/src/pages/config/HelpCenterSection.tsx index a82b775a8..e49a17780 100644 --- a/gui/src/pages/config/HelpCenterSection.tsx +++ b/gui/src/pages/config/HelpCenterSection.tsx @@ -1,6 +1,7 @@ import { ArrowTopRightOnSquareIcon, DocumentArrowUpIcon, + PaintBrushIcon, TableCellsIcon, } from "@heroicons/react/24/outline"; import { useContext } from "react"; @@ -9,6 +10,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useAppDispatch } from "../../redux/hooks"; import { setOnboardingCard } from "../../redux/slices/uiSlice"; import { saveCurrentSession } from "../../redux/thunks/session"; +import { ROUTES } from "../../util/navigation"; import MoreHelpRow from "./MoreHelpRow"; export function HelpCenterSection() { @@ -83,6 +85,16 @@ export function HelpCenterSection() { ideMessenger.post("showTutorial", undefined); }} /> + {process.env.NODE_ENV === "development" && ( + { + navigate(ROUTES.THEME); + }} + /> + )}
); diff --git a/gui/src/pages/config/KeyboardShortcuts.tsx b/gui/src/pages/config/KeyboardShortcuts.tsx index d7c3828d7..77d8c2733 100644 --- a/gui/src/pages/config/KeyboardShortcuts.tsx +++ b/gui/src/pages/config/KeyboardShortcuts.tsx @@ -11,7 +11,7 @@ interface KeyboardShortcutProps { function KeyboardShortcut(props: KeyboardShortcutProps) { return (
{props.description}: diff --git a/gui/src/styles/ThemePage.tsx b/gui/src/styles/ThemePage.tsx new file mode 100644 index 000000000..c08252b35 --- /dev/null +++ b/gui/src/styles/ThemePage.tsx @@ -0,0 +1,136 @@ +import { + CheckCircleIcon, + ExclamationCircleIcon, + ExclamationTriangleIcon, +} from "@heroicons/react/24/outline"; +import { useState } from "react"; +import { useNavigate } from "react-router-dom"; +import { THEME_COLORS } from "./theme"; + +const ThemeTailwindClassExample = ({ + className, + varName, + defaultColor, +}: { + className: string; + varName: string; + defaultColor: string; +}) => { + return ( + <> +
+ {className} +
+
+ {varName} +
+
+ {defaultColor} +
+ + ); +}; + +function ThemePage() { + const navigate = useNavigate(); + const [listToggled, setListToggled] = useState(false); + return ( +
+ navigate("/more")} + > + ← + Back to Settings + + +
+
+

Normal text

+

Description text

+

Muted text

+
+ + + + +
+ Normal border +
+ +
+ Focus border +
+ + + +
+ Badge +
+ +
+
+ + Success +
+
+ + Warning +
+
+ + Error +
+
+ +
setListToggled(!listToggled)} + className={`cursor-pointer p-2 ${listToggled ? "bg-list-active text-list-active-foreground" : "bg-background text-foreground hover:bg-list-hover"}`} + > + List item (click to select) +
+
+ Editor +
+
+

All Theme Colors

+
+
+ Tailwind Class +
+
+ CSS Var +
+
+ Fallback +
+ {Object.entries(THEME_COLORS).map(([key, val]) => ( + + ))} +
+
+ ); +} +export default ThemePage; diff --git a/gui/src/styles/theme.ts b/gui/src/styles/theme.ts new file mode 100644 index 000000000..b5f2b3535 --- /dev/null +++ b/gui/src/styles/theme.ts @@ -0,0 +1,225 @@ +// All vscode variables https://gist.github.com/estruyf/ba49203e1a7d6868e9320a4ea480c27a +// Examples for vscode https://github.com/githubocto/tailwind-vscode/blob/main/index.js +export const THEME_COLORS = { + background: { + var: "--vscode-sideBar-background", + default: "#141c2d", + }, + foreground: { + var: "--vscode-sideBar-foreground", // --vscode-editor-foreground + default: "rgba(243, 239, 245, 0.8)", + }, + editor: { + var: "--vscode-editor-background", + default: "#0e131f", + }, + "editor-foreground": { + var: "--vscode-editor-foreground", + default: "#f3eff5", + }, + "primary-background": { + var: "--vscode-button-background", + default: "#1bbe84", + }, + "primary-foreground": { + var: "--vscode-button-foreground", + default: "#ffffff", + }, + "primary-hover": { + var: "--vscode-button-hoverBackground", + default: "#24dfe8", + }, + secondary: { + var: "--vscode-button-secondaryBackground", + default: "rgba(243, 239, 245, 0.2)", + }, + "secondary-foreground": { + var: "--vscode-button-secondaryForeground", + default: "#f3eff5", + }, + "secondary-hover": { + var: "--vscode-button-secondaryHoverBackground", + default: "rgba(243, 239, 245, 0.2)", + }, + border: { + // --vscode-panel-border + var: "--vscode-sideBar-border", + default: "#242d34", + }, + "border-focus": { + var: "--vscode-focusBorder", + default: "#263354", + }, + // Command styles are used for tip-tap editor + command: { + var: "--vscode-commandCenter-background", + default: "#141c2d", + }, + "command-foreground": { + var: "--vscode-commandCenter-foreground", + default: "#f3eff5", + }, + "command-border": { + var: "--vscode-commandCenter-inactiveBorder", + default: "#999998", + }, + "command-border-focus": { + var: "--vscode-commandCenter-activeBorder", + default: "#ed1292", + }, + description: { + var: "--vscode-descriptionForeground", + default: "rgba(243, 239, 245, 0.7)", + }, + "description-muted": { + var: "--vscode-list-deemphasizedForeground", + default: "#8c8c8c", + }, + "input-background": { + var: "--vscode-input-background", + default: "#0d1217", + }, + "input-foreground": { + var: "--vscode-input-foreground", + default: "#f3eff5", + }, + "input-border": { + var: "--vscode-input-border", + default: "#242d34", + }, + "input-placeholder": { + var: "--vscode-input-placeholderForeground", + default: "rgba(243, 239, 245, 0.5)", + }, + "table-oddRow": { + var: "--vscode-tree-tableOddRowsBackground", + default: "rgb(45, 45, 45)", + }, + badge: { + var: "--vscode-badge-background", + default: "rgb(80, 80, 80)", + }, + "badge-foreground": { + var: "--vscode-badge-foreground", + default: "#fff", + }, + success: { + var: "--vscode-notebookStatusSuccessIcon-foreground", // "var(--vscode-testing-iconPassed, #1bbe84)" // --vscode-charts-green + default: "#1bbe84", + }, + warning: { + var: "--vscode-editorWarning-foreground", // --vscode-list-warningForeground + default: "#ffe45e", + }, + error: { + var: "--vscode-editorError-foreground", // --vscode-list-errorForeground + default: "#fe4a49", + }, + link: { + var: "--vscode-textLink-foreground", + default: "#4da6ff", + }, + accent: { + var: "--vscode-tab-activeBorderTop", + default: "#ed1292", + }, + "find-match": { + var: "--vscode-editor-findMatchBackground", // Can't get "var(--vscode-editor-findMatchBackground, rgba(237, 18, 146, 0.5))" to work + default: "rgba(191, 219, 254, 0.3)", + }, + "find-match-selected": { + var: "--vscode-editor-findMatchHighlightBackground", + default: "rgba(255, 223, 0, 0.3)", + }, + "list-hover": { + var: "--vscode-list-hoverBackground", + default: "rgba(243, 239, 245, 0.13)", + }, + "list-active": { + var: "--vscode-list-activeSelectionBackground", + default: "rgba(243, 239, 245, 0.2)", + }, + "list-active-foreground": { + var: "--vscode-list-activeSelectionForeground", + default: "#f3eff5", + }, +}; + +// Consider defaults +// export const vscInputBackground = `var(${VSC_INPUT_BACKGROUND_VAR}, rgb(45 45 45))`; +// export const vscQuickInputBackground = `var(${VSC_QUICK_INPUT_BACKGROUND_VAR}, ${VSC_INPUT_BACKGROUND_VAR}, rgb(45 45 45))`; +// export const vscBackground = `var(${VSC_BACKGROUND_VAR}, rgb(30 30 30))`; +// export const vscForeground = `var(${VSC_FOREGROUND_VAR}, #fff)`; +// export const vscButtonBackground = `var(${VSC_BUTTON_BACKGROUND_VAR}, #1bbe84)`; +// export const vscButtonForeground = `var(${VSC_BUTTON_FOREGROUND_VAR}, #ffffff)`; +// export const vscEditorBackground = `var(${VSC_EDITOR_BACKGROUND_VAR}, ${VSC_BACKGROUND_VAR}, rgb(30 30 30))`; +// export const vscListActiveBackground = `var(${VSC_LIST_SELECTION_BACKGROUND_VAR}, #1bbe84)`; +// export const vscFocusBorder = `var(${VSC_FOCUS_BORDER_VAR}, #1bbe84)`; +// export const vscListActiveForeground = `var(${VSC_LIST_ACTIVE_FOREGROUND_VAR}, ${VSC_FOREGROUND_VAR})`; +// export const vscInputBorder = `var(${VSC_INPUT_BORDER_VAR}, ${lightGray})`; +// export const vscInputBorderFocus = `var(${VSC_FOCUS_BORDER_VAR}, ${lightGray})`; +// export const vscBadgeBackground = `var(${VSC_BADGE_BACKGROUND_VAR}, #1bbe84)`; +// export const vscBadgeForeground = `var(${VSC_BADGE_FOREGROUND_VAR}, #ffffff)`; +// export const vscCommandCenterActiveBorder = `var(${VSC_COMMAND_CENTER_ACTIVE_BORDER_VAR}, #1bbe84)`; +// export const vscCommandCenterInactiveBorder = `var(${VSC_COMMAND_CENTER_INACTIVE_BORDER_VAR}, #1bbe84)`; +// export const vscFindMatchSelected = `var(${VSC_FIND_MATCH_SELECTED_VAR}, rgba(255, 223, 0))`; + +// Fonts: +// --vscode - editor - font - family; +// --vscode - font - family; + +// Current list of CSS variables needed (e.g. for jetbrains to send!) +// --vscode-sideBar-background +// --vscode-sideBar-foreground +// --vscode-editor-background +// --vscode-editor-foreground +// --vscode-button-background +// --vscode-button-foreground +// --vscode-button-secondaryBackground +// --vscode-button-secondaryForeground +// --vscode-sideBar-border +// --vscode-focusBorder +// --vscode-commandCenter-background +// --vscode-commandCenter-foreground +// --vscode-commandCenter-inactiveBorder +// --vscode-commandCenter-activeBorder +// --vscode-descriptionForeground +// --vscode-list-deemphasizedForeground +// --vscode-input-background +// --vscode-input-foreground +// --vscode-input-border +// --vscode-input-placeholderForeground +// --vscode-tree-tableOddRowsBackground +// --vscode-badge-background +// --vscode-badge-foreground +// --vscode-notebookStatusSuccessIcon-foreground +// --vscode-editorWarning-foreground +// --vscode-editorError-foreground +// --vscode-editor-findMatchBackground +// --vscode-editor-findMatchHighlightBackground +// --vscode-list-hoverBackground +// --vscode-list-activeSelectionBackground +// --vscode-list-activeSelectionForeground + +export const THEME_CSS_VARS = Object.values(THEME_COLORS).map( + (value) => value.var, +); + +export const THEME_CSS_VAR_DEFAULTS = Object.entries(THEME_COLORS).reduce( + (acc, [_, value]) => { + acc[value.var] = value.default; + return acc; + }, + {} as Record, +); + +export const THEME_DEFAULTS = Object.entries(THEME_COLORS).reduce( + (acc, [key, value]) => { + acc[key] = value.default; + return acc; + }, + {} as Record, +); + +export const varWithFallback = (className: keyof typeof THEME_COLORS) => + `var(${THEME_COLORS[className].var}, ${THEME_COLORS[className].default})`; diff --git a/gui/src/styles/utils.ts b/gui/src/styles/utils.ts new file mode 100644 index 000000000..a46860ac4 --- /dev/null +++ b/gui/src/styles/utils.ts @@ -0,0 +1,45 @@ +export function parseHexColor(hexColor: string): { + r: number; + g: number; + b: number; +} { + if (hexColor.startsWith("#")) { + hexColor = hexColor.slice(1); + } + + if (hexColor.length > 6) { + hexColor = hexColor.slice(0, 6); + } + + const r = parseInt(hexColor.substring(0, 2), 16); + const g = parseInt(hexColor.substring(2, 4), 16); + const b = parseInt(hexColor.substring(4, 6), 16); + + return { r, g, b }; +} + +export function parseColorForHex(colorVar: string): string { + const value = getComputedStyle(document.documentElement).getPropertyValue( + colorVar, + ); + if (value.startsWith("#")) { + return value.slice(0, 7); + } + + // Parse rgb/rgba + const rgbValues = value + .slice(value.startsWith("rgba") ? 5 : 4, -1) + .split(",") + .map((x) => x.trim()) + .filter((_, i) => i < 3) // Only take the first 3 values (RGB, ignore alpha) + .map((x) => parseInt(x, 10)); + + let hex = + "#" + + rgbValues + .map((x) => x.toString(16)) + .map((x) => (x.length === 1 ? "0" + x : x)) + .join(""); + + return hex; +} diff --git a/gui/src/util/navigation.ts b/gui/src/util/navigation.ts index 0f145b6cd..44ef9a9ee 100644 --- a/gui/src/util/navigation.ts +++ b/gui/src/util/navigation.ts @@ -2,5 +2,6 @@ export const ROUTES = { HOME: "/", CONFIG: "/config", + THEME: "/theme", // EXAMPLE_ROUTE_WITH_PARAMS: (params: ParamsType) => `/route/${params}`, }; diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index 941429d2e..a1270a857 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -1,5 +1,6 @@ /** @type {import('tailwindcss').Config} */ const defaultTheme = require("tailwindcss/defaultTheme"); +const { varWithFallback, THEME_COLORS } = require("./src/styles/theme"); module.exports = { content: [ @@ -29,25 +30,75 @@ module.exports = { default: "5px", }, colors: { - lightgray: "#999998", - "vsc-input-background": "var(--vscode-input-background, rgb(45 45 45))", - "vsc-background": "var(--vscode-sideBar-background, rgb(30 30 30))", - "vsc-foreground": "var(--vscode-editor-foreground, #fff)", - "vsc-editor-background": - "var(--vscode-editor-background, var(--vscode-sideBar-background, rgb(30 30 30)))", - "vsc-input-border": "var(--vscode-input-border, #999998)", - "vsc-commandCenter-inactiveBorder": - "var(--vscode-commandCenter-inactiveBorder, #999998)", + background: varWithFallback("background"), + foreground: varWithFallback("foreground"), + editor: { + DEFAULT: varWithFallback("editor"), + foreground: varWithFallback("editor-foreground"), + }, + primary: { + DEFAULT: varWithFallback("primary-background"), + foreground: varWithFallback("primary-foreground"), + hover: varWithFallback("primary-hover"), + }, + secondary: { + DEFAULT: varWithFallback("secondary"), + foreground: varWithFallback("secondary-foreground"), + hover: varWithFallback("secondary-hover"), + }, + border: { + DEFAULT: varWithFallback("border"), + focus: varWithFallback("border-focus"), + }, + command: { + DEFAULT: varWithFallback("command"), + foreground: varWithFallback("command-foreground"), + border: { + DEFAULT: varWithFallback("command-border"), + focus: varWithFallback("command-border-focus"), + }, + }, + description: { + DEFAULT: varWithFallback("description"), + muted: varWithFallback("description-muted"), + }, + input: { + DEFAULT: varWithFallback("input-background"), + foreground: varWithFallback("input-foreground"), + border: varWithFallback("input-border"), + placeholder: varWithFallback("input-placeholder"), + }, + table: { + oddRow: varWithFallback("table-oddRow"), + }, + badge: { + DEFAULT: varWithFallback("badge"), + foreground: varWithFallback("badge-foreground"), + }, + success: varWithFallback("success"), + warning: varWithFallback("warning"), + error: varWithFallback("error"), + link: varWithFallback("link"), + accent: varWithFallback("accent"), + findMatch: { + DEFAULT: THEME_COLORS["find-match"].default, + selected: varWithFallback("find-match-selected"), + }, + list: { + hover: varWithFallback("list-hover"), + active: { + DEFAULT: varWithFallback("list-active"), + foreground: varWithFallback("list-active-foreground"), + }, + }, - // Starting to make things less vsc-specific - // TODO make it all non-IDE-specific naming - "find-match-selected": - "var(--vscode-editor-findMatchHighlightBackground, rgba(255, 223, 0))", - "table-odd-rows":"var(--vscode-tree-tableOddRowsBackground, #1bbe84)", - "list-active": "var(--vscode-list-activeSelectionBackground, #1bbe84)", - "list-active-foreground": - "var(--vscode-quickInputList-focusForeground, var(--vscode-editor-foreground))", - badge: "var(--vscode-badge-background, #1bbe84)", + // DEPRECATED, slowly remove usages of these ide-named or explicit colors + lightgray: "#999998", // use border, description, or description-muted instead + "vsc-input-background": varWithFallback("input-background"), // use "input-background" instead + "vsc-background": varWithFallback("background"), // use "background" instead + "vsc-foreground": varWithFallback("foreground"), // use "foreground" instead // NOTE - might want to use editor-foreground + "vsc-editor-background": varWithFallback("editor"), // use "editor" instead + "vsc-input-border": varWithFallback("input-border"), // use "input-border" instead }, }, }, From 24bb5eb0dab8467f606d249f8be16fcb9ff083c0 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 20 May 2025 20:55:19 -0700 Subject: [PATCH 26/58] feat(JB): impl `showFile` --- core/index.d.ts | 6 +++++- core/protocol/ideWebview.ts | 3 ++- .../continue/IdeProtocolClient.kt | 13 +++++++++++-- .../protocol/ideWebview.kt | 10 ---------- .../continuedev/continueintellijextension/types.kt | 4 ++++ 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 9bc413331..8cf7b8cb8 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -842,7 +842,7 @@ export interface SlashCommand { description: string; prompt?: string; params?: { [key: string]: any }; - promptFile?: string + promptFile?: string; run: (sdk: ContinueSDK) => AsyncGenerator; } @@ -1253,6 +1253,10 @@ export interface AcceptOrRejectDiffPayload { streamId?: string; } +export interface ShowFilePayload { + filepath: string; +} + export interface RangeInFileWithContents { filepath: string; range: { diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 3c836126a..267216d58 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -8,6 +8,7 @@ import { MessageContent, RangeInFileWithContents, AcceptOrRejectDiffPayload, + ShowFilePayload, } from "../"; export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { @@ -23,7 +24,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { ]; overwriteFile: [{ filepath: string; prevFileContent: string | null }, void]; showTutorial: [undefined, void]; - showFile: [{ filepath: string }, void]; + showFile: [ShowFilePayload, void]; toggleDevTools: [undefined, void]; reloadWindow: [undefined, void]; focusEditor: [undefined, void]; diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index cc9f018fa..eb5072db1 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -91,6 +91,15 @@ class IdeProtocolClient( respond(jsonData) } + "showFile" -> { + val params = Gson().fromJson( + dataElement.toString(), + ShowFilePayload::class.java + ) + ide.openFile(params.filepath) + respond(null) + } + "getIdeSettings" -> { val settings = ide.getIdeSettings() respond(settings) @@ -438,7 +447,7 @@ class IdeProtocolClient( "acceptDiff" -> { val params = Gson().fromJson( dataElement.toString(), - AcceptDiffParams::class.java + AcceptOrRejectDiffPayload::class.java ) val filepath = params.filepath; @@ -454,7 +463,7 @@ class IdeProtocolClient( "rejectDiff" -> { val params = Gson().fromJson( dataElement.toString(), - RejectDiffParams::class.java + AcceptOrRejectDiffPayload::class.java ) val filepath = params.filepath; diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt index b875f744c..718755a99 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt @@ -15,16 +15,6 @@ data class ApplyToFileParams( val toolCallId: String? ) -data class AcceptDiffParams( - val filepath: String, - val streamId: String -) - -data class RejectDiffParams( - val filepath: String, - val streamId: String -) - data class InsertAtCursorParams( val text: String ) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt index aaa4a8e8e..ed38e4726 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt @@ -250,4 +250,8 @@ data class StreamDiffLinesPayload( data class AcceptOrRejectDiffPayload( val filepath: String, val streamId: String? = null +) + +data class ShowFilePayload( + val filepath: String ) \ No newline at end of file From 83e9650946d339a8c61a96ffbb64d3be3cc327a2 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 20 May 2025 21:06:33 -0700 Subject: [PATCH 27/58] complete theme mapping for vs code --- gui/src/styles/theme.ts | 75 +++++++---------------------------------- gui/tailwind.config.cjs | 2 +- 2 files changed, 13 insertions(+), 64 deletions(-) diff --git a/gui/src/styles/theme.ts b/gui/src/styles/theme.ts index b5f2b3535..f9379fc4b 100644 --- a/gui/src/styles/theme.ts +++ b/gui/src/styles/theme.ts @@ -1,17 +1,18 @@ // All vscode variables https://gist.github.com/estruyf/ba49203e1a7d6868e9320a4ea480c27a // Examples for vscode https://github.com/githubocto/tailwind-vscode/blob/main/index.js + export const THEME_COLORS = { background: { var: "--vscode-sideBar-background", - default: "#141c2d", + default: "#1e1e1e", }, foreground: { var: "--vscode-sideBar-foreground", // --vscode-editor-foreground - default: "rgba(243, 239, 245, 0.8)", + default: "rgba(243, 239, 245)", }, editor: { var: "--vscode-editor-background", - default: "#0e131f", + default: "#1e1e1e", }, "editor-foreground": { var: "--vscode-editor-foreground", @@ -19,7 +20,7 @@ export const THEME_COLORS = { }, "primary-background": { var: "--vscode-button-background", - default: "#1bbe84", + default: "#1b3ebe", }, "primary-foreground": { var: "--vscode-button-foreground", @@ -27,7 +28,7 @@ export const THEME_COLORS = { }, "primary-hover": { var: "--vscode-button-hoverBackground", - default: "#24dfe8", + default: "#2847ad", }, secondary: { var: "--vscode-button-secondaryBackground", @@ -77,7 +78,7 @@ export const THEME_COLORS = { }, "input-background": { var: "--vscode-input-background", - default: "#0d1217", + default: "#2d2d2d", }, "input-foreground": { var: "--vscode-input-foreground", @@ -85,7 +86,7 @@ export const THEME_COLORS = { }, "input-border": { var: "--vscode-input-border", - default: "#242d34", + default: "#999998", }, "input-placeholder": { var: "--vscode-input-placeholderForeground", @@ -101,7 +102,7 @@ export const THEME_COLORS = { }, "badge-foreground": { var: "--vscode-badge-foreground", - default: "#fff", + default: "#ffffff", }, success: { var: "--vscode-notebookStatusSuccessIcon-foreground", // "var(--vscode-testing-iconPassed, #1bbe84)" // --vscode-charts-green @@ -145,61 +146,9 @@ export const THEME_COLORS = { }, }; -// Consider defaults -// export const vscInputBackground = `var(${VSC_INPUT_BACKGROUND_VAR}, rgb(45 45 45))`; -// export const vscQuickInputBackground = `var(${VSC_QUICK_INPUT_BACKGROUND_VAR}, ${VSC_INPUT_BACKGROUND_VAR}, rgb(45 45 45))`; -// export const vscBackground = `var(${VSC_BACKGROUND_VAR}, rgb(30 30 30))`; -// export const vscForeground = `var(${VSC_FOREGROUND_VAR}, #fff)`; -// export const vscButtonBackground = `var(${VSC_BUTTON_BACKGROUND_VAR}, #1bbe84)`; -// export const vscButtonForeground = `var(${VSC_BUTTON_FOREGROUND_VAR}, #ffffff)`; -// export const vscEditorBackground = `var(${VSC_EDITOR_BACKGROUND_VAR}, ${VSC_BACKGROUND_VAR}, rgb(30 30 30))`; -// export const vscListActiveBackground = `var(${VSC_LIST_SELECTION_BACKGROUND_VAR}, #1bbe84)`; -// export const vscFocusBorder = `var(${VSC_FOCUS_BORDER_VAR}, #1bbe84)`; -// export const vscListActiveForeground = `var(${VSC_LIST_ACTIVE_FOREGROUND_VAR}, ${VSC_FOREGROUND_VAR})`; -// export const vscInputBorder = `var(${VSC_INPUT_BORDER_VAR}, ${lightGray})`; -// export const vscInputBorderFocus = `var(${VSC_FOCUS_BORDER_VAR}, ${lightGray})`; -// export const vscBadgeBackground = `var(${VSC_BADGE_BACKGROUND_VAR}, #1bbe84)`; -// export const vscBadgeForeground = `var(${VSC_BADGE_FOREGROUND_VAR}, #ffffff)`; -// export const vscCommandCenterActiveBorder = `var(${VSC_COMMAND_CENTER_ACTIVE_BORDER_VAR}, #1bbe84)`; -// export const vscCommandCenterInactiveBorder = `var(${VSC_COMMAND_CENTER_INACTIVE_BORDER_VAR}, #1bbe84)`; -// export const vscFindMatchSelected = `var(${VSC_FIND_MATCH_SELECTED_VAR}, rgba(255, 223, 0))`; - -// Fonts: -// --vscode - editor - font - family; -// --vscode - font - family; - -// Current list of CSS variables needed (e.g. for jetbrains to send!) -// --vscode-sideBar-background -// --vscode-sideBar-foreground -// --vscode-editor-background -// --vscode-editor-foreground -// --vscode-button-background -// --vscode-button-foreground -// --vscode-button-secondaryBackground -// --vscode-button-secondaryForeground -// --vscode-sideBar-border -// --vscode-focusBorder -// --vscode-commandCenter-background -// --vscode-commandCenter-foreground -// --vscode-commandCenter-inactiveBorder -// --vscode-commandCenter-activeBorder -// --vscode-descriptionForeground -// --vscode-list-deemphasizedForeground -// --vscode-input-background -// --vscode-input-foreground -// --vscode-input-border -// --vscode-input-placeholderForeground -// --vscode-tree-tableOddRowsBackground -// --vscode-badge-background -// --vscode-badge-foreground -// --vscode-notebookStatusSuccessIcon-foreground -// --vscode-editorWarning-foreground -// --vscode-editorError-foreground -// --vscode-editor-findMatchBackground -// --vscode-editor-findMatchHighlightBackground -// --vscode-list-hoverBackground -// --vscode-list-activeSelectionBackground -// --vscode-list-activeSelectionForeground +// TODO: add fonts - GUI fonts in jetbrains differ from IDE: +// --vscode-editor-font-family; +// --vscode-font-family; export const THEME_CSS_VARS = Object.values(THEME_COLORS).map( (value) => value.var, diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index a1270a857..5bd3d4462 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -93,7 +93,7 @@ module.exports = { }, // DEPRECATED, slowly remove usages of these ide-named or explicit colors - lightgray: "#999998", // use border, description, or description-muted instead + lightgray: "#999998", // use border, description, or description-muted instead - AVOID AVOID AVOID "vsc-input-background": varWithFallback("input-background"), // use "input-background" instead "vsc-background": varWithFallback("background"), // use "background" instead "vsc-foreground": varWithFallback("foreground"), // use "foreground" instead // NOTE - might want to use editor-foreground From f4d56e6545ed269addf8e0d2a479f8308682fade Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 20 May 2025 22:55:18 -0700 Subject: [PATCH 28/58] jetbrains infrastructure --- core/protocol/ideWebview.ts | 6 +- core/protocol/webview.ts | 2 +- .../continue/GetTheme.kt | 135 +++++++++++----- gui/src/components/index.ts | 4 +- gui/src/hooks/ParallelListeners.tsx | 43 +---- gui/src/styles/ThemePage.tsx | 85 +++++++++- gui/src/styles/theme.ts | 148 +++++++++++++----- gui/tailwind.config.cjs | 10 +- 8 files changed, 300 insertions(+), 133 deletions(-) diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 3c836126a..607b42256 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -2,12 +2,12 @@ import { ToIdeFromWebviewOrCoreProtocol } from "./ide"; import { ToWebviewFromIdeOrCoreProtocol } from "./webview"; import { + AcceptOrRejectDiffPayload, ApplyState, - SetCodeToEditPayload, HighlightedCodePayload, MessageContent, RangeInFileWithContents, - AcceptOrRejectDiffPayload, + SetCodeToEditPayload, } from "../"; export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { @@ -41,7 +41,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { vscMediaUrl: string; }, ]; - "jetbrains/getColors": [undefined, Record]; + "jetbrains/getColors": [undefined, Record]; "vscode/openMoveRightMarkdown": [undefined, void]; setGitHubAuthToken: [{ token: string }, void]; acceptDiff: [AcceptOrRejectDiffPayload, void]; diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index 534517d6f..5ba47e3d4 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -40,7 +40,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { setTTSActive: [boolean, void]; getWebviewHistoryLength: [undefined, number]; getCurrentSessionId: [undefined, string]; - "jetbrains/setColors": [Record, void]; + "jetbrains/setColors": [Record, void]; sessionUpdate: [{ sessionInfo: ControlPlaneSessionInfo | undefined }, void]; toolCallPartialOutput: [{ toolCallId: string; contextItems: any[] }, void]; }; diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index 6aecca81b..249321bf9 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -38,64 +38,117 @@ class GetTheme { return globalScheme.getColor(EditorColors.MODIFIED_TAB_ICON_COLOR) ?: globalScheme.defaultForeground } - fun getTheme(): Map { - fun toHex(color: Color): String { - return String.format("#%02x%02x%02x", color.red, color.green, color.blue) + fun toHex(color: Color?): String? { + if(color == null) { + return null } + return String.format("#%02x%02x%02x", color.red, color.green, color.blue) + } + + fun namedColor(name: String): Color? { + // JB Color named color will fall back to a default unless we give it a fallback + // We want defaults to be handled on the GUI side, so we give it this filler color + // Which has a very low chance of conflicting with a real one + // And return undefined if it gets the skip color + val SKIP_COLOR = Color (18, 52, 86) // Hex #123456 + val color = JBColor.namedColor(name, SKIP_COLOR) + if(toHex(color) == "#123456") { + return null + } + return color + } + + fun getTheme(): Map { try { + // IDE colors val background = JBColor.background() val foreground = JBColor.foreground() - val buttonBackground = JBColor.namedColor("Button.background", Color(230, 230, 230)) - val buttonForeground = JBColor.namedColor("Button.foreground", Color(0, 0, 0)) - - val badgeBackground = JBColor.namedColor("Badge.background", Color(150, 150, 150)) - val badgeForeground = JBColor.namedColor("Badge.foreground", Color(0, 0, 0)) - - val inputBackground = JBColor.namedColor("TextField.background", Color(255, 255, 255)) - val border = JBColor.border() - val focusBorder = JBColor.namedColor("Focus.borderColor", Color(100, 100, 255)) + val focusBorder = namedColor("Focus.borderColor") ?: namedColor("Component.focusedBorderColor") + + val buttonBackground = namedColor("Button.background") + val buttonForeground = namedColor("Button.foreground") + val buttonHoverBackground = namedColor("Button.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") + + val badgeBackground = namedColor("Badge.background") + val badgeForeground = namedColor("Badge.foreground") + + val commandBackground = namedColor("CommandButton.background") ?: namedColor("ToolWindow.background") + val commandForeground = namedColor("CommandButton.foreground") ?: namedColor("ToolWindow.foreground") + + val inputBackground = namedColor("TextField.background") + val inputForeground = namedColor("TextField.foreground") + val inputPlaceholder = namedColor("TextField.inactiveForeground") + + val listHoverBackground = namedColor("List.hoverBackground") ?: namedColor("List.dropLineColor") + val actionHoverBackground = namedColor("ActionButton.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") + val hoverBackground = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") ?: namedColor("List.dropLineColor") + val listSelectionForeground = namedColor("List.selectionForeground") + + + val description = namedColor("Label.infoForeground") ?: namedColor("ToolTip.foreground") + val mutedDescription = namedColor("Label.disabledForeground") + + val link = namedColor("Link.activeForeground") + + val successColor = namedColor("Notification.Success.background") ?: namedColor("ProgressBar.progressColor") + val warningColor = namedColor("Notification.Warning.background") ?: namedColor("ProgressBar.warningColor") + val errorColor = namedColor("ErrorBackground") ?: namedColor("Notification.Error.background") ?: namedColor("ProgressBar.errorColor") + val accentColor = namedColor("Focus.defaultButtonBorderColor") ?: namedColor("Button.default.focusedBorderColor") ?: namedColor("Button.focusedBorderColor") + + // Editor colors val editorScheme = EditorColorsManager.getInstance().globalScheme val editorBackground = editorScheme.defaultBackground val editorForeground = editorScheme.defaultForeground - val actionHoverBackground = JBColor.namedColor("ActionButton.hoverBackground", Color(220, 220, 220)) - - val findMatchBackground = editorScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)?.backgroundColor ?: Color(255, 221, 0) + val findMatchBackground = editorScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)?.backgroundColor + val findMatchSelectedBackground = namedColor("SearchMatch.selectedBackground") ?: + editorScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)?.backgroundColor + + // These should match the keys in GUI's theme.ts val theme = mapOf( - "--vscode-editor-foreground" to toHex(editorForeground), - "--vscode-editor-background" to toHex(editorBackground), - - "--vscode-button-background" to toHex(buttonBackground), - "--vscode-button-foreground" to toHex(buttonForeground), - - "--vscode-list-activeSelectionBackground" to toHex(actionHoverBackground) + "50", - - "--vscode-quickInputList-focusForeground" to toHex(foreground), - "--vscode-quickInput-background" to toHex(inputBackground), - - "--vscode-badge-background" to toHex(badgeBackground), - "--vscode-badge-foreground" to toHex(badgeForeground), - - "--vscode-input-background" to toHex(inputBackground), - "--vscode-input-border" to toHex(border), - "--vscode-sideBar-background" to toHex(background), - "--vscode-sideBar-border" to toHex(border), - "--vscode-focusBorder" to toHex(focusBorder), - - "--vscode-commandCenter-activeBorder" to toHex(focusBorder), - "--vscode-commandCenter-inactiveBorder" to toHex(border), - - "--vscode-editor-findMatchHighlightBackground" to toHex(findMatchBackground) + "40" + "background" to toHex(background), + "foreground" to toHex(foreground), + "editor-background" to toHex(editorBackground), + "editor-foreground" to toHex(editorForeground), + "primary-background" to toHex(buttonBackground), + "primary-foreground" to toHex(buttonForeground), + "primary-hover" to toHex(buttonHoverBackground), + "secondary-background" to toHex(getSecondaryDark()), + "secondary-foreground" to toHex(foreground), + "secondary-hover" to toHex(hoverBackground), + "border" to toHex(border), + "border-focus" to toHex(focusBorder), + "command-background" to toHex(commandBackground), + "command-foreground" to toHex(commandForeground), + "command-border" to toHex(border), // make command specific + "command-border-focus" to toHex(focusBorder), // make command specific + "description" to toHex(description), + "description-muted" to toHex(mutedDescription), + "input-background" to toHex(inputBackground), + "input-foreground" to toHex(inputForeground), + "input-border" to toHex(border), + "input-placeholder" to toHex(inputPlaceholder), + "table-oddRow" to toHex(hoverBackground), + "badge-background" to toHex(badgeBackground), + "badge-foreground" to toHex(badgeForeground), + "success" to toHex(successColor), + "warning" to toHex(warningColor), + "error" to toHex(errorColor), + "link" to toHex(link), + "accent" to toHex(accentColor), + "find-match" to toHex(findMatchBackground) + "40", + "find-match-selected" to toHex(findMatchSelectedBackground), + "list-hover" to toHex(listHoverBackground), + "list-active" to toHex(actionHoverBackground) + "50", + "list-active-foreground" to toHex(listSelectionForeground) ) - return theme } catch (error: Error) { return mapOf() } - } } \ No newline at end of file diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index 3412fe107..a2abd53a4 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -12,7 +12,7 @@ export const vscBackground = varWithFallback("background"); export const vscForeground = varWithFallback("foreground"); export const vscButtonBackground = varWithFallback("primary-background"); export const vscButtonForeground = varWithFallback("primary-foreground"); -export const vscEditorBackground = varWithFallback("editor"); +export const vscEditorBackground = varWithFallback("editor-background"); export const vscListActiveBackground = varWithFallback("list-active"); export const vscFocusBorder = varWithFallback("border-focus"); export const vscListActiveForeground = varWithFallback( @@ -20,7 +20,7 @@ export const vscListActiveForeground = varWithFallback( ); export const vscInputBorder = varWithFallback("input-border"); export const vscInputBorderFocus = varWithFallback("border-focus"); -export const vscBadgeBackground = varWithFallback("badge"); +export const vscBadgeBackground = varWithFallback("badge-background"); export const vscBadgeForeground = varWithFallback("badge-foreground"); export const vscCommandCenterActiveBorder = varWithFallback( "command-border-focus", diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index a0a2fd209..c3f776454 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -28,7 +28,10 @@ import { cancelStream } from "../redux/thunks/cancelStream"; import { refreshSessionMetadata } from "../redux/thunks/session"; import { streamResponseThunk } from "../redux/thunks/streamResponse"; import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols"; -import { THEME_COLORS } from "../styles/theme"; +import { + setDocumentStylesFromLocalStorage, + setDocumentStylesFromTheme, +} from "../styles/theme"; import { isJetBrains } from "../util"; import { setLocalStorage } from "../util/localStorage"; import { useWebviewListener } from "./useWebviewListener"; @@ -139,34 +142,13 @@ function ParallelListeners() { dispatch(cancelStream()); const jetbrains = isJetBrains(); - for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { - const cssVarName = themeVals.var; - if (jetbrains) { - const cached = localStorage.getItem(colorName); - if (cached) { - document.body.style.setProperty(cssVarName, cached); - } - } - - // Remove alpha channel from colors - const value = getComputedStyle(document.documentElement).getPropertyValue( - cssVarName, - ); - if (value.startsWith("#") && value.length > 7) { - document.body.style.setProperty(cssVarName, value.slice(0, 7)); - } - } + setDocumentStylesFromLocalStorage(jetbrains); if (jetbrains) { // Save theme colors to local storage for immediate loading in JetBrains ideMessenger.request("jetbrains/getColors", undefined).then((result) => { if (result.status === "success") { - Object.entries(result.content).forEach(([colorName, value]) => { - const cssVarName = - THEME_COLORS[colorName as keyof typeof THEME_COLORS]?.var; - document.body.style.setProperty(cssVarName, value); - document.documentElement.style.setProperty(cssVarName, value); - }); + setDocumentStylesFromTheme(result.content); } }); @@ -183,24 +165,13 @@ function ParallelListeners() { (window as any).vscMachineId = msg.vscMachineId; (window as any).vscMediaUrl = msg.vscMediaUrl; }); - - for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { - const currentVal = document.body.style.getPropertyValue(themeVals.var); - if (currentVal) { - localStorage.setItem(colorName, currentVal); - } - } } }, []); useWebviewListener( "jetbrains/setColors", async (data) => { - Object.entries(data).forEach(([key, value]) => { - const cssVarName = THEME_COLORS[key as keyof typeof THEME_COLORS]?.var; - document.body.style.setProperty(cssVarName, value); - document.documentElement.style.setProperty(cssVarName, value); - }); + setDocumentStylesFromTheme(data); }, [], ); diff --git a/gui/src/styles/ThemePage.tsx b/gui/src/styles/ThemePage.tsx index c08252b35..a5439a94a 100644 --- a/gui/src/styles/ThemePage.tsx +++ b/gui/src/styles/ThemePage.tsx @@ -3,18 +3,27 @@ import { ExclamationCircleIcon, ExclamationTriangleIcon, } from "@heroicons/react/24/outline"; -import { useState } from "react"; +import { useContext, useEffect, useMemo, useState } from "react"; import { useNavigate } from "react-router-dom"; -import { THEME_COLORS } from "./theme"; +import { Button } from "../components"; +import { IdeMessengerContext } from "../context/IdeMessenger"; +import { isJetBrains } from "../util"; +import { + clearThemeLocalCache, + setDocumentStylesFromTheme, + THEME_COLORS, +} from "./theme"; const ThemeTailwindClassExample = ({ className, varName, defaultColor, + isMissing, }: { className: string; varName: string; defaultColor: string; + isMissing?: boolean; }) => { return ( <> @@ -22,7 +31,7 @@ const ThemeTailwindClassExample = ({ {className}
{ + return isJetBrains(); + }, []); + + const refreshJetbrainsColors = () => { + ideMessenger.request("jetbrains/getColors", undefined).then((result) => { + console.log(result); + if (result.status === "success") { + setDocumentStylesFromTheme(result.content); + } + }); + }; + + const [missingVars, setMissingVars] = useState([]); + const checkMissingClasses = () => { + const missingVars: string[] = []; + Object.entries(THEME_COLORS).forEach(([colorName, themeVals]) => { + const value = getComputedStyle(document.documentElement).getPropertyValue( + themeVals.var, + ); + if (!value) { + missingVars.push(`${colorName}`); //: ${themeVals.var}`); + } + }); + setMissingVars(missingVars); + }; + useEffect(() => { + checkMissingClasses(); + }, []); + return (
Editor
+
+

+ Missing Theme Variables +

+ {missingVars.length > 0 ? ( +
+ {missingVars.map((varName) => ( +
+ {varName} +
+ ))} +
+ ) : ( +
No missing variables
+ )} + +
+ {jetbrains ? ( + <> +

+ Manage Jetbrains Theme +

+
+ + +
+ + ) : null}

All Theme Colors

@@ -121,10 +193,11 @@ function ThemePage() {
Fallback
- {Object.entries(THEME_COLORS).map(([key, val]) => ( + {Object.entries(THEME_COLORS).map(([colorName, val]) => ( diff --git a/gui/src/styles/theme.ts b/gui/src/styles/theme.ts index f9379fc4b..bfa24bbda 100644 --- a/gui/src/styles/theme.ts +++ b/gui/src/styles/theme.ts @@ -1,148 +1,150 @@ // All vscode variables https://gist.github.com/estruyf/ba49203e1a7d6868e9320a4ea480c27a // Examples for vscode https://github.com/githubocto/tailwind-vscode/blob/main/index.js +// The current default theme is dark with blue accents export const THEME_COLORS = { background: { var: "--vscode-sideBar-background", - default: "#1e1e1e", + default: "#1e1e1e", // dark gray }, foreground: { var: "--vscode-sideBar-foreground", // --vscode-editor-foreground - default: "rgba(243, 239, 245)", + default: "#e6e6e6", // light gray }, - editor: { + "editor-background": { var: "--vscode-editor-background", - default: "#1e1e1e", + default: "#1e1e1e", // dark gray }, "editor-foreground": { var: "--vscode-editor-foreground", - default: "#f3eff5", + default: "#e6e6e6", // light gray }, "primary-background": { var: "--vscode-button-background", - default: "#1b3ebe", + default: "#2c5aa0", // medium blue }, "primary-foreground": { var: "--vscode-button-foreground", - default: "#ffffff", + default: "#ffffff", // white }, "primary-hover": { var: "--vscode-button-hoverBackground", - default: "#2847ad", + default: "#3a6db3", // lighter blue }, - secondary: { + "secondary-background": { var: "--vscode-button-secondaryBackground", - default: "rgba(243, 239, 245, 0.2)", + default: "#303030", // medium dark gray }, "secondary-foreground": { var: "--vscode-button-secondaryForeground", - default: "#f3eff5", + default: "#e6e6e6", // light gray }, "secondary-hover": { var: "--vscode-button-secondaryHoverBackground", - default: "rgba(243, 239, 245, 0.2)", + default: "#3a3a3a", // medium gray }, border: { // --vscode-panel-border var: "--vscode-sideBar-border", - default: "#242d34", + default: "#2a2a2a", // dark gray border }, "border-focus": { var: "--vscode-focusBorder", - default: "#263354", + default: "#3a6db3", // lighter blue }, // Command styles are used for tip-tap editor - command: { + "command-background": { var: "--vscode-commandCenter-background", - default: "#141c2d", + default: "#252525", // dark gray }, "command-foreground": { var: "--vscode-commandCenter-foreground", - default: "#f3eff5", + default: "#e6e6e6", // light gray }, "command-border": { var: "--vscode-commandCenter-inactiveBorder", - default: "#999998", + default: "#555555", // medium gray }, "command-border-focus": { var: "--vscode-commandCenter-activeBorder", - default: "#ed1292", + default: "#4d8bf0", // bright blue }, description: { var: "--vscode-descriptionForeground", - default: "rgba(243, 239, 245, 0.7)", + default: "#b3b3b3", // medium light gray }, "description-muted": { var: "--vscode-list-deemphasizedForeground", - default: "#8c8c8c", + default: "#8c8c8c", // medium gray }, "input-background": { var: "--vscode-input-background", - default: "#2d2d2d", + default: "#2d2d2d", // dark gray }, "input-foreground": { var: "--vscode-input-foreground", - default: "#f3eff5", + default: "#e6e6e6", // light gray }, "input-border": { var: "--vscode-input-border", - default: "#999998", + default: "#555555", // medium gray }, "input-placeholder": { var: "--vscode-input-placeholderForeground", - default: "rgba(243, 239, 245, 0.5)", + default: "#9e9e9e", // medium light gray }, "table-oddRow": { var: "--vscode-tree-tableOddRowsBackground", - default: "rgb(45, 45, 45)", + default: "#2d2d2d", // dark gray }, - badge: { + "badge-background": { var: "--vscode-badge-background", - default: "rgb(80, 80, 80)", + default: "#4d4d4d", // medium dark gray }, "badge-foreground": { var: "--vscode-badge-foreground", - default: "#ffffff", + default: "#ffffff", // white }, success: { var: "--vscode-notebookStatusSuccessIcon-foreground", // "var(--vscode-testing-iconPassed, #1bbe84)" // --vscode-charts-green - default: "#1bbe84", + default: "#4caf50", // green }, warning: { var: "--vscode-editorWarning-foreground", // --vscode-list-warningForeground - default: "#ffe45e", + default: "#ffb74d", // amber/yellow }, error: { var: "--vscode-editorError-foreground", // --vscode-list-errorForeground - default: "#fe4a49", + default: "#f44336", // red }, link: { var: "--vscode-textLink-foreground", - default: "#4da6ff", + default: "#5c9ce6", // medium blue }, accent: { var: "--vscode-tab-activeBorderTop", - default: "#ed1292", + default: "#4d8bf0", // bright blue }, "find-match": { var: "--vscode-editor-findMatchBackground", // Can't get "var(--vscode-editor-findMatchBackground, rgba(237, 18, 146, 0.5))" to work - default: "rgba(191, 219, 254, 0.3)", + default: "#264f7840", // translucent blue }, "find-match-selected": { var: "--vscode-editor-findMatchHighlightBackground", - default: "rgba(255, 223, 0, 0.3)", + default: "#ffb74d40", // translucent amber }, "list-hover": { + // --vscode-tab-hoverBackground var: "--vscode-list-hoverBackground", - default: "rgba(243, 239, 245, 0.13)", + default: "#383838", // medium dark gray }, "list-active": { var: "--vscode-list-activeSelectionBackground", - default: "rgba(243, 239, 245, 0.2)", + default: "#2c5aa050", // translucent medium blue }, "list-active-foreground": { var: "--vscode-list-activeSelectionForeground", - default: "#f3eff5", + default: "#ffffff", // white }, }; @@ -172,3 +174,71 @@ export const THEME_DEFAULTS = Object.entries(THEME_COLORS).reduce( export const varWithFallback = (className: keyof typeof THEME_COLORS) => `var(${THEME_COLORS[className].var}, ${THEME_COLORS[className].default})`; + +export const setDocumentStylesFromTheme = ( + theme: Record, +) => { + // Check for missing theme items + const themeKeys = Object.keys(THEME_COLORS); + const missingKeys = themeKeys.filter( + (key) => !Object.keys(theme).includes(key), + ); + if (missingKeys.length > 0) { + console.warn( + `Missing theme keys: ${missingKeys.join(", ")}. Please check theme`, + ); + } + // Write each theme color to the document + Object.entries(theme).forEach(([colorName, value]) => { + if (value) { + const cssVarName = + THEME_COLORS[colorName as keyof typeof THEME_COLORS]?.var; + // TODO VALUE WITHOUT ALPHA CHANNEL + document.body.style.setProperty(cssVarName, value); + document.documentElement.style.setProperty(cssVarName, value); + localStorage.setItem(colorName, value); + } else { + console.warn( + `Theme color ${colorName} is undefined or null. Please check theme. Falling back to defaults.`, + ); + } + }); + + // Cache values in local storage + for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { + const currentVal = document.body.style.getPropertyValue(themeVals.var); + if (currentVal) { + localStorage.setItem(colorName, currentVal); + } + } +}; + +export const setDocumentStylesFromLocalStorage = (checkCache: boolean) => { + for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { + const cssVarName = themeVals.var; + + // Get cached values (for non-vscode IDEs) + if (checkCache) { + const cached = localStorage.getItem(colorName); + if (cached) { + document.body.style.setProperty(cssVarName, cached); + } + } + + // Remove alpha channel from all hex colors besides ones that are expected to have it + if (!colorName.includes("find-match")) { + const value = getComputedStyle(document.documentElement).getPropertyValue( + cssVarName, + ); + if (value.startsWith("#") && value.length > 7) { + document.body.style.setProperty(cssVarName, value.slice(0, 7)); + } + } + } +}; + +export const clearThemeLocalCache = () => { + for (const colorName of Object.keys(THEME_COLORS)) { + localStorage.removeItem(colorName); + } +}; diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index 5bd3d4462..39e4cfc87 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -33,7 +33,7 @@ module.exports = { background: varWithFallback("background"), foreground: varWithFallback("foreground"), editor: { - DEFAULT: varWithFallback("editor"), + DEFAULT: varWithFallback("editor-background"), foreground: varWithFallback("editor-foreground"), }, primary: { @@ -42,7 +42,7 @@ module.exports = { hover: varWithFallback("primary-hover"), }, secondary: { - DEFAULT: varWithFallback("secondary"), + DEFAULT: varWithFallback("secondary-background"), foreground: varWithFallback("secondary-foreground"), hover: varWithFallback("secondary-hover"), }, @@ -51,7 +51,7 @@ module.exports = { focus: varWithFallback("border-focus"), }, command: { - DEFAULT: varWithFallback("command"), + DEFAULT: varWithFallback("command-background"), foreground: varWithFallback("command-foreground"), border: { DEFAULT: varWithFallback("command-border"), @@ -72,7 +72,7 @@ module.exports = { oddRow: varWithFallback("table-oddRow"), }, badge: { - DEFAULT: varWithFallback("badge"), + DEFAULT: varWithFallback("badge-background"), foreground: varWithFallback("badge-foreground"), }, success: varWithFallback("success"), @@ -97,7 +97,7 @@ module.exports = { "vsc-input-background": varWithFallback("input-background"), // use "input-background" instead "vsc-background": varWithFallback("background"), // use "background" instead "vsc-foreground": varWithFallback("foreground"), // use "foreground" instead // NOTE - might want to use editor-foreground - "vsc-editor-background": varWithFallback("editor"), // use "editor" instead + "vsc-editor-background": varWithFallback("editor-background"), // use "editor" instead "vsc-input-border": varWithFallback("input-border"), // use "input-border" instead }, }, From 6eccee3f80007bb6e630eb2a8a1ea87fd90d00b8 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 20 May 2025 23:54:29 -0700 Subject: [PATCH 29/58] gs --- gui/src/components/TabBar/TabBar.tsx | 4 +- gui/src/index.css | 4 +- gui/src/styles/ThemePage.tsx | 89 ++++++++++----- gui/src/styles/theme.ts | 163 +++++++++++++++------------ 4 files changed, 152 insertions(+), 108 deletions(-) diff --git a/gui/src/components/TabBar/TabBar.tsx b/gui/src/components/TabBar/TabBar.tsx index 2fe905674..be8c53213 100644 --- a/gui/src/components/TabBar/TabBar.tsx +++ b/gui/src/components/TabBar/TabBar.tsx @@ -22,8 +22,8 @@ const tabBackgroundVar = varWithFallback("background"); // --vscode-tab-inactive const tabForegroundVar = varWithFallback("foreground"); // --vscode-tab-inactiveForeground const tabHoverBackgroundVar = varWithFallback("list-hover"); // --vscode-tab-hoverBackground const tabHoverForegroundVar = varWithFallback("foreground"); // --vscode-tab-hoverForeground -const tabSelectedBackgroundVar = varWithFallback("list-hover"); // --vscode-tab-activeBackground -const tabSelectedForegroundVar = varWithFallback("list-active-foreground"); // --vscode-tab-activeForeground +const tabSelectedBackgroundVar = varWithFallback("background"); // --vscode-tab-activeBackground +const tabSelectedForegroundVar = varWithFallback("foreground"); // --vscode-tab-activeForeground const tabAccentVar = varWithFallback("accent"); // --vscode-tab-activeBorderTop const TabBarContainer = styled.div` diff --git a/gui/src/index.css b/gui/src/index.css index 34d0d004f..68f8861f2 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -25,7 +25,7 @@ body, #root { height: 100%; line-height: 1.3; - background-color: var(--vscode-sideBar-background); + /* background-color: var(--vscode-sideBar-background); */ font-family: system-ui, -apple-system, @@ -42,7 +42,7 @@ body, body { padding: 0; - color: var(--vscode-sideBar-foreground); + /* color: var(--vscode-sideBar-foreground); */ padding: 0px; margin: 0px; height: 100%; diff --git a/gui/src/styles/ThemePage.tsx b/gui/src/styles/ThemePage.tsx index a5439a94a..564155bfe 100644 --- a/gui/src/styles/ThemePage.tsx +++ b/gui/src/styles/ThemePage.tsx @@ -8,35 +8,39 @@ import { useNavigate } from "react-router-dom"; import { Button } from "../components"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { isJetBrains } from "../util"; +import { ROUTES } from "../util/navigation"; import { clearThemeLocalCache, setDocumentStylesFromTheme, THEME_COLORS, + varWithFallback, } from "./theme"; const ThemeTailwindClassExample = ({ - className, - varName, + colorName, + varNames, defaultColor, isMissing, }: { - className: string; - varName: string; + colorName: string; + varNames: string[]; defaultColor: string; isMissing?: boolean; }) => { return ( <>
- {className} + {colorName}
- {varName} + {varNames.join(", ")}
{ const missingVars: string[] = []; Object.entries(THEME_COLORS).forEach(([colorName, themeVals]) => { - const value = getComputedStyle(document.documentElement).getPropertyValue( - themeVals.var, - ); - if (!value) { - missingVars.push(`${colorName}`); //: ${themeVals.var}`); + let found = false; + themeVals.vars.forEach((cssVar) => { + const value = getComputedStyle( + document.documentElement, + ).getPropertyValue(cssVar); + if (value) { + found = true; + } + }); + if (!found) { + missingVars.push(colorName); } }); setMissingVars(missingVars); @@ -88,7 +98,7 @@ function ThemePage() {
navigate("/more")} + onClick={() => navigate(ROUTES.HOME)} > ← Back to Settings @@ -117,7 +127,7 @@ function ThemePage() {
@@ -125,30 +135,49 @@ function ThemePage() { Badge
-
-
- - Success -
-
- - Warning -
-
- - Error -
+
+ + Success +
+
+ + Warning +
+
+ + Error
setListToggled(!listToggled)} className={`cursor-pointer p-2 ${listToggled ? "bg-list-active text-list-active-foreground" : "bg-background text-foreground hover:bg-list-hover"}`} > - List item (click to select) + List item (clickable)
Editor
+ + + + + + + + + +
+ even table row +
+ odd table row +
+
+ Link +
+
+ find match + current match +

@@ -197,9 +226,9 @@ function ThemePage() { ))}

diff --git a/gui/src/styles/theme.ts b/gui/src/styles/theme.ts index bfa24bbda..64238d410 100644 --- a/gui/src/styles/theme.ts +++ b/gui/src/styles/theme.ts @@ -4,146 +4,157 @@ // The current default theme is dark with blue accents export const THEME_COLORS = { background: { - var: "--vscode-sideBar-background", + vars: [ + "--vscode-sideBar-background", + "--vscode-panel-background", + "--vscode-editor-background", + ], default: "#1e1e1e", // dark gray }, foreground: { - var: "--vscode-sideBar-foreground", // --vscode-editor-foreground + vars: [ + "--vscode-sideBar-foreground", + "--vscode-editor-foreground", + "--vscode-panel-foreground", + ], // --vscode-editor-foreground default: "#e6e6e6", // light gray }, "editor-background": { - var: "--vscode-editor-background", + vars: ["--vscode-editor-background"], default: "#1e1e1e", // dark gray }, "editor-foreground": { - var: "--vscode-editor-foreground", + vars: ["--vscode-editor-foreground"], default: "#e6e6e6", // light gray }, "primary-background": { - var: "--vscode-button-background", + vars: ["--vscode-button-background"], default: "#2c5aa0", // medium blue }, "primary-foreground": { - var: "--vscode-button-foreground", + vars: ["--vscode-button-foreground"], default: "#ffffff", // white }, "primary-hover": { - var: "--vscode-button-hoverBackground", + vars: ["--vscode-button-hoverBackground"], default: "#3a6db3", // lighter blue }, "secondary-background": { - var: "--vscode-button-secondaryBackground", + vars: ["--vscode-button-secondaryBackground"], default: "#303030", // medium dark gray }, "secondary-foreground": { - var: "--vscode-button-secondaryForeground", + vars: ["--vscode-button-secondaryForeground"], default: "#e6e6e6", // light gray }, "secondary-hover": { - var: "--vscode-button-secondaryHoverBackground", + vars: ["--vscode-button-secondaryHoverBackground"], default: "#3a3a3a", // medium gray }, border: { - // --vscode-panel-border - var: "--vscode-sideBar-border", + vars: ["--vscode-sideBar-border", "--vscode-panel-border"], default: "#2a2a2a", // dark gray border }, "border-focus": { - var: "--vscode-focusBorder", + vars: ["--vscode-focusBorder"], default: "#3a6db3", // lighter blue }, // Command styles are used for tip-tap editor "command-background": { - var: "--vscode-commandCenter-background", + vars: ["--vscode-commandCenter-background"], default: "#252525", // dark gray }, "command-foreground": { - var: "--vscode-commandCenter-foreground", + vars: ["--vscode-commandCenter-foreground"], default: "#e6e6e6", // light gray }, "command-border": { - var: "--vscode-commandCenter-inactiveBorder", + vars: ["--vscode-commandCenter-inactiveBorder"], default: "#555555", // medium gray }, "command-border-focus": { - var: "--vscode-commandCenter-activeBorder", + vars: ["--vscode-commandCenter-activeBorder"], default: "#4d8bf0", // bright blue }, description: { - var: "--vscode-descriptionForeground", + vars: ["--vscode-descriptionForeground"], default: "#b3b3b3", // medium light gray }, "description-muted": { - var: "--vscode-list-deemphasizedForeground", + vars: ["--vscode-list-deemphasizedForeground"], default: "#8c8c8c", // medium gray }, "input-background": { - var: "--vscode-input-background", + vars: ["--vscode-input-background"], default: "#2d2d2d", // dark gray }, "input-foreground": { - var: "--vscode-input-foreground", + vars: ["--vscode-input-foreground"], default: "#e6e6e6", // light gray }, "input-border": { - var: "--vscode-input-border", + vars: [ + "--vscode-input-border", + "--vscode-commandCenter-inactiveBorder", + "vscode-border", + ], default: "#555555", // medium gray }, "input-placeholder": { - var: "--vscode-input-placeholderForeground", + vars: ["--vscode-input-placeholderForeground"], default: "#9e9e9e", // medium light gray }, "table-oddRow": { - var: "--vscode-tree-tableOddRowsBackground", + vars: ["--vscode-tree-tableOddRowsBackground"], default: "#2d2d2d", // dark gray }, "badge-background": { - var: "--vscode-badge-background", + vars: ["--vscode-badge-background"], default: "#4d4d4d", // medium dark gray }, "badge-foreground": { - var: "--vscode-badge-foreground", + vars: ["--vscode-badge-foreground"], default: "#ffffff", // white }, success: { - var: "--vscode-notebookStatusSuccessIcon-foreground", // "var(--vscode-testing-iconPassed, #1bbe84)" // --vscode-charts-green + vars: ["--vscode-notebookStatusSuccessIcon-foreground"], // "var(--vscode-testing-iconPassed, #1bbe84)" // --vscode-charts-green default: "#4caf50", // green }, warning: { - var: "--vscode-editorWarning-foreground", // --vscode-list-warningForeground + vars: ["--vscode-editorWarning-foreground"], // --vscode-list-warningForeground default: "#ffb74d", // amber/yellow }, error: { - var: "--vscode-editorError-foreground", // --vscode-list-errorForeground + vars: ["--vscode-editorError-foreground"], // --vscode-list-errorForeground default: "#f44336", // red }, link: { - var: "--vscode-textLink-foreground", + vars: ["--vscode-textLink-foreground"], default: "#5c9ce6", // medium blue }, accent: { - var: "--vscode-tab-activeBorderTop", + vars: ["--vscode-tab-activeBorderTop", "--vscode-focusBorder"], default: "#4d8bf0", // bright blue }, "find-match": { - var: "--vscode-editor-findMatchBackground", // Can't get "var(--vscode-editor-findMatchBackground, rgba(237, 18, 146, 0.5))" to work + vars: ["--vscode-editor-findMatchBackground"], // Can't get "var(--vscode-editor-findMatchBackground, rgba(237, 18, 146, 0.5))" to work default: "#264f7840", // translucent blue }, "find-match-selected": { - var: "--vscode-editor-findMatchHighlightBackground", + vars: ["--vscode-editor-findMatchHighlightBackground"], default: "#ffb74d40", // translucent amber }, "list-hover": { // --vscode-tab-hoverBackground - var: "--vscode-list-hoverBackground", + vars: ["--vscode-list-hoverBackground"], default: "#383838", // medium dark gray }, "list-active": { - var: "--vscode-list-activeSelectionBackground", + vars: ["--vscode-list-activeSelectionBackground"], default: "#2c5aa050", // translucent medium blue }, "list-active-foreground": { - var: "--vscode-list-activeSelectionForeground", + vars: ["--vscode-list-activeSelectionForeground"], default: "#ffffff", // white }, }; @@ -151,14 +162,15 @@ export const THEME_COLORS = { // TODO: add fonts - GUI fonts in jetbrains differ from IDE: // --vscode-editor-font-family; // --vscode-font-family; - -export const THEME_CSS_VARS = Object.values(THEME_COLORS).map( - (value) => value.var, -); +export const THEME_CSS_VARS = Object.values(THEME_COLORS) + .map((value) => value.vars) + .flat(); export const THEME_CSS_VAR_DEFAULTS = Object.entries(THEME_COLORS).reduce( (acc, [_, value]) => { - acc[value.var] = value.default; + value.vars.forEach((varName) => { + acc[varName] = value.default; + }); return acc; }, {} as Record, @@ -172,8 +184,12 @@ export const THEME_DEFAULTS = Object.entries(THEME_COLORS).reduce( {} as Record, ); -export const varWithFallback = (className: keyof typeof THEME_COLORS) => - `var(${THEME_COLORS[className].var}, ${THEME_COLORS[className].default})`; +// Generates recursive CSS variable fallback for a given color name +// e.g. var(--vscode-button-background, var(--vscode-button-foreground, #ffffff)) +export const varWithFallback = (colorName: keyof typeof THEME_COLORS) => + THEME_COLORS[colorName].vars.reduce((curr, varName) => { + return `var(${varName}, ${curr})`; + }, THEME_COLORS[colorName].default); export const setDocumentStylesFromTheme = ( theme: Record, @@ -191,47 +207,46 @@ export const setDocumentStylesFromTheme = ( // Write each theme color to the document Object.entries(theme).forEach(([colorName, value]) => { if (value) { - const cssVarName = - THEME_COLORS[colorName as keyof typeof THEME_COLORS]?.var; - // TODO VALUE WITHOUT ALPHA CHANNEL - document.body.style.setProperty(cssVarName, value); - document.documentElement.style.setProperty(cssVarName, value); - localStorage.setItem(colorName, value); + const themeVals = THEME_COLORS[colorName as keyof typeof THEME_COLORS]; + if (!themeVals) { + console.warn( + `Receieved theme color ${colorName} which is not used by the theme`, + ); + return; + } + + // Remove alpha channel from all hex colors besides ones that are expected to have it + let colorVal = value; + if ( + !colorName.includes("find-match") && + colorVal.startsWith("#") && + value.length > 7 + ) { + colorVal = colorVal.slice(0, 7); + } + + localStorage.setItem(colorName, colorVal); + for (const cssVar of themeVals.vars) { + document.body.style.setProperty(cssVar, colorVal); + document.documentElement.style.setProperty(cssVar, colorVal); + } } else { console.warn( `Theme color ${colorName} is undefined or null. Please check theme. Falling back to defaults.`, ); } }); - - // Cache values in local storage - for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { - const currentVal = document.body.style.getPropertyValue(themeVals.var); - if (currentVal) { - localStorage.setItem(colorName, currentVal); - } - } }; export const setDocumentStylesFromLocalStorage = (checkCache: boolean) => { for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { - const cssVarName = themeVals.var; - - // Get cached values (for non-vscode IDEs) - if (checkCache) { - const cached = localStorage.getItem(colorName); - if (cached) { - document.body.style.setProperty(cssVarName, cached); - } - } - - // Remove alpha channel from all hex colors besides ones that are expected to have it - if (!colorName.includes("find-match")) { - const value = getComputedStyle(document.documentElement).getPropertyValue( - cssVarName, - ); - if (value.startsWith("#") && value.length > 7) { - document.body.style.setProperty(cssVarName, value.slice(0, 7)); + for (const cssVar of themeVals.vars) { + // Get cached values (for non-vscode IDEs) + if (checkCache) { + const cached = localStorage.getItem(colorName); + if (cached) { + document.body.style.setProperty(cssVar, cached); + } } } } From 862c49340f0b39138afbe3aada1be35721b1a9cc Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 20 May 2025 23:54:36 -0700 Subject: [PATCH 30/58] fix syntax error --- gui/src/components/dialogs/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gui/src/components/dialogs/index.tsx b/gui/src/components/dialogs/index.tsx index c4a80e0b4..d205d59f8 100644 --- a/gui/src/components/dialogs/index.tsx +++ b/gui/src/components/dialogs/index.tsx @@ -8,8 +8,7 @@ import { vscBackground, vscForeground, } from ".."; -import { THEME_COLORS } from "../../styles/theme"; -import { parseColorForHex } from "../../styles/utils"; +import { varWithFallback } from "../../styles/theme"; interface TextDialogProps { showDialog: boolean; @@ -22,7 +21,7 @@ const ScreenCover = styled.div` position: fixed; width: 100%; height: 100%; - background-color: ${parseColorForHex(THEME_COLORS["background"].var)}aa; + background-color: ${varWithFallback("background")}aa; z-index: 100000; flex-direction: column; `; From ab414e2e411d2a398ca3b3da78a2f1bd25442750 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 21 May 2025 00:04:52 -0700 Subject: [PATCH 31/58] cleanup --- gui/src/components/modelSelection/platform/shared.tsx | 2 +- gui/src/index.css | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/gui/src/components/modelSelection/platform/shared.tsx b/gui/src/components/modelSelection/platform/shared.tsx index 8ae0f4c6f..b617fd34e 100644 --- a/gui/src/components/modelSelection/platform/shared.tsx +++ b/gui/src/components/modelSelection/platform/shared.tsx @@ -146,7 +146,7 @@ export function Option({ diff --git a/gui/src/index.css b/gui/src/index.css index 68f8861f2..d4e5e12b8 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -25,7 +25,6 @@ body, #root { height: 100%; line-height: 1.3; - /* background-color: var(--vscode-sideBar-background); */ font-family: system-ui, -apple-system, @@ -42,7 +41,6 @@ body, body { padding: 0; - /* color: var(--vscode-sideBar-foreground); */ padding: 0px; margin: 0px; height: 100%; From 0d940ec6d1377b38945bd6217040cd025f89a80c Mon Sep 17 00:00:00 2001 From: Saim Date: Wed, 21 May 2025 16:41:00 +0530 Subject: [PATCH 32/58] fix: add unit tests for commandExtractor and improve multiline comment handling --- .../RunInTerminalButton.tsx | 37 +-------- .../utils/commandExtractor.test.ts | 80 +++++++++++++++++++ .../utils/commandExtractor.ts | 50 ++++++++++++ 3 files changed, 131 insertions(+), 36 deletions(-) create mode 100644 gui/src/components/StyledMarkdownPreview/utils/commandExtractor.test.ts create mode 100644 gui/src/components/StyledMarkdownPreview/utils/commandExtractor.ts diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx index 98deb4879..da0e439c0 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx @@ -3,6 +3,7 @@ import { useContext } from "react"; import { lightGray, vscForeground } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { isJetBrains } from "../../../util"; +import { extractCommand } from "../utils/commandExtractor"; interface RunInTerminalButtonProps { command: string; @@ -16,42 +17,6 @@ export function RunInTerminalButton({ command }: RunInTerminalButtonProps) { return null; } - // Extract just the command line (the line after $ or the first line) - function extractCommand(cmd: string): string { - // First handle the $ prompt case, extract the line after it - if (cmd.includes("$")) { - const match = cmd.match(/\$\s*([^\n]+)/); - if (match) { - return match[1].trim(); - } - } - - // Process all lines, filtering out comments and empty lines - const lines = cmd.split("\n") - .map(line => line.trim()) - .filter(line => - line && - !line.startsWith("#") && - !line.startsWith("//") && - !line.startsWith("/*") - ); - - // Handle multi-line commands - let result = ""; - for (let i = 0; i < lines.length; i++) { - const line = lines[i]; - result += line; - - // Add space for command continuation - if (line.endsWith("&&") || line.endsWith("|") || line.endsWith("\\")) { - result += " "; - } else if (i < lines.length - 1) { - result += " "; - } - } - return result.trim(); - } - function runInTerminal() { // Extract just the command line const extractedCommand = extractCommand(command); diff --git a/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.test.ts b/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.test.ts new file mode 100644 index 000000000..1d1d6099c --- /dev/null +++ b/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.test.ts @@ -0,0 +1,80 @@ +import { extractCommand } from './commandExtractor'; + +describe('extractCommand', () => { + // Test basic command extraction + it('should extract command from $ prompt', () => { + expect(extractCommand('$ echo hello')).toBe('echo hello'); + expect(extractCommand('$ echo hello')).toBe('echo hello'); + expect(extractCommand('$echo hello')).toBe('echo hello'); + }); + + // Test comment removal + it('should remove comments at beginning of lines', () => { + expect(extractCommand('# shell comment\necho hello')).toBe('echo hello'); + expect(extractCommand('// js comment\necho hello')).toBe('echo hello'); + expect(extractCommand('/* multi-line\ncomment */\necho hello')).toBe('echo hello'); + }); + + // Test multiline comment removal + it('should remove multiline comments anywhere in the text', () => { + expect(extractCommand('echo /* comment */ hello')).toBe('echo hello'); + expect(extractCommand('echo hello /* comment */')).toBe('echo hello'); + expect(extractCommand('echo /* multiple\nline\ncomment */ hello')).toBe('echo hello'); + }); + + // Test line continuation handling + it('should handle line continuations correctly', () => { + expect(extractCommand('echo hello && \\\necho world')).toBe('echo hello && echo world'); + expect(extractCommand('echo hello | \\\ngrep h')).toBe('echo hello | grep h'); + expect(extractCommand('echo hello \\\nworld')).toBe('echo hello world'); + }); + + // Test complex command combinations + it('should handle complex command combinations', () => { + expect(extractCommand(` + # shell comment + echo hello /* inline comment */ && \\ + // js comment + echo world + `)).toBe('echo hello && echo world'); + }); + + // Test empty and whitespace handling + it('should handle empty and whitespace inputs', () => { + expect(extractCommand('')).toBe(''); + expect(extractCommand(' \n \t ')).toBe(''); + }); + + // Test comment-only inputs + it('should handle comment-only inputs', () => { + expect(extractCommand('/* comment */')).toBe(''); + expect(extractCommand('# comment')).toBe(''); + expect(extractCommand('// comment')).toBe(''); + expect(extractCommand('/* multi\nline\ncomment */')).toBe(''); + }); + + // Test inline comments + it('should handle inline comments correctly according to implementation', () => { + // But removes multiline comments even when inline + expect(extractCommand('/* inline */ echo hello world')).toBe('echo hello world'); + }); + + // Test multiple line continuations + it('should handle multiple line continuations', () => { + expect(extractCommand(` + echo hello && \\ + echo world && \\ + echo test + `)).toBe('echo hello && echo world && echo test'); + }); + + // Test nested line continuations + it('should handle nested line continuations', () => { + expect(extractCommand(` + echo hello && \\ + (echo nested && \\ + echo more) && \\ + echo final + `)).toBe('echo hello && (echo nested && echo more) && echo final'); + }); +}); \ No newline at end of file diff --git a/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.ts b/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.ts new file mode 100644 index 000000000..35075b6bd --- /dev/null +++ b/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.ts @@ -0,0 +1,50 @@ +/** + * Extracts and processes command strings, handling comments and line continuations. + * @param cmd The command string to process + * @returns The processed command string + */ +export function extractCommand(cmd: string): string { + if (!cmd || cmd.trim() === '') { + return ''; + } + + // Remove multi-line comments (/* ... */) and replace with a single space + cmd = cmd.replace(/\/\*[\s\S]*?\*\//g, " "); + + // Handle the $ prompt case first + if (cmd.includes("$")) { + const match = cmd.match(/\$\s*([^\n]+)/); + if (match) { + // Return just the command after $ without further processing + return match[1].trim(); + } + } + + // Process lines - remove single-line comments only at beginning of lines + const lines = cmd.split('\n') + .map(line => line.replace(/^\s*#.*$/, '').replace(/^\s*\/\/.*$/, '')) + .map(line => line.trim()) + .filter(line => line); + + // Join lines with proper handling of continuations + let result = ''; + for (let i = 0; i < lines.length; i++) { + let line = lines[i]; + + // Remove trailing continuation characters and join with next line + while ( + (line.endsWith('&&') || line.endsWith('|') || line.endsWith('\\')) && + i < lines.length - 1 + ) { + // Remove the continuation character(s) and any trailing spaces + line = line.replace(/(&&|\||\\)\s*$/, '').trim(); + // Join with the next line + i++; + line += ' ' + lines[i]; + } + + result += line + ' '; + } + + return result.trim().replace(/\s+/g, ' '); +} \ No newline at end of file From 6a675d8edce1e430faa32b5142554bf61b843e0a Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 21 May 2025 10:17:52 -0700 Subject: [PATCH 33/58] fix: broken link --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 2657b6258..731a8ce40 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -105,7 +105,7 @@ "continue.enableQuickActions": { "type": "boolean", "default": false, - "markdownDescription": "Enable the experimental Quick Actions feature. Read our walkthrough to learn about configuration and how to share feedback: [continue.dev › Walkthrough: Quick Actions (experimental)](https://docs.continue.dev/features/quick-actions)" + "markdownDescription": "Enable the experimental Quick Actions feature. Read our walkthrough to learn about configuration and how to share feedback: [continue.dev › Walkthrough: Quick Actions (experimental)](https://docs.continue.dev/customize/deep-dives/vscode-actions#quick-actions)" }, "continue.enableTabAutocomplete": { "type": "boolean", From 887bd1d02868308ec1af223b4f278278178834a7 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 21 May 2025 11:05:23 -0700 Subject: [PATCH 34/58] add theme recursive test --- .../continue/GetTheme.kt | 96 ++++++++++--------- gui/src/components/find/FindWidget.tsx | 2 +- gui/src/index.css | 2 + gui/src/styles/ThemePage.tsx | 10 +- gui/src/styles/theme.test.ts | 24 +++++ gui/src/styles/theme.ts | 27 +++--- gui/tailwind.config.cjs | 4 +- 7 files changed, 104 insertions(+), 61 deletions(-) create mode 100644 gui/src/styles/theme.test.ts diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index 249321bf9..7fbc21cf4 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -2,6 +2,7 @@ package com.github.continuedev.continueintellijextension.`continue` import com.intellij.openapi.editor.colors.EditorColors import com.intellij.openapi.editor.colors.EditorColorsManager +import com.intellij.openapi.editor.colors.CodeInsightColors import java.awt.Color import kotlin.math.max import kotlin.math.min @@ -60,6 +61,8 @@ class GetTheme { fun getTheme(): Map { try { + val editorScheme = EditorColorsManager.getInstance().globalScheme + // IDE colors val background = JBColor.background() val foreground = JBColor.foreground() @@ -69,8 +72,7 @@ class GetTheme { val buttonBackground = namedColor("Button.background") val buttonForeground = namedColor("Button.foreground") - val buttonHoverBackground = namedColor("Button.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") - + val buttonHoverBackground = namedColor("Button.hoverBackground") ?: buttonBackground?.brighter() val badgeBackground = namedColor("Badge.background") val badgeForeground = namedColor("Badge.foreground") @@ -83,7 +85,8 @@ class GetTheme { val listHoverBackground = namedColor("List.hoverBackground") ?: namedColor("List.dropLineColor") val actionHoverBackground = namedColor("ActionButton.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") - val hoverBackground = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") ?: namedColor("List.dropLineColor") + val hoverBackground = namedColor("List.dropLineColor") + val tableOddRow = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") ?: hoverBackground val listSelectionForeground = namedColor("List.selectionForeground") @@ -92,13 +95,16 @@ class GetTheme { val link = namedColor("Link.activeForeground") - val successColor = namedColor("Notification.Success.background") ?: namedColor("ProgressBar.progressColor") - val warningColor = namedColor("Notification.Warning.background") ?: namedColor("ProgressBar.warningColor") - val errorColor = namedColor("ErrorBackground") ?: namedColor("Notification.Error.background") ?: namedColor("ProgressBar.errorColor") - val accentColor = namedColor("Focus.defaultButtonBorderColor") ?: namedColor("Button.default.focusedBorderColor") ?: namedColor("Button.focusedBorderColor") + val successColor = namedColor("ValidationSuccess.successColor") + ?: namedColor("Component.successForeground") + ?: namedColor("Label.successForeground") + val warningColor = namedColor("ValidationWarning.warningColor") + ?: EditorColorsManager.getInstance().globalScheme.getAttributes(CodeInsightColors.WARNINGS_ATTRIBUTES)?.effectColor + ?: namedColor("Component.warningForeground") + ?: namedColor("Label.warningForeground") - // Editor colors - val editorScheme = EditorColorsManager.getInstance().globalScheme + val errorColor = namedColor("ValidationError.errorColor") ?: namedColor("Component.errorForeground") ?: namedColor("Label.errorForeground") + val accentColor = namedColor("Focus.defaultButtonBorderColor") ?: namedColor("Button.default.focusedBorderColor") ?: namedColor("Button.focusedBorderColor") val editorBackground = editorScheme.defaultBackground val editorForeground = editorScheme.defaultForeground @@ -110,42 +116,42 @@ class GetTheme { // These should match the keys in GUI's theme.ts val theme = mapOf( - "background" to toHex(background), - "foreground" to toHex(foreground), - "editor-background" to toHex(editorBackground), - "editor-foreground" to toHex(editorForeground), - "primary-background" to toHex(buttonBackground), - "primary-foreground" to toHex(buttonForeground), - "primary-hover" to toHex(buttonHoverBackground), - "secondary-background" to toHex(getSecondaryDark()), - "secondary-foreground" to toHex(foreground), - "secondary-hover" to toHex(hoverBackground), - "border" to toHex(border), - "border-focus" to toHex(focusBorder), - "command-background" to toHex(commandBackground), - "command-foreground" to toHex(commandForeground), - "command-border" to toHex(border), // make command specific - "command-border-focus" to toHex(focusBorder), // make command specific - "description" to toHex(description), - "description-muted" to toHex(mutedDescription), - "input-background" to toHex(inputBackground), - "input-foreground" to toHex(inputForeground), - "input-border" to toHex(border), - "input-placeholder" to toHex(inputPlaceholder), - "table-oddRow" to toHex(hoverBackground), - "badge-background" to toHex(badgeBackground), - "badge-foreground" to toHex(badgeForeground), - "success" to toHex(successColor), - "warning" to toHex(warningColor), - "error" to toHex(errorColor), - "link" to toHex(link), - "accent" to toHex(accentColor), - "find-match" to toHex(findMatchBackground) + "40", - "find-match-selected" to toHex(findMatchSelectedBackground), - "list-hover" to toHex(listHoverBackground), - "list-active" to toHex(actionHoverBackground) + "50", - "list-active-foreground" to toHex(listSelectionForeground) - ) + "background" to background, + "foreground" to foreground, + "editor-background" to editorBackground, + "editor-foreground" to editorForeground, + "primary-background" to buttonBackground, + "primary-foreground" to buttonForeground, + "primary-hover" to buttonHoverBackground, + "secondary-background" to getSecondaryDark(), + "secondary-foreground" to foreground, + "secondary-hover" to hoverBackground, + "border" to border, + "border-focus" to focusBorder, + "command-background" to commandBackground, + "command-foreground" to commandForeground, + "command-border" to border, + "command-border-focus" to focusBorder, + "description" to description, + "description-muted" to mutedDescription, + "input-background" to inputBackground, + "input-foreground" to inputForeground, + "input-border" to border, + "input-placeholder" to inputPlaceholder, + "table-oddRow" to tableOddRow, + "badge-background" to badgeBackground, + "badge-foreground" to badgeForeground, + "success" to successColor, + "warning" to warningColor, + "error" to errorColor, + "link" to link, + "accent" to accentColor, + "find-match" to findMatchBackground, + "find-match-selected" to findMatchSelectedBackground, + "list-hover" to listHoverBackground, + "list-active" to actionHoverBackground, + "list-active-foreground" to listSelectionForeground + ).mapValues { toHex(it.value) } return theme } catch (error: Error) { return mapOf() diff --git a/gui/src/components/find/FindWidget.tsx b/gui/src/components/find/FindWidget.tsx index c5a245d8f..ab79cb4dc 100644 --- a/gui/src/components/find/FindWidget.tsx +++ b/gui/src/components/find/FindWidget.tsx @@ -41,7 +41,7 @@ const HighlightOverlay = (props: HighlightOverlayProps) => { const { isCurrent, top, left, width, height } = props; return (
← Back to Settings - +

+ Theme Tester +

Normal text

@@ -178,6 +180,10 @@ function ThemePage() { find match current match
+
+ Accent +
+

@@ -214,7 +220,7 @@ function ThemePage() {

All Theme Colors

- Tailwind Class + Theme Color
CSS Var diff --git a/gui/src/styles/theme.test.ts b/gui/src/styles/theme.test.ts new file mode 100644 index 000000000..f65dd7583 --- /dev/null +++ b/gui/src/styles/theme.test.ts @@ -0,0 +1,24 @@ +import { getRecursiveVar } from "./theme"; + +test("getRecursiveVar returns single var with default for one variable", () => { + const vars = ["--test-var"]; + const defaultColor = "#ffffff"; + const result = getRecursiveVar(vars, defaultColor); + expect(result).toBe("var(--test-var, #ffffff)"); +}); + +test("getRecursiveVar returns nested vars in correct order for multiple variables", () => { + const vars = ["--first-var", "--second-var", "--third-var"]; + const defaultColor = "#000000"; + const result = getRecursiveVar(vars, defaultColor); + expect(result).toBe( + "var(--first-var, var(--second-var, var(--third-var, #000000)))", + ); +}); + +test("getRecursiveVar handles empty vars array", () => { + const vars: string[] = []; + const defaultColor = "#123456"; + const result = getRecursiveVar(vars, defaultColor); + expect(result).toBe("#123456"); +}); diff --git a/gui/src/styles/theme.ts b/gui/src/styles/theme.ts index 64238d410..dc5475dcb 100644 --- a/gui/src/styles/theme.ts +++ b/gui/src/styles/theme.ts @@ -6,8 +6,8 @@ export const THEME_COLORS = { background: { vars: [ "--vscode-sideBar-background", - "--vscode-panel-background", "--vscode-editor-background", + "--vscode-panel-background", ], default: "#1e1e1e", // dark gray }, @@ -16,7 +16,7 @@ export const THEME_COLORS = { "--vscode-sideBar-foreground", "--vscode-editor-foreground", "--vscode-panel-foreground", - ], // --vscode-editor-foreground + ], default: "#e6e6e6", // light gray }, "editor-background": { @@ -186,10 +186,19 @@ export const THEME_DEFAULTS = Object.entries(THEME_COLORS).reduce( // Generates recursive CSS variable fallback for a given color name // e.g. var(--vscode-button-background, var(--vscode-button-foreground, #ffffff)) -export const varWithFallback = (colorName: keyof typeof THEME_COLORS) => - THEME_COLORS[colorName].vars.reduce((curr, varName) => { +export const getRecursiveVar = (vars: string[], defaultColor: string) => { + return vars.reverse().reduce((curr, varName) => { return `var(${varName}, ${curr})`; - }, THEME_COLORS[colorName].default); + }, defaultColor); +}; + +export const varWithFallback = (colorName: keyof typeof THEME_COLORS) => { + const themeVals = THEME_COLORS[colorName]; + if (!themeVals) { + throw new Error(`Invalid theme color name ${colorName}`); + } + return getRecursiveVar(themeVals.vars, themeVals.default); +}; export const setDocumentStylesFromTheme = ( theme: Record, @@ -215,13 +224,9 @@ export const setDocumentStylesFromTheme = ( return; } - // Remove alpha channel from all hex colors besides ones that are expected to have it + // Remove alpha channel from all hex colors (seems to cause bad colors) let colorVal = value; - if ( - !colorName.includes("find-match") && - colorVal.startsWith("#") && - value.length > 7 - ) { + if (colorVal.startsWith("#") && value.length > 7) { colorVal = colorVal.slice(0, 7); } diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index 39e4cfc87..ed91cee11 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -93,10 +93,10 @@ module.exports = { }, // DEPRECATED, slowly remove usages of these ide-named or explicit colors - lightgray: "#999998", // use border, description, or description-muted instead - AVOID AVOID AVOID + lightgray: "#999998", // use border, description, or description-muted instead - AVOID "vsc-input-background": varWithFallback("input-background"), // use "input-background" instead "vsc-background": varWithFallback("background"), // use "background" instead - "vsc-foreground": varWithFallback("foreground"), // use "foreground" instead // NOTE - might want to use editor-foreground + "vsc-foreground": varWithFallback("editor-foreground"), // use "foreground" instead "vsc-editor-background": varWithFallback("editor-background"), // use "editor" instead "vsc-input-border": varWithFallback("input-border"), // use "input-border" instead }, From dbd3430984d07969cfaad8063736f3de705e0bcf Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Wed, 21 May 2025 20:33:30 +0200 Subject: [PATCH 35/58] Add Devstral as model supporting tools Ref #5778 --- core/llm/toolSupport.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index 8a96a4d60..cd14586bb 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -88,6 +88,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< return ( !model.toLowerCase().includes("mamba") && [ + "devstral", "codestral", "mistral-large", "mistral-small", @@ -136,6 +137,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< "aya-expanse", "firefunction-v2", "mistral", + "devstral", ].some((part) => modelName.toLowerCase().includes(part)) ) { return true; From 6c5441effde54f4356fc919bf0f88e2e2777e278 Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Wed, 21 May 2025 20:37:36 +0200 Subject: [PATCH 36/58] Update toolSupport.test.ts to support devstral --- core/llm/toolSupport.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/llm/toolSupport.test.ts b/core/llm/toolSupport.test.ts index c92bb93ee..416a4c9eb 100644 --- a/core/llm/toolSupport.test.ts +++ b/core/llm/toolSupport.test.ts @@ -155,6 +155,7 @@ describe("PROVIDER_TOOL_SUPPORT", () => { expect(supportsFn("pixtral-12b-2409")).toBe(true); expect(supportsFn("pixtral-large-latest")).toBe(true); expect(supportsFn("open-mistral-nemo")).toBe(true); + expect(supportsFn("devstral-latest")).toBe(true); }); it("should return false for other unsupported models", () => { @@ -170,6 +171,7 @@ describe("PROVIDER_TOOL_SUPPORT", () => { expect(supportsFn("CODESTRAL-LATEST")).toBe(true); expect(supportsFn("MINISTRAL-8B-LATEST")).toBe(true); expect(supportsFn("PIXTRAL-12B-2409")).toBe(true); + expect(supportsFn("DEVSTRAL-LATEST")).toBe(true); }); }); @@ -192,6 +194,7 @@ describe("PROVIDER_TOOL_SUPPORT", () => { expect(supportsFn("aya-expanse")).toBe(true); expect(supportsFn("firefunction-v2")).toBe(true); expect(supportsFn("mistral-7b")).toBe(true); + expect(supportsFn("devstral-24b")).toBe(true); }); it("should return false for explicitly unsupported models", () => { From f66f0980f2c6abc66d04f64c2ac2b65e52a3cc92 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 21 May 2025 11:49:00 -0700 Subject: [PATCH 37/58] theme logic fix for setting fallbacks in jetbrains --- .../continue/GetTheme.kt | 2 +- gui/src/styles/ThemePage.tsx | 102 ++++++++---------- gui/src/styles/theme.ts | 81 +++++++------- 3 files changed, 90 insertions(+), 95 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index 7fbc21cf4..5fe10d011 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -102,8 +102,8 @@ class GetTheme { ?: EditorColorsManager.getInstance().globalScheme.getAttributes(CodeInsightColors.WARNINGS_ATTRIBUTES)?.effectColor ?: namedColor("Component.warningForeground") ?: namedColor("Label.warningForeground") - val errorColor = namedColor("ValidationError.errorColor") ?: namedColor("Component.errorForeground") ?: namedColor("Label.errorForeground") + val accentColor = namedColor("Focus.defaultButtonBorderColor") ?: namedColor("Button.default.focusedBorderColor") ?: namedColor("Button.focusedBorderColor") val editorBackground = editorScheme.defaultBackground diff --git a/gui/src/styles/ThemePage.tsx b/gui/src/styles/ThemePage.tsx index 6a9dd2864..e1075ba02 100644 --- a/gui/src/styles/ThemePage.tsx +++ b/gui/src/styles/ThemePage.tsx @@ -62,36 +62,39 @@ function ThemePage() { return isJetBrains(); }, []); - const refreshJetbrainsColors = () => { - ideMessenger.request("jetbrains/getColors", undefined).then((result) => { - console.log(result); - if (result.status === "success") { - setDocumentStylesFromTheme(result.content); - } - }); + const [missingVars, setMissingVars] = useState([]); + const refreshColors = () => { + if (jetbrains) { + // Jetbrains: get colors and check which ones are missing from theme + void ideMessenger + .request("jetbrains/getColors", undefined) + .then((result) => { + console.log(result); + if (result.status === "success") { + const missingColors = setDocumentStylesFromTheme(result.content); + setMissingVars(missingColors); + } + }); + } else { + // VS Code: find actual missing CSS variables + const notFound: string[] = []; + Object.entries(THEME_COLORS).forEach(([colorName, themeVals], idx) => { + let found = false; + themeVals.vars.forEach((cssVar) => { + const value = getComputedStyle( + document.documentElement, + ).getPropertyValue(cssVar); + if (!value) { + notFound.push(`cssVar (choice #${idx + 1} for color ${colorName}`); + } + }); + }); + setMissingVars(notFound); + } }; - const [missingVars, setMissingVars] = useState([]); - const checkMissingClasses = () => { - const missingVars: string[] = []; - Object.entries(THEME_COLORS).forEach(([colorName, themeVals]) => { - let found = false; - themeVals.vars.forEach((cssVar) => { - const value = getComputedStyle( - document.documentElement, - ).getPropertyValue(cssVar); - if (value) { - found = true; - } - }); - if (!found) { - missingVars.push(colorName); - } - }); - setMissingVars(missingVars); - }; useEffect(() => { - checkMissingClasses(); + refreshColors(); }, []); return ( @@ -185,37 +188,22 @@ function ThemePage() {
-
-

- Missing Theme Variables -

- {missingVars.length > 0 ? ( -
- {missingVars.map((varName) => ( -
- {varName} -
- ))} -
- ) : ( -
No missing variables
- )} - -
+

Manage Theme

+

Missing Theme Colors

+ {missingVars.length > 0 ? ( +
+ {missingVars.map((varName) => ( +
+ {varName} +
+ ))} +
+ ) : ( +
No missing variables
+ )} + {jetbrains ? ( - <> -

- Manage Jetbrains Theme -

-
- - -
- + ) : null}

All Theme Colors

diff --git a/gui/src/styles/theme.ts b/gui/src/styles/theme.ts index dc5475dcb..ad0ee0bd7 100644 --- a/gui/src/styles/theme.ts +++ b/gui/src/styles/theme.ts @@ -117,15 +117,23 @@ export const THEME_COLORS = { default: "#ffffff", // white }, success: { - vars: ["--vscode-notebookStatusSuccessIcon-foreground"], // "var(--vscode-testing-iconPassed, #1bbe84)" // --vscode-charts-green + vars: [ + "--vscode-notebookStatusSuccessIcon-foreground", + "--vscode-testing-iconPassed", + "--vscode-gitDecoration-addedResourceForeground", + "--vscode-charts-green", + ], default: "#4caf50", // green }, warning: { - vars: ["--vscode-editorWarning-foreground"], // --vscode-list-warningForeground + vars: [ + "--vscode-editorWarning-foreground", + "--vscode-list-warningForeground", + ], default: "#ffb74d", // amber/yellow }, error: { - vars: ["--vscode-editorError-foreground"], // --vscode-list-errorForeground + vars: ["--vscode-editorError-foreground", "--vscode-list-errorForeground"], default: "#f44336", // red }, link: { @@ -187,7 +195,7 @@ export const THEME_DEFAULTS = Object.entries(THEME_COLORS).reduce( // Generates recursive CSS variable fallback for a given color name // e.g. var(--vscode-button-background, var(--vscode-button-foreground, #ffffff)) export const getRecursiveVar = (vars: string[], defaultColor: string) => { - return vars.reverse().reduce((curr, varName) => { + return [...vars].reverse().reduce((curr, varName) => { return `var(${varName}, ${curr})`; }, defaultColor); }; @@ -203,44 +211,43 @@ export const varWithFallback = (colorName: keyof typeof THEME_COLORS) => { export const setDocumentStylesFromTheme = ( theme: Record, ) => { - // Check for missing theme items - const themeKeys = Object.keys(THEME_COLORS); - const missingKeys = themeKeys.filter( - (key) => !Object.keys(theme).includes(key), - ); - if (missingKeys.length > 0) { - console.warn( - `Missing theme keys: ${missingKeys.join(", ")}. Please check theme`, - ); - } - // Write each theme color to the document + // Check for extraneous theme items Object.entries(theme).forEach(([colorName, value]) => { - if (value) { - const themeVals = THEME_COLORS[colorName as keyof typeof THEME_COLORS]; - if (!themeVals) { - console.warn( - `Receieved theme color ${colorName} which is not used by the theme`, - ); - return; - } - - // Remove alpha channel from all hex colors (seems to cause bad colors) - let colorVal = value; - if (colorVal.startsWith("#") && value.length > 7) { - colorVal = colorVal.slice(0, 7); - } - - localStorage.setItem(colorName, colorVal); - for (const cssVar of themeVals.vars) { - document.body.style.setProperty(cssVar, colorVal); - document.documentElement.style.setProperty(cssVar, colorVal); - } - } else { + const themeVals = THEME_COLORS[colorName as keyof typeof THEME_COLORS]; + if (!themeVals) { console.warn( - `Theme color ${colorName} is undefined or null. Please check theme. Falling back to defaults.`, + `Receieved theme color ${colorName} which is not used by the theme`, ); + return; } }); + + // Write theme values to document + const missingColors: string[] = []; + Object.entries(THEME_COLORS).forEach(([colorName, settings]) => { + let colorVal = settings.default; + const newColor = theme[colorName]; + if (newColor) { + colorVal = newColor; + // Remove alpha channel from all hex colors (seems to cause bad colors) + if (newColor.startsWith("#") && newColor.length > 7) { + colorVal = colorVal.slice(0, 7); + } + } else { + missingColors.push(colorName); + // console.warn( + // `Missing theme color: ${colorName}. Falling back to default ${colorVal}`, + // ); + } + + localStorage.setItem(colorName, colorVal); + for (const cssVar of settings.vars) { + document.body.style.setProperty(cssVar, colorVal); + document.documentElement.style.setProperty(cssVar, colorVal); + } + }); + + return missingColors; }; export const setDocumentStylesFromLocalStorage = (checkCache: boolean) => { From e368c42b65f8af197061c1c90233d7a9467fe055 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 21 May 2025 12:04:31 -0700 Subject: [PATCH 38/58] secondary button hover --- .../continueintellijextension/continue/GetTheme.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index 5fe10d011..316777fc8 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -73,6 +73,10 @@ class GetTheme { val buttonBackground = namedColor("Button.background") val buttonForeground = namedColor("Button.foreground") val buttonHoverBackground = namedColor("Button.hoverBackground") ?: buttonBackground?.brighter() + + val secondaryBackground = getSecondaryDark() + val secondaryHover = secondaryBackground.brighter() + val badgeBackground = namedColor("Badge.background") val badgeForeground = namedColor("Badge.foreground") @@ -85,8 +89,8 @@ class GetTheme { val listHoverBackground = namedColor("List.hoverBackground") ?: namedColor("List.dropLineColor") val actionHoverBackground = namedColor("ActionButton.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") - val hoverBackground = namedColor("List.dropLineColor") - val tableOddRow = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") ?: hoverBackground + + val tableOddRow = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") val listSelectionForeground = namedColor("List.selectionForeground") @@ -123,9 +127,9 @@ class GetTheme { "primary-background" to buttonBackground, "primary-foreground" to buttonForeground, "primary-hover" to buttonHoverBackground, - "secondary-background" to getSecondaryDark(), + "secondary-background" to secondaryBackground, "secondary-foreground" to foreground, - "secondary-hover" to hoverBackground, + "secondary-hover" to secondaryHover, "border" to border, "border-focus" to focusBorder, "command-background" to commandBackground, From eb512182b85ab0147006b0733f942acaa2f66e58 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 21 May 2025 12:23:56 -0700 Subject: [PATCH 39/58] Revert "feat: add support for SSE MCP servers" --- core/config/workspace/workspaceBlocks.ts | 6 -- core/config/yaml/loadYaml.test.ts | 107 ---------------------- core/config/yaml/loadYaml.ts | 44 ++------- docs/docs/customize/deep-dives/mcp.mdx | 10 -- docs/docs/reference.md | 14 +-- packages/config-yaml/src/converter.ts | 46 ++-------- packages/config-yaml/src/schemas/index.ts | 49 +++------- 7 files changed, 28 insertions(+), 248 deletions(-) delete mode 100644 core/config/yaml/loadYaml.test.ts diff --git a/core/config/workspace/workspaceBlocks.ts b/core/config/workspace/workspaceBlocks.ts index 1bd66bdd5..009e3cdff 100644 --- a/core/config/workspace/workspaceBlocks.ts +++ b/core/config/workspace/workspaceBlocks.ts @@ -53,16 +53,10 @@ function getContentsForNewBlock(blockType: BlockType): ConfigYaml { configYaml.mcpServers = [ { name: "New MCP server", - type: "stdio", command: "npx", args: ["-y", ""], env: {}, }, - { - name: "New MCP server", - type: "sse", - url: "https://example.org/sse" - }, ]; break; } diff --git a/core/config/yaml/loadYaml.test.ts b/core/config/yaml/loadYaml.test.ts deleted file mode 100644 index 600b94eef..000000000 --- a/core/config/yaml/loadYaml.test.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { MCPServer } from "@continuedev/config-yaml"; -import { convertYamlMcpToContinueMcp } from "./loadYaml"; - -describe("MCP Server Configuration Tests", () => { - test("should convert stdio MCP server correctly", () => { - const stdioServer: MCPServer = { - name: "Test Stdio Server", - type: "stdio", - command: "uvx", - args: ["mcp-server-sqlite", "--db-path", "/test.db"], - env: { TEST_ENV: "value" }, - connectionTimeout: 5000 - }; - - const result = convertYamlMcpToContinueMcp(stdioServer); - - expect(result).toEqual({ - transport: { - type: "stdio", - command: "uvx", - args: ["mcp-server-sqlite", "--db-path", "/test.db"], - env: { TEST_ENV: "value" } - }, - timeout: 5000 - }); - }); - - test("should convert SSE MCP server correctly", () => { - const sseServer: MCPServer = { - name: "Test SSE Server", - type: "sse", - url: "http://localhost:8150/cosmos/mcp/v1/sse", - connectionTimeout: 3000 - }; - - const result = convertYamlMcpToContinueMcp(sseServer); - - expect(result).toEqual({ - transport: { - type: "sse", - url: "http://localhost:8150/cosmos/mcp/v1/sse" - }, - timeout: 3000 - }); - }); - - test("should convert WebSocket MCP server correctly", () => { - const wsServer: MCPServer = { - name: "Test WebSocket Server", - type: "websocket", - url: "ws://localhost:8150/cosmos/mcp/v1/ws", - connectionTimeout: 10000 - }; - - const result = convertYamlMcpToContinueMcp(wsServer); - - expect(result).toEqual({ - transport: { - type: "websocket", - url: "ws://localhost:8150/cosmos/mcp/v1/ws" - }, - timeout: 10000 - }); - }); - - test("should handle legacy MCP server format for backward compatibility", () => { - // Test with old format that doesn't have a type field - const legacyServer = { - name: "Legacy Server", - command: "old-command", - args: ["--legacy"], - connectionTimeout: 2000 - } as any; - - const result = convertYamlMcpToContinueMcp(legacyServer); - - expect(result).toEqual({ - transport: { - type: "stdio", - command: "old-command", - args: ["--legacy"], - env: undefined - }, - timeout: 2000 - }); - }); - - test("should handle missing optional fields", () => { - const minimalServer: MCPServer = { - name: "Minimal Server", - type: "stdio", - command: "minimal" - }; - - const result = convertYamlMcpToContinueMcp(minimalServer); - - expect(result).toEqual({ - transport: { - type: "stdio", - command: "minimal", - args: [], - env: undefined - }, - timeout: undefined - }); - }); -}); \ No newline at end of file diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 7a33aa22b..7c18aec00 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -62,42 +62,17 @@ function convertYamlRuleToContinueRule(rule: Rule): RuleWithSource { } } -export function convertYamlMcpToContinueMcp( +function convertYamlMcpToContinueMcp( server: MCPServer, ): ExperimentalMCPOptions { - const transportConfig = (() => { - switch (server.type) { - case "stdio": - return { - type: "stdio" as const, - command: server.command, - args: server.args ?? [], - env: server.env, - }; - case "sse": - return { - type: "sse" as const, - url: server.url, - }; - case "websocket": - return { - type: "websocket" as const, - url: server.url, - }; - default: - // Default to stdio for backward compatibility - return { - type: "stdio" as const, - command: (server as any).command, - args: (server as any).args ?? [], - env: (server as any).env, - }; - } - })(); - return { - transport: transportConfig, - timeout: server.connectionTimeout + transport: { + type: "stdio", + command: server.command, + args: server.args ?? [], + env: server.env, + }, + timeout: server.connectionTimeout, }; } @@ -269,7 +244,7 @@ async function configYamlToContinueConfig(options: { config.mcpServers?.forEach((mcpServer) => { const mcpArgVariables = - (mcpServer.type === "stdio" ? mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) : []) ?? []; + mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? []; if (mcpArgVariables.length === 0) { return; @@ -481,6 +456,7 @@ async function configYamlToContinueConfig(options: { id: server.name, name: server.name, transport: { + type: "stdio", args: [], ...server, }, diff --git a/docs/docs/customize/deep-dives/mcp.mdx b/docs/docs/customize/deep-dives/mcp.mdx index 7f241d094..e4e828520 100644 --- a/docs/docs/customize/deep-dives/mcp.mdx +++ b/docs/docs/customize/deep-dives/mcp.mdx @@ -20,15 +20,11 @@ To set up your own MCP server, read the [MCP quickstart](https://modelcontextpro ```yaml title="config.yaml" mcpServers: - name: My MCP Server - type: stdio command: uvx args: - mcp-server-sqlite - --db-path - /Users/NAME/test.db - - name: My MCP Server with SSE - type: sse - url: "https://example.com/mcp-server/sse" ``` @@ -42,12 +38,6 @@ To set up your own MCP server, read the [MCP quickstart](https://modelcontextpro "command": "uvx", "args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"] } - }, - { - "transport": { - "type": "sse", - "url": "https://example.com/mcp-server/sse" - } } ] } diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 1496657e1..e8b915813 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -379,33 +379,21 @@ prompts, context, and tool use. Continue supports any MCP server with the MCP co **Properties:** - `name` (**required**): The name of the MCP server. -- `type"` (**required**): The type of the MCP server. Can be "stdio", "sse", or "websocket". - -**Stdio type** - - `command` (**required**): The command used to start the server. - `args`: An optional array of arguments for the command. - `env`: An optional map of environment variables for the server process. - `connectionTimeout`: An optional connection timeout number to the server in milliseconds. -**SSE or Websocket type** - -- `url` (**required**): The URL of the MCP server. - **Example:** ```yaml title="config.yaml" mcpServers: - - name: My MCP Server with stdio - type: stdio + - name: My MCP Server command: uvx args: - mcp-server-sqlite - --db-path - /Users/NAME/test.db - - name: My MCP Server with SSE - type: sse - url: "https://example.com/mcp-server/sse" ``` ### `data` diff --git a/packages/config-yaml/src/converter.ts b/packages/config-yaml/src/converter.ts index 334e6c699..40e1f226a 100644 --- a/packages/config-yaml/src/converter.ts +++ b/packages/config-yaml/src/converter.ts @@ -128,48 +128,14 @@ function convertCustomCommand( function convertMcp(mcp: any): NonNullable[number] { const { transport } = mcp; - const { type } = transport; + const { command, args, env, server_name } = transport; - // Common properties for all server types - const baseServer: any = { - name: mcp.name, - type: type, + return { + command, + args, + env, + name: server_name || "MCP Server", }; - - if (mcp.faviconUrl) { - baseServer.faviconUrl = mcp.faviconUrl - } - if (mcp.connectionTimeout) { - baseServer.connectionTimeout = mcp.connectionTimeout - } - - // Type-specific properties - switch (type) { - case "stdio": - const stdioServer = { - ...baseServer, - command: transport.command, - }; - - if (transport.args) { - stdioServer.args = transport.args - } - if (transport.env) { - stdioServer.env = transport.env - } - - return stdioServer; - - case "sse": - case "websocket": - return { - ...baseServer, - url: transport.url - }; - - default: - throw new Error(`Unknown MCP server type: ${type}`); - } } function convertDoc( diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index ce7ffaa4f..35e110206 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -9,31 +9,14 @@ export const contextSchema = z.object({ params: z.any().optional(), }); -const mcpServerSchema = z.discriminatedUnion("type", [ - z.object({ - name: z.string(), - type: z.literal("stdio"), - command: z.string(), - faviconUrl: z.string().optional(), - args: z.array(z.string()).optional(), - env: z.record(z.string()).optional(), - connectionTimeout: z.number().gt(0).optional() - }), - z.object({ - name: z.string(), - type: z.literal("sse"), - url: z.string(), - faviconUrl: z.string().optional(), - connectionTimeout: z.number().gt(0).optional() - }), - z.object({ - name: z.string(), - type: z.literal("websocket"), - url: z.string(), - faviconUrl: z.string().optional(), - connectionTimeout: z.number().gt(0).optional() - }) -]); +const mcpServerSchema = z.object({ + name: z.string(), + command: z.string(), + faviconUrl: z.string().optional(), + args: z.array(z.string()).optional(), + env: z.record(z.string()).optional(), + connectionTimeout: z.number().gt(0).optional() +}); export type MCPServer = z.infer; @@ -78,17 +61,7 @@ export const blockItemWrapperSchema = ( export const blockOrSchema = ( schema: T, usesSchema: z.ZodTypeAny = defaultUsesSchema, - isDiscriminatedUnion?: boolean, -) => { - if (isDiscriminatedUnion) { - return z.union([schema, z.object({ - uses: usesSchema, - with: z.record(z.string()).optional(), - override: z.any().optional(), - })]); - } - return z.union([schema, blockItemWrapperSchema(schema, usesSchema)]); -}; +) => z.union([schema, blockItemWrapperSchema(schema, usesSchema)]); export const commonMetadataSchema = z.object({ tags: z.string().optional(), @@ -125,7 +98,7 @@ export const configYamlSchema = baseConfigYamlSchema.extend({ .optional(), context: z.array(blockOrSchema(contextSchema)).optional(), data: z.array(blockOrSchema(dataSchema)).optional(), - mcpServers: z.array(blockOrSchema(mcpServerSchema as any, defaultUsesSchema, true)).optional(), + mcpServers: z.array(blockOrSchema(mcpServerSchema)).optional(), rules: z .array( z.union([ @@ -250,4 +223,4 @@ export const configSchema = z.object({ api_key: z.string().optional(), }); -export type Config = z.infer; \ No newline at end of file +export type Config = z.infer; From bdc2ec8374ac9e7d14fc440ea80fa438005735e8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 21 May 2025 12:37:43 -0700 Subject: [PATCH 40/58] fix: missing context items --- core/llm/constructMessages.ts | 28 +++++++++++++++++++-- core/llm/rules/getSystemMessageWithRules.ts | 26 ++++++++++++++++--- gui/src/redux/thunks/streamResponse.ts | 1 + 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index 309429d4b..0a7ba5a03 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -58,7 +58,7 @@ const EDIT_MESSAGE = `\ at the beginning, middle, or end of files using these "lazy" comments. Only provide the complete file when explicitly requested. Include a concise explanation of changes unless the user specifically asks for code only. -` +`; export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\ @@ -92,7 +92,8 @@ export function constructMessages( const historyItem = filteredHistory[i]; if (messageMode === "chat") { - const toolMessage: ToolResultChatMessage = historyItem.message as ToolResultChatMessage; + const toolMessage: ToolResultChatMessage = + historyItem.message as ToolResultChatMessage; if (historyItem.toolCallState?.toolCallId || toolMessage.toolCallId) { // remove all tool calls from the history continue; @@ -127,10 +128,33 @@ export function constructMessages( | ToolResultChatMessage | undefined; + // Find the context items for the last user message + let lastUserContextItems; + if (lastUserMsg) { + const lastUserMsgIndex = msgs.findIndex((msg) => { + if (msg.role !== "user" && msg.role !== "tool") return false; + if ("id" in msg && "id" in lastUserMsg) { + return msg.id === lastUserMsg.id; + } + return msg === lastUserMsg; + }); + + if (lastUserMsgIndex !== -1) { + const historyIndex = filteredHistory.findIndex( + (item) => item.message === msgs[lastUserMsgIndex], + ); + + if (historyIndex !== -1) { + lastUserContextItems = filteredHistory[historyIndex].contextItems; + } + } + } + const systemMessage = getSystemMessageWithRules({ baseSystemMessage: baseChatOrAgentSystemMessage, rules, userMessage: lastUserMsg, + contextItems: lastUserContextItems, }); if (systemMessage.trim()) { diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 3d7372fef..a6969248c 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -1,5 +1,10 @@ import { minimatch } from "minimatch"; -import { RuleWithSource, ToolResultChatMessage, UserChatMessage } from "../.."; +import { + ContextItemWithId, + RuleWithSource, + ToolResultChatMessage, + UserChatMessage, +} from "../.."; import { renderChatMessage } from "../../util/messageContent"; import { extractPathsFromCodeBlocks } from "../utils/extractPathsFromCodeBlocks"; @@ -24,21 +29,32 @@ const matchesGlobs = ( }; /** - * Filters rules that apply to the given message + * Filters rules that apply to the given message and/or context items */ export const getApplicableRules = ( userMessage: UserChatMessage | ToolResultChatMessage | undefined, rules: RuleWithSource[], + contextItems?: ContextItemWithId[], ): RuleWithSource[] => { const filePathsFromMessage = userMessage ? extractPathsFromCodeBlocks(renderChatMessage(userMessage)) : []; + // Extract file paths from context items + const filePathsFromContextItems = contextItems + ? contextItems + .filter((item) => item.uri?.type === "file" && item.uri?.value) + .map((item) => item.uri!.value) + : []; + + // Combine file paths from both sources + const allFilePaths = [...filePathsFromMessage, ...filePathsFromContextItems]; + return rules.filter((rule) => { // A rule is active if it has no globs (applies to all files) // or if at least one file path matches its globs const hasNoGlobs = !rule.globs; - const matchesAnyFilePath = filePathsFromMessage.some((path) => + const matchesAnyFilePath = allFilePaths.some((path) => matchesGlobs(path, rule.globs), ); @@ -50,12 +66,14 @@ export const getSystemMessageWithRules = ({ baseSystemMessage, userMessage, rules, + contextItems, }: { baseSystemMessage?: string; userMessage: UserChatMessage | ToolResultChatMessage | undefined; rules: RuleWithSource[]; + contextItems?: ContextItemWithId[]; }) => { - const applicableRules = getApplicableRules(userMessage, rules); + const applicableRules = getApplicableRules(userMessage, rules, contextItems); let systemMessage = baseSystemMessage ?? ""; for (const rule of applicableRules) { diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index c9a21a30c..8f11fc7f5 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -100,6 +100,7 @@ export const streamResponseThunk = createAsyncThunk< ? (userMsg as UserChatMessage | ToolResultChatMessage) : undefined, rules, + selectedContextItems, ); // Store in history for UI display From d265ec01e280f2c36e9fe61be365de0d1c5e982b Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 21 May 2025 12:41:40 -0700 Subject: [PATCH 41/58] improv: clean up code --- core/llm/constructMessages.ts | 53 ++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index 0a7ba5a03..1e217f57f 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -1,6 +1,7 @@ import { ChatHistoryItem, ChatMessage, + ContextItemWithId, RuleWithSource, TextMessagePart, ToolResultChatMessage, @@ -77,6 +78,31 @@ export const DEFAULT_AGENT_SYSTEM_MESSAGE = `\ ${EDIT_MESSAGE} `; +/** + * Helper function to get the context items for a user message + */ +function getUserContextItems( + userMsg: UserChatMessage | ToolResultChatMessage | undefined, + history: ChatHistoryItem[], +): ContextItemWithId[] | undefined { + if (!userMsg) return undefined; + + // Find the history item that contains the userMsg + const historyItem = history.find((item) => { + // Check if the message ID matches + if ("id" in userMsg && "id" in item.message) { + return (item.message as any).id === (userMsg as any).id; + } + // Fallback to content comparison + return ( + item.message.content === userMsg.content && + item.message.role === userMsg.role + ); + }); + + return historyItem?.contextItems; +} + export function constructMessages( messageMode: string, history: ChatHistoryItem[], @@ -128,28 +154,11 @@ export function constructMessages( | ToolResultChatMessage | undefined; - // Find the context items for the last user message - let lastUserContextItems; - if (lastUserMsg) { - const lastUserMsgIndex = msgs.findIndex((msg) => { - if (msg.role !== "user" && msg.role !== "tool") return false; - if ("id" in msg && "id" in lastUserMsg) { - return msg.id === lastUserMsg.id; - } - return msg === lastUserMsg; - }); - - if (lastUserMsgIndex !== -1) { - const historyIndex = filteredHistory.findIndex( - (item) => item.message === msgs[lastUserMsgIndex], - ); - - if (historyIndex !== -1) { - lastUserContextItems = filteredHistory[historyIndex].contextItems; - } - } - } - + // Get context items for the last user message + const lastUserContextItems = getUserContextItems( + lastUserMsg, + filteredHistory, + ); const systemMessage = getSystemMessageWithRules({ baseSystemMessage: baseChatOrAgentSystemMessage, rules, From 17a249c1ceaea71aa5c629cbcce2896a64b31d15 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 21 May 2025 12:46:59 -0700 Subject: [PATCH 42/58] test: generating system message --- .../rules/getSystemMessageWithRules.test.ts | 145 +++++++++++++++++- core/llm/rules/getSystemMessageWithRules.ts | 25 ++- 2 files changed, 160 insertions(+), 10 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.test.ts b/core/llm/rules/getSystemMessageWithRules.test.ts index cad93e8d7..8f576247c 100644 --- a/core/llm/rules/getSystemMessageWithRules.test.ts +++ b/core/llm/rules/getSystemMessageWithRules.test.ts @@ -1,4 +1,4 @@ -import { RuleWithSource, UserChatMessage } from "../.."; +import { ContextItemWithId, RuleWithSource, UserChatMessage } from "../.."; import { getSystemMessageWithRules } from "./getSystemMessageWithRules"; describe("getSystemMessageWithRules", () => { @@ -33,11 +33,40 @@ describe("getSystemMessageWithRules", () => { source: "rules-block", }; + // Empty context items + const emptyContextItems: ContextItemWithId[] = []; + + // Context items with file paths + const tsContextItem: ContextItemWithId = { + content: "TypeScript file content", + name: "Component.tsx", + description: "A TypeScript component", + id: { providerTitle: "file", itemId: "src/Component.tsx" }, + uri: { type: "file", value: "src/Component.tsx" }, + }; + + const pyContextItem: ContextItemWithId = { + content: "Python file content", + name: "utils.py", + description: "A Python utility file", + id: { providerTitle: "file", itemId: "utils.py" }, + uri: { type: "file", value: "utils.py" }, + }; + + const jsContextItem: ContextItemWithId = { + content: "JavaScript file content", + name: "utils.js", + description: "A JavaScript utility file", + id: { providerTitle: "file", itemId: "src/utils.js" }, + uri: { type: "file", value: "src/utils.js" }, + }; + it("should not include pattern-matched rules when no file paths are mentioned", () => { const result = getSystemMessageWithRules({ baseSystemMessage, userMessage: undefined, rules: [tsRule], + contextItems: emptyContextItems, }); expect(result).toBe(baseSystemMessage); @@ -48,12 +77,13 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage: undefined, rules: [generalRule], + contextItems: emptyContextItems, }); expect(result).toBe(`${baseSystemMessage}\n\n${generalRule.rule}`); }); - it("should include only matching rules based on file paths", () => { + it("should include only matching rules based on file paths in message", () => { const userMessage: UserChatMessage = { role: "user", content: @@ -64,6 +94,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [tsRule, pythonRule, generalRule], + contextItems: emptyContextItems, }); // Should include TS rule and general rule, but not Python rule @@ -71,7 +102,38 @@ describe("getSystemMessageWithRules", () => { expect(result).toBe(expected); }); - it("should include multiple matching rules", () => { + it("should include matching rules based on file paths in context items", () => { + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [tsRule, pythonRule, generalRule], + contextItems: [tsContextItem], + }); + + // Should include TS rule and general rule, but not Python rule + const expected = `${baseSystemMessage}\n\n${tsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + it("should include matching rules from both message and context items", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```python test.py\nprint('hello')\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [tsRule, pythonRule, generalRule], + contextItems: [tsContextItem], + }); + + // Should include TS rule, Python rule, and general rule + const expected = `${baseSystemMessage}\n\n${tsRule.rule}\n\n${pythonRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + it("should include multiple matching rules from message", () => { const userMessage: UserChatMessage = { role: "user", content: @@ -82,6 +144,20 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [tsRule, pythonRule, generalRule], + contextItems: emptyContextItems, + }); + + // Should include all rules + const expected = `${baseSystemMessage}\n\n${tsRule.rule}\n\n${pythonRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + it("should include multiple matching rules from context items", () => { + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [tsRule, pythonRule, generalRule], + contextItems: [tsContextItem, pyContextItem], }); // Should include all rules @@ -99,6 +175,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [tsRule, pythonRule, generalRule], + contextItems: emptyContextItems, }); // Should only include the general rule @@ -125,6 +202,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [commaRule], + contextItems: emptyContextItems, }); // With the current implementation, the comma-separated pattern is treated as a single string, @@ -151,6 +229,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [arrayGlobRule], + contextItems: emptyContextItems, }); // With our new implementation, the array of patterns should match both src/main.ts and tests/example.test.ts @@ -176,6 +255,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [arrayGlobRule], + contextItems: emptyContextItems, }); // Should match src/main.ts but not config/settings.ts @@ -201,6 +281,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [arrayGlobRule], + contextItems: emptyContextItems, }); // Should not match any file paths @@ -218,6 +299,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [jsRule, tsRule, generalRule], + contextItems: emptyContextItems, }); // Should include JS rule and general rule @@ -236,6 +318,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [jsRule, tsRule, generalRule], + contextItems: emptyContextItems, }); // Should include JS rule and general rule @@ -257,10 +340,66 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [jsRule, tsRule, generalRule], + contextItems: emptyContextItems, }); // Should include JS rule, TS rule, and general rule const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${tsRule.rule}\n\n${generalRule.rule}`; expect(result).toBe(expected); }); + + // Test for context items when there's no message + it("should apply rules based on context items only when no message is present", () => { + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [jsRule, tsRule, generalRule], + contextItems: [jsContextItem], + }); + + // Should include JS rule and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // Test for non-file context items + it("should ignore non-file context items", () => { + const nonFileContextItem: ContextItemWithId = { + content: "Some search result", + name: "Search result", + description: "A search result", + id: { providerTitle: "search", itemId: "search-result" }, + // No uri with type "file" + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [jsRule, tsRule, generalRule], + contextItems: [nonFileContextItem], + }); + + // Should only include general rule + const expected = `${baseSystemMessage}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // Test combining context items with message + it("should match rules from both message code blocks and context items", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```ts src/main.ts\nconsole.log('hello');\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [jsRule, tsRule, pythonRule, generalRule], + contextItems: [jsContextItem, pyContextItem], + }); + + // Should include JS, TS, Python rules and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${tsRule.rule}\n\n${pythonRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); }); diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index a6969248c..19870a6da 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -30,11 +30,16 @@ const matchesGlobs = ( /** * Filters rules that apply to the given message and/or context items + * + * @param userMessage - The user or tool message to check for file paths in code blocks + * @param rules - The list of rules to filter + * @param contextItems - Context items to check for file paths + * @returns List of applicable rules */ export const getApplicableRules = ( userMessage: UserChatMessage | ToolResultChatMessage | undefined, rules: RuleWithSource[], - contextItems?: ContextItemWithId[], + contextItems: ContextItemWithId[], ): RuleWithSource[] => { const filePathsFromMessage = userMessage ? extractPathsFromCodeBlocks(renderChatMessage(userMessage)) @@ -42,11 +47,8 @@ export const getApplicableRules = ( // Extract file paths from context items const filePathsFromContextItems = contextItems - ? contextItems - .filter((item) => item.uri?.type === "file" && item.uri?.value) - .map((item) => item.uri!.value) - : []; - + .filter((item) => item.uri?.type === "file" && item.uri?.value) + .map((item) => item.uri!.value); // Combine file paths from both sources const allFilePaths = [...filePathsFromMessage, ...filePathsFromContextItems]; @@ -62,6 +64,15 @@ export const getApplicableRules = ( }); }; +/** + * Creates a system message string with applicable rules appended + * + * @param baseSystemMessage - The base system message to start with + * @param userMessage - The user message to check for file paths + * @param rules - The list of rules to filter + * @param contextItems - Context items to check for file paths + * @returns System message with applicable rules appended + */ export const getSystemMessageWithRules = ({ baseSystemMessage, userMessage, @@ -71,7 +82,7 @@ export const getSystemMessageWithRules = ({ baseSystemMessage?: string; userMessage: UserChatMessage | ToolResultChatMessage | undefined; rules: RuleWithSource[]; - contextItems?: ContextItemWithId[]; + contextItems: ContextItemWithId[]; }) => { const applicableRules = getApplicableRules(userMessage, rules, contextItems); let systemMessage = baseSystemMessage ?? ""; From cd82f4c61fdff90c8ed0e845a3b2ee8b0ce1be9d Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 21 May 2025 12:53:33 -0700 Subject: [PATCH 43/58] fix: type errors --- core/edit/streamDiffLines.ts | 1 + core/llm/constructMessages.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/edit/streamDiffLines.ts b/core/edit/streamDiffLines.ts index 4cba92608..ff1585520 100644 --- a/core/edit/streamDiffLines.ts +++ b/core/edit/streamDiffLines.ts @@ -122,6 +122,7 @@ export async function* streamDiffLines({ (msg) => msg.role === "user" || msg.role === "tool", ) as UserChatMessage | ToolResultChatMessage | undefined), baseSystemMessage: undefined, + contextItems: [], }) : undefined; diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index 1e217f57f..5358deee5 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -84,8 +84,8 @@ ${EDIT_MESSAGE} function getUserContextItems( userMsg: UserChatMessage | ToolResultChatMessage | undefined, history: ChatHistoryItem[], -): ContextItemWithId[] | undefined { - if (!userMsg) return undefined; +): ContextItemWithId[] { + if (!userMsg) return []; // Find the history item that contains the userMsg const historyItem = history.find((item) => { @@ -100,7 +100,7 @@ function getUserContextItems( ); }); - return historyItem?.contextItems; + return historyItem?.contextItems || []; } export function constructMessages( From 7f978cc6d5e9d910fc523f393b8c07651a70b9a8 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 21 May 2025 13:48:42 -0700 Subject: [PATCH 44/58] color tweaks --- .../continueintellijextension/continue/GetTheme.kt | 2 +- gui/src/styles/ThemePage.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index 316777fc8..be28db2e8 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -86,7 +86,7 @@ class GetTheme { val inputBackground = namedColor("TextField.background") val inputForeground = namedColor("TextField.foreground") val inputPlaceholder = namedColor("TextField.inactiveForeground") - + // list hover is too aggressive, primary hover is too much of a change, secondary seems useless, normal -> description -> muted doesn't grok consistently val listHoverBackground = namedColor("List.hoverBackground") ?: namedColor("List.dropLineColor") val actionHoverBackground = namedColor("ActionButton.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") diff --git a/gui/src/styles/ThemePage.tsx b/gui/src/styles/ThemePage.tsx index e1075ba02..b365ec535 100644 --- a/gui/src/styles/ThemePage.tsx +++ b/gui/src/styles/ThemePage.tsx @@ -104,7 +104,7 @@ function ThemePage() { onClick={() => navigate(ROUTES.HOME)} > ← - Back to Settings + Back to Chat

Theme Tester @@ -214,7 +214,7 @@ function ThemePage() { CSS Var

- Fallback + Default
{Object.entries(THEME_COLORS).map(([colorName, val]) => ( Date: Wed, 21 May 2025 18:30:28 -0700 Subject: [PATCH 45/58] jetbrains color tweaks - primary button --- .../continue/GetTheme.kt | 70 ++++++++++++++++--- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index be28db2e8..357757fe0 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -8,6 +8,7 @@ import kotlin.math.max import kotlin.math.min import com.intellij.ui.JBColor import com.intellij.ui.ColorUtil +import kotlin.math.roundToInt class GetTheme { fun getSecondaryDark(): Color { @@ -59,23 +60,66 @@ class GetTheme { return color } + fun lighten(color: Color, percentage: Int = 5): Color { + // Increase each RGB component slightly + val factor = 1 + percentage / 100f; + fun lightenInt(value: Int): Int { + return (value * factor).roundToInt().coerceAtMost(255) + } + return Color( + lightenInt(color.red), + lightenInt (color.green), + lightenInt(color.blue), + color.alpha + ) + } + + fun darken(color: Color, percentage: Int = 5): Color { + // Decrease each RGB component slightly + val factor = 1 - percentage / 100f; + fun darkenInt(value: Int): Int { + return (value * factor).roundToInt().coerceAtLeast(0) + } + return Color( + darkenInt(color.red), + darkenInt(color.green), + darkenInt(color.blue), + color.alpha + ) + } + + fun slightChange(color: Color?, percentage: Int = 5): Color? { + if(color == null){ + return null + } + // If dark, make slightly lighter. If light, make slightly darker + val averageRgb = (color.red + color.green + color.blue) / 3 + return if (averageRgb > 128) darken(color, percentage) else lighten(color, percentage) + } + fun getTheme(): Map { try { val editorScheme = EditorColorsManager.getInstance().globalScheme - // IDE colors val background = JBColor.background() val foreground = JBColor.foreground() val border = JBColor.border() val focusBorder = namedColor("Focus.borderColor") ?: namedColor("Component.focusedBorderColor") - val buttonBackground = namedColor("Button.background") - val buttonForeground = namedColor("Button.foreground") - val buttonHoverBackground = namedColor("Button.hoverBackground") ?: buttonBackground?.brighter() + val buttonBackground = namedColor("Button.default.startBackground") + ?: namedColor("Button.default.background") - val secondaryBackground = getSecondaryDark() - val secondaryHover = secondaryBackground.brighter() + val buttonForeground = namedColor("Button.default.startForeground") + ?: namedColor("Button.default.foreground") + + val buttonHoverBackground = namedColor("Button.default.hoverStartBackground") + ?: namedColor("Button.default.hoverBackground") + ?: namedColor("Button.default.startHoverBackground") + ?: slightChange(buttonBackground) + + val secondaryBackground = namedColor("Button.background") ?: background + val secondaryHoverBackground = namedColor("Button.hoverBackground") ?: slightChange(secondaryBackground) val badgeBackground = namedColor("Badge.background") val badgeForeground = namedColor("Badge.foreground") @@ -86,16 +130,20 @@ class GetTheme { val inputBackground = namedColor("TextField.background") val inputForeground = namedColor("TextField.foreground") val inputPlaceholder = namedColor("TextField.inactiveForeground") - // list hover is too aggressive, primary hover is too much of a change, secondary seems useless, normal -> description -> muted doesn't grok consistently - val listHoverBackground = namedColor("List.hoverBackground") ?: namedColor("List.dropLineColor") + + val listHoverBackground = namedColor("List.hoverBackground") ?: slightChange(background) val actionHoverBackground = namedColor("ActionButton.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") val tableOddRow = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") val listSelectionForeground = namedColor("List.selectionForeground") + val description = namedColor("Label.disabledForeground") ?: namedColor("Label.infoForeground") - val description = namedColor("Label.infoForeground") ?: namedColor("ToolTip.foreground") - val mutedDescription = namedColor("Label.disabledForeground") + val mutedDescription = namedColor("Component.infoForeground") + ?: namedColor("ContextHelp.foreground") + ?: namedColor("TextField.placeholderForeground") + ?: namedColor("Label.disabledForeground") + ?: namedColor("ToolTip.foreground") val link = namedColor("Link.activeForeground") @@ -129,7 +177,7 @@ class GetTheme { "primary-hover" to buttonHoverBackground, "secondary-background" to secondaryBackground, "secondary-foreground" to foreground, - "secondary-hover" to secondaryHover, + "secondary-hover" to secondaryHoverBackground, "border" to border, "border-focus" to focusBorder, "command-background" to commandBackground, From e68ae4147ab53ade422f852ba6b022c7b7ffeccc Mon Sep 17 00:00:00 2001 From: James Moughon Date: Thu, 22 May 2025 08:18:52 -0500 Subject: [PATCH 46/58] Update troubleshooting.mdx Adding documentation for Windows cert issues --- docs/docs/troubleshooting.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/troubleshooting.mdx b/docs/docs/troubleshooting.mdx index 9692191eb..405417a27 100644 --- a/docs/docs/troubleshooting.mdx +++ b/docs/docs/troubleshooting.mdx @@ -120,6 +120,8 @@ If you're seeing a `fetch failed` error and your network requires custom certifi You may also set `requestOptions.caBundlePath` to an array of paths to multiple certificates. +***Windows VS Code Users***: Installing the [win-ca](https://marketplace.visualstudio.com/items?itemName=ukoloff.win-ca) extension should also correct this issue. + #### VS Code Proxy Settings If you are using VS Code and require requests to be made through a proxy, you are likely already set up through VS Code's [Proxy Server Support](https://code.visualstudio.com/docs/setup/network#_proxy-server-support). To double-check that this is enabled, use cmd/ctrl + , to open settings and search for "Proxy Support". Unless it is set to "off", then VS Code is responsible for making the request to the proxy. From 505d22da3e8e65fda547523919f008fd032b78ce Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 22 May 2025 19:23:50 +0530 Subject: [PATCH 47/58] specify the schema versions in dev data docs --- docs/docs/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference.md b/docs/docs/reference.md index e8b915813..7773afbfc 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -406,7 +406,7 @@ Destinations to which [development data](./customize/deep-dives/development-data - `destination` (**required**): The destination/endpoint that will receive the data. Can be: - an HTTP endpoint that will receive a POST request with a JSON blob - a file URL to a directory in which events will be dumpted to `.jsonl` files -- `schema` (**required**): the schema version of the JSON blobs to be sent +- `schema` (**required**): the schema version of the JSON blobs to be sent. Options include `0.1.0` and `0.2.0` - `events`: an array of event names to include. Defaults to all events if not specified. - `level`: a pre-defined filter for event fields. Options include `all` and `noCode`; the latter excludes data like file contents, prompts, and completions. Defaults to `all` From 1b24a7c185ae92c3af4b9bb729ea1a492321740e Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 08:41:02 -0700 Subject: [PATCH 48/58] watsonx-openai-adapter --- extensions/vscode/package-lock.json | 4 +- packages/openai-adapters/src/apis/WatsonX.ts | 228 +++++++++++++++++++ packages/openai-adapters/src/index.ts | 11 +- packages/openai-adapters/src/types.ts | 10 + 4 files changed, 248 insertions(+), 5 deletions(-) create mode 100644 packages/openai-adapters/src/apis/WatsonX.ts diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index bdd37caf7..313cf7175 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.36", + "version": "1.1.38", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.36", + "version": "1.1.38", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", diff --git a/packages/openai-adapters/src/apis/WatsonX.ts b/packages/openai-adapters/src/apis/WatsonX.ts new file mode 100644 index 000000000..88306da7e --- /dev/null +++ b/packages/openai-adapters/src/apis/WatsonX.ts @@ -0,0 +1,228 @@ +import { streamSse } from "@continuedev/fetch"; +import { OpenAI } from "openai/index"; +import { + ChatCompletion, + ChatCompletionChunk, + ChatCompletionCreateParamsNonStreaming, + ChatCompletionCreateParamsStreaming, + Completion, + CompletionCreateParamsNonStreaming, + CompletionCreateParamsStreaming, +} from "openai/resources/index"; +import { ChatCompletionCreateParams } from "openai/src/resources/index.js"; +import { WatsonXConfig } from "../types.js"; +import { customFetch } from "../util.js"; +import { + BaseLlmApi, + CreateRerankResponse, + FimCreateParamsStreaming, + RerankCreateParams, +} from "./base.js"; + +export class WatsonXApi implements BaseLlmApi { + apiBase: string; + apiVersion: string = "2023-05-29"; + projectId?: string; + deploymentId?: string; + + constructor(protected config: WatsonXConfig) { + this.apiBase = config.apiBase ?? "https://us-south.ml.cloud.ibm.com"; + if (!this.apiBase.endsWith("/")) { + this.apiBase += "/"; + } + this.apiVersion = config.apiVersion ?? this.apiVersion; + this.projectId = config.projectId; + this.deploymentId = config.deploymentId; + } + + private getHeaders(): Record { + return { + "Content-Type": "application/json", + Authorization: `Bearer ${this.config.apiKey}`, + }; + } + + private getEndpoint(endpoint: string): string { + return `${this.apiBase}ml/v1/${this.deploymentId ? `deployments/${this.deploymentId}/` : ""}text/${endpoint}_stream?version=${this.apiVersion}`; + } + + private _convertBody(oaiBody: ChatCompletionCreateParams) { + const stopSequences = oaiBody.stop + ? Array.isArray(oaiBody.stop) + ? oaiBody.stop.filter((s) => s.trim() !== "") + : [oaiBody.stop] + : undefined; + + const payload: any = { + messages: oaiBody.messages, + max_tokens: oaiBody.max_tokens ?? 1024, + stop: stopSequences, + frequency_penalty: oaiBody.frequency_penalty, + presence_penalty: oaiBody.presence_penalty, + }; + + if (!this.deploymentId) { + payload.model_id = oaiBody.model; + payload.project_id = this.projectId; + } + + if (oaiBody.temperature !== undefined) { + payload.temperature = oaiBody.temperature; + } + + if (oaiBody.top_p !== undefined) { + payload.top_p = oaiBody.top_p; + } + + if (oaiBody.tools) { + payload.tools = oaiBody.tools; + if (oaiBody.tool_choice) { + payload.tool_choice = oaiBody.tool_choice; + } else { + payload.tool_choice_option = "auto"; + } + } + + return payload; + } + + async chatCompletionNonStream( + body: ChatCompletionCreateParamsNonStreaming, + signal: AbortSignal, + ): Promise { + throw new Error("Method not implemented."); + } + + async *chatCompletionStream( + body: ChatCompletionCreateParamsStreaming, + signal: AbortSignal, + ): AsyncGenerator { + const url = this.getEndpoint("chat"); + const response = await customFetch(this.config.requestOptions)(url, { + method: "POST", + headers: this.getHeaders(), + body: JSON.stringify(this._convertBody(body)), + signal, + }); + + if (!response.ok || !response.body) { + throw new Error( + `Failed to stream chat completion: ${await response.text()}`, + ); + } + + for await (const value of streamSse(response as any)) { + const chunk = value; + yield chunk; + } + } + + async completionNonStream( + body: CompletionCreateParamsNonStreaming, + signal: AbortSignal, + ): Promise { + throw new Error("Method not implemented."); + } + + async *completionStream( + body: CompletionCreateParamsStreaming, + signal: AbortSignal, + ): AsyncGenerator { + const params = { + decoding_method: body.temperature ? "sample" : "greedy", + max_new_tokens: body.max_tokens ?? 1024, + min_new_tokens: 1, + stop_sequences: body.stop + ? Array.isArray(body.stop) + ? body.stop + : [body.stop] + : [], + include_stop_sequence: false, + repetition_penalty: body.frequency_penalty || 1, + temperature: body.temperature, + top_p: body.top_p, + top_k: 100, + }; + + const payload: any = { + input: body.prompt, + parameters: params, + }; + + if (!this.deploymentId) { + payload.model_id = body.model; + payload.project_id = this.projectId; + } + + const url = this.getEndpoint("generation"); + const response = await customFetch(this.config.requestOptions)(url, { + method: "POST", + headers: this.getHeaders(), + body: JSON.stringify(payload), + signal, + }); + + if (!response.ok || !response.body) { + throw new Error(`Failed to stream completion: ${await response.text()}`); + } + + let generatedText = ""; + for await (const value of streamSse(response as any)) { + const lines = value.toString().split("\n"); + let generatedChunk = ""; + + lines.forEach((line: string) => { + if (line.startsWith("data:")) { + const dataStr = line.replace(/^data:\s+/, ""); + try { + const data = JSON.parse(dataStr); + data.results.forEach((result: any) => { + generatedChunk += result.generated_text || ""; + }); + } catch (e) { + // parsing error is expected with streaming response + } + } + }); + + if (generatedChunk) { + generatedText += generatedChunk; + yield { + id: `watsonx-${Date.now()}`, + object: "text_completion", + created: Date.now(), + model: body.model, + choices: [ + { + text: generatedChunk, + index: 0, + logprobs: null, + finish_reason: "stop", + }, + ], + }; + } + } + } + + async *fimStream( + body: FimCreateParamsStreaming, + signal: AbortSignal, + ): AsyncGenerator { + throw new Error("Method not implemented."); + } + + async embed( + body: OpenAI.Embeddings.EmbeddingCreateParams, + ): Promise { + throw new Error("Method not implemented."); + } + + async rerank(body: RerankCreateParams): Promise { + throw new Error("Method not implemented."); + } + + async list(): Promise { + throw new Error("Method not implemented."); + } +} diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index e9ac7501b..eea617cf7 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -11,6 +11,7 @@ import { MockApi } from "./apis/Mock.js"; import { MoonshotApi } from "./apis/Moonshot.js"; import { OpenAIApi } from "./apis/OpenAI.js"; import { RelaceApi } from "./apis/Relace.js"; +import { WatsonXApi } from "./apis/WatsonX.js"; import { BaseLlmApi } from "./apis/base.js"; import { LLMConfig, OpenAIConfigSchema } from "./types.js"; @@ -48,6 +49,8 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { return new RelaceApi(config); case "inception": return new InceptionApi(config); + case "watsonx": + return new WatsonXApi(config); case "x-ai": return openAICompatible("https://api.x.ai/v1/", config); case "voyage": @@ -75,7 +78,10 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { case "nvidia": return openAICompatible("https://integrate.api.nvidia.com/v1/", config); case "ovhcloud": - return openAICompatible("https://oai.endpoints.kepler.ai.cloud.ovh.net/v1/", config); + return openAICompatible( + "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1/", + config, + ); case "scaleway": return openAICompatible("https://api.scaleway.ai/v1/", config); case "fireworks": @@ -111,10 +117,9 @@ export { type Completion, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, - type CompletionCreateParamsStreaming + type CompletionCreateParamsStreaming, } from "openai/resources/index"; // export export type { BaseLlmApi } from "./apis/base.js"; export type { LLMConfig } from "./types.js"; - diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index a5e8c4955..e7478ed53 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -99,6 +99,15 @@ export const AnthropicConfigSchema = OpenAIConfigSchema.extend({ }); export type AnthropicConfig = z.infer; +export const WatsonXConfigSchema = BasePlusConfig.extend({ + provider: z.literal("watsonx"), + apiKey: z.string(), + apiVersion: z.string().optional(), + projectId: z.string().optional(), + deploymentId: z.string().optional(), +}); +export type WatsonXConfig = z.infer; + export const JinaConfigSchema = OpenAIConfigSchema.extend({ provider: z.literal("jina"), }); @@ -118,6 +127,7 @@ export const LLMConfigSchema = z.discriminatedUnion("provider", [ AzureConfigSchema, GeminiConfigSchema, AnthropicConfigSchema, + WatsonXConfigSchema, JinaConfigSchema, MockConfigSchema, InceptionConfigSchema, From b24a76fdabb5eccada838d8fe5ed5834c0120df1 Mon Sep 17 00:00:00 2001 From: chezsmithy Date: Thu, 22 May 2025 13:28:49 -0700 Subject: [PATCH 49/58] feat: :sparkles: Add support for Claude Sonnet 4 --- core/llm/llms/Bedrock.ts | 2 +- core/llm/toolSupport.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index 7ca0f801c..3b44e1f61 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -306,7 +306,7 @@ class Bedrock extends BaseLLM { } const supportsTools = - PROVIDER_TOOL_SUPPORT.bedrock?.(options.model || "") ?? false; + (this.capabilities?.tools || PROVIDER_TOOL_SUPPORT.bedrock?.(options.model)) ?? false; let toolConfig = supportsTools && options.tools ? { diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index cd14586bb..f08e3cf8a 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -17,6 +17,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< "claude-3.5", "claude-3-7", "claude-3.7", + "claude-sonnet-4", "gpt-4", "o3", "gemini", @@ -24,7 +25,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< }, anthropic: (model) => { if ( - ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) => + ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7","claude-sonnet-4"].some((part) => model.toLowerCase().startsWith(part), ) ) { @@ -76,7 +77,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< // For Bedrock, only support Claude Sonnet models with versions 3.5/3-5 and 3.7/3-7 if ( model.toLowerCase().includes("sonnet") && - ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) => + ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7","claude-sonnet-4"].some((part) => model.toLowerCase().includes(part), ) ) { From 6d4857bf32b4cec864a7601a34a7d232f44fcb46 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 19:01:00 -0700 Subject: [PATCH 50/58] pass `env` to continueProperties --- core/llm/llms/stubs/ContinueProxy.ts | 3 +++ packages/config-yaml/package.json | 2 +- packages/config-yaml/src/load/clientRender.ts | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/llm/llms/stubs/ContinueProxy.ts b/core/llm/llms/stubs/ContinueProxy.ts index e43e2bfe2..806924966 100644 --- a/core/llm/llms/stubs/ContinueProxy.ts +++ b/core/llm/llms/stubs/ContinueProxy.ts @@ -26,9 +26,11 @@ class ContinueProxy extends OpenAI { // but we need to keep track of the actual values that the proxy will use // to call whatever LLM API is chosen private actualApiBase?: string; + private env?: Record; constructor(options: LLMOptions) { super(options); + this.env = options.env; this.actualApiBase = options.apiBase; this.apiKeyLocation = options.apiKeyLocation; this.orgScopeId = options.orgScopeId; @@ -48,6 +50,7 @@ class ContinueProxy extends OpenAI { apiKeyLocation: this.apiKeyLocation, apiBase: this.actualApiBase, orgScopeId: this.orgScopeId ?? null, + env: this.env, }; return { continueProperties, diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index f538969ea..5499f7a50 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.87", + "version": "1.0.88", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/load/clientRender.ts b/packages/config-yaml/src/load/clientRender.ts index 18a0aebd0..46001b847 100644 --- a/packages/config-yaml/src/load/clientRender.ts +++ b/packages/config-yaml/src/load/clientRender.ts @@ -160,6 +160,7 @@ export const continuePropertiesSchema = z.object({ apiKeyLocation: z.string().optional(), apiBase: z.string().optional(), orgScopeId: z.string().nullable(), + env: z.record(z.string(), z.any()).optional(), }); export type ContinueProperties = z.infer; From 73b576f40c31c636921b68911ea3712d39887b10 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 19:18:12 -0700 Subject: [PATCH 51/58] fix watsonx tests (openai-adapters) --- packages/openai-adapters/src/apis/WatsonX.ts | 91 +++++++++++++++++-- .../openai-adapters/src/test/main.test.ts | 1 + packages/openai-adapters/src/types.ts | 8 +- 3 files changed, 87 insertions(+), 13 deletions(-) diff --git a/packages/openai-adapters/src/apis/WatsonX.ts b/packages/openai-adapters/src/apis/WatsonX.ts index 88306da7e..e9980b782 100644 --- a/packages/openai-adapters/src/apis/WatsonX.ts +++ b/packages/openai-adapters/src/apis/WatsonX.ts @@ -30,18 +30,85 @@ export class WatsonXApi implements BaseLlmApi { if (!this.apiBase.endsWith("/")) { this.apiBase += "/"; } - this.apiVersion = config.apiVersion ?? this.apiVersion; - this.projectId = config.projectId; - this.deploymentId = config.deploymentId; + this.apiVersion = config.env.apiVersion ?? this.apiVersion; + this.projectId = config.env.projectId; + this.deploymentId = config.env.deploymentId; } - private getHeaders(): Record { + private async getHeaders(): Promise> { + const bearer = await this.getBearerToken(); return { "Content-Type": "application/json", - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `Bearer ${bearer.token}`, }; } + async getBearerToken(): Promise<{ token: string; expiration: number }> { + if (this.apiBase?.includes("cloud.ibm.com")) { + // watsonx SaaS + const wxToken = (await ( + await customFetch(this.config.requestOptions)( + `https://iam.cloud.ibm.com/identity/token?apikey=${this.config.apiKey}&grant_type=urn:ibm:params:oauth:grant-type:apikey`, + { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + Accept: "application/json", + }, + }, + ) + ).json()) as any; + return { + token: wxToken["access_token"], + expiration: wxToken["expiration"], + }; + } else { + // watsonx Software + if (!this.config.apiKey?.includes(":")) { + // Using ZenApiKey auth + return { + token: this.config.apiKey ?? "", + expiration: -1, + }; + } else { + // Using username/password auth + const userPass = this.config.apiKey?.split(":"); + const wxToken = (await ( + await customFetch(this.config.requestOptions)( + `${this.apiBase}/icp4d-api/v1/authorize`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify({ + username: userPass[0], + password: userPass[1], + }), + }, + ) + ).json()) as any; + const wxTokenExpiry = (await ( + await customFetch(this.config.requestOptions)( + `${this.apiBase}/usermgmt/v1/user/tokenExpiry`, + { + method: "GET", + headers: { + Accept: "application/json", + Authorization: `Bearer ${wxToken["token"]}`, + }, + }, + ) + ).json()) as any; + return { + token: wxToken["token"], + expiration: wxTokenExpiry["exp"], + }; + } + } + } + private getEndpoint(endpoint: string): string { return `${this.apiBase}ml/v1/${this.deploymentId ? `deployments/${this.deploymentId}/` : ""}text/${endpoint}_stream?version=${this.apiVersion}`; } @@ -98,10 +165,12 @@ export class WatsonXApi implements BaseLlmApi { signal: AbortSignal, ): AsyncGenerator { const url = this.getEndpoint("chat"); + const headers = await this.getHeaders(); + const stringifiedBody = JSON.stringify(this._convertBody(body)); const response = await customFetch(this.config.requestOptions)(url, { method: "POST", - headers: this.getHeaders(), - body: JSON.stringify(this._convertBody(body)), + headers, + body: stringifiedBody, signal, }); @@ -112,8 +181,10 @@ export class WatsonXApi implements BaseLlmApi { } for await (const value of streamSse(response as any)) { - const chunk = value; - yield chunk; + if (!value.choices?.[0]) { + continue; + } + yield value; } } @@ -157,7 +228,7 @@ export class WatsonXApi implements BaseLlmApi { const url = this.getEndpoint("generation"); const response = await customFetch(this.config.requestOptions)(url, { method: "POST", - headers: this.getHeaders(), + headers: await this.getHeaders(), body: JSON.stringify(payload), signal, }); diff --git a/packages/openai-adapters/src/test/main.test.ts b/packages/openai-adapters/src/test/main.test.ts index 4222216ff..6d838a48c 100644 --- a/packages/openai-adapters/src/test/main.test.ts +++ b/packages/openai-adapters/src/test/main.test.ts @@ -10,6 +10,7 @@ function testConfig(config: ModelConfig) { provider: config.provider as any, apiKey: config.apiKey, apiBase: config.apiBase, + env: config.env, }); if (false) { diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index e7478ed53..fd7ad94db 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -102,9 +102,11 @@ export type AnthropicConfig = z.infer; export const WatsonXConfigSchema = BasePlusConfig.extend({ provider: z.literal("watsonx"), apiKey: z.string(), - apiVersion: z.string().optional(), - projectId: z.string().optional(), - deploymentId: z.string().optional(), + env: z.object({ + apiVersion: z.string().optional(), + projectId: z.string().optional(), + deploymentId: z.string().optional(), + }), }); export type WatsonXConfig = z.infer; From 1e52abab863165de68dfc9541b5aa21977322dca Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 19:22:41 -0700 Subject: [PATCH 52/58] implement chat non-stream in watsonx openai-adapter --- packages/openai-adapters/src/apis/WatsonX.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/openai-adapters/src/apis/WatsonX.ts b/packages/openai-adapters/src/apis/WatsonX.ts index e9980b782..3962662d2 100644 --- a/packages/openai-adapters/src/apis/WatsonX.ts +++ b/packages/openai-adapters/src/apis/WatsonX.ts @@ -11,7 +11,7 @@ import { } from "openai/resources/index"; import { ChatCompletionCreateParams } from "openai/src/resources/index.js"; import { WatsonXConfig } from "../types.js"; -import { customFetch } from "../util.js"; +import { chatCompletion, customFetch } from "../util.js"; import { BaseLlmApi, CreateRerankResponse, @@ -157,7 +157,22 @@ export class WatsonXApi implements BaseLlmApi { body: ChatCompletionCreateParamsNonStreaming, signal: AbortSignal, ): Promise { - throw new Error("Method not implemented."); + const generator = this.chatCompletionStream( + { + ...body, + stream: true, + }, + signal, + ); + + let content = ""; + for await (const chunk of generator) { + content += chunk.choices[0].delta.content ?? ""; + } + return chatCompletion({ + content, + model: body.model, + }); } async *chatCompletionStream( From e957171f586817c1696755367f0f7acf95611453 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 19:25:09 -0700 Subject: [PATCH 53/58] publish new version --- packages/openai-adapters/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/openai-adapters/package.json b/packages/openai-adapters/package.json index 766b93eb5..966f5a858 100644 --- a/packages/openai-adapters/package.json +++ b/packages/openai-adapters/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/openai-adapters", - "version": "1.0.21", + "version": "1.0.26", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From abd7ebe0cb16371bcc4615f531fcf766d406ff14 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 19:26:30 -0700 Subject: [PATCH 54/58] x --- packages/openai-adapters/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/openai-adapters/README.md b/packages/openai-adapters/README.md index 2f29fbf0d..1f8c849ad 100644 --- a/packages/openai-adapters/README.md +++ b/packages/openai-adapters/README.md @@ -64,7 +64,7 @@ They are concerned with: - [x] Vllm - [ ] Vertex AI - [x] Voyage AI -- [ ] WatsonX +- [x] WatsonX - [x] xAI - [x] Fireworks - [x] Moonshot From 606ccb8c840a1e73e1150d783c1d9d865284e2f6 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 20:09:00 -0700 Subject: [PATCH 55/58] fix type errors --- core/llm/llms/stubs/ContinueProxy.ts | 8 +++++--- core/package-lock.json | 2 +- gui/package-lock.json | 2 +- packages/config-yaml/package-lock.json | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/llm/llms/stubs/ContinueProxy.ts b/core/llm/llms/stubs/ContinueProxy.ts index 806924966..29c892bc8 100644 --- a/core/llm/llms/stubs/ContinueProxy.ts +++ b/core/llm/llms/stubs/ContinueProxy.ts @@ -26,11 +26,13 @@ class ContinueProxy extends OpenAI { // but we need to keep track of the actual values that the proxy will use // to call whatever LLM API is chosen private actualApiBase?: string; - private env?: Record; + + // Contains extra properties that we pass along to the proxy. Originally from `env` property on LLMOptions + private configEnv?: Record; constructor(options: LLMOptions) { super(options); - this.env = options.env; + this.configEnv = options.env; this.actualApiBase = options.apiBase; this.apiKeyLocation = options.apiKeyLocation; this.orgScopeId = options.orgScopeId; @@ -50,7 +52,7 @@ class ContinueProxy extends OpenAI { apiKeyLocation: this.apiKeyLocation, apiBase: this.actualApiBase, orgScopeId: this.orgScopeId ?? null, - env: this.env, + env: this.configEnv, }; return { continueProperties, diff --git a/core/package-lock.json b/core/package-lock.json index 8592b627c..8e0db053e 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -138,7 +138,7 @@ }, "../packages/config-yaml": { "name": "@continuedev/config-yaml", - "version": "1.0.87", + "version": "1.0.88", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", diff --git a/gui/package-lock.json b/gui/package-lock.json index 8c95b8f38..b3c4bb0be 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -211,7 +211,7 @@ }, "../packages/config-yaml": { "name": "@continuedev/config-yaml", - "version": "1.0.87", + "version": "1.0.88", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", diff --git a/packages/config-yaml/package-lock.json b/packages/config-yaml/package-lock.json index bef305fe9..dc3a327ed 100644 --- a/packages/config-yaml/package-lock.json +++ b/packages/config-yaml/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.87", + "version": "1.0.88", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/config-yaml", - "version": "1.0.87", + "version": "1.0.88", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", From 4aafea8a556bd22a67b3714a79ac3076dfecc77e Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 20:09:13 -0700 Subject: [PATCH 56/58] bump package.json --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 731a8ce40..a9eddcfe1 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.38", + "version": "1.1.39", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 35f1e2746ec866962d4987306226bd5ab2e63883 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 22:15:34 -0700 Subject: [PATCH 57/58] add type and url to mcp config --- packages/config-yaml/src/schemas/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 35e110206..957134416 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -12,10 +12,12 @@ export const contextSchema = z.object({ const mcpServerSchema = z.object({ name: z.string(), command: z.string(), + type: z.enum(["sse", "stdio"]).optional(), + url: z.string().optional(), faviconUrl: z.string().optional(), args: z.array(z.string()).optional(), env: z.record(z.string()).optional(), - connectionTimeout: z.number().gt(0).optional() + connectionTimeout: z.number().gt(0).optional(), }); export type MCPServer = z.infer; From 92ea6676b0d2f316c1dd8f476897ddce2def9bad Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 22 May 2025 22:34:20 -0700 Subject: [PATCH 58/58] allow sse MCP definition in config-yaml --- core/config/yaml/loadYaml.ts | 4 ++-- extensions/vscode/package-lock.json | 4 ++-- packages/config-yaml/src/schemas/index.ts | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 7c18aec00..0a0dd03fc 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -71,7 +71,7 @@ function convertYamlMcpToContinueMcp( command: server.command, args: server.args ?? [], env: server.env, - }, + } as any, // TODO: Fix the mcpServers types in config-yaml (discriminated union) timeout: server.connectionTimeout, }; } @@ -458,7 +458,7 @@ async function configYamlToContinueConfig(options: { transport: { type: "stdio", args: [], - ...server, + ...(server as any), // TODO: fix the types on mcpServers in config-yaml }, timeout: server.connectionTimeout, })), diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8c0ea0739..6c1b47cf6 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.38", + "version": "1.1.39", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.38", + "version": "1.1.39", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 957134416..1a8eb9471 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -9,9 +9,10 @@ export const contextSchema = z.object({ params: z.any().optional(), }); +// TODO: This should be a discriminated union by type const mcpServerSchema = z.object({ name: z.string(), - command: z.string(), + command: z.string().optional(), type: z.enum(["sse", "stdio"]).optional(), url: z.string().optional(), faviconUrl: z.string().optional(),