Merge pull request #7669 from continuedev/nate/init-command

feat: /init slash command for CLI
This commit is contained in:
Nate Sesti 2025-09-10 14:36:21 -07:00 • committed by GitHub
commit aa661ea939
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 56 additions and 1 deletions

View file

@ -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",

View file

@ -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<SlashCommandResult> {
const prompt = createInitPrompt();
return {
newInput: prompt,
};
}

View file

@ -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<string, CommandHandler> = {
return { openSessionSelector: true };
},
fork: handleFork,
init: (args, assistant) => {
posthogService.capture("useSlashCommand", { name: "init" });
return handleInit(args, assistant);
},
};
export async function handleSlashCommands(

View file

@ -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 {