MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / loadEpisodeBlock

Function loadEpisodeBlock

src/context/episodic-memory.ts:159–173  ·  view source on GitHub ↗
(
  projectRoot: string,
  query: string,
  opts: { topK?: number; minScore?: number; diversity?: number } = {},
)

Source from the content-addressed store, hash-verified

157 * Builds a one-shot file-existence Set (each touched file checked once) so the pure ranker
158 * can ground episodes against the CURRENT tree without doing I/O itself. */
159export async function loadEpisodeBlock(
160 projectRoot: string,
161 query: string,
162 opts: { topK?: number; minScore?: number; diversity?: number } = {},
163): Promise<string> {
164 const episodes = await readEpisodes(projectRoot);
165 // Resolve existence once per distinct file referenced by any episode.
166 const referenced = new Set<string>();
167 for (const e of episodes) for (const f of e.filesChanged) referenced.add(f);
168 const existing = new Set<string>();
169 await Promise.all([...referenced].map(async f => {
170 try { await fs.access(path.resolve(projectRoot, f)); existing.add(f); } catch { /* gone */ }
171 }));
172 return buildEpisodeBlock(rankEpisodes(query, episodes, { ...opts, fileExists: f => existing.has(f) }));
173}

Callers 1

buildInitialMessagesMethod · 0.85

Calls 6

readEpisodesFunction · 0.85
buildEpisodeBlockFunction · 0.85
rankEpisodesFunction · 0.85
addMethod · 0.80
resolveMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected