diff --git a/.changes/unreleased/Added-20241113-165958.yaml b/.changes/unreleased/Added-20241113-165958.yaml new file mode 100644 index 000000000..95aaa7c70 --- /dev/null +++ b/.changes/unreleased/Added-20241113-165958.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: .continuerules file to set system prompt +time: 2024-11-13T16:59:58.544875-08:00 diff --git a/.changes/unreleased/Added-20241113-170006.yaml b/.changes/unreleased/Added-20241113-170006.yaml new file mode 100644 index 000000000..bc254f8d9 --- /dev/null +++ b/.changes/unreleased/Added-20241113-170006.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: .prompt files v2 +time: 2024-11-13T17:00:06.855468-08:00 diff --git a/.github/workflows/auto-assign.yaml b/.github/workflows/auto-assign.yaml index 3108307e5..dc5388ef3 100644 --- a/.github/workflows/auto-assign.yaml +++ b/.github/workflows/auto-assign.yaml @@ -14,7 +14,7 @@ jobs: uses: pozil/auto-assign-issue@v2 with: repo-token: ${{ secrets.CI_GITHUB_TOKEN }} - assignees: sestinj,Patrick-Erichsen + assignees: sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa numOfAssignee: 1 - name: "Add default labels" uses: actions-ecosystem/action-add-labels@v1 diff --git a/.instructions b/.instructions new file mode 100644 index 000000000..bad5d9689 --- /dev/null +++ b/.instructions @@ -0,0 +1 @@ +Give concise responses. diff --git a/core/autocomplete/README.md b/core/autocomplete/README.md index c02be2b01..9baf9cd4b 100644 --- a/core/autocomplete/README.md +++ b/core/autocomplete/README.md @@ -7,7 +7,7 @@ Continue now provides support for tab autocomplete in [VS Code](https://marketpl We recommend setting up tab-autocomplete with a local Ollama instance. To do this, first download the latest version of Ollama from [here](https://ollama.ai). Then, run the following command to download our recommended model: ```bash -ollama run starcoder:3b +ollama run qwen2.5-coder:1.5b ``` Once it has been downloaded, you should begin to see completions in VS Code. @@ -17,9 +17,9 @@ Once it has been downloaded, you should begin to see completions in VS Code. You can also set up tab-autocomplete with a local LM Studio instance by following these steps: 1. Download the latest version of LM Studio from [here](https://lmstudio.ai/) -2. Download a model (e.g. search for `second-state/StarCoder2-3B-GGUF` and choose one of the options there) +2. Download a model (e.g. search for `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF` and choose one of the options there) 3. Go to the server section (button is on the left), select your model from the dropdown at the top, and click "Start Server" -4. Go to the "My Models" section (button is on the left), find your selected model, and copy the name the path (example: `second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf`); this will be used as the "model" attribute in Continue +4. Go to the "My Models" section (button is on the left), find your selected model, and copy the name the path (example: `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF/qwen2.5-coder-1.5b-instruct-q4_k_m.gguf`); this will be used as the "model" attribute in Continue 5. Go to Continue and modify the configurations for a [custom model](#setting-up-a-custom-model) 6. Set the "provider" to `lmstudio` and the "model" to the path copied earlier @@ -28,8 +28,8 @@ Example: ```json title="config.json" { "tabAutocompleteModel": { - "title": "Starcoder2 3b", - "model": "second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf", + "title": "Qwen2.5-Coder 1.5b", + "model": "Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF", "provider": "lmstudio", }, ... @@ -69,11 +69,9 @@ If you aren't yet familiar with the available options, you can learn more in our ### What model should I use? -If you are running the model locally, we recommend `starcoder:3b`. +If you are running the model locally, we recommend `qwen2.5-coder:1.5b`. -If you find it to be too slow, you should try `deepseek-coder:1.3b-base`. - -If you have a bit more compute, or are running a model in the cloud, you can upgrade to `deepseek-coder:6.7b-base`. +If you have a bit more compute, or are running a model in the cloud, you can upgrade to `qwen2.5-coder:7b`. Regardless of what you are willing to spend, we do not recommend using GPT or Claude for autocomplete. Learn why [below](#i-want-better-completions-should-i-use-gpt-4). @@ -83,7 +81,7 @@ The following can be configured in `config.json`: ### `tabAutocompleteModel` -This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `starcoder-1b`, or `starcoder-3b`. +This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `qwen2.5-coder:1.5b`, or `starcoder-3b`. ### `tabAutocompleteOptions` @@ -105,7 +103,7 @@ This object allows you to customize the behavior of tab-autocomplete. The availa "tabAutocompleteModel": { "title": "Tab Autocomplete Model", "provider": "ollama", - "model": "starcoder:3b", + "model": "qwen2.5-coder:1.5b", "apiBase": "https://" }, "tabAutocompleteOptions": { @@ -128,7 +126,7 @@ Follow these steps to ensure that everything is set up correctly: 1. Make sure you have the "Enable Tab Autocomplete" setting checked (in VS Code, you can toggle by clicking the "Continue" button in the status bar). 2. Make sure you have downloaded Ollama. -3. Run `ollama run starcoder:3b` to verify that the model is downloaded. +3. Run `ollama run qwen2.5-coder:1.5b` to verify that the model is downloaded. 4. Make sure that any other completion providers are disabled (e.g. Copilot), as they may interfere. 5. Make sure that you aren't also using another Ollama model for chat. This will cause Ollama to constantly load and unload the models from memory, resulting in slow responses (or none at all) for both. 6. Check the output of the logs to find any potential errors (cmd/ctrl+shift+p -> "Toggle Developer Tools" -> "Console" tab in VS Code, ~/.continue/logs/core.log in JetBrains). diff --git a/core/autocomplete/context/root-path-context/RootPathContextService.ts b/core/autocomplete/context/root-path-context/RootPathContextService.ts index accd4f6df..9c47138cd 100644 --- a/core/autocomplete/context/root-path-context/RootPathContextService.ts +++ b/core/autocomplete/context/root-path-context/RootPathContextService.ts @@ -9,6 +9,21 @@ import { AstPath } from "../../util/ast"; import { ImportDefinitionsService } from "../ImportDefinitionsService"; import { AutocompleteSnippet } from "../ranking"; +function getSyntaxTreeString( + node: Parser.SyntaxNode, + indent: string = "", +): string { + let result = ""; + const nodeInfo = `${node.type} [${node.startPosition.row}:${node.startPosition.column} - ${node.endPosition.row}:${node.endPosition.column}]`; + result += `${indent}${nodeInfo}\n`; + + for (const child of node.children) { + result += getSyntaxTreeString(child, indent + " "); + } + + return result; +} + export class RootPathContextService { private cache = new LRUCache({ max: 100, @@ -28,6 +43,7 @@ export class RootPathContextService { "function_declaration", "function_definition", "method_definition", + "method_declaration", "class_declaration", "class_definition", ]); @@ -58,12 +74,17 @@ export class RootPathContextService { this.importDefinitionsService.get(filepath); break; default: + // const type = node.type; + // debugger; + // console.log(getSyntaxTreeString(node)); + query = await getQueryForFile( filepath, `root-path-context-queries/${node.type}`, ); break; } + const type = node.type; if (!query) { return snippets; @@ -115,6 +136,8 @@ export class RootPathContextService { RootPathContextService.TYPES_TO_USE.has(node.type), )) { const key = RootPathContextService.keyFromNode(parentKey, astNode); + // const type = astNode.type; + // debugger; const foundInCache = this.cache.get(key); const newSnippets = diff --git a/core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts b/core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts index 196a7b643..fe81a0edd 100644 --- a/core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts +++ b/core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts @@ -1,29 +1,8 @@ +import { TYPESCRIPT_TEST_CASES } from "./testCases/typescript"; import { testRootPathContext } from "./testUtils"; const TEST_CASES = [ - { - nodeType: "function_declaration", - fileName: "file1.ts", - language: "TypeScript", - cursorPosition: { line: 10, character: 24 }, - definitionPositions: [ - { row: 9, column: 34 }, // Person - { row: 9, column: 44 }, // Address - ], - }, - { - nodeType: "method_declaration", - fileName: "file1.ts", - language: "TypeScript", - cursorPosition: { line: 22, character: 30 }, - definitionPositions: [ - { row: 13, column: 29 }, // BaseClass - { row: 13, column: 55 }, // FirstInterface - { row: 13, column: 72 }, // SecondInterface - { row: 21, column: 33 }, // Person - { row: 21, column: 43 }, // Address - ], - }, + ...TYPESCRIPT_TEST_CASES, { nodeType: "function_definition", fileName: "file1.py", @@ -46,6 +25,39 @@ const TEST_CASES = [ { row: 11, column: 59 }, // Address ], }, + { + nodeType: "function_definition", + fileName: "file1.php", + language: "PHP", + cursorPosition: { line: 12, character: 32 }, + definitionPositions: [ + { row: 10, column: 26 }, // Person + { row: 10, column: 44 }, // Address + ], + }, + { + nodeType: "method_declaration", + fileName: "file1.php", + language: "PHP", + cursorPosition: { line: 26, character: 35 }, + definitionPositions: [ + { row: 15, column: 29 }, // BaseClass + { row: 15, column: 55 }, // FirstInterface + { row: 15, column: 72 }, // SecondInterface + { row: 25, column: 43 }, // Person + { row: 25, column: 61 }, // Address + ], + }, + { + nodeType: "function_declaration", + fileName: "file1.go", + language: "Go", + cursorPosition: { line: 7, character: 21 }, + definitionPositions: [ + { row: 6, column: 33 }, // models.User + { row: 6, column: 50 }, // models.Address + ], + }, ]; describe("RootPathContextService", () => { diff --git a/core/autocomplete/context/root-path-context/test/files/file1.ts b/core/autocomplete/context/root-path-context/test/files/class.ts similarity index 54% rename from core/autocomplete/context/root-path-context/test/files/file1.ts rename to core/autocomplete/context/root-path-context/test/files/class.ts index ba09c5709..017b592ae 100644 --- a/core/autocomplete/context/root-path-context/test/files/file1.ts +++ b/core/autocomplete/context/root-path-context/test/files/class.ts @@ -7,10 +7,6 @@ import { // @ts-ignore } from "./types"; -function getAddress(person: Person): Address { - return person.address; -} - class Group extends BaseClass implements FirstInterface, SecondInterface { people: Person[]; @@ -20,6 +16,18 @@ class Group extends BaseClass implements FirstInterface, SecondInterface { } getPersonAddress(person: Person): Address { - return getAddress(person); + return person.address; + } + + getHardcodedAddress(): Address { + return { street: "123 Main St", city: "Anytown" }; + } + + addPerson(person: Person) { + this.people = [...this.people, person]; + } + + addPeople(people: Person[]) { + this.people = [...this.people, ...people]; } } diff --git a/core/autocomplete/context/root-path-context/test/files/file1.go b/core/autocomplete/context/root-path-context/test/files/file1.go new file mode 100644 index 000000000..94eec171c --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/file1.go @@ -0,0 +1,9 @@ +package main + +import ( + "core/autocomplete/context/root-path-context/test/files/models" +) + +func getAddress(user *models.User) *models.Address { + return user.Address +} \ No newline at end of file diff --git a/core/autocomplete/context/root-path-context/test/files/file1.php b/core/autocomplete/context/root-path-context/test/files/file1.php new file mode 100644 index 000000000..a72f805e0 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/file1.php @@ -0,0 +1,32 @@ +getAddress(); +} + +class Group extends BaseClass implements FirstInterface, SecondInterface +{ + private array $people; + + public function __construct(array $people) + { + parent::__construct(); + $this->people = $people; + } + + public function getPersonAddress(Person $person): Address + { + return getAddress($person); + } +} + +?> \ No newline at end of file diff --git a/core/autocomplete/context/root-path-context/test/files/functions.ts b/core/autocomplete/context/root-path-context/test/files/functions.ts new file mode 100644 index 000000000..2b6125a74 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/functions.ts @@ -0,0 +1,25 @@ +import { + Address, + Person, + // @ts-ignore +} from "./types"; + +function getAddress(person: Person): Address { + return person.address; +} + +function getFirstAddress(people: Person[]): Address { + return people[0].address; +} + +function logPerson(person: Person) { + console.log(`Name: ${person.name}, Age: ${person.age}`); +} + +function getHardcodedAddress(): Address { + return { street: "123 Main St", city: "Anytown", zipCode: "12345" }; +} + +function getAddresses(people: Person[]): Address[] { + return people[0].address; +} diff --git a/core/autocomplete/context/root-path-context/test/testCases/typescript.ts b/core/autocomplete/context/root-path-context/test/testCases/typescript.ts new file mode 100644 index 000000000..6913cb8d3 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/testCases/typescript.ts @@ -0,0 +1,89 @@ +export const TYPESCRIPT_TEST_CASES = [ + { + nodeType: "function_declaration with a param and a return type", + fileName: "functions.ts", + language: "TypeScript", + cursorPosition: { line: 7, character: 24 }, + definitionPositions: [ + { row: 6, column: 34 }, // Person + { row: 6, column: 44 }, // Address + ], + }, + { + nodeType: "function_declaration with array param", + fileName: "functions.ts", + language: "TypeScript", + cursorPosition: { line: 11, character: 27 }, + definitionPositions: [ + { row: 10, column: 39 }, // Person + { row: 10, column: 51 }, // Address + ], + }, + { + nodeType: "function_declaration without return type", + fileName: "functions.ts", + language: "TypeScript", + cursorPosition: { line: 15, character: 58 }, + definitionPositions: [ + { row: 14, column: 33 }, // Person + ], + }, + { + nodeType: "function_declaration without params", + fileName: "functions.ts", + language: "TypeScript", + cursorPosition: { line: 19, character: 70 }, + definitionPositions: [ + { row: 18, column: 39 }, // Person + ], + }, + { + nodeType: "method_declaration", + fileName: "class.ts", + language: "TypeScript", + cursorPosition: { line: 18, character: 26 }, + definitionPositions: [ + { row: 9, column: 29 }, // BaseClass + { row: 9, column: 55 }, // FirstInterface + { row: 9, column: 72 }, // SecondInterface + { row: 17, column: 33 }, // Person + { row: 17, column: 43 }, // Address + ], + }, + { + nodeType: "method_declaration without arguments", + fileName: "class.ts", + language: "TypeScript", + cursorPosition: { line: 22, character: 54 }, + definitionPositions: [ + { row: 9, column: 29 }, // BaseClass + { row: 9, column: 55 }, // FirstInterface + { row: 9, column: 72 }, // SecondInterface + { row: 21, column: 32 }, // Address + ], + }, + { + nodeType: "method_declaration without return type", + fileName: "class.ts", + language: "TypeScript", + cursorPosition: { line: 26, character: 43 }, + definitionPositions: [ + { row: 9, column: 29 }, // BaseClass + { row: 9, column: 55 }, // FirstInterface + { row: 9, column: 72 }, // SecondInterface + { row: 25, column: 26 }, // Person + ], + }, + { + nodeType: "method_declaration with array type arguments", + fileName: "class.ts", + language: "TypeScript", + cursorPosition: { line: 30, character: 46 }, + definitionPositions: [ + { row: 9, column: 29 }, // BaseClass + { row: 9, column: 55 }, // FirstInterface + { row: 9, column: 72 }, // SecondInterface + { row: 29, column: 26 }, // Person + ], + }, +]; diff --git a/core/autocomplete/filtering/streamTransforms/charStream.test.ts b/core/autocomplete/filtering/streamTransforms/charStream.test.ts index 7ab8923fc..b466ae3cd 100644 --- a/core/autocomplete/filtering/streamTransforms/charStream.test.ts +++ b/core/autocomplete/filtering/streamTransforms/charStream.test.ts @@ -157,4 +157,20 @@ describe("stopAtStopTokens", () => { expect(output.join("")).toBe("Hello world!"); }); + + it("should handle stop token when remaining buffer is smaller than maximum stop token length", async () => { + const mockStream = createMockStream(["Hello world!STOP"]); + const stopTokens: string[] = [ + "STOP", + "STOP_TOKEN_THAT_IS_LARGER_THAN_BUFFER", + ]; + const result = stopAtStopTokens(mockStream, stopTokens); + + const output = []; + for await (const char of result) { + output.push(char); + } + + expect(output.join("")).toBe("Hello world!"); + }); }); diff --git a/core/autocomplete/filtering/streamTransforms/charStream.ts b/core/autocomplete/filtering/streamTransforms/charStream.ts index 79fc33a0d..9f37e1f58 100644 --- a/core/autocomplete/filtering/streamTransforms/charStream.ts +++ b/core/autocomplete/filtering/streamTransforms/charStream.ts @@ -70,7 +70,8 @@ export async function* noFirstCharNewline(stream: AsyncGenerator) { * 2. Otherwise, buffers incoming chunks and checks for stop tokens. * 3. Yields characters one by one if no stop token is found at the start of the buffer. * 4. Stops yielding and returns if a stop token is encountered. - * 5. After the stream ends, yields any remaining buffered characters. + * 5. After the stream ends, filters encountered stop tokens in remaining buffer. + * 6. Yields any remaining buffered characters. */ export async function* stopAtStopTokens( stream: AsyncGenerator, @@ -106,6 +107,10 @@ export async function* stopAtStopTokens( } } } + // Filter out the possible stop tokens from remaining buffer + stopTokens.forEach((token) => { + buffer = buffer.replace(token, ""); + }); // Yield any remaining characters in the buffer for (const char of buffer) { diff --git a/core/config/getSystemPromptDotFile.ts b/core/config/getSystemPromptDotFile.ts new file mode 100644 index 000000000..03690dd47 --- /dev/null +++ b/core/config/getSystemPromptDotFile.ts @@ -0,0 +1,27 @@ +import { IDE } from ".."; + +export const SYSTEM_PROMPT_DOT_FILE = ".continuerules"; + +export async function getSystemPromptDotFile(ide: IDE): Promise { + const dirs = await ide.getWorkspaceDirs(); + + let prompts: string[] = []; + const pathSep = await ide.pathSep(); + for (const dir of dirs) { + const dotFile = `${dir}${pathSep}${SYSTEM_PROMPT_DOT_FILE}`; + if (await ide.fileExists(dotFile)) { + try { + const content = await ide.readFile(dotFile); + prompts.push(content); + } catch (e) { + // ignore if file doesn't exist + } + } + } + + if (!prompts.length) { + return null; + } + + return prompts.join("\n\n"); +} diff --git a/core/config/load.ts b/core/config/load.ts index 0e405301e..b692b36bf 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -64,6 +64,7 @@ import { defaultSlashCommandsJetBrains, defaultSlashCommandsVscode, } from "./default"; +import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; import { DEFAULT_PROMPTS_FOLDER, getPromptFiles, @@ -735,6 +736,11 @@ async function loadFullConfigNode( return { errors, config: undefined, configLoadInterrupted: true }; } + const systemPromptDotFile = await getSystemPromptDotFile(ide); + if (systemPromptDotFile) { + serialized.systemMessage = systemPromptDotFile; + } + // Convert serialized to intermediate config let intermediate = await serializedToIntermediateConfig(serialized, ide); diff --git a/core/config/onboarding.ts b/core/config/onboarding.ts index fa6d54945..6b05ca59f 100644 --- a/core/config/onboarding.ts +++ b/core/config/onboarding.ts @@ -4,7 +4,7 @@ import { FREE_TRIAL_MODELS } from "./default"; export const TRIAL_FIM_MODEL = "codestral-latest"; export const ONBOARDING_LOCAL_MODEL_TITLE = "Ollama"; -export const LOCAL_ONBOARDING_FIM_MODEL = "starcoder2:3b"; +export const LOCAL_ONBOARDING_FIM_MODEL = "qwen2.5-coder:1.5b"; export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b"; export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B"; @@ -35,7 +35,7 @@ export function setupLocalConfig( ...config.models.filter((model) => model.provider !== "free-trial"), ], tabAutocompleteModel: { - title: "Starcoder 3b", + title: "Qwen2.5-Coder 1.5B", provider: "ollama", model: LOCAL_ONBOARDING_FIM_MODEL, }, diff --git a/core/llm/llms/stubs/ContinueProxy.ts b/core/llm/llms/stubs/ContinueProxy.ts index 0d04f77f5..97dec3a35 100644 --- a/core/llm/llms/stubs/ContinueProxy.ts +++ b/core/llm/llms/stubs/ContinueProxy.ts @@ -13,13 +13,14 @@ class ContinueProxy extends OpenAI { static providerName: ModelProvider = "continue-proxy"; static defaultOptions: Partial = { useLegacyCompletionsEndpoint: false, - requestOptions: { - headers: { - "x-continue-unique-id": Telemetry.uniqueId, - }, - }, }; + protected _getHeaders() { + const headers: any = super._getHeaders(); + headers["x-continue-unique-id"] = Telemetry.uniqueId; + return headers; + } + supportsCompletions(): boolean { return false; } diff --git a/core/promptFiles/v2/createNewPromptFile.ts b/core/promptFiles/v2/createNewPromptFile.ts index a8ea87109..21ff3c7c1 100644 --- a/core/promptFiles/v2/createNewPromptFile.ts +++ b/core/promptFiles/v2/createNewPromptFile.ts @@ -1,46 +1,42 @@ -import path from "path"; - import { IDE } from "../.."; import { GlobalContext } from "../../util/GlobalContext"; - -import { DEFAULT_PROMPTS_FOLDER_V2 } from "./getPromptFiles"; +import { getPathModuleForIde } from "../../util/pathModule"; const FIRST_TIME_DEFAULT_PROMPT_FILE = `# This is an example ".prompt" file # It is used to define and reuse prompts within Continue -# Continue will automatically create a context provider for each prompt in the .prompts folder +# Each .prompt file can be accessed by typing "@prompts" in the Chat input # A prompt file consists of two parts: # 1. Everything above the "---" is YAML. Here you can set "temperature", "description", and other options # 2. Everything below the "---" is the prompt body -# If you don't want to set any options, you don't need to include the "---" +# If you do not want to set any options, you do not need to include the "---" # In the body, you can reference: -# 1. Files, using either absolute or relative (based on the workspace root) paths - # e.g. @README.md - # e.g. @src/test/test.py - # e.g. @/Users/me/Desktop/my-project/src/test/test.py -# 2. URLs - # e.g. https://example.com -# 3. Some context providers, like - # e.g. @currentFile - # e.g. @os - # e.g. @repo-map +# 1. Files, using either absolute or relative paths (based on the workspace root) + # @README.md + # @src/test/test.py + # @/Users/me/Desktop/my-project/src/test/test.py +# 2. URLs, for example + # @https://example.com +# 3. Context providers, for example + # @currentFile + # @os + # @repo-map # To learn more, see the full .prompt file reference: https://docs.continue.dev/features/prompt-files name: Example + +# For example, here is how you would write a .prompt +name: Example description: Example prompt file -version: 2 ---- -@README.md - -Please reference the above README.md file to understand the current project. -`; - -const DEFAULT_PROMPT_FILE = `version: 2 --- -`; +Here is information about the current repo: + +@README.md`; + +const DEFAULT_PROMPT_FILE = ""; export async function createNewPromptFileV2( ide: IDE, @@ -52,9 +48,11 @@ export async function createNewPromptFileV2( "No workspace directories found. Make sure you've opened a folder in your IDE.", ); } - const baseDir = path.join( + const pathModule = await getPathModuleForIde(ide); + + const baseDir = pathModule.join( workspaceDirs[0], - promptPath ?? DEFAULT_PROMPTS_FOLDER_V2, + promptPath ?? pathModule.join(".continue", "prompts"), ); // Find the first available filename @@ -62,7 +60,10 @@ export async function createNewPromptFileV2( let promptFilePath: string; do { const suffix = counter === 0 ? "" : `-${counter}`; - promptFilePath = path.join(baseDir, `new-prompt-file${suffix}.prompt`); + promptFilePath = pathModule.join( + baseDir, + `new-prompt-file${suffix}.prompt`, + ); counter++; } while (await ide.fileExists(promptFilePath)); diff --git a/core/promptFiles/v2/getPromptFiles.ts b/core/promptFiles/v2/getPromptFiles.ts index c78068899..0353746be 100644 --- a/core/promptFiles/v2/getPromptFiles.ts +++ b/core/promptFiles/v2/getPromptFiles.ts @@ -1,7 +1,6 @@ -import path from "path"; - import { IDE } from "../.."; import { walkDir } from "../../indexing/walkDir"; +import { getPathModuleForIde } from "../../util/pathModule"; import { readAllGlobalPromptFiles } from "../../util/paths"; async function getPromptFilesFromDir( @@ -27,20 +26,23 @@ async function getPromptFilesFromDir( } } -export const DEFAULT_PROMPTS_FOLDER_V2 = ".prompts"; - export async function getAllPromptFilesV2( ide: IDE, overridePromptFolder?: string, ): Promise<{ path: string; content: string }[]> { const workspaceDirs = await ide.getWorkspaceDirs(); let promptFiles: { path: string; content: string }[] = []; + const pathModule = await getPathModuleForIde(ide); + promptFiles = ( await Promise.all( workspaceDirs.map((dir) => getPromptFilesFromDir( ide, - path.join(dir, overridePromptFolder ?? DEFAULT_PROMPTS_FOLDER_V2), + pathModule.join( + dir, + overridePromptFolder ?? pathModule.join(".continue", "prompts"), + ), ), ), ) diff --git a/core/promptFiles/v2/renderPromptFile.ts b/core/promptFiles/v2/renderPromptFile.ts index bb70b19a2..89b36b0a8 100644 --- a/core/promptFiles/v2/renderPromptFile.ts +++ b/core/promptFiles/v2/renderPromptFile.ts @@ -1,7 +1,7 @@ import { ContextItem, ContextProviderExtras } from "../.."; +import { contextProviderClassFromName } from "../../context/providers"; import URLContextProvider from "../../context/providers/URLContextProvider"; import { getBasename } from "../../util"; - import { getPreambleAndBody } from "./parse"; async function resolveAttachment( @@ -15,6 +15,13 @@ async function resolveAttachment( if (contextProvider) { const items = await contextProvider.getContextItems("", extras); return items; + } else { + // Just instantiate it here + const providerClass = contextProviderClassFromName(name) as any; + if (providerClass) { + const providerInstance = new providerClass({}); + return providerInstance.getContextItems("", extras); + } } // Files diff --git a/core/util/pathModule.ts b/core/util/pathModule.ts new file mode 100644 index 000000000..8b06ab56c --- /dev/null +++ b/core/util/pathModule.ts @@ -0,0 +1,13 @@ +import { PlatformPath, posix, win32 } from "node:path"; +import { IDE } from ".."; + +export type PathSep = "/" | "\\"; + +function getPathModuleFromPathSep(pathSep: PathSep): PlatformPath { + return pathSep === "/" ? posix : win32; +} + +export async function getPathModuleForIde(ide: IDE): Promise { + const pathSep = await ide.pathSep(); + return getPathModuleFromPathSep(pathSep as PathSep); +} diff --git a/core/util/paths.ts b/core/util/paths.ts index f8b70159f..d606f095d 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -327,7 +327,7 @@ export function getPromptLogsPath(): string { } export function getGlobalPromptsPath(): string { - return path.join(getContinueGlobalPath(), ".prompts"); + return path.join(getContinueGlobalPath(), "prompts"); } export function readAllGlobalPromptFiles( diff --git a/docs/docs/autocomplete/model-setup.md b/docs/docs/autocomplete/model-setup.md index 05136e546..8aae88c75 100644 --- a/docs/docs/autocomplete/model-setup.md +++ b/docs/docs/autocomplete/model-setup.md @@ -26,26 +26,23 @@ The API keys for Codestral and the general Mistral APIs are different. If you ar ## Local, offline / self-hosted experience -For those preferring local execution or self-hosting,`StarCoder2-3b` offers a good balance of performance and quality for most users: +For those preferring local execution or self-hosting,`Qwen2.5-Coder 1.5B` offers a good balance of performance and quality for most users: ```json title="config.json"" { "tabAutocompleteModel": { - "title": "StarCoder2-3b", - "model": "starcoder2:3b", + "title": "Qwen2.5-Coder 1.5B", + "model": "qwen2.5-coder:1.5b", "provider": "ollama" } } ``` -## Alternative experiences - -- Completions too slow? Try `deepseek-coder:1.3b-base` for quicker completions on less powerful hardware -- Have more compute? Use `deepseek-coder:6.7b-base` for potentially higher-quality suggestions +Have more compute? Use `qwen2.5-coder:7b` for potentially higher-quality suggestions. :::note -For LM Studio users, navigate to the "My Models" section, find your desired model, and copy the path (e.g., second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf). Use this path as the `model` value in your configuration. +For LM Studio users, navigate to the "My Models" section, find your desired model, and copy the path (e.g., `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF/wen2.5-coder-1.5b-instruct-q4_k_m.gguf`). Use this path as the `model` value in your configuration. ::: diff --git a/docs/docs/customize/deep-dives/autocomplete.md b/docs/docs/customize/deep-dives/autocomplete.md index 2ae2435d5..9e03aa756 100644 --- a/docs/docs/customize/deep-dives/autocomplete.md +++ b/docs/docs/customize/deep-dives/autocomplete.md @@ -23,7 +23,7 @@ If you want to have the best autocomplete experience, we recommend using Codestr If you'd like to run your autocomplete model locally, we recommend using Ollama. To do this, first download the latest version of Ollama from [here](https://ollama.ai). Then, run the following command to download our recommended model: ```bash -ollama run starcoder2:3b +ollama run qwen2.5-coder:1.5b ``` Once it has been downloaded, you should begin to see completions in VS Code. @@ -37,7 +37,7 @@ All of the configuration options available for chat models are available to use "tabAutocompleteModel": { "title": "Tab Autocomplete Model", "provider": "ollama", - "model": "starcoder2:3b", + "model": "qwen2.5-coder:1.5b", "apiBase": "https://" }, ... @@ -52,7 +52,7 @@ The following can be configured in `config.json`: ### `tabAutocompleteModel` -This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `starcoder-1b`, or `starcoder2-3b`. +This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `qwen2.5-coder:1.5b`, or `starcoder2-3b`. ### `tabAutocompleteOptions` @@ -78,7 +78,7 @@ This object allows you to customize the behavior of tab-autocomplete. The availa "tabAutocompleteModel": { "title": "Tab Autocomplete Model", "provider": "ollama", - "model": "starcoder2:3b", + "model": "qwen2.5-coder:1.5b", "apiBase": "https://" }, "tabAutocompleteOptions": { @@ -101,16 +101,12 @@ Follow these steps to ensure that everything is set up correctly: 1. Make sure you have the "Enable Tab Autocomplete" setting checked (in VS Code, you can toggle by clicking the "Continue" button in the status bar, and in JetBrains by going to Settings -> Tools -> Continue). 2. Make sure you have downloaded Ollama. -3. Run `ollama run starcoder2:3b` to verify that the model is downloaded. +3. Run `ollama run qwen2.5-coder:1.5b` to verify that the model is downloaded. 4. Make sure that any other completion providers are disabled (e.g. Copilot), as they may interfere. 5. Check the output of the logs to find any potential errors: cmd/ctrl + shift + P -> "Toggle Developer Tools" -> "Console" tab in VS Code, ~/.continue/logs/core.log in JetBrains. 6. Check VS Code settings to make sure that `"editor.inlineSuggest.enabled"` is set to `true` (use cmd/ctrl + , then search for this and check the box) 7. If you are still having issues, please let us know in our [Discord](https://discord.gg/vapESyrFmJ) and we'll help as soon as possible. -### Completions are slow - -Depending on your hardware, you may want to try a smaller, faster model. If 3b isn't working for you we recommend trying `deepseek-coder:1.3b-base`. - ### Completions are only ever single-line To ensure that you receive multi-line completions, you can set `"multilineCompletions": "always"` in `tabAutocompleteOptions`. By default, it is `"auto"`. If you still find that you are only seeing single-line completions, this may be because some models tend to produce shorter completions when starting in the middle of a file. You can try temporarily moving text below your cursor out of your active file, or switching to a larger model. diff --git a/docs/docs/customize/model-providers/top-level/ollama.md b/docs/docs/customize/model-providers/top-level/ollama.md index ae97d30c3..ed96ac385 100644 --- a/docs/docs/customize/model-providers/top-level/ollama.md +++ b/docs/docs/customize/model-providers/top-level/ollama.md @@ -23,14 +23,14 @@ We recommend configuring **Llama3.1 8B** as your chat model. ## Autocomplete model -We recommend configuring **StarCoder2 3B** as your autocomplete model. +We recommend configuring **Qwen2.5-Coder 1.5B** as your autocomplete model. ```json title="config.json" { "tabAutocompleteModel": { - "title": "StarCoder2 3B", + "title": "Qwen2.5-Coder 1.5B", "provider": "ollama", - "model": "starcoder2:3b" + "model": "qwen2.5-coder:1.5b" } } ``` diff --git a/docs/docs/customize/model-types/autocomplete.md b/docs/docs/customize/model-types/autocomplete.md index 64d39c893..d85920605 100644 --- a/docs/docs/customize/model-types/autocomplete.md +++ b/docs/docs/customize/model-types/autocomplete.md @@ -13,4 +13,4 @@ In Continue, these models are used to display inline [Autocomplete](../../autoco If you have the ability to use any model, we recommend `Codestral` with [Mistral](../model-providers/top-level/mistral.md#autocomplete-model) or [Vertex AI](../model-providers/top-level/vertexai.md#autocomplete-model). -If you want to run a model locally, we recommend `Starcoder2-3B` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model). +If you want to run a model locally, we recommend `Qwen2.5-Coder 1.5B` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model). diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt index 509bc44ce..fa39729fa 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt @@ -71,7 +71,6 @@ private fun getTutorialFileName(): String { } class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { - private val coroutineScope = CoroutineScope(Dispatchers.IO) override fun runActivity(project: Project) { removeShortcutFromAction(getPlatformSpecificKeyStroke("J")) @@ -110,6 +109,7 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { } private fun initializePlugin(project: Project) { + val coroutineScope = CoroutineScope(Dispatchers.IO) val continuePluginService = ServiceManager.getService( project, ContinuePluginService::class.java @@ -234,7 +234,5 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { } override fun dispose() { - // Cleanup resources here - coroutineScope.cancel() } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt index aaa6ce28d..178ae4059 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt @@ -19,7 +19,7 @@ class CoreMessenger( private val project: Project, continueCorePath: String, private val ideProtocolClient: IdeProtocolClient, - coroutineScope: CoroutineScope + val coroutineScope: CoroutineScope ) { private var writer: Writer? = null private var reader: BufferedReader? = null @@ -232,4 +232,11 @@ class CoreMessenger( } } } + + fun killSubProcess() { + process?.isAlive?.let { + exitCallbacks.clear() + process?.destroy() + } + } } 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 b773026bd..c2a35a918 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 @@ -105,7 +105,7 @@ class AsyncFileSaveListener(private val ideProtocolClient: IdeProtocolClient) : for (event in events) { if (event.path.endsWith(".continue/config.json") || event.path.endsWith(".continue/config.ts") || event.path.endsWith( ".continue\\config.json" - ) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") + ) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(".continuerc.json") ) { return object : AsyncFileListener.ChangeApplier { override fun afterVfsChange() { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt index 7318d2731..87b08f829 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt @@ -34,6 +34,10 @@ class ContinuePluginService(project: Project) : Disposable, DumbAware { override fun dispose() { coroutineScope.cancel() + coreMessenger?.coroutineScope?.let { + it.cancel() + coreMessenger?.killSubProcess() + } } fun sendToWebview( diff --git a/extensions/vscode/CHANGELOG.md b/extensions/vscode/CHANGELOG.md index 88925e7f4..8dac5cd8c 100644 --- a/extensions/vscode/CHANGELOG.md +++ b/extensions/vscode/CHANGELOG.md @@ -7,8 +7,6 @@ and is generated by [Changie](https://github.com/miniscruff/changie). Pre-release Changes ### Added -* New Edit mode in sidebar (cmd/ctrl+I) -* Significantly faster and more accurate docs crawler by default * OpenAI predicted outputs support * Improve codebase retrieval with BM25 * Support for Grok from xAI @@ -19,12 +17,19 @@ Pre-release Changes * Improved reference for config.json * New @web context provider * Updates for llama3.2 +* .continuerules file to set system prompt +* .prompt files v2 ### Changed * Improved @docs crawler * Many improvements to make autocomplete more eager ### Fixed * Brought back the Apply button for all code blocks +## 0.8.56 - 2024-11-08 +### Added +* New Edit mode in sidebar (cmd/ctrl+I) +* Significantly faster and more accurate docs crawler by default + ## 0.8.55 - 2024-10-25 ### Added * Web context provider diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index a0535391f..eb75d1f90 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -772,6 +772,11 @@ "mistral-tiny", "mistral-small", "mistral-medium", + "qwen2.5-coder:1.5b", + "qwen2.5-coder:3b", + "qwen2.5-coder:7b", + "qwen2.5-coder:14b", + "qwen2.5-coder:32b", "AUTODETECT" ] }, @@ -1028,7 +1033,12 @@ "stable-code-3b", "starcoder-1b", "starcoder-3b", - "starcoder2-3b" + "starcoder2-3b", + "qwen2.5-coder:1.5b", + "qwen2.5-coder:3b", + "qwen2.5-coder:7b", + "qwen2.5-coder:14b", + "qwen2.5-coder:32b" ] }, { @@ -1081,6 +1091,11 @@ "starcoder-1b", "starcoder-3b", "starcoder2-3b", + "qwen2.5-coder:1.5b", + "qwen2.5-coder:3b", + "qwen2.5-coder:7b", + "qwen2.5-coder:14b", + "qwen2.5-coder:32b", "AUTODETECT" ] }, @@ -1400,7 +1415,12 @@ "stable-code-3b", "starcoder-1b", "starcoder-3b", - "starcoder2-3b" + "starcoder2-3b", + "qwen2.5-coder:1.5b", + "qwen2.5-coder:3b", + "qwen2.5-coder:7b", + "qwen2.5-coder:14b", + "qwen2.5-coder:32b" ] }, { @@ -2710,8 +2730,8 @@ }, "tabAutocompleteModel": { "title": "Tab Autocomplete Model", - "markdownDescription": "The model used for tab autocompletion. If undefined, Continue will default to using starcoder2:3b on a local Ollama instance.\n\n*IMPORTANT*:\n\nIf you use a custom model, ensure that it is one trained for fill-in-the-middle completions. An instruct model is typically not well-suited to autocomplete and you may receive unsatisfactory completions.", - "x-intellij-html-description": "The model used for tab autocompletion. If undefined, Continue will default to using starcoder2:3b on a local Ollama instance.

IMPORTANT:

If you use a custom model, ensure that it is one trained for fill-in-the-middle completions. An instruct model is typically not well-suited to autocomplete and you may receive unsatisfactory completions.", + "markdownDescription": "The model used for tab autocompletion. If undefined, Continue will default to using qwen2.5-coder:1.5b on a local Ollama instance.\n\n*IMPORTANT*:\n\nIf you use a custom model, ensure that it is one trained for fill-in-the-middle completions. An instruct model is typically not well-suited to autocomplete and you may receive unsatisfactory completions.", + "x-intellij-html-description": "The model used for tab autocompletion. If undefined, Continue will default to using qwen2.5-coder:1.5b on a local Ollama instance.

IMPORTANT:

If you use a custom model, ensure that it is one trained for fill-in-the-middle completions. An instruct model is typically not well-suited to autocomplete and you may receive unsatisfactory completions.", "default": { "title": "Tab Autocomplete Model", "provider": "ollama", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 30828f300..2ecfb4768 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": "0.9.228", + "version": "0.9.229", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index f8bc7c556..06263e356 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -37,6 +37,7 @@ import { VsCodeIde } from "../VsCodeIde"; import { VsCodeMessenger } from "./VsCodeMessenger"; +import { SYSTEM_PROMPT_DOT_FILE } from "core/config/getSystemPromptDotFile"; import type { VsCodeWebviewProtocol } from "../webviewProtocol"; export class VsCodeExtension { @@ -284,7 +285,8 @@ export class VsCodeExtension { if ( filepath.endsWith(".continuerc.json") || - filepath.endsWith(".prompt") + filepath.endsWith(".prompt") || + filepath.endsWith(SYSTEM_PROMPT_DOT_FILE) ) { this.configHandler.reloadConfig(); } else if ( @@ -296,14 +298,16 @@ export class VsCodeExtension { } else { // Reindex the file this.core.invoke("index/forceReIndex", { - dirs: [filepath] + dirs: [filepath], }); } }); vscode.workspace.onDidDeleteFiles(async (event) => { this.core.invoke("index/forceReIndex", { - dirs: event.files.map((file) => file.fsPath.split("/").slice(0, -1).join("/")) + dirs: event.files.map((file) => + file.fsPath.split("/").slice(0, -1).join("/"), + ), }); }); @@ -352,7 +356,8 @@ export class VsCodeExtension { // Register a content provider for the readonly virtual documents const documentContentProvider = new (class - implements vscode.TextDocumentContentProvider { + implements vscode.TextDocumentContentProvider + { // emitter and its event onDidChangeEmitter = new vscode.EventEmitter(); onDidChange = this.onDidChangeEmitter.event; diff --git a/extensions/vscode/src/util/loadAutocompleteModel.ts b/extensions/vscode/src/util/loadAutocompleteModel.ts index f4f4c87b3..b4aa9289b 100644 --- a/extensions/vscode/src/util/loadAutocompleteModel.ts +++ b/extensions/vscode/src/util/loadAutocompleteModel.ts @@ -6,7 +6,7 @@ import type { ILLM } from "core"; export class TabAutocompleteModel { private _llm: ILLM | undefined; - private defaultTag = "starcoder2:3b"; + private defaultTag = "qwen2.5-coder:1.5b"; private globalContext: GlobalContext = new GlobalContext(); constructor(private configHandler: ConfigHandler) {} diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/class_declaration/php.scm b/extensions/vscode/tree-sitter/root-path-context-queries/class_declaration/php.scm new file mode 100644 index 000000000..5e9a9c13e --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/class_declaration/php.scm @@ -0,0 +1,13 @@ +( + (class_declaration + (base_clause + (name) @superclass) + ) +) + +( + (class_declaration + (class_interface_clause + (name) @interface) + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/go.scm b/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/go.scm new file mode 100644 index 000000000..482f50841 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/go.scm @@ -0,0 +1,12 @@ +( + (function_declaration + (parameter_list + (parameter_declaration + type: (_) @param_type + )* + ) + ; Optional return type node before the block + ([_] @return_type)? + (block) + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/typescript.scm b/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/typescript.scm index ab10968a3..24dc04e22 100644 --- a/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/typescript.scm +++ b/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/typescript.scm @@ -1,10 +1,34 @@ +; Pattern for capturing the return type ( - (function_declaration - (formal_parameters - (_ - (type_annotation) @param_type - ) + (function_declaration + (type_annotation) @return_type + ) +) + +; Pattern for parameters with direct type_identifier +( + (function_declaration + (formal_parameters + (_ + (type_annotation + (type_identifier) @param_type ) - (type_annotation) @return_type + ) ) + ) +) + +; Pattern for parameters with one level of nesting +( + (function_declaration + (formal_parameters + (_ + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) ) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/function_definition/php.scm b/extensions/vscode/tree-sitter/root-path-context-queries/function_definition/php.scm new file mode 100644 index 000000000..3f9303ae1 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/function_definition/php.scm @@ -0,0 +1,10 @@ +( + (function_definition + parameters: (formal_parameters + (simple_parameter + type: (named_type) @param_type + )* + ) + return_type: (named_type) @return_type + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/method_declaration/php.scm b/extensions/vscode/tree-sitter/root-path-context-queries/method_declaration/php.scm new file mode 100644 index 000000000..825324e01 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/method_declaration/php.scm @@ -0,0 +1,10 @@ +( + (method_declaration + (formal_parameters + (simple_parameter + type: (named_type) @param_type + )* + ) + return_type: (named_type) @return_type + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/method_definition/typescript.scm b/extensions/vscode/tree-sitter/root-path-context-queries/method_definition/typescript.scm index 727db5090..9f8685385 100644 --- a/extensions/vscode/tree-sitter/root-path-context-queries/method_definition/typescript.scm +++ b/extensions/vscode/tree-sitter/root-path-context-queries/method_definition/typescript.scm @@ -1,10 +1,34 @@ +; Pattern for capturing the return type ( - (method_definition - (formal_parameters - (_ - (type_annotation) @param_type - ) - ) - (type_annotation) @return_type - ) + (method_definition + (type_annotation) @return_type + ) +) + +; Pattern for parameters with direct type_identifier +( + (method_definition + (formal_parameters + (_ + (type_annotation + (type_identifier) @param_type + ) + ) + ) + ) +) + +; Pattern for parameters with one level of nesting +( + (method_definition + (formal_parameters + (_ + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) ) diff --git a/gui/src/components/find/FindWidget.tsx b/gui/src/components/find/FindWidget.tsx index 266a09cd8..60a9bf2a9 100644 --- a/gui/src/components/find/FindWidget.tsx +++ b/gui/src/components/find/FindWidget.tsx @@ -389,7 +389,7 @@ export const useFindWidget = (searchRef: RefObject) => { e.stopPropagation(); previousMatch(); }} - className="h-4 w-4 focus:ring focus:ring-1" + className="h-4 w-4 focus:ring" disabled={matches.length < 2 || active} > @@ -401,7 +401,7 @@ export const useFindWidget = (searchRef: RefObject) => { e.stopPropagation(); nextMatch(); }} - className="h-4 w-4 focus:ring focus:ring-1" + className="h-4 w-4 focus:ring" disabled={matches.length < 2 || active} > @@ -420,7 +420,7 @@ export const useFindWidget = (searchRef: RefObject) => { e.stopPropagation(); setCaseSensitive((curr) => !curr); }} - className="h-5 w-6 rounded-full border text-xs focus:outline-none focus:ring focus:ring-1" + className="h-5 w-6 rounded-full border text-xs focus:outline-none focus:ring" > Aa @@ -428,7 +428,7 @@ export const useFindWidget = (searchRef: RefObject) => { setOpen(false)} - className="focus:ring focus:ring-1" + className="focus:ring" >