Merge branch 'main' into rich-llm-logging
This commit is contained in:
commit
6e54e7f612
23 changed files with 241 additions and 179 deletions
1
.node-version
Normal file
1
.node-version
Normal file
|
|
@ -0,0 +1 @@
|
|||
20.11.0
|
||||
|
|
@ -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,21 @@ export function slashFromCustomCommand(
|
|||
{ input },
|
||||
);
|
||||
} else {
|
||||
renderedPrompt = customCommand.prompt + "\n\n" + input;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export async function renderPromptFileV2(
|
|||
rawContent: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<[ContextItem[], string]> {
|
||||
const [preamble, body] = getPreambleAndBody(rawContent);
|
||||
const [_, body] = getPreambleAndBody(rawContent);
|
||||
|
||||
const contextItemsPromises: Promise<ContextItem[]>[] = [];
|
||||
const renderedBody = body.replace(/@([^\s]+)/g, (match, name) => {
|
||||
|
|
@ -75,6 +75,10 @@ export async function renderPromptFileV2(
|
|||
});
|
||||
|
||||
const contextItems = (await Promise.all(contextItemsPromises)).flat();
|
||||
const renderedPrompt =
|
||||
contextItems.map((item) => item.content).join("\n\n") +
|
||||
"\n\n" +
|
||||
renderedBody;
|
||||
|
||||
return [contextItems, renderedBody];
|
||||
return [contextItems, renderedPrompt];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 <kbd>cmd/ctrl</kbd> + <kbd>L</kbd> to select it in the Continue sidebar.
|
||||
|
||||
Then, type <kbd>/</kbd> 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).
|
||||
97
docs/docs/customize/deep-dives/prompts.md
Normal file
97
docs/docs/customize/deep-dives/prompts.md
Normal file
|
|
@ -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 <kbd>/</kbd>, 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.
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||

|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -45,13 +45,15 @@ import TabItem from "@theme/TabItem";
|
|||
"apiBase": "https://codestral.mistral.ai/v1"
|
||||
}
|
||||
],
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Codestral",
|
||||
"provider": "mistral",
|
||||
"model": "codestral-latest",
|
||||
"apiKey": "<YOUR_CODESTRAL_API_KEY>",
|
||||
"apiBase": "https://codestral.mistral.ai/v1"
|
||||
}
|
||||
"tabAutocompleteModel": [
|
||||
{
|
||||
"title": "Codestral",
|
||||
"provider": "mistral",
|
||||
"model": "codestral-latest",
|
||||
"apiKey": "<YOUR_CODESTRAL_API_KEY>",
|
||||
"apiBase": "https://codestral.mistral.ai/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
|
|
|
|||
|
|
@ -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/prompts.md). The `config.yaml` spec for `prompts` can be found [here](../../reference.md#prompts).
|
||||
|
||||
## Data
|
||||
|
||||
|
|
|
|||
|
|
@ -474,7 +474,8 @@ models:
|
|||
- name: qwen2.5-coder-7b
|
||||
<<: *model_defaults
|
||||
model: qwen2.5-coder-7b
|
||||
useLegacyCompletionsEndpoint: false
|
||||
env:
|
||||
useLegacyCompletionsEndpoint: false
|
||||
roles:
|
||||
- autocomplete
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -489,6 +489,10 @@ const config = {
|
|||
to: "/getting-started/install",
|
||||
from: "/getting-started",
|
||||
},
|
||||
{
|
||||
to: "/customize/deep-dives/prompts",
|
||||
from: "/customize/deep-dives/prompt-files",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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` 定制斜杠命令
|
||||
|
|
|
|||
|
|
@ -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 创建一个拉取请求!
|
||||
|
|
|
|||
54
gui/package-lock.json
generated
54
gui/package-lock.json
generated
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ export default defineConfig({
|
|||
build: {
|
||||
// Change the output .js filename to not include a hash
|
||||
rollupOptions: {
|
||||
// external: ["vscode-webview"],
|
||||
input: {
|
||||
index: resolve(__dirname, "index.html"),
|
||||
indexConsole: resolve(__dirname, "indexConsole.html"),
|
||||
|
|
|
|||
|
|
@ -5,27 +5,58 @@
|
|||
# - 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..."
|
||||
# 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" &> /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."
|
||||
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."
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue