diff --git a/core/config/markdown/utils.ts b/core/config/markdown/utils.ts index 5fbade09bdd..df64a75be7b 100644 --- a/core/config/markdown/utils.ts +++ b/core/config/markdown/utils.ts @@ -4,6 +4,15 @@ import { } from "@continuedev/config-yaml"; import { joinPathsToUri } from "../../util/uri"; +function createRelativeRuleFilePathParts(ruleName: string): string[] { + const safeRuleName = sanitizeRuleName(ruleName); + return [".continue", "rules", `${safeRuleName}.${RULE_FILE_EXTENSION}`]; +} + +export function createRelativeRuleFilePath(ruleName: string): string { + return createRelativeRuleFilePathParts(ruleName).join("/"); +} + /** * Creates the file path for a rule in the workspace .continue/rules directory */ @@ -11,11 +20,8 @@ export function createRuleFilePath( workspaceDir: string, ruleName: string, ): string { - const safeRuleName = sanitizeRuleName(ruleName); return joinPathsToUri( workspaceDir, - ".continue", - "rules", - `${safeRuleName}.${RULE_FILE_EXTENSION}`, + ...createRelativeRuleFilePathParts(ruleName), ); } diff --git a/extensions/cli/src/commands/init.ts b/extensions/cli/src/commands/init.ts index f4c31e61444..ad50333ef54 100644 --- a/extensions/cli/src/commands/init.ts +++ b/extensions/cli/src/commands/init.ts @@ -1,9 +1,11 @@ import { type AssistantConfig } from "@continuedev/sdk"; +import { createRelativeRuleFilePath } from "core/config/markdown/utils.js"; import { SlashCommandResult } from "../ui/hooks/useChat.types.js"; function createInitPrompt(): string { - return `Please analyze this repository and create a comprehensive AGENTS.md file. Use your available tools to understand the project structure, read important files like README.md, package.json, requirements.txt, and other configuration files to understand the technology stack and setup. + const relativeRuleFilepath = createRelativeRuleFilePath("review"); + return `Please analyze this repository and create a comprehensive AGENTS.md file, along with a custom slash command. Use your available tools to understand the project structure, read important files like README.md, package.json, requirements.txt, and other configuration files to understand the technology stack and setup. Create an AGENTS.md file with the following structure: @@ -30,7 +32,23 @@ Create an AGENTS.md file with the following structure: - Development environment setup - Lint and format commands -Please create the AGENTS.md file using the Write tool after analyzing the repository. Focus on providing actionable information that would help both AI agents and human developers understand and work effectively with this codebase. Keep the file concise but informational.`; +Additionally, create a slash command file at ${relativeRuleFilepath} with the following structure: + +\`\`\`md +--- +invokable: true +--- + +Review this code for potential issues, including: + + + +Provide specific, actionable feedback for improvements. +\`\`\` + +This slash command will be invokable using /review and will provide instructions for code review tasks common to this repository. + +Please create both the AGENTS.md file and the .continue/rules/review.md file using the Write tool after analyzing the repository. Focus on providing actionable information that would help both AI agents and human developers understand and work effectively with this codebase. Keep the files concise but informational.`; } export async function handleInit(