MCPcopy Create free account
hub / github.com/PawanOsman/OpenCursor / buildContextBlock

Function buildContextBlock

src/context/workspaceContext.ts:305–329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

303}
304
305export async function buildContextBlock(): Promise<string> {
306 const openFiles = getOpenFiles();
307 const [tree, git, rules, skills] = await Promise.all([getFileTree(), getGitContext(), getCursorRules(openFiles), listSkills()]);
308 const selection = getActiveSelection();
309
310 const parts: string[] = [];
311 parts.push(`<workspace_files>\n${tree}\n</workspace_files>`);
312 if (openFiles.length) {
313 parts.push(`<open_files>\n${openFiles.join("\n")}\n</open_files>`);
314 }
315 if (selection) {
316 parts.push(`<active_selection>\n${selection}\n</active_selection>`);
317 }
318 if (git) {
319 parts.push(`<git>\n${git}\n</git>`);
320 }
321 if (rules) {
322 parts.push(`<rules>\n${rules}\n</rules>`);
323 }
324 if (skills.length) {
325 const list = skills.map((s) => `- ${s.name}: ${s.description} (read ${s.path} to use)`).join("\n");
326 parts.push(`<available_skills>\nThese skills provide specialized instructions. When a task matches, read the SKILL.md file with read_file and follow it.\n${list}\n</available_skills>`);
327 }
328 return parts.join("\n\n");
329}

Callers

nothing calls this directly

Calls 7

getOpenFilesFunction · 0.85
getFileTreeFunction · 0.85
getGitContextFunction · 0.85
getCursorRulesFunction · 0.85
listSkillsFunction · 0.85
getActiveSelectionFunction · 0.85
allMethod · 0.80

Tested by

no test coverage detected