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

Function suggestCommand

devctx/src/commands/suggest.ts:10–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import { callAI } from "../core/ai";
9
10export async function suggestCommand() {
11 if (!(await isInitialized())) {
12 console.log(chalk.red("✗ DevContext not initialized. Run `devctx init` first."));
13 return;
14 }
15
16 try {
17 const branch = await getCurrentBranch();
18 const entries = await loadBranchContext(branch);
19 const [filesChanged, recentCommits] = await Promise.all([
20 getChangedFiles(),
21 getRecentCommits(10),
22 ]);
23
24 if (entries.length === 0 && filesChanged.length === 0) {
25 console.log(chalk.yellow("⚠ No context or changes found. Nothing to analyze."));
26 return;
27 }
28
29 console.log(chalk.gray(" Analyzing codebase and context..."));
30
31 const latest = entries[entries.length - 1];
32 const contextSummary = latest
33 ? `Current task: ${latest.task}
34Current state: ${latest.currentState}
35Previous approaches: ${latest.approaches.join(", ") || "none"}
36Previous decisions: ${latest.decisions.join(", ") || "none"}
37Known blockers: ${latest.blockers?.join(", ") || "none"}
38Previous next steps: ${latest.nextSteps.join(", ") || "none"}`
39 : "No previous context available.";
40
41 const prompt = `You are a senior developer mentor. Based on the following project context, suggest concrete next steps.
42
43Branch: ${branch}
44
45${contextSummary}
46
47Recent commits:
48${recentCommits.map((c) => `- ${c}`).join("\n")}
49
50Currently changed files: ${filesChanged.join(", ") || "none"}
51
52Provide 3-5 specific, actionable next steps. For each step, briefly explain WHY it's important. Format as a numbered list.`;
53
54 const result = await callAI([
55 {
56 role: "system",
57 content: "You are a helpful senior developer. Be concise and actionable.",
58 },
59 { role: "user", content: prompt },
60 ]);
61
62 if (result.error) {
63 console.log(chalk.red(`✗ ${result.error}`));
64 return;
65 }
66
67 console.log(chalk.bold.cyan("\n💡 Suggested Next Steps\n"));

Callers

nothing calls this directly

Calls 6

isInitializedFunction · 0.90
getCurrentBranchFunction · 0.90
loadBranchContextFunction · 0.90
getChangedFilesFunction · 0.90
getRecentCommitsFunction · 0.90
callAIFunction · 0.90

Tested by

no test coverage detected