From c5e002b47520a99cf3e6582471a6dbc5736cb7a0 Mon Sep 17 00:00:00 2001 From: Diwakar Date: Fri, 4 Apr 2025 16:10:49 +0700 Subject: [PATCH 01/12] Update YAML reference docs with fix for useLegacyCompletionsEndpoint --- docs/docs/reference.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 735c89be3..757cfa13e 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -474,7 +474,8 @@ models: - name: qwen2.5-coder-7b <<: *model_defaults model: qwen2.5-coder-7b - useLegacyCompletionsEndpoint: false + env: + useLegacyCompletionsEndpoint: false roles: - autocomplete ``` From 048eaf803eb5a0ecbf046faa9b0c2cc2b9682c22 Mon Sep 17 00:00:00 2001 From: "T. Todua" <7117978+ttodua@users.noreply.github.com> Date: Fri, 4 Apr 2025 17:00:10 +0400 Subject: [PATCH 02/12] doc(ui) - support for array as noted here: https://github.com/continuedev/continue/issues/892#issuecomment-2178910959 it's now supported --- .../customize/tutorials/set-up-codestral.mdx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/docs/customize/tutorials/set-up-codestral.mdx b/docs/docs/customize/tutorials/set-up-codestral.mdx index 97ec3c981..1ace12f2f 100644 --- a/docs/docs/customize/tutorials/set-up-codestral.mdx +++ b/docs/docs/customize/tutorials/set-up-codestral.mdx @@ -45,13 +45,15 @@ import TabItem from "@theme/TabItem"; "apiBase": "https://codestral.mistral.ai/v1" } ], - "tabAutocompleteModel": { - "title": "Codestral", - "provider": "mistral", - "model": "codestral-latest", - "apiKey": "", - "apiBase": "https://codestral.mistral.ai/v1" - } + "tabAutocompleteModel": [ + { + "title": "Codestral", + "provider": "mistral", + "model": "codestral-latest", + "apiKey": "", + "apiBase": "https://codestral.mistral.ai/v1" + } + ] } ``` From 68325392f26722aad16bf9ae7c9a80708a3a5c67 Mon Sep 17 00:00:00 2001 From: Sherman Boyd Date: Sun, 6 Apr 2025 16:53:01 -0700 Subject: [PATCH 03/12] support fnm as well as nvm --- scripts/install-dependencies.sh | 69 ++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index c3262e66c..b5a420eab 100755 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -5,27 +5,60 @@ # - Debug -> Extension set -e -# Check if node version matches .nvmrc -if [ -f .nvmrc ]; then +# Set the correct Node version at the start of the script +setup_node_version() { + # Get required node version from .node-version or .nvmrc + if [ -f .node-version ]; then + required_node_version=$(cat .node-version) + elif [ -f .nvmrc ]; then required_node_version=$(cat .nvmrc) - current_node_version=$(node -v) - - # Remove 'v' prefix from versions for comparison - required_version=${required_node_version#v} - current_version=${current_node_version#v} + else + echo "No .node-version or .nvmrc file found. Skipping Node.js version check." + return + fi - if [ "$required_version" != "$current_version" ]; then - echo "⚠️ Warning: Your Node.js version ($current_node_version) does not match the required version ($required_node_version)" - echo "Please consider switching to the correct version using: nvm use" - - if [ -t 0 ]; then - read -p "Press Enter to continue with installation anyway..." - else - echo "Continuing with installation anyway..." - fi - echo + # Remove 'v' prefix if present + required_version=${required_node_version#v} + + # Try fnm first + if command -v fnm &> /dev/null; then + echo "📦 Using fnm to set Node.js version to $required_version..." + eval "$(fnm env --use-on-cd)" + fnm use "$required_version" || fnm use + # Then try nvm + elif command -v nvm &> /dev/null || [ -s "$NVM_DIR/nvm.sh" ]; then + echo "📦 Using nvm to set Node.js version to $required_version..." + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm + nvm use "$required_version" || nvm use + # Fall back to version check only + else + echo "Neither fnm nor nvm found. Proceeding with current Node.js version." + fi + + # Verify the current Node.js version after our attempt to set it + current_node_version=$(node -v) + current_version=${current_node_version#v} + + if [ "$required_version" != "$current_version" ]; then + echo "⚠️ Warning: Your Node.js version ($current_node_version) does not match the required version (v$required_version)" + echo "Even after attempting to use version managers, the correct version couldn't be activated." + echo "Please consider switching to the correct version using: `nvm use` or `fnm use` or setting " + echo "the correct version in a .nvmrc or .node-version file." + + if [ -t 0 ]; then + read -p "Press Enter to continue with installation anyway..." + else + echo "Continuing with installation anyway..." fi -fi + echo + else + echo "✅ Using Node.js $current_node_version as required." + fi +} + +# Run the node version setup +setup_node_version echo "Installing root-level dependencies..." npm install From b6f2f3905dc4d16249a69e50543bd8ce569563b6 Mon Sep 17 00:00:00 2001 From: Sherman Boyd Date: Sun, 6 Apr 2025 16:56:47 -0700 Subject: [PATCH 04/12] suppress output for fnm and nvm commands --- scripts/install-dependencies.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index b5a420eab..7120e8c5d 100755 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -23,14 +23,15 @@ setup_node_version() { # Try fnm first if command -v fnm &> /dev/null; then echo "📦 Using fnm to set Node.js version to $required_version..." - eval "$(fnm env --use-on-cd)" - fnm use "$required_version" || fnm use + # Capture output to avoid duplicate messages + eval "$(fnm env --use-on-cd)" &> /dev/null + fnm use "$required_version" &> /dev/null || fnm use &> /dev/null # Then try nvm elif command -v nvm &> /dev/null || [ -s "$NVM_DIR/nvm.sh" ]; then echo "📦 Using nvm to set Node.js version to $required_version..." export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm - nvm use "$required_version" || nvm use + nvm use "$required_version" &> /dev/null || nvm use &> /dev/null # Fall back to version check only else echo "Neither fnm nor nvm found. Proceeding with current Node.js version." @@ -43,9 +44,6 @@ setup_node_version() { if [ "$required_version" != "$current_version" ]; then echo "⚠️ Warning: Your Node.js version ($current_node_version) does not match the required version (v$required_version)" echo "Even after attempting to use version managers, the correct version couldn't be activated." - echo "Please consider switching to the correct version using: `nvm use` or `fnm use` or setting " - echo "the correct version in a .nvmrc or .node-version file." - if [ -t 0 ]; then read -p "Press Enter to continue with installation anyway..." else From 576978e8c9d747363d810f456995293d266aaedb Mon Sep 17 00:00:00 2001 From: Sherman Boyd Date: Sun, 6 Apr 2025 16:59:09 -0700 Subject: [PATCH 05/12] Add node version for fnm users --- .node-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .node-version diff --git a/.node-version b/.node-version new file mode 100644 index 000000000..18c284172 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +20.11.0 \ No newline at end of file From e5608a94e543cd8b66d68c222eacc82e8c021aff Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sun, 6 Apr 2025 19:58:47 -0700 Subject: [PATCH 06/12] feat: fix ctx providers w/ slash cmds --- core/commands/index.ts | 23 +++++++++++++++++-- .../v1/slashCommandFromPromptFile.ts | 13 ++++++++++- core/promptFiles/v2/renderPromptFile.ts | 10 +++++--- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/core/commands/index.ts b/core/commands/index.ts index 7115d22be..6837449ef 100644 --- a/core/commands/index.ts +++ b/core/commands/index.ts @@ -1,6 +1,7 @@ import { CustomCommand, SlashCommand, SlashCommandDescription } from "../"; import { renderTemplatedString } from "../promptFiles/v1/renderTemplatedString"; import { replaceSlashCommandWithPromptInChatHistory } from "../promptFiles/v1/updateChatHistory"; +import { renderPromptFileV2 } from "../promptFiles/v2/renderPromptFile"; import { renderChatMessage } from "../util/messageContent"; import SlashCommands from "./slash"; @@ -15,7 +16,16 @@ export function slashFromCustomCommand( name: commandName, description: customCommand.description ?? "", prompt: customCommand.prompt, - run: async function* ({ input, llm, history, ide, completionOptions }) { + run: async function* ({ + input, + llm, + history, + ide, + completionOptions, + config, + selectedCode, + fetch, + }) { // Render prompt template let renderedPrompt: string; if (customCommand.prompt.includes("{{{ input }}}")) { @@ -25,7 +35,16 @@ export function slashFromCustomCommand( { input }, ); } else { - renderedPrompt = customCommand.prompt + "\n\n" + input; + renderedPrompt = await renderPromptFileV2(customCommand.prompt, { + config, + llm, + ide, + selectedCode, + fetch, + fullInput: input, + embeddingsProvider: config.modelsByRole.embed[0], + reranker: config.modelsByRole.rerank[0], + }); } // Replaces slash command messages with the rendered prompt diff --git a/core/promptFiles/v1/slashCommandFromPromptFile.ts b/core/promptFiles/v1/slashCommandFromPromptFile.ts index 6abd4927f..cfe3d409a 100644 --- a/core/promptFiles/v1/slashCommandFromPromptFile.ts +++ b/core/promptFiles/v1/slashCommandFromPromptFile.ts @@ -2,6 +2,7 @@ import { ContinueSDK, SlashCommand } from "../.."; import { renderChatMessage } from "../../util/messageContent"; import { getLastNPathParts } from "../../util/uri"; import { parsePromptFileV1V2 } from "../v2/parsePromptFileV1V2"; +import { renderPromptFileV2 } from "../v2/renderPromptFile"; import { getContextProviderHelpers } from "./getContextProviderHelpers"; import { renderTemplatedString } from "./renderTemplatedString"; @@ -67,7 +68,17 @@ export function slashCommandFromPromptFileV1( context.llm.systemMessage = systemMessage; const userInput = extractUserInput(context.input, name); - const renderedPrompt = await renderPromptV1(prompt, context, userInput); + const renderedPrompt = await renderPromptFileV2(prompt, { + config: context.config, + fullInput: userInput, + embeddingsProvider: context.config.modelsByRole.embed[0], + reranker: context.config.modelsByRole.rerank[0], + llm: context.llm, + ide: context.ide, + selectedCode: context.selectedCode, + fetch: context.fetch, + }); + const messages = replaceSlashCommandWithPromptInChatHistory( context.history, name, diff --git a/core/promptFiles/v2/renderPromptFile.ts b/core/promptFiles/v2/renderPromptFile.ts index 1f08011a8..c13a3ef93 100644 --- a/core/promptFiles/v2/renderPromptFile.ts +++ b/core/promptFiles/v2/renderPromptFile.ts @@ -65,8 +65,8 @@ async function resolveAttachment( export async function renderPromptFileV2( rawContent: string, extras: ContextProviderExtras, -): Promise<[ContextItem[], string]> { - const [preamble, body] = getPreambleAndBody(rawContent); +) { + const [_, body] = getPreambleAndBody(rawContent); const contextItemsPromises: Promise[] = []; const renderedBody = body.replace(/@([^\s]+)/g, (match, name) => { @@ -76,5 +76,9 @@ export async function renderPromptFileV2( const contextItems = (await Promise.all(contextItemsPromises)).flat(); - return [contextItems, renderedBody]; + return ( + contextItems.map((item) => item.content).join("\n\n") + + "\n\n" + + renderedBody + ); } From 84df7f45bf91c70da79901c0a44cc3b156655f6f Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 7 Apr 2025 09:00:15 -0700 Subject: [PATCH 07/12] fix: return ctx items from prompt file --- core/commands/index.ts | 25 +++++++++++-------- .../v1/slashCommandFromPromptFile.ts | 2 +- core/promptFiles/v2/renderPromptFile.ts | 10 ++++---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/core/commands/index.ts b/core/commands/index.ts index 6837449ef..3037d7ef7 100644 --- a/core/commands/index.ts +++ b/core/commands/index.ts @@ -35,16 +35,21 @@ export function slashFromCustomCommand( { input }, ); } else { - renderedPrompt = await renderPromptFileV2(customCommand.prompt, { - config, - llm, - ide, - selectedCode, - fetch, - fullInput: input, - embeddingsProvider: config.modelsByRole.embed[0], - reranker: config.modelsByRole.rerank[0], - }); + const renderedPromptFile = await renderPromptFileV2( + customCommand.prompt, + { + config, + llm, + ide, + selectedCode, + fetch, + fullInput: input, + embeddingsProvider: config.modelsByRole.embed[0], + reranker: config.modelsByRole.rerank[0], + }, + ); + + renderedPrompt = renderedPromptFile[1]; } // Replaces slash command messages with the rendered prompt diff --git a/core/promptFiles/v1/slashCommandFromPromptFile.ts b/core/promptFiles/v1/slashCommandFromPromptFile.ts index cfe3d409a..fd0b48b2c 100644 --- a/core/promptFiles/v1/slashCommandFromPromptFile.ts +++ b/core/promptFiles/v1/slashCommandFromPromptFile.ts @@ -68,7 +68,7 @@ export function slashCommandFromPromptFileV1( context.llm.systemMessage = systemMessage; const userInput = extractUserInput(context.input, name); - const renderedPrompt = await renderPromptFileV2(prompt, { + const [_, renderedPrompt] = await renderPromptFileV2(prompt, { config: context.config, fullInput: userInput, embeddingsProvider: context.config.modelsByRole.embed[0], diff --git a/core/promptFiles/v2/renderPromptFile.ts b/core/promptFiles/v2/renderPromptFile.ts index c13a3ef93..4d52c7ba1 100644 --- a/core/promptFiles/v2/renderPromptFile.ts +++ b/core/promptFiles/v2/renderPromptFile.ts @@ -65,7 +65,7 @@ async function resolveAttachment( export async function renderPromptFileV2( rawContent: string, extras: ContextProviderExtras, -) { +): Promise<[ContextItem[], string]> { const [_, body] = getPreambleAndBody(rawContent); const contextItemsPromises: Promise[] = []; @@ -75,10 +75,10 @@ export async function renderPromptFileV2( }); const contextItems = (await Promise.all(contextItemsPromises)).flat(); - - return ( + const renderedPrompt = contextItems.map((item) => item.content).join("\n\n") + "\n\n" + - renderedBody - ); + renderedBody; + + return [contextItems, renderedPrompt]; } From 204aa51a944906fe629e92095a3f7f86113b9f6c Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 7 Apr 2025 10:11:43 -0700 Subject: [PATCH 08/12] feat: updated prompt docs --- .../docs/customize/deep-dives/prompt-files.md | 69 ------------- docs/docs/customize/deep-dives/prompts.md | 97 +++++++++++++++++++ docs/docs/hub/blocks/block-types.md | 7 +- docs/docusaurus.config.js | 4 + 4 files changed, 102 insertions(+), 75 deletions(-) delete mode 100644 docs/docs/customize/deep-dives/prompt-files.md create mode 100644 docs/docs/customize/deep-dives/prompts.md diff --git a/docs/docs/customize/deep-dives/prompt-files.md b/docs/docs/customize/deep-dives/prompt-files.md deleted file mode 100644 index 68995746f..000000000 --- a/docs/docs/customize/deep-dives/prompt-files.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: Prompt files ---- - -Prompt files allow you to build and use local prompts, and provide a convenient way to test and iterate on prompts before publishing them to the Hub. - -:::info -Visit the Hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=prompts) -::: - -## Quick start - -Below is a quick example of setting up a prompt file: - -1. Create a folder called `.continue/prompts` at the top level of your workspace (or you can use the button in the UI by typing @, selecting "Prompt Files", and selecting "New Prompt File"). -2. Add a file called `rails.prompt` to this folder. -3. Write the following contents to `rails.prompt` and save. - -```.prompt -name: Rails Project -description: Information about this project ---- -Attached is a summary of the current Ruby on Rails application, including the @Gemfile and database schema in @db/schema.rb -``` - -Now to use this prompt, you can highlight code and use cmd/ctrl + L to select it in the Continue sidebar. - -Then, type / and choose the "Rails Project" prompt. You can now ask any question as usual and the LLM will have the information from your .prompt file. - -## Format - -The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to reference files, URLs, and context providers. - -:::info -The current state of this format is experimental and subject to change -::: - -### Preamble - -The "preamble" is everything above the `---` separator, and lets you specify model parameters. It uses YAML syntax and currently supports the following parameters: - -- `name` - The display title -- `description` - The description you will see in the dropdown -- `version` - Can be either "1" (for legacy prompt files) or "2" (this is the default and does not need to be set) - -If you don't need any of these parameters, you can leave out the preamble and do not need to include the `---` separator. - -### Context - -Many [context provider](../context-providers.mdx) can be referenced by typing "@" followed by the name of the context provider. The currently supported list is: - -- `@terminal` - The contents of the terminal -- `@currentFile` - The currently active file -- `@open` - All open files -- `@os` - Information about the operating system -- `@problems` - Problems reported by the language server in the active file -- `@repo-map` - A map of files in the repository -- `@tree` - A tree view of the repository structure - -Or you can directly type URLs and file paths: - -- `@https://github.com/continuedev/continue` - The contents of a URL -- `@src/index.ts` - The contents of a file (VS Code only) - -All references will be attached as context items, rather than injected directly inline. - -## Feedback - -If you have ideas about how to improve the `.prompt` file format, please reach out on [Discord](https://discord.gg/NWtdYexhMs). diff --git a/docs/docs/customize/deep-dives/prompts.md b/docs/docs/customize/deep-dives/prompts.md new file mode 100644 index 000000000..1cd1c0085 --- /dev/null +++ b/docs/docs/customize/deep-dives/prompts.md @@ -0,0 +1,97 @@ +--- +title: Prompts +--- + +Prompts are reusable instructions that can be referenced at any time during chat. They are especially useful as context for repetitive and/or complex tasks. + +:::info +Visit the Hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=prompts) +::: + +## Examples + +Below are some examples to get you started. + +### Security review + +```text title="Security best practices review" +@open - Review these files for the following security best practices: +- Does the architecture follow security-by-design principles? +- Are there potential security vulnerabilities in the system design? +- Is sensitive data handled appropriately throughout the lifecycle? +``` + +### Reference best practice guides + +```text title="Redux best practices review" +@https://redux.js.org/style-guide/ +@currentFile + +Review this code for adherence to Redux best practices. +``` + +### Pull in commonly used files for tasks + +```text title="Generate a new TypeORM entity" +@src/db/dataSource.ts @src/db/entity/SampleEntity.ts + +Use these files to generate a new TypeORM entity based on the following requirements: +``` + +## Including Context Providers in your prompts + +Many [context providers](../context-providers.mdx) can be referenced by typing "@" followed by the name of the context provider. The currently supported list is: + +- `@terminal` - The contents of the terminal +- `@currentFile` - The currently active file +- `@open` - All open files +- `@os` - Information about the operating system +- `@problems` - Problems reported by the language server in the active file +- `@repo-map` - A map of files in the repository +- `@tree` - A tree view of the repository structure + +Or you can directly type URLs and file paths: + +- `@https://github.com/continuedev/continue` - The contents of a URL +- `@src/index.ts` - The contents of a file (VS Code only) + +All references will be attached as context items, rather than injected directly inline. + +## Local `.prompt` files + +In addition to Prompt blocks on the Hub, you can also define prompts in local `.prompt` files, located in the `.continue/prompts` folder at the top level of your workspace. This is useful for quick iteration on prompts to test them out before pushing up to the Hub. + +### Quick Start + +Below is a quick example of setting up a prompt file: + +1. Create a folder called `.continue/prompts` at the top level of your workspace +2. Add a file called `test.prompt` to this folder. +3. Write the following contents to `test.prompt` and save. + +```.prompt +name: Current file prompt +description: A test prompt using the current file context provider +--- +@currentFile +``` + +Now to use this prompt, you can open Chat, type /, select the prompt, and add type out some additional text such as "Review the code for any issues". + +### Format + +The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to reference files, URLs, and context providers. + +:::info +The current state of this format is experimental and subject to change +::: + +### Preamble + +The "preamble" is everything above the `---` separator, and lets you specify model parameters. It uses YAML syntax and currently supports the following parameters: + +- `name` - The display title +- `description` - The description you will see in the dropdown +- `version` - Can be either "1" (for legacy prompt files) or "2" (this is the default and does not need to be set) + +If you don't need any of these parameters, you can leave out the preamble and do not need to include the `---` separator. diff --git a/docs/docs/hub/blocks/block-types.md b/docs/docs/hub/blocks/block-types.md index 0c2698542..2cc58ee5f 100644 --- a/docs/docs/hub/blocks/block-types.md +++ b/docs/docs/hub/blocks/block-types.md @@ -41,12 +41,7 @@ Learn more in the [rules deep dive](../../customize/deep-dives/rules.md), and vi Prompts blocks are pre-written, reusable prompts that can be referenced at any time during chat. They are especially useful as context for repetitive and/or complex tasks. [Explore prompts](https://hub.continue.dev/explore/prompts) on the hub. -Prompt blocks have the same syntax as [prompt files](../../customize/deep-dives/prompt-files.md). There are two important differences between prompt blocks and prompt files: - -1. Currently, prompt blocks cannot use context providers -2. Prompt blocks are stored within `config.yaml` rather than `.continue/prompts` in project directory and - -The `config.yaml` spec for `prompts` can be found [here](../../reference.md#prompts). +Prompt blocks have the same syntax as [prompt files](../../customize/deep-dives/prompt-files.md). The `config.yaml` spec for `prompts` can be found [here](../../reference.md#prompts). ## Data diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index c74e6a71b..be943b8f9 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -489,6 +489,10 @@ const config = { to: "/getting-started/install", from: "/getting-started", }, + { + to: "/customize/deep-dives/prompt-files", + from: "/customize/deep-dives/prompts", + }, ], }, ], From 3e1e0ea9bdfe2aebf4e222b21f8348001e1bc8cb Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 7 Apr 2025 10:40:55 -0700 Subject: [PATCH 09/12] Update editorConfig.ts --- .../TipTapEditor/utils/editorConfig.ts | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts index 8addede87..e50769ac8 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts @@ -1,4 +1,4 @@ -import { Editor } from "@tiptap/core"; +import { Editor, JSONContent } from "@tiptap/core"; import Document from "@tiptap/extension-document"; import History from "@tiptap/extension-history"; import Image from "@tiptap/extension-image"; @@ -48,6 +48,28 @@ export function getPlaceholderText( : "Ask a follow-up"; } +/** + * Checks if the editor content is valid for submission. + * A valid submission can contain either text content or prompt/code blocks + * + * @param json The editor JSON content + * @returns true if the content is valid for submission, false otherwise + */ +export function hasValidEditorContent(json: JSONContent): boolean { + // Check for prompt or code blocks + const hasPromptOrCodeBlock = json.content?.some( + (c) => + c.type === ContinueExtensions.PromptBlock.name || + c.type === ContinueExtensions.CodeBlock.name, + ); + + // Check for text content + const hasTextContent = json.content?.some((c) => c.content); + + // Content is valid if it has either text or special blocks + return hasTextContent || hasPromptOrCodeBlock || false; +} + /** * This function is called only once, so we need to use refs to pass in the latest values */ @@ -367,8 +389,8 @@ export function createEditorConfig(options: { const json = editor.getJSON(); - // Don't do anything if input box is empty - if (!json.content?.some((c) => c.content)) { + // Don't do anything if input box doesn't have valid content + if (!hasValidEditorContent(json)) { return; } From 66345e83550a898cd36eae67a68fb020ce957677 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 7 Apr 2025 10:52:56 -0700 Subject: [PATCH 10/12] feat: fix broken links --- docs/docs/customize/context-providers.mdx | 5 ----- docs/docs/customize/deep-dives/slash-commands.mdx | 2 +- docs/docs/customize/deep-dives/vscode-actions.md | 2 +- .../customize/tutorials/build-your-own-context-provider.mdx | 2 +- .../docs/customize/tutorials/build-your-own-slash-command.md | 2 +- docs/docs/hub/blocks/block-types.md | 2 +- .../current/actions/how-to-customize.md | 2 +- .../current/actions/how-to-use-it.md | 2 +- 8 files changed, 7 insertions(+), 12 deletions(-) diff --git a/docs/docs/customize/context-providers.mdx b/docs/docs/customize/context-providers.mdx index b31deedf4..204f680f0 100644 --- a/docs/docs/customize/context-providers.mdx +++ b/docs/docs/customize/context-providers.mdx @@ -530,10 +530,6 @@ The [Model Context Protocol](https://modelcontextprotocol.io/introduction) is a You'll then be able to type "@" and see "MCP" in the context providers dropdown. -### Prompt Files - -See [Prompt Files](./deep-dives/prompt-files.md). Prompt files are not added directly to the config file; prompt files are parsed and injected into the config automatically, to be used like other context providers. - ### `@Issue` Reference the conversation in a GitHub issue. @@ -883,7 +879,6 @@ You can override this query by setting the `issueQuery` parameter. You can set the `maxResults` parameter to limit the number of results returned. The default is `50`. - ### `@Discord` Reference the messages in a Discord channel. diff --git a/docs/docs/customize/deep-dives/slash-commands.mdx b/docs/docs/customize/deep-dives/slash-commands.mdx index 0c9796768..059cf8213 100644 --- a/docs/docs/customize/deep-dives/slash-commands.mdx +++ b/docs/docs/customize/deep-dives/slash-commands.mdx @@ -26,7 +26,7 @@ The easiest way to add a slash command is by adding [`prompt` blocks](../../hub/ It is also possible to write your own slash command by defining a “.prompt file.” Prompt files can be as simple as a text file, but also include templating so that you can refer to files, URLs, highlighted code, and more. -Learn more about prompt files [here](./prompt-files.md) +Learn more about prompt files [here](./prompts.md) ### MCP Server prompts diff --git a/docs/docs/customize/deep-dives/vscode-actions.md b/docs/docs/customize/deep-dives/vscode-actions.md index 0c0cdd1f1..d9f1b7b66 100644 --- a/docs/docs/customize/deep-dives/vscode-actions.md +++ b/docs/docs/customize/deep-dives/vscode-actions.md @@ -14,7 +14,7 @@ To make common use cases even more accessible, we provide a handful of other way ## Quick actions -Quick Actions are displayed as buttons above top-level classes and functions in your source code, letting you invoke actions with one click. They will edit that class or function, but nothing outside of it. They can also be customized with [.prompt files](./prompt-files.md) to perform custom actions. +Quick Actions are displayed as buttons above top-level classes and functions in your source code, letting you invoke actions with one click. They will edit that class or function, but nothing outside of it. They can also be customized with [.prompt files](./prompts.md) to perform custom actions. ![quick-actions](/img/quick-actions.png) diff --git a/docs/docs/customize/tutorials/build-your-own-context-provider.mdx b/docs/docs/customize/tutorials/build-your-own-context-provider.mdx index 7710a84c2..1494680c0 100644 --- a/docs/docs/customize/tutorials/build-your-own-context-provider.mdx +++ b/docs/docs/customize/tutorials/build-your-own-context-provider.mdx @@ -50,7 +50,7 @@ Then, create a server that responds to requests as are made from [HttpContextPro The `"options"` property can be used to send additional parameters to your endpoint, which will be included in the request body. :::info -The following methods for creating custom context providers are deprecated. We recommend using HTTP context providers, [MCP Servers](../context-providers.mdx#model-context-protocol), and [Prompt files](../deep-dives/prompt-files.md) where possible. +The following methods for creating custom context providers are deprecated. We recommend using HTTP context providers, [MCP Servers](../context-providers.mdx#model-context-protocol), and [Prompts](../deep-dives/prompts.md) where possible. ::: ## Using CustomContextProvider diff --git a/docs/docs/customize/tutorials/build-your-own-slash-command.md b/docs/docs/customize/tutorials/build-your-own-slash-command.md index 27b0517b3..03543a22f 100644 --- a/docs/docs/customize/tutorials/build-your-own-slash-command.md +++ b/docs/docs/customize/tutorials/build-your-own-slash-command.md @@ -3,7 +3,7 @@ title: Build your own slash command --- :::info -Slash commands can currently only be added using [`config.json`](../../json-reference.md) or `config.ts`. The [`YAML Config Format`](../../reference.md) is the new and preferred format. We recommend looking into [Prompt Files](../deep-dives/prompt-files.md) to achieve similar functionality. +Slash commands can currently only be added using [`config.json`](../../json-reference.md) or `config.ts`. The [`YAML Config Format`](../../reference.md) is the new and preferred format. We recommend looking into [Prompt Files](../deep-dives/prompts.md) to achieve similar functionality. ::: There are two ways to add custom slash commands: diff --git a/docs/docs/hub/blocks/block-types.md b/docs/docs/hub/blocks/block-types.md index 2cc58ee5f..b9c5bbd13 100644 --- a/docs/docs/hub/blocks/block-types.md +++ b/docs/docs/hub/blocks/block-types.md @@ -41,7 +41,7 @@ Learn more in the [rules deep dive](../../customize/deep-dives/rules.md), and vi Prompts blocks are pre-written, reusable prompts that can be referenced at any time during chat. They are especially useful as context for repetitive and/or complex tasks. [Explore prompts](https://hub.continue.dev/explore/prompts) on the hub. -Prompt blocks have the same syntax as [prompt files](../../customize/deep-dives/prompt-files.md). The `config.yaml` spec for `prompts` can be found [here](../../reference.md#prompts). +Prompt blocks have the same syntax as [prompt files](../../customize/deep-dives/prompts.md). The `config.yaml` spec for `prompts` can be found [here](../../reference.md#prompts). ## Data diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md index 2ffc4d0f2..d3c1097e7 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md @@ -13,7 +13,7 @@ Continue 有一个大的内置斜杠命令库,但是当你首次安装时, 有两种方法添加定制斜杠命令: -1. 使用 `.prompt` 文件 - 这是大多数情况下推荐的。[在这里](../customize/deep-dives/prompt-files.md) 查看完整参考。 +1. 使用 `.prompt` 文件 - 这是大多数情况下推荐的。[在这里](../customize/deep-dives/prompts.md) 查看完整参考。 2. 使用 `config.ts` - 这给你对于 LLM, IDE 和其他重要的入口可编程的访问,通过编写 JavaScript/TypeScript 函数 ### 使用 `config.ts` 定制斜杠命令 diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-use-it.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-use-it.md index f265a9885..a0d4c0023 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-use-it.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-use-it.md @@ -24,7 +24,7 @@ Actions 是常见用例的快捷方式。例如,你可能想要审查代码, 通过定义一个 ".prompt 文件" ,也可以编写你自己的斜杠命令。 prompt 文件可以是个简单的文本文件,但是也包含模板,所以你可以引用文件, URL ,高亮代码以及更多。 -完整的 .prompt 文件可以参考 [这里](../customize/deep-dives/prompt-files.md) 。 +完整的 .prompt 文件可以参考 [这里](../customize/deep-dives/prompt.md) 。 :::tip[Prompt 库] 为了帮助你开始,[我们精心编写了一个小的 `.prompt` 文件库](https://github.com/continuedev/prompt-file-examples) 。我们鼓励社区贡献到这个仓库,所以请考虑为你的 prompt 创建一个拉取请求! From 945bd7b7e84263dec705f677cdbe01a09e95f2d5 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 7 Apr 2025 10:57:21 -0700 Subject: [PATCH 11/12] Update docusaurus.config.js --- docs/docusaurus.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index be943b8f9..06e717ad7 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -286,7 +286,7 @@ const config = { ], }, { - to: "/customize/deep-dives/prompt-files", + to: "/customize/deep-dives/prompts", from: ["/walkthroughs/prompt-files", "/features/prompt-files"], }, // TODO - actions redirects @@ -490,8 +490,8 @@ const config = { from: "/getting-started", }, { - to: "/customize/deep-dives/prompt-files", - from: "/customize/deep-dives/prompts", + to: "/customize/deep-dives/prompts", + from: "/customize/deep-dives/prompt-files", }, ], }, From eeaf3ba6434d6c48d9a55ea1122c4a1f074ed607 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 7 Apr 2025 12:39:09 -0700 Subject: [PATCH 12/12] remove vscode-webview package --- gui/package-lock.json | 54 +-------------------------------- gui/package.json | 4 +-- gui/src/context/IdeMessenger.ts | 1 - gui/vite.config.ts | 1 - 4 files changed, 2 insertions(+), 58 deletions(-) diff --git a/gui/package-lock.json b/gui/package-lock.json index df7ea183b..69c571f84 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -25,7 +25,6 @@ "@tiptap/starter-kit": "^2.1.13", "@tiptap/suggestion": "^2.1.13", "@types/uuid": "^10.0.0", - "@types/vscode-webview": "^1.57.1", "clsx": "^2.1.1", "core": "file:../core", "dompurify": "^3.0.6", @@ -63,8 +62,7 @@ "tailwind-merge": "^3.0.2", "tippy.js": "^6.3.7", "unist-util-visit": "^5.0.0", - "uuid": "^9.0.1", - "vscode-webview": "^1.0.1-beta.1" + "uuid": "^9.0.1" }, "devDependencies": { "@swc/cli": "^0.3.14", @@ -3237,11 +3235,6 @@ "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz", "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==" }, - "node_modules/@types/vscode-webview": { - "version": "1.57.5", - "resolved": "https://registry.npmjs.org/@types/vscode-webview/-/vscode-webview-1.57.5.tgz", - "integrity": "sha512-iBAUYNYkz+uk1kdsq05fEcoh8gJmwT3lqqFPN7MGyjQ3HVloViMdo7ZJ8DFIP8WOK74PjOEilosqAyxV2iUFUw==" - }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.16.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.16.0.tgz", @@ -5960,19 +5953,6 @@ "url": "https://github.com/sponsors/rawify" } }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -6176,11 +6156,6 @@ "url": "https://github.com/sindresorhus/got?sponsor=1" } }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" - }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -7667,17 +7642,6 @@ "node": ">=6" } }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -12180,14 +12144,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/update-browserslist-db": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", @@ -13429,14 +13385,6 @@ } } }, - "node_modules/vscode-webview": { - "version": "1.0.1-beta.1", - "resolved": "https://registry.npmjs.org/vscode-webview/-/vscode-webview-1.0.1-beta.1.tgz", - "integrity": "sha512-8H2icqlb93qIvZs7Me/0sALMqJrX2e2W7JVE0mfK8exUPETP9Bmg+feivaByd1Xbg78lcKaNF9ZRrIFSenUVxQ==", - "dependencies": { - "fs-extra": "^10.0.0" - } - }, "node_modules/w3c-keyname": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", diff --git a/gui/package.json b/gui/package.json index fa4b439af..2d4ed109b 100644 --- a/gui/package.json +++ b/gui/package.json @@ -33,7 +33,6 @@ "@tiptap/starter-kit": "^2.1.13", "@tiptap/suggestion": "^2.1.13", "@types/uuid": "^10.0.0", - "@types/vscode-webview": "^1.57.1", "clsx": "^2.1.1", "core": "file:../core", "dompurify": "^3.0.6", @@ -71,8 +70,7 @@ "tailwind-merge": "^3.0.2", "tippy.js": "^6.3.7", "unist-util-visit": "^5.0.0", - "uuid": "^9.0.1", - "vscode-webview": "^1.0.1-beta.1" + "uuid": "^9.0.1" }, "devDependencies": { "@swc/cli": "^0.3.14", diff --git a/gui/src/context/IdeMessenger.ts b/gui/src/context/IdeMessenger.ts index c2e848446..4d0258efd 100644 --- a/gui/src/context/IdeMessenger.ts +++ b/gui/src/context/IdeMessenger.ts @@ -15,7 +15,6 @@ import { } from "core/protocol/util"; import { createContext } from "react"; import { v4 as uuidv4 } from "uuid"; -import "vscode-webview"; import { isJetBrains } from "../util"; interface vscode { diff --git a/gui/vite.config.ts b/gui/vite.config.ts index 6c5cd6d75..50c8d6495 100644 --- a/gui/vite.config.ts +++ b/gui/vite.config.ts @@ -8,7 +8,6 @@ export default defineConfig({ build: { // Change the output .js filename to not include a hash rollupOptions: { - // external: ["vscode-webview"], output: { entryFileNames: `assets/[name].js`, chunkFileNames: `assets/[name].js`,