diff --git a/extensions/cli/src/commands/commands.ts b/extensions/cli/src/commands/commands.ts index 419241100..82e4a8a71 100644 --- a/extensions/cli/src/commands/commands.ts +++ b/extensions/cli/src/commands/commands.ts @@ -65,7 +65,11 @@ export const SYSTEM_SLASH_COMMANDS: SystemCommand[] = [ description: "Manage MCP server connections", category: "system", }, - + { + name: "init", + description: "Create an AGENTS.md file", + category: "system", + }, { name: "compact", description: "Summarize chat history into a compact form", diff --git a/extensions/cli/src/commands/init.ts b/extensions/cli/src/commands/init.ts new file mode 100644 index 000000000..f4c31e614 --- /dev/null +++ b/extensions/cli/src/commands/init.ts @@ -0,0 +1,45 @@ +import { type AssistantConfig } from "@continuedev/sdk"; + +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. + +Create an AGENTS.md file with the following structure: + +# Repository Overview + +## Project Description +- What this project does +- Main purpose and goals +- Key technologies used + +## Architecture Overview +- High-level architecture +- Main components and their relationships +- Data flow and system interactions + +## Directory Structure +- Important directories and their purposes +- Key files and configuration +- Entry points and main modules + +## Development Workflow +- How to build/run the project +- Testing approach +- 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.`; +} + +export async function handleInit( + _args: string[], + _assistant: AssistantConfig, +): Promise { + const prompt = createInitPrompt(); + + return { + newInput: prompt, + }; +} diff --git a/extensions/cli/src/slashCommands.ts b/extensions/cli/src/slashCommands.ts index 5c7d69fa1..d708a1c7d 100644 --- a/extensions/cli/src/slashCommands.ts +++ b/extensions/cli/src/slashCommands.ts @@ -7,6 +7,7 @@ import { loadAuthConfig, } from "./auth/workos.js"; import { getAllSlashCommands } from "./commands/commands.js"; +import { handleInit } from "./commands/init.js"; import { handleInfoSlashCommand } from "./infoScreen.js"; import { reloadService, SERVICE_NAMES, services } from "./services/index.js"; import { getCurrentSession } from "./session.js"; @@ -176,6 +177,10 @@ const commandHandlers: Record = { return { openSessionSelector: true }; }, fork: handleFork, + init: (args, assistant) => { + posthogService.capture("useSlashCommand", { name: "init" }); + return handleInit(args, assistant); + }, }; export async function handleSlashCommands( diff --git a/extensions/cli/src/ui/TipsDisplay.tsx b/extensions/cli/src/ui/TipsDisplay.tsx index 148e06583..075a65749 100644 --- a/extensions/cli/src/ui/TipsDisplay.tsx +++ b/extensions/cli/src/ui/TipsDisplay.tsx @@ -9,6 +9,7 @@ const CONTINUE_CLI_TIPS = [ 'Multi-line input is supported by typing "\\" and pressing enter', "Use `cn ls` or `/resume` to resume a previous conversation", 'Run `cn` with the `-p` flag for headless mode. For example: `cn -p "Generate a commit message for the current changes. Output _only_ the commit message and nothing else."`', + "Use the /init slash command to generate an AGENTS.md file. This will help `cn` understand your codebase and generate better responses.", ]; interface TipsDisplayProps {