From 0dbd944cfba0626423016045c5b9ab60a2b37f2a Mon Sep 17 00:00:00 2001 From: David Ichim Date: Fri, 11 Oct 2024 10:40:32 +0300 Subject: [PATCH 1/6] Chat: brought back syntax highlighting for most common languages such as dart or scss - Updated rehype-highlight to ^7.0.0 in orde to get rid of lowlight 2.9.0 and load only version 3.1.0 - Added dependency on highlight.js since we load these extra syntax languages and tslint complains if we don't add it --- pnpm-lock.yaml | 139 +++--------------- vscode/package.json | 3 +- .../webviews/components/MarkdownFromCody.tsx | 64 ++------ vscode/webviews/utils/highlight.ts | 37 +++++ 4 files changed, 71 insertions(+), 172 deletions(-) create mode 100644 vscode/webviews/utils/highlight.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 865e78c31cf5..b7f6158e164e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -555,6 +555,9 @@ importers: he: specifier: ^1.2.0 version: 1.2.0 + highlight.js: + specifier: 11.9.0 + version: 11.9.0 http-proxy-agent: specifier: ^7.0.2 version: 7.0.2 @@ -604,8 +607,8 @@ importers: specifier: ^5.1.1 version: 5.1.1(react-dom@18.2.0)(react@18.2.0) rehype-highlight: - specifier: ^6.0.0 - version: 6.0.0 + specifier: ^7.0.0 + version: 7.0.0 rehype-sanitize: specifier: ^6.0.0 version: 6.0.0 @@ -6473,12 +6476,6 @@ packages: '@types/node': 20.12.7 dev: true - /@types/hast@2.3.10: - resolution: {integrity: sha512-McWspRw8xx8J9HurkVBfYj0xKoE25tOFlHGdx4MJ5xORQrMGZNqJhVQWaIbm6Oyla5kYOXtDiopzKRJzEOkwJw==} - dependencies: - '@types/unist': 2.0.10 - dev: false - /@types/hast@3.0.4: resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} dependencies: @@ -9401,12 +9398,6 @@ packages: dependencies: reusify: 1.0.4 - /fault@2.0.1: - resolution: {integrity: sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==} - dependencies: - format: 0.2.2 - dev: false - /fd-slicer@1.1.0: resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} dependencies: @@ -9583,11 +9574,6 @@ packages: combined-stream: 1.0.8 mime-types: 2.1.35 - /format@0.2.2: - resolution: {integrity: sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==} - engines: {node: '>=0.4.x'} - dev: false - /formdata-node@4.4.1: resolution: {integrity: sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==} engines: {node: '>= 12.20'} @@ -10110,18 +10096,10 @@ packages: '@types/hast': 3.0.4 dev: true - /hast-util-is-element@2.1.3: - resolution: {integrity: sha512-O1bKah6mhgEq2WtVMk+Ta5K7pPMqsBBlmzysLdcwKVrqzZQ0CHqUPiIVspNhAG1rvxpvJjtGee17XfauZYKqVA==} - dependencies: - '@types/hast': 2.3.10 - '@types/unist': 2.0.10 - dev: false - /hast-util-is-element@3.0.0: resolution: {integrity: sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==} dependencies: '@types/hast': 3.0.4 - dev: true /hast-util-sanitize@5.0.1: resolution: {integrity: sha512-IGrgWLuip4O2nq5CugXy4GI2V8kx4sFVy5Hd4vF7AR2gxS0N9s7nEAVUyeMtZKZvzrxVsHt73XdTsno1tClIkQ==} @@ -10159,13 +10137,13 @@ packages: '@types/hast': 3.0.4 dev: true - /hast-util-to-text@3.1.2: - resolution: {integrity: sha512-tcllLfp23dJJ+ju5wCCZHVpzsQQ43+moJbqVX3jNWPB7z/KFC4FyZD6R7y94cHL6MQ33YtMZL8Z0aIXXI4XFTw==} + /hast-util-to-text@4.0.2: + resolution: {integrity: sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==} dependencies: - '@types/hast': 2.3.10 - '@types/unist': 2.0.10 - hast-util-is-element: 2.1.3 - unist-util-find-after: 4.0.1 + '@types/hast': 3.0.4 + '@types/unist': 3.0.2 + hast-util-is-element: 3.0.0 + unist-util-find-after: 5.0.0 dev: false /hast-util-whitespace@3.0.0: @@ -10183,11 +10161,6 @@ packages: engines: {node: '>=10.0.0'} dev: true - /highlight.js@11.8.0: - resolution: {integrity: sha512-MedQhoqVdr0U6SSnWPzfiadUcDHfN/Wzq25AkXiQv9oiOO/sG0S7XkvpFIqWBl9Yq1UYyYOOVORs5UW2XlPyzg==} - engines: {node: '>=12.0.0'} - dev: false - /highlight.js@11.9.0: resolution: {integrity: sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==} engines: {node: '>=12.0.0'} @@ -10572,11 +10545,6 @@ packages: resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} dev: false - /is-buffer@2.0.5: - resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==} - engines: {node: '>=4'} - dev: false - /is-callable@1.2.7: resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} engines: {node: '>= 0.4'} @@ -11454,14 +11422,6 @@ packages: tslib: 2.1.0 dev: true - /lowlight@2.9.0: - resolution: {integrity: sha512-OpcaUTCLmHuVuBcyNckKfH5B0oA4JUavb/M/8n9iAvanJYNQkrVm4pvyX0SUaqkBG4dnWHKt7p50B3ngAG2Rfw==} - dependencies: - '@types/hast': 2.3.10 - fault: 2.0.1 - highlight.js: 11.8.0 - dev: false - /lowlight@3.1.0: resolution: {integrity: sha512-CEbNVoSikAxwDMDPjXlqlFYiZLkDJHwyGu/MfOsJnF3d7f3tds5J3z8s/l9TMXhzfsJCCJEAsD78842mwmg0PQ==} dependencies: @@ -14012,14 +13972,14 @@ packages: unist-util-visit: 5.0.0 dev: true - /rehype-highlight@6.0.0: - resolution: {integrity: sha512-q7UtlFicLhetp7K48ZgZiJgchYscMma7XjzX7t23bqEJF8m6/s+viXQEe4oHjrATTIZpX7RG8CKD7BlNZoh9gw==} + /rehype-highlight@7.0.0: + resolution: {integrity: sha512-QtobgRgYoQaK6p1eSr2SD1i61f7bjF2kZHAQHxeCHAuJf7ZUDMvQ7owDq9YTkmar5m5TSUol+2D3bp3KfJf/oA==} dependencies: - '@types/hast': 2.3.10 - hast-util-to-text: 3.1.2 - lowlight: 2.9.0 - unified: 10.1.2 - unist-util-visit: 4.1.2 + '@types/hast': 3.0.4 + hast-util-to-text: 4.0.2 + lowlight: 3.1.0 + unist-util-visit: 5.0.0 + vfile: 6.0.1 dev: false /rehype-sanitize@6.0.0: @@ -15643,18 +15603,6 @@ packages: engines: {node: '>=4'} dev: true - /unified@10.1.2: - resolution: {integrity: sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==} - dependencies: - '@types/unist': 2.0.10 - bail: 2.0.2 - extend: 3.0.2 - is-buffer: 2.0.5 - is-plain-obj: 4.1.0 - trough: 2.2.0 - vfile: 5.3.7 - dev: false - /unified@11.0.5: resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==} dependencies: @@ -15698,17 +15646,11 @@ packages: crypto-random-string: 2.0.0 dev: true - /unist-util-find-after@4.0.1: - resolution: {integrity: sha512-QO/PuPMm2ERxC6vFXEPtmAutOopy5PknD+Oq64gGwxKtk4xwo9Z97t9Av1obPmGU0IyTa6EKYUfTrK2QJS3Ozw==} + /unist-util-find-after@5.0.0: + resolution: {integrity: sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==} dependencies: - '@types/unist': 2.0.10 - unist-util-is: 5.2.1 - dev: false - - /unist-util-is@5.2.1: - resolution: {integrity: sha512-u9njyyfEh43npf1M+yGKDGVPbY/JWEemg5nH05ncKPfi+kBbKBJoTdsogMu33uhytuLlv9y0O7GH7fEdwLdLQw==} - dependencies: - '@types/unist': 2.0.10 + '@types/unist': 3.0.2 + unist-util-is: 6.0.0 dev: false /unist-util-is@6.0.0: @@ -15729,39 +15671,18 @@ packages: unist-util-visit: 5.0.0 dev: false - /unist-util-stringify-position@3.0.3: - resolution: {integrity: sha512-k5GzIBZ/QatR8N5X2y+drfpWG8IDBzdnVj6OInRNWm1oXrzydiaAT2OQiA8DPRRZyAKb9b6I2a6PxYklZD0gKg==} - dependencies: - '@types/unist': 2.0.10 - dev: false - /unist-util-stringify-position@4.0.0: resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==} dependencies: '@types/unist': 3.0.2 dev: false - /unist-util-visit-parents@5.1.3: - resolution: {integrity: sha512-x6+y8g7wWMyQhL1iZfhIPhDAs7Xwbn9nRosDXl7qoPTSCy0yNxnKc+hWokFifWQIDGi154rdUqKvbCa4+1kLhg==} - dependencies: - '@types/unist': 2.0.10 - unist-util-is: 5.2.1 - dev: false - /unist-util-visit-parents@6.0.1: resolution: {integrity: sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==} dependencies: '@types/unist': 3.0.2 unist-util-is: 6.0.0 - /unist-util-visit@4.1.2: - resolution: {integrity: sha512-MSd8OUGISqHdVvfY9TPhyK2VdUrPgxkUtWSuMHF6XAAFuL4LokseigBnZtPnJMu+FbynTkFNnFlyjxpVKujMRg==} - dependencies: - '@types/unist': 2.0.10 - unist-util-is: 5.2.1 - unist-util-visit-parents: 5.1.3 - dev: false - /unist-util-visit@5.0.0: resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==} dependencies: @@ -15967,13 +15888,6 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} - /vfile-message@3.1.4: - resolution: {integrity: sha512-fa0Z6P8HUrQN4BZaX05SIVXic+7kE3b05PWAtPuYP9QLHsLKYR7/AlLW3NtOrpXRLeawpDLMsVkmk5DG0NXgWw==} - dependencies: - '@types/unist': 2.0.10 - unist-util-stringify-position: 3.0.3 - dev: false - /vfile-message@4.0.2: resolution: {integrity: sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==} dependencies: @@ -15981,15 +15895,6 @@ packages: unist-util-stringify-position: 4.0.0 dev: false - /vfile@5.3.7: - resolution: {integrity: sha512-r7qlzkgErKjobAmyNIkkSpizsFPYiUPuJb5pNW1RB4JcYVZhs4lIbVqk8XPk033CV/1z8ss5pkax8SuhGpcG8g==} - dependencies: - '@types/unist': 2.0.10 - is-buffer: 2.0.5 - unist-util-stringify-position: 3.0.3 - vfile-message: 3.1.4 - dev: false - /vfile@6.0.1: resolution: {integrity: sha512-1bYqc7pt6NIADBJ98UiG0Bn/CHIVOoZ/IyEkqIruLg0mE1BKzkOXY2D6CSqQIcKqgadppE5lrxgWXJmXd7zZJw==} dependencies: diff --git a/vscode/package.json b/vscode/package.json index 5b32e3a500b7..a4afe4b32e9f 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -1360,6 +1360,7 @@ "glob": "^7.2.3", "graceful-fs": "^4.2.11", "he": "^1.2.0", + "highlight.js": "11.9.0", "http-proxy-agent": "^7.0.2", "https-proxy-agent": "^7.0.4", "ini": "^4.1.2", @@ -1376,7 +1377,7 @@ "postcss-scss": "^4.0.9", "react-markdown": "^9.0.1", "react-visibility-sensor": "^5.1.1", - "rehype-highlight": "^6.0.0", + "rehype-highlight": "^7.0.0", "rehype-sanitize": "^6.0.0", "remark-gfm": "^4.0.0", "semver": "^7.5.4", diff --git a/vscode/webviews/components/MarkdownFromCody.tsx b/vscode/webviews/components/MarkdownFromCody.tsx index 28f5350e5a4d..15bea390184e 100644 --- a/vscode/webviews/components/MarkdownFromCody.tsx +++ b/vscode/webviews/components/MarkdownFromCody.tsx @@ -1,5 +1,4 @@ import { CodyIDE } from '@sourcegraph/cody-shared' -import { common } from 'lowlight' import type { ComponentProps, FunctionComponent } from 'react' import { useMemo } from 'react' import Markdown, { defaultUrlTransform } from 'react-markdown' @@ -8,6 +7,7 @@ import rehypeHighlight, { type Options as RehypeHighlightOptions } from 'rehype- import rehypeSanitize, { type Options as RehypeSanitizeOptions, defaultSchema } from 'rehype-sanitize' import remarkGFM from 'remark-gfm' import { remarkAttachFilePathToCodeBlocks } from '../chat/extract-file-path' +import { SYNTAX_HIGHLIGHTING_LANGUAGES } from '../utils/highlight' import { useConfig } from '../utils/useConfig' /** @@ -123,7 +123,12 @@ function markdownPluginProps(): Pick< ...(defaultSchema.attributes?.code || []), // We use `data-file-path` to attach file path metadata to blocks. ['data-file-path'], - ['className', ...LANGUAGES.map(language => `language-${language}`)], + [ + 'className', + ...Object.keys(SYNTAX_HIGHLIGHTING_LANGUAGES).map( + language => `language-${language}` + ), + ], ], }, } satisfies RehypeSanitizeOptions, @@ -135,9 +140,9 @@ function markdownPluginProps(): Pick< rehypeHighlight as any, { detect: true, - languages: Object.fromEntries( - Object.entries(common).filter(([language]) => LANGUAGES.includes(language)) - ), + languages: { + ...SYNTAX_HIGHLIGHTING_LANGUAGES, + }, // `ignoreMissing: true` is required to avoid errors when trying to highlight // partial code blocks received from the LLM that have (e.g.) "```p" for @@ -152,52 +157,3 @@ function markdownPluginProps(): Pick< } return _markdownPluginProps } - -const LANGUAGES = [ - 'apex', - 'bash', - 'c', - 'clojure', - 'cpp', - 'cpp', - 'cs', - 'csharp', - 'css', - 'dart', - 'diff', - 'diff', - 'dockerfile', - 'dockerfile', - 'elixir', - 'fortran', - 'go', - 'graphql', - 'groovy', - 'haskell', - 'html', - 'http', - 'java', - 'javascript', - 'json', - 'jsonc', - 'kotlin', - 'lua', - 'markdown', - 'matlab', - 'nix', - 'objectivec', - 'ocaml', - 'perl', - 'php', - 'python', - 'r', - 'ruby', - 'rust', - 'scala', - 'sql', - 'swift', - 'typescript', - 'verilog', - 'vhdl', - 'yaml', -] diff --git a/vscode/webviews/utils/highlight.ts b/vscode/webviews/utils/highlight.ts new file mode 100644 index 000000000000..03278959b2b0 --- /dev/null +++ b/vscode/webviews/utils/highlight.ts @@ -0,0 +1,37 @@ +import clojure from 'highlight.js/lib/languages/clojure' +import dart from 'highlight.js/lib/languages/dart' +import dockerfile from 'highlight.js/lib/languages/dockerfile' +import elixir from 'highlight.js/lib/languages/elixir' +import fortran from 'highlight.js/lib/languages/fortran' +import groovy from 'highlight.js/lib/languages/groovy' +import haskell from 'highlight.js/lib/languages/haskell' +import http from 'highlight.js/lib/languages/http' +import jsonc from 'highlight.js/lib/languages/json' +import matlab from 'highlight.js/lib/languages/matlab' +import nix from 'highlight.js/lib/languages/nix' +import ocaml from 'highlight.js/lib/languages/ocaml' +import scala from 'highlight.js/lib/languages/scala' +import verilog from 'highlight.js/lib/languages/verilog' +import vhdl from 'highlight.js/lib/languages/vhdl' +import html from 'highlight.js/lib/languages/xml' // highlight.js uses 'xml' for HTML/XML +import { common } from 'lowlight' + +export const SYNTAX_HIGHLIGHTING_LANGUAGES = { + ...common, + clojure, + dart, + dockerfile, + elixir, + fortran, + groovy, + haskell, + html, + http, + jsonc, + matlab, + nix, + ocaml, + scala, + verilog, + vhdl, +} From 4d4cf290e5737c8e91660877bf9cb0742961d964 Mon Sep 17 00:00:00 2001 From: David Ichim Date: Sat, 12 Oct 2024 11:08:48 +0300 Subject: [PATCH 2/6] pin lowlight to version ^2.9.0 and rehype-highlight to ^6.0.0 - As requested in review as it seems there were performance issues with rehype-highlight 7.0.0 as seen in pull request #5313 --- pnpm-lock.yaml | 142 ++++++++++++++++++++++++++++++++++++-------- vscode/package.json | 4 +- 2 files changed, 118 insertions(+), 28 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b7f6158e164e..a5c5a4fddf7c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -577,8 +577,8 @@ importers: specifier: ^4.17.21 version: 4.17.21 lowlight: - specifier: ^3.1.0 - version: 3.1.0 + specifier: ^2.9.0 + version: 2.9.0 lru-cache: specifier: ^10.0.0 version: 10.0.0 @@ -607,8 +607,8 @@ importers: specifier: ^5.1.1 version: 5.1.1(react-dom@18.2.0)(react@18.2.0) rehype-highlight: - specifier: ^7.0.0 - version: 7.0.0 + specifier: ^6.0.0 + version: 6.0.0 rehype-sanitize: specifier: ^6.0.0 version: 6.0.0 @@ -6476,6 +6476,12 @@ packages: '@types/node': 20.12.7 dev: true + /@types/hast@2.3.10: + resolution: {integrity: sha512-McWspRw8xx8J9HurkVBfYj0xKoE25tOFlHGdx4MJ5xORQrMGZNqJhVQWaIbm6Oyla5kYOXtDiopzKRJzEOkwJw==} + dependencies: + '@types/unist': 2.0.10 + dev: false + /@types/hast@3.0.4: resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} dependencies: @@ -9398,6 +9404,12 @@ packages: dependencies: reusify: 1.0.4 + /fault@2.0.1: + resolution: {integrity: sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==} + dependencies: + format: 0.2.2 + dev: false + /fd-slicer@1.1.0: resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} dependencies: @@ -9574,6 +9586,11 @@ packages: combined-stream: 1.0.8 mime-types: 2.1.35 + /format@0.2.2: + resolution: {integrity: sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==} + engines: {node: '>=0.4.x'} + dev: false + /formdata-node@4.4.1: resolution: {integrity: sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==} engines: {node: '>= 12.20'} @@ -10096,10 +10113,18 @@ packages: '@types/hast': 3.0.4 dev: true + /hast-util-is-element@2.1.3: + resolution: {integrity: sha512-O1bKah6mhgEq2WtVMk+Ta5K7pPMqsBBlmzysLdcwKVrqzZQ0CHqUPiIVspNhAG1rvxpvJjtGee17XfauZYKqVA==} + dependencies: + '@types/hast': 2.3.10 + '@types/unist': 2.0.10 + dev: false + /hast-util-is-element@3.0.0: resolution: {integrity: sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==} dependencies: '@types/hast': 3.0.4 + dev: true /hast-util-sanitize@5.0.1: resolution: {integrity: sha512-IGrgWLuip4O2nq5CugXy4GI2V8kx4sFVy5Hd4vF7AR2gxS0N9s7nEAVUyeMtZKZvzrxVsHt73XdTsno1tClIkQ==} @@ -10137,13 +10162,13 @@ packages: '@types/hast': 3.0.4 dev: true - /hast-util-to-text@4.0.2: - resolution: {integrity: sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==} + /hast-util-to-text@3.1.2: + resolution: {integrity: sha512-tcllLfp23dJJ+ju5wCCZHVpzsQQ43+moJbqVX3jNWPB7z/KFC4FyZD6R7y94cHL6MQ33YtMZL8Z0aIXXI4XFTw==} dependencies: - '@types/hast': 3.0.4 - '@types/unist': 3.0.2 - hast-util-is-element: 3.0.0 - unist-util-find-after: 5.0.0 + '@types/hast': 2.3.10 + '@types/unist': 2.0.10 + hast-util-is-element: 2.1.3 + unist-util-find-after: 4.0.1 dev: false /hast-util-whitespace@3.0.0: @@ -10161,6 +10186,11 @@ packages: engines: {node: '>=10.0.0'} dev: true + /highlight.js@11.8.0: + resolution: {integrity: sha512-MedQhoqVdr0U6SSnWPzfiadUcDHfN/Wzq25AkXiQv9oiOO/sG0S7XkvpFIqWBl9Yq1UYyYOOVORs5UW2XlPyzg==} + engines: {node: '>=12.0.0'} + dev: false + /highlight.js@11.9.0: resolution: {integrity: sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==} engines: {node: '>=12.0.0'} @@ -10545,6 +10575,11 @@ packages: resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} dev: false + /is-buffer@2.0.5: + resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==} + engines: {node: '>=4'} + dev: false + /is-callable@1.2.7: resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} engines: {node: '>= 0.4'} @@ -11422,12 +11457,12 @@ packages: tslib: 2.1.0 dev: true - /lowlight@3.1.0: - resolution: {integrity: sha512-CEbNVoSikAxwDMDPjXlqlFYiZLkDJHwyGu/MfOsJnF3d7f3tds5J3z8s/l9TMXhzfsJCCJEAsD78842mwmg0PQ==} + /lowlight@2.9.0: + resolution: {integrity: sha512-OpcaUTCLmHuVuBcyNckKfH5B0oA4JUavb/M/8n9iAvanJYNQkrVm4pvyX0SUaqkBG4dnWHKt7p50B3ngAG2Rfw==} dependencies: - '@types/hast': 3.0.4 - devlop: 1.1.0 - highlight.js: 11.9.0 + '@types/hast': 2.3.10 + fault: 2.0.1 + highlight.js: 11.8.0 dev: false /lru-cache@10.0.0: @@ -13972,14 +14007,14 @@ packages: unist-util-visit: 5.0.0 dev: true - /rehype-highlight@7.0.0: - resolution: {integrity: sha512-QtobgRgYoQaK6p1eSr2SD1i61f7bjF2kZHAQHxeCHAuJf7ZUDMvQ7owDq9YTkmar5m5TSUol+2D3bp3KfJf/oA==} + /rehype-highlight@6.0.0: + resolution: {integrity: sha512-q7UtlFicLhetp7K48ZgZiJgchYscMma7XjzX7t23bqEJF8m6/s+viXQEe4oHjrATTIZpX7RG8CKD7BlNZoh9gw==} dependencies: - '@types/hast': 3.0.4 - hast-util-to-text: 4.0.2 - lowlight: 3.1.0 - unist-util-visit: 5.0.0 - vfile: 6.0.1 + '@types/hast': 2.3.10 + hast-util-to-text: 3.1.2 + lowlight: 2.9.0 + unified: 10.1.2 + unist-util-visit: 4.1.2 dev: false /rehype-sanitize@6.0.0: @@ -15603,6 +15638,18 @@ packages: engines: {node: '>=4'} dev: true + /unified@10.1.2: + resolution: {integrity: sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==} + dependencies: + '@types/unist': 2.0.10 + bail: 2.0.2 + extend: 3.0.2 + is-buffer: 2.0.5 + is-plain-obj: 4.1.0 + trough: 2.2.0 + vfile: 5.3.7 + dev: false + /unified@11.0.5: resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==} dependencies: @@ -15646,11 +15693,17 @@ packages: crypto-random-string: 2.0.0 dev: true - /unist-util-find-after@5.0.0: - resolution: {integrity: sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==} + /unist-util-find-after@4.0.1: + resolution: {integrity: sha512-QO/PuPMm2ERxC6vFXEPtmAutOopy5PknD+Oq64gGwxKtk4xwo9Z97t9Av1obPmGU0IyTa6EKYUfTrK2QJS3Ozw==} dependencies: - '@types/unist': 3.0.2 - unist-util-is: 6.0.0 + '@types/unist': 2.0.10 + unist-util-is: 5.2.1 + dev: false + + /unist-util-is@5.2.1: + resolution: {integrity: sha512-u9njyyfEh43npf1M+yGKDGVPbY/JWEemg5nH05ncKPfi+kBbKBJoTdsogMu33uhytuLlv9y0O7GH7fEdwLdLQw==} + dependencies: + '@types/unist': 2.0.10 dev: false /unist-util-is@6.0.0: @@ -15671,18 +15724,39 @@ packages: unist-util-visit: 5.0.0 dev: false + /unist-util-stringify-position@3.0.3: + resolution: {integrity: sha512-k5GzIBZ/QatR8N5X2y+drfpWG8IDBzdnVj6OInRNWm1oXrzydiaAT2OQiA8DPRRZyAKb9b6I2a6PxYklZD0gKg==} + dependencies: + '@types/unist': 2.0.10 + dev: false + /unist-util-stringify-position@4.0.0: resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==} dependencies: '@types/unist': 3.0.2 dev: false + /unist-util-visit-parents@5.1.3: + resolution: {integrity: sha512-x6+y8g7wWMyQhL1iZfhIPhDAs7Xwbn9nRosDXl7qoPTSCy0yNxnKc+hWokFifWQIDGi154rdUqKvbCa4+1kLhg==} + dependencies: + '@types/unist': 2.0.10 + unist-util-is: 5.2.1 + dev: false + /unist-util-visit-parents@6.0.1: resolution: {integrity: sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==} dependencies: '@types/unist': 3.0.2 unist-util-is: 6.0.0 + /unist-util-visit@4.1.2: + resolution: {integrity: sha512-MSd8OUGISqHdVvfY9TPhyK2VdUrPgxkUtWSuMHF6XAAFuL4LokseigBnZtPnJMu+FbynTkFNnFlyjxpVKujMRg==} + dependencies: + '@types/unist': 2.0.10 + unist-util-is: 5.2.1 + unist-util-visit-parents: 5.1.3 + dev: false + /unist-util-visit@5.0.0: resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==} dependencies: @@ -15888,6 +15962,13 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} + /vfile-message@3.1.4: + resolution: {integrity: sha512-fa0Z6P8HUrQN4BZaX05SIVXic+7kE3b05PWAtPuYP9QLHsLKYR7/AlLW3NtOrpXRLeawpDLMsVkmk5DG0NXgWw==} + dependencies: + '@types/unist': 2.0.10 + unist-util-stringify-position: 3.0.3 + dev: false + /vfile-message@4.0.2: resolution: {integrity: sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==} dependencies: @@ -15895,6 +15976,15 @@ packages: unist-util-stringify-position: 4.0.0 dev: false + /vfile@5.3.7: + resolution: {integrity: sha512-r7qlzkgErKjobAmyNIkkSpizsFPYiUPuJb5pNW1RB4JcYVZhs4lIbVqk8XPk033CV/1z8ss5pkax8SuhGpcG8g==} + dependencies: + '@types/unist': 2.0.10 + is-buffer: 2.0.5 + unist-util-stringify-position: 3.0.3 + vfile-message: 3.1.4 + dev: false + /vfile@6.0.1: resolution: {integrity: sha512-1bYqc7pt6NIADBJ98UiG0Bn/CHIVOoZ/IyEkqIruLg0mE1BKzkOXY2D6CSqQIcKqgadppE5lrxgWXJmXd7zZJw==} dependencies: diff --git a/vscode/package.json b/vscode/package.json index a4afe4b32e9f..44b973555100 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -1367,7 +1367,7 @@ "js-levenshtein": "^1.1.6", "lexical": "^0.17.0", "lodash": "^4.17.21", - "lowlight": "^3.1.0", + "lowlight": "^2.9.0", "lru-cache": "^10.0.0", "lucide-react": "^0.378.0", "mac-ca": "^2.0.3", @@ -1377,7 +1377,7 @@ "postcss-scss": "^4.0.9", "react-markdown": "^9.0.1", "react-visibility-sensor": "^5.1.1", - "rehype-highlight": "^7.0.0", + "rehype-highlight": "^6.0.0", "rehype-sanitize": "^6.0.0", "remark-gfm": "^4.0.0", "semver": "^7.5.4", From c4b8a04ad08e9102ea248601c3b3e2bdd72e55da Mon Sep 17 00:00:00 2001 From: David Ichim Date: Tue, 15 Oct 2024 18:07:07 +0300 Subject: [PATCH 3/6] removed lowlight dependency in favor of importing directly the syntax languages from highligh.js - This way we can trim the bundle even more by importing only languages that should be supported --- pnpm-lock.yaml | 3 -- vscode/package.json | 73 ++++++++++++++++++++++------ vscode/webviews/utils/highlight.ts | 78 +++++++++++++++++++++++++++++- 3 files changed, 134 insertions(+), 20 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a5c5a4fddf7c..15f300a8df67 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -576,9 +576,6 @@ importers: lodash: specifier: ^4.17.21 version: 4.17.21 - lowlight: - specifier: ^2.9.0 - version: 2.9.0 lru-cache: specifier: ^10.0.0 version: 10.0.0 diff --git a/vscode/package.json b/vscode/package.json index 44b973555100..bf14f33376bf 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -56,7 +56,14 @@ "version-bump:patch": "RELEASE_TYPE=patch ts-node-transpile-only ./scripts/version-bump.ts", "version-bump:dry-run": "RELEASE_TYPE=prerelease ts-node-transpile-only ./scripts/version-bump.ts" }, - "categories": ["AI", "Chat", "Programming Languages", "Machine Learning", "Snippets", "Education"], + "categories": [ + "AI", + "Chat", + "Programming Languages", + "Machine Learning", + "Snippets", + "Education" + ], "keywords": [ "cody", "codey", @@ -120,7 +127,11 @@ }, "main": "./dist/extension.node.js", "browser": "./dist/extension.web.js", - "activationEvents": ["onLanguage", "onStartupFinished", "onWebviewPanel:cody.editorPanel"], + "activationEvents": [ + "onLanguage", + "onStartupFinished", + "onWebviewPanel:cody.editorPanel" + ], "contributes": { "walkthroughs": [ { @@ -719,13 +730,17 @@ }, { "command": "cody.supercompletion.jumpTo", - "args": ["next"], + "args": [ + "next" + ], "key": "shift+ctrl+down", "when": "cody.activated && !editorReadonly && cody.hasActionableSupercompletion" }, { "command": "cody.supercompletion.jumpTo", - "args": ["previous"], + "args": [ + "previous" + ], "key": "shift+ctrl+up", "when": "cody.activated && !editorReadonly && cody.hasActionableSupercompletion" } @@ -979,7 +994,10 @@ "order": 2, "type": "string", "markdownDescription": "A Git repository URL to use instead of allowing Cody to infer the Git repository from the workspace.", - "examples": ["https://github.com/sourcegraph/cody", "ssh://git@github.com/sourcegraph/cody"] + "examples": [ + "https://github.com/sourcegraph/cody", + "ssh://git@github.com/sourcegraph/cody" + ] }, "cody.customHeaders": { "order": 4, @@ -1029,12 +1047,18 @@ "order": 6, "type": "string", "markdownDescription": "A custom instruction to be included at the start of all chat messages (e.g. \"Answer all my questions in Spanish.\")", - "examples": ["Answer all my questions in Spanish."] + "examples": [ + "Answer all my questions in Spanish." + ] }, "cody.chat.defaultLocation": { "order": 6, "type": "string", - "enum": ["sticky", "sidebar", "editor"], + "enum": [ + "sticky", + "sidebar", + "editor" + ], "markdownDescription": "Controls where the Cody chat view opens when the user invokes the `Cody: New Chat` command, or the Alt+L and Alt+/ shortcuts.", "enumDescriptions": [ "Opens in the last-activated view location, which is set whenever the user explicitly chooses to open chat in a given location", @@ -1047,7 +1071,9 @@ "order": 7, "type": "string", "markdownDescription": "A custom instruction to be included at the end of all instructions for edit commands (e.g. \"Write all unit tests with Jest instead of detected framework.\")", - "examples": ["Write all unit tests with Jest instead of detected framework."] + "examples": [ + "Write all unit tests with Jest instead of detected framework." + ] }, "cody.codeActions.enabled": { "order": 11, @@ -1093,15 +1119,24 @@ "cody.telemetry.level": { "order": 99, "type": "string", - "enum": ["all", "off"], - "enumDescriptions": ["Sends usage data and errors.", "Disables all extension telemetry."], + "enum": [ + "all", + "off" + ], + "enumDescriptions": [ + "Sends usage data and errors.", + "Disables all extension telemetry." + ], "markdownDescription": "Controls the telemetry about Cody usage and errors. See [Cody usage and privacy notice](https://about.sourcegraph.com/terms/cody-notice).", "default": "all" }, "cody.autocomplete.advanced.provider": { "type": "string", "default": "default", - "enum": ["default", "experimental-ollama"], + "enum": [ + "default", + "experimental-ollama" + ], "enumDescriptions": [ "Our recommended setup with the best balance of quality and latency. We continuously update this for optimal performance.", "Experimental support for Ollama users. Use `cody.autocomplete.experimental.ollamaOptions` to configure requests to Ollama server." @@ -1125,7 +1160,10 @@ }, "cody.experimental.foldingRanges": { "type": "string", - "enum": ["lsp", "indentation-based"], + "enum": [ + "lsp", + "indentation-based" + ], "enumDescriptions": [ "Use folding ranges that are enabled by default in VS Code, and are usually powered by LSP", "Use custom implementation of folding ranges that is indentation based. This is the implementation that is used by other Cody clients like the JetBrains plugin" @@ -1136,7 +1174,11 @@ "cody.autocomplete.experimental.graphContext": { "type": "string", "default": null, - "enum": [null, "tsc", "tsc-mixed"], + "enum": [ + null, + "tsc", + "tsc-mixed" + ], "markdownDescription": "Use the code graph to retrieve context for autocomplete requests." }, "cody.autocomplete.experimental.fireworksOptions": { @@ -1311,7 +1353,9 @@ "untrustedWorkspaces": { "supported": "limited", "description": "Cody only uses providers (configured in `openctx.providers`) from trusted workspaces because providers may execute arbitrary code.", - "restrictedConfigurations": ["openctx.providers"] + "restrictedConfigurations": [ + "openctx.providers" + ] } }, "dependencies": { @@ -1367,7 +1411,6 @@ "js-levenshtein": "^1.1.6", "lexical": "^0.17.0", "lodash": "^4.17.21", - "lowlight": "^2.9.0", "lru-cache": "^10.0.0", "lucide-react": "^0.378.0", "mac-ca": "^2.0.3", diff --git a/vscode/webviews/utils/highlight.ts b/vscode/webviews/utils/highlight.ts index 03278959b2b0..d48f421ece6a 100644 --- a/vscode/webviews/utils/highlight.ts +++ b/vscode/webviews/utils/highlight.ts @@ -1,37 +1,111 @@ +import arduino from 'highlight.js/lib/languages/arduino' +import bash from 'highlight.js/lib/languages/bash' +import c from 'highlight.js/lib/languages/c' import clojure from 'highlight.js/lib/languages/clojure' +import cpp from 'highlight.js/lib/languages/cpp' +import csharp from 'highlight.js/lib/languages/csharp' +import css from 'highlight.js/lib/languages/css' import dart from 'highlight.js/lib/languages/dart' +import delphi from 'highlight.js/lib/languages/delphi' +import diff from 'highlight.js/lib/languages/diff' import dockerfile from 'highlight.js/lib/languages/dockerfile' import elixir from 'highlight.js/lib/languages/elixir' import fortran from 'highlight.js/lib/languages/fortran' +import go from 'highlight.js/lib/languages/go' +import graphql from 'highlight.js/lib/languages/graphql' import groovy from 'highlight.js/lib/languages/groovy' import haskell from 'highlight.js/lib/languages/haskell' import http from 'highlight.js/lib/languages/http' +import ini from 'highlight.js/lib/languages/ini' +import java from 'highlight.js/lib/languages/java' +import javascript from 'highlight.js/lib/languages/javascript' +import json from 'highlight.js/lib/languages/json' import jsonc from 'highlight.js/lib/languages/json' +import kotlin from 'highlight.js/lib/languages/kotlin' +import less from 'highlight.js/lib/languages/less' +import lua from 'highlight.js/lib/languages/lua' +import makefile from 'highlight.js/lib/languages/makefile' +import markdown from 'highlight.js/lib/languages/markdown' import matlab from 'highlight.js/lib/languages/matlab' import nix from 'highlight.js/lib/languages/nix' +import objectivec from 'highlight.js/lib/languages/objectivec' import ocaml from 'highlight.js/lib/languages/ocaml' +import perl from 'highlight.js/lib/languages/perl' +import php from 'highlight.js/lib/languages/php' +import phpTemplate from 'highlight.js/lib/languages/php-template' +import plaintext from 'highlight.js/lib/languages/plaintext' +import python from 'highlight.js/lib/languages/python' +import pythonRepl from 'highlight.js/lib/languages/python-repl' +import r from 'highlight.js/lib/languages/r' +import ruby from 'highlight.js/lib/languages/ruby' +import rust from 'highlight.js/lib/languages/rust' import scala from 'highlight.js/lib/languages/scala' +import scss from 'highlight.js/lib/languages/scss' +import shell from 'highlight.js/lib/languages/shell' +import sql from 'highlight.js/lib/languages/sql' +import swift from 'highlight.js/lib/languages/swift' +import typescript from 'highlight.js/lib/languages/typescript' +import vbnet from 'highlight.js/lib/languages/vbnet' import verilog from 'highlight.js/lib/languages/verilog' import vhdl from 'highlight.js/lib/languages/vhdl' +import wasm from 'highlight.js/lib/languages/wasm' import html from 'highlight.js/lib/languages/xml' // highlight.js uses 'xml' for HTML/XML -import { common } from 'lowlight' +import xml from 'highlight.js/lib/languages/xml' +import yaml from 'highlight.js/lib/languages/yaml' export const SYNTAX_HIGHLIGHTING_LANGUAGES = { - ...common, + arduino, + bash, + c, clojure, + cpp, + csharp, + css, dart, + delphi, + diff, dockerfile, elixir, fortran, + go, + graphql, groovy, haskell, html, http, + ini, + java, + javascript, + json, jsonc, + kotlin, + less, + lua, + makefile, + markdown, matlab, nix, + objectivec, ocaml, + perl, + php, + phpTemplate, + plaintext, + python, + pythonRepl, + r, + ruby, + rust, scala, + scss, + shell, + sql, + swift, + typescript, + vbnet, verilog, vhdl, + wasm, + xml, + yaml, } From a266686d996909252e3c0fbfc649d82b9ec66b9e Mon Sep 17 00:00:00 2001 From: David Ichim Date: Wed, 16 Oct 2024 09:26:09 +0300 Subject: [PATCH 4/6] pnpm biome fix --- vscode/package.json | 72 +++++++++------------------------------------ 1 file changed, 14 insertions(+), 58 deletions(-) diff --git a/vscode/package.json b/vscode/package.json index d0d68f597769..24754569f9d9 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -56,14 +56,7 @@ "version-bump:patch": "RELEASE_TYPE=patch ts-node-transpile-only ./scripts/version-bump.ts", "version-bump:dry-run": "RELEASE_TYPE=prerelease ts-node-transpile-only ./scripts/version-bump.ts" }, - "categories": [ - "AI", - "Chat", - "Programming Languages", - "Machine Learning", - "Snippets", - "Education" - ], + "categories": ["AI", "Chat", "Programming Languages", "Machine Learning", "Snippets", "Education"], "keywords": [ "cody", "codey", @@ -127,11 +120,7 @@ }, "main": "./dist/extension.node.js", "browser": "./dist/extension.web.js", - "activationEvents": [ - "onLanguage", - "onStartupFinished", - "onWebviewPanel:cody.editorPanel" - ], + "activationEvents": ["onLanguage", "onStartupFinished", "onWebviewPanel:cody.editorPanel"], "contributes": { "walkthroughs": [ { @@ -730,17 +719,13 @@ }, { "command": "cody.supercompletion.jumpTo", - "args": [ - "next" - ], + "args": ["next"], "key": "shift+ctrl+down", "when": "cody.activated && !editorReadonly && cody.hasActionableSupercompletion" }, { "command": "cody.supercompletion.jumpTo", - "args": [ - "previous" - ], + "args": ["previous"], "key": "shift+ctrl+up", "when": "cody.activated && !editorReadonly && cody.hasActionableSupercompletion" } @@ -994,10 +979,7 @@ "order": 2, "type": "string", "markdownDescription": "A Git repository URL to use instead of allowing Cody to infer the Git repository from the workspace.", - "examples": [ - "https://github.com/sourcegraph/cody", - "ssh://git@github.com/sourcegraph/cody" - ] + "examples": ["https://github.com/sourcegraph/cody", "ssh://git@github.com/sourcegraph/cody"] }, "cody.customHeaders": { "order": 4, @@ -1047,18 +1029,12 @@ "order": 6, "type": "string", "markdownDescription": "A custom instruction to be included at the start of all chat messages (e.g. \"Answer all my questions in Spanish.\")", - "examples": [ - "Answer all my questions in Spanish." - ] + "examples": ["Answer all my questions in Spanish."] }, "cody.chat.defaultLocation": { "order": 6, "type": "string", - "enum": [ - "sticky", - "sidebar", - "editor" - ], + "enum": ["sticky", "sidebar", "editor"], "markdownDescription": "Controls where the Cody chat view opens when the user invokes the `Cody: New Chat` command, or the Alt+L and Alt+/ shortcuts.", "enumDescriptions": [ "Opens in the last-activated view location, which is set whenever the user explicitly chooses to open chat in a given location", @@ -1071,9 +1047,7 @@ "order": 7, "type": "string", "markdownDescription": "A custom instruction to be included at the end of all instructions for edit commands (e.g. \"Write all unit tests with Jest instead of detected framework.\")", - "examples": [ - "Write all unit tests with Jest instead of detected framework." - ] + "examples": ["Write all unit tests with Jest instead of detected framework."] }, "cody.codeActions.enabled": { "order": 11, @@ -1119,24 +1093,15 @@ "cody.telemetry.level": { "order": 99, "type": "string", - "enum": [ - "all", - "off" - ], - "enumDescriptions": [ - "Sends usage data and errors.", - "Disables all extension telemetry." - ], + "enum": ["all", "off"], + "enumDescriptions": ["Sends usage data and errors.", "Disables all extension telemetry."], "markdownDescription": "Controls the telemetry about Cody usage and errors. See [Cody usage and privacy notice](https://about.sourcegraph.com/terms/cody-notice).", "default": "all" }, "cody.autocomplete.advanced.provider": { "type": "string", "default": "default", - "enum": [ - "default", - "experimental-ollama" - ], + "enum": ["default", "experimental-ollama"], "enumDescriptions": [ "Our recommended setup with the best balance of quality and latency. We continuously update this for optimal performance.", "Experimental support for Ollama users. Use `cody.autocomplete.experimental.ollamaOptions` to configure requests to Ollama server." @@ -1160,10 +1125,7 @@ }, "cody.experimental.foldingRanges": { "type": "string", - "enum": [ - "lsp", - "indentation-based" - ], + "enum": ["lsp", "indentation-based"], "enumDescriptions": [ "Use folding ranges that are enabled by default in VS Code, and are usually powered by LSP", "Use custom implementation of folding ranges that is indentation based. This is the implementation that is used by other Cody clients like the JetBrains plugin" @@ -1174,11 +1136,7 @@ "cody.autocomplete.experimental.graphContext": { "type": "string", "default": null, - "enum": [ - null, - "tsc", - "tsc-mixed" - ], + "enum": [null, "tsc", "tsc-mixed"], "markdownDescription": "Use the code graph to retrieve context for autocomplete requests." }, "cody.autocomplete.experimental.fireworksOptions": { @@ -1353,9 +1311,7 @@ "untrustedWorkspaces": { "supported": "limited", "description": "Cody only uses providers (configured in `openctx.providers`) from trusted workspaces because providers may execute arbitrary code.", - "restrictedConfigurations": [ - "openctx.providers" - ] + "restrictedConfigurations": ["openctx.providers"] } }, "dependencies": { From 9e854051eb3dbdb6e2f3089d79072d640736749a Mon Sep 17 00:00:00 2001 From: David Ichim Date: Mon, 21 Oct 2024 09:23:56 +0300 Subject: [PATCH 5/6] externalize highlight.js languages in Vite config to avoid build error due to loading of such library --- web/vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/vite.config.ts b/web/vite.config.ts index d43c686d1f39..819c9ff489ff 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -109,7 +109,7 @@ export default defineProjectWithDefaults(__dirname, { entry: [resolve(__dirname, 'lib/index.ts'), resolve(__dirname, 'lib/agent/agent.worker.ts')], }, rollupOptions: { - external: ['react', 'react/jsx-runtime'], + external: ['react', 'react/jsx-runtime', /^highlight\.js\/lib\/languages\/.+$/], watch: { include: ['demo/**', 'lib/**'], exclude: ['node_modules'], From d1c18a7ebd7bd5bef52190c4eb8ed5e8ba5055a5 Mon Sep 17 00:00:00 2001 From: David Ichim Date: Mon, 21 Oct 2024 09:59:07 +0300 Subject: [PATCH 6/6] Revert "externalize highlight.js languages in Vite config to avoid build error due to loading of such library" This reverts commit 9e854051eb3dbdb6e2f3089d79072d640736749a. Upon running pnpm install again in the root pnpm build no longer complained about the loading of the external library. --- web/vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/vite.config.ts b/web/vite.config.ts index 93100efe5633..465a19b896e4 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -109,7 +109,7 @@ export default defineProjectWithDefaults(__dirname, { entry: [resolve(__dirname, 'lib/index.ts'), resolve(__dirname, 'lib/agent/agent.worker.ts')], }, rollupOptions: { - external: ['react', 'react/jsx-runtime', /^highlight\.js\/lib\/languages\/.+$/], + external: ['react', 'react/jsx-runtime'], watch: { include: ['demo/**', 'lib/**'], exclude: ['node_modules'],