summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/cli/src/config/config.ts8
-rw-r--r--packages/cli/src/ui/App.tsx13
-rw-r--r--packages/cli/src/ui/components/Footer.tsx11
-rw-r--r--packages/cli/src/ui/hooks/useGeminiStream.ts7
-rw-r--r--packages/server/src/config/config.ts16
5 files changed, 45 insertions, 10 deletions
diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts
index 48cc96a0..6d8c10f6 100644
--- a/packages/cli/src/config/config.ts
+++ b/packages/cli/src/config/config.ts
@@ -20,6 +20,7 @@ const DEFAULT_GEMINI_MODEL = 'gemini-2.5-flash-preview-04-17';
interface CliArgs {
target_dir: string | undefined;
model: string | undefined;
+ debug_mode: boolean | undefined;
}
function parseArguments(): CliArgs {
@@ -36,6 +37,12 @@ function parseArguments(): CliArgs {
description: `The Gemini model to use. Defaults to ${DEFAULT_GEMINI_MODEL}.`,
default: DEFAULT_GEMINI_MODEL,
})
+ .option('debug_mode', {
+ alias: 'z',
+ type: 'boolean',
+ description: 'Whether to run in debug mode. Defaults to false.',
+ default: false,
+ })
.help()
.alias('h', 'help')
.strict().argv;
@@ -64,6 +71,7 @@ export function loadCliConfig(): Config {
process.env.GEMINI_API_KEY,
argv.model || DEFAULT_GEMINI_MODEL,
argv.target_dir || process.cwd(),
+ argv.debug_mode || false,
);
}
diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx
index 14b76c8f..cfbc024e 100644
--- a/packages/cli/src/ui/App.tsx
+++ b/packages/cli/src/ui/App.tsx
@@ -31,11 +31,8 @@ interface AppProps {
export const App = ({ config }: AppProps) => {
const [history, setHistory] = useState<HistoryItem[]>([]);
const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
- const { streamingState, submitQuery, initError } = useGeminiStream(
- setHistory,
- config.getApiKey(),
- config.getModel(),
- );
+ const { streamingState, submitQuery, initError, debugMessage } =
+ useGeminiStream(setHistory, config.getApiKey(), config.getModel());
const { elapsedTime, currentLoadingPhrase } =
useLoadingIndicator(streamingState);
@@ -147,7 +144,11 @@ export const App = ({ config }: AppProps) => {
</>
)}
- <Footer queryLength={query.length} />
+ <Footer
+ queryLength={query.length}
+ debugMode={config.getDebugMode()}
+ debugMessage={debugMessage}
+ />
<ITermDetectionWarning />
</Box>
);
diff --git a/packages/cli/src/ui/components/Footer.tsx b/packages/cli/src/ui/components/Footer.tsx
index 3b4e197b..35ed6910 100644
--- a/packages/cli/src/ui/components/Footer.tsx
+++ b/packages/cli/src/ui/components/Footer.tsx
@@ -10,13 +10,22 @@ import { Colors } from '../colors.js';
interface FooterProps {
queryLength: number;
+ debugMode: boolean;
+ debugMessage: string;
}
-export const Footer: React.FC<FooterProps> = ({ queryLength }) => (
+export const Footer: React.FC<FooterProps> = ({
+ queryLength,
+ debugMode,
+ debugMessage,
+}) => (
<Box marginTop={1} justifyContent="space-between">
<Box minWidth={15}>
<Text color={Colors.SubtleComment}>
{queryLength === 0 ? '? for shortcuts' : ''}
+ {debugMode && (
+ <Text color="red"> {debugMessage || 'Running in debug mode.'}</Text>
+ )}
</Text>
</Box>
<Text color={Colors.AccentBlue}>Gemini</Text>
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts
index 56203179..1d839998 100644
--- a/packages/cli/src/ui/hooks/useGeminiStream.ts
+++ b/packages/cli/src/ui/hooks/useGeminiStream.ts
@@ -49,6 +49,7 @@ export const useGeminiStream = (
const [streamingState, setStreamingState] = useState<StreamingState>(
StreamingState.Idle,
);
+ const [debugMessage, setDebugMessage] = useState<string>('');
const [initError, setInitError] = useState<string | null>(null);
const abortControllerRef = useRef<AbortController | null>(null);
const chatSessionRef = useRef<Chat | null>(null);
@@ -104,6 +105,10 @@ export const useGeminiStream = (
if (streamingState === StreamingState.Responding) return;
if (typeof query === 'string' && query.trim().length === 0) return;
+ if (typeof query === 'string') {
+ setDebugMessage(`User query: ${query}`);
+ }
+
const userMessageTimestamp = Date.now();
const client = geminiClientRef.current;
if (!client) {
@@ -403,7 +408,7 @@ export const useGeminiStream = (
],
);
- return { streamingState, submitQuery, initError };
+ return { streamingState, submitQuery, initError, debugMessage };
};
// Define ServerTool interface here if not importing from server (circular dep issue?)
diff --git a/packages/server/src/config/config.ts b/packages/server/src/config/config.ts
index 86cd7a6c..bd698cf6 100644
--- a/packages/server/src/config/config.ts
+++ b/packages/server/src/config/config.ts
@@ -13,11 +13,18 @@ export class Config {
private apiKey: string;
private model: string;
private targetDir: string;
+ private debugMode: boolean;
- constructor(apiKey: string, model: string, targetDir: string) {
+ constructor(
+ apiKey: string,
+ model: string,
+ targetDir: string,
+ debugMode: boolean,
+ ) {
this.apiKey = apiKey;
this.model = model;
this.targetDir = targetDir;
+ this.debugMode = debugMode;
}
getApiKey(): string {
@@ -31,6 +38,10 @@ export class Config {
getTargetDir(): string {
return this.targetDir;
}
+
+ getDebugMode(): boolean {
+ return this.debugMode;
+ }
}
function findEnvFile(startDir: string): string | null {
@@ -60,6 +71,7 @@ export function createServerConfig(
apiKey: string,
model: string,
targetDir: string,
+ debugMode: boolean,
): Config {
- return new Config(apiKey, model, path.resolve(targetDir));
+ return new Config(apiKey, model, path.resolve(targetDir), debugMode);
}