Elffuss BraidHub

kikocis/continue public

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

feat: /init slash command for CLI
Changesetc3cb880f79e5fbf3e7328b5a888df767a9402bb9ee1a4c202b0eb3f9f41cc633
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-09-10 14:36 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-10 14:36 -07:00
Parents8a6602dc5d0c, 5875481a5280

Browse the files at this changeset

4 files changed

modified extensions/cli/src/commands/commands.ts +5 −1
@@ -65,7 +65,11 @@
6565 description: "Manage MCP server connections",
6666 category: "system",
6767 },
68-
68+ {
69+ name: "init",
70+ description: "Create an AGENTS.md file",
71+ category: "system",
72+ },
6973 {
7074 name: "compact",
7175 description: "Summarize chat history into a compact form",
added extensions/cli/src/commands/init.ts +45 −0
@@ -0,0 +1,45 @@
1+import { type AssistantConfig } from "@continuedev/sdk";
2+
3+import { SlashCommandResult } from "../ui/hooks/useChat.types.js";
4+
5+function createInitPrompt(): string {
6+ 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.
7+
8+Create an AGENTS.md file with the following structure:
9+
10+# Repository Overview
11+
12+## Project Description
13+- What this project does
14+- Main purpose and goals
15+- Key technologies used
16+
17+## Architecture Overview
18+- High-level architecture
19+- Main components and their relationships
20+- Data flow and system interactions
21+
22+## Directory Structure
23+- Important directories and their purposes
24+- Key files and configuration
25+- Entry points and main modules
26+
27+## Development Workflow
28+- How to build/run the project
29+- Testing approach
30+- Development environment setup
31+- Lint and format commands
32+
33+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.`;
34+}
35+
36+export async function handleInit(
37+ _args: string[],
38+ _assistant: AssistantConfig,
39+): Promise<SlashCommandResult> {
40+ const prompt = createInitPrompt();
41+
42+ return {
43+ newInput: prompt,
44+ };
45+}
modified extensions/cli/src/slashCommands.ts +5 −0
@@ -7,6 +7,7 @@
77 loadAuthConfig,
88 } from "./auth/workos.js";
99 import { getAllSlashCommands } from "./commands/commands.js";
10+import { handleInit } from "./commands/init.js";
1011 import { handleInfoSlashCommand } from "./infoScreen.js";
1112 import { reloadService, SERVICE_NAMES, services } from "./services/index.js";
1213 import { getCurrentSession } from "./session.js";
@@ -176,6 +177,10 @@
176177 return { openSessionSelector: true };
177178 },
178179 fork: handleFork,
180+ init: (args, assistant) => {
181+ posthogService.capture("useSlashCommand", { name: "init" });
182+ return handleInit(args, assistant);
183+ },
179184 };
180185
181186 export async function handleSlashCommands(
modified extensions/cli/src/ui/TipsDisplay.tsx +1 −0
@@ -9,6 +9,7 @@
99 'Multi-line input is supported by typing "\\" and pressing enter',
1010 "Use `cn ls` or `/resume` to resume a previous conversation",
1111 '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."`',
12+ "Use the /init slash command to generate an AGENTS.md file. This will help `cn` understand your codebase and generate better responses.",
1213 ];
1314
1415 interface TipsDisplayProps {