2025-04-18 17:44:24 -07:00
|
|
|
|
/**
|
|
|
|
|
|
* @license
|
2026-02-09 21:53:10 -05:00
|
|
|
|
* Copyright 2026 Google LLC
|
2025-04-18 17:44:24 -07:00
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-08-26 00:04:53 +02:00
|
|
|
|
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-08-07 16:11:35 -07:00
|
|
|
|
import { theme } from '../semantic-colors.js';
|
2025-12-17 09:43:21 -08:00
|
|
|
|
import {
|
|
|
|
|
|
shortenPath,
|
|
|
|
|
|
tildeifyPath,
|
|
|
|
|
|
getDisplayString,
|
|
|
|
|
|
} from '@google/gemini-cli-core';
|
2025-05-22 10:36:44 -07:00
|
|
|
|
import { ConsoleSummaryDisplay } from './ConsoleSummaryDisplay.js';
|
2025-05-30 22:18:01 +00:00
|
|
|
|
import process from 'node:process';
|
2025-11-16 20:45:07 -08:00
|
|
|
|
import { ThemedGradient } from './ThemedGradient.js';
|
2025-05-30 22:18:01 +00:00
|
|
|
|
import { MemoryUsageDisplay } from './MemoryUsageDisplay.js';
|
2025-08-07 11:16:47 -07:00
|
|
|
|
import { ContextUsageDisplay } from './ContextUsageDisplay.js';
|
2026-02-09 21:53:10 -05:00
|
|
|
|
import { QuotaDisplay } from './QuotaDisplay.js';
|
2025-07-30 17:43:11 -07:00
|
|
|
|
import { DebugProfiler } from './DebugProfiler.js';
|
2025-10-07 10:28:35 -07:00
|
|
|
|
import { isDevelopment } from '../../utils/installationInfo.js';
|
2025-09-26 21:27:00 -04:00
|
|
|
|
import { useUIState } from '../contexts/UIStateContext.js';
|
|
|
|
|
|
import { useConfig } from '../contexts/ConfigContext.js';
|
|
|
|
|
|
import { useSettings } from '../contexts/SettingsContext.js';
|
|
|
|
|
|
import { useVimMode } from '../contexts/VimModeContext.js';
|
|
|
|
|
|
|
|
|
|
|
|
export const Footer: React.FC = () => {
|
|
|
|
|
|
const uiState = useUIState();
|
|
|
|
|
|
const config = useConfig();
|
|
|
|
|
|
const settings = useSettings();
|
|
|
|
|
|
const { vimEnabled, vimMode } = useVimMode();
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
model,
|
|
|
|
|
|
targetDir,
|
|
|
|
|
|
debugMode,
|
|
|
|
|
|
branchName,
|
|
|
|
|
|
debugMessage,
|
|
|
|
|
|
corgiMode,
|
|
|
|
|
|
errorCount,
|
|
|
|
|
|
showErrorDetails,
|
|
|
|
|
|
promptTokenCount,
|
|
|
|
|
|
nightly,
|
|
|
|
|
|
isTrustedFolder,
|
2026-01-26 15:23:54 -08:00
|
|
|
|
terminalWidth,
|
2026-02-09 21:53:10 -05:00
|
|
|
|
quotaStats,
|
2025-09-26 21:27:00 -04:00
|
|
|
|
} = {
|
2025-10-27 15:33:12 -07:00
|
|
|
|
model: uiState.currentModel,
|
2025-09-26 21:27:00 -04:00
|
|
|
|
targetDir: config.getTargetDir(),
|
|
|
|
|
|
debugMode: config.getDebugMode(),
|
|
|
|
|
|
branchName: uiState.branchName,
|
|
|
|
|
|
debugMessage: uiState.debugMessage,
|
|
|
|
|
|
corgiMode: uiState.corgiMode,
|
|
|
|
|
|
errorCount: uiState.errorCount,
|
|
|
|
|
|
showErrorDetails: uiState.showErrorDetails,
|
|
|
|
|
|
promptTokenCount: uiState.sessionStats.lastPromptTokenCount,
|
|
|
|
|
|
nightly: uiState.nightly,
|
|
|
|
|
|
isTrustedFolder: uiState.isTrustedFolder,
|
2026-01-26 15:23:54 -08:00
|
|
|
|
terminalWidth: uiState.terminalWidth,
|
2026-02-09 21:53:10 -05:00
|
|
|
|
quotaStats: uiState.quota.stats,
|
2025-09-26 21:27:00 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const showMemoryUsage =
|
2026-01-15 09:26:10 -08:00
|
|
|
|
config.getDebugMode() || settings.merged.ui.showMemoryUsage;
|
|
|
|
|
|
const hideCWD = settings.merged.ui.footer.hideCWD;
|
|
|
|
|
|
const hideSandboxStatus = settings.merged.ui.footer.hideSandboxStatus;
|
|
|
|
|
|
const hideModelInfo = settings.merged.ui.footer.hideModelInfo;
|
|
|
|
|
|
const hideContextPercentage = settings.merged.ui.footer.hideContextPercentage;
|
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
|
|
|
|
|
2026-01-26 15:23:54 -08:00
|
|
|
|
const pathLength = Math.max(20, Math.floor(terminalWidth * 0.25));
|
2025-10-09 19:27:20 -07:00
|
|
|
|
const displayPath = shortenPath(tildeifyPath(targetDir), pathLength);
|
2025-06-15 11:15:53 -07:00
|
|
|
|
|
2025-09-11 20:16:09 -04:00
|
|
|
|
const justifyContent = hideCWD && hideModelInfo ? 'center' : 'space-between';
|
2025-09-26 21:27:00 -04:00
|
|
|
|
const displayVimMode = vimEnabled ? vimMode : undefined;
|
2025-09-11 20:16:09 -04:00
|
|
|
|
|
2025-10-07 10:28:35 -07:00
|
|
|
|
const showDebugProfiler = debugMode || isDevelopment;
|
|
|
|
|
|
|
2025-08-07 15:55:53 -07:00
|
|
|
|
return (
|
2025-08-07 11:16:47 -07:00
|
|
|
|
<Box
|
2025-09-11 20:16:09 -04:00
|
|
|
|
justifyContent={justifyContent}
|
2026-01-26 15:23:54 -08:00
|
|
|
|
width={terminalWidth}
|
2025-10-09 19:27:20 -07:00
|
|
|
|
flexDirection="row"
|
|
|
|
|
|
alignItems="center"
|
|
|
|
|
|
paddingX={1}
|
2025-08-07 11:16:47 -07:00
|
|
|
|
>
|
2025-10-07 10:28:35 -07:00
|
|
|
|
{(showDebugProfiler || displayVimMode || !hideCWD) && (
|
2025-09-11 20:16:09 -04:00
|
|
|
|
<Box>
|
2025-10-07 10:28:35 -07:00
|
|
|
|
{showDebugProfiler && <DebugProfiler />}
|
2025-09-26 21:27:00 -04:00
|
|
|
|
{displayVimMode && (
|
|
|
|
|
|
<Text color={theme.text.secondary}>[{displayVimMode}] </Text>
|
|
|
|
|
|
)}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
{!hideCWD &&
|
|
|
|
|
|
(nightly ? (
|
2025-11-16 20:45:07 -08:00
|
|
|
|
<ThemedGradient>
|
|
|
|
|
|
{displayPath}
|
|
|
|
|
|
{branchName && <Text> ({branchName}*)</Text>}
|
|
|
|
|
|
</ThemedGradient>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
) : (
|
|
|
|
|
|
<Text color={theme.text.link}>
|
|
|
|
|
|
{displayPath}
|
|
|
|
|
|
{branchName && (
|
|
|
|
|
|
<Text color={theme.text.secondary}> ({branchName}*)</Text>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
))}
|
|
|
|
|
|
{debugMode && (
|
|
|
|
|
|
<Text color={theme.status.error}>
|
|
|
|
|
|
{' ' + (debugMessage || '--debug')}
|
2025-08-07 15:55:53 -07:00
|
|
|
|
</Text>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
)}
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
)}
|
2025-08-07 15:55:53 -07:00
|
|
|
|
|
2025-08-14 11:15:48 -07:00
|
|
|
|
{/* Middle Section: Centered Trust/Sandbox Info */}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
{!hideSandboxStatus && (
|
|
|
|
|
|
<Box
|
2025-10-09 19:27:20 -07:00
|
|
|
|
flexGrow={1}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
alignItems="center"
|
2025-10-09 19:27:20 -07:00
|
|
|
|
justifyContent="center"
|
2025-09-11 20:16:09 -04:00
|
|
|
|
display="flex"
|
|
|
|
|
|
>
|
|
|
|
|
|
{isTrustedFolder === false ? (
|
|
|
|
|
|
<Text color={theme.status.warning}>untrusted</Text>
|
|
|
|
|
|
) : process.env['SANDBOX'] &&
|
|
|
|
|
|
process.env['SANDBOX'] !== 'sandbox-exec' ? (
|
|
|
|
|
|
<Text color="green">
|
|
|
|
|
|
{process.env['SANDBOX'].replace(/^gemini-(?:cli-)?/, '')}
|
2025-08-07 16:11:35 -07:00
|
|
|
|
</Text>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
) : process.env['SANDBOX'] === 'sandbox-exec' ? (
|
|
|
|
|
|
<Text color={theme.status.warning}>
|
|
|
|
|
|
macOS Seatbelt{' '}
|
|
|
|
|
|
<Text color={theme.text.secondary}>
|
|
|
|
|
|
({process.env['SEATBELT_PROFILE']})
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Text color={theme.status.error}>
|
2025-10-09 19:27:20 -07:00
|
|
|
|
no sandbox
|
2026-01-26 15:23:54 -08:00
|
|
|
|
{terminalWidth >= 100 && (
|
2025-10-09 19:27:20 -07:00
|
|
|
|
<Text color={theme.text.secondary}> (see /docs)</Text>
|
|
|
|
|
|
)}
|
2025-09-02 10:35:43 -07:00
|
|
|
|
</Text>
|
|
|
|
|
|
)}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
</Box>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/* Right Section: Gemini Label and Console Summary */}
|
2025-10-09 19:27:20 -07:00
|
|
|
|
{!hideModelInfo && (
|
|
|
|
|
|
<Box alignItems="center" justifyContent="flex-end">
|
|
|
|
|
|
<Box alignItems="center">
|
|
|
|
|
|
<Text color={theme.text.accent}>
|
2026-02-06 13:02:57 -05:00
|
|
|
|
{getDisplayString(model)}
|
2025-12-17 09:43:21 -08:00
|
|
|
|
<Text color={theme.text.secondary}> /model</Text>
|
2025-10-30 19:18:25 -04:00
|
|
|
|
{!hideContextPercentage && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
{' '}
|
|
|
|
|
|
<ContextUsageDisplay
|
|
|
|
|
|
promptTokenCount={promptTokenCount}
|
|
|
|
|
|
model={model}
|
2026-01-26 15:23:54 -08:00
|
|
|
|
terminalWidth={terminalWidth}
|
2025-10-30 19:18:25 -04:00
|
|
|
|
/>
|
|
|
|
|
|
</>
|
2026-02-09 21:53:10 -05:00
|
|
|
|
)}
|
|
|
|
|
|
{quotaStats && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
{' '}
|
|
|
|
|
|
<QuotaDisplay
|
|
|
|
|
|
remaining={quotaStats.remaining}
|
|
|
|
|
|
limit={quotaStats.limit}
|
|
|
|
|
|
resetTime={quotaStats.resetTime}
|
|
|
|
|
|
terse={true}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</>
|
2025-10-30 19:18:25 -04:00
|
|
|
|
)}
|
2025-10-09 19:27:20 -07:00
|
|
|
|
</Text>
|
|
|
|
|
|
{showMemoryUsage && <MemoryUsageDisplay />}
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
<Box alignItems="center">
|
2025-09-11 20:16:09 -04:00
|
|
|
|
{corgiMode && (
|
2025-10-09 19:27:20 -07:00
|
|
|
|
<Box paddingLeft={1} flexDirection="row">
|
|
|
|
|
|
<Text>
|
|
|
|
|
|
<Text color={theme.ui.symbol}>| </Text>
|
|
|
|
|
|
<Text color={theme.status.error}>▼</Text>
|
|
|
|
|
|
<Text color={theme.text.primary}>(´</Text>
|
|
|
|
|
|
<Text color={theme.status.error}>ᴥ</Text>
|
|
|
|
|
|
<Text color={theme.text.primary}>`)</Text>
|
|
|
|
|
|
<Text color={theme.status.error}>▼</Text>
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</Box>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
)}
|
|
|
|
|
|
{!showErrorDetails && errorCount > 0 && (
|
2025-10-09 19:27:20 -07:00
|
|
|
|
<Box paddingLeft={1} flexDirection="row">
|
2025-10-15 10:03:10 -07:00
|
|
|
|
<Text color={theme.ui.comment}>| </Text>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
<ConsoleSummaryDisplay errorCount={errorCount} />
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Box>
|
2025-09-02 10:35:43 -07:00
|
|
|
|
</Box>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
)}
|
2025-04-21 14:43:43 -07:00
|
|
|
|
</Box>
|
2025-08-07 15:55:53 -07:00
|
|
|
|
);
|
|
|
|
|
|
};
|