2025-04-18 17:44:24 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
import React from 'react';
|
2025-04-17 18:06:21 -04:00
|
|
|
import { Box, Text } from 'ink';
|
2025-08-25 22:11:27 +02:00
|
|
|
import { EOL } from 'node:os';
|
2025-08-15 20:18:31 -07:00
|
|
|
import { Colors } from '../../colors.js';
|
2025-08-25 22:11:27 +02:00
|
|
|
import crypto from 'node:crypto';
|
2025-07-23 15:39:22 -07:00
|
|
|
import { colorizeCode, colorizeLine } from '../../utils/CodeColorizer.js';
|
2025-06-19 20:17:23 +00:00
|
|
|
import { MaxSizedBox } from '../shared/MaxSizedBox.js';
|
2025-08-15 20:18:31 -07:00
|
|
|
import { theme } from '../../semantic-colors.js';
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
|
|
|
|
|
interface DiffLine {
|
|
|
|
|
type: 'add' | 'del' | 'context' | 'hunk' | 'other';
|
|
|
|
|
oldLine?: number;
|
|
|
|
|
newLine?: number;
|
|
|
|
|
content: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseDiffWithLineNumbers(diffContent: string): DiffLine[] {
|
2025-08-22 14:10:45 +08:00
|
|
|
const lines = diffContent.split(EOL);
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
const result: DiffLine[] = [];
|
|
|
|
|
let currentOldLine = 0;
|
|
|
|
|
let currentNewLine = 0;
|
|
|
|
|
let inHunk = false;
|
|
|
|
|
const hunkHeaderRegex = /^@@ -(\d+),?\d* \+(\d+),?\d* @@/;
|
|
|
|
|
|
|
|
|
|
for (const line of lines) {
|
|
|
|
|
const hunkMatch = line.match(hunkHeaderRegex);
|
|
|
|
|
if (hunkMatch) {
|
|
|
|
|
currentOldLine = parseInt(hunkMatch[1], 10);
|
|
|
|
|
currentNewLine = parseInt(hunkMatch[2], 10);
|
|
|
|
|
inHunk = true;
|
|
|
|
|
result.push({ type: 'hunk', content: line });
|
|
|
|
|
// We need to adjust the starting point because the first line number applies to the *first* actual line change/context,
|
|
|
|
|
// but we increment *before* pushing that line. So decrement here.
|
|
|
|
|
currentOldLine--;
|
|
|
|
|
currentNewLine--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!inHunk) {
|
2025-04-17 18:06:21 -04:00
|
|
|
// Skip standard Git header lines more robustly
|
|
|
|
|
if (
|
|
|
|
|
line.startsWith('--- ') ||
|
|
|
|
|
line.startsWith('+++ ') ||
|
|
|
|
|
line.startsWith('diff --git') ||
|
|
|
|
|
line.startsWith('index ') ||
|
|
|
|
|
line.startsWith('similarity index') ||
|
|
|
|
|
line.startsWith('rename from') ||
|
|
|
|
|
line.startsWith('rename to') ||
|
|
|
|
|
line.startsWith('new file mode') ||
|
|
|
|
|
line.startsWith('deleted file mode')
|
|
|
|
|
)
|
|
|
|
|
continue;
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
// If it's not a hunk or header, skip (or handle as 'other' if needed)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (line.startsWith('+')) {
|
|
|
|
|
currentNewLine++; // Increment before pushing
|
2025-04-17 18:06:21 -04:00
|
|
|
result.push({
|
|
|
|
|
type: 'add',
|
|
|
|
|
newLine: currentNewLine,
|
|
|
|
|
content: line.substring(1),
|
|
|
|
|
});
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
} else if (line.startsWith('-')) {
|
|
|
|
|
currentOldLine++; // Increment before pushing
|
2025-04-17 18:06:21 -04:00
|
|
|
result.push({
|
|
|
|
|
type: 'del',
|
|
|
|
|
oldLine: currentOldLine,
|
|
|
|
|
content: line.substring(1),
|
|
|
|
|
});
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
} else if (line.startsWith(' ')) {
|
|
|
|
|
currentOldLine++; // Increment before pushing
|
|
|
|
|
currentNewLine++;
|
2025-04-17 18:06:21 -04:00
|
|
|
result.push({
|
|
|
|
|
type: 'context',
|
|
|
|
|
oldLine: currentOldLine,
|
|
|
|
|
newLine: currentNewLine,
|
|
|
|
|
content: line.substring(1),
|
|
|
|
|
});
|
|
|
|
|
} else if (line.startsWith('\\')) {
|
|
|
|
|
// Handle "\ No newline at end of file"
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
result.push({ type: 'other', content: line });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface DiffRendererProps {
|
|
|
|
|
diffContent: string;
|
|
|
|
|
filename?: string;
|
|
|
|
|
tabWidth?: number;
|
2025-06-19 20:17:23 +00:00
|
|
|
availableTerminalHeight?: number;
|
|
|
|
|
terminalWidth: number;
|
2025-07-20 16:51:18 +09:00
|
|
|
theme?: import('../../themes/theme.js').Theme;
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DEFAULT_TAB_WIDTH = 4; // Spaces per tab for normalization
|
|
|
|
|
|
2025-04-18 19:09:41 -04:00
|
|
|
export const DiffRenderer: React.FC<DiffRendererProps> = ({
|
2025-04-17 18:06:21 -04:00
|
|
|
diffContent,
|
2025-04-25 17:11:08 -07:00
|
|
|
filename,
|
2025-04-17 18:06:21 -04:00
|
|
|
tabWidth = DEFAULT_TAB_WIDTH,
|
2025-06-19 20:17:23 +00:00
|
|
|
availableTerminalHeight,
|
|
|
|
|
terminalWidth,
|
2025-07-20 16:51:18 +09:00
|
|
|
theme,
|
2025-04-17 18:06:21 -04:00
|
|
|
}) => {
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
if (!diffContent || typeof diffContent !== 'string') {
|
2025-08-15 20:18:31 -07:00
|
|
|
return <Text color={Colors.AccentYellow}>No diff content.</Text>;
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const parsedLines = parseDiffWithLineNumbers(diffContent);
|
|
|
|
|
|
2025-05-15 23:51:53 -07:00
|
|
|
if (parsedLines.length === 0) {
|
|
|
|
|
return (
|
2025-08-15 20:18:31 -07:00
|
|
|
<Box borderStyle="round" borderColor={Colors.Gray} padding={1}>
|
2025-05-15 23:51:53 -07:00
|
|
|
<Text dimColor>No changes detected.</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-27 23:19:08 -07:00
|
|
|
// Check if the diff represents a new file (only additions and header lines)
|
|
|
|
|
const isNewFile = parsedLines.every(
|
|
|
|
|
(line) =>
|
|
|
|
|
line.type === 'add' ||
|
|
|
|
|
line.type === 'hunk' ||
|
|
|
|
|
line.type === 'other' ||
|
|
|
|
|
line.content.startsWith('diff --git') ||
|
|
|
|
|
line.content.startsWith('new file mode'),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let renderedOutput;
|
|
|
|
|
|
|
|
|
|
if (isNewFile) {
|
|
|
|
|
// Extract only the added lines' content
|
|
|
|
|
const addedContent = parsedLines
|
|
|
|
|
.filter((line) => line.type === 'add')
|
|
|
|
|
.map((line) => line.content)
|
|
|
|
|
.join('\n');
|
|
|
|
|
// Attempt to infer language from filename, default to plain text if no filename
|
|
|
|
|
const fileExtension = filename?.split('.').pop() || null;
|
|
|
|
|
const language = fileExtension
|
|
|
|
|
? getLanguageFromExtension(fileExtension)
|
|
|
|
|
: null;
|
2025-06-19 20:17:23 +00:00
|
|
|
renderedOutput = colorizeCode(
|
|
|
|
|
addedContent,
|
|
|
|
|
language,
|
|
|
|
|
availableTerminalHeight,
|
|
|
|
|
terminalWidth,
|
2025-07-20 16:51:18 +09:00
|
|
|
theme,
|
2025-06-19 20:17:23 +00:00
|
|
|
);
|
2025-04-27 23:19:08 -07:00
|
|
|
} else {
|
2025-06-19 20:17:23 +00:00
|
|
|
renderedOutput = renderDiffContent(
|
|
|
|
|
parsedLines,
|
|
|
|
|
filename,
|
|
|
|
|
tabWidth,
|
|
|
|
|
availableTerminalHeight,
|
|
|
|
|
terminalWidth,
|
|
|
|
|
);
|
2025-04-27 23:19:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return renderedOutput;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const renderDiffContent = (
|
|
|
|
|
parsedLines: DiffLine[],
|
2025-06-19 20:17:23 +00:00
|
|
|
filename: string | undefined,
|
2025-04-27 23:19:08 -07:00
|
|
|
tabWidth = DEFAULT_TAB_WIDTH,
|
2025-06-19 20:17:23 +00:00
|
|
|
availableTerminalHeight: number | undefined,
|
|
|
|
|
terminalWidth: number,
|
2025-04-27 23:19:08 -07:00
|
|
|
) => {
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
// 1. Normalize whitespace (replace tabs with spaces) *before* further processing
|
2025-04-17 18:06:21 -04:00
|
|
|
const normalizedLines = parsedLines.map((line) => ({
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
...line,
|
2025-04-17 18:06:21 -04:00
|
|
|
content: line.content.replace(/\t/g, ' '.repeat(tabWidth)),
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// Filter out non-displayable lines (hunks, potentially 'other') using the normalized list
|
2025-04-17 18:06:21 -04:00
|
|
|
const displayableLines = normalizedLines.filter(
|
|
|
|
|
(l) => l.type !== 'hunk' && l.type !== 'other',
|
|
|
|
|
);
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
|
|
|
|
|
if (displayableLines.length === 0) {
|
|
|
|
|
return (
|
2025-08-15 20:18:31 -07:00
|
|
|
<Box borderStyle="round" borderColor={Colors.Gray} padding={1}>
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
<Text dimColor>No changes detected.</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-23 15:39:22 -07:00
|
|
|
const maxLineNumber = Math.max(
|
|
|
|
|
0,
|
|
|
|
|
...displayableLines.map((l) => l.oldLine ?? 0),
|
|
|
|
|
...displayableLines.map((l) => l.newLine ?? 0),
|
|
|
|
|
);
|
|
|
|
|
const gutterWidth = Math.max(1, maxLineNumber.toString().length);
|
|
|
|
|
|
|
|
|
|
const fileExtension = filename?.split('.').pop() || null;
|
|
|
|
|
const language = fileExtension
|
|
|
|
|
? getLanguageFromExtension(fileExtension)
|
|
|
|
|
: null;
|
|
|
|
|
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
// Calculate the minimum indentation across all displayable lines
|
|
|
|
|
let baseIndentation = Infinity; // Start high to find the minimum
|
|
|
|
|
for (const line of displayableLines) {
|
|
|
|
|
// Only consider lines with actual content for indentation calculation
|
|
|
|
|
if (line.content.trim() === '') continue;
|
|
|
|
|
|
|
|
|
|
const firstCharIndex = line.content.search(/\S/); // Find index of first non-whitespace char
|
2025-04-17 18:06:21 -04:00
|
|
|
const currentIndent = firstCharIndex === -1 ? 0 : firstCharIndex; // Indent is 0 if no non-whitespace found
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
baseIndentation = Math.min(baseIndentation, currentIndent);
|
|
|
|
|
}
|
|
|
|
|
// If baseIndentation remained Infinity (e.g., no displayable lines with content), default to 0
|
|
|
|
|
if (!isFinite(baseIndentation)) {
|
|
|
|
|
baseIndentation = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-25 17:11:08 -07:00
|
|
|
const key = filename
|
|
|
|
|
? `diff-box-${filename}`
|
2025-04-27 23:19:08 -07:00
|
|
|
: `diff-box-${crypto.createHash('sha1').update(JSON.stringify(parsedLines)).digest('hex')}`;
|
|
|
|
|
|
2025-05-19 23:44:24 -07:00
|
|
|
let lastLineNumber: number | null = null;
|
2025-05-25 10:26:51 -07:00
|
|
|
const MAX_CONTEXT_LINES_WITHOUT_GAP = 5;
|
2025-05-19 23:44:24 -07:00
|
|
|
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
return (
|
2025-06-19 20:17:23 +00:00
|
|
|
<MaxSizedBox
|
|
|
|
|
maxHeight={availableTerminalHeight}
|
|
|
|
|
maxWidth={terminalWidth}
|
|
|
|
|
key={key}
|
|
|
|
|
>
|
2025-05-19 23:44:24 -07:00
|
|
|
{displayableLines.reduce<React.ReactNode[]>((acc, line, index) => {
|
|
|
|
|
// Determine the relevant line number for gap calculation based on type
|
|
|
|
|
let relevantLineNumberForGapCalc: number | null = null;
|
|
|
|
|
if (line.type === 'add' || line.type === 'context') {
|
|
|
|
|
relevantLineNumberForGapCalc = line.newLine ?? null;
|
|
|
|
|
} else if (line.type === 'del') {
|
|
|
|
|
// For deletions, the gap is typically in relation to the original file's line numbering
|
|
|
|
|
relevantLineNumberForGapCalc = line.oldLine ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
lastLineNumber !== null &&
|
|
|
|
|
relevantLineNumberForGapCalc !== null &&
|
|
|
|
|
relevantLineNumberForGapCalc >
|
|
|
|
|
lastLineNumber + MAX_CONTEXT_LINES_WITHOUT_GAP + 1
|
|
|
|
|
) {
|
|
|
|
|
acc.push(
|
2025-06-19 20:17:23 +00:00
|
|
|
<Box key={`gap-${index}`}>
|
2025-08-15 20:18:31 -07:00
|
|
|
<Text wrap="truncate" color={Colors.Gray}>
|
2025-07-23 15:39:22 -07:00
|
|
|
{'═'.repeat(terminalWidth)}
|
|
|
|
|
</Text>
|
2025-06-19 20:17:23 +00:00
|
|
|
</Box>,
|
2025-05-19 23:44:24 -07:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const lineKey = `diff-line-${index}`;
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
let gutterNumStr = '';
|
|
|
|
|
let prefixSymbol = ' ';
|
|
|
|
|
|
|
|
|
|
switch (line.type) {
|
|
|
|
|
case 'add':
|
|
|
|
|
gutterNumStr = (line.newLine ?? '').toString();
|
|
|
|
|
prefixSymbol = '+';
|
2025-05-19 23:44:24 -07:00
|
|
|
lastLineNumber = line.newLine ?? null;
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
break;
|
|
|
|
|
case 'del':
|
|
|
|
|
gutterNumStr = (line.oldLine ?? '').toString();
|
|
|
|
|
prefixSymbol = '-';
|
2025-05-19 23:44:24 -07:00
|
|
|
// For deletions, update lastLineNumber based on oldLine if it's advancing.
|
|
|
|
|
// This helps manage gaps correctly if there are multiple consecutive deletions
|
|
|
|
|
// or if a deletion is followed by a context line far away in the original file.
|
|
|
|
|
if (line.oldLine !== undefined) {
|
|
|
|
|
lastLineNumber = line.oldLine;
|
|
|
|
|
}
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
break;
|
|
|
|
|
case 'context':
|
|
|
|
|
gutterNumStr = (line.newLine ?? '').toString();
|
|
|
|
|
prefixSymbol = ' ';
|
2025-05-19 23:44:24 -07:00
|
|
|
lastLineNumber = line.newLine ?? null;
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
break;
|
2025-04-18 19:09:41 -04:00
|
|
|
default:
|
2025-05-19 23:44:24 -07:00
|
|
|
return acc;
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const displayContent = line.content.substring(baseIndentation);
|
|
|
|
|
|
2025-05-19 23:44:24 -07:00
|
|
|
acc.push(
|
|
|
|
|
<Box key={lineKey} flexDirection="row">
|
2025-08-14 23:18:39 -07:00
|
|
|
<Text
|
2025-08-15 20:18:31 -07:00
|
|
|
color={theme.text.secondary}
|
2025-08-14 23:18:39 -07:00
|
|
|
backgroundColor={
|
|
|
|
|
line.type === 'add'
|
2025-08-15 20:18:31 -07:00
|
|
|
? theme.background.diff.added
|
2025-08-14 23:18:39 -07:00
|
|
|
: line.type === 'del'
|
2025-08-15 20:18:31 -07:00
|
|
|
? theme.background.diff.removed
|
2025-08-14 23:18:39 -07:00
|
|
|
: undefined
|
|
|
|
|
}
|
|
|
|
|
>
|
2025-07-23 15:39:22 -07:00
|
|
|
{gutterNumStr.padStart(gutterWidth)}{' '}
|
2025-04-17 18:06:21 -04:00
|
|
|
</Text>
|
2025-07-23 15:39:22 -07:00
|
|
|
{line.type === 'context' ? (
|
|
|
|
|
<>
|
2025-08-15 20:18:31 -07:00
|
|
|
<Text>{prefixSymbol} </Text>
|
2025-07-23 15:39:22 -07:00
|
|
|
<Text wrap="wrap">
|
2025-08-15 20:18:31 -07:00
|
|
|
{colorizeLine(displayContent, language)}
|
2025-07-23 15:39:22 -07:00
|
|
|
</Text>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<Text
|
|
|
|
|
backgroundColor={
|
2025-08-14 23:18:39 -07:00
|
|
|
line.type === 'add'
|
2025-08-15 20:18:31 -07:00
|
|
|
? theme.background.diff.added
|
|
|
|
|
: theme.background.diff.removed
|
2025-07-23 15:39:22 -07:00
|
|
|
}
|
|
|
|
|
wrap="wrap"
|
|
|
|
|
>
|
2025-08-14 23:18:39 -07:00
|
|
|
<Text
|
|
|
|
|
color={
|
|
|
|
|
line.type === 'add'
|
2025-08-15 20:18:31 -07:00
|
|
|
? theme.status.success
|
|
|
|
|
: theme.status.error
|
2025-08-14 23:18:39 -07:00
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{prefixSymbol}
|
|
|
|
|
</Text>{' '}
|
2025-08-15 20:18:31 -07:00
|
|
|
{colorizeLine(displayContent, language)}
|
2025-07-23 15:39:22 -07:00
|
|
|
</Text>
|
|
|
|
|
)}
|
2025-05-19 23:44:24 -07:00
|
|
|
</Box>,
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
);
|
2025-05-19 23:44:24 -07:00
|
|
|
return acc;
|
|
|
|
|
}, [])}
|
2025-06-19 20:17:23 +00:00
|
|
|
</MaxSizedBox>
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
);
|
|
|
|
|
};
|
2025-04-27 23:19:08 -07:00
|
|
|
|
|
|
|
|
const getLanguageFromExtension = (extension: string): string | null => {
|
|
|
|
|
const languageMap: { [key: string]: string } = {
|
2025-05-15 23:51:53 -07:00
|
|
|
js: 'javascript',
|
|
|
|
|
ts: 'typescript',
|
|
|
|
|
py: 'python',
|
|
|
|
|
json: 'json',
|
|
|
|
|
css: 'css',
|
|
|
|
|
html: 'html',
|
|
|
|
|
sh: 'bash',
|
|
|
|
|
md: 'markdown',
|
|
|
|
|
yaml: 'yaml',
|
|
|
|
|
yml: 'yaml',
|
|
|
|
|
txt: 'plaintext',
|
|
|
|
|
java: 'java',
|
|
|
|
|
c: 'c',
|
|
|
|
|
cpp: 'cpp',
|
|
|
|
|
rb: 'ruby',
|
2025-04-27 23:19:08 -07:00
|
|
|
};
|
|
|
|
|
return languageMap[extension] || null; // Return null if extension not found
|
|
|
|
|
};
|