Run npm run format

- This has the entirety of the changes.

Part of https://b.corp.google.com/issues/411720532
This commit is contained in:
Taylor Mullen
2025-04-18 18:08:43 -04:00
committed by N. Taylor Mullen
parent fa264e4286
commit 383b917784
26 changed files with 211 additions and 208 deletions

View File

@@ -14,7 +14,7 @@ export interface AiClient {
generateJson(
prompt: Content[], // Keep flexible or define a stricter prompt structure type
schema: SchemaUnion,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<any>; // Ideally, specify the expected JSON structure TAnalysisResult | TAnalysisFailure
}
@@ -127,10 +127,14 @@ export class BackgroundTerminalAnalyzer {
// Reread files one last time in case output was written just before exit
try {
currentStdout = await fs.readFile(tempStdoutFilePath, 'utf-8');
} catch { /* ignore */ }
} catch {
/* ignore */
}
try {
currentStderr = await fs.readFile(tempStderrFilePath, 'utf-8');
} catch { /* ignore */ }
} catch {
/* ignore */
}
lastAnalysisResult = await this.analyzeOutputWithLLM(
currentStdout,

View File

@@ -1,18 +1,18 @@
export function isNodeError(error: unknown): error is NodeJS.ErrnoException {
return error instanceof Error && 'code' in error;
return error instanceof Error && 'code' in error;
}
export function getErrorMessage(error: unknown): string {
if (error instanceof Error) {
return error.message;
} else {
// Attempt to convert the non-Error value to a string for logging
try {
const errorMessage = String(error);
return errorMessage;
} catch {
// If String() itself fails (highly unlikely)
return 'Failed to get error details';
}
}
}
if (error instanceof Error) {
return error.message;
} else {
// Attempt to convert the non-Error value to a string for logging
try {
const errorMessage = String(error);
return errorMessage;
} catch {
// If String() itself fails (highly unlikely)
return 'Failed to get error details';
}
}
}

View File

@@ -137,7 +137,10 @@ async function readFullStructure(
folderInfo.subFolders.length +
folderInfo.subFolders.reduce((sum, sf) => sum + sf.totalChildren, 0);
} catch (error: unknown) {
if (isNodeError(error) && (error.code === 'EACCES' || error.code === 'ENOENT')) {
if (
isNodeError(error) &&
(error.code === 'EACCES' || error.code === 'ENOENT')
) {
console.warn(
`Warning: Could not read directory ${folderPath}: ${error.message}`,
);
@@ -345,10 +348,7 @@ export async function getFolderStructure(
}
// 2. Reduce the structure (handles ignored folders specifically)
const reducedRoot = reduceStructure(
fullInfo,
mergedOptions.maxItems,
);
const reducedRoot = reduceStructure(fullInfo, mergedOptions.maxItems);
// 3. Count items in the *reduced* structure for the summary
const rootNodeItselfCount = 0; // Don't count the root node in the items summary