MCPcopy Create free account
hub / github.com/ReviewStage/stage-cli / runPrep

Function runPrep

packages/cli/src/prep.ts:17–36  ·  view source on GitHub ↗
(options: DiffScopeOptions)

Source from the content-addressed store, hash-verified

15}
16
17export async function runPrep(options: DiffScopeOptions): Promise<string> {
18 const { scope, rawDiff, mergeBaseSha } = await resolveDiffScope(options);
19
20 const allFiles = parseGitDiff(rawDiff);
21 const stageIgnore = loadStageIgnore(readRepoRoot());
22 const { files } = filterFilesForLlm(allFiles, stageIgnore);
23
24 const formattedHunks = files
25 .flatMap((file) => file.hunks.map((hunk) => formatHunkForPrompt(file, hunk)))
26 .join("\n\n");
27
28 const commitMessages = getCommitMessages(mergeBaseSha, scope.headSha);
29
30 const sections = ["=== COMMIT MESSAGES ===", commitMessages, "", "=== HUNKS ===", formattedHunks];
31
32 const filePath = path.join(tmpdir(), `stage-prep-${Date.now()}.txt`);
33 writeFileSync(filePath, sections.join("\n"), "utf8");
34
35 return filePath;
36}

Callers 1

index.tsFile · 0.85

Calls 7

resolveDiffScopeFunction · 0.85
parseGitDiffFunction · 0.85
loadStageIgnoreFunction · 0.85
readRepoRootFunction · 0.85
filterFilesForLlmFunction · 0.85
formatHunkForPromptFunction · 0.85
getCommitMessagesFunction · 0.85

Tested by

no test coverage detected