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';
|
|
|
|
|
import { Box, Text, useInput } from 'ink';
|
2025-04-21 10:53:11 -04:00
|
|
|
import { DiffRenderer } from './DiffRenderer.js';
|
|
|
|
|
import { Colors } from '../../colors.js';
|
2025-04-17 18:06:21 -04:00
|
|
|
import {
|
|
|
|
|
ToolCallConfirmationDetails,
|
|
|
|
|
ToolConfirmationOutcome,
|
|
|
|
|
ToolExecuteConfirmationDetails,
|
2025-05-30 15:32:21 -07:00
|
|
|
ToolMcpConfirmationDetails,
|
2025-06-08 18:56:58 +01:00
|
|
|
Config,
|
2025-06-25 05:41:11 -07:00
|
|
|
} from '@google/gemini-cli-core';
|
2025-04-22 18:25:03 -07:00
|
|
|
import {
|
|
|
|
|
RadioButtonSelect,
|
|
|
|
|
RadioSelectItem,
|
|
|
|
|
} from '../shared/RadioButtonSelect.js';
|
2025-06-19 20:17:23 +00:00
|
|
|
import { MaxSizedBox } from '../shared/MaxSizedBox.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
|
|
|
|
|
|
|
|
export interface ToolConfirmationMessageProps {
|
|
|
|
|
confirmationDetails: ToolCallConfirmationDetails;
|
2025-06-08 18:56:58 +01:00
|
|
|
config?: Config;
|
2025-06-12 02:21:54 +01:00
|
|
|
isFocused?: boolean;
|
2025-06-19 20:17:23 +00:00
|
|
|
availableTerminalHeight?: number;
|
|
|
|
|
terminalWidth: number;
|
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 ToolConfirmationMessage: React.FC<
|
|
|
|
|
ToolConfirmationMessageProps
|
2025-06-19 20:17:23 +00:00
|
|
|
> = ({
|
|
|
|
|
confirmationDetails,
|
2025-08-06 17:36:05 +00:00
|
|
|
config,
|
2025-06-19 20:17:23 +00:00
|
|
|
isFocused = true,
|
|
|
|
|
availableTerminalHeight,
|
|
|
|
|
terminalWidth,
|
|
|
|
|
}) => {
|
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 { onConfirm } = confirmationDetails;
|
2025-06-19 20:17:23 +00:00
|
|
|
const childWidth = terminalWidth - 2; // 2 for padding
|
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-08-06 17:36:05 +00:00
|
|
|
const handleConfirm = async (outcome: ToolConfirmationOutcome) => {
|
|
|
|
|
if (confirmationDetails.type === 'edit') {
|
|
|
|
|
const ideClient = config?.getIdeClient();
|
|
|
|
|
if (config?.getIdeMode() && config?.getIdeModeFeature()) {
|
|
|
|
|
const cliOutcome =
|
|
|
|
|
outcome === ToolConfirmationOutcome.Cancel ? 'rejected' : 'accepted';
|
|
|
|
|
await ideClient?.resolveDiffFromCli(
|
|
|
|
|
confirmationDetails.filePath,
|
|
|
|
|
cliOutcome,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onConfirm(outcome);
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-12 09:43:57 +05:30
|
|
|
useInput((input, key) => {
|
2025-06-12 02:21:54 +01:00
|
|
|
if (!isFocused) return;
|
2025-08-12 09:43:57 +05:30
|
|
|
if (key.escape || (key.ctrl && (input === 'c' || input === 'C'))) {
|
2025-08-06 17:36:05 +00:00
|
|
|
handleConfirm(ToolConfirmationOutcome.Cancel);
|
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-08-06 17:36:05 +00:00
|
|
|
const handleSelect = (item: ToolConfirmationOutcome) => handleConfirm(item);
|
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 bodyContent: React.ReactNode | null = null; // Removed contextDisplay here
|
|
|
|
|
let question: string;
|
2025-04-22 18:25:03 -07:00
|
|
|
|
|
|
|
|
const options: Array<RadioSelectItem<ToolConfirmationOutcome>> = new Array<
|
|
|
|
|
RadioSelectItem<ToolConfirmationOutcome>
|
|
|
|
|
>();
|
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-19 20:17:23 +00:00
|
|
|
// Body content is now the DiffRenderer, passing filename to it
|
|
|
|
|
// The bordered box is removed from here and handled within DiffRenderer
|
|
|
|
|
|
|
|
|
|
function availableBodyContentHeight() {
|
|
|
|
|
if (options.length === 0) {
|
|
|
|
|
// This should not happen in practice as options are always added before this is called.
|
|
|
|
|
throw new Error('Options not provided for confirmation message');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (availableTerminalHeight === undefined) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculate the vertical space (in lines) consumed by UI elements
|
|
|
|
|
// surrounding the main body content.
|
|
|
|
|
const PADDING_OUTER_Y = 2; // Main container has `padding={1}` (top & bottom).
|
|
|
|
|
const MARGIN_BODY_BOTTOM = 1; // margin on the body container.
|
|
|
|
|
const HEIGHT_QUESTION = 1; // The question text is one line.
|
|
|
|
|
const MARGIN_QUESTION_BOTTOM = 1; // Margin on the question container.
|
|
|
|
|
const HEIGHT_OPTIONS = options.length; // Each option in the radio select takes one line.
|
|
|
|
|
|
|
|
|
|
const surroundingElementsHeight =
|
|
|
|
|
PADDING_OUTER_Y +
|
|
|
|
|
MARGIN_BODY_BOTTOM +
|
|
|
|
|
HEIGHT_QUESTION +
|
|
|
|
|
MARGIN_QUESTION_BOTTOM +
|
|
|
|
|
HEIGHT_OPTIONS;
|
|
|
|
|
return Math.max(availableTerminalHeight - surroundingElementsHeight, 1);
|
|
|
|
|
}
|
2025-08-06 17:36:05 +00:00
|
|
|
|
2025-05-22 06:00:36 +00:00
|
|
|
if (confirmationDetails.type === 'edit') {
|
2025-06-08 18:56:58 +01:00
|
|
|
if (confirmationDetails.isModifying) {
|
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
minWidth="90%"
|
|
|
|
|
borderStyle="round"
|
|
|
|
|
borderColor={Colors.Gray}
|
|
|
|
|
justifyContent="space-around"
|
|
|
|
|
padding={1}
|
|
|
|
|
overflow="hidden"
|
|
|
|
|
>
|
|
|
|
|
<Text>Modify in progress: </Text>
|
|
|
|
|
<Text color={Colors.AccentGreen}>
|
|
|
|
|
Save and close external editor to continue
|
|
|
|
|
</Text>
|
|
|
|
|
</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
|
|
|
question = `Apply this change?`;
|
|
|
|
|
options.push(
|
2025-04-17 18:06:21 -04:00
|
|
|
{
|
2025-04-25 14:05:58 -07:00
|
|
|
label: 'Yes, allow once',
|
2025-04-17 18:06:21 -04:00
|
|
|
value: ToolConfirmationOutcome.ProceedOnce,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-04-25 14:16:24 -07:00
|
|
|
label: 'Yes, allow always',
|
2025-04-17 18:06:21 -04:00
|
|
|
value: ToolConfirmationOutcome.ProceedAlways,
|
|
|
|
|
},
|
2025-08-06 17:36:05 +00:00
|
|
|
);
|
|
|
|
|
if (config?.getIdeMode() && config?.getIdeModeFeature()) {
|
|
|
|
|
options.push({
|
2025-08-11 21:06:01 +00:00
|
|
|
label: 'No (esc)',
|
2025-08-06 17:36:05 +00:00
|
|
|
value: ToolConfirmationOutcome.Cancel,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
options.push({
|
2025-06-12 02:21:54 +01:00
|
|
|
label: 'Modify with external editor',
|
|
|
|
|
value: ToolConfirmationOutcome.ModifyWithEditor,
|
2025-08-06 17:36:05 +00:00
|
|
|
});
|
|
|
|
|
options.push({
|
2025-07-30 16:37:51 -04:00
|
|
|
label: 'No, suggest changes (esc)',
|
|
|
|
|
value: ToolConfirmationOutcome.Cancel,
|
2025-08-06 17:36:05 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-19 20:17:23 +00:00
|
|
|
bodyContent = (
|
|
|
|
|
<DiffRenderer
|
|
|
|
|
diffContent={confirmationDetails.fileDiff}
|
|
|
|
|
filename={confirmationDetails.fileName}
|
|
|
|
|
availableTerminalHeight={availableBodyContentHeight()}
|
|
|
|
|
terminalWidth={childWidth}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2025-05-30 15:32:21 -07:00
|
|
|
} else if (confirmationDetails.type === 'exec') {
|
2025-04-17 18:06:21 -04:00
|
|
|
const executionProps =
|
|
|
|
|
confirmationDetails as ToolExecuteConfirmationDetails;
|
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-07-25 12:25:32 -07:00
|
|
|
question = `Allow execution of: '${executionProps.rootCommand}'?`;
|
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
|
|
|
options.push(
|
2025-04-17 18:06:21 -04:00
|
|
|
{
|
2025-07-25 12:25:32 -07:00
|
|
|
label: `Yes, allow once`,
|
2025-04-17 18:06:21 -04:00
|
|
|
value: ToolConfirmationOutcome.ProceedOnce,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 12:25:32 -07:00
|
|
|
label: `Yes, allow always ...`,
|
2025-04-17 18:06:21 -04:00
|
|
|
value: ToolConfirmationOutcome.ProceedAlways,
|
|
|
|
|
},
|
2025-07-30 16:37:51 -04:00
|
|
|
{
|
|
|
|
|
label: 'No, suggest changes (esc)',
|
|
|
|
|
value: ToolConfirmationOutcome.Cancel,
|
|
|
|
|
},
|
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-19 20:17:23 +00:00
|
|
|
|
|
|
|
|
let bodyContentHeight = availableBodyContentHeight();
|
|
|
|
|
if (bodyContentHeight !== undefined) {
|
|
|
|
|
bodyContentHeight -= 2; // Account for padding;
|
|
|
|
|
}
|
|
|
|
|
bodyContent = (
|
|
|
|
|
<Box flexDirection="column">
|
|
|
|
|
<Box paddingX={1} marginLeft={1}>
|
|
|
|
|
<MaxSizedBox
|
|
|
|
|
maxHeight={bodyContentHeight}
|
|
|
|
|
maxWidth={Math.max(childWidth - 4, 1)}
|
|
|
|
|
>
|
|
|
|
|
<Box>
|
|
|
|
|
<Text color={Colors.AccentCyan}>{executionProps.command}</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
</MaxSizedBox>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
2025-06-13 17:44:14 -07:00
|
|
|
} else if (confirmationDetails.type === 'info') {
|
|
|
|
|
const infoProps = confirmationDetails;
|
|
|
|
|
const displayUrls =
|
|
|
|
|
infoProps.urls &&
|
|
|
|
|
!(infoProps.urls.length === 1 && infoProps.urls[0] === infoProps.prompt);
|
|
|
|
|
|
2025-06-19 20:17:23 +00:00
|
|
|
question = `Do you want to proceed?`;
|
|
|
|
|
options.push(
|
|
|
|
|
{
|
|
|
|
|
label: 'Yes, allow once',
|
|
|
|
|
value: ToolConfirmationOutcome.ProceedOnce,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Yes, allow always',
|
|
|
|
|
value: ToolConfirmationOutcome.ProceedAlways,
|
|
|
|
|
},
|
2025-07-30 16:37:51 -04:00
|
|
|
{
|
|
|
|
|
label: 'No, suggest changes (esc)',
|
|
|
|
|
value: ToolConfirmationOutcome.Cancel,
|
|
|
|
|
},
|
2025-06-19 20:17:23 +00:00
|
|
|
);
|
|
|
|
|
|
2025-06-13 17:44:14 -07:00
|
|
|
bodyContent = (
|
|
|
|
|
<Box flexDirection="column" paddingX={1} marginLeft={1}>
|
|
|
|
|
<Text color={Colors.AccentCyan}>{infoProps.prompt}</Text>
|
|
|
|
|
{displayUrls && infoProps.urls && infoProps.urls.length > 0 && (
|
|
|
|
|
<Box flexDirection="column" marginTop={1}>
|
|
|
|
|
<Text>URLs to fetch:</Text>
|
|
|
|
|
{infoProps.urls.map((url) => (
|
|
|
|
|
<Text key={url}> - {url}</Text>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
2025-05-30 15:32:21 -07:00
|
|
|
} else {
|
|
|
|
|
// mcp tool confirmation
|
|
|
|
|
const mcpProps = confirmationDetails as ToolMcpConfirmationDetails;
|
|
|
|
|
|
|
|
|
|
bodyContent = (
|
|
|
|
|
<Box flexDirection="column" paddingX={1} marginLeft={1}>
|
|
|
|
|
<Text color={Colors.AccentCyan}>MCP Server: {mcpProps.serverName}</Text>
|
|
|
|
|
<Text color={Colors.AccentCyan}>Tool: {mcpProps.toolName}</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
question = `Allow execution of MCP tool "${mcpProps.toolName}" from server "${mcpProps.serverName}"?`;
|
|
|
|
|
options.push(
|
|
|
|
|
{
|
|
|
|
|
label: 'Yes, allow once',
|
|
|
|
|
value: ToolConfirmationOutcome.ProceedOnce,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: `Yes, always allow tool "${mcpProps.toolName}" from server "${mcpProps.serverName}"`,
|
|
|
|
|
value: ToolConfirmationOutcome.ProceedAlwaysTool, // Cast until types are updated
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: `Yes, always allow all tools from server "${mcpProps.serverName}"`,
|
|
|
|
|
value: ToolConfirmationOutcome.ProceedAlwaysServer,
|
|
|
|
|
},
|
2025-07-30 16:37:51 -04:00
|
|
|
{
|
|
|
|
|
label: 'No, suggest changes (esc)',
|
|
|
|
|
value: ToolConfirmationOutcome.Cancel,
|
|
|
|
|
},
|
2025-05-30 15:32:21 -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
|
|
|
<Box flexDirection="column" padding={1} width={childWidth}>
|
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
|
|
|
{/* Body Content (Diff Renderer or Command Info) */}
|
|
|
|
|
{/* No separate context display here anymore for edits */}
|
|
|
|
|
<Box flexGrow={1} flexShrink={1} overflow="hidden" marginBottom={1}>
|
2025-04-17 18:06:21 -04:00
|
|
|
{bodyContent}
|
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
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
{/* Confirmation Question */}
|
|
|
|
|
<Box marginBottom={1} flexShrink={0}>
|
2025-06-19 20:17:23 +00:00
|
|
|
<Text wrap="truncate">{question}</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
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
{/* Select Input for Options */}
|
|
|
|
|
<Box flexShrink={0}>
|
2025-06-12 02:21:54 +01:00
|
|
|
<RadioButtonSelect
|
|
|
|
|
items={options}
|
|
|
|
|
onSelect={handleSelect}
|
|
|
|
|
isFocused={isFocused}
|
|
|
|
|
/>
|
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
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|