mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
feat: Add programming language to CLI events (#6071)
Co-authored-by: christine betts <chrstn@uw.edu> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com> Co-authored-by: JaeHo Jang <diehreo@gmail.com> Co-authored-by: Jacob Richman <jacob314@gmail.com> Co-authored-by: Victor May <mayvic@google.com> Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com> Co-authored-by: joshualitt <joshualitt@google.com> Co-authored-by: Billy Biggs <bbiggs@google.com> Co-authored-by: Ricardo Fabbri <rfabbri@gmail.com> Co-authored-by: Arya Gummadi <aryagummadi@google.com> Co-authored-by: Tommaso Sciortino <sciortino@gmail.com> Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com> Co-authored-by: Shreya Keshive <skeshive@gmail.com> Co-authored-by: Ben Guo <36952867+HunDun0Ben@users.noreply.github.com> Co-authored-by: Ben Guo <hundunben@gmail.com> Co-authored-by: mkusaka <hinoshita1992@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
IdeConnectionEvent,
|
||||
KittySequenceOverflowEvent,
|
||||
ChatCompressionEvent,
|
||||
FileOperationEvent,
|
||||
} from '../types.js';
|
||||
import { EventMetadataKey } from './event-metadata-key.js';
|
||||
import { Config } from '../../config/config.js';
|
||||
@@ -33,6 +34,7 @@ export enum EventNames {
|
||||
START_SESSION = 'start_session',
|
||||
NEW_PROMPT = 'new_prompt',
|
||||
TOOL_CALL = 'tool_call',
|
||||
FILE_OPERATION = 'file_operation',
|
||||
API_REQUEST = 'api_request',
|
||||
API_RESPONSE = 'api_response',
|
||||
API_ERROR = 'api_error',
|
||||
@@ -476,6 +478,64 @@ export class ClearcutLogger {
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
logFileOperationEvent(event: FileOperationEvent): void {
|
||||
const data: EventValue[] = [
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_TOOL_CALL_NAME,
|
||||
value: JSON.stringify(event.tool_name),
|
||||
},
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_FILE_OPERATION_TYPE,
|
||||
value: JSON.stringify(event.operation),
|
||||
},
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_FILE_OPERATION_LINES,
|
||||
value: JSON.stringify(event.lines),
|
||||
},
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_FILE_OPERATION_MIMETYPE,
|
||||
value: JSON.stringify(event.mimetype),
|
||||
},
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_FILE_OPERATION_EXTENSION,
|
||||
value: JSON.stringify(event.extension),
|
||||
},
|
||||
];
|
||||
|
||||
if (event.programming_language) {
|
||||
data.push({
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_PROGRAMMING_LANGUAGE,
|
||||
value: event.programming_language,
|
||||
});
|
||||
}
|
||||
|
||||
if (event.diff_stat) {
|
||||
const metadataMapping: { [key: string]: EventMetadataKey } = {
|
||||
ai_added_lines: EventMetadataKey.GEMINI_CLI_AI_ADDED_LINES,
|
||||
ai_removed_lines: EventMetadataKey.GEMINI_CLI_AI_REMOVED_LINES,
|
||||
user_added_lines: EventMetadataKey.GEMINI_CLI_USER_ADDED_LINES,
|
||||
user_removed_lines: EventMetadataKey.GEMINI_CLI_USER_REMOVED_LINES,
|
||||
};
|
||||
|
||||
for (const [key, gemini_cli_key] of Object.entries(metadataMapping)) {
|
||||
if (
|
||||
event.diff_stat[key as keyof typeof event.diff_stat] !== undefined
|
||||
) {
|
||||
data.push({
|
||||
gemini_cli_key,
|
||||
value: JSON.stringify(
|
||||
event.diff_stat[key as keyof typeof event.diff_stat],
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const logEvent = this.createLogEvent(EventNames.FILE_OPERATION, data);
|
||||
this.enqueueLogEvent(logEvent);
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
logApiRequestEvent(event: ApiRequestEvent): void {
|
||||
const data: EventValue[] = [
|
||||
{
|
||||
|
||||
@@ -219,6 +219,9 @@ export enum EventMetadataKey {
|
||||
// Logs user removed lines in edit/write tool response.
|
||||
GEMINI_CLI_USER_REMOVED_LINES = 50,
|
||||
|
||||
// Logs the programming language of the project.
|
||||
GEMINI_CLI_PROGRAMMING_LANGUAGE = 56,
|
||||
|
||||
// ==========================================================================
|
||||
// Kitty Sequence Overflow Event Keys
|
||||
// ===========================================================================
|
||||
@@ -246,4 +249,20 @@ export enum EventMetadataKey {
|
||||
|
||||
// Logs name of MCP tools as comma seperated string
|
||||
GEMINI_CLI_START_SESSION_MCP_TOOLS = 65,
|
||||
|
||||
// ==========================================================================
|
||||
// File Operation Event Keys
|
||||
// ===========================================================================
|
||||
|
||||
// Logs the operation type of the file operation.
|
||||
GEMINI_CLI_FILE_OPERATION_TYPE = 66,
|
||||
|
||||
// Logs the number of lines in the file operation.
|
||||
GEMINI_CLI_FILE_OPERATION_LINES = 67,
|
||||
|
||||
// Logs the mimetype of the file in the file operation.
|
||||
GEMINI_CLI_FILE_OPERATION_MIMETYPE = 68,
|
||||
|
||||
// Logs the extension of the file in the file operation.
|
||||
GEMINI_CLI_FILE_OPERATION_EXTENSION = 69,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user