mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Fix for git issue 5657 to add lines of code added/removed telemetry (#5823)
Co-authored-by: Ravikant Agarwal <ravikantag@google.com>
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
||||
ensureCorrectEdit,
|
||||
ensureCorrectFileContent,
|
||||
} from '../utils/editCorrector.js';
|
||||
import { DEFAULT_DIFF_OPTIONS } from './diffOptions.js';
|
||||
import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
|
||||
import { ModifiableDeclarativeTool, ModifyContext } from './modifiable-tool.js';
|
||||
import { getSpecificMimeType } from '../utils/fileUtils.js';
|
||||
import {
|
||||
@@ -52,6 +52,11 @@ export interface WriteFileToolParams {
|
||||
* Whether the proposed content was modified by the user.
|
||||
*/
|
||||
modified_by_user?: boolean;
|
||||
|
||||
/**
|
||||
* Initially proposed content.
|
||||
*/
|
||||
ai_proposed_content?: string;
|
||||
}
|
||||
|
||||
interface GetCorrectedFileContentResult {
|
||||
@@ -283,6 +288,15 @@ export class WriteFileTool
|
||||
DEFAULT_DIFF_OPTIONS,
|
||||
);
|
||||
|
||||
const originallyProposedContent =
|
||||
params.ai_proposed_content || params.content;
|
||||
const diffStat = getDiffStat(
|
||||
fileName,
|
||||
currentContentForDiff,
|
||||
originallyProposedContent,
|
||||
params.content,
|
||||
);
|
||||
|
||||
const llmSuccessMessageParts = [
|
||||
isNewFile
|
||||
? `Successfully created and wrote to new file: ${params.file_path}.`
|
||||
@@ -299,6 +313,7 @@ export class WriteFileTool
|
||||
fileName,
|
||||
originalContent: correctedContentResult.originalContent,
|
||||
newContent: correctedContentResult.correctedContent,
|
||||
diffStat,
|
||||
};
|
||||
|
||||
const lines = fileContent.split('\n').length;
|
||||
@@ -311,6 +326,7 @@ export class WriteFileTool
|
||||
lines,
|
||||
mimetype,
|
||||
extension,
|
||||
diffStat,
|
||||
);
|
||||
} else {
|
||||
recordFileOperationMetric(
|
||||
@@ -319,6 +335,7 @@ export class WriteFileTool
|
||||
lines,
|
||||
mimetype,
|
||||
extension,
|
||||
diffStat,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -418,11 +435,15 @@ export class WriteFileTool
|
||||
_oldContent: string,
|
||||
modifiedProposedContent: string,
|
||||
originalParams: WriteFileToolParams,
|
||||
) => ({
|
||||
...originalParams,
|
||||
content: modifiedProposedContent,
|
||||
modified_by_user: true,
|
||||
}),
|
||||
) => {
|
||||
const content = originalParams.content;
|
||||
return {
|
||||
...originalParams,
|
||||
ai_proposed_content: content,
|
||||
content: modifiedProposedContent,
|
||||
modified_by_user: true,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user