Skip to content

Commit 6e54e7f

Browse files
Merge branch 'main' into rich-llm-logging
2 parents 25ee72e + de2921d commit 6e54e7f

23 files changed

+242
-180
lines changed

Diff for: .node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.11.0

Diff for: core/commands/index.ts

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CustomCommand, SlashCommand, SlashCommandDescription } from "../";
22
import { renderTemplatedString } from "../promptFiles/v1/renderTemplatedString";
33
import { replaceSlashCommandWithPromptInChatHistory } from "../promptFiles/v1/updateChatHistory";
4+
import { renderPromptFileV2 } from "../promptFiles/v2/renderPromptFile";
45
import { renderChatMessage } from "../util/messageContent";
56

67
import SlashCommands from "./slash";
@@ -15,7 +16,16 @@ export function slashFromCustomCommand(
1516
name: commandName,
1617
description: customCommand.description ?? "",
1718
prompt: customCommand.prompt,
18-
run: async function* ({ input, llm, history, ide, completionOptions }) {
19+
run: async function* ({
20+
input,
21+
llm,
22+
history,
23+
ide,
24+
completionOptions,
25+
config,
26+
selectedCode,
27+
fetch,
28+
}) {
1929
// Render prompt template
2030
let renderedPrompt: string;
2131
if (customCommand.prompt.includes("{{{ input }}}")) {
@@ -25,7 +35,21 @@ export function slashFromCustomCommand(
2535
{ input },
2636
);
2737
} else {
28-
renderedPrompt = customCommand.prompt + "\n\n" + input;
38+
const renderedPromptFile = await renderPromptFileV2(
39+
customCommand.prompt,
40+
{
41+
config,
42+
llm,
43+
ide,
44+
selectedCode,
45+
fetch,
46+
fullInput: input,
47+
embeddingsProvider: config.modelsByRole.embed[0],
48+
reranker: config.modelsByRole.rerank[0],
49+
},
50+
);
51+
52+
renderedPrompt = renderedPromptFile[1];
2953
}
3054

3155
// Replaces slash command messages with the rendered prompt

Diff for: core/promptFiles/v1/slashCommandFromPromptFile.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ContinueSDK, SlashCommand } from "../..";
22
import { renderChatMessage } from "../../util/messageContent";
33
import { getLastNPathParts } from "../../util/uri";
44
import { parsePromptFileV1V2 } from "../v2/parsePromptFileV1V2";
5+
import { renderPromptFileV2 } from "../v2/renderPromptFile";
56

67
import { getContextProviderHelpers } from "./getContextProviderHelpers";
78
import { renderTemplatedString } from "./renderTemplatedString";
@@ -67,7 +68,17 @@ export function slashCommandFromPromptFileV1(
6768
context.llm.systemMessage = systemMessage;
6869

6970
const userInput = extractUserInput(context.input, name);
70-
const renderedPrompt = await renderPromptV1(prompt, context, userInput);
71+
const [_, renderedPrompt] = await renderPromptFileV2(prompt, {
72+
config: context.config,
73+
fullInput: userInput,
74+
embeddingsProvider: context.config.modelsByRole.embed[0],
75+
reranker: context.config.modelsByRole.rerank[0],
76+
llm: context.llm,
77+
ide: context.ide,
78+
selectedCode: context.selectedCode,
79+
fetch: context.fetch,
80+
});
81+
7182
const messages = replaceSlashCommandWithPromptInChatHistory(
7283
context.history,
7384
name,

Diff for: core/promptFiles/v2/renderPromptFile.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export async function renderPromptFileV2(
6666
rawContent: string,
6767
extras: ContextProviderExtras,
6868
): Promise<[ContextItem[], string]> {
69-
const [preamble, body] = getPreambleAndBody(rawContent);
69+
const [_, body] = getPreambleAndBody(rawContent);
7070

7171
const contextItemsPromises: Promise<ContextItem[]>[] = [];
7272
const renderedBody = body.replace(/@([^\s]+)/g, (match, name) => {
@@ -75,6 +75,10 @@ export async function renderPromptFileV2(
7575
});
7676

7777
const contextItems = (await Promise.all(contextItemsPromises)).flat();
78+
const renderedPrompt =
79+
contextItems.map((item) => item.content).join("\n\n") +
80+
"\n\n" +
81+
renderedBody;
7882

79-
return [contextItems, renderedBody];
83+
return [contextItems, renderedPrompt];
8084
}

Diff for: docs/docs/customize/context-providers.mdx

-5
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,6 @@ The [Model Context Protocol](https://modelcontextprotocol.io/introduction) is a
530530

531531
You'll then be able to type "@" and see "MCP" in the context providers dropdown.
532532

533-
### Prompt Files
534-
535-
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.
536-
537533
### `@Issue`
538534

539535
Reference the conversation in a GitHub issue.
@@ -883,7 +879,6 @@ You can override this query by setting the `issueQuery` parameter.
883879

884880
You can set the `maxResults` parameter to limit the number of results returned. The default is `50`.
885881

886-
887882
### `@Discord`
888883

889884
Reference the messages in a Discord channel.

Diff for: docs/docs/customize/deep-dives/prompt-files.md

-69
This file was deleted.

Diff for: docs/docs/customize/deep-dives/prompts.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Prompts
3+
---
4+
5+
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.
6+
7+
:::info
8+
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)
9+
:::
10+
11+
## Examples
12+
13+
Below are some examples to get you started.
14+
15+
### Security review
16+
17+
```text title="Security best practices review"
18+
@open - Review these files for the following security best practices:
19+
- Does the architecture follow security-by-design principles?
20+
- Are there potential security vulnerabilities in the system design?
21+
- Is sensitive data handled appropriately throughout the lifecycle?
22+
```
23+
24+
### Reference best practice guides
25+
26+
```text title="Redux best practices review"
27+
@https://redux.js.org/style-guide/
28+
@currentFile
29+
30+
Review this code for adherence to Redux best practices.
31+
```
32+
33+
### Pull in commonly used files for tasks
34+
35+
```text title="Generate a new TypeORM entity"
36+
@src/db/dataSource.ts @src/db/entity/SampleEntity.ts
37+
38+
Use these files to generate a new TypeORM entity based on the following requirements:
39+
```
40+
41+
## Including Context Providers in your prompts
42+
43+
Many [context providers](../context-providers.mdx) can be referenced by typing "@" followed by the name of the context provider. The currently supported list is:
44+
45+
- `@terminal` - The contents of the terminal
46+
- `@currentFile` - The currently active file
47+
- `@open` - All open files
48+
- `@os` - Information about the operating system
49+
- `@problems` - Problems reported by the language server in the active file
50+
- `@repo-map` - A map of files in the repository
51+
- `@tree` - A tree view of the repository structure
52+
53+
Or you can directly type URLs and file paths:
54+
55+
- `@https://github.com/continuedev/continue` - The contents of a URL
56+
- `@src/index.ts` - The contents of a file (VS Code only)
57+
58+
All references will be attached as context items, rather than injected directly inline.
59+
60+
## Local `.prompt` files
61+
62+
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.
63+
64+
### Quick Start
65+
66+
Below is a quick example of setting up a prompt file:
67+
68+
1. Create a folder called `.continue/prompts` at the top level of your workspace
69+
2. Add a file called `test.prompt` to this folder.
70+
3. Write the following contents to `test.prompt` and save.
71+
72+
```.prompt
73+
name: Current file prompt
74+
description: A test prompt using the current file context provider
75+
---
76+
@currentFile
77+
```
78+
79+
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".
80+
81+
### Format
82+
83+
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.
84+
85+
:::info
86+
The current state of this format is experimental and subject to change
87+
:::
88+
89+
### Preamble
90+
91+
The "preamble" is everything above the `---` separator, and lets you specify model parameters. It uses YAML syntax and currently supports the following parameters:
92+
93+
- `name` - The display title
94+
- `description` - The description you will see in the dropdown
95+
- `version` - Can be either "1" (for legacy prompt files) or "2" (this is the default and does not need to be set)
96+
97+
If you don't need any of these parameters, you can leave out the preamble and do not need to include the `---` separator.

Diff for: docs/docs/customize/deep-dives/slash-commands.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The easiest way to add a slash command is by adding [`prompt` blocks](../../hub/
2626

2727
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.
2828

29-
Learn more about prompt files [here](./prompt-files.md)
29+
Learn more about prompt files [here](./prompts.md)
3030

3131
### MCP Server prompts
3232

Diff for: docs/docs/customize/deep-dives/vscode-actions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To make common use cases even more accessible, we provide a handful of other way
1414

1515
## Quick actions
1616

17-
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.
17+
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.
1818

1919
![quick-actions](/img/quick-actions.png)
2020

Diff for: docs/docs/customize/tutorials/build-your-own-context-provider.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Then, create a server that responds to requests as are made from [HttpContextPro
5050
The `"options"` property can be used to send additional parameters to your endpoint, which will be included in the request body.
5151

5252
:::info
53-
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.
53+
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.
5454
:::
5555

5656
## Using CustomContextProvider

Diff for: docs/docs/customize/tutorials/build-your-own-slash-command.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Build your own slash command
33
---
44

55
:::info
6-
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.
6+
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.
77
:::
88

99
There are two ways to add custom slash commands:

Diff for: docs/docs/customize/tutorials/set-up-codestral.mdx

+9-7
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ import TabItem from "@theme/TabItem";
4545
"apiBase": "https://codestral.mistral.ai/v1"
4646
}
4747
],
48-
"tabAutocompleteModel": {
49-
"title": "Codestral",
50-
"provider": "mistral",
51-
"model": "codestral-latest",
52-
"apiKey": "<YOUR_CODESTRAL_API_KEY>",
53-
"apiBase": "https://codestral.mistral.ai/v1"
54-
}
48+
"tabAutocompleteModel": [
49+
{
50+
"title": "Codestral",
51+
"provider": "mistral",
52+
"model": "codestral-latest",
53+
"apiKey": "<YOUR_CODESTRAL_API_KEY>",
54+
"apiBase": "https://codestral.mistral.ai/v1"
55+
}
56+
]
5557
}
5658
```
5759
</TabItem>

Diff for: docs/docs/hub/blocks/block-types.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,7 @@ Learn more in the [rules deep dive](../../customize/deep-dives/rules.md), and vi
4141

4242
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.
4343

44-
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:
45-
46-
1. Currently, prompt blocks cannot use context providers
47-
2. Prompt blocks are stored within `config.yaml` rather than `.continue/prompts` in project directory and
48-
49-
The `config.yaml` spec for `prompts` can be found [here](../../reference.md#prompts).
44+
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).
5045

5146
## Data
5247

Diff for: docs/docs/reference.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ models:
474474
- name: qwen2.5-coder-7b
475475
<<: *model_defaults
476476
model: qwen2.5-coder-7b
477-
useLegacyCompletionsEndpoint: false
477+
env:
478+
useLegacyCompletionsEndpoint: false
478479
roles:
479480
- autocomplete
480481
```

Diff for: docs/docusaurus.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ const config = {
286286
],
287287
},
288288
{
289-
to: "/customize/deep-dives/prompt-files",
289+
to: "/customize/deep-dives/prompts",
290290
from: ["/walkthroughs/prompt-files", "/features/prompt-files"],
291291
},
292292
// TODO - actions redirects
@@ -489,6 +489,10 @@ const config = {
489489
to: "/getting-started/install",
490490
from: "/getting-started",
491491
},
492+
{
493+
to: "/customize/deep-dives/prompts",
494+
from: "/customize/deep-dives/prompt-files",
495+
},
492496
],
493497
},
494498
],

Diff for: docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Continue 有一个大的内置斜杠命令库,但是当你首次安装时,
1313

1414
有两种方法添加定制斜杠命令:
1515

16-
1. 使用 `.prompt` 文件 - 这是大多数情况下推荐的。[在这里](../customize/deep-dives/prompt-files.md) 查看完整参考。
16+
1. 使用 `.prompt` 文件 - 这是大多数情况下推荐的。[在这里](../customize/deep-dives/prompts.md) 查看完整参考。
1717
2. 使用 `config.ts` - 这给你对于 LLM, IDE 和其他重要的入口可编程的访问,通过编写 JavaScript/TypeScript 函数
1818

1919
### 使用 `config.ts` 定制斜杠命令

0 commit comments

Comments
 (0)