From 4549ab558983494a068bc035546d97ab820e6290 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Sat, 28 Mar 2026 13:44:10 +0000 Subject: [PATCH] feat(analyze): add project name inference for Go analysis prompts - Modify Go prompt to include instruction for inferring project name from directory or go.mod. - Update analyze command to infer project name from directory base and replace placeholder in prompt content. - Enhance prompt formatting with bold text and rephrased sections for clarity. --- .grokkit/prompts/go.md | 6 +++--- cmd/analyze.go | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.grokkit/prompts/go.md b/.grokkit/prompts/go.md index d56b773..b1d17eb 100644 --- a/.grokkit/prompts/go.md +++ b/.grokkit/prompts/go.md @@ -1,6 +1,6 @@ You are an expert Go educator and codebase archaeologist helping a learning developer or hobbyist deeply understand a project. -Generate a single, clean, educational Markdown report with these exact sections (use proper Markdown): +Generate a **single, clean, educational Markdown report** with these **exact sections** (use proper Markdown headings and bullet points): # Project Analysis: [Inferred Project Name] @@ -13,7 +13,7 @@ Generate a single, clean, educational Markdown report with these exact sections - Main public APIs and their purpose ## Function & Method Reference -For each exported function/method (group by package): +Group by package. For each exported function/method: - What it does - How it works (key logic, patterns, idioms) - Why it exists (design rationale or problem it solves) @@ -26,4 +26,4 @@ For each exported function/method (group by package): - Recommended order to read/understand the code - Common pitfalls or tricky parts for newcomers -Be precise, encouraging, and educational. Use short code snippets only when they illuminate a concept. Do not add extra commentary outside the sections. +Be precise, encouraging, and educational. Use short code snippets only when they illuminate a concept. Do **not** add extra commentary outside the sections. Infer the project name from directory or go.mod if possible. diff --git a/cmd/analyze.go b/cmd/analyze.go index f55ede1..613eafe 100644 --- a/cmd/analyze.go +++ b/cmd/analyze.go @@ -73,6 +73,12 @@ Uses language-specific prompts discovered in .grokkit/prompts/ or ~/.config/grok os.Exit(1) } logger.Info("Loaded analysis prompt", "language", lang, "path", promptPath) + // Improve prompt with the project name if possible + projectName := filepath.Base(dir) + if projectName == "." { + projectName = "Current Project" + } + promptContent = strings.Replace(promptContent, "[Inferred Project Name]", projectName, 1) // 4. Build rich project context context := buildProjectContext(dir, files)