MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / readIndexLocal

Function readIndexLocal

packages/node-sdk/examples/t8-race-direct.ts:9–23  ·  view source on GitHub ↗
(homeDir: string)

Source from the content-addressed store, hash-verified

7 return join(homeDir, 'session_index.jsonl');
8}
9async function readIndexLocal(homeDir: string): Promise<Map<string, any>> {
10 try {
11 const raw = await readFile(sessionIndexPathLocal(homeDir), 'utf-8');
12 const m = new Map<string, any>();
13 for (const line of raw.split(/\r?\n/)) {
14 const t = line.trim();
15 if (!t) continue;
16 const e = JSON.parse(t);
17 m.set(e.sessionId, e);
18 }
19 return m;
20 } catch {
21 return new Map();
22 }
23}
24async function appendIndexLocal(homeDir: string, entry: any): Promise<void> {
25 await mkdir(homeDir, { recursive: true, mode: 0o700 });
26 await appendFile(sessionIndexPathLocal(homeDir), `${JSON.stringify(entry)}\n`, 'utf-8');

Callers 1

emulateCreateFunction · 0.85

Calls 3

sessionIndexPathLocalFunction · 0.85
setMethod · 0.65
readFileFunction · 0.50

Tested by

no test coverage detected