MCPcopy Create free account
hub / github.com/IAmUnbounded/devctx / summarizeCommand

Function summarizeCommand

devctx/src/commands/summarize.ts:18–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16const git = simpleGit();
17
18export 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
48Repository: ${repo}
49Branch: ${branch}
50Author: ${author}
51
52Recent commits:
53${recentCommits.map((c) => `- ${c}`).join("\n")}
54
55Files changed: ${filesChanged.join(", ") || "none"}
56Files staged: ${filesStaged.join(", ") || "none"}
57
58Diff summary:
59${diffSummary}
60
61Generate 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
70Be 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." },

Callers

nothing calls this directly

Calls 9

isInitializedFunction · 0.90
getCurrentBranchFunction · 0.90
getRepoNameFunction · 0.90
getChangedFilesFunction · 0.90
getStagedFilesFunction · 0.90
getRecentCommitsFunction · 0.90
getAuthorFunction · 0.90
callAIFunction · 0.90
saveContextFunction · 0.90

Tested by

no test coverage detected