diff --git a/internal/llm/prompt/initialize.go b/internal/llm/prompt/initialize.go new file mode 100644 index 0000000000000000000000000000000000000000..62a0f57c6122195490e2f989874cf5660f4a0da2 --- /dev/null +++ b/internal/llm/prompt/initialize.go @@ -0,0 +1,14 @@ +package prompt + +func Initialize() string { + return `Please analyze this codebase and create a **CRUSH.md** file containing: + +- Build/lint/test commands - especially for running a single test +- Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. + +The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20-30 lines long. +If there's already a **CRUSH.md**, improve it. + +If there are Cursor rules` + " (in `.cursor/rules/` or `.cursorrules`) or Copilot rules (in `.github/copilot-instructions.md`), make sure to include them.\n" + + "Add the `.crush` directory to the `.gitignore` file if it's not already there." +} diff --git a/internal/tui/components/chat/splash/splash.go b/internal/tui/components/chat/splash/splash.go index c0d959eccce503e2830c14cd24ebbe6a0403c3bd..722aaea6f75c6ef0bef7e0a9ec2de319c6d71bfb 100644 --- a/internal/tui/components/chat/splash/splash.go +++ b/internal/tui/components/chat/splash/splash.go @@ -10,6 +10,7 @@ import ( tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/crush/internal/config" "github.com/charmbracelet/crush/internal/fur/provider" + "github.com/charmbracelet/crush/internal/llm/prompt" "github.com/charmbracelet/crush/internal/tui/components/chat" "github.com/charmbracelet/crush/internal/tui/components/completions" "github.com/charmbracelet/crush/internal/tui/components/core" @@ -242,14 +243,6 @@ func (s *splashCmp) saveAPIKeyAndContinue(apiKey string) tea.Cmd { func (s *splashCmp) initializeProject() tea.Cmd { s.needsProjectInit = false - prompt := `Please analyze this codebase and create a CRUSH.md file containing: -1. Build/lint/test commands - especially for running a single test -2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. - -The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long. -If there's already a CRUSH.md, improve it. -If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them. -Add the .crush directory to the .gitignore file if it's not already there.` if err := config.MarkProjectInitialized(); err != nil { return util.ReportError(err) @@ -261,7 +254,7 @@ Add the .crush directory to the .gitignore file if it's not already there.` cmds = append(cmds, util.CmdHandler(chat.SessionClearedMsg{}), util.CmdHandler(chat.SendMsg{ - Text: prompt, + Text: prompt.Initialize(), }), ) } diff --git a/internal/tui/components/dialogs/commands/commands.go b/internal/tui/components/dialogs/commands/commands.go index 140996fdd59af21e27e6eb4017ca5cca847cb0d9..10cdbbd539f06836550b7da6a857d35db3becd74 100644 --- a/internal/tui/components/dialogs/commands/commands.go +++ b/internal/tui/components/dialogs/commands/commands.go @@ -6,6 +6,7 @@ import ( tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/lipgloss/v2" + "github.com/charmbracelet/crush/internal/llm/prompt" "github.com/charmbracelet/crush/internal/tui/components/chat" "github.com/charmbracelet/crush/internal/tui/components/completions" "github.com/charmbracelet/crush/internal/tui/components/core" @@ -239,16 +240,8 @@ func (c *commandDialogCmp) defaultCommands() []Command { Title: "Initialize Project", Description: "Create/Update the CRUSH.md memory file", Handler: func(cmd Command) tea.Cmd { - prompt := `Please analyze this codebase and create a CRUSH.md file containing: - 1. Build/lint/test commands - especially for running a single test - 2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. - - The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long. - If there's already a CRUSH.md, improve it. - If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them. - Add the .crush directory to the .gitignore file if it's not already there.` return util.CmdHandler(chat.SendMsg{ - Text: prompt, + Text: prompt.Initialize(), }) }, },