()
| 16 | const git = simpleGit(); |
| 17 | |
| 18 | export async function summarizeCommand() { |
| 19 | if (!(await isInitialized())) { |
| 20 | console.log(chalk.red("✗ DevContext not initialized. Run `devctx init` first.")); |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | try { |
| 25 | console.log(chalk.gray(" Analyzing git changes...")); |
| 26 | |
| 27 | const [branch, repo, filesChanged, filesStaged, recentCommits, author] = |
| 28 | await Promise.all([ |
| 29 | getCurrentBranch(), |
| 30 | getRepoName(), |
| 31 | getChangedFiles(), |
| 32 | getStagedFiles(), |
| 33 | getRecentCommits(10), |
| 34 | getAuthor(), |
| 35 | ]); |
| 36 | |
| 37 | // Get git diff for context |
| 38 | let diffSummary = ""; |
| 39 | try { |
| 40 | const diff = await git.diff(["--stat"]); |
| 41 | diffSummary = diff.slice(0, 2000); // cap at 2k chars |
| 42 | } catch { |
| 43 | diffSummary = "No diff available"; |
| 44 | } |
| 45 | |
| 46 | const prompt = `You are a developer assistant. Based on the following git activity, generate a concise coding context summary. |
| 47 | |
| 48 | Repository: ${repo} |
| 49 | Branch: ${branch} |
| 50 | Author: ${author} |
| 51 | |
| 52 | Recent commits: |
| 53 | ${recentCommits.map((c) => `- ${c}`).join("\n")} |
| 54 | |
| 55 | Files changed: ${filesChanged.join(", ") || "none"} |
| 56 | Files staged: ${filesStaged.join(", ") || "none"} |
| 57 | |
| 58 | Diff summary: |
| 59 | ${diffSummary} |
| 60 | |
| 61 | Generate a JSON response with: |
| 62 | { |
| 63 | "task": "one-line description of what's being worked on", |
| 64 | "approaches": ["approach 1", "approach 2"], |
| 65 | "decisions": ["decision 1"], |
| 66 | "currentState": "where things currently stand", |
| 67 | "nextSteps": ["step 1", "step 2"] |
| 68 | } |
| 69 | |
| 70 | Be concise. Only include approaches/decisions if they're clearly evident from the commits and changes.`; |
| 71 | |
| 72 | console.log(chalk.gray(" Generating AI summary...")); |
| 73 | |
| 74 | const result = await callAI([ |
| 75 | { role: "system", content: "You are a helpful developer assistant. Always respond with valid JSON." }, |
nothing calls this directly
no test coverage detected