diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 3daa2757e..85e94bbb2 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -56,7 +56,7 @@ function convertYamlRuleToContinueRule(rule: Rule): RuleWithSource { return { source: "rules-block", rule: rule.rule, - if: rule.if, + globs: rule.globs, name: rule.name, }; } diff --git a/core/edit/streamDiffLines.ts b/core/edit/streamDiffLines.ts index 38178e737..f88aeefc0 100644 --- a/core/edit/streamDiffLines.ts +++ b/core/edit/streamDiffLines.ts @@ -117,7 +117,6 @@ export async function* streamDiffLines({ ) as UserChatMessage | ToolResultChatMessage | undefined); const systemMessage = getSystemMessageWithRules({ - currentModel: llm.model, rules, userMessage: lastUserMessage, baseSystemMessage: undefined, diff --git a/core/index.d.ts b/core/index.d.ts index 877f308ae..b5cac75ae 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1,4 +1,8 @@ -import { DataDestination, ModelRole, PromptTemplates } from "@continuedev/config-yaml"; +import { + DataDestination, + ModelRole, + PromptTemplates, +} from "@continuedev/config-yaml"; import Parser from "web-tree-sitter"; import { LLMConfigurationStatuses } from "./llm/constants"; import { GetGhTokenArgs } from "./protocol/ide"; @@ -1502,7 +1506,7 @@ export interface RuleWithSource { | "rules-block" | "json-systemMessage" | ".continuerules"; - if?: string; + globs?: string | string[]; rule: string; description?: string; ruleFile?: string; diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index 972d5d9e3..11701feb8 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -12,7 +12,7 @@ import { isUserOrToolMsg } from "./messages"; import { getSystemMessageWithRules } from "./rules/getSystemMessageWithRules"; export const DEFAULT_CHAT_SYSTEM_MESSAGE_URL = - "https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts#L8"; + "https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts"; export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\ @@ -58,14 +58,10 @@ export const DEFAULT_CHAT_SYSTEM_MESSAGE = `\ of changes unless the user specifically asks for code only. `; -const CANCELED_TOOL_CALL_MESSAGE = - "This tool call was cancelled by the user. You should clarify next steps, as they don't wish for you to use this tool."; - export function constructMessages( history: ChatHistoryItem[], baseChatSystemMessage: string | undefined, rules: RuleWithSource[], - modelName: string, ): ChatMessage[] { const filteredHistory = history.filter( (item) => item.message.role !== "system", @@ -107,8 +103,8 @@ export function constructMessages( baseSystemMessage: baseChatSystemMessage ?? DEFAULT_CHAT_SYSTEM_MESSAGE, rules, userMessage: lastUserMsg, - currentModel: modelName, }); + if (systemMessage.trim()) { msgs.unshift({ role: "system", diff --git a/core/llm/rules/getSystemMessageWithRules.test.ts b/core/llm/rules/getSystemMessageWithRules.test.ts new file mode 100644 index 000000000..c1a7765ee --- /dev/null +++ b/core/llm/rules/getSystemMessageWithRules.test.ts @@ -0,0 +1,201 @@ +import { RuleWithSource, UserChatMessage } from "../.."; +import { getSystemMessageWithRules } from "./getSystemMessageWithRules"; + +describe("getSystemMessageWithRules", () => { + const baseSystemMessage = "Base system message"; + const tsRule: RuleWithSource = { + name: "TypeScript Rule", + rule: "Follow TypeScript best practices", + globs: "**/*.ts?(x)", + source: "rules-block", + }; + + // Rule without pattern (always active) + const generalRule: RuleWithSource = { + name: "General Rule", + rule: "Always write clear comments", + source: "rules-block", + }; + + // Rule with a different pattern + const pythonRule: RuleWithSource = { + name: "Python Rule", + rule: "Follow PEP 8 guidelines", + globs: "**/*.py", + source: "rules-block", + }; + + it("should not include pattern-matched rules when no file paths are mentioned", () => { + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [tsRule], + }); + + expect(result).toBe(baseSystemMessage); + }); + + it("should include general rules (without matches) regardless of file paths", () => { + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage: undefined, + rules: [generalRule], + }); + + expect(result).toBe(`${baseSystemMessage}\n\n${generalRule.rule}`); + }); + + it("should include only matching rules based on file paths", () => { + const userMessage: UserChatMessage = { + role: "user", + content: + "```tsx Component.tsx\nexport const Component = () =>
Hello
;\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [tsRule, pythonRule, generalRule], + }); + + // 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 multiple matching rules", () => { + const userMessage: UserChatMessage = { + role: "user", + content: + "```tsx Component.tsx\nexport const Component = () =>
Hello
;\n```\n```python test.py\nprint('hello')\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [tsRule, pythonRule, generalRule], + }); + + // 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 only general rules when no paths match pattern-specific rules", () => { + const userMessage: UserChatMessage = { + role: "user", + content: "```ruby test.rb\nputs 'hello'\n```", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [tsRule, pythonRule, generalRule], + }); + + // Should only include the general rule + const expected = `${baseSystemMessage}\n\n${generalRule.rule}`; + expect(result).toBe(expected); + }); + + it("should NOT match with comma-separated glob patterns", () => { + const userMessage: UserChatMessage = { + role: "user", + content: + "```ts src/main.ts\nconsole.log('hello');\n```\n```ts tests/example.test.ts\ntest('should work', () => {});\n```", + }; + + // Rule with comma-separated glob patterns + const commaRule: RuleWithSource = { + name: "TypeScript Standards", + rule: "Use TypeScript best practices for comma-separated globs", + globs: "src/**/*.ts, tests/**/*.ts", + source: "rules-block", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [commaRule], + }); + + // With the current implementation, the comma-separated pattern is treated as a single string, + // so it won't match any of the file paths (minimatch doesn't support comma-separated patterns) + expect(result).toBe(baseSystemMessage); + }); + + it("should match with an array of glob patterns", () => { + const userMessage: UserChatMessage = { + role: "user", + content: + "```ts src/main.ts\nconsole.log('hello');\n```\n```ts tests/example.test.ts\ntest('should work', () => {});\n```\n```ts config/settings.ts\nconst config = {};\n```", + }; + + // Rule with an array of glob patterns + const arrayGlobRule: RuleWithSource = { + name: "TypeScript Standards", + rule: "Use TypeScript best practices for array globs", + globs: ["src/**/*.ts", "tests/**/*.ts"], + source: "rules-block", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [arrayGlobRule], + }); + + // With our new implementation, the array of patterns should match both src/main.ts and tests/example.test.ts + expect(result).toBe(`${baseSystemMessage}\n\n${arrayGlobRule.rule}`); + }); + + it("should match only patterns in the array", () => { + const userMessage: UserChatMessage = { + role: "user", + content: + "```ts src/main.ts\nconsole.log('hello');\n```\n```ts config/settings.ts\nconst config = {};\n```", + }; + + // Rule with an array of glob patterns + const arrayGlobRule: RuleWithSource = { + name: "TypeScript Standards", + rule: "Use TypeScript best practices for array globs", + globs: ["src/**/*.ts", "tests/**/*.ts"], + source: "rules-block", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [arrayGlobRule], + }); + + // Should match src/main.ts but not config/settings.ts + expect(result).toBe(`${baseSystemMessage}\n\n${arrayGlobRule.rule}`); + }); + + it("should not match any when no patterns in the array match", () => { + const userMessage: UserChatMessage = { + role: "user", + content: + "```ts config/settings.ts\nconst config = {};\n```\n```ruby test.rb\nputs 'hello'\n```", + }; + + // Rule with an array of glob patterns + const arrayGlobRule: RuleWithSource = { + name: "TypeScript Standards", + rule: "Use TypeScript best practices for array globs", + globs: ["src/**/*.ts", "tests/**/*.ts"], + source: "rules-block", + }; + + const result = getSystemMessageWithRules({ + baseSystemMessage, + userMessage, + rules: [arrayGlobRule], + }); + + // Should not match any file paths + expect(result).toBe(baseSystemMessage); + }); +}); diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 6f3d48583..dacd941bb 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -1,32 +1,52 @@ +import { minimatch } from "minimatch"; import { RuleWithSource, ToolResultChatMessage, UserChatMessage } from "../.."; import { renderChatMessage } from "../../util/messageContent"; import { extractPathsFromCodeBlocks } from "../utils/extractPathsFromCodeBlocks"; -import { isRuleActive } from "./isRuleActive"; + +/** + * Checks if a path matches any of the provided globs + */ +const matchesGlobs = ( + path: string, + globs: string | string[] | undefined, +): boolean => { + if (!globs) return true; + + if (typeof globs === "string") { + return minimatch(path, globs); + } + + if (Array.isArray(globs)) { + return globs.some((glob) => minimatch(path, glob)); + } + + return false; +}; export const getSystemMessageWithRules = ({ baseSystemMessage, userMessage, rules, - currentModel, }: { baseSystemMessage?: string; userMessage: UserChatMessage | ToolResultChatMessage | undefined; rules: RuleWithSource[]; - currentModel: string; }) => { const filePathsFromMessage = userMessage ? extractPathsFromCodeBlocks(renderChatMessage(userMessage)) : []; let systemMessage = baseSystemMessage ?? ""; + for (const rule of rules) { - if ( - isRuleActive({ - rule, - activePaths: filePathsFromMessage, - currentModel, - }) - ) { + // 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) => + matchesGlobs(path, rule.globs), + ); + + if (hasNoGlobs || matchesAnyFilePath) { systemMessage += `\n\n${rule.rule}`; } } diff --git a/core/llm/rules/isRuleActive.test.ts b/core/llm/rules/isRuleActive.test.ts deleted file mode 100644 index 89e06e148..000000000 --- a/core/llm/rules/isRuleActive.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { RuleWithSource } from "../.."; -import { isRuleActive } from "./isRuleActive"; - -describe("isRuleActive", () => { - const rule: RuleWithSource = { - name: "My Rule", - rule: "Do no harm", - if: '${{ contains(current.model.model, "claude-3-7-sonnet") and glob("*.tsx") }}', - source: "rules-block", - }; - - it("should return false when activePaths is empty", () => { - expect( - isRuleActive({ - rule, - activePaths: [], - currentModel: "claude-3-7-sonnet", - }), - ).toBe(false); - }); - - it("should return false when no matching paths exist", () => { - expect( - isRuleActive({ - rule, - activePaths: ["test.py", "main.js"], - currentModel: "claude-3-7-sonnet", - }), - ).toBe(false); - }); - - it("should return true when both conditions are met", () => { - expect( - isRuleActive({ - rule, - activePaths: ["Component.tsx", "main.js"], - currentModel: "claude-3-7-sonnet", - }), - ).toBe(true); - }); - - it("should return false when only glob matches but model doesn't", () => { - expect( - isRuleActive({ - rule, - activePaths: ["Component.tsx"], - currentModel: "gpt-4", - }), - ).toBe(false); - }); - - it("should return false when model matches but glob doesn't", () => { - expect( - isRuleActive({ - rule, - activePaths: ["Component.ts"], - currentModel: "claude-3-7-sonnet", - }), - ).toBe(false); - }); -}); diff --git a/core/llm/rules/isRuleActive.ts b/core/llm/rules/isRuleActive.ts deleted file mode 100644 index 9c80f67ec..000000000 --- a/core/llm/rules/isRuleActive.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { compileExpression } from "filtrex"; -import { minimatch } from "minimatch"; -import { RuleWithSource } from "../.."; - -const TEMPLATE_VAR_REGEX = /^\$\{\{(\s*.*?\s*)\}\}$/; - -const createGlobFunction = (activePaths: string[]) => { - return (pattern: string) => { - const result = activePaths.some((path) => minimatch(path, pattern)); - return result; - }; -}; - -const contains = (str: string, searchStr: string): boolean => { - return str.includes(searchStr); -}; - -const evaluateIf = ({ - condition, - activePaths, - currentModel, -}: { - condition: string; - activePaths: string[]; - currentModel: string; -}) => { - const expression = condition.match(TEMPLATE_VAR_REGEX)?.[1]?.trim(); - if (!expression) { - return true; - } - - try { - const evaluate = compileExpression(expression, { - extraFunctions: { - glob: createGlobFunction(activePaths), - contains, - }, - constants: { - "current.model.model": currentModel, - }, - }); - - return evaluate({}); - } catch (error) { - console.error("Error evaluating rule condition:", error); - return false; - } -}; - -export const isRuleActive = ({ - rule, - activePaths, - currentModel, -}: { - rule: RuleWithSource; - activePaths: string[]; - currentModel: string; -}): boolean => { - if (rule.if) { - return evaluateIf({ condition: rule.if, activePaths, currentModel }); - } - - return true; -}; diff --git a/docs/docs/blocks/context-providers.md b/docs/docs/blocks/context-providers.md new file mode 100644 index 000000000..918ff3961 --- /dev/null +++ b/docs/docs/blocks/context-providers.md @@ -0,0 +1,21 @@ +--- +title: Context Blocks +sidebar_label: Context +description: Determine what internal information your AI assistant can access +keywords: [context, blocks, repositories, integration, knowledge base] +sidebar_position: 2 +--- + +These blocks determine what internal information your AI assistant can access: + +- **Connect to source repositories** and issues, CI/CD systems, wikis, and knowledge bases +- **Determine the scope** of what the AI can "see" when providing assistance +- **Customize** to match your specific development environment +- **Include proprietary code patterns** unique to your organization +- **Integrate data sources** to connect to any internal system with valuable context + +![Context Blocks Overview](/img/context-blocks-overview.png) + +## Learn More + +Learn more about context providers [here](../reference.md#context), and check out [this guide](../customize/tutorials/build-your-own-context-provider.mdx) to creating your own custom context provider. diff --git a/docs/docs/blocks/data.md b/docs/docs/blocks/data.md new file mode 100644 index 000000000..6e38e35e8 --- /dev/null +++ b/docs/docs/blocks/data.md @@ -0,0 +1,20 @@ +--- +title: Data Blocks +sidebar_label: Data +description: Help organizations capture and analyze AI assistant usage data +keywords: [data, blocks, analytics, metrics, storage, compliance] +sidebar_position: 7 +--- + +These help organizations capture and analyze AI assistant usage data: + +- **Analytics Integration**: Export metrics to observability platforms like Splunk or New Relic +- **Cloud Storage**: Store development data in S3/Azure Blob for model fine-tuning and auditing +- **Impact Measurement**: Track acceptance rates and productivity outcomes for ROI calculation +- **Compliance Reporting**: Generate audit trails for security and governance requirements + +![Data Blocks Overview](/img/data-blocks-overview.png) + +## Learn More + +You can read more about development data [here](../customize/deep-dives/development-data.md). Data destinations are configured in the [`data`](../reference.md#data) section of `config.yaml`. diff --git a/docs/docs/blocks/docs.md b/docs/docs/blocks/docs.md new file mode 100644 index 000000000..304a8c474 --- /dev/null +++ b/docs/docs/blocks/docs.md @@ -0,0 +1,19 @@ +--- +title: Docs Blocks +sidebar_label: Docs +description: Bring your documentation directly into the IDE +keywords: [docs, blocks, documentation, guidance, flow] +sidebar_position: 3 +--- + +This is how Continue brings your documentation directly into the IDE: + +- **Provide just-in-time guidance** without context switching +- **Reduce support burden** by making information discoverable +- **Keep developers in flow** by eliminating searches through multiple systems + +![Docs Blocks Overview](/img/docs-blocks-overview.png) + +## Learn More + +Learn more in the [@Docs deep dive](../customize/deep-dives/docs.mdx), and view [`docs`](../reference.md#docs) in the YAML Reference for more details. diff --git a/docs/docs/blocks/mcp.md b/docs/docs/blocks/mcp.md new file mode 100644 index 000000000..7201c4ac1 --- /dev/null +++ b/docs/docs/blocks/mcp.md @@ -0,0 +1,44 @@ +--- +title: MCP Blocks +--- + +title: MCP Blocks +sidebar_label: MCP +description: Model Context Protocol servers provide specialized functionality +keywords: [mcp, blocks, model context protocol, integrations, tools] +sidebar_position: 4 + +--- + +Model Context Protocol servers provide specialized functionality: + +- **Enable integration** with external tools and systems +- **Create extensible interfaces** for custom capabilities +- **Support complex interactions** with your development environment +- **Allow partners** to contribute specialized functionality +- **Connect to databases** to understand schema and data models during development + +![MCP Blocks Overview](/img/mcp-blocks-overview.png) + +## Learn More + +Learn more in the [MCP deep dive](../customize/deep-dives/mcp.mdx), and view [`mcpServers`](../reference.md#mcpservers) in the YAML Reference for more details. +description: Model Context Protocol servers provide specialized functionality +keywords: [mcp, blocks, model context protocol, integrations, tools] +sidebar_position: 4 + +--- + +Model Context Protocol servers provide specialized functionality: + +- Enable integration with external tools and systems +- Create extensible interfaces for custom capabilities +- Support more complex interactions with your development environment +- Allow partners to contribute specialized functionality +- Database Connectors: Understand schema and data models during development + +![MCP Blocks Overview](/img/mcp-blocks-overview.png) + +## Learn More + +Learn more in the [MCP deep dive](../customize/deep-dives/mcp.mdx), and view [`mcpServers`](../reference.md#mcpservers) in the YAML Reference for more details. diff --git a/docs/docs/blocks/models.md b/docs/docs/blocks/models.md new file mode 100644 index 000000000..bcf78be02 --- /dev/null +++ b/docs/docs/blocks/models.md @@ -0,0 +1,24 @@ +--- +title: Model Blocks +sidebar_label: Model +description: Foundation of the entire assistant experience offering specialized capabilities +keywords: [model, blocks, chat, edit, apply, autocomplete, embedding, reranker] +sidebar_position: 1 +--- + +These blocks form the foundation of the entire assistant experience, offering different specialized capabilities: + +- **[Chat](../customize/model-roles/chat.mdx)**: Power conversational interactions about code and provide detailed guidance +- **[Edit](../customize/model-roles/edit.mdx)**: Handle complex code transformations and refactoring tasks +- **[Apply](../customize/model-roles/apply.mdx)**: Execute targeted code modifications with high accuracy +- **[Autocomplete](../customize/model-roles/autocomplete.md)**: Provide real-time suggestions as developers type +- **[Embedding](../customize/model-roles/embeddings.mdx)**: Transform code into vector representations for semantic search +- **[Reranker](../customize/model-roles/reranking.mdx)**: Improve search relevance by ordering results based on semantic meaning + +![Model Blocks Overview](/img/model-blocks-overview.png) + +## Learn More + +Continue supports [many model providers](../customize/model-providers), including Anthropic, OpenAI, Gemini, Ollama, Amazon Bedrock, Azure, xAI, DeepSeek, and more. Models can have various roles like `chat`, `edit`, `apply`, `autocomplete`, `embed`, and `rerank`. + +Read more about roles [here](../customize/model-roles/intro.mdx) and view [`models`](../reference.md#models) in the YAML Reference. diff --git a/docs/docs/blocks/prompts.md b/docs/docs/blocks/prompts.md new file mode 100644 index 000000000..07cc9fb53 --- /dev/null +++ b/docs/docs/blocks/prompts.md @@ -0,0 +1,21 @@ +--- +title: Prompt Blocks +sidebar_label: Prompt +description: Specialized instructions that shape how models respond +keywords: [prompts, blocks, instructions, guidance, code review] +sidebar_position: 6 +--- + +These are the specialized instructions that shape how models respond: + +- **Define interaction patterns** for specific tasks or frameworks +- **Encode domain expertise** for particular technologies +- **Ensure consistent guidance** aligned with organizational practices +- **Can be shared and reused** across multiple assistants +- **Act as automated code reviewers** that ensure consistency across teams + +![Prompt Blocks Overview](/img/prompts-blocks-overview.png) + +## Learn More + +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). diff --git a/docs/docs/blocks/rules.md b/docs/docs/blocks/rules.md new file mode 100644 index 000000000..bc1baaf4b --- /dev/null +++ b/docs/docs/blocks/rules.md @@ -0,0 +1,19 @@ +--- +title: Rules Blocks +sidebar_label: Rules +description: Guardrails for your AI coding assistants +keywords: [rules, blocks, standards, practices, guardrails] +sidebar_position: 5 +--- + +Think of these as the guardrails for your AI coding assistants: + +- **Enforce company-specific coding standards** and security practices +- **Implement quality checks** that match your engineering culture +- **Create paved paths** for developers to follow organizational best practices + +![Rules Blocks Overview](/img/rules-blocks-overview.png) + +## Learn More + +Learn more in the [rules deep dive](../customize/deep-dives/rules.md), and view [`rules`](../reference.md#rules) in the YAML Reference for more details. diff --git a/docs/docs/customize/deep-dives/rules.md b/docs/docs/customize/deep-dives/rules.md index 94dec8a07..27a1e61a9 100644 --- a/docs/docs/customize/deep-dives/rules.md +++ b/docs/docs/customize/deep-dives/rules.md @@ -7,7 +7,7 @@ keywords: [rules, .continuerules, system, prompt, message] Rules are used to provide instructions to the model for [Chat](../../chat/how-to-use-it.md), [Edit](../../edit/how-to-use-it.md), and [Agent](../../agent/how-to-use-it.md) requests. -Rules are **_NOT_** included in most other requests, such as [autocomplete](./autocomplete.mdx) or [apply](../model-roles/apply.mdx). +Rules are not included in most other requests, such as [autocomplete](./autocomplete.mdx) or [apply](../model-roles/apply.mdx). You can view the current rules by clicking the pen icon above the main toolbar: @@ -25,22 +25,31 @@ When in Agent mode, you can simply prompt the agent to create a rule for you. For example, you can say "Create a rule for this", and a rule will be created for you in `~/.continue/rules` based on your conversation. ::: +### Syntax + Rules blocks can be simple text, or have the following properties: - `name` (**required**): A display name/title for the rule - `rule` (**required**): The text content of the rule - -Examples: +- `globs` (optional): When files are provided as context that match this glob pattern, the rule will be included. This can be either a single pattern (e.g., `"**/*.{ts,tsx}"`) or an array of patterns (e.g., `["src/**/*.ts", "tests/**/*.ts"]`). ```yaml title="config.yaml" rules: + - Always annotate Python functions with their parameter and return types + + - name: TypeScript best practices + rule: Always use TypeScript interfaces to define shape of objects. Use type aliases sparingly. + globs: "**/*.{ts,tsx}" + + - name: TypeScript test patterns + rule: In TypeScript tests, use Jest's describe/it pattern and follow best practices for mocking. + globs: + - "src/**/*.test.ts" + - "tests/**/*.ts" + - uses: myprofile/my-mood-setter with: - TONE: consise - - Always annotate Python functions with their parameter and return types - - Always write Google style docstrings for functions and classes - - name: Server-side components - rule: When writing Next.js React components, use server-side components where possible instead of client components. + TONE: concise ``` ## Chat System Message diff --git a/docs/docs/reference.md b/docs/docs/reference.md index ca794416a..dd8f7bc3b 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -32,7 +32,7 @@ Assistants can either explicitly define blocks - see [Properties](#properties) b ### Using Blocks -Hub blocks and assistants are identified with a slug in the format `owner-slug/block-or-assistant-slug`, where an owner can be a user or organization (For example, if you want to use the [OpenAI 4o Model block](https://hub.continue.dev/openai/gpt-4o), your slug would be `openai/gpt-4o`). These blocks are pulled from https://hub.continue.dev. +Hub blocks and assistants are identified with a slug in the format `owner-slug/block-or-assistant-slug`, where an owner can be a user or organization (For example, if you want to use the [OpenAI 4o Model block](https://hub.continue.dev/openai/gpt-4o), your slug would be `openai/gpt-4o`). These blocks are pulled from [https://hub.continue.dev](https://hub.continue.dev). Blocks can be imported into an assistant by adding a `uses` clause under the block type. This can be alongside other `uses` clauses or explicit blocks of that type. @@ -270,19 +270,25 @@ Explicit rules can either be simple text or an object with the following propert - `name` (**required**): A display name/title for the rule - `rule` (**required**): The text content of the rule - - -Example +- `globs` (optional): When files are provided as context that match this glob pattern, the rule will be included. This can be either a single pattern (e.g., `"**/*.{ts,tsx}"`) or an array of patterns (e.g., `["src/**/*.ts", "tests/**/*.ts"]`). ```yaml title="config.yaml" rules: + - Always annotate Python functions with their parameter and return types + + - name: TypeScript best practices + rule: Always use TypeScript interfaces to define shape of objects. Use type aliases sparingly. + globs: "**/*.{ts,tsx}" + + - name: TypeScript test patterns + rule: In TypeScript tests, use Jest's describe/it pattern and follow best practices for mocking. + globs: + - "src/**/*.test.ts" + - "tests/**/*.ts" + - uses: myprofile/my-mood-setter with: TONE: concise - - Always annotate Python functions with their parameter and return types - - Always write Google style docstrings for functions and classes - - name: Server-side components - rule: When writing Next.js React components, use server-side components where possible instead of client components. ``` --- diff --git a/docs/sidebars.js b/docs/sidebars.js index 1a634d163..89bfb71bd 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -55,6 +55,16 @@ const sidebars = { }, ], }, + { + type: "category", + label: "Blocks", + items: [ + { + type: "autogenerated", + dirName: "blocks", + }, + ], + }, "telemetry", "troubleshooting", { diff --git a/docs/static/img/context-blocks-overview.png b/docs/static/img/context-blocks-overview.png new file mode 100644 index 000000000..2db89de89 Binary files /dev/null and b/docs/static/img/context-blocks-overview.png differ diff --git a/docs/static/img/data-blocks-overview.png b/docs/static/img/data-blocks-overview.png new file mode 100644 index 000000000..dc7ec288e Binary files /dev/null and b/docs/static/img/data-blocks-overview.png differ diff --git a/docs/static/img/docs-blocks-overview.png b/docs/static/img/docs-blocks-overview.png new file mode 100644 index 000000000..ac7876784 Binary files /dev/null and b/docs/static/img/docs-blocks-overview.png differ diff --git a/docs/static/img/mcp-blocks-overview.png b/docs/static/img/mcp-blocks-overview.png new file mode 100644 index 000000000..0967ee831 Binary files /dev/null and b/docs/static/img/mcp-blocks-overview.png differ diff --git a/docs/static/img/model-blocks-overview.png b/docs/static/img/model-blocks-overview.png new file mode 100644 index 000000000..56e139a29 Binary files /dev/null and b/docs/static/img/model-blocks-overview.png differ diff --git a/docs/static/img/prompts-blocks-overview.png b/docs/static/img/prompts-blocks-overview.png new file mode 100644 index 000000000..109f58654 Binary files /dev/null and b/docs/static/img/prompts-blocks-overview.png differ diff --git a/docs/static/img/rules-blocks-overview.png b/docs/static/img/rules-blocks-overview.png new file mode 100644 index 000000000..7864c8d6b Binary files /dev/null and b/docs/static/img/rules-blocks-overview.png differ diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 7cf0b9dd7..805cd2d4a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.24", + "version": "1.1.25", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.24", + "version": "1.1.25", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/package-lock.json b/gui/package-lock.json index 183bdc0b1..765d4d78a 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -4380,7 +4380,8 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ] + ], + "license": "CC-BY-4.0" }, "node_modules/ccount": { "version": "2.0.1", diff --git a/gui/src/components/mainInput/Lump/sections/ErrorSection.tsx b/gui/src/components/mainInput/Lump/sections/ErrorSection.tsx index d4d01141c..ccc05166b 100644 --- a/gui/src/components/mainInput/Lump/sections/ErrorSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/ErrorSection.tsx @@ -24,14 +24,11 @@ export function ErrorSection() { }`} > {error.fatal ? ( - + ) : ( - + )} -

- {error.fatal ? "Fatal Error:" : "Warning:"}{" "} - {error.message} -

+

{error.message}

))} diff --git a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx index 0fae7611e..77b6c4bd9 100644 --- a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx @@ -123,16 +123,16 @@ const RuleCard: React.FC = ({ rule }) => { > {rule.rule} - {rule.if ? ( + {rule.globs ? (
- Applies if + Applies to files - {rule.if.replace(/\${{|}}/g, "")} + {rule.globs}
) : null} diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index f58a4194a..37ba5d51a 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -34,7 +34,6 @@ import { ProfileDescription } from "core/config/ConfigHandler"; import { useNavigate } from "react-router-dom"; import { vscCommandCenterInactiveBorder } from "../.."; import { ROUTES } from "../../../util/navigation"; -import { ToolTip } from "../../gui/Tooltip"; import { useLump } from "../../mainInput/Lump/LumpContext"; import { useFontSize } from "../../ui/font"; import AssistantIcon from "./AssistantIcon"; @@ -113,42 +112,35 @@ const AssistantSelectOption = ({
- {!profile.errors?.length ? ( - isLocalProfile(profile) ? ( - { - e.stopPropagation(); - e.preventDefault(); - handleConfigure(); - }} - /> - ) : ( - { - e.stopPropagation(); - e.preventDefault(); - handleConfigure(); - }} - /> - ) + {profile.errors && profile.errors?.length > 0 && ( + { + e.preventDefault(); + e.stopPropagation(); + handleClickError(); + }} + /> + )} + {isLocalProfile(profile) ? ( + { + e.stopPropagation(); + e.preventDefault(); + handleConfigure(); + }} + /> ) : ( - <> - { - e.preventDefault(); - e.stopPropagation(); - handleClickError(); - }} - /> - -
Errors
- {JSON.stringify(profile.errors, null, 2)} -
- + { + e.stopPropagation(); + e.preventDefault(); + handleConfigure(); + }} + /> )}
diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index 63b5e6189..dd00b86fb 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -89,7 +89,6 @@ export const streamResponseThunk = createAsyncThunk< [...updatedHistory], selectedChatModel?.baseChatSystemMessage, state.config.config.rules, - selectedChatModel.model, ); posthog.capture("step run", { diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index 269402bf5..7ff0ee47e 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -69,7 +69,6 @@ export const streamResponseAfterToolCall = createAsyncThunk< [...updatedHistory], selectedChatModel?.baseChatSystemMessage, state.config.config.rules, - selectedChatModel.model, ); unwrapResult(await dispatch(streamNormalInput({ messages }))); diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 1de41838c..7f8d55531 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -35,16 +35,15 @@ const docSchema = z.object({ }); export type DocsConfig = z.infer; - const ruleObjectSchema = z.object({ name: z.string(), rule: z.string(), - if: z.string().optional(), + globs: z.union([z.string(), z.array(z.string())]).optional(), }); - const ruleSchema = z.union([z.string(), ruleObjectSchema]); export type Rule = z.infer; +export type RuleObject = z.infer; const defaultUsesSchema = z.string(); @@ -168,3 +167,59 @@ export const blockSchema = baseConfigYamlSchema.and( ); export type Block = z.infer; + +export const continueCommandSchema = z.object({ + name: z.string(), + description: z.string().optional(), + prompt: z.string(), + placeholders: z.array(z.string()).optional(), + context: z.string().optional(), + contextWindowSize: z.number().optional(), + model: z.string().optional(), + systemMessage: z.string().optional(), + slashCommand: z.string().optional(), + hideFromCommandPalette: z.boolean().optional(), + hideFromSlashCommands: z.boolean().optional(), + mode: z.enum(["insert", "replace", "diff"]).optional(), + addEnhancedContext: z.boolean().optional(), +}); + +export const languageMarkerSchema = z.object({ + language: z.string(), + markers: z.array(z.string()), +}); + +export const sidebarSchema = z.object({ + enabled: z.boolean().optional(), + defaultOpen: z.boolean().optional(), + defaultWidth: z.number().optional(), + showButtonsThreshold: z.number().optional(), +}); + +const toolSchema = z.object({ + name: z.string(), + description: z.string(), + defaultIcon: z.string().optional(), +}); + +export const autoindentExtensionsSchema = z.array(z.string()); + +export const configSchema = z.object({ + models: z.array(modelSchema).optional(), + defaultModel: z.string().optional(), + defaultRecentMessages: z.number().optional(), + commands: z.array(continueCommandSchema).optional(), + tools: z.array(toolSchema).optional(), + contextProviders: z.array(z.any()).optional(), + langMarkers: z.array(languageMarkerSchema).optional(), + sidebar: sidebarSchema.optional(), + tabAutocompleteModel: z.string().optional(), + rules: z.array(ruleObjectSchema).optional(), + doneWithBannerForever: z.boolean().optional(), + autoindentExtensions: autoindentExtensionsSchema.optional(), + proxy: z.string().optional(), + api_base: z.string().optional(), + api_key: z.string().optional(), +}); + +export type Config = z.infer;