summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
authorSeth Troisi <[email protected]>2025-05-05 17:57:06 +0000
committerGitHub <[email protected]>2025-05-05 10:57:06 -0700
commit415b757d4a7e654ebf6eae50b67498d0ae49f7f2 (patch)
treeef97e881bbb57547447cffe314cf296a4355d8b2 /packages/cli/src
parenta0bed3e7169eb6ce89b283b4c1dc0107e3851572 (diff)
Remove passthroughCommands (#252)
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/config/config.ts1
-rw-r--r--packages/cli/src/ui/hooks/passthroughCommandProcessor.ts108
-rw-r--r--packages/cli/src/ui/hooks/useGeminiStream.ts15
3 files changed, 0 insertions, 124 deletions
diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts
index 94390ec1..20ca7806 100644
--- a/packages/cli/src/config/config.ts
+++ b/packages/cli/src/config/config.ts
@@ -88,7 +88,6 @@ export async function loadCliConfig(settings: Settings): Promise<Config> {
process.cwd(),
argv.debug_mode || false,
argv.question || '',
- undefined, // TODO: load passthroughCommands from .env file
argv.full_context || false,
);
}
diff --git a/packages/cli/src/ui/hooks/passthroughCommandProcessor.ts b/packages/cli/src/ui/hooks/passthroughCommandProcessor.ts
deleted file mode 100644
index 97244e8c..00000000
--- a/packages/cli/src/ui/hooks/passthroughCommandProcessor.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * @license
- * Copyright 2025 Google LLC
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import { exec as _exec } from 'child_process';
-import { useCallback } from 'react';
-import { Config } from '@gemini-code/server';
-import { type PartListUnion } from '@google/genai';
-import { HistoryItem, StreamingState } from '../types.js';
-import { getCommandFromQuery } from '../utils/commandUtils.js';
-
-// Helper function (consider moving to a shared util if used elsewhere)
-const addHistoryItem = (
- setHistory: React.Dispatch<React.SetStateAction<HistoryItem[]>>,
- itemData: Omit<HistoryItem, 'id'>,
- id: number,
-) => {
- setHistory((prevHistory) => [
- ...prevHistory,
- { ...itemData, id } as HistoryItem,
- ]);
-};
-
-export const usePassthroughProcessor = (
- setHistory: React.Dispatch<React.SetStateAction<HistoryItem[]>>,
- setStreamingState: React.Dispatch<React.SetStateAction<StreamingState>>,
- setDebugMessage: React.Dispatch<React.SetStateAction<string>>,
- getNextMessageId: (baseTimestamp: number) => number,
- config: Config,
-) => {
- const handlePassthroughCommand = useCallback(
- (rawQuery: PartListUnion): boolean => {
- if (typeof rawQuery !== 'string') {
- return false; // Passthrough only works with string commands
- }
-
- const trimmedQuery = rawQuery.trim();
- if (!trimmedQuery) {
- return false;
- }
-
- const [symbol, command] = getCommandFromQuery(trimmedQuery);
-
- // Passthrough commands don't start with symbol
- if (symbol !== undefined) {
- return false;
- }
-
- if (config.getPassthroughCommands().includes(command)) {
- // Add user message *before* execution starts
- const userMessageTimestamp = Date.now();
- addHistoryItem(
- setHistory,
- { type: 'user', text: trimmedQuery },
- userMessageTimestamp,
- );
-
- // Execute and capture output
- const targetDir = config.getTargetDir();
- setDebugMessage(
- `Executing pass through command in ${targetDir}: ${trimmedQuery}`,
- );
- const execOptions = {
- cwd: targetDir,
- };
-
- // Set state to Responding while the command runs
- setStreamingState(StreamingState.Responding);
-
- _exec(trimmedQuery, execOptions, (error, stdout, stderr) => {
- const timestamp = getNextMessageId(userMessageTimestamp); // Use user message time as base
- if (error) {
- addHistoryItem(
- setHistory,
- { type: 'error', text: error.message },
- timestamp,
- );
- } else if (stderr) {
- // Treat stderr as info for passthrough, as some tools use it for non-error output
- addHistoryItem(
- setHistory,
- { type: 'info', text: stderr },
- timestamp,
- );
- } else {
- // Add stdout as an info message
- addHistoryItem(
- setHistory,
- { type: 'info', text: stdout || '(Command produced no output)' },
- timestamp,
- );
- }
- // Set state back to Idle *after* command finishes and output is added
- setStreamingState(StreamingState.Idle);
- });
-
- return true; // Command was handled
- }
-
- return false; // Not a passthrough command
- },
- [config, setDebugMessage, setHistory, setStreamingState, getNextMessageId],
- );
-
- return { handlePassthroughCommand };
-};
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts
index 52675145..2931bbc3 100644
--- a/packages/cli/src/ui/hooks/useGeminiStream.ts
+++ b/packages/cli/src/ui/hooks/useGeminiStream.ts
@@ -30,7 +30,6 @@ import {
import { isAtCommand } from '../utils/commandUtils.js';
import { useSlashCommandProcessor } from './slashCommandProcessor.js';
import { useShellCommandProcessor } from './shellCommandProcessor.js';
-import { usePassthroughProcessor } from './passthroughCommandProcessor.js';
import { handleAtCommand } from './atCommandProcessor.js';
import { findSafeSplitPoint } from '../utils/markdownUtilities.js';
@@ -88,14 +87,6 @@ export const useGeminiStream = (
config,
);
- const { handlePassthroughCommand } = usePassthroughProcessor(
- setHistory,
- setStreamingState,
- setDebugMessage,
- getNextMessageId,
- config,
- );
-
// Initialize Client Effect - uses props now
useEffect(() => {
setInitError(null);
@@ -177,11 +168,6 @@ export const useGeminiStream = (
return;
}
- // 3. Check for Passthrough Commands
- if (handlePassthroughCommand(trimmedQuery)) {
- return;
- }
-
// 3. Check for @ Commands using the utility function
if (isAtCommand(trimmedQuery)) {
const atCommandResult = await handleAtCommand({
@@ -542,7 +528,6 @@ export const useGeminiStream = (
getNextMessageId,
updateGeminiMessage,
handleSlashCommand,
- handlePassthroughCommand,
// handleAtCommand is implicitly included via its direct call
setDebugMessage, // Added dependency for handleAtCommand & passthrough
setStreamingState, // Added dependency for handlePassthroughCommand