mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
Cleanup low value comments. (#248)
This commit is contained in:
@@ -12,7 +12,6 @@ import { promises as fs } from 'fs';
|
||||
import { exec as _exec } from 'child_process';
|
||||
import { promisify } from 'util';
|
||||
|
||||
// Define the AnalysisStatus type alias
|
||||
type AnalysisStatus =
|
||||
| 'Running'
|
||||
| 'SuccessReported'
|
||||
@@ -20,7 +19,6 @@ type AnalysisStatus =
|
||||
| 'Unknown'
|
||||
| 'AnalysisFailed';
|
||||
|
||||
// Promisify child_process.exec for easier async/await usage
|
||||
const execAsync = promisify(_exec);
|
||||
|
||||
// Identifier for the background process (e.g., PID)
|
||||
@@ -33,20 +31,17 @@ export interface AnalysisResult {
|
||||
inferredStatus: 'Running' | 'SuccessReported' | 'ErrorReported' | 'Unknown';
|
||||
}
|
||||
|
||||
// Represents the structure returned when the LLM analysis itself fails
|
||||
export interface AnalysisFailure {
|
||||
error: string;
|
||||
inferredStatus: 'AnalysisFailed';
|
||||
}
|
||||
|
||||
// Type guard to check if the result is a failure object
|
||||
function isAnalysisFailure(
|
||||
result: AnalysisResult | AnalysisFailure,
|
||||
): result is AnalysisFailure {
|
||||
return (result as AnalysisFailure).inferredStatus === 'AnalysisFailed';
|
||||
}
|
||||
|
||||
// Represents the final outcome after polling is complete (or failed/timed out)
|
||||
export interface FinalAnalysisOutcome {
|
||||
status: string; // e.g., 'Completed_SuccessReported', 'TimedOut_Running', 'AnalysisFailed'
|
||||
summary: string; // Final summary or error message
|
||||
@@ -60,7 +55,7 @@ export class BackgroundTerminalAnalyzer {
|
||||
private initialDelayMs: number;
|
||||
|
||||
constructor(
|
||||
config: Config, // Accept Config object
|
||||
config: Config,
|
||||
options: {
|
||||
pollIntervalMs?: number;
|
||||
maxAttempts?: number;
|
||||
@@ -68,7 +63,6 @@ export class BackgroundTerminalAnalyzer {
|
||||
} = {},
|
||||
) {
|
||||
try {
|
||||
// Initialize Gemini client using config
|
||||
this.geminiClient = new GeminiClient(config);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
@@ -262,7 +256,6 @@ export class BackgroundTerminalAnalyzer {
|
||||
return { status: finalStatus, summary: finalSummary };
|
||||
}
|
||||
|
||||
// --- Actual Implementation of isProcessRunning ---
|
||||
/**
|
||||
* Checks if the background process is still running using OS-specific methods.
|
||||
* @param pid Process handle/identifier (expects a number for standard checks).
|
||||
@@ -312,7 +305,6 @@ export class BackgroundTerminalAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
// --- LLM Analysis Method (largely unchanged but added validation robustness) ---
|
||||
private async performLlmAnalysis(
|
||||
stdoutContent: string,
|
||||
stderrContent: string,
|
||||
@@ -433,7 +425,6 @@ Based *only* on the provided stdout and stderr:
|
||||
'Unknown',
|
||||
];
|
||||
|
||||
// Cast the unknown value to string before checking with includes
|
||||
const statusString = resultJson?.inferredStatus as string;
|
||||
const inferredStatus = validStatuses.includes(
|
||||
statusString as Exclude<AnalysisStatus, 'AnalysisFailed'>,
|
||||
@@ -441,15 +432,13 @@ Based *only* on the provided stdout and stderr:
|
||||
? (statusString as Exclude<AnalysisStatus, 'AnalysisFailed'>)
|
||||
: 'Unknown';
|
||||
|
||||
// Explicitly construct the object matching AnalysisResult type
|
||||
const analysisResult: AnalysisResult = { summary, inferredStatus };
|
||||
return analysisResult;
|
||||
} catch (error: unknown) {
|
||||
console.error(`LLM Analysis Request Failed for PID ${pid}:`, error);
|
||||
// Return the AnalysisFailure type
|
||||
const analysisFailure: AnalysisFailure = {
|
||||
error: `[Analysis failed: ${getErrorMessage(error)}]`,
|
||||
inferredStatus: 'AnalysisFailed', // This matches the AnalysisStatus type
|
||||
inferredStatus: 'AnalysisFailed',
|
||||
};
|
||||
return analysisFailure;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,10 @@ 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';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ async function readFullStructure(
|
||||
options: MergedFolderStructureOptions,
|
||||
): Promise<FullFolderInfo | null> {
|
||||
const name = path.basename(folderPath);
|
||||
// Initialize with isIgnored: false
|
||||
const folderInfo: Omit<FullFolderInfo, 'totalChildren' | 'totalFiles'> = {
|
||||
name,
|
||||
path: folderPath,
|
||||
@@ -97,7 +96,7 @@ async function readFullStructure(
|
||||
subFolders: [],
|
||||
totalChildren: 0, // No children explored
|
||||
totalFiles: 0, // No files explored
|
||||
isIgnored: true, // Mark as ignored
|
||||
isIgnored: true,
|
||||
};
|
||||
folderInfo.subFolders.push(ignoredFolderInfo);
|
||||
// Skip recursion for this folder
|
||||
@@ -122,7 +121,6 @@ async function readFullStructure(
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile()) {
|
||||
const fileName = entry.name;
|
||||
// Include if no pattern or if pattern matches
|
||||
if (
|
||||
!options.fileIncludePattern ||
|
||||
options.fileIncludePattern.test(fileName)
|
||||
@@ -156,7 +154,7 @@ async function readFullStructure(
|
||||
}
|
||||
|
||||
return {
|
||||
...(folderInfo as FullFolderInfo), // Cast needed after conditional assignment check
|
||||
...folderInfo,
|
||||
totalChildren: totalChildrenCount,
|
||||
totalFiles: totalFileCount,
|
||||
};
|
||||
@@ -285,7 +283,6 @@ function countReducedItems(node: ReducedFolderNode): number {
|
||||
|
||||
/**
|
||||
* Formats the reduced folder structure into a tree-like string.
|
||||
* (No changes needed in this function)
|
||||
* @param node The current node in the reduced structure.
|
||||
* @param indent The current indentation string.
|
||||
* @param isLast Sibling indicator.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import path from 'node:path'; // Import the 'path' module
|
||||
import path from 'node:path';
|
||||
|
||||
/**
|
||||
* Shortens a path string if it exceeds maxLen, prioritizing the start and end segments.
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
/**
|
||||
* Simple utility to validate objects against JSON Schemas
|
||||
* In a real implementation, you would use a library like Ajv
|
||||
*/
|
||||
export class SchemaValidator {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user