mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-05-19 16:13:56 +00:00
fix(copilot): use bounded readSessionFile helper
Events JSONL and workspace.yaml reads now pass through the 128 MB-capped helper. The workspace.yaml path stays non-fatal: a null read skips cwd derivation but still pushes the session with sessionId as the fallback project label. MEDIUM-1 coverage for the Copilot provider.
This commit is contained in:
parent
1de0baf329
commit
9f6827d528
1 changed files with 7 additions and 11 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import { readdir, readFile, stat } from 'fs/promises'
|
||||
import { readdir, stat } from 'fs/promises'
|
||||
import { basename, dirname, join } from 'path'
|
||||
import { homedir } from 'os'
|
||||
|
||||
import { readSessionFile } from '../fs-utils.js'
|
||||
import { calculateCost } from '../models.js'
|
||||
import type { Provider, SessionSource, SessionParser, ParsedProviderCall } from './types.js'
|
||||
|
||||
|
|
@ -85,13 +86,8 @@ function parseCwd(yaml: string): string | null {
|
|||
function createParser(source: SessionSource, seenKeys: Set<string>): SessionParser {
|
||||
return {
|
||||
async *parse(): AsyncGenerator<ParsedProviderCall> {
|
||||
let content: string
|
||||
try {
|
||||
content = await readFile(source.path, 'utf-8')
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
const content = await readSessionFile(source.path)
|
||||
if (content === null) return
|
||||
const sessionId = basename(dirname(source.path))
|
||||
const lines = content.split('\n').filter(l => l.trim())
|
||||
let currentModel = ''
|
||||
|
|
@ -177,11 +173,11 @@ async function discoverSessionsInDir(sessionStateDir: string): Promise<SessionSo
|
|||
if (!s?.isFile()) continue
|
||||
|
||||
let project = sessionId
|
||||
try {
|
||||
const yaml = await readFile(join(sessionStateDir, sessionId, 'workspace.yaml'), 'utf-8')
|
||||
const yaml = await readSessionFile(join(sessionStateDir, sessionId, 'workspace.yaml'))
|
||||
if (yaml !== null) {
|
||||
const cwd = parseCwd(yaml)
|
||||
if (cwd) project = basename(cwd)
|
||||
} catch {}
|
||||
}
|
||||
|
||||
sources.push({ path: eventsPath, project, provider: 'copilot' })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue