perf(hashline): use write metadata line counts
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -141,6 +141,22 @@ function extractFilePath(metadata: unknown): string | undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
function extractLineCount(metadata: unknown): number | undefined {
|
||||
if (!metadata || typeof metadata !== "object") {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const objectMeta = metadata as Record<string, unknown>
|
||||
const candidates = [objectMeta.lineCount, objectMeta.linesWritten, objectMeta.lines]
|
||||
for (const candidate of candidates) {
|
||||
if (typeof candidate === "number" && Number.isInteger(candidate) && candidate >= 0) {
|
||||
return candidate
|
||||
}
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
async function appendWriteHashlineOutput(output: { output: string; metadata: unknown }): Promise<void> {
|
||||
if (output.output.startsWith(WRITE_SUCCESS_MARKER)) {
|
||||
return
|
||||
@@ -151,6 +167,12 @@ async function appendWriteHashlineOutput(output: { output: string; metadata: unk
|
||||
return
|
||||
}
|
||||
|
||||
const metadataLineCount = extractLineCount(output.metadata)
|
||||
if (metadataLineCount !== undefined) {
|
||||
output.output = `${WRITE_SUCCESS_MARKER} ${metadataLineCount} lines written.`
|
||||
return
|
||||
}
|
||||
|
||||
const filePath = extractFilePath(output.metadata)
|
||||
if (!filePath) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user