- Add Go-specific analysis prompt in .grokkit/prompts/go.md - Expand cmd/analyze.go to discover files, detect language, load prompts, build context, generate report via Grok, and handle output with preview/confirmation - Integrate analyzeCmd into root command - Introduce internal/linter/language.go for primary language detection - Add internal/prompts/analyze.go for loading analysis prompts from project or global locations
33 lines
928 B
Go
33 lines
928 B
Go
package prompts
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// LoadAnalysisPrompt returns the path and content of the best matching prompt.
|
|
// Search order: {projectRoot}/.grokkit/prompts/{language}.md → ~/.config/grokkit/prompts/{language}.md
|
|
func LoadAnalysisPrompt(projectRoot, language string) (path, content string, err error) {
|
|
if language == "" {
|
|
language = "unknown"
|
|
}
|
|
|
|
// 1. Project-local (preferred)
|
|
localPath := filepath.Join(projectRoot, ".grokkit", "prompts", language+".md")
|
|
if data, readErr := os.ReadFile(localPath); readErr == nil {
|
|
return localPath, string(data), nil
|
|
}
|
|
|
|
// 2. Global config
|
|
home := os.Getenv("HOME")
|
|
if home == "" {
|
|
home = "/root" // fallback for containers
|
|
}
|
|
globalPath := filepath.Join(home, ".config", "grokkit", "prompts", language+".md")
|
|
if data, readErr := os.ReadFile(globalPath); readErr == nil {
|
|
return globalPath, string(data), nil
|
|
}
|
|
|
|
return "", "", os.ErrNotExist
|
|
}
|