From 1bfc62dcc2c10e962d4a67009027b7187e690d03 Mon Sep 17 00:00:00 2001 From: Evan Senter Date: Fri, 18 Apr 2025 17:35:29 +0100 Subject: Adding some wiring to allow the Ink app to warn if there are local development changes that haven't been captured in the recent build of the Gemini CLI. --- packages/cli/package.json | 2 +- packages/cli/src/core/gemini-client.ts | 2 +- packages/cli/src/ui/App.tsx | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/cli/package.json b/packages/cli/package.json index b5dd0c23..e2bd5c3d 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -5,7 +5,7 @@ "type": "module", "main": "dist/gemini.js", "scripts": { - "build": "tsc", + "build": "tsc && touch dist/.last_build", "start": "node dist/gemini.js", "debug": "node --inspect-brk dist/gemini.js", "lint": "eslint . --ext .ts,.tsx", diff --git a/packages/cli/src/core/gemini-client.ts b/packages/cli/src/core/gemini-client.ts index 0b79a2ad..6ce89816 100644 --- a/packages/cli/src/core/gemini-client.ts +++ b/packages/cli/src/core/gemini-client.ts @@ -9,7 +9,7 @@ import { Content, } from '@google/genai'; import { getApiKey } from '../config/env.js'; -import { getModel } from '../config/globalConfig.js'; +import { getModel } from '../config/globalConfig.js'; import { CoreSystemPrompt } from './prompts.js'; import { type ToolCallEvent, diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index 1bc0f6c6..cc440392 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -1,5 +1,8 @@ import React, { useState, useEffect } from 'react'; import { Box, Text } from 'ink'; +import fs from 'fs'; +import path from 'path'; +import os from 'os'; import type { HistoryItem } from './types.js'; import { useGeminiStream } from './hooks/useGeminiStream.js'; import { useLoadingIndicator } from './hooks/useLoadingIndicator.js'; @@ -12,6 +15,8 @@ import Footer from './components/Footer.js'; import { StreamingState } from '../core/gemini-stream.js'; import { PartListUnion } from '@google/genai'; +const warningsFilePath = path.join(os.tmpdir(), 'gemini-code-cli-warnings.txt'); + interface AppProps { directory: string; } @@ -19,11 +24,31 @@ interface AppProps { const App = ({ directory }: AppProps) => { const [query, setQuery] = useState(''); const [history, setHistory] = useState([]); + const [startupWarnings, setStartupWarnings] = useState([]); const { streamingState, submitQuery, initError } = useGeminiStream(setHistory); const { elapsedTime, currentLoadingPhrase } = useLoadingIndicator(streamingState); + useEffect(() => { + try { + if (fs.existsSync(warningsFilePath)) { + console.log('[App] Found warnings file:', warningsFilePath); + const warningsContent = fs.readFileSync(warningsFilePath, 'utf-8'); + setStartupWarnings(warningsContent.split('\n').filter(line => line.trim() !== '')); + try { + fs.unlinkSync(warningsFilePath); + } catch (unlinkErr: any) { + console.warn(`[App] Warning: Could not delete warnings file: ${unlinkErr.message}`); + } + } else { + console.log('[App] No warnings file found.'); + } + } catch (err: any) { + console.error(`[App] Error checking/reading warnings file: ${err.message}`); + } + }, []); + const handleInputSubmit = (value: PartListUnion) => { submitQuery(value) .then(() => { @@ -63,6 +88,22 @@ const App = ({ directory }: AppProps) => {
+ {startupWarnings.length > 0 && ( + + {startupWarnings.map((warning, index) => ( + + {warning} + + ))} + + )} + {initError && -- cgit v1.2.3