From 6e8f4d86cd3ae1a84bada2a72be2f6e6688dfa00 Mon Sep 17 00:00:00 2001 From: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Date: Sat, 8 Feb 2025 16:28:52 -0500 Subject: [PATCH 001/171] added new gemini models to config_schema.json --- extensions/vscode/config_schema.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index d9dab076b..642335557 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -937,7 +937,10 @@ "gemini-1.5-flash", "gemini-1.5-flash-8b", "gemini-2.0-flash-exp", - "gemini-2.0-flash" + "gemini-2.0-flash", + "gemini-2.0-flash-thinking-exp-01-21", + "gemini-2.0-pro-exp-02-05", + "gemini-2.0-flash-lite-preview-02-05" ] } } From 3c36b4dc378ddd8c5c5c2cc234e9a605d776d928 Mon Sep 17 00:00:00 2001 From: Ingo Eichhorst Date: Sun, 16 Feb 2025 22:31:10 +0100 Subject: [PATCH 002/171] feat: add unified diff instant apply --- core/edit/lazy/applyCodeBlock.ts | 12 + core/edit/lazy/unifiedDiffApply.test.ts | 412 ++++++++++++++++++++++++ core/edit/lazy/unifiedDiffApply.ts | 152 +++++++++ docs/docs/edit/how-to-use-it.md | 7 + 4 files changed, 583 insertions(+) create mode 100644 core/edit/lazy/unifiedDiffApply.test.ts create mode 100644 core/edit/lazy/unifiedDiffApply.ts diff --git a/core/edit/lazy/applyCodeBlock.ts b/core/edit/lazy/applyCodeBlock.ts index 924d1c282..8a311a4fe 100644 --- a/core/edit/lazy/applyCodeBlock.ts +++ b/core/edit/lazy/applyCodeBlock.ts @@ -5,6 +5,7 @@ import { getUriFileExtension } from "../../util/uri"; import { deterministicApplyLazyEdit } from "./deterministic"; import { streamLazyApply } from "./streamLazyApply"; +import { isUnifiedDiffFormat, applyUnifiedDiff } from "./unifiedDiffApply"; function canUseInstantApply(filename: string) { const fileExtension = getUriFileExtension(filename); @@ -32,5 +33,16 @@ export async function applyCodeBlock( } } + // If the code block is a diff + if (isUnifiedDiffFormat(newFile)) { + try { + const diffLines = applyUnifiedDiff(oldFile, newFile); + const diffGenerator = generateLines(diffLines!); + return [true, diffGenerator]; + } catch (e) { + console.error("Failed to apply unified diff", e); + } + } + return [false, streamLazyApply(oldFile, filename, newFile, llm, fastLlm)]; } diff --git a/core/edit/lazy/unifiedDiffApply.test.ts b/core/edit/lazy/unifiedDiffApply.test.ts new file mode 100644 index 000000000..c7a5a8370 --- /dev/null +++ b/core/edit/lazy/unifiedDiffApply.test.ts @@ -0,0 +1,412 @@ +import { applyUnifiedDiff, isUnifiedDiffFormat } from "./unifiedDiffApply"; + +describe("isUnifiedDiffFormat", () => { + it("should return true for valid unified diff format", () => { + const validDiff = `--- original.txt ++++ modified.txt +@@ -1,3 +1,4 @@ + line1 +-line2 ++newline2 ++newline3 + line3`; + expect(isUnifiedDiffFormat(validDiff)).toBe(true); + }); + + it("should return false for empty diff", () => { + expect(isUnifiedDiffFormat("")).toBe(false); + }); + + it("should return false for diff without hunk header", () => { + const invalidDiff = `--- original.txt ++++ modified.txt ++line1 +-line2 ++line3`; + expect(isUnifiedDiffFormat(invalidDiff)).toBe(false); + }); + + it("should return false for diff without valid content", () => { + const invalidDiff = `--- original.txt ++++ modified.txt +@@ -1,3 +1,4 @@`; + expect(isUnifiedDiffFormat(invalidDiff)).toBe(false); + }); + + it("should return true even without file headers if hunk headers exist", () => { + const diffWithoutFileHeaders = `@@ -1,3 +1,4 @@ + line1 +-line2 ++newline2 ++newline3 + line3`; + expect(isUnifiedDiffFormat(diffWithoutFileHeaders)).toBe(true); + }); + + it("should return true in case of empty lines", () => { + const diffWithoutFileHeaders = `@@ -1,3 +1,4 @@ + line1 +-line2 ++newline2 + line3`; + expect(isUnifiedDiffFormat(diffWithoutFileHeaders)).toBe(true); + }); +}); + +describe("applyUnifiedDiff", () => { + it("should correctly apply a add line of unified diff", () => { + const sourceCode = `func main() { + scanner := bufio.NewScanner(os.Stdin) + fmt.Println("Calculator started! Available operations:") + fmt.Println(" + : Addition") + fmt.Println(" - : Subtraction") + fmt.Println(" * : Multiplication") + fmt.Println(" / : Division") + fmt.Println(" ^ : Power") + fmt.Println(" √ : Square root (use only one number)") +} +// End of file`; + + const diffText = `--- original.go ++++ updated.go +@@ -30,6 +30,7 @@ + fmt.Println(" / : Division") + fmt.Println(" ^ : Power") + fmt.Println(" √ : Square root (use only one number)") ++ fmt.Println(" log: Logarithm (use 'log base number')") + }`; + + const result = applyUnifiedDiff(sourceCode, diffText); + + const expected = [ + { type: "same", line: "func main() {" }, + { type: "same", line: " scanner := bufio.NewScanner(os.Stdin)" }, + { type: "same", line: " fmt.Println(\"Calculator started! Available operations:\")" }, + { type: "same", line: " fmt.Println(\" + : Addition\")" }, + { type: "same", line: " fmt.Println(\" - : Subtraction\")" }, + { type: "same", line: " fmt.Println(\" * : Multiplication\")" }, + { type: "same", line: " fmt.Println(\" / : Division\")" }, + { type: "same", line: " fmt.Println(\" ^ : Power\")" }, + { type: "same", line: " fmt.Println(\" √ : Square root (use only one number)\")" }, + { type: "new", line: " fmt.Println(\" log: Logarithm (use 'log base number')\")" }, + { type: "same", line: "}" }, + { type: "same", line: "// End of file" } + ]; + + expect(result).toEqual(expected); + }); + + it("should correctly apply multiple insertions and deletions", () => { + const sourceCode = `package main +import "fmt" +func main() { + fmt.Println("Hello") + fmt.Println("World") +}`; + + const diffText = `--- original.go ++++ updated.go +@@ -1,8 +1,11 @@ + package main + +-import "fmt" ++import ( ++ "fmt" ++ "time" ++) + + func main() { +- fmt.Println("Hello") ++ fmt.Printf("The time is: %v\\n", time.Now()) +- fmt.Println("World") ++ fmt.Println("Goodbye!") + }`; + const result = applyUnifiedDiff(sourceCode, diffText); + + const expected = [ + { type: "same", line: "package main" }, + { type: "same", line: "" }, + { type: "old", line: "import \"fmt\"" }, + { type: "new", line: "import (" }, + { type: "new", line: " \"fmt\"" }, + { type: "new", line: " \"time\"" }, + { type: "new", line: ")" }, + { type: "same", line: "" }, + { type: "same", line: "func main() {" }, + { type: "old", line: " fmt.Println(\"Hello\")" }, + { type: "new", line: " fmt.Printf(\"The time is: %v\\n\", time.Now())" }, + { type: "old", line: " fmt.Println(\"World\")" }, + { type: "new", line: " fmt.Println(\"Goodbye!\")" }, + { type: "same", line: "}" } + ]; + + expect(result).toEqual(expected); + }); + + it("should correctly apply multiple diff blocks", () => { + const sourceCode = `package main +import ( + "bufio" + "fmt" + "math" + "os" + "strconv" + "strings" + "testing" +) +func main() { + scanner := bufio.NewScanner(os.Stdin) + fmt.Println("Calculator started! Available operations:") + fmt.Println(" + : Addition") + fmt.Println(" - : Subtraction") + fmt.Println(" * : Multiplication") + fmt.Println(" / : Division") + fmt.Println(" ^ : Power") + fmt.Println(" √ : Square root (use only one number)") + for { + fmt.Print("Enter calculation (e.g., 5 + 3 or √ 16) or 'q' to quit: ") + scanner.Scan() + input := scanner.Text() + if strings.ToLower(input) == "q" { + fmt.Println("Goodbye!") + break + } + result, err := calculate(input) + if err != nil { + fmt.Printf("Error: %v\n", err) + continue + } + fmt.Printf("Result: %v\n", result) + } +} +func calculate(input string) (float64, error) { + parts := strings.Fields(input) + if len(parts) < 2 { + return 0, fmt.Errorf("invalid input format: please use 'number operator number' or '√ number'") + } + if parts[0] == "√" { + if len(parts) != 2 { + return 0, fmt.Errorf("square root operation requires exactly one number") + } + num, err := strconv.ParseFloat(parts[1], 64) + if err != nil { + return 0, fmt.Errorf("invalid number for square root: %v", err) + } + if num < 0 { + return 0, fmt.Errorf("cannot calculate square root of a negative number") + } + return math.Sqrt(num), nil + } + if len(parts) != 3 { + return 0, fmt.Errorf("invalid input format: please use 'number operator number'") + } + num1, err := strconv.ParseFloat(parts[0], 64) + if err != nil { + return 0, fmt.Errorf("invalid first number: %v", err) + } + operator := parts[1] + num2, err := strconv.ParseFloat(parts[2], 64) + if err != nil { + return 0, fmt.Errorf("invalid second number: %v", err) + } + switch operator { + case "+": + return num1 + num2, nil + case "-": + return num1 - num2, nil + case "*": + return num1 * num2, nil + case "/": + if num2 == 0 { + return 0, fmt.Errorf("division by zero is not allowed") + } + return num1 / num2, nil + case "^": + return math.Pow(num1, num2), nil + default: + return 0, fmt.Errorf("invalid operator: must be +, -, *, /, ^, or √") + } +} +func TestCalculate(t *testing.T) { + tests := []struct { + input string + expected float64 + hasError bool + }{ + {"2 + 3", 5, false}, + {"10 - 5", 5, false}, + {"4 * 3", 12, false}, + {"15 / 3", 5, false}, + {"2 ^ 3", 8, false}, + {"√ 16", 4, false}, + {"2 + a", 0, true}, + {"15 / 0", 0, true}, + {"√ -4", 0, true}, + {"3 $ 4", 0, true}, + {"", 0, true}, + {"1", 0, true}, + {"1 +", 0, true}, + {"+ 1", 0, true}, + {"√ 2 3", 0, true}, + } + for _, test := range tests { + result, err := calculate(test.input) + if test.hasError && err == nil { + t.Errorf("Expected error for input '%s', but got none", test.input) + continue + } + if !test.hasError && err != nil { + t.Errorf("Unexpected error for input '%s': %v", test.input, err) + continue + } + if !test.hasError && result != test.expected { + t.Errorf("For input '%s': expected %f, but got %f", test.input, test.expected, result) + } + } +} +func TestSpecialCases(t *testing.T) { + result, err := calculate("2.5 + 2.5") + if err != nil { + t.Errorf("Unexpected error for floating point addition: %v", err) + } + if result != 5.0 { + t.Errorf("Floating point addition failed: expected 5.0, got %f", result) + } + result, err = calculate("2.5 ^ 2") + if err != nil { + t.Errorf("Unexpected error for power operation: %v", err) + } + expected := 6.25 + if math.Abs(result-expected) > 0.0001 { + t.Errorf("Power operation failed: expected %f, got %f", expected, result) + } + result, err = calculate("√ 2") + if err != nil { + t.Errorf("Unexpected error for square root: %v", err) + } + expected = math.Sqrt(2) + if math.Abs(result-expected) > 0.0001 { + t.Errorf("Square root operation failed: expected %f, got %f", expected, result) + } +} +func TestLargeNumbers(t *testing.T) { + result, err := calculate("1000000000 + 1000000000") + if err != nil { + t.Errorf("Unexpected error for adding large numbers: %v", err) + } + if result != 2000000000 { + t.Errorf("Adding large numbers failed: expected 2000000000, got %f", result) + } + result, err = calculate("1000000 * 1000000") + if err != nil { + t.Errorf("Unexpected error for multiplying large numbers: %v", err) + } + if result != 1000000000000 { + t.Errorf("Multiplying large numbers failed: expected 1000000000000, got %f", result) + } + result, err = calculate("2 ^ 30") + if err != nil { + t.Errorf("Unexpected error for large exponent operation: %v", err) + } + expected := math.Pow(2, 30) + if result != expected { + t.Errorf("Power operation with large exponent failed: expected %f, got %f", expected, result) + } + result, err = calculate("1000000000000 / 1000000") + if err != nil { + t.Errorf("Unexpected error for dividing large numbers: %v", err) + } + if result != 1000000 { + t.Errorf("Dividing large numbers failed: expected 1000000, got %f", result) + } +}`; + + const diffText = `--- original.go ++++ updated.go +@@ -30,6 +30,7 @@ + fmt.Println(" / : Division") + fmt.Println(" ^ : Power") + fmt.Println(" √ : Square root (use only one number)") ++ fmt.Println(" log: Logarithm (use 'log base number')") ++ fmt.Println(" Base must be > 0 and != 1, number must be > 0") + for { + fmt.Print("Enter calculation (e.g., 5 + 3 or √ 16) or 'q' to quit: ") +@@ -73,6 +74,8 @@ + } + return math.Sqrt(num), nil + } ++ ++ // Handle logarithmic operations ++ if parts[0] == "log" { ++ if len(parts) != 3 { ++ return 0, fmt.Errorf("logarithm operation requires exactly two arguments: 'log base number'") ++ } ++ base, err := strconv.ParseFloat(parts[1], 64) ++ if err != nil || base <= 0 || base == 1 { ++ return 0, fmt.Errorf("invalid base for logarithm: must be > 0 and != 1") ++ } ++ num, err := strconv.ParseFloat(parts[2], 64) ++ if err != nil || num <= 0 { ++ return 0, fmt.Errorf("invalid number for logarithm: must be > 0") ++ } ++ return math.Log(num) / math.Log(base), nil ++ } ++ + if len(parts) != 3 { + return 0, fmt.Errorf("invalid input format: please use 'number operator number'") +@@ -155,6 +158,15 @@ + } + } + } ++ ++func TestLogarithmicCases(t *testing.T) { ++ tests := []struct { ++ input string ++ expected float64 ++ hasError bool ++ }{ ++ {"log 2 8", 3, false}, ++ {"log 10 100", 2, false}, ++ {"log 10 -5", 0, true}, ++ {"log 1 100", 0, true}, ++ {"log 0.5 0.25", 2, false}, ++ }`; + const result = applyUnifiedDiff(sourceCode, diffText); + + expect(result[0].line).toEqual("package main"); + // 1st block + expect(result[21].line).toEqual(" fmt.Println(\" log: Logarithm (use 'log base number')\")"); + expect(result[22].line).toEqual(" fmt.Println(\" Base must be > 0 and != 1, number must be > 0\")"); + // 2nd block + expect(result[60]).toEqual({type: "same", line: "\t}"}); + expect(result[61]).toEqual({type: "new", line: "\t"}); + expect(result[62]).toEqual({type: "new", line: "\t// Handle logarithmic operations"}); + expect(result[77]).toEqual({type: "new", line: ""}); + expect(result[78]).toEqual({type: "same", line: "\tif len(parts) != 3 {"}); + // 3rd block + expect(result[145]).toEqual({type: "same", line: "}"}); + expect(result[146]).toEqual({type: "new", line: ""}); + expect(result[147]).toEqual({type: "new", line: "func TestLogarithmicCases(t *testing.T) {"}); + expect(result[158]).toEqual({type: "new", line: "\t}"}); + expect(result[159]).toEqual({type: "same", line: ""}); + expect(result[160]).toEqual({type: "same", line: "func TestSpecialCases(t *testing.T) {"}); + + }); + + it("should throw error when hunk cannot be matched to source", () => { + const sourceCode = `line1 +line2 +line3`; + + const diffText = `--- a.txt ++++ b.txt +@@ -1,3 +1,4 @@ +missing1 +-missing2 ++newline2 +missing3`; + + expect(() => applyUnifiedDiff(sourceCode, diffText)) + .toThrow("Hunk could not be applied cleanly to source code."); + }); +}); diff --git a/core/edit/lazy/unifiedDiffApply.ts b/core/edit/lazy/unifiedDiffApply.ts new file mode 100644 index 000000000..c5768f1d4 --- /dev/null +++ b/core/edit/lazy/unifiedDiffApply.ts @@ -0,0 +1,152 @@ +import { DiffLine } from "../../index"; + +/** + * Checks if a string matches unified diff format by validating: + * 1. Has at least one hunk header (@@ -n,m +n,m @@) + * 2. Contains valid diff content lines (starting with +, -, or space) which are not header lines + */ +export function isUnifiedDiffFormat(diff: string): boolean { + const lines = diff.trim().split("\n"); + + if (lines.length < 3) {return false;} + + let hasHunkHeader = false; + let hasValidContent = false; + + for (const line of lines) { + if (line.startsWith("---") || line.startsWith("+++")) { + // ignore file headers - they are not required or useful + } else if (line.match(/^@@ -\d+,?\d* \+\d+,?\d* @@/)) { + hasHunkHeader = true; + } else if (line.match(/^[+ -]/) || line === "") { + hasValidContent = true; + } + } + + return hasHunkHeader && hasValidContent; +} + +function extractBeforeLines(hunkLines: string[]): string[] { + return hunkLines + .filter((line) => line.startsWith("-") || !line.startsWith("+")) + .map((line) => line.substring(1)); +} + +/** + * Applies a unified diff to source code and returns an array of DiffLine objects. + * Each DiffLine contains a type ("same", "new", or "old") and the line content. + * + * @throws Error if the diff cannot be cleanly applied to the source + */ +export function applyUnifiedDiff(sourceCode: string, unifiedDiffText: string): DiffLine[] { + const sourceLines = sourceCode.split(/\r?\n/); + const hunks = parseUnifiedDiff(unifiedDiffText); + const diffResult: DiffLine[] = []; + let currentPos = 0; // pointer in sourceLines + + for (const hunk of hunks) { + const hunkBeforeLines = extractBeforeLines(hunk.lines); + const hunkStart = findHunkInSource(sourceLines, hunkBeforeLines, currentPos); + if (hunkStart === -1) { + // All hunks must be found in the source code. If not, throw an error. + throw new Error("Hunk could not be applied cleanly to source code."); + } + + // Emit any unchanged lines that come before this hunk. + for (let i = currentPos; i < hunkStart; i++) { + diffResult.push({ type: "same", line: sourceLines[i] }); + } + let hunkSourcePos = hunkStart; + + for (const dline of hunk.lines) { + const srcLine = sourceLines[hunkSourcePos]; + if (dline.startsWith("+")) { + // Insertion: output new line (strip the '+' marker) + diffResult.push({ type: "new", line: dline.substring(1) }); + } else if (dline.startsWith("-")) { + // Removal: output the removed (old) line and advance the pointer. + diffResult.push({ type: "old", line: srcLine }); + hunkSourcePos++; + } else { + // Context line: use the source line (in case the diff’s context has a minor whitespace error) + // and advance the pointer. + diffResult.push({ type: "same", line: srcLine }); + hunkSourcePos++; + } + } + currentPos = hunkSourcePos; + } + + for (let i = currentPos; i < sourceLines.length; i++) { + diffResult.push({ type: "same", line: sourceLines[i] }); + } + return diffResult; +} + +interface Hunk { + lines: string[]; +} + +/** + * Parses a unified diff string into an array of hunks. + * It skips the file header lines (starting with "---" or "+++") and hunk header lines (starting with "@@"), + * then collects the remaining lines (which may start with '+' or '-' or have no prefix). + */ +function parseUnifiedDiff(diffText: string): Hunk[] { + const lines = diffText.split(/\r?\n/); + const hunks: Hunk[] = []; + let currentHunk: Hunk | null = null; + + for (const line of lines) { + if (line.startsWith("---") || line.startsWith("+++")) { + // Skip file header lines. + continue; + } + if (line.startsWith("@@")) { + if (currentHunk) { + hunks.push(currentHunk); + } + currentHunk = { lines: [] }; + continue; + } + currentHunk?.lines.push(line); + } + if (currentHunk) { + hunks.push(currentHunk); + } + return hunks; +} + +/** + * Searches for an occurrence of the block of lines (the “before” block) in sourceLines, + * starting at startIndex. Comparison is done by checking if the lines are exactly equal, + * or if their trimmed versions are equal. + * + * Returns the index in sourceLines where the block begins, or -1 if no match is found. + */ +function findHunkInSource(sourceLines: string[], hunkBeforeLines: string[], startIndex: number): number { + for (let i = startIndex; i <= sourceLines.length - hunkBeforeLines.length; i++) { + let match = true; + for (let j = 0; j < hunkBeforeLines.length; j++) { + const sl = sourceLines[i + j]; + const hl = hunkBeforeLines[j]; + if (!linesMatch(sl, hl)) { + match = false; + break; + } + } + if (match) { + return i; + } + } + return -1; +} + +/** + * Returns true if the two lines are either exactly equal or equal after trimming whitespace and tabs. + */ +function linesMatch(a: string, b: string): boolean { + const trimmedA = a.replace(/^\s+/, ""); + const trimmedB = b.replace(/^\s+/, ""); + return trimmedA === trimmedB; +} diff --git a/docs/docs/edit/how-to-use-it.md b/docs/docs/edit/how-to-use-it.md index 850c34b60..19f8e0ccd 100644 --- a/docs/docs/edit/how-to-use-it.md +++ b/docs/docs/edit/how-to-use-it.md @@ -35,3 +35,10 @@ You can navigate through each proposed change, accepting or rejecting them using You can also accept or reject all changes at once using cmd/ctrl + shift + enter (to accept) or cmd/ctrl + shift + delete/backspace (to reject). If you want to request a new suggestion for the same highlighted code section, you can use cmd/ctrl + i to re-prompt the model. + +## Instant Diff Apply + +If you have large files (exeeding the output token of your model) the edit apply will delete all lines that exceed the model window. To mitigate you can instead of applying the changes directly, ask the chat LLM to "generate a unified diff". +The resulting diff (if the LLM has not made a mistake) can be instantly applied, changing only the lines that need to change. + +Explainer Video: https://youtu.be/b7Xxsot4gyw \ No newline at end of file From 2869cf50781317eddf55dde8248a247953f53d99 Mon Sep 17 00:00:00 2001 From: lkyu <67578466+lkyu-ly@users.noreply.github.com> Date: Thu, 20 Feb 2025 01:07:24 +0800 Subject: [PATCH 003/171] Update domain in docusaurus.config.js Change site url from `continue.dev` to `docs.continue.dev` so as to generate a correct sitemap. --- docs/docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index c97113a0a..0ca029806 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -19,7 +19,7 @@ const config = { favicon: "img/favicon.ico", // Set the production url of your site here - url: "https://continue.dev", + url: "https://docs.continue.dev", // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' baseUrl: "/", From 17dbfe6bfd38f67b7cb535da00fa626cdaf4f690 Mon Sep 17 00:00:00 2001 From: Aplulu Date: Fri, 21 Feb 2025 02:49:36 +0900 Subject: [PATCH 004/171] fix: Resolve proxy error when adding Azure OpenAI model --- packages/openai-adapters/src/apis/AzureOpenAI.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/openai-adapters/src/apis/AzureOpenAI.ts b/packages/openai-adapters/src/apis/AzureOpenAI.ts index 2b02af69d..fc9fbdda8 100644 --- a/packages/openai-adapters/src/apis/AzureOpenAI.ts +++ b/packages/openai-adapters/src/apis/AzureOpenAI.ts @@ -40,8 +40,10 @@ export class AzureOpenAIApi implements BaseLlmApi { if (PROXY) { const url = new URL(PROXY); proxyOptions = { - host: url.hostname, - port: Number(url.port), + host: (url.protocol ? url.protocol + "//" : "") + url.hostname, + port: Number(url.port || 80), + username: url.username, + password: url.password, }; } From ad73f4eaa58bfde4d710d8a276d08db6ea4891d1 Mon Sep 17 00:00:00 2001 From: ferenci84 Date: Fri, 21 Feb 2025 17:59:56 +0100 Subject: [PATCH 005/171] modify condition to ignore non-file URIs in RecentlyEditedTracker --- extensions/vscode/src/autocomplete/recentlyEdited.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/vscode/src/autocomplete/recentlyEdited.ts b/extensions/vscode/src/autocomplete/recentlyEdited.ts index 69b9b4d0f..d32f362dd 100644 --- a/extensions/vscode/src/autocomplete/recentlyEdited.ts +++ b/extensions/vscode/src/autocomplete/recentlyEdited.ts @@ -47,7 +47,7 @@ export class RecentlyEditedTracker { editedRange: Omit, ): Promise { - if (editedRange.uri.scheme === "output") { + if (editedRange.uri.scheme !== "file") { return; } @@ -83,7 +83,6 @@ export class RecentlyEditedTracker { RecentlyEditedTracker.maxRecentlyEditedRanges, ); } - } private insertDocument(uri: vscode.Uri): void { From 15e93dd5d0dc3b5dcd00504833beacbddbfe44f3 Mon Sep 17 00:00:00 2001 From: Ingo Eichhorst Date: Sun, 23 Feb 2025 13:16:50 +0100 Subject: [PATCH 006/171] fix: fixed misallignment in tests caused by linter --- core/edit/lazy/unifiedDiffApply.test.ts | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/core/edit/lazy/unifiedDiffApply.test.ts b/core/edit/lazy/unifiedDiffApply.test.ts index c7a5a8370..f0eae9b64 100644 --- a/core/edit/lazy/unifiedDiffApply.test.ts +++ b/core/edit/lazy/unifiedDiffApply.test.ts @@ -46,8 +46,10 @@ describe("isUnifiedDiffFormat", () => { it("should return true in case of empty lines", () => { const diffWithoutFileHeaders = `@@ -1,3 +1,4 @@ line1 + -line2 +newline2 + line3`; expect(isUnifiedDiffFormat(diffWithoutFileHeaders)).toBe(true); }); @@ -98,7 +100,9 @@ describe("applyUnifiedDiff", () => { it("should correctly apply multiple insertions and deletions", () => { const sourceCode = `package main + import "fmt" + func main() { fmt.Println("Hello") fmt.Println("World") @@ -375,22 +379,21 @@ func TestLargeNumbers(t *testing.T) { expect(result[0].line).toEqual("package main"); // 1st block - expect(result[21].line).toEqual(" fmt.Println(\" log: Logarithm (use 'log base number')\")"); - expect(result[22].line).toEqual(" fmt.Println(\" Base must be > 0 and != 1, number must be > 0\")"); + expect(result[18].line).toEqual("\tfmt.Println(\" √ : Square root (use only one number)\")"); + expect(result[19].line).toEqual(" fmt.Println(\" log: Logarithm (use 'log base number')\")"); + expect(result[20].line).toEqual(" fmt.Println(\" Base must be > 0 and != 1, number must be > 0\")"); // 2nd block - expect(result[60]).toEqual({type: "same", line: "\t}"}); - expect(result[61]).toEqual({type: "new", line: "\t"}); - expect(result[62]).toEqual({type: "new", line: "\t// Handle logarithmic operations"}); - expect(result[77]).toEqual({type: "new", line: ""}); - expect(result[78]).toEqual({type: "same", line: "\tif len(parts) != 3 {"}); + expect(result[56]).toEqual({type: "same", line: "\t}"}); + expect(result[57]).toEqual({type: "new", line: "\t"}); + expect(result[58]).toEqual({type: "new", line: "\t// Handle logarithmic operations"}); + expect(result[73]).toEqual({type: "new", line: ""}); + expect(result[74]).toEqual({type: "same", line: "\tif len(parts) != 3 {"}); // 3rd block - expect(result[145]).toEqual({type: "same", line: "}"}); - expect(result[146]).toEqual({type: "new", line: ""}); - expect(result[147]).toEqual({type: "new", line: "func TestLogarithmicCases(t *testing.T) {"}); - expect(result[158]).toEqual({type: "new", line: "\t}"}); - expect(result[159]).toEqual({type: "same", line: ""}); - expect(result[160]).toEqual({type: "same", line: "func TestSpecialCases(t *testing.T) {"}); - + expect(result[140]).toEqual({type: "same", line: "}"}); + expect(result[141]).toEqual({type: "new", line: ""}); + expect(result[142]).toEqual({type: "new", line: "func TestLogarithmicCases(t *testing.T) {"}); + expect(result[153]).toEqual({type: "new", line: "\t}"}); + expect(result[154]).toEqual({type: "same", line: "func TestSpecialCases(t *testing.T) {"}); }); it("should throw error when hunk cannot be matched to source", () => { From b02e6ba660b493fcd62742dfb2010c90b88a2656 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 27 Feb 2025 11:47:20 -0800 Subject: [PATCH 007/171] fix markdown patch --- .../markdown/utils/patchNestedMarkdown.ts | 68 ++++--------------- 1 file changed, 13 insertions(+), 55 deletions(-) diff --git a/gui/src/components/markdown/utils/patchNestedMarkdown.ts b/gui/src/components/markdown/utils/patchNestedMarkdown.ts index 29b305b26..b8be69ae7 100644 --- a/gui/src/components/markdown/utils/patchNestedMarkdown.ts +++ b/gui/src/components/markdown/utils/patchNestedMarkdown.ts @@ -8,9 +8,8 @@ // TODO support github-specific markdown as well, edge case */ - export const patchNestedMarkdown = (source: string): string => { - if (!source.match(/```(md|markdown)/)) return source; // For performance + if (!source.match(/```(\w+\.(md|markdown))/)) return source; // For performance // const start = Date.now(); let nestCount = 0; const lines = source.split("\n"); @@ -28,9 +27,18 @@ export const patchNestedMarkdown = (source: string): string => { } } else { // Enter the markdown block, start tracking nesting - if (line.startsWith("```md") || line.startsWith("```markdown")) { - nestCount = 1; - lines[i] = lines[i].replace(/```(md|markdown)/, "~~~"); // Replace backticks with tildes + if (line.startsWith("```")) { + const header = line.replaceAll("`", ""); + const file = header.split(" ")[0]; + + if (file) { + const ext = file.split(".").at(-1); + debugger; + if (ext === "md" || ext === "markdown") { + nestCount = 1; + lines[i] = lines[i].replaceAll("`", "~"); // Replace backticks with tildes + } + } } } } @@ -38,53 +46,3 @@ export const patchNestedMarkdown = (source: string): string => { // console.log(`patched in ${Date.now() - start}ms`); return out; }; - -// This version tries to detect if a codeblock without a language specified is a starter codeblock -// It tries again if didn't come back to root nesting, without checking for that ^ -// I didn't use for performance and also because the root nest check doesn't make sense mid-generation - -// export const patchNestedMarkdown = (source: string): string => { -// const start = Date.now(); - -// let attempts = 0; - -// while (attempts <= 2) { -// let nestCount = 0; -// const lines = source.split("\n"); -// const trimmedLines = lines.map((l) => l.trim()); -// for (let i = 0; i < trimmedLines.length; i++) { -// const line = trimmedLines[i]; -// if (nestCount) { -// if (line.match(/^`+$/)) { -// if (attempts === 0 && i !== lines.length && lines[i + 1] !== "") { -// nestCount++; -// continue; -// } -// if (nestCount === 1) lines[i] = "~~~"; -// nestCount--; -// } else if (line.startsWith("```")) { -// // Going into a nested codeblock -// nestCount++; -// } -// } else { -// // Enter the markdown block, start tracking nesting -// if (line.startsWith("```md") || line.startsWith("```markdown")) { -// nestCount = 1; -// lines[i] = lines[i].replace(/^```(md|markdown)/, "~~~"); // Replace backticks with tildes -// } -// } -// } -// if (nestCount === 0) { -// console.log( -// `patch successful in ${Date.now() - start} ms with ${attempts} attempts`, -// ); -// return lines.join("\n"); -// } -// attempts++; -// } - -// console.log( -// `patch failed in ${Date.now() - start} ms with ${attempts} attempts`, -// ); -// return source; -// }; From e2e8e3990a40fe4ff49d8ce6ac21f1a85e1f5b62 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 27 Feb 2025 11:49:01 -0800 Subject: [PATCH 008/171] cleanup --- gui/src/components/markdown/utils/patchNestedMarkdown.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/src/components/markdown/utils/patchNestedMarkdown.ts b/gui/src/components/markdown/utils/patchNestedMarkdown.ts index b8be69ae7..10d5af1b2 100644 --- a/gui/src/components/markdown/utils/patchNestedMarkdown.ts +++ b/gui/src/components/markdown/utils/patchNestedMarkdown.ts @@ -33,7 +33,6 @@ export const patchNestedMarkdown = (source: string): string => { if (file) { const ext = file.split(".").at(-1); - debugger; if (ext === "md" || ext === "markdown") { nestCount = 1; lines[i] = lines[i].replaceAll("`", "~"); // Replace backticks with tildes From 47a47dac42ee8e025b21d0950bc190dc3206a9fc Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 28 Feb 2025 14:54:23 -0800 Subject: [PATCH 009/171] docs note --- docs/docs/json-reference.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/json-reference.md b/docs/docs/json-reference.md index ba21ccb65..11e92a183 100644 --- a/docs/docs/json-reference.md +++ b/docs/docs/json-reference.md @@ -36,6 +36,7 @@ Each model has specific configuration options tailored to its provider and funct - `engine`: Engine for Azure OpenAI requests. - `capabilities`: Override auto-detected capabilities: - `uploadImage`: Boolean indicating if the model supports image uploads. + - `tools`: Boolean indicating if the model supports tool calls. _(AWS Only)_ From 037545fd77e2439afaf09408c12fd7a25dec35a9 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 1 Mar 2025 10:52:38 -0800 Subject: [PATCH 010/171] stale-issue-helper dry run --- .github/workflows/stale-issue-helper.yaml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/stale-issue-helper.yaml diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml new file mode 100644 index 000000000..c6d4c415a --- /dev/null +++ b/.github/workflows/stale-issue-helper.yaml @@ -0,0 +1,25 @@ +name: "Label stale issues and PRs" +on: + schedule: + - cron: "*/5 * * * *" + +jobs: + stale: + runs-on: ubuntu-latest + strategy: + matrix: + assignee: [sestinj, Patrick-Erichsen, tomasz-stefaniak, RomneyDa] + steps: + - uses: actions/stale@v9 + with: + stale-issue-message: "This issue hasn't been updated in a while. @${{ matrix.assignee }} can you take a look?" + stale-pr-message: "This PR hasn't been updated in a while. @${{ matrix.assignee }} can you take a look?" + days-before-stale: 180 + days-before-close: -1 + days-before-pr-close: -1 + stale-issue-label: "stale" + stale-pr-label: "stale" + debug-only: true + exempt-issue-labels: "needs-triage,no-stale" + exempt-pr-labels: "no-stale,no-stale" + exempt-assignees: ${{ toJSON(fromJSON('["sestinj", "Patrick-Erichsen", "tomasz-stefaniak", "RomneyDa"]').filter(user => user != matrix.assignee)) }} From 3acbc68df82ebfd03ffbd13fdb317cf3c0e0f6df Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 1 Mar 2025 10:53:22 -0800 Subject: [PATCH 011/171] run on push --- .github/workflows/stale-issue-helper.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index c6d4c415a..11c651cd7 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -1,7 +1,10 @@ name: "Label stale issues and PRs" on: + push: + branches: + - nate/stale-issue-helper schedule: - - cron: "*/5 * * * *" + - cron: "30 1 * * *" jobs: stale: From 17e5eb912f640f9cf19ef3d52ed8cfdd72e49a7b Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 1 Mar 2025 11:12:09 -0800 Subject: [PATCH 012/171] use excluded-assignees --- .github/workflows/stale-issue-helper.yaml | 16 +++++++++++++- scripts/getExcludedAssignees.js | 27 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 scripts/getExcludedAssignees.js diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 11c651cd7..4bfc83dee 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -13,6 +13,20 @@ jobs: matrix: assignee: [sestinj, Patrick-Erichsen, tomasz-stefaniak, RomneyDa] steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + + - name: Compute excluded assignees + id: excluded-assignees + run: | + node ./scripts/getExcludedAssignees.js sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa ${{ matrix.assignee }} + + echo "excluded_assignees=$result" >> $GITHUB_OUTPUT + - uses: actions/stale@v9 with: stale-issue-message: "This issue hasn't been updated in a while. @${{ matrix.assignee }} can you take a look?" @@ -25,4 +39,4 @@ jobs: debug-only: true exempt-issue-labels: "needs-triage,no-stale" exempt-pr-labels: "no-stale,no-stale" - exempt-assignees: ${{ toJSON(fromJSON('["sestinj", "Patrick-Erichsen", "tomasz-stefaniak", "RomneyDa"]').filter(user => user != matrix.assignee)) }} + exempt-assignees: ${{ steps.excluded-assignees.outputs.excluded_assignees }} diff --git a/scripts/getExcludedAssignees.js b/scripts/getExcludedAssignees.js new file mode 100644 index 000000000..e6ac5904c --- /dev/null +++ b/scripts/getExcludedAssignees.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node + +function removeStringFromList(list, stringToRemove) { + return list.filter((item) => item !== stringToRemove); +} + +function main() { + // Get command line arguments + const args = process.argv.slice(2); + + if (args.length < 2) { + console.error( + "Usage: node script.js ", + ); + process.exit(1); + } + + const list = args[0].split(","); + const stringToRemove = args[1]; + + const result = removeStringFromList(list, stringToRemove); + + // Output the result as comma-separated values + console.log(result.join(",")); +} + +main(); From 22c296867638ff5a149c96a2ae7a128516f8f8c5 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 1 Mar 2025 11:17:55 -0800 Subject: [PATCH 013/171] include only assigned --- .github/workflows/stale-issue-helper.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 4bfc83dee..f2780530f 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -40,3 +40,4 @@ jobs: exempt-issue-labels: "needs-triage,no-stale" exempt-pr-labels: "no-stale,no-stale" exempt-assignees: ${{ steps.excluded-assignees.outputs.excluded_assignees }} + include-only-assigned: true From a6160ce3433427ba5258645290b028a3291540e5 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 1 Mar 2025 11:20:05 -0800 Subject: [PATCH 014/171] fx --- .github/workflows/stale-issue-helper.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index f2780530f..2c5a00b19 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -23,8 +23,9 @@ jobs: - name: Compute excluded assignees id: excluded-assignees run: | - node ./scripts/getExcludedAssignees.js sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa ${{ matrix.assignee }} + result=$(node ./scripts/getExcludedAssignees.js sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa ${{ matrix.assignee }}) + echo "Result: $result" echo "excluded_assignees=$result" >> $GITHUB_OUTPUT - uses: actions/stale@v9 From 0b78baf289283ab73359980d29a3648064220538 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 1 Mar 2025 11:26:54 -0800 Subject: [PATCH 015/171] env --- .github/workflows/stale-issue-helper.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 2c5a00b19..6b8747e8a 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -9,9 +9,11 @@ on: jobs: stale: runs-on: ubuntu-latest + env: + TEAM_MEMBERS: "sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa" strategy: matrix: - assignee: [sestinj, Patrick-Erichsen, tomasz-stefaniak, RomneyDa] + assignee: ${{ env.TEAM_MEMBERS }} steps: - uses: actions/checkout@v4 @@ -23,7 +25,7 @@ jobs: - name: Compute excluded assignees id: excluded-assignees run: | - result=$(node ./scripts/getExcludedAssignees.js sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa ${{ matrix.assignee }}) + result=$(node ./scripts/getExcludedAssignees.js ${{ env.TEAM_MEMBERS }} ${{ matrix.assignee }}) echo "Result: $result" echo "excluded_assignees=$result" >> $GITHUB_OUTPUT @@ -39,6 +41,6 @@ jobs: stale-pr-label: "stale" debug-only: true exempt-issue-labels: "needs-triage,no-stale" - exempt-pr-labels: "no-stale,no-stale" + exempt-pr-labels: "no-stale" exempt-assignees: ${{ steps.excluded-assignees.outputs.excluded_assignees }} include-only-assigned: true From db35636b71c05e787efc1af35ece6cfd993dd759 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 1 Mar 2025 11:28:02 -0800 Subject: [PATCH 016/171] fix --- .github/workflows/stale-issue-helper.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 6b8747e8a..891908f7c 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -13,7 +13,7 @@ jobs: TEAM_MEMBERS: "sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa" strategy: matrix: - assignee: ${{ env.TEAM_MEMBERS }} + assignee: [sestinj, Patrick-Erichsen, tomasz-stefaniak, RomneyDa] steps: - uses: actions/checkout@v4 From 2376ed817a15187ea1e8f2f2545881b4d2788aa4 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 2 Mar 2025 15:51:37 -0800 Subject: [PATCH 017/171] handle URI query params --- core/core.ts | 20 ++++++---- core/index.d.ts | 3 +- core/protocol/coreWebview.ts | 5 ++- extensions/vscode/package.json | 1 + .../vscode/src/extension/VsCodeExtension.ts | 39 ++++++++++++++++++- .../vscode/src/stubs/WorkOsAuthProvider.ts | 13 +++---- extensions/vscode/src/stubs/uriHandler.ts | 10 +++++ gui/src/components/TabBar/TabBar.tsx | 4 -- 8 files changed, 73 insertions(+), 22 deletions(-) create mode 100644 extensions/vscode/src/stubs/uriHandler.ts diff --git a/core/core.ts b/core/core.ts index 6d78ca855..c5b5a064a 100644 --- a/core/core.ts +++ b/core/core.ts @@ -950,15 +950,21 @@ export class Core { }); // - on("didChangeSelectedProfile", (msg) => { - void this.configHandler.setSelectedProfile(msg.data.id); - void this.configHandler.reloadConfig(); + on("didChangeSelectedProfile", async (msg) => { + await this.configHandler.setSelectedProfile(msg.data.id); + await this.configHandler.reloadConfig(); }); - on("didChangeSelectedOrg", (msg) => { - void this.configHandler.setSelectedOrgId(msg.data.id); - void this.configHandler.reloadConfig(); - void this.configHandler.loadAssistantsForSelectedOrg(); + on("didChangeSelectedOrg", async (msg) => { + await this.configHandler.setSelectedOrgId(msg.data.id); + await this.configHandler.loadAssistantsForSelectedOrg(); + if (msg.data.profileId) { + this.invoke("didChangeSelectedProfile", { + id: msg.data.profileId, + }); + } else { + await this.configHandler.reloadConfig(); + } }); on("didChangeControlPlaneSessionInfo", async (msg) => { diff --git a/core/index.d.ts b/core/index.d.ts index 7cbf0e25b..f34a7fbc9 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -920,8 +920,9 @@ export interface BaseCompletionOptions { } export interface ModelCapability { - uploadImage?: boolean; tools?: boolean; + uploadImage?: boolean; + outputImage?: boolean; } export interface ModelDescription { diff --git a/core/protocol/coreWebview.ts b/core/protocol/coreWebview.ts index 67b5919a4..5e71e5f11 100644 --- a/core/protocol/coreWebview.ts +++ b/core/protocol/coreWebview.ts @@ -5,7 +5,10 @@ import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js"; export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol & { didChangeSelectedProfile: [{ id: string | null }, void]; - didChangeSelectedOrg: [{ id: string | null }, void]; + didChangeSelectedOrg: [ + { id: string | null; profileId?: string | null }, + void, + ]; }; export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol & { didChangeAvailableProfiles: [ diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 366da7ff5..9ee40b4a0 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -52,6 +52,7 @@ "llama" ], "activationEvents": [ + "onUri", "onStartupFinished", "onView:continueGUIView" ], diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 8953c91a0..814f6be97 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -28,6 +28,7 @@ import { registerAllPromptFilesCompletionProviders } from "../lang-server/prompt import EditDecorationManager from "../quickEdit/EditDecorationManager"; import { QuickEdit } from "../quickEdit/QuickEditQuickPick"; import { setupRemoteConfigSync } from "../stubs/activation"; +import { UriEventHandler } from "../stubs/uriHandler"; import { getControlPlaneSessionInfo, WorkOsAuthProvider, @@ -55,10 +56,11 @@ export class VsCodeExtension { private battery: Battery; private workOsAuthProvider: WorkOsAuthProvider; private fileSearch: FileSearch; + private uriHandler = new UriEventHandler(); constructor(context: vscode.ExtensionContext) { // Register auth provider - this.workOsAuthProvider = new WorkOsAuthProvider(context); + this.workOsAuthProvider = new WorkOsAuthProvider(context, this.uriHandler); this.workOsAuthProvider.refreshSessions(); context.subscriptions.push(this.workOsAuthProvider); @@ -193,6 +195,41 @@ export class VsCodeExtension { ), ); + // Handle uri events + this.uriHandler.event((uri) => { + const queryParams = new URLSearchParams(uri.query); + let profileId = queryParams.get("profile_id"); + let orgId = queryParams.get("org_id"); + + if (orgId) { + if (orgId === "null") { + orgId = null; + } + // In case org id is passed with profile id + // Make sure org is updated before profile is set + if (profileId) { + if (profileId === "null") { + profileId = null; + } + this.core.invoke("didChangeSelectedOrg", { + id: orgId, + profileId, + }); + } else { + this.core.invoke("didChangeSelectedOrg", { + id: orgId, + }); + } + } else if (profileId) { + if (profileId === "null") { + profileId = null; + } + this.core.invoke("didChangeSelectedProfile", { + id: profileId, + }); + } + }); + // Battery this.battery = new Battery(); context.subscriptions.push(this.battery); diff --git a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts index 8f0e00c8c..30151d565 100644 --- a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts +++ b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts @@ -15,13 +15,13 @@ import { ExtensionContext, ProgressLocation, Uri, - UriHandler, window, workspace, } from "vscode"; import { PromiseAdapter, promiseFromEvent } from "./promiseUtils"; import { SecretStorage } from "./SecretStorage"; +import { UriEventHandler } from "./uriHandler"; const AUTH_NAME = "Continue"; @@ -35,11 +35,6 @@ const controlPlaneEnv = getControlPlaneEnvSync( const SESSIONS_SECRET_KEY = `${controlPlaneEnv.AUTH_TYPE}.sessions`; -class UriEventHandler extends EventEmitter implements UriHandler { - public handleUri(uri: Uri) { - this.fire(uri); - } -} // Function to generate a random string of specified length function generateRandomString(length: number): string { const possibleCharacters = @@ -83,13 +78,15 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable { string, { promise: Promise; cancel: EventEmitter } >(); - private _uriHandler = new UriEventHandler(); private static EXPIRATION_TIME_MS = 1000 * 60 * 15; // 15 minutes private secretStorage: SecretStorage; - constructor(private readonly context: ExtensionContext) { + constructor( + private readonly context: ExtensionContext, + private readonly _uriHandler: UriEventHandler, + ) { this._disposable = Disposable.from( authentication.registerAuthenticationProvider( controlPlaneEnv.AUTH_TYPE, diff --git a/extensions/vscode/src/stubs/uriHandler.ts b/extensions/vscode/src/stubs/uriHandler.ts new file mode 100644 index 000000000..cc324f856 --- /dev/null +++ b/extensions/vscode/src/stubs/uriHandler.ts @@ -0,0 +1,10 @@ +import * as vscode from "vscode"; + +export class UriEventHandler + extends vscode.EventEmitter + implements vscode.UriHandler +{ + public handleUri(uri: vscode.Uri) { + this.fire(uri); + } +} diff --git a/gui/src/components/TabBar/TabBar.tsx b/gui/src/components/TabBar/TabBar.tsx index 859f6e90c..3b87a23c6 100644 --- a/gui/src/components/TabBar/TabBar.tsx +++ b/gui/src/components/TabBar/TabBar.tsx @@ -155,10 +155,6 @@ export function TabBar() { ); const tabs = useSelector((state: RootState) => state.tabs.tabs); - useEffect(() => { - console.log("session", currentSession); - }, [currentSession.id]); - // Simple UUID generator for our needs const generateId = useCallback(() => { return Date.now().toString(36) + Math.random().toString(36).substring(2); From b6bfb222f94b2528d33579cdff67be011dda8e55 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 19:53:47 -0800 Subject: [PATCH 018/171] auto close --- .github/workflows/stale-issue-helper.yaml | 31 +++-------------------- scripts/getExcludedAssignees.js | 27 -------------------- 2 files changed, 4 insertions(+), 54 deletions(-) delete mode 100644 scripts/getExcludedAssignees.js diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 891908f7c..e05e45c40 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -9,38 +9,15 @@ on: jobs: stale: runs-on: ubuntu-latest - env: - TEAM_MEMBERS: "sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa" - strategy: - matrix: - assignee: [sestinj, Patrick-Erichsen, tomasz-stefaniak, RomneyDa] steps: - - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - - - name: Compute excluded assignees - id: excluded-assignees - run: | - result=$(node ./scripts/getExcludedAssignees.js ${{ env.TEAM_MEMBERS }} ${{ matrix.assignee }}) - - echo "Result: $result" - echo "excluded_assignees=$result" >> $GITHUB_OUTPUT - - uses: actions/stale@v9 with: - stale-issue-message: "This issue hasn't been updated in a while. @${{ matrix.assignee }} can you take a look?" - stale-pr-message: "This PR hasn't been updated in a while. @${{ matrix.assignee }} can you take a look?" - days-before-stale: 180 - days-before-close: -1 - days-before-pr-close: -1 + close-issue-message: "This issue was closed because it hasn't been updated for 120 days. If it's still important, please reopen + comment and we will glady take another look." + stale-issue-message: "It looks like this issue hasn't been updated in 90 days. If there's still no activity after 120 days, it will be closed." + days-before-stale: 90 + days-before-close: 120 stale-issue-label: "stale" stale-pr-label: "stale" debug-only: true exempt-issue-labels: "needs-triage,no-stale" exempt-pr-labels: "no-stale" - exempt-assignees: ${{ steps.excluded-assignees.outputs.excluded_assignees }} - include-only-assigned: true diff --git a/scripts/getExcludedAssignees.js b/scripts/getExcludedAssignees.js deleted file mode 100644 index e6ac5904c..000000000 --- a/scripts/getExcludedAssignees.js +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env node - -function removeStringFromList(list, stringToRemove) { - return list.filter((item) => item !== stringToRemove); -} - -function main() { - // Get command line arguments - const args = process.argv.slice(2); - - if (args.length < 2) { - console.error( - "Usage: node script.js ", - ); - process.exit(1); - } - - const list = args[0].split(","); - const stringToRemove = args[1]; - - const result = removeStringFromList(list, stringToRemove); - - // Output the result as comma-separated values - console.log(result.join(",")); -} - -main(); From 2f71a8edf0e8ef9c686ee8db6a41b3cbf7c22051 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 19:55:14 -0800 Subject: [PATCH 019/171] don't close/mark prs stale --- .github/workflows/stale-issue-helper.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index e05e45c40..2e0f0fdcd 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -16,6 +16,8 @@ jobs: stale-issue-message: "It looks like this issue hasn't been updated in 90 days. If there's still no activity after 120 days, it will be closed." days-before-stale: 90 days-before-close: 120 + days-before-pr-stale: -1 + days-before-pr-close: -1 stale-issue-label: "stale" stale-pr-label: "stale" debug-only: true From 567d2f146e6addffd44b849648c39a1b8e0bbd4d Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:00:59 -0800 Subject: [PATCH 020/171] update messages --- .github/workflows/stale-issue-helper.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 2e0f0fdcd..b5f32c704 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -13,7 +13,7 @@ jobs: - uses: actions/stale@v9 with: close-issue-message: "This issue was closed because it hasn't been updated for 120 days. If it's still important, please reopen + comment and we will glady take another look." - stale-issue-message: "It looks like this issue hasn't been updated in 90 days. If there's still no activity after 120 days, it will be closed." + stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after 120 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue." days-before-stale: 90 days-before-close: 120 days-before-pr-stale: -1 From d0b7d1a0e0b4f15562f70a2d6443f6dc83040a09 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:09:58 -0800 Subject: [PATCH 021/171] first round: close issues before 90 days --- .github/workflows/stale-issue-helper.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index b5f32c704..70159939e 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -14,12 +14,11 @@ jobs: with: close-issue-message: "This issue was closed because it hasn't been updated for 120 days. If it's still important, please reopen + comment and we will glady take another look." stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after 120 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue." - days-before-stale: 90 - days-before-close: 120 + days-before-stale: -1 + days-before-close: 90 days-before-pr-stale: -1 days-before-pr-close: -1 stale-issue-label: "stale" stale-pr-label: "stale" - debug-only: true - exempt-issue-labels: "needs-triage,no-stale" + exempt-issue-labels: "needs-triage,no-stale,high,highest" exempt-pr-labels: "no-stale" From d4e46a946bd8551659aec1cd26c4645fa3e76225 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:18:40 -0800 Subject: [PATCH 022/171] update msg --- .github/workflows/stale-issue-helper.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 70159939e..4e6e39d3d 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/stale@v9 with: - close-issue-message: "This issue was closed because it hasn't been updated for 120 days. If it's still important, please reopen + comment and we will glady take another look." + close-issue-message: "This issue was closed because it hasn't been updated for 120 days. If it's still important, please reopen + comment and we'll gladly take another look!" stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after 120 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue." days-before-stale: -1 days-before-close: 90 From dd9ac81b44213f27eff617c9e70bded6454a39c9 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:19:51 -0800 Subject: [PATCH 023/171] mark stale --- .github/workflows/stale-issue-helper.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 4e6e39d3d..30e1ad773 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -13,8 +13,8 @@ jobs: - uses: actions/stale@v9 with: close-issue-message: "This issue was closed because it hasn't been updated for 120 days. If it's still important, please reopen + comment and we'll gladly take another look!" - stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after 120 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue." - days-before-stale: -1 + # stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after 120 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue." + days-before-stale: 90 days-before-close: 90 days-before-pr-stale: -1 days-before-pr-close: -1 From d9d79b259ee4969d409b7497362d7038f8b4fc2d Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:22:52 -0800 Subject: [PATCH 024/171] mark stale --- .github/workflows/stale-issue-helper.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 30e1ad773..9df56ba06 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/stale@v9 with: - close-issue-message: "This issue was closed because it hasn't been updated for 120 days. If it's still important, please reopen + comment and we'll gladly take another look!" - # stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after 120 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue." + close-issue-message: "This issue was closed because it hasn't been updated for 100 days. If it's still important, please reopen + comment and we'll gladly take another look!" + stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue." days-before-stale: 90 - days-before-close: 90 + days-before-close: 100 days-before-pr-stale: -1 days-before-pr-close: -1 stale-issue-label: "stale" From 899c9f5349dd5a5bc97a8177ffbc75715b364ac8 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:24:07 -0800 Subject: [PATCH 025/171] permissions --- .github/workflows/stale-issue-helper.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 9df56ba06..f4f9d46c7 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -8,6 +8,9 @@ on: jobs: stale: + permissions: + issues: write + pull-requests: write runs-on: ubuntu-latest steps: - uses: actions/stale@v9 From 8ac5f1dc213d56cac004459d516cdca7abbfaaae Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:37:54 -0800 Subject: [PATCH 026/171] update name --- .github/workflows/stale-issue-helper.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index f4f9d46c7..6f4ddd0b3 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -1,4 +1,4 @@ -name: "Label stale issues and PRs" +name: "Label and close stale issues" on: push: branches: From dbfebd5a734fbb661d6e7009e3d31030c6de8445 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:40:28 -0800 Subject: [PATCH 027/171] update close --- .github/workflows/stale-issue-helper.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 6f4ddd0b3..ce58d0933 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/stale@v9 with: - close-issue-message: "This issue was closed because it hasn't been updated for 100 days. If it's still important, please reopen + comment and we'll gladly take another look!" + close-issue-message: "This issue was closed because it wasn't updated for 10 days after being marked stale. If it's still important, please reopen + comment and we'll gladly take another look!" stale-issue-message: "This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue." days-before-stale: 90 - days-before-close: 100 + days-before-close: 10 days-before-pr-stale: -1 days-before-pr-close: -1 stale-issue-label: "stale" From 937b74f380d5b49f57c71f5cce19f9bf843443ee Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:44:09 -0800 Subject: [PATCH 028/171] update title --- .github/workflows/stale-issue-helper.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index ce58d0933..38e2a0226 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -1,4 +1,4 @@ -name: "Label and close stale issues" +name: "Label / close stale issues" on: push: branches: From 3fd2685a610cbaf26c624165ee72bbec0551bf7c Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:47:06 -0800 Subject: [PATCH 029/171] increase ops --- .github/workflows/stale-issue-helper.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 38e2a0226..c37a3aa1b 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -21,6 +21,7 @@ jobs: days-before-close: 10 days-before-pr-stale: -1 days-before-pr-close: -1 + operations-per-run: 100 stale-issue-label: "stale" stale-pr-label: "stale" exempt-issue-labels: "needs-triage,no-stale,high,highest" From 75387a18a0cbf710c117f066feaec83d0b36c635 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 20:48:47 -0800 Subject: [PATCH 030/171] increase ops --- .github/workflows/stale-issue-helper.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index c37a3aa1b..8f10ebcb5 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -21,7 +21,7 @@ jobs: days-before-close: 10 days-before-pr-stale: -1 days-before-pr-close: -1 - operations-per-run: 100 + operations-per-run: 2000 stale-issue-label: "stale" stale-pr-label: "stale" exempt-issue-labels: "needs-triage,no-stale,high,highest" From 58b5ad94cca789be64e91dad6f5b958d532d501c Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 2 Mar 2025 21:01:19 -0800 Subject: [PATCH 031/171] remove push trigger --- .github/workflows/stale-issue-helper.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/stale-issue-helper.yaml b/.github/workflows/stale-issue-helper.yaml index 8f10ebcb5..067f4c60f 100644 --- a/.github/workflows/stale-issue-helper.yaml +++ b/.github/workflows/stale-issue-helper.yaml @@ -1,8 +1,5 @@ name: "Label / close stale issues" on: - push: - branches: - - nate/stale-issue-helper schedule: - cron: "30 1 * * *" @@ -21,7 +18,7 @@ jobs: days-before-close: 10 days-before-pr-stale: -1 days-before-pr-close: -1 - operations-per-run: 2000 + operations-per-run: 1000 stale-issue-label: "stale" stale-pr-label: "stale" exempt-issue-labels: "needs-triage,no-stale,high,highest" From e997f40b16c782c8d3d62618f00aa61d5c0898d7 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 2 Mar 2025 22:39:35 -0800 Subject: [PATCH 032/171] clean up --- core/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index f34a7fbc9..7cbf0e25b 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -920,9 +920,8 @@ export interface BaseCompletionOptions { } export interface ModelCapability { - tools?: boolean; uploadImage?: boolean; - outputImage?: boolean; + tools?: boolean; } export interface ModelDescription { From 753b3bc938944882d8523053458f3de2c21d08b4 Mon Sep 17 00:00:00 2001 From: Simon Chauvin <34301767+chauvinSimon@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:29:17 +0100 Subject: [PATCH 033/171] Update codebase.mdx - fix yaml against LanceError To prevent the popup of VSCode Error: `Error getting context items from codebase: Error: lance error: LanceError(IO): k must be positive ...` --- docs/docs/customize/deep-dives/codebase.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/customize/deep-dives/codebase.mdx b/docs/docs/customize/deep-dives/codebase.mdx index 24256672e..409ecd080 100644 --- a/docs/docs/customize/deep-dives/codebase.mdx +++ b/docs/docs/customize/deep-dives/codebase.mdx @@ -49,8 +49,8 @@ There are a few options that let you configure the behavior of the `@codebase` c context: - provider: codebase params: - nRetrieve: 25, - nFinal: 5, + nRetrieve: 25 + nFinal: 5 useReranking: true ``` From 892f89e0e23f9ef1cac2eef40d82c25ba8abc153 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 3 Mar 2025 16:08:15 -0800 Subject: [PATCH 034/171] use URI.resolve --- core/util/uri.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/core/util/uri.ts b/core/util/uri.ts index 13d7956ac..a5a84d3b4 100644 --- a/core/util/uri.ts +++ b/core/util/uri.ts @@ -116,19 +116,30 @@ export function getLastNUriRelativePathParts( } export function joinPathsToUri(uri: string, ...pathSegments: string[]) { - const components = URI.parse(uri); + let baseUri = uri; + if (baseUri.at(-1) !== "/") { + baseUri += "/"; + } const segments = pathSegments.map((segment) => pathToUriPathSegment(segment)); - components.path = `${components.path}/${segments.join("/")}`; - return URI.serialize(components); + return URI.resolve(baseUri, segments.join("/")); } +// const components = URI.parse(uri); +// return URI.serialize(components); +// components.path = `${components.path}/${segments.join("/")}`; + export function joinEncodedUriPathSegmentToUri( uri: string, pathSegment: string, ) { - const components = URI.parse(uri); - components.path = `${components.path}/${pathSegment}`; - return URI.serialize(components); + let baseUri = uri; + if (baseUri.at(-1) !== "/") { + baseUri += "/"; + } + return URI.resolve(baseUri, pathSegment); + // const components = URI.parse(uri); + // components.path = `${components.path}/${pathSegment}`; + // return URI.serialize(components); } export function getShortestUniqueRelativeUriPaths( From a8d9a312a6efb935edca0de7cd8e77fb6d9a2660 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 3 Mar 2025 16:12:30 -0800 Subject: [PATCH 035/171] cleanup --- core/util/uri.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/core/util/uri.ts b/core/util/uri.ts index a5a84d3b4..e180a0a69 100644 --- a/core/util/uri.ts +++ b/core/util/uri.ts @@ -124,10 +124,6 @@ export function joinPathsToUri(uri: string, ...pathSegments: string[]) { return URI.resolve(baseUri, segments.join("/")); } -// const components = URI.parse(uri); -// return URI.serialize(components); -// components.path = `${components.path}/${segments.join("/")}`; - export function joinEncodedUriPathSegmentToUri( uri: string, pathSegment: string, @@ -137,9 +133,6 @@ export function joinEncodedUriPathSegmentToUri( baseUri += "/"; } return URI.resolve(baseUri, pathSegment); - // const components = URI.parse(uri); - // components.path = `${components.path}/${pathSegment}`; - // return URI.serialize(components); } export function getShortestUniqueRelativeUriPaths( From 19c8da156f75c01bb587814d1d197f509a7fcaba Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 4 Mar 2025 09:55:11 -0800 Subject: [PATCH 036/171] yaml model capabilities --- core/config/yaml/models.ts | 20 +++++++++++++++++++- packages/config-yaml/src/schemas/models.ts | 9 +++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index c6916b010..a0dccd46a 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -35,8 +35,10 @@ async function modelConfigToBaseLLM( return undefined; } + const { capabilities, ...rest } = model; + let options: LLMOptions = { - ...model, + ...rest, completionOptions: { ...(model.defaultCompletionOptions ?? {}), model: model.model, @@ -51,6 +53,22 @@ async function modelConfigToBaseLLM( promptTemplates: model.promptTemplates, }; + // Model capabilities - need to be undefined if not found + // To fallback to our autodetection + if (capabilities?.find((c) => c === "tool_use")) { + options.capabilities = { + ...options.capabilities, + tools: true, + }; + } + + if (capabilities?.find((c) => c === "image_input")) { + options.capabilities = { + ...options.capabilities, + uploadImage: true, + }; + } + if (model.embedOptions?.maxBatchSize) { options.maxEmbeddingBatchSize = model.embedOptions.maxBatchSize; } diff --git a/packages/config-yaml/src/schemas/models.ts b/packages/config-yaml/src/schemas/models.ts index 1fd6247a6..ff3f6bec3 100644 --- a/packages/config-yaml/src/schemas/models.ts +++ b/packages/config-yaml/src/schemas/models.ts @@ -31,6 +31,14 @@ export const modelRolesSchema = z.enum([ ]); export type ModelRole = z.infer; +// TODO consider just using array of strings for model capabilities +// To allow more dynamic string parsing +export const modelCapabilitySchema = z.union([ + z.literal("tool_use"), + z.literal("image_input"), +]); +export type ModelCapability = z.infer; + export const completionOptionsSchema = z.object({ contextLength: z.number().optional(), maxTokens: z.number().optional(), @@ -61,6 +69,7 @@ const baseModelFields = { apiKey: z.string().optional(), apiBase: z.string().optional(), roles: modelRolesSchema.array().optional(), + capabilities: modelCapabilitySchema.array().optional(), defaultCompletionOptions: completionOptionsSchema.optional(), requestOptions: requestOptionsSchema.optional(), embedOptions: embedOptionsSchema.optional(), From 84066e35f3b5ac7515aee64af63a977f09432b8e Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 4 Mar 2025 09:59:30 -0800 Subject: [PATCH 037/171] yaml example --- docs/docs/yaml-reference.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/docs/yaml-reference.md b/docs/docs/yaml-reference.md index 9de133cd7..5a4263ef3 100644 --- a/docs/docs/yaml-reference.md +++ b/docs/docs/yaml-reference.md @@ -134,6 +134,7 @@ The `models` section defines the language models used in your configuration. Mod - `provider` (**required**): The provider of the model (e.g., `openai`, `ollama`). - `model` (**required**): The specific model name (e.g., `gpt-4`, `starcoder`). - `roles`: An array specifying the roles this model can fulfill, such as `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`. The default value is `[chat, edit, apply, summarize]`. Note that the `summarize` role is not currently used. +- `capabilities`: Array of strings denoting model capabilities, which will overwrite Continue's autodetection based on provider and model. Supported capabilities include `tool_use` and `image_input`. - `embedOptions`: If the model includes role `embed`, these settings apply for embeddings: - `maxChunkSize`: Maximum tokens per document chunk. Minimum is 128 tokens. @@ -187,6 +188,17 @@ models: model: codestral-latest roles: - autocomplete + + - name: My Model - OpenAI-Compatible + provider: openai + apiBase: http://my-endpoint/v1 + model: my-custom-model + capabilities: + - tool_use + - image_input + roles: + - chat + - edit ``` --- From c707feb5bd787d1feb54e8b2ac9cfc68985fdac0 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 4 Mar 2025 11:11:27 -0800 Subject: [PATCH 038/171] bump and release new config yaml version --- packages/config-yaml/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index 9433fbc30..9163700c4 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.52", + "version": "1.0.53", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From 93193606654d001ff0d98b1c40677ff8aa6a4d88 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 4 Mar 2025 14:06:07 -0800 Subject: [PATCH 039/171] blocktype param --- docs/docs/customize/deep-dives/development-data.md | 2 +- docs/docs/customize/deep-dives/docs.mdx | 2 +- docs/docs/customize/deep-dives/prompt-files.md | 2 +- docs/docs/customize/deep-dives/rules.md | 2 +- docs/docs/customize/tools.mdx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/customize/deep-dives/development-data.md b/docs/docs/customize/deep-dives/development-data.md index 976c02833..da9f5136c 100644 --- a/docs/docs/customize/deep-dives/development-data.md +++ b/docs/docs/customize/deep-dives/development-data.md @@ -14,7 +14,7 @@ You can read more about how development data is generated as a byproduct of LLM- You can also configure custom destinations for your data, including remote HTTP endpoints and local file directories. -For hub assistants, data destinations are configured in `data` blocks. Visit the hub to [explore example data blocks](https://hub.continue.dev/explore/data) or [create your own](https://hub.continue.dev/new?type=block&block=data). +For hub assistants, data destinations are configured in `data` blocks. Visit the hub to [explore example data blocks](https://hub.continue.dev/explore/data) or [create your own](https://hub.continue.dev/new?type=block&blockType=data). See more details about adding `data` blocks to your configuration files in the [YAML specification](../../yaml-reference.md#data) diff --git a/docs/docs/customize/deep-dives/docs.mdx b/docs/docs/customize/deep-dives/docs.mdx index 7a5be2263..4a2aac376 100644 --- a/docs/docs/customize/deep-dives/docs.mdx +++ b/docs/docs/customize/deep-dives/docs.mdx @@ -64,7 +64,7 @@ Pre-indexed docs are only available in VS Code because the VS Code extension shi ### Hub `docs` Blocks -@Docs uses [`docs` blocks](../../hub/blocks/block-types.md#docs) in Assistants from the hub. Visit the hub to [explore `docs` blocks](https://hub.continue.dev/explore/docs) or [create your own](https://hub.continue.dev/new?type=block&block=docs). +@Docs uses [`docs` blocks](../../hub/blocks/block-types.md#docs) in Assistants from the hub. Visit the hub to [explore `docs` blocks](https://hub.continue.dev/explore/docs) or [create your own](https://hub.continue.dev/new?type=block&blockType=docs). ### Through the `@Docs` Context Provider diff --git a/docs/docs/customize/deep-dives/prompt-files.md b/docs/docs/customize/deep-dives/prompt-files.md index 1ab90e94a..f5c834c17 100644 --- a/docs/docs/customize/deep-dives/prompt-files.md +++ b/docs/docs/customize/deep-dives/prompt-files.md @@ -4,7 +4,7 @@ title: Prompt files Prompt files provide a convenient way to standardize common patterns and share a collection of LLM prompts with your team. They make it easy to build and use these prompts. -On the [hub](../../hub/introduction.md), prompt files are stored within [prompt blocks](../../hub/blocks/block-types.md#prompts), which show up as [slash commands](../slash-commands.mdx) in Chat. Visit the hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&block=rules). +On the [hub](../../hub/introduction.md), prompt files are stored within [prompt blocks](../../hub/blocks/block-types.md#prompts), which show up as [slash commands](../slash-commands.mdx) in Chat. Visit the hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=rules). Prompt files can also be stored within your project's root directory as `.prompt` files. See below. diff --git a/docs/docs/customize/deep-dives/rules.md b/docs/docs/customize/deep-dives/rules.md index eac9137ce..59f816c15 100644 --- a/docs/docs/customize/deep-dives/rules.md +++ b/docs/docs/customize/deep-dives/rules.md @@ -9,7 +9,7 @@ Rules are used to provide instructions to **chat** models. They are inserted int ## Hub `rules` blocks -Rules can be added to an Assistant on the Continue Hub. Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&block=rules) in the Hub. +Rules can be added to an Assistant on the Continue Hub. Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub. ## `.continuerules` diff --git a/docs/docs/customize/tools.mdx b/docs/docs/customize/tools.mdx index 45280697e..1aad549f1 100644 --- a/docs/docs/customize/tools.mdx +++ b/docs/docs/customize/tools.mdx @@ -30,7 +30,7 @@ Currently custom tools can be configured using the [Model Context Protocol](http MCP Servers can be added to hub Assistants using `mcpServers` blocks. You can explore available MCP server blocks [here](https://hub.continue.dev/explore/mcp). -To set up your own MCP server, read the [MCP quickstart](https://modelcontextprotocol.io/quickstart) and then [create an `mcpServers` block](https://hub.continue.dev/new?type=block&block=mcpServers) or add the following to your [config file](../customize/deep-dives/configuration.md): +To set up your own MCP server, read the [MCP quickstart](https://modelcontextprotocol.io/quickstart) and then [create an `mcpServers` block](https://hub.continue.dev/new?type=block&blockType=mcpServers) or add the following to your [config file](../customize/deep-dives/configuration.md): From 9404e00e91aed089cd3a8cd344a138af95f83740 Mon Sep 17 00:00:00 2001 From: Piotr Czekaj Date: Wed, 5 Mar 2025 11:47:53 +0100 Subject: [PATCH 040/171] Fix invalid mime type in Jetbrains IDE connection.url.toString() contains values like: jar:file:/Users/some.username/Library/Application%20Support/JetBrains/IntelliJIdea2024.3/plugins/continue-intellij-extension/lib/instrumented-continue-intellij-extension-1.0.2.jar!/webview/index.html if user has "js" in his home folder name then index.html will be treated as text/javascript and continue dev sidebar will output html source code instead of working app --- .../factories/CustomhandlerFactory.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/factories/CustomhandlerFactory.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/factories/CustomhandlerFactory.kt index 1c683253d..489ef9006 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/factories/CustomhandlerFactory.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/factories/CustomhandlerFactory.kt @@ -111,7 +111,10 @@ class OpenedConnection(private val connection: URLConnection?) : ) { try { if (connection != null) { - val url = connection.url.toString() + val fullUrl = connection.url.toString() + // Extract only the resource path after the JAR prefix to prevent incorrect mime type matching + // (e.g., if a user's home folder contains "js" in the path) + val url = fullUrl.substringAfterLast("jar!/", fullUrl) when { url.contains("css") -> cefResponse.mimeType = "text/css" url.contains("js") -> cefResponse.mimeType = "text/javascript" From 85804ff9e54adf30f1a4b23b3003b39338a82065 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 5 Mar 2025 13:13:30 -0800 Subject: [PATCH 041/171] feat: smaller headings, use assistant name --- extensions/vscode/package-lock.json | 4 +- gui/src/components/PageHeader.tsx | 10 +- .../markdown/StyledMarkdownPreview.tsx | 24 +++ .../platform/AssistantSelect.tsx | 9 +- .../platform/AssistantSelectOptions.tsx | 9 +- .../modelSelection/platform/utils.ts | 6 - gui/src/pages/More/More.tsx | 2 +- gui/src/pages/config/index.tsx | 182 ++++++++++-------- gui/src/pages/history/index.tsx | 2 +- 9 files changed, 141 insertions(+), 107 deletions(-) delete mode 100644 gui/src/components/modelSelection/platform/utils.ts diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index cbcebc34e..ed46978a0 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.3", + "version": "1.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.3", + "version": "1.1.4", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/PageHeader.tsx b/gui/src/components/PageHeader.tsx index 22755926e..bc759df2b 100644 --- a/gui/src/components/PageHeader.tsx +++ b/gui/src/components/PageHeader.tsx @@ -4,15 +4,23 @@ export interface PageHeaderProps { onTitleClick?: () => void; title?: string; rightContent?: React.ReactNode; + showBorder?: boolean; // Added this prop } export default function PageHeader({ onTitleClick, title, rightContent, + showBorder, }: PageHeaderProps) { return ( -
+
{title && (
` + h1 { + font-size: 1.25em; + } + + h2 { + font-size: 1.15em; + } + + h3 { + font-size: 1.05em; + } + + h4 { + font-size: 1em; + } + + h5 { + font-size: 0.95em; + } + + h6 { + font-size: 0.9em; + } + pre { white-space: ${(props) => props.whiteSpace}; background-color: ${vscEditorBackground}; diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 629f0fe14..a4dde488d 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -10,7 +10,6 @@ import { getFontSize, isMetaEquivalentKeyPressed } from "../../../util"; import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition"; import AssistantIcon from "./AssistantIcon"; import { AssistantSelectOptions } from "./AssistantSelectOptions"; -import { getProfileDisplayText } from "./utils"; function AssistantSelectButton(props: { selectedProfile: ProfileDescription }) { return ( @@ -18,9 +17,7 @@ function AssistantSelectButton(props: { selectedProfile: ProfileDescription }) {
- - {getProfileDisplayText(props.selectedProfile)} - + {props.selectedProfile.title}
); @@ -29,7 +26,7 @@ function AssistantSelectButton(props: { selectedProfile: ProfileDescription }) { export default function AssistantSelect() { const dispatch = useAppDispatch(); const buttonRef = useRef(null); - const { selectedProfile, selectedOrganization, profiles } = useAuth(); + const { selectedProfile, selectedOrganization } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); useEffect(() => { @@ -87,7 +84,7 @@ export default function AssistantSelect() { - + { if (buttonRef.current) { diff --git a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx index c0b7e6071..cd8d5cd5c 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx @@ -11,7 +11,6 @@ import { getFontSize, getMetaKeyLabel, isLocalProfile } from "../../../util"; import { ROUTES } from "../../../util/navigation"; import AssistantIcon from "./AssistantIcon"; import { Divider, Option, OptionDiv } from "./shared"; -import { getProfileDisplayText } from "./utils"; interface AssistantSelectOptionsProps { onClose: () => void; @@ -49,8 +48,8 @@ export function AssistantSelectOptions({ } return ( -
-
+
+
{profiles.map((profile, idx) => { return (