MCPcopy Index your code
hub / github.com/codeaashu/claude-code / listCandidates

Function listCandidates

src/utils/listSessionsImpl.ts:169–198  ·  view source on GitHub ↗
(
  projectDir: string,
  doStat: boolean,
  projectPath?: string,
)

Source from the content-addressed store, hash-verified

167 * (caller must sort/dedup after reading file contents instead).
168 */
169export async function listCandidates(
170 projectDir: string,
171 doStat: boolean,
172 projectPath?: string,
173): Promise<Candidate[]> {
174 let names: string[]
175 try {
176 names = await readdir(projectDir)
177 } catch {
178 return []
179 }
180
181 const results = await Promise.all(
182 names.map(async (name): Promise<Candidate | null> => {
183 if (!name.endsWith('.jsonl')) return null
184 const sessionId = validateUuid(name.slice(0, -6))
185 if (!sessionId) return null
186 const filePath = join(projectDir, name)
187 if (!doStat) return { sessionId, filePath, mtime: 0, projectPath }
188 try {
189 const s = await stat(filePath)
190 return { sessionId, filePath, mtime: s.mtime.getTime(), projectPath }
191 } catch {
192 return null
193 }
194 }),
195 )
196
197 return results.filter((c): c is Candidate => c !== null)
198}
199
200/**
201 * Reads a candidate's file contents and extracts full SessionInfo.

Callers 3

gatherProjectCandidatesFunction · 0.85
gatherAllCandidatesFunction · 0.85
listSessionsTouchedSinceFunction · 0.85

Calls 3

readdirFunction · 0.85
statFunction · 0.85
validateUuidFunction · 0.70

Tested by

no test coverage detected