2025-04-18 17:44:24 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-26 00:04:53 +02:00
|
|
|
import type { ThoughtSummary } from '@google/gemini-cli-core';
|
|
|
|
|
import type React from 'react';
|
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 { Box, Text } from 'ink';
|
2025-09-10 10:57:07 -07:00
|
|
|
import { theme } from '../semantic-colors.js';
|
2025-05-24 00:44:17 -07:00
|
|
|
import { useStreamingContext } from '../contexts/StreamingContext.js';
|
|
|
|
|
import { StreamingState } from '../types.js';
|
2025-05-28 18:17:19 +00:00
|
|
|
import { GeminiRespondingSpinner } from './GeminiRespondingSpinner.js';
|
2025-07-08 11:14:42 +05:00
|
|
|
import { formatDuration } from '../utils/formatters.js';
|
2025-08-07 15:55:53 -07:00
|
|
|
import { useTerminalSize } from '../hooks/useTerminalSize.js';
|
|
|
|
|
import { isNarrowWidth } from '../utils/isNarrowWidth.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 LoadingIndicatorProps {
|
2025-06-04 00:46:57 -07:00
|
|
|
currentLoadingPhrase?: string;
|
2025-04-17 18:06:21 -04:00
|
|
|
elapsedTime: number;
|
2025-05-17 21:25:28 -07:00
|
|
|
rightContent?: React.ReactNode;
|
2025-06-15 11:19:05 -07:00
|
|
|
thought?: ThoughtSummary | 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
|
|
|
}
|
|
|
|
|
|
2025-04-18 19:09:41 -04:00
|
|
|
export const LoadingIndicator: React.FC<LoadingIndicatorProps> = ({
|
2025-04-17 18:06:21 -04:00
|
|
|
currentLoadingPhrase,
|
|
|
|
|
elapsedTime,
|
2025-05-17 21:25:28 -07:00
|
|
|
rightContent,
|
2025-06-15 11:19:05 -07:00
|
|
|
thought,
|
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-28 19:46:08 +00:00
|
|
|
const streamingState = useStreamingContext();
|
2025-08-07 15:55:53 -07:00
|
|
|
const { columns: terminalWidth } = useTerminalSize();
|
|
|
|
|
const isNarrow = isNarrowWidth(terminalWidth);
|
2025-05-24 00:44:17 -07:00
|
|
|
|
|
|
|
|
if (streamingState === StreamingState.Idle) {
|
2025-05-23 10:25:17 -07:00
|
|
|
return null;
|
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
|
|
|
|
2025-06-15 11:19:05 -07:00
|
|
|
const primaryText = thought?.subject || currentLoadingPhrase;
|
|
|
|
|
|
2025-08-07 15:55:53 -07:00
|
|
|
const cancelAndTimerContent =
|
|
|
|
|
streamingState !== StreamingState.WaitingForConfirmation
|
|
|
|
|
? `(esc to cancel, ${elapsedTime < 60 ? `${elapsedTime}s` : formatDuration(elapsedTime * 1000)})`
|
|
|
|
|
: null;
|
|
|
|
|
|
2025-04-17 18:06:21 -04:00
|
|
|
return (
|
2025-08-07 15:55:53 -07:00
|
|
|
<Box paddingLeft={0} flexDirection="column">
|
2025-06-15 11:19:05 -07:00
|
|
|
{/* Main loading line */}
|
2025-08-07 15:55:53 -07:00
|
|
|
<Box
|
|
|
|
|
width="100%"
|
|
|
|
|
flexDirection={isNarrow ? 'column' : 'row'}
|
|
|
|
|
alignItems={isNarrow ? 'flex-start' : 'center'}
|
|
|
|
|
>
|
|
|
|
|
<Box>
|
|
|
|
|
<Box marginRight={1}>
|
|
|
|
|
<GeminiRespondingSpinner
|
|
|
|
|
nonRespondingDisplay={
|
|
|
|
|
streamingState === StreamingState.WaitingForConfirmation
|
|
|
|
|
? '⠏'
|
|
|
|
|
: ''
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2025-09-25 11:33:06 -07:00
|
|
|
{primaryText && (
|
|
|
|
|
<Text color={theme.text.accent} wrap="truncate-end">
|
|
|
|
|
{primaryText}
|
|
|
|
|
</Text>
|
|
|
|
|
)}
|
2025-08-07 15:55:53 -07:00
|
|
|
{!isNarrow && cancelAndTimerContent && (
|
2025-10-31 07:43:12 -07:00
|
|
|
<>
|
|
|
|
|
<Box flexShrink={0} width={1} />
|
|
|
|
|
<Text color={theme.text.secondary}>{cancelAndTimerContent}</Text>
|
|
|
|
|
</>
|
2025-08-07 15:55:53 -07:00
|
|
|
)}
|
2025-06-15 11:19:05 -07:00
|
|
|
</Box>
|
2025-08-07 15:55:53 -07:00
|
|
|
{!isNarrow && <Box flexGrow={1}>{/* Spacer */}</Box>}
|
|
|
|
|
{!isNarrow && rightContent && <Box>{rightContent}</Box>}
|
2025-05-28 18:17:19 +00:00
|
|
|
</Box>
|
2025-08-07 15:55:53 -07:00
|
|
|
{isNarrow && cancelAndTimerContent && (
|
|
|
|
|
<Box>
|
2025-09-10 10:57:07 -07:00
|
|
|
<Text color={theme.text.secondary}>{cancelAndTimerContent}</Text>
|
2025-08-07 15:55:53 -07:00
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
{isNarrow && rightContent && <Box>{rightContent}</Box>}
|
2025-04-17 18:06:21 -04: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
|
|
|
};
|