Improve readability issues

This is only the first change of many changes.

* Remove redundant autogenerated comments
* Use the recommended file name style
* Use camelCase for variable names
* Don't introduce submodules for relevant types
* Don't introduce constants like modules, these are implementation details
* Remove empty files
This commit is contained in:
Jaana Dogan
2025-04-17 12:03:02 -07:00
committed by N. Taylor Mullen
parent 898a83031c
commit 81ba61df7f
25 changed files with 186 additions and 240 deletions

View File

@@ -1,22 +0,0 @@
import { ToolCallEvent } from "../ui/types.js";
export enum GeminiEventType {
Content,
ToolCallInfo,
}
export interface GeminiContentEvent {
type: GeminiEventType.Content;
value: string;
}
export interface GeminiToolCallInfoEvent {
type: GeminiEventType.ToolCallInfo;
value: ToolCallEvent;
}
export type GeminiEvent =
| GeminiContentEvent
| GeminiToolCallInfoEvent;
export type GeminiStream = AsyncIterable<GeminiEvent>;

View File

@@ -1,4 +0,0 @@
export enum StreamingState {
Idle,
Responding,
}

View File

@@ -1 +0,0 @@
export const MEMORY_FILE_NAME = 'GEMINI.md';

View File

@@ -10,9 +10,9 @@ import { CoreSystemPrompt } from './prompts.js';
import { type ToolCallEvent, type ToolCallConfirmationDetails, ToolCallStatus } from '../ui/types.js';
import process from 'node:process';
import { toolRegistry } from '../tools/tool-registry.js';
import { ToolResult } from '../tools/ToolResult.js';
import { ToolResult } from '../tools/tool.js';
import { getFolderStructure } from '../utils/getFolderStructure.js';
import { GeminiEventType, GeminiStream } from './GeminiStream.js';
import { GeminiEventType, GeminiStream } from './gemini-stream.js';
type ToolExecutionOutcome = {
callId: string;
@@ -62,7 +62,7 @@ ${folderStructure}
try {
const chat = this.ai.chats.create({
model: 'gemini-2.5-pro-preview-03-25',//'gemini-2.0-flash',
model: 'gemini-2.0-flash',//'gemini-2.0-flash',
config: {
systemInstruction: CoreSystemPrompt,
...this.defaultHyperParameters,

View File

@@ -1,7 +1,33 @@
import { ToolCallEvent } from "../ui/types.js";
import { Part } from '@google/genai';
import { HistoryItem } from '../ui/types.js';
import { GeminiEventType, GeminiStream } from './GeminiStream.js';
import { handleToolCallChunk, addErrorMessageToHistory } from './historyUpdater.js';
import { handleToolCallChunk, addErrorMessageToHistory } from './history-updater.js';
export enum GeminiEventType {
Content,
ToolCallInfo,
}
export interface GeminiContentEvent {
type: GeminiEventType.Content;
value: string;
}
export interface GeminiToolCallInfoEvent {
type: GeminiEventType.ToolCallInfo;
value: ToolCallEvent;
}
export type GeminiEvent =
| GeminiContentEvent
| GeminiToolCallInfoEvent;
export type GeminiStream = AsyncIterable<GeminiEvent>;
export enum StreamingState {
Idle,
Responding,
}
interface StreamProcessorParams {
stream: GeminiStream;
@@ -104,7 +130,6 @@ export const processGeminiStream = async ({ // Renamed function for clarity
clearTimeout(renderTimeoutId);
renderTimeoutId = null;
}
// Flush any text buffer content.
render(textBuffer);
currentGeminiMessageId = null; // End text message context

View File

@@ -1,7 +1,7 @@
import { Part } from "@google/genai";
import { toolRegistry } from "../tools/tool-registry.js";
import { HistoryItem, IndividualToolCallDisplay, ToolCallEvent, ToolCallStatus, ToolConfirmationOutcome, ToolEditConfirmationDetails, ToolExecuteConfirmationDetails } from "../ui/types.js";
import { ToolResultDisplay } from "../tools/ToolResult.js";
import { ToolResultDisplay } from "../tools/tool.js";
/**
* Processes a tool call chunk and updates the history state accordingly.
@@ -46,13 +46,9 @@ export const handleToolCallChunk = (
if (!tool) {
throw new Error(`Tool "${chunk.name}" not found or is not registered.`);
}
handleToolCallChunk({ ...chunk, status: ToolCallStatus.Invoked, resultDisplay: "Executing...", confirmationDetails: undefined }, setHistory, submitQuery, getNextMessageId, currentToolGroupIdRef);
const result = await tool.execute(chunk.args);
handleToolCallChunk({ ...chunk, status: ToolCallStatus.Invoked, resultDisplay: result.returnDisplay, confirmationDetails: undefined }, setHistory, submitQuery, getNextMessageId, currentToolGroupIdRef);
const functionResponse: Part = {
functionResponse: {
name: chunk.name,
@@ -60,7 +56,6 @@ export const handleToolCallChunk = (
response: { "output": result.llmContent },
},
}
await submitQuery(functionResponse);
}
}

View File

@@ -1,6 +1,7 @@
import { ReadFileTool } from "../tools/read-file.tool.js";
import { TerminalTool } from "../tools/terminal.tool.js";
import { MEMORY_FILE_NAME } from "./constants.js";
const MEMORY_FILE_NAME = 'GEMINI.md';
const contactEmail = 'ntaylormullen@google.com';
export const CoreSystemPrompt = `