MCPcopy Create free account
hub / github.com/Qinbf/groundmap / getRootIndexContent

Function getRootIndexContent

tools/debug-console/app/api/chat/route.ts:33–49  ·  view source on GitHub ↗
(workspace: string | undefined)

Source from the content-addressed store, hash-verified

31const rootIndexCache = new Map<string, { content: string; expiresAt: number }>();
32
33async function getRootIndexContent(workspace: string | undefined): Promise<string> {
34 const key = workspace ?? "__default__";
35 const now = Date.now();
36 const cached = rootIndexCache.get(key);
37 if (cached && cached.expiresAt > now) return cached.content;
38 try {
39 // executeTool 从 workspaceContext 读 ws(本函数在 run(ws) 作用域内被调)
40 const r = await executeTool("read_page", { path: "wiki/root_index.md" });
41 if (!r.ok || !r.data) return "";
42 const d = r.data as { content?: string };
43 const content = d.content || "";
44 rootIndexCache.set(key, { content, expiresAt: now + ROOT_INDEX_TTL_MS });
45 return content;
46 } catch {
47 return "";
48 }
49}
50
51/** 在 system prompt 末尾 append root_index 全文,让 AI 不需要花一轮调 read_page 读它 */
52function appendPrewarmedIndex(baseSystem: string, indexContent: string): string {

Callers 1

startFunction · 0.85

Calls 1

executeToolFunction · 0.90

Tested by

no test coverage detected