diff --git a/core/edit/streamDiffLines.ts b/core/edit/streamDiffLines.ts index 4cba92608..ff1585520 100644 --- a/core/edit/streamDiffLines.ts +++ b/core/edit/streamDiffLines.ts @@ -122,6 +122,7 @@ export async function* streamDiffLines({ (msg) => msg.role === "user" || msg.role === "tool", ) as UserChatMessage | ToolResultChatMessage | undefined), baseSystemMessage: undefined, + contextItems: [], }) : undefined; diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index 309429d4b..5358deee5 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -1,6 +1,7 @@ import { ChatHistoryItem, ChatMessage, + ContextItemWithId, RuleWithSource, TextMessagePart, ToolResultChatMessage, @@ -58,7 +59,7 @@ const EDIT_MESSAGE = `\ at the beginning, middle, or end of files using these "lazy" comments. Only provide the complete file when explicitly requested. Include a concise explanation of changes unless the user specifically asks for code only. -` +`; export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\ @@ -77,6 +78,31 @@ export const DEFAULT_AGENT_SYSTEM_MESSAGE = `\ ${EDIT_MESSAGE} `; +/** + * Helper function to get the context items for a user message + */ +function getUserContextItems( + userMsg: UserChatMessage | ToolResultChatMessage | undefined, + history: ChatHistoryItem[], +): ContextItemWithId[] { + if (!userMsg) return []; + + // Find the history item that contains the userMsg + const historyItem = history.find((item) => { + // Check if the message ID matches + if ("id" in userMsg && "id" in item.message) { + return (item.message as any).id === (userMsg as any).id; + } + // Fallback to content comparison + return ( + item.message.content === userMsg.content && + item.message.role === userMsg.role + ); + }); + + return historyItem?.contextItems || []; +} + export function constructMessages( messageMode: string, history: ChatHistoryItem[], @@ -92,7 +118,8 @@ export function constructMessages( const historyItem = filteredHistory[i]; if (messageMode === "chat") { - const toolMessage: ToolResultChatMessage = historyItem.message as ToolResultChatMessage; + const toolMessage: ToolResultChatMessage = + historyItem.message as ToolResultChatMessage; if (historyItem.toolCallState?.toolCallId || toolMessage.toolCallId) { // remove all tool calls from the history continue; @@ -127,10 +154,16 @@ export function constructMessages( | ToolResultChatMessage | undefined; + // Get context items for the last user message + const lastUserContextItems = getUserContextItems( + lastUserMsg, + filteredHistory, + ); const systemMessage = getSystemMessageWithRules({ baseSystemMessage: baseChatOrAgentSystemMessage, rules, userMessage: lastUserMsg, + contextItems: lastUserContextItems, }); if (systemMessage.trim()) { diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index 7ca0f801c..3b44e1f61 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -306,7 +306,7 @@ class Bedrock extends BaseLLM { } const supportsTools = - PROVIDER_TOOL_SUPPORT.bedrock?.(options.model || "") ?? false; + (this.capabilities?.tools || PROVIDER_TOOL_SUPPORT.bedrock?.(options.model)) ?? false; let toolConfig = supportsTools && options.tools ? { diff --git a/core/llm/rules/getSystemMessageWithRules.test.ts b/core/llm/rules/getSystemMessageWithRules.test.ts index c1a7765ee..8f576247c 100644 --- a/core/llm/rules/getSystemMessageWithRules.test.ts +++ b/core/llm/rules/getSystemMessageWithRules.test.ts @@ -1,4 +1,4 @@ -import { RuleWithSource, UserChatMessage } from "../.."; +import { ContextItemWithId, RuleWithSource, UserChatMessage } from "../.."; import { getSystemMessageWithRules } from "./getSystemMessageWithRules"; describe("getSystemMessageWithRules", () => { @@ -25,11 +25,48 @@ describe("getSystemMessageWithRules", () => { source: "rules-block", }; + // JavaScript rule + const jsRule: RuleWithSource = { + name: "JavaScript Rule", + rule: "Follow JavaScript best practices", + globs: "**/*.js", + source: "rules-block", + }; + + // Empty context items + const emptyContextItems: ContextItemWithId[] = []; + + // Context items with file paths + const tsContextItem: ContextItemWithId = { + content: "TypeScript file content", + name: "Component.tsx", + description: "A TypeScript component", + id: { providerTitle: "file", itemId: "src/Component.tsx" }, + uri: { type: "file", value: "src/Component.tsx" }, + }; + + const pyContextItem: ContextItemWithId = { + content: "Python file content", + name: "utils.py", + description: "A Python utility file", + id: { providerTitle: "file", itemId: "utils.py" }, + uri: { type: "file", value: "utils.py" }, + }; + + const jsContextItem: ContextItemWithId = { + content: "JavaScript file content", + name: "utils.js", + description: "A JavaScript utility file", + id: { providerTitle: "file", itemId: "src/utils.js" }, + uri: { type: "file", value: "src/utils.js" }, + }; + it("should not include pattern-matched rules when no file paths are mentioned", () => { const result = getSystemMessageWithRules({ baseSystemMessage, userMessage: undefined, rules: [tsRule], + contextItems: emptyContextItems, }); expect(result).toBe(baseSystemMessage); @@ -40,12 +77,13 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage: undefined, rules: [generalRule], + contextItems: emptyContextItems, }); expect(result).toBe(`${baseSystemMessage}\n\n${generalRule.rule}`); }); - it("should include only matching rules based on file paths", () => { + it("should include only matching rules based on file paths in message", () => { const userMessage: UserChatMessage = { role: "user", content: @@ -56,6 +94,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [tsRule, pythonRule, generalRule], + contextItems: emptyContextItems, }); // Should include TS rule and general rule, but not Python rule @@ -63,7 +102,38 @@ describe("getSystemMessageWithRules", () => { expect(result).toBe(expected); }); - it("should include multiple matching rules", () => { + it("should include matching rules based on file paths in context items", () => { + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [tsRule, pythonRule, generalRule], + contextItems: [tsContextItem], + }); + + // Should include TS rule and general rule, but not Python rule + const expected = `${baseSystemMessage}\n\n${tsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + it("should include matching rules from both message and context items", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```python test.py\nprint('hello')\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [tsRule, pythonRule, generalRule], + contextItems: [tsContextItem], + }); + + // Should include TS rule, Python rule, and general rule + const expected = `${baseSystemMessage}\n\n${tsRule.rule}\n\n${pythonRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + it("should include multiple matching rules from message", () => { const userMessage: UserChatMessage = { role: "user", content: @@ -74,6 +144,20 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [tsRule, pythonRule, generalRule], + contextItems: emptyContextItems, + }); + + // Should include all rules + const expected = `${baseSystemMessage}\n\n${tsRule.rule}\n\n${pythonRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + it("should include multiple matching rules from context items", () => { + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [tsRule, pythonRule, generalRule], + contextItems: [tsContextItem, pyContextItem], }); // Should include all rules @@ -91,6 +175,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [tsRule, pythonRule, generalRule], + contextItems: emptyContextItems, }); // Should only include the general rule @@ -117,6 +202,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [commaRule], + contextItems: emptyContextItems, }); // With the current implementation, the comma-separated pattern is treated as a single string, @@ -143,6 +229,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [arrayGlobRule], + contextItems: emptyContextItems, }); // With our new implementation, the array of patterns should match both src/main.ts and tests/example.test.ts @@ -168,6 +255,7 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [arrayGlobRule], + contextItems: emptyContextItems, }); // Should match src/main.ts but not config/settings.ts @@ -193,9 +281,125 @@ describe("getSystemMessageWithRules", () => { baseSystemMessage, userMessage, rules: [arrayGlobRule], + contextItems: emptyContextItems, }); // Should not match any file paths expect(result).toBe(baseSystemMessage); }); + + // New test for code block with filename only (no language) + it("should handle code blocks with filename only (no language identifier)", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```test.js\nclass Calculator { /* code */ }\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [jsRule, tsRule, generalRule], + contextItems: emptyContextItems, + }); + + // Should include JS rule and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // New test for code blocks with line ranges + it("should handle code blocks with line ranges", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```js test.js (19-25)\ndivide(number) { /* code */ }\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [jsRule, tsRule, generalRule], + contextItems: emptyContextItems, + }); + + // Should include JS rule and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // New test for mixed code block formats + it("should handle mixed code block formats in the same message", () => { + const userMessage: UserChatMessage = { + role: "user", + content: + "```test.js\nclass Calculator { /* code */ }\n```\n" + + "```js utils.js (19-25)\ndivide(number) { /* code */ }\n```\n" + + "```ts config/settings.ts\nconst config = {};\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [jsRule, tsRule, generalRule], + contextItems: emptyContextItems, + }); + + // Should include JS rule, TS rule, and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${tsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // Test for context items when there's no message + it("should apply rules based on context items only when no message is present", () => { + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [jsRule, tsRule, generalRule], + contextItems: [jsContextItem], + }); + + // Should include JS rule and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // Test for non-file context items + it("should ignore non-file context items", () => { + const nonFileContextItem: ContextItemWithId = { + content: "Some search result", + name: "Search result", + description: "A search result", + id: { providerTitle: "search", itemId: "search-result" }, + // No uri with type "file" + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [jsRule, tsRule, generalRule], + contextItems: [nonFileContextItem], + }); + + // Should only include general rule + const expected = `${baseSystemMessage}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + // Test combining context items with message + it("should match rules from both message code blocks and context items", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```ts src/main.ts\nconsole.log('hello');\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [jsRule, tsRule, pythonRule, generalRule], + contextItems: [jsContextItem, pyContextItem], + }); + + // Should include JS, TS, Python rules and general rule + const expected = `${baseSystemMessage}\n\n${jsRule.rule}\n\n${tsRule.rule}\n\n${pythonRule.rule}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); }); diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 3d7372fef..19870a6da 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -1,5 +1,10 @@ import { minimatch } from "minimatch"; -import { RuleWithSource, ToolResultChatMessage, UserChatMessage } from "../.."; +import { + ContextItemWithId, + RuleWithSource, + ToolResultChatMessage, + UserChatMessage, +} from "../.."; import { renderChatMessage } from "../../util/messageContent"; import { extractPathsFromCodeBlocks } from "../utils/extractPathsFromCodeBlocks"; @@ -24,21 +29,34 @@ const matchesGlobs = ( }; /** - * Filters rules that apply to the given message + * Filters rules that apply to the given message and/or context items + * + * @param userMessage - The user or tool message to check for file paths in code blocks + * @param rules - The list of rules to filter + * @param contextItems - Context items to check for file paths + * @returns List of applicable rules */ export const getApplicableRules = ( userMessage: UserChatMessage | ToolResultChatMessage | undefined, rules: RuleWithSource[], + contextItems: ContextItemWithId[], ): RuleWithSource[] => { const filePathsFromMessage = userMessage ? extractPathsFromCodeBlocks(renderChatMessage(userMessage)) : []; + // Extract file paths from context items + const filePathsFromContextItems = contextItems + .filter((item) => item.uri?.type === "file" && item.uri?.value) + .map((item) => item.uri!.value); + // Combine file paths from both sources + const allFilePaths = [...filePathsFromMessage, ...filePathsFromContextItems]; + return rules.filter((rule) => { // A rule is active if it has no globs (applies to all files) // or if at least one file path matches its globs const hasNoGlobs = !rule.globs; - const matchesAnyFilePath = filePathsFromMessage.some((path) => + const matchesAnyFilePath = allFilePaths.some((path) => matchesGlobs(path, rule.globs), ); @@ -46,16 +64,27 @@ export const getApplicableRules = ( }); }; +/** + * Creates a system message string with applicable rules appended + * + * @param baseSystemMessage - The base system message to start with + * @param userMessage - The user message to check for file paths + * @param rules - The list of rules to filter + * @param contextItems - Context items to check for file paths + * @returns System message with applicable rules appended + */ export const getSystemMessageWithRules = ({ baseSystemMessage, userMessage, rules, + contextItems, }: { baseSystemMessage?: string; userMessage: UserChatMessage | ToolResultChatMessage | undefined; rules: RuleWithSource[]; + contextItems: ContextItemWithId[]; }) => { - const applicableRules = getApplicableRules(userMessage, rules); + const applicableRules = getApplicableRules(userMessage, rules, contextItems); let systemMessage = baseSystemMessage ?? ""; for (const rule of applicableRules) { diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index cd14586bb..f08e3cf8a 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -17,6 +17,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< "claude-3.5", "claude-3-7", "claude-3.7", + "claude-sonnet-4", "gpt-4", "o3", "gemini", @@ -24,7 +25,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< }, anthropic: (model) => { if ( - ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) => + ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7","claude-sonnet-4"].some((part) => model.toLowerCase().startsWith(part), ) ) { @@ -76,7 +77,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< // For Bedrock, only support Claude Sonnet models with versions 3.5/3-5 and 3.7/3-7 if ( model.toLowerCase().includes("sonnet") && - ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) => + ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7","claude-sonnet-4"].some((part) => model.toLowerCase().includes(part), ) ) { diff --git a/core/llm/utils/extractPathsFromCodeBlocks.test.ts b/core/llm/utils/extractPathsFromCodeBlocks.test.ts new file mode 100644 index 000000000..93959a392 --- /dev/null +++ b/core/llm/utils/extractPathsFromCodeBlocks.test.ts @@ -0,0 +1,35 @@ +import { extractPathsFromCodeBlocks } from "./extractPathsFromCodeBlocks"; + +describe("extractPathsFromCodeBlocks", () => { + it("should extract paths from code blocks with language and filepath", () => { + const content = "```typescript src/main.ts\nconst x = 1;\n```"; + expect(extractPathsFromCodeBlocks(content)).toEqual(["src/main.ts"]); + }); + + it("should extract paths from code blocks with filepath only (no language)", () => { + const content = "```test.js\nclass Calculator { }\n```"; + expect(extractPathsFromCodeBlocks(content)).toEqual(["test.js"]); + }); + + it("should extract paths from code blocks with line ranges", () => { + const content = "```js test.js (19-25)\nfunction test() {}\n```"; + expect(extractPathsFromCodeBlocks(content)).toEqual(["test.js"]); + }); + + it("should handle multiple code blocks with different formats", () => { + const content = + "```typescript src/main.ts\nconst x = 1;\n```\n" + + "```test.js\nclass Calculator { }\n```\n" + + "```js utils.js (19-25)\nfunction test() {}\n```"; + const result = extractPathsFromCodeBlocks(content); + expect(result).toContain("src/main.ts"); + expect(result).toContain("test.js"); + expect(result).toContain("utils.js"); + expect(result.length).toBe(3); + }); + + it("should not extract paths from code blocks without file paths", () => { + const content = "```typescript\nconst x = 1;\n```"; + expect(extractPathsFromCodeBlocks(content)).toEqual([]); + }); +}); \ No newline at end of file diff --git a/core/llm/utils/extractPathsFromCodeBlocks.ts b/core/llm/utils/extractPathsFromCodeBlocks.ts index 7573a1f6f..00f723c7a 100644 --- a/core/llm/utils/extractPathsFromCodeBlocks.ts +++ b/core/llm/utils/extractPathsFromCodeBlocks.ts @@ -2,21 +2,37 @@ * Extracts file paths from markdown code blocks */ export function extractPathsFromCodeBlocks(content: string): string[] { - // Match: - // 1. Starting ``` - // 2. Optional language identifier - // 3. Required whitespace - // 4. File path (captured) that must contain a dot and extension - const codeBlockRegex = /```(?:[\w-+#]+)?\s+([^\s\n()]+\.[a-zA-Z0-9]+)/g; - const paths: string[] = []; - let match; + console.log("CONTENT", content); - while ((match = codeBlockRegex.exec(content)) !== null) { - const path = match[1]; - if (path && !path.startsWith("```")) { - paths.push(path); + const paths: string[] = []; + + // Match code block opening patterns: + // 1. ```language filepath + // 2. ```filepath + // 3. ```language filepath (range) + + // First match all code block starts + const codeBlockStarts = content.match(/```[^\n]+/g) || []; + + for (const blockStart of codeBlockStarts) { + // Try to extract a valid filename with extension + const filenameMatches = blockStart.match(/([^\s()```]+\.[a-zA-Z0-9]+)/); + + if (filenameMatches && filenameMatches[1]) { + const filename = filenameMatches[1]; + + // Verify this is a legitimate filename (not part of something else) + if ( + // Check if valid extension + /\.[a-zA-Z0-9]+$/.test(filename) && + // Make sure it's not a URL + !filename.includes("://") && + // Avoid duplicates + !paths.includes(filename) + ) { + paths.push(filename); + } } } - return paths; } diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 267216d58..540f8a7e3 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -2,12 +2,12 @@ import { ToIdeFromWebviewOrCoreProtocol } from "./ide"; import { ToWebviewFromIdeOrCoreProtocol } from "./webview"; import { + AcceptOrRejectDiffPayload, ApplyState, - SetCodeToEditPayload, HighlightedCodePayload, MessageContent, RangeInFileWithContents, - AcceptOrRejectDiffPayload, + SetCodeToEditPayload, ShowFilePayload, } from "../"; @@ -42,7 +42,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { vscMediaUrl: string; }, ]; - "jetbrains/getColors": [undefined, Record]; + "jetbrains/getColors": [undefined, Record]; "vscode/openMoveRightMarkdown": [undefined, void]; setGitHubAuthToken: [{ token: string }, void]; acceptDiff: [AcceptOrRejectDiffPayload, void]; diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index 534517d6f..5ba47e3d4 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -40,7 +40,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { setTTSActive: [boolean, void]; getWebviewHistoryLength: [undefined, number]; getCurrentSessionId: [undefined, string]; - "jetbrains/setColors": [Record, void]; + "jetbrains/setColors": [Record, void]; sessionUpdate: [{ sessionInfo: ControlPlaneSessionInfo | undefined }, void]; toolCallPartialOutput: [{ toolCallId: string; contextItems: any[] }, void]; }; diff --git a/docs/docs/reference.md b/docs/docs/reference.md index e8b915813..7773afbfc 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -406,7 +406,7 @@ Destinations to which [development data](./customize/deep-dives/development-data - `destination` (**required**): The destination/endpoint that will receive the data. Can be: - an HTTP endpoint that will receive a POST request with a JSON blob - a file URL to a directory in which events will be dumpted to `.jsonl` files -- `schema` (**required**): the schema version of the JSON blobs to be sent +- `schema` (**required**): the schema version of the JSON blobs to be sent. Options include `0.1.0` and `0.2.0` - `events`: an array of event names to include. Defaults to all events if not specified. - `level`: a pre-defined filter for event fields. Options include `all` and `noCode`; the latter excludes data like file contents, prompts, and completions. Defaults to `all` diff --git a/docs/docs/troubleshooting.mdx b/docs/docs/troubleshooting.mdx index 9692191eb..405417a27 100644 --- a/docs/docs/troubleshooting.mdx +++ b/docs/docs/troubleshooting.mdx @@ -120,6 +120,8 @@ If you're seeing a `fetch failed` error and your network requires custom certifi You may also set `requestOptions.caBundlePath` to an array of paths to multiple certificates. +***Windows VS Code Users***: Installing the [win-ca](https://marketplace.visualstudio.com/items?itemName=ukoloff.win-ca) extension should also correct this issue. + #### VS Code Proxy Settings If you are using VS Code and require requests to be made through a proxy, you are likely already set up through VS Code's [Proxy Server Support](https://code.visualstudio.com/docs/setup/network#_proxy-server-support). To double-check that this is enabled, use cmd/ctrl + , to open settings and search for "Proxy Support". Unless it is set to "off", then VS Code is responsible for making the request to the proxy. diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index 6aecca81b..357757fe0 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -2,11 +2,13 @@ package com.github.continuedev.continueintellijextension.`continue` import com.intellij.openapi.editor.colors.EditorColors import com.intellij.openapi.editor.colors.EditorColorsManager +import com.intellij.openapi.editor.colors.CodeInsightColors import java.awt.Color import kotlin.math.max import kotlin.math.min import com.intellij.ui.JBColor import com.intellij.ui.ColorUtil +import kotlin.math.roundToInt class GetTheme { fun getSecondaryDark(): Color { @@ -38,64 +40,173 @@ class GetTheme { return globalScheme.getColor(EditorColors.MODIFIED_TAB_ICON_COLOR) ?: globalScheme.defaultForeground } - fun getTheme(): Map { - fun toHex(color: Color): String { - return String.format("#%02x%02x%02x", color.red, color.green, color.blue) + fun toHex(color: Color?): String? { + if(color == null) { + return null } + return String.format("#%02x%02x%02x", color.red, color.green, color.blue) + } + + fun namedColor(name: String): Color? { + // JB Color named color will fall back to a default unless we give it a fallback + // We want defaults to be handled on the GUI side, so we give it this filler color + // Which has a very low chance of conflicting with a real one + // And return undefined if it gets the skip color + val SKIP_COLOR = Color (18, 52, 86) // Hex #123456 + val color = JBColor.namedColor(name, SKIP_COLOR) + if(toHex(color) == "#123456") { + return null + } + return color + } + + fun lighten(color: Color, percentage: Int = 5): Color { + // Increase each RGB component slightly + val factor = 1 + percentage / 100f; + fun lightenInt(value: Int): Int { + return (value * factor).roundToInt().coerceAtMost(255) + } + return Color( + lightenInt(color.red), + lightenInt (color.green), + lightenInt(color.blue), + color.alpha + ) + } + + fun darken(color: Color, percentage: Int = 5): Color { + // Decrease each RGB component slightly + val factor = 1 - percentage / 100f; + fun darkenInt(value: Int): Int { + return (value * factor).roundToInt().coerceAtLeast(0) + } + return Color( + darkenInt(color.red), + darkenInt(color.green), + darkenInt(color.blue), + color.alpha + ) + } + + fun slightChange(color: Color?, percentage: Int = 5): Color? { + if(color == null){ + return null + } + // If dark, make slightly lighter. If light, make slightly darker + val averageRgb = (color.red + color.green + color.blue) / 3 + return if (averageRgb > 128) darken(color, percentage) else lighten(color, percentage) + } + + fun getTheme(): Map { try { + val editorScheme = EditorColorsManager.getInstance().globalScheme + val background = JBColor.background() val foreground = JBColor.foreground() - val buttonBackground = JBColor.namedColor("Button.background", Color(230, 230, 230)) - val buttonForeground = JBColor.namedColor("Button.foreground", Color(0, 0, 0)) - - val badgeBackground = JBColor.namedColor("Badge.background", Color(150, 150, 150)) - val badgeForeground = JBColor.namedColor("Badge.foreground", Color(0, 0, 0)) - - val inputBackground = JBColor.namedColor("TextField.background", Color(255, 255, 255)) - val border = JBColor.border() - val focusBorder = JBColor.namedColor("Focus.borderColor", Color(100, 100, 255)) - val editorScheme = EditorColorsManager.getInstance().globalScheme + val focusBorder = namedColor("Focus.borderColor") ?: namedColor("Component.focusedBorderColor") + + val buttonBackground = namedColor("Button.default.startBackground") + ?: namedColor("Button.default.background") + + val buttonForeground = namedColor("Button.default.startForeground") + ?: namedColor("Button.default.foreground") + + val buttonHoverBackground = namedColor("Button.default.hoverStartBackground") + ?: namedColor("Button.default.hoverBackground") + ?: namedColor("Button.default.startHoverBackground") + ?: slightChange(buttonBackground) + + val secondaryBackground = namedColor("Button.background") ?: background + val secondaryHoverBackground = namedColor("Button.hoverBackground") ?: slightChange(secondaryBackground) + + val badgeBackground = namedColor("Badge.background") + val badgeForeground = namedColor("Badge.foreground") + + val commandBackground = namedColor("CommandButton.background") ?: namedColor("ToolWindow.background") + val commandForeground = namedColor("CommandButton.foreground") ?: namedColor("ToolWindow.foreground") + + val inputBackground = namedColor("TextField.background") + val inputForeground = namedColor("TextField.foreground") + val inputPlaceholder = namedColor("TextField.inactiveForeground") + + val listHoverBackground = namedColor("List.hoverBackground") ?: slightChange(background) + val actionHoverBackground = namedColor("ActionButton.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") + + val tableOddRow = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") + val listSelectionForeground = namedColor("List.selectionForeground") + + val description = namedColor("Label.disabledForeground") ?: namedColor("Label.infoForeground") + + val mutedDescription = namedColor("Component.infoForeground") + ?: namedColor("ContextHelp.foreground") + ?: namedColor("TextField.placeholderForeground") + ?: namedColor("Label.disabledForeground") + ?: namedColor("ToolTip.foreground") + + val link = namedColor("Link.activeForeground") + + val successColor = namedColor("ValidationSuccess.successColor") + ?: namedColor("Component.successForeground") + ?: namedColor("Label.successForeground") + val warningColor = namedColor("ValidationWarning.warningColor") + ?: EditorColorsManager.getInstance().globalScheme.getAttributes(CodeInsightColors.WARNINGS_ATTRIBUTES)?.effectColor + ?: namedColor("Component.warningForeground") + ?: namedColor("Label.warningForeground") + val errorColor = namedColor("ValidationError.errorColor") ?: namedColor("Component.errorForeground") ?: namedColor("Label.errorForeground") + + val accentColor = namedColor("Focus.defaultButtonBorderColor") ?: namedColor("Button.default.focusedBorderColor") ?: namedColor("Button.focusedBorderColor") val editorBackground = editorScheme.defaultBackground val editorForeground = editorScheme.defaultForeground - val actionHoverBackground = JBColor.namedColor("ActionButton.hoverBackground", Color(220, 220, 220)) - - val findMatchBackground = editorScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)?.backgroundColor ?: Color(255, 221, 0) + val findMatchBackground = editorScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)?.backgroundColor + val findMatchSelectedBackground = namedColor("SearchMatch.selectedBackground") ?: + editorScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)?.backgroundColor + + // These should match the keys in GUI's theme.ts val theme = mapOf( - "--vscode-editor-foreground" to toHex(editorForeground), - "--vscode-editor-background" to toHex(editorBackground), - - "--vscode-button-background" to toHex(buttonBackground), - "--vscode-button-foreground" to toHex(buttonForeground), - - "--vscode-list-activeSelectionBackground" to toHex(actionHoverBackground) + "50", - - "--vscode-quickInputList-focusForeground" to toHex(foreground), - "--vscode-quickInput-background" to toHex(inputBackground), - - "--vscode-badge-background" to toHex(badgeBackground), - "--vscode-badge-foreground" to toHex(badgeForeground), - - "--vscode-input-background" to toHex(inputBackground), - "--vscode-input-border" to toHex(border), - "--vscode-sideBar-background" to toHex(background), - "--vscode-sideBar-border" to toHex(border), - "--vscode-focusBorder" to toHex(focusBorder), - - "--vscode-commandCenter-activeBorder" to toHex(focusBorder), - "--vscode-commandCenter-inactiveBorder" to toHex(border), - - "--vscode-editor-findMatchHighlightBackground" to toHex(findMatchBackground) + "40" - ) - + "background" to background, + "foreground" to foreground, + "editor-background" to editorBackground, + "editor-foreground" to editorForeground, + "primary-background" to buttonBackground, + "primary-foreground" to buttonForeground, + "primary-hover" to buttonHoverBackground, + "secondary-background" to secondaryBackground, + "secondary-foreground" to foreground, + "secondary-hover" to secondaryHoverBackground, + "border" to border, + "border-focus" to focusBorder, + "command-background" to commandBackground, + "command-foreground" to commandForeground, + "command-border" to border, + "command-border-focus" to focusBorder, + "description" to description, + "description-muted" to mutedDescription, + "input-background" to inputBackground, + "input-foreground" to inputForeground, + "input-border" to border, + "input-placeholder" to inputPlaceholder, + "table-oddRow" to tableOddRow, + "badge-background" to badgeBackground, + "badge-foreground" to badgeForeground, + "success" to successColor, + "warning" to warningColor, + "error" to errorColor, + "link" to link, + "accent" to accentColor, + "find-match" to findMatchBackground, + "find-match-selected" to findMatchSelectedBackground, + "list-hover" to listHoverBackground, + "list-active" to actionHoverBackground, + "list-active-foreground" to listSelectionForeground + ).mapValues { toHex(it.value) } return theme } catch (error: Error) { return mapOf() } - } } \ No newline at end of file diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 313cf7175..8c0ea0739 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -64,7 +64,7 @@ "devDependencies": { "@biomejs/biome": "1.6.4", "@nestjs/common": "^11.0.16", - "@openapitools/openapi-generator-cli": "^2.5.2", + "@openapitools/openapi-generator-cli": "^2.20.0", "@types/chai": "^5.0.1", "@types/cors": "^2.8.17", "@types/express": "^4.17.21", @@ -1444,14 +1444,28 @@ "resolved": "https://registry.npmjs.org/@neon-rs/load/-/load-0.0.74.tgz", "integrity": "sha512-/cPZD907UNz55yrc/ud4wDgQKtU1TvkD9jeqZWG6J4IMmZkp6zgjkQcKA8UvpkZlcpPHvc8J17sGzLFbP/LUYg==" }, + "node_modules/@nestjs/axios": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-4.0.0.tgz", + "integrity": "sha512-1cB+Jyltu/uUPNQrpUimRHEQHrnQrpLzVj6dU3dgn6iDDDdahr10TgHFGTmw5VuJ9GzKZsCLDL78VSwJAs/9JQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@nestjs/common": "^10.0.0 || ^11.0.0", + "axios": "^1.3.1", + "rxjs": "^7.0.0" + } + }, "node_modules/@nestjs/common": { - "version": "11.0.16", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.0.16.tgz", - "integrity": "sha512-agvuQ8su4aZ+PVxAmY89odG1eR97HEQvxPmTMdDqyvDWzNerl7WQhUEd+j4/UyNWcF1or1UVcrtPj52x+eUSsA==", + "version": "11.0.20", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.0.20.tgz", + "integrity": "sha512-/GH8NDCczjn6+6RNEtSNAts/nq/wQE8L1qZ9TRjqjNqEsZNE1vpFuRIhmcO2isQZ0xY5rySnpaRdrOAul3gQ3A==", "dev": true, "license": "MIT", "dependencies": { + "file-type": "20.4.1", "iterare": "1.2.1", + "load-esm": "1.0.2", "tslib": "2.8.1", "uid": "2.0.2" }, @@ -1462,7 +1476,6 @@ "peerDependencies": { "class-transformer": "*", "class-validator": "*", - "file-type": "^20.4.1", "reflect-metadata": "^0.1.12 || ^0.2.0", "rxjs": "^7.1.0" }, @@ -1475,6 +1488,58 @@ } } }, + "node_modules/@nestjs/core": { + "version": "11.0.20", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.0.20.tgz", + "integrity": "sha512-yUkEzBGiRNSEThVl6vMCXgoA9sDGWoRbJsTLdYdCC7lg7PE1iXBnna1FiBfQjT995pm0fjyM1e3WsXmyWeJXbw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "@nuxt/opencollective": "0.4.1", + "fast-safe-stringify": "2.1.1", + "iterare": "1.2.1", + "path-to-regexp": "8.2.0", + "tslib": "2.8.1", + "uid": "2.0.2" + }, + "engines": { + "node": ">= 20" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "@nestjs/common": "^11.0.0", + "@nestjs/microservices": "^11.0.0", + "@nestjs/platform-express": "^11.0.0", + "@nestjs/websockets": "^11.0.0", + "reflect-metadata": "^0.1.12 || ^0.2.0", + "rxjs": "^7.1.0" + }, + "peerDependenciesMeta": { + "@nestjs/microservices": { + "optional": true + }, + "@nestjs/platform-express": { + "optional": true + }, + "@nestjs/websockets": { + "optional": true + } + } + }, + "node_modules/@nestjs/core/node_modules/path-to-regexp": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", + "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1567,11 +1632,29 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@nuxt/opencollective": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@nuxt/opencollective/-/opencollective-0.4.1.tgz", + "integrity": "sha512-GXD3wy50qYbxCJ652bDrDzgMr3NFEkIS374+IgFQKkCvk9yiYcLvX2XDYr7UyQxf4wK0e+yqDYRubZ0DtOxnmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "consola": "^3.2.3" + }, + "bin": { + "opencollective": "bin/opencollective.js" + }, + "engines": { + "node": "^14.18.0 || >=16.10.0", + "npm": ">=5.10.0" + } + }, "node_modules/@nuxtjs/opencollective": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz", "integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.1.0", "consola": "^2.15.0", @@ -1585,11 +1668,19 @@ "npm": ">=5.0.0" } }, + "node_modules/@nuxtjs/opencollective/node_modules/consola": { + "version": "2.15.3", + "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", + "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==", + "dev": true, + "license": "MIT" + }, "node_modules/@nuxtjs/opencollective/node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", "dev": true, + "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -1609,48 +1700,52 @@ "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@nuxtjs/opencollective/node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true + "dev": true, + "license": "BSD-2-Clause" }, "node_modules/@nuxtjs/opencollective/node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, + "license": "MIT", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, "node_modules/@openapitools/openapi-generator-cli": { - "version": "2.15.3", - "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.15.3.tgz", - "integrity": "sha512-2UBnsDlMt36thhdXxisbA1qReVtbCaw+NCvXoslRXlaJBL4qkAmZUhNeDLNu3LCbwA2PASMWhJSqeLwgwMCitw==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.20.0.tgz", + "integrity": "sha512-Amtd7/9Lodaxnmfsru8R5n0CW9lyWOI40UsppGMfuNFkFFbabq51/VAJFsOHkNnDRwVUc7AGKWjN5icphDGlTQ==", "dev": true, "hasInstallScript": true, + "license": "Apache-2.0", "dependencies": { - "@nestjs/axios": "3.1.1", - "@nestjs/common": "10.4.6", - "@nestjs/core": "10.4.6", + "@nestjs/axios": "4.0.0", + "@nestjs/common": "11.0.20", + "@nestjs/core": "11.0.20", "@nuxtjs/opencollective": "0.3.2", - "axios": "1.7.7", + "axios": "1.8.4", "chalk": "4.1.2", "commander": "8.3.0", "compare-versions": "4.1.4", "concurrently": "6.5.1", "console.table": "0.10.0", - "fs-extra": "10.1.0", + "fs-extra": "11.3.0", "glob": "9.3.5", "inquirer": "8.2.6", "lodash": "4.17.21", - "proxy-agent": "6.4.0", - "reflect-metadata": "0.1.13", - "rxjs": "7.8.1", + "proxy-agent": "6.5.0", + "reflect-metadata": "0.2.2", + "rxjs": "7.8.2", "tslib": "2.8.1" }, "bin": { @@ -1664,97 +1759,6 @@ "url": "https://opencollective.com/openapi_generator" } }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/axios": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.1.1.tgz", - "integrity": "sha512-ySoxrzqX80P1q6LKLKGcgyBd2utg4gbC+4FsJNpXYvILorMlxss/ECNogD9EXLCE4JS5exVFD5ez0nK5hXcNTQ==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0", - "axios": "^1.3.1", - "rxjs": "^6.0.0 || ^7.0.0" - } - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/common": { - "version": "10.4.6", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.4.6.tgz", - "integrity": "sha512-KkezkZvU9poWaNq4L+lNvx+386hpOxPJkfXBBeSMrcqBOx8kVr36TGN2uYkF4Ta4zNu1KbCjmZbc0rhHSg296g==", - "dev": true, - "dependencies": { - "iterare": "1.2.1", - "tslib": "2.7.0", - "uid": "2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nest" - }, - "peerDependencies": { - "class-transformer": "*", - "class-validator": "*", - "reflect-metadata": "^0.1.12 || ^0.2.0", - "rxjs": "^7.1.0" - }, - "peerDependenciesMeta": { - "class-transformer": { - "optional": true - }, - "class-validator": { - "optional": true - } - } - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/common/node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", - "dev": true - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/core": { - "version": "10.4.6", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.4.6.tgz", - "integrity": "sha512-zXVPxCNRfO6gAy0yvEDjUxE/8gfZICJFpsl2lZAUH31bPb6m+tXuhUq2mVCTEltyMYQ+DYtRe+fEYM2v152N1g==", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "@nuxtjs/opencollective": "0.3.2", - "fast-safe-stringify": "2.1.1", - "iterare": "1.2.1", - "path-to-regexp": "3.3.0", - "tslib": "2.7.0", - "uid": "2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nest" - }, - "peerDependencies": { - "@nestjs/common": "^10.0.0", - "@nestjs/microservices": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "@nestjs/websockets": "^10.0.0", - "reflect-metadata": "^0.1.12 || ^0.2.0", - "rxjs": "^7.1.0" - }, - "peerDependenciesMeta": { - "@nestjs/microservices": { - "optional": true - }, - "@nestjs/platform-express": { - "optional": true - }, - "@nestjs/websockets": { - "optional": true - } - } - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/@nestjs/core/node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", - "dev": true - }, "node_modules/@openapitools/openapi-generator-cli/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -1764,6 +1768,21 @@ "balanced-match": "^1.0.0" } }, + "node_modules/@openapitools/openapi-generator-cli/node_modules/fs-extra": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.0.tgz", + "integrity": "sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, "node_modules/@openapitools/openapi-generator-cli/node_modules/glob": { "version": "9.3.5", "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz", @@ -1806,18 +1825,6 @@ "node": ">=8" } }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/path-to-regexp": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.3.0.tgz", - "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==", - "dev": true - }, - "node_modules/@openapitools/openapi-generator-cli/node_modules/reflect-metadata": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", - "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", - "dev": true - }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -1959,7 +1966,6 @@ "integrity": "sha512-MADQgmZT1eKjp06jpI2yozxaU9uVs4GzzgSL+uEq7bVcJ9V1ZXQkeGNql1fsSI0gMy1vhvNTNbUqrx+pZfJVmg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "debug": "^4.4.0", "fflate": "^0.8.2", @@ -1979,7 +1985,6 @@ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ms": "^2.1.3" }, @@ -1997,8 +2002,7 @@ "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@tootallnate/once": { "version": "2.0.0", @@ -2012,7 +2016,8 @@ "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/body-parser": { "version": "1.19.5", @@ -3078,12 +3083,10 @@ } }, "node_modules/agent-base": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", - "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", - "dependencies": { - "debug": "^4.3.4" - }, + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "license": "MIT", "engines": { "node": ">= 14" } @@ -3343,6 +3346,7 @@ "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", "dev": true, + "license": "MIT", "dependencies": { "tslib": "^2.0.1" }, @@ -3377,9 +3381,10 @@ "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==" }, "node_modules/axios": { - "version": "1.7.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", - "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "version": "1.8.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz", + "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==", + "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -3434,6 +3439,7 @@ "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.5.tgz", "integrity": "sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==", "dev": true, + "license": "MIT", "engines": { "node": ">=10.0.0" } @@ -4606,10 +4612,14 @@ } }, "node_modules/consola": { - "version": "2.15.3", - "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", - "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==", - "dev": true + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", + "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.10.0" + } }, "node_modules/console-control-strings": { "version": "1.1.0", @@ -4972,6 +4982,7 @@ "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", "dev": true, + "license": "MIT", "dependencies": { "ast-types": "^0.13.4", "escodegen": "^2.1.0", @@ -5460,6 +5471,7 @@ "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "esprima": "^4.0.1", "estraverse": "^5.2.0", @@ -5481,6 +5493,7 @@ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } @@ -5649,6 +5662,7 @@ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true, + "license": "BSD-2-Clause", "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -5956,7 +5970,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/fastq": { "version": "1.17.1", @@ -6001,8 +6016,7 @@ "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/figures": { "version": "3.2.0", @@ -6046,7 +6060,6 @@ "integrity": "sha512-hw9gNZXUfZ02Jo0uafWLaFVPter5/k2rfcrjFJJHX/77xtSDOfJuEFb6oKlFV86FLP1SuyHMW1PSk0U9M5tKkQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@tokenizer/inflate": "^0.2.6", "strtok3": "^10.2.0", @@ -6491,15 +6504,15 @@ } }, "node_modules/get-uri": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.3.tgz", - "integrity": "sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw==", + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.4.tgz", + "integrity": "sha512-E1b1lFFLvLgak2whF2xDBcOy6NLVGZBqqjJjsIhvopKfWWEi64pLVTWWehV8KlLerZkfNTA95sTe2OdJKm1OzQ==", "dev": true, + "license": "MIT", "dependencies": { "basic-ftp": "^5.0.2", "data-uri-to-buffer": "^6.0.2", - "debug": "^4.3.4", - "fs-extra": "^11.2.0" + "debug": "^4.3.4" }, "engines": { "node": ">= 14" @@ -6510,24 +6523,11 @@ "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 14" } }, - "node_modules/get-uri/node_modules/fs-extra": { - "version": "11.2.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", - "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -6986,11 +6986,12 @@ } }, "node_modules/https-proxy-agent": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", - "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "license": "MIT", "dependencies": { - "agent-base": "^7.0.2", + "agent-base": "^7.1.2", "debug": "4" }, "engines": { @@ -7921,6 +7922,26 @@ "uc.micro": "^1.0.1" } }, + "node_modules/load-esm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/load-esm/-/load-esm-1.0.2.tgz", + "integrity": "sha512-nVAvWk/jeyrWyXEAs84mpQCYccxRqgKY4OznLuJhJCa0XsPSfdOIr2zvBZEj3IHEHbX97jjscKRRV539bW0Gpw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + }, + { + "type": "buymeacoffee", + "url": "https://buymeacoffee.com/borewit" + } + ], + "license": "MIT", + "engines": { + "node": ">=13.2.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -9267,6 +9288,7 @@ "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4.0" } @@ -9965,31 +9987,33 @@ } }, "node_modules/pac-proxy-agent": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.2.tgz", - "integrity": "sha512-BFi3vZnO9X5Qt6NRz7ZOaPja3ic0PhlsmCRYLOpN11+mWBCR6XJDqW5RF3j8jm4WGGQZtBA+bTfxYzeKW73eHg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz", + "integrity": "sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA==", "dev": true, + "license": "MIT", "dependencies": { "@tootallnate/quickjs-emscripten": "^0.23.0", - "agent-base": "^7.0.2", + "agent-base": "^7.1.2", "debug": "^4.3.4", "get-uri": "^6.0.1", "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.5", + "https-proxy-agent": "^7.0.6", "pac-resolver": "^7.0.1", - "socks-proxy-agent": "^8.0.4" + "socks-proxy-agent": "^8.0.5" }, "engines": { "node": ">= 14" } }, "node_modules/pac-proxy-agent/node_modules/socks-proxy-agent": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.4.tgz", - "integrity": "sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw==", + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", + "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", "dev": true, + "license": "MIT", "dependencies": { - "agent-base": "^7.1.1", + "agent-base": "^7.1.2", "debug": "^4.3.4", "socks": "^2.8.3" }, @@ -10002,6 +10026,7 @@ "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz", "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==", "dev": true, + "license": "MIT", "dependencies": { "degenerator": "^5.0.0", "netmask": "^2.0.2" @@ -10194,7 +10219,6 @@ "integrity": "sha512-nri2TO5JE3/mRryik9LlHFT53cgHfRK0Lt0BAZQXku/AW3E6XLt2GaY8siWi7dvW/m1z0ecn+J+bpDa9ZN3IsQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=18" }, @@ -10680,19 +10704,20 @@ } }, "node_modules/proxy-agent": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.4.0.tgz", - "integrity": "sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.5.0.tgz", + "integrity": "sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A==", "dev": true, + "license": "MIT", "dependencies": { - "agent-base": "^7.0.2", + "agent-base": "^7.1.2", "debug": "^4.3.4", "http-proxy-agent": "^7.0.1", - "https-proxy-agent": "^7.0.3", + "https-proxy-agent": "^7.0.6", "lru-cache": "^7.14.1", - "pac-proxy-agent": "^7.0.1", + "pac-proxy-agent": "^7.1.0", "proxy-from-env": "^1.1.0", - "socks-proxy-agent": "^8.0.2" + "socks-proxy-agent": "^8.0.5" }, "engines": { "node": ">= 14" @@ -10703,17 +10728,19 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", "dev": true, + "license": "ISC", "engines": { "node": ">=12" } }, "node_modules/proxy-agent/node_modules/socks-proxy-agent": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.4.tgz", - "integrity": "sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw==", + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", + "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", "dev": true, + "license": "MIT", "dependencies": { - "agent-base": "^7.1.1", + "agent-base": "^7.1.2", "debug": "^4.3.4", "socks": "^2.8.3" }, @@ -11077,11 +11104,11 @@ } }, "node_modules/reflect-metadata": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz", - "integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", + "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==", "dev": true, - "peer": true + "license": "Apache-2.0" }, "node_modules/regenerator-runtime": { "version": "0.14.1", @@ -11418,10 +11445,11 @@ "integrity": "sha512-cLgakCUf6PedEu15t8kbsjnwIFFR2D4RfL+W3iWFJ4iac7z4B0ZI8fxy4R3J956kAI68HclCFGL8MPoUVC3qVA==" }, "node_modules/rxjs": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", - "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", "dev": true, + "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" } @@ -12168,7 +12196,6 @@ "integrity": "sha512-Xt18+h4s7Z8xyZ0tmBoRmzxcop97R4BAh+dXouUDCYn+Em+1P3qpkUfI5ueWLT8ynC5hZ+q4iPEmGG1urvQGBg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@tokenizer/token": "^0.3.0", "peek-readable": "^7.0.0" @@ -12824,7 +12851,6 @@ "integrity": "sha512-lbDrTLVsHhOMljPscd0yitpozq7Ga2M5Cvez5AjGg8GASBjtt6iERCAJ93yommPmz62fb45oFIXHEZ3u9bfJEA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" @@ -13082,7 +13108,6 @@ "integrity": "sha512-ZPtzy0hu4cZjv3z5NW9gfKnNLjoz4y6uv4HlelAjDK7sY/xOkKZv9xK/WQpcsBB3jEybChz9DPC2U/+cusjJVQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=18" }, diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index a9eddcfe1..56fc1e80a 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -631,7 +631,7 @@ "devDependencies": { "@biomejs/biome": "1.6.4", "@nestjs/common": "^11.0.16", - "@openapitools/openapi-generator-cli": "^2.5.2", + "@openapitools/openapi-generator-cli": "^2.20.0", "@types/chai": "^5.0.1", "@types/cors": "^2.8.17", "@types/express": "^4.17.21", diff --git a/gui/src/App.tsx b/gui/src/App.tsx index 03b6fb05a..6fc120707 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -9,6 +9,7 @@ import ErrorPage from "./pages/error"; import Chat from "./pages/gui"; import History from "./pages/history"; import Stats from "./pages/stats"; +import ThemePage from "./styles/ThemePage"; import { ROUTES } from "./util/navigation"; const router = createMemoryRouter([ @@ -37,6 +38,10 @@ const router = createMemoryRouter([ path: ROUTES.CONFIG, element: , }, + { + path: ROUTES.THEME, + element: , + }, ], }, ]); diff --git a/gui/src/components/StyledMarkdownPreview/SymbolLink.tsx b/gui/src/components/StyledMarkdownPreview/SymbolLink.tsx index 40ca69708..8224af794 100644 --- a/gui/src/components/StyledMarkdownPreview/SymbolLink.tsx +++ b/gui/src/components/StyledMarkdownPreview/SymbolLink.tsx @@ -44,14 +44,7 @@ function SymbolLink({ symbol, content }: SymbolLinkProps) { data-tooltip-id={id} data-tooltip-delay-show={500} > - - {content} - + {content}
{processedContent ?? symbol.filepath}
diff --git a/gui/src/components/TabBar/TabBar.tsx b/gui/src/components/TabBar/TabBar.tsx index 3b87a23c6..be8c53213 100644 --- a/gui/src/components/TabBar/TabBar.tsx +++ b/gui/src/components/TabBar/TabBar.tsx @@ -13,13 +13,25 @@ import { } from "../../redux/slices/tabsSlice"; import { AppDispatch, RootState } from "../../redux/store"; import { loadSession, saveCurrentSession } from "../../redux/thunks/session"; +import { varWithFallback } from "../../styles/theme"; + +// Haven't set up theme colors for tabs yet +// Will keep it simple and choose from existing ones. Comments show vars we could use +const tabBorderVar = varWithFallback("border"); // --vscode-tab-border +const tabBackgroundVar = varWithFallback("background"); // --vscode-tab-inactiveBackground +const tabForegroundVar = varWithFallback("foreground"); // --vscode-tab-inactiveForeground +const tabHoverBackgroundVar = varWithFallback("list-hover"); // --vscode-tab-hoverBackground +const tabHoverForegroundVar = varWithFallback("foreground"); // --vscode-tab-hoverForeground +const tabSelectedBackgroundVar = varWithFallback("background"); // --vscode-tab-activeBackground +const tabSelectedForegroundVar = varWithFallback("foreground"); // --vscode-tab-activeForeground +const tabAccentVar = varWithFallback("accent"); // --vscode-tab-activeBorderTop const TabBarContainer = styled.div` display: flex; flex-wrap: wrap; flex-shrink: 0; flex-grow: 0; - background-color: var(--vscode-tab-inactiveBackground); + background-color: ${tabBackgroundVar}; border-bottom: none; position: relative; margin-top: 2px; @@ -41,24 +53,18 @@ const Tab = styled.div<{ isActive: boolean }>` max-width: 150px; height: 25px; background-color: ${(props) => - props.isActive - ? "var(--vscode-tab-activeBackground)" - : "var(--vscode-tab-inactiveBackground)"}; + props.isActive ? tabSelectedBackgroundVar : tabBackgroundVar}; color: ${(props) => - props.isActive - ? "var(--vscode-tab-activeForeground)" - : "var(--vscode-tab-inactiveForeground)"}; + props.isActive ? tabSelectedForegroundVar : tabForegroundVar}; cursor: pointer; - border: 1px solid var(--vscode-tab-border); + border: 1px solid ${tabBorderVar}; border-bottom: ${(props) => - props.isActive ? "none" : `1px solid var(--vscode-tab-border)`}; + props.isActive ? "none" : `1px solid ${tabBorderVar}`}; user-select: none; position: relative; transition: background-color 0.2s; border-top: ${(props) => - props.isActive - ? `1px solid var(--vscode-tab-activeBorderTop, --vscode-tab-border)` - : `1px solid var(--vscode-tab-border)`}; + props.isActive ? `1px solid ${tabAccentVar}` : `1px solid ${tabBorderVar}`}; &:first-child { border-left: none; } @@ -68,13 +74,9 @@ const Tab = styled.div<{ isActive: boolean }>` &:hover { background-color: ${(props) => - props.isActive - ? "var(--vscode-tab-activeBackground)" - : "var(--vscode-tab-hoverBackground)"}; + props.isActive ? tabSelectedBackgroundVar : tabHoverBackgroundVar}; color: ${(props) => - props.isActive - ? "var(--vscode-tab-activeForeground)" - : "var(--vscode-tab-hoverForeground)"}; + props.isActive ? tabSelectedForegroundVar : tabHoverForegroundVar}; } `; @@ -104,7 +106,7 @@ const CloseButton = styled.button` &:hover { opacity: 1; - background-color: var(--vscode-tab-hoverBackground); + background-color: ${tabHoverBackgroundVar}; } ${Tab}:hover & { @@ -119,33 +121,12 @@ const CloseButton = styled.button` const TabBarSpace = styled.div` flex: 1; display: flex; - border-bottom: 1px solid var(--vscode-tab-border); - background-color: var(--vscode-tab-inactiveBackground); -`; - -const NewTabButton = styled.button` - display: flex; - align-items: center; - justify-content: center; - width: 35px; - height: 100%; - border: none; - background: transparent; - color: var(--vscode-tab-inactiveForeground); - cursor: pointer; - opacity: 0.7; - transition: opacity 0.2s; - - &:hover { - opacity: 1; - background-color: var(--vscode-tab-hoverBackground); - color: var(--vscode-tab-hoverForeground); - } + border-bottom: 1px solid ${tabBorderVar}; + background-color: ${tabBackgroundVar}; `; export function TabBar() { const dispatch = useDispatch(); - const currentSession = useSelector((state: RootState) => state.session); const currentSessionId = useSelector((state: RootState) => state.session.id); const currentSessionTitle = useSelector( (state: RootState) => state.session.title, diff --git a/gui/src/components/dialogs/index.tsx b/gui/src/components/dialogs/index.tsx index 5acf040b6..d205d59f8 100644 --- a/gui/src/components/dialogs/index.tsx +++ b/gui/src/components/dialogs/index.tsx @@ -4,12 +4,11 @@ import ReactMarkdown from "react-markdown"; import styled from "styled-components"; import { CloseButton, - VSC_BACKGROUND_VAR, defaultBorderRadius, - parseColorForHex, vscBackground, vscForeground, } from ".."; +import { varWithFallback } from "../../styles/theme"; interface TextDialogProps { showDialog: boolean; @@ -22,7 +21,7 @@ const ScreenCover = styled.div` position: fixed; width: 100%; height: 100%; - background-color: ${parseColorForHex(VSC_BACKGROUND_VAR)}aa; + background-color: ${varWithFallback("background")}aa; z-index: 100000; flex-direction: column; `; diff --git a/gui/src/components/find/FindWidget.tsx b/gui/src/components/find/FindWidget.tsx index fd174f59c..ab79cb4dc 100644 --- a/gui/src/components/find/FindWidget.tsx +++ b/gui/src/components/find/FindWidget.tsx @@ -12,8 +12,8 @@ import { useState, } from "react"; import { HeaderButton, Input } from ".."; -import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; import { useAppSelector } from "../../redux/hooks"; +import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; interface SearchMatch { index: number; @@ -41,7 +41,7 @@ const HighlightOverlay = (props: HighlightOverlayProps) => { const { isCurrent, top, left, width, height } = props; return (
+
6) { - hexColor = hexColor.slice(0, 6); - } - - const r = parseInt(hexColor.substring(0, 2), 16); - const g = parseInt(hexColor.substring(2, 4), 16); - const b = parseInt(hexColor.substring(4, 6), 16); - - return { r, g, b }; -} - -export function parseColorForHex(colorVar: string): string { - const value = getComputedStyle(document.documentElement).getPropertyValue( - colorVar, - ); - if (value.startsWith("#")) { - return value.slice(0, 7); - } - - // Parse rgb/rgba - const rgbValues = value - .slice(value.startsWith("rgba") ? 5 : 4, -1) - .split(",") - .map((x) => x.trim()) - .filter((_, i) => i < 3) // Only take the first 3 values (RGB, ignore alpha) - .map((x) => parseInt(x, 10)); - - let hex = - "#" + - rgbValues - .map((x) => x.toString(16)) - .map((x) => (x.length === 1 ? "0" + x : x)) - .join(""); - - return hex; -} +export const vscInputBackground = varWithFallback("input-background"); +export const vscQuickInputBackground = varWithFallback("input-background"); +export const vscBackground = varWithFallback("background"); +export const vscForeground = varWithFallback("foreground"); +export const vscButtonBackground = varWithFallback("primary-background"); +export const vscButtonForeground = varWithFallback("primary-foreground"); +export const vscEditorBackground = varWithFallback("editor-background"); +export const vscListActiveBackground = varWithFallback("list-active"); +export const vscFocusBorder = varWithFallback("border-focus"); +export const vscListActiveForeground = varWithFallback( + "list-active-foreground", +); +export const vscInputBorder = varWithFallback("input-border"); +export const vscInputBorderFocus = varWithFallback("border-focus"); +export const vscBadgeBackground = varWithFallback("badge-background"); +export const vscBadgeForeground = varWithFallback("badge-foreground"); +export const vscCommandCenterActiveBorder = varWithFallback( + "command-border-focus", +); +export const vscCommandCenterInactiveBorder = varWithFallback("command-border"); export const Button = styled.button` padding: 6px 12px; @@ -226,10 +143,6 @@ export const Input = styled.input` } `; -export const Label = styled.label<{ fontSize?: number }>` - font-size: ${(props) => props.fontSize || getFontSize()}px; -`; - export const HeaderButton = styled.button<{ inverted: boolean | undefined; backgroundColor?: string; diff --git a/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx b/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx index a5b89d0f4..3b8359e96 100644 --- a/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx @@ -159,7 +159,7 @@ export function ExpandableToolbarPreview(props: ExpandableToolbarPreviewProps) { contentEditable={false} >
= { ".hljs-comment": ["comment"], diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index 1b609ce39..c3f776454 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -1,5 +1,4 @@ import { useCallback, useContext, useEffect, useRef } from "react"; -import { VSC_THEME_COLOR_VARS } from "../components"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; @@ -29,6 +28,10 @@ import { cancelStream } from "../redux/thunks/cancelStream"; import { refreshSessionMetadata } from "../redux/thunks/session"; import { streamResponseThunk } from "../redux/thunks/streamResponse"; import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols"; +import { + setDocumentStylesFromLocalStorage, + setDocumentStylesFromTheme, +} from "../styles/theme"; import { isJetBrains } from "../util"; import { setLocalStorage } from "../util/localStorage"; import { useWebviewListener } from "./useWebviewListener"; @@ -139,31 +142,13 @@ function ParallelListeners() { dispatch(cancelStream()); const jetbrains = isJetBrains(); - for (const colorVar of VSC_THEME_COLOR_VARS) { - if (jetbrains) { - const cached = localStorage.getItem(colorVar); - if (cached) { - document.body.style.setProperty(colorVar, cached); - } - } - - // Remove alpha channel from colors - const value = getComputedStyle(document.documentElement).getPropertyValue( - colorVar, - ); - if (colorVar.startsWith("#") && value.length > 7) { - document.body.style.setProperty(colorVar, value.slice(0, 7)); - } - } + setDocumentStylesFromLocalStorage(jetbrains); if (jetbrains) { // Save theme colors to local storage for immediate loading in JetBrains ideMessenger.request("jetbrains/getColors", undefined).then((result) => { if (result.status === "success") { - Object.entries(result.content).forEach(([key, value]) => { - document.body.style.setProperty(key, value); - document.documentElement.style.setProperty(key, value); - }); + setDocumentStylesFromTheme(result.content); } }); @@ -180,25 +165,13 @@ function ParallelListeners() { (window as any).vscMachineId = msg.vscMachineId; (window as any).vscMediaUrl = msg.vscMediaUrl; }); - - for (const colorVar of VSC_THEME_COLOR_VARS) { - if (document.body.style.getPropertyValue(colorVar)) { - localStorage.setItem( - colorVar, - document.body.style.getPropertyValue(colorVar), - ); - } - } } }, []); useWebviewListener( "jetbrains/setColors", async (data) => { - Object.entries(data).forEach(([key, value]) => { - document.body.style.setProperty(key, value); - document.documentElement.style.setProperty(key, value); - }); + setDocumentStylesFromTheme(data); }, [], ); diff --git a/gui/src/pages/config/HelpCenterSection.tsx b/gui/src/pages/config/HelpCenterSection.tsx index a82b775a8..e49a17780 100644 --- a/gui/src/pages/config/HelpCenterSection.tsx +++ b/gui/src/pages/config/HelpCenterSection.tsx @@ -1,6 +1,7 @@ import { ArrowTopRightOnSquareIcon, DocumentArrowUpIcon, + PaintBrushIcon, TableCellsIcon, } from "@heroicons/react/24/outline"; import { useContext } from "react"; @@ -9,6 +10,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useAppDispatch } from "../../redux/hooks"; import { setOnboardingCard } from "../../redux/slices/uiSlice"; import { saveCurrentSession } from "../../redux/thunks/session"; +import { ROUTES } from "../../util/navigation"; import MoreHelpRow from "./MoreHelpRow"; export function HelpCenterSection() { @@ -83,6 +85,16 @@ export function HelpCenterSection() { ideMessenger.post("showTutorial", undefined); }} /> + {process.env.NODE_ENV === "development" && ( + { + navigate(ROUTES.THEME); + }} + /> + )}
); diff --git a/gui/src/pages/config/KeyboardShortcuts.tsx b/gui/src/pages/config/KeyboardShortcuts.tsx index d7c3828d7..77d8c2733 100644 --- a/gui/src/pages/config/KeyboardShortcuts.tsx +++ b/gui/src/pages/config/KeyboardShortcuts.tsx @@ -11,7 +11,7 @@ interface KeyboardShortcutProps { function KeyboardShortcut(props: KeyboardShortcutProps) { return (
{props.description}: diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index c9a21a30c..8f11fc7f5 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -100,6 +100,7 @@ export const streamResponseThunk = createAsyncThunk< ? (userMsg as UserChatMessage | ToolResultChatMessage) : undefined, rules, + selectedContextItems, ); // Store in history for UI display diff --git a/gui/src/styles/ThemePage.tsx b/gui/src/styles/ThemePage.tsx new file mode 100644 index 000000000..b365ec535 --- /dev/null +++ b/gui/src/styles/ThemePage.tsx @@ -0,0 +1,232 @@ +import { + CheckCircleIcon, + ExclamationCircleIcon, + ExclamationTriangleIcon, +} from "@heroicons/react/24/outline"; +import { useContext, useEffect, useMemo, useState } from "react"; +import { useNavigate } from "react-router-dom"; +import { Button } from "../components"; +import { IdeMessengerContext } from "../context/IdeMessenger"; +import { isJetBrains } from "../util"; +import { ROUTES } from "../util/navigation"; +import { + clearThemeLocalCache, + setDocumentStylesFromTheme, + THEME_COLORS, + varWithFallback, +} from "./theme"; + +const ThemeTailwindClassExample = ({ + colorName, + varNames, + defaultColor, + isMissing, +}: { + colorName: string; + varNames: string[]; + defaultColor: string; + isMissing?: boolean; +}) => { + return ( + <> +
+ {colorName} +
+
+ {varNames.join(", ")} +
+
+ {defaultColor} +
+ + ); +}; + +function ThemePage() { + const navigate = useNavigate(); + const [listToggled, setListToggled] = useState(false); + const ideMessenger = useContext(IdeMessengerContext); + const jetbrains = useMemo(() => { + return isJetBrains(); + }, []); + + const [missingVars, setMissingVars] = useState([]); + const refreshColors = () => { + if (jetbrains) { + // Jetbrains: get colors and check which ones are missing from theme + void ideMessenger + .request("jetbrains/getColors", undefined) + .then((result) => { + console.log(result); + if (result.status === "success") { + const missingColors = setDocumentStylesFromTheme(result.content); + setMissingVars(missingColors); + } + }); + } else { + // VS Code: find actual missing CSS variables + const notFound: string[] = []; + Object.entries(THEME_COLORS).forEach(([colorName, themeVals], idx) => { + let found = false; + themeVals.vars.forEach((cssVar) => { + const value = getComputedStyle( + document.documentElement, + ).getPropertyValue(cssVar); + if (!value) { + notFound.push(`cssVar (choice #${idx + 1} for color ${colorName}`); + } + }); + }); + setMissingVars(notFound); + } + }; + + useEffect(() => { + refreshColors(); + }, []); + + return ( +
+ navigate(ROUTES.HOME)} + > + ← + Back to Chat + +

+ Theme Tester +

+
+
+

Normal text

+

Description text

+

Muted text

+
+ + + + +
+ Normal border +
+ +
+ Focus border +
+ + + +
+ Badge +
+ +
+ + Success +
+
+ + Warning +
+
+ + Error +
+ +
setListToggled(!listToggled)} + className={`cursor-pointer p-2 ${listToggled ? "bg-list-active text-list-active-foreground" : "bg-background text-foreground hover:bg-list-hover"}`} + > + List item (clickable) +
+
+ Editor +
+ + + + + + + + + +
+ even table row +
+ odd table row +
+
+ Link +
+
+ find match + current match +
+
+ Accent +
+
+
+

Manage Theme

+

Missing Theme Colors

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

All Theme Colors

+
+
+ Theme Color +
+
+ CSS Var +
+
+ Default +
+ {Object.entries(THEME_COLORS).map(([colorName, val]) => ( + + ))} +
+
+ ); +} +export default ThemePage; diff --git a/gui/src/styles/theme.test.ts b/gui/src/styles/theme.test.ts new file mode 100644 index 000000000..f65dd7583 --- /dev/null +++ b/gui/src/styles/theme.test.ts @@ -0,0 +1,24 @@ +import { getRecursiveVar } from "./theme"; + +test("getRecursiveVar returns single var with default for one variable", () => { + const vars = ["--test-var"]; + const defaultColor = "#ffffff"; + const result = getRecursiveVar(vars, defaultColor); + expect(result).toBe("var(--test-var, #ffffff)"); +}); + +test("getRecursiveVar returns nested vars in correct order for multiple variables", () => { + const vars = ["--first-var", "--second-var", "--third-var"]; + const defaultColor = "#000000"; + const result = getRecursiveVar(vars, defaultColor); + expect(result).toBe( + "var(--first-var, var(--second-var, var(--third-var, #000000)))", + ); +}); + +test("getRecursiveVar handles empty vars array", () => { + const vars: string[] = []; + const defaultColor = "#123456"; + const result = getRecursiveVar(vars, defaultColor); + expect(result).toBe("#123456"); +}); diff --git a/gui/src/styles/theme.ts b/gui/src/styles/theme.ts new file mode 100644 index 000000000..ad0ee0bd7 --- /dev/null +++ b/gui/src/styles/theme.ts @@ -0,0 +1,271 @@ +// All vscode variables https://gist.github.com/estruyf/ba49203e1a7d6868e9320a4ea480c27a +// Examples for vscode https://github.com/githubocto/tailwind-vscode/blob/main/index.js + +// The current default theme is dark with blue accents +export const THEME_COLORS = { + background: { + vars: [ + "--vscode-sideBar-background", + "--vscode-editor-background", + "--vscode-panel-background", + ], + default: "#1e1e1e", // dark gray + }, + foreground: { + vars: [ + "--vscode-sideBar-foreground", + "--vscode-editor-foreground", + "--vscode-panel-foreground", + ], + default: "#e6e6e6", // light gray + }, + "editor-background": { + vars: ["--vscode-editor-background"], + default: "#1e1e1e", // dark gray + }, + "editor-foreground": { + vars: ["--vscode-editor-foreground"], + default: "#e6e6e6", // light gray + }, + "primary-background": { + vars: ["--vscode-button-background"], + default: "#2c5aa0", // medium blue + }, + "primary-foreground": { + vars: ["--vscode-button-foreground"], + default: "#ffffff", // white + }, + "primary-hover": { + vars: ["--vscode-button-hoverBackground"], + default: "#3a6db3", // lighter blue + }, + "secondary-background": { + vars: ["--vscode-button-secondaryBackground"], + default: "#303030", // medium dark gray + }, + "secondary-foreground": { + vars: ["--vscode-button-secondaryForeground"], + default: "#e6e6e6", // light gray + }, + "secondary-hover": { + vars: ["--vscode-button-secondaryHoverBackground"], + default: "#3a3a3a", // medium gray + }, + border: { + vars: ["--vscode-sideBar-border", "--vscode-panel-border"], + default: "#2a2a2a", // dark gray border + }, + "border-focus": { + vars: ["--vscode-focusBorder"], + default: "#3a6db3", // lighter blue + }, + // Command styles are used for tip-tap editor + "command-background": { + vars: ["--vscode-commandCenter-background"], + default: "#252525", // dark gray + }, + "command-foreground": { + vars: ["--vscode-commandCenter-foreground"], + default: "#e6e6e6", // light gray + }, + "command-border": { + vars: ["--vscode-commandCenter-inactiveBorder"], + default: "#555555", // medium gray + }, + "command-border-focus": { + vars: ["--vscode-commandCenter-activeBorder"], + default: "#4d8bf0", // bright blue + }, + description: { + vars: ["--vscode-descriptionForeground"], + default: "#b3b3b3", // medium light gray + }, + "description-muted": { + vars: ["--vscode-list-deemphasizedForeground"], + default: "#8c8c8c", // medium gray + }, + "input-background": { + vars: ["--vscode-input-background"], + default: "#2d2d2d", // dark gray + }, + "input-foreground": { + vars: ["--vscode-input-foreground"], + default: "#e6e6e6", // light gray + }, + "input-border": { + vars: [ + "--vscode-input-border", + "--vscode-commandCenter-inactiveBorder", + "vscode-border", + ], + default: "#555555", // medium gray + }, + "input-placeholder": { + vars: ["--vscode-input-placeholderForeground"], + default: "#9e9e9e", // medium light gray + }, + "table-oddRow": { + vars: ["--vscode-tree-tableOddRowsBackground"], + default: "#2d2d2d", // dark gray + }, + "badge-background": { + vars: ["--vscode-badge-background"], + default: "#4d4d4d", // medium dark gray + }, + "badge-foreground": { + vars: ["--vscode-badge-foreground"], + default: "#ffffff", // white + }, + success: { + vars: [ + "--vscode-notebookStatusSuccessIcon-foreground", + "--vscode-testing-iconPassed", + "--vscode-gitDecoration-addedResourceForeground", + "--vscode-charts-green", + ], + default: "#4caf50", // green + }, + warning: { + vars: [ + "--vscode-editorWarning-foreground", + "--vscode-list-warningForeground", + ], + default: "#ffb74d", // amber/yellow + }, + error: { + vars: ["--vscode-editorError-foreground", "--vscode-list-errorForeground"], + default: "#f44336", // red + }, + link: { + vars: ["--vscode-textLink-foreground"], + default: "#5c9ce6", // medium blue + }, + accent: { + vars: ["--vscode-tab-activeBorderTop", "--vscode-focusBorder"], + default: "#4d8bf0", // bright blue + }, + "find-match": { + vars: ["--vscode-editor-findMatchBackground"], // Can't get "var(--vscode-editor-findMatchBackground, rgba(237, 18, 146, 0.5))" to work + default: "#264f7840", // translucent blue + }, + "find-match-selected": { + vars: ["--vscode-editor-findMatchHighlightBackground"], + default: "#ffb74d40", // translucent amber + }, + "list-hover": { + // --vscode-tab-hoverBackground + vars: ["--vscode-list-hoverBackground"], + default: "#383838", // medium dark gray + }, + "list-active": { + vars: ["--vscode-list-activeSelectionBackground"], + default: "#2c5aa050", // translucent medium blue + }, + "list-active-foreground": { + vars: ["--vscode-list-activeSelectionForeground"], + default: "#ffffff", // white + }, +}; + +// TODO: add fonts - GUI fonts in jetbrains differ from IDE: +// --vscode-editor-font-family; +// --vscode-font-family; +export const THEME_CSS_VARS = Object.values(THEME_COLORS) + .map((value) => value.vars) + .flat(); + +export const THEME_CSS_VAR_DEFAULTS = Object.entries(THEME_COLORS).reduce( + (acc, [_, value]) => { + value.vars.forEach((varName) => { + acc[varName] = value.default; + }); + return acc; + }, + {} as Record, +); + +export const THEME_DEFAULTS = Object.entries(THEME_COLORS).reduce( + (acc, [key, value]) => { + acc[key] = value.default; + return acc; + }, + {} as Record, +); + +// Generates recursive CSS variable fallback for a given color name +// e.g. var(--vscode-button-background, var(--vscode-button-foreground, #ffffff)) +export const getRecursiveVar = (vars: string[], defaultColor: string) => { + return [...vars].reverse().reduce((curr, varName) => { + return `var(${varName}, ${curr})`; + }, defaultColor); +}; + +export const varWithFallback = (colorName: keyof typeof THEME_COLORS) => { + const themeVals = THEME_COLORS[colorName]; + if (!themeVals) { + throw new Error(`Invalid theme color name ${colorName}`); + } + return getRecursiveVar(themeVals.vars, themeVals.default); +}; + +export const setDocumentStylesFromTheme = ( + theme: Record, +) => { + // Check for extraneous theme items + Object.entries(theme).forEach(([colorName, value]) => { + const themeVals = THEME_COLORS[colorName as keyof typeof THEME_COLORS]; + if (!themeVals) { + console.warn( + `Receieved theme color ${colorName} which is not used by the theme`, + ); + return; + } + }); + + // Write theme values to document + const missingColors: string[] = []; + Object.entries(THEME_COLORS).forEach(([colorName, settings]) => { + let colorVal = settings.default; + const newColor = theme[colorName]; + if (newColor) { + colorVal = newColor; + // Remove alpha channel from all hex colors (seems to cause bad colors) + if (newColor.startsWith("#") && newColor.length > 7) { + colorVal = colorVal.slice(0, 7); + } + } else { + missingColors.push(colorName); + // console.warn( + // `Missing theme color: ${colorName}. Falling back to default ${colorVal}`, + // ); + } + + localStorage.setItem(colorName, colorVal); + for (const cssVar of settings.vars) { + document.body.style.setProperty(cssVar, colorVal); + document.documentElement.style.setProperty(cssVar, colorVal); + } + }); + + return missingColors; +}; + +export const setDocumentStylesFromLocalStorage = (checkCache: boolean) => { + for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) { + for (const cssVar of themeVals.vars) { + // Get cached values (for non-vscode IDEs) + if (checkCache) { + const cached = localStorage.getItem(colorName); + if (cached) { + document.body.style.setProperty(cssVar, cached); + } + } + } + } +}; + +export const clearThemeLocalCache = () => { + for (const colorName of Object.keys(THEME_COLORS)) { + localStorage.removeItem(colorName); + } +}; diff --git a/gui/src/styles/utils.ts b/gui/src/styles/utils.ts new file mode 100644 index 000000000..a46860ac4 --- /dev/null +++ b/gui/src/styles/utils.ts @@ -0,0 +1,45 @@ +export function parseHexColor(hexColor: string): { + r: number; + g: number; + b: number; +} { + if (hexColor.startsWith("#")) { + hexColor = hexColor.slice(1); + } + + if (hexColor.length > 6) { + hexColor = hexColor.slice(0, 6); + } + + const r = parseInt(hexColor.substring(0, 2), 16); + const g = parseInt(hexColor.substring(2, 4), 16); + const b = parseInt(hexColor.substring(4, 6), 16); + + return { r, g, b }; +} + +export function parseColorForHex(colorVar: string): string { + const value = getComputedStyle(document.documentElement).getPropertyValue( + colorVar, + ); + if (value.startsWith("#")) { + return value.slice(0, 7); + } + + // Parse rgb/rgba + const rgbValues = value + .slice(value.startsWith("rgba") ? 5 : 4, -1) + .split(",") + .map((x) => x.trim()) + .filter((_, i) => i < 3) // Only take the first 3 values (RGB, ignore alpha) + .map((x) => parseInt(x, 10)); + + let hex = + "#" + + rgbValues + .map((x) => x.toString(16)) + .map((x) => (x.length === 1 ? "0" + x : x)) + .join(""); + + return hex; +} diff --git a/gui/src/util/navigation.ts b/gui/src/util/navigation.ts index 0f145b6cd..44ef9a9ee 100644 --- a/gui/src/util/navigation.ts +++ b/gui/src/util/navigation.ts @@ -2,5 +2,6 @@ export const ROUTES = { HOME: "/", CONFIG: "/config", + THEME: "/theme", // EXAMPLE_ROUTE_WITH_PARAMS: (params: ParamsType) => `/route/${params}`, }; diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index 941429d2e..ed91cee11 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -1,5 +1,6 @@ /** @type {import('tailwindcss').Config} */ const defaultTheme = require("tailwindcss/defaultTheme"); +const { varWithFallback, THEME_COLORS } = require("./src/styles/theme"); module.exports = { content: [ @@ -29,25 +30,75 @@ module.exports = { default: "5px", }, colors: { - lightgray: "#999998", - "vsc-input-background": "var(--vscode-input-background, rgb(45 45 45))", - "vsc-background": "var(--vscode-sideBar-background, rgb(30 30 30))", - "vsc-foreground": "var(--vscode-editor-foreground, #fff)", - "vsc-editor-background": - "var(--vscode-editor-background, var(--vscode-sideBar-background, rgb(30 30 30)))", - "vsc-input-border": "var(--vscode-input-border, #999998)", - "vsc-commandCenter-inactiveBorder": - "var(--vscode-commandCenter-inactiveBorder, #999998)", + background: varWithFallback("background"), + foreground: varWithFallback("foreground"), + editor: { + DEFAULT: varWithFallback("editor-background"), + foreground: varWithFallback("editor-foreground"), + }, + primary: { + DEFAULT: varWithFallback("primary-background"), + foreground: varWithFallback("primary-foreground"), + hover: varWithFallback("primary-hover"), + }, + secondary: { + DEFAULT: varWithFallback("secondary-background"), + foreground: varWithFallback("secondary-foreground"), + hover: varWithFallback("secondary-hover"), + }, + border: { + DEFAULT: varWithFallback("border"), + focus: varWithFallback("border-focus"), + }, + command: { + DEFAULT: varWithFallback("command-background"), + foreground: varWithFallback("command-foreground"), + border: { + DEFAULT: varWithFallback("command-border"), + focus: varWithFallback("command-border-focus"), + }, + }, + description: { + DEFAULT: varWithFallback("description"), + muted: varWithFallback("description-muted"), + }, + input: { + DEFAULT: varWithFallback("input-background"), + foreground: varWithFallback("input-foreground"), + border: varWithFallback("input-border"), + placeholder: varWithFallback("input-placeholder"), + }, + table: { + oddRow: varWithFallback("table-oddRow"), + }, + badge: { + DEFAULT: varWithFallback("badge-background"), + foreground: varWithFallback("badge-foreground"), + }, + success: varWithFallback("success"), + warning: varWithFallback("warning"), + error: varWithFallback("error"), + link: varWithFallback("link"), + accent: varWithFallback("accent"), + findMatch: { + DEFAULT: THEME_COLORS["find-match"].default, + selected: varWithFallback("find-match-selected"), + }, + list: { + hover: varWithFallback("list-hover"), + active: { + DEFAULT: varWithFallback("list-active"), + foreground: varWithFallback("list-active-foreground"), + }, + }, - // Starting to make things less vsc-specific - // TODO make it all non-IDE-specific naming - "find-match-selected": - "var(--vscode-editor-findMatchHighlightBackground, rgba(255, 223, 0))", - "table-odd-rows":"var(--vscode-tree-tableOddRowsBackground, #1bbe84)", - "list-active": "var(--vscode-list-activeSelectionBackground, #1bbe84)", - "list-active-foreground": - "var(--vscode-quickInputList-focusForeground, var(--vscode-editor-foreground))", - badge: "var(--vscode-badge-background, #1bbe84)", + // DEPRECATED, slowly remove usages of these ide-named or explicit colors + lightgray: "#999998", // use border, description, or description-muted instead - AVOID + "vsc-input-background": varWithFallback("input-background"), // use "input-background" instead + "vsc-background": varWithFallback("background"), // use "background" instead + "vsc-foreground": varWithFallback("editor-foreground"), // use "foreground" instead + "vsc-editor-background": varWithFallback("editor-background"), // use "editor" instead + "vsc-input-border": varWithFallback("input-border"), // use "input-border" instead }, }, },