merge duplicate imports packages/cli/src subtask3 (#22056)

This commit is contained in:
nityam
2026-03-12 02:51:40 +05:30
committed by GitHub
parent 3bf4f885d8
commit 352bbc36c0
46 changed files with 192 additions and 127 deletions
@@ -9,14 +9,13 @@ import type React from 'react';
import { act } from 'react'; import { act } from 'react';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
import type { Mock } from 'vitest'; import { vi, afterAll, beforeAll, type Mock } from 'vitest';
import { vi, afterAll, beforeAll } from 'vitest';
import type { Key } from './KeypressContext.js';
import { import {
KeypressProvider, KeypressProvider,
useKeypressContext, useKeypressContext,
ESC_TIMEOUT, ESC_TIMEOUT,
FAST_RETURN_TIMEOUT, FAST_RETURN_TIMEOUT,
type Key,
} from './KeypressContext.js'; } from './KeypressContext.js';
import { terminalCapabilityManager } from '../utils/terminalCapabilityManager.js'; import { terminalCapabilityManager } from '../utils/terminalCapabilityManager.js';
import { useStdin } from 'ink'; import { useStdin } from 'ink';
@@ -5,10 +5,10 @@
*/ */
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import type React from 'react';
import { act } from 'react'; import { act } from 'react';
import { MouseProvider, useMouseContext, useMouse } from './MouseContext.js'; import { MouseProvider, useMouseContext, useMouse } from './MouseContext.js';
import { vi, type Mock } from 'vitest'; import { vi, type Mock } from 'vitest';
import type React from 'react';
import { useStdin } from 'ink'; import { useStdin } from 'ink';
import { EventEmitter } from 'node:events'; import { EventEmitter } from 'node:events';
import { appEvents, AppEvent } from '../../utils/events.js'; import { appEvents, AppEvent } from '../../utils/events.js';
@@ -4,12 +4,13 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import { type MutableRefObject, Component, type ReactNode } from 'react'; import { type MutableRefObject, Component, type ReactNode, act } from 'react';
import { render } from '../../test-utils/render.js'; import { render } from '../../test-utils/render.js';
import {
import { act } from 'react'; SessionStatsProvider,
import type { SessionMetrics } from './SessionContext.js'; useSessionStats,
import { SessionStatsProvider, useSessionStats } from './SessionContext.js'; type SessionMetrics,
} from './SessionContext.js';
import { describe, it, expect, vi } from 'vitest'; import { describe, it, expect, vi } from 'vitest';
import { uiTelemetryService } from '@google/gemini-cli-core'; import { uiTelemetryService } from '@google/gemini-cli-core';
@@ -5,17 +5,16 @@
*/ */
import type React from 'react'; import type React from 'react';
import { Component, type ReactNode } from 'react'; import { Component, type ReactNode, act } from 'react';
import { renderHook, render } from '../../test-utils/render.js'; import { renderHook, render } from '../../test-utils/render.js';
import { act } from 'react';
import { describe, it, expect, vi, beforeEach } from 'vitest'; import { describe, it, expect, vi, beforeEach } from 'vitest';
import { SettingsContext, useSettingsStore } from './SettingsContext.js'; import { SettingsContext, useSettingsStore } from './SettingsContext.js';
import { import {
type LoadedSettings,
SettingScope, SettingScope,
createTestMergedSettings,
type LoadedSettings,
type LoadedSettingsSnapshot, type LoadedSettingsSnapshot,
type SettingsFile, type SettingsFile,
createTestMergedSettings,
} from '../../config/settings.js'; } from '../../config/settings.js';
const createMockSettingsFile = (path: string): SettingsFile => ({ const createMockSettingsFile = (path: string): SettingsFile => ({
@@ -4,10 +4,16 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import type { Mock } from 'vitest'; import {
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; describe,
it,
expect,
vi,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import { handleAtCommand } from './atCommandProcessor.js'; import { handleAtCommand } from './atCommandProcessor.js';
import type { Config, DiscoveredMCPResource } from '@google/gemini-cli-core';
import { import {
FileDiscoveryService, FileDiscoveryService,
GlobTool, GlobTool,
@@ -18,6 +24,8 @@ import {
GEMINI_IGNORE_FILE_NAME, GEMINI_IGNORE_FILE_NAME,
// DEFAULT_FILE_EXCLUDES, // DEFAULT_FILE_EXCLUDES,
CoreToolCallStatus, CoreToolCallStatus,
type Config,
type DiscoveredMCPResource,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core';
import * as core from '@google/gemini-cli-core'; import * as core from '@google/gemini-cli-core';
import * as os from 'node:os'; import * as os from 'node:os';
@@ -9,19 +9,18 @@ import { act } from 'react';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
import { useSlashCommandProcessor } from './slashCommandProcessor.js'; import { useSlashCommandProcessor } from './slashCommandProcessor.js';
import type { SlashCommand } from '../commands/types.js'; import { CommandKind, type SlashCommand } from '../commands/types.js';
import { CommandKind } from '../commands/types.js';
import type { LoadedSettings } from '../../config/settings.js'; import type { LoadedSettings } from '../../config/settings.js';
import { MessageType } from '../types.js'; import { MessageType } from '../types.js';
import { BuiltinCommandLoader } from '../../services/BuiltinCommandLoader.js'; import { BuiltinCommandLoader } from '../../services/BuiltinCommandLoader.js';
import { FileCommandLoader } from '../../services/FileCommandLoader.js'; import { FileCommandLoader } from '../../services/FileCommandLoader.js';
import { McpPromptLoader } from '../../services/McpPromptLoader.js'; import { McpPromptLoader } from '../../services/McpPromptLoader.js';
import { import {
type GeminiClient,
SlashCommandStatus, SlashCommandStatus,
MCPDiscoveryState, MCPDiscoveryState,
makeFakeConfig, makeFakeConfig,
coreEvents, coreEvents,
type GeminiClient,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core';
const { const {
@@ -17,10 +17,12 @@ import { act } from 'react';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { useApprovalModeIndicator } from './useApprovalModeIndicator.js'; import { useApprovalModeIndicator } from './useApprovalModeIndicator.js';
import { Config, ApprovalMode } from '@google/gemini-cli-core'; import {
import type { Config as ActualConfigType } from '@google/gemini-cli-core'; Config,
import type { Key } from './useKeypress.js'; ApprovalMode,
import { useKeypress } from './useKeypress.js'; type Config as ActualConfigType,
} from '@google/gemini-cli-core';
import { useKeypress, type Key } from './useKeypress.js';
import { MessageType } from '../types.js'; import { MessageType } from '../types.js';
vi.mock('./useKeypress.js'); vi.mock('./useKeypress.js');
@@ -13,8 +13,7 @@ import {
import { useKeypress } from './useKeypress.js'; import { useKeypress } from './useKeypress.js';
import { Command } from '../key/keyMatchers.js'; import { Command } from '../key/keyMatchers.js';
import { useKeyMatchers } from './useKeyMatchers.js'; import { useKeyMatchers } from './useKeyMatchers.js';
import type { HistoryItemWithoutId } from '../types.js'; import { MessageType, type HistoryItemWithoutId } from '../types.js';
import { MessageType } from '../types.js';
export interface UseApprovalModeIndicatorArgs { export interface UseApprovalModeIndicatorArgs {
config: Config; config: Config;
@@ -10,14 +10,18 @@ import * as path from 'node:path';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
import { useAtCompletion } from './useAtCompletion.js'; import { useAtCompletion } from './useAtCompletion.js';
import type { Config, FileSearch } from '@google/gemini-cli-core';
import { import {
FileSearchFactory, FileSearchFactory,
FileDiscoveryService, FileDiscoveryService,
escapePath, escapePath,
type Config,
type FileSearch,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core';
import type { FileSystemStructure } from '@google/gemini-cli-test-utils'; import {
import { createTmpDir, cleanupTmpDir } from '@google/gemini-cli-test-utils'; createTmpDir,
cleanupTmpDir,
type FileSystemStructure,
} from '@google/gemini-cli-test-utils';
import type { Suggestion } from '../components/SuggestionsDisplay.js'; import type { Suggestion } from '../components/SuggestionsDisplay.js';
// Test harness to capture the state from the hook's callbacks. // Test harness to capture the state from the hook's callbacks.
+6 -3
View File
@@ -7,14 +7,17 @@
import { useEffect, useReducer, useRef } from 'react'; import { useEffect, useReducer, useRef } from 'react';
import { setTimeout as setTimeoutPromise } from 'node:timers/promises'; import { setTimeout as setTimeoutPromise } from 'node:timers/promises';
import * as path from 'node:path'; import * as path from 'node:path';
import type { Config, FileSearch } from '@google/gemini-cli-core';
import { import {
FileSearchFactory, FileSearchFactory,
escapePath, escapePath,
FileDiscoveryService, FileDiscoveryService,
type Config,
type FileSearch,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core';
import type { Suggestion } from '../components/SuggestionsDisplay.js'; import {
import { MAX_SUGGESTIONS_TO_SHOW } from '../components/SuggestionsDisplay.js'; MAX_SUGGESTIONS_TO_SHOW,
type Suggestion,
} from '../components/SuggestionsDisplay.js';
import { CommandKind } from '../commands/types.js'; import { CommandKind } from '../commands/types.js';
import { AsyncFzf } from 'fzf'; import { AsyncFzf } from 'fzf';
@@ -24,10 +24,14 @@ import type { CommandContext } from '../commands/types.js';
import type { Config } from '@google/gemini-cli-core'; import type { Config } from '@google/gemini-cli-core';
import { useTextBuffer } from '../components/shared/text-buffer.js'; import { useTextBuffer } from '../components/shared/text-buffer.js';
import type { Suggestion } from '../components/SuggestionsDisplay.js'; import type { Suggestion } from '../components/SuggestionsDisplay.js';
import type { UseAtCompletionProps } from './useAtCompletion.js'; import {
import { useAtCompletion } from './useAtCompletion.js'; useAtCompletion,
import type { UseSlashCompletionProps } from './useSlashCompletion.js'; type UseAtCompletionProps,
import { useSlashCompletion } from './useSlashCompletion.js'; } from './useAtCompletion.js';
import {
useSlashCompletion,
type UseSlashCompletionProps,
} from './useSlashCompletion.js';
import { useShellCompletion } from './useShellCompletion.js'; import { useShellCompletion } from './useShellCompletion.js';
vi.mock('./useAtCompletion', () => ({ vi.mock('./useAtCompletion', () => ({
@@ -14,10 +14,10 @@ import { toCodePoints } from '../utils/textUtils.js';
import { useAtCompletion } from './useAtCompletion.js'; import { useAtCompletion } from './useAtCompletion.js';
import { useSlashCompletion } from './useSlashCompletion.js'; import { useSlashCompletion } from './useSlashCompletion.js';
import { useShellCompletion } from './useShellCompletion.js'; import { useShellCompletion } from './useShellCompletion.js';
import type { PromptCompletion } from './usePromptCompletion.js';
import { import {
usePromptCompletion, usePromptCompletion,
PROMPT_COMPLETION_MIN_LENGTH, PROMPT_COMPLETION_MIN_LENGTH,
type PromptCompletion,
} from './usePromptCompletion.js'; } from './usePromptCompletion.js';
import type { Config } from '@google/gemini-cli-core'; import type { Config } from '@google/gemini-cli-core';
import { useCompletion } from './useCompletion.js'; import { useCompletion } from './useCompletion.js';
+4 -2
View File
@@ -6,8 +6,10 @@
import { useState, useCallback } from 'react'; import { useState, useCallback } from 'react';
import type { Suggestion } from '../components/SuggestionsDisplay.js'; import {
import { MAX_SUGGESTIONS_TO_SHOW } from '../components/SuggestionsDisplay.js'; MAX_SUGGESTIONS_TO_SHOW,
type Suggestion,
} from '../components/SuggestionsDisplay.js';
export interface UseCompletionReturn { export interface UseCompletionReturn {
suggestions: Suggestion[]; suggestions: Suggestion[];
@@ -6,8 +6,10 @@
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useUIState } from '../contexts/UIStateContext.js'; import { useUIState } from '../contexts/UIStateContext.js';
import { getConfirmingToolState } from '../utils/confirmingTool.js'; import {
import type { ConfirmingToolState } from '../utils/confirmingTool.js'; getConfirmingToolState,
type ConfirmingToolState,
} from '../utils/confirmingTool.js';
export type { ConfirmingToolState } from '../utils/confirmingTool.js'; export type { ConfirmingToolState } from '../utils/confirmingTool.js';
@@ -4,7 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import { debugLogger, type GeminiCLIExtension } from '@google/gemini-cli-core'; import {
debugLogger,
checkExhaustive,
type GeminiCLIExtension,
} from '@google/gemini-cli-core';
import { getErrorMessage } from '../../utils/errors.js'; import { getErrorMessage } from '../../utils/errors.js';
import { import {
ExtensionUpdateState, ExtensionUpdateState,
@@ -19,7 +23,6 @@ import {
updateExtension, updateExtension,
} from '../../config/extensions/update.js'; } from '../../config/extensions/update.js';
import { type ExtensionUpdateInfo } from '../../config/extension.js'; import { type ExtensionUpdateInfo } from '../../config/extension.js';
import { checkExhaustive } from '@google/gemini-cli-core';
import type { ExtensionManager } from '../../config/extension-manager.js'; import type { ExtensionManager } from '../../config/extension-manager.js';
type ConfirmationRequestWrapper = { type ConfirmationRequestWrapper = {
@@ -8,8 +8,7 @@ import { renderHook } from '../../test-utils/render.js';
import { vi, type Mock } from 'vitest'; import { vi, type Mock } from 'vitest';
import { useFlickerDetector } from './useFlickerDetector.js'; import { useFlickerDetector } from './useFlickerDetector.js';
import { useConfig } from '../contexts/ConfigContext.js'; import { useConfig } from '../contexts/ConfigContext.js';
import { recordFlickerFrame } from '@google/gemini-cli-core'; import { recordFlickerFrame, type Config } from '@google/gemini-cli-core';
import { type Config } from '@google/gemini-cli-core';
import { type DOMElement, measureElement } from 'ink'; import { type DOMElement, measureElement } from 'ink';
import { useUIState } from '../contexts/UIStateContext.js'; import { useUIState } from '../contexts/UIStateContext.js';
import { appEvents, AppEvent } from '../../utils/events.js'; import { appEvents, AppEvent } from '../../utils/events.js';
@@ -20,8 +20,10 @@ import { waitFor } from '../../test-utils/async.js';
import { useFolderTrust } from './useFolderTrust.js'; import { useFolderTrust } from './useFolderTrust.js';
import type { LoadedSettings } from '../../config/settings.js'; import type { LoadedSettings } from '../../config/settings.js';
import { FolderTrustChoice } from '../components/FolderTrustDialog.js'; import { FolderTrustChoice } from '../components/FolderTrustDialog.js';
import type { LoadedTrustedFolders } from '../../config/trustedFolders.js'; import {
import { TrustLevel } from '../../config/trustedFolders.js'; TrustLevel,
type LoadedTrustedFolders,
} from '../../config/trustedFolders.js';
import * as trustedFolders from '../../config/trustedFolders.js'; import * as trustedFolders from '../../config/trustedFolders.js';
import { coreEvents, ExitCodes, isHeadlessMode } from '@google/gemini-cli-core'; import { coreEvents, ExitCodes, isHeadlessMode } from '@google/gemini-cli-core';
import { MessageType } from '../types.js'; import { MessageType } from '../types.js';
@@ -5,22 +5,29 @@
*/ */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import type { Mock, MockInstance } from 'vitest'; import {
import { describe, it, expect, vi, beforeEach } from 'vitest'; describe,
it,
expect,
vi,
beforeEach,
type Mock,
type MockInstance,
} from 'vitest';
import { act } from 'react'; import { act } from 'react';
import { renderHookWithProviders } from '../../test-utils/render.js'; import { renderHookWithProviders } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
import { useGeminiStream } from './useGeminiStream.js'; import { useGeminiStream } from './useGeminiStream.js';
import { useKeypress } from './useKeypress.js'; import { useKeypress } from './useKeypress.js';
import * as atCommandProcessor from './atCommandProcessor.js'; import * as atCommandProcessor from './atCommandProcessor.js';
import type { import {
TrackedToolCall, useToolScheduler,
TrackedCompletedToolCall, type TrackedToolCall,
TrackedExecutingToolCall, type TrackedCompletedToolCall,
TrackedCancelledToolCall, type TrackedExecutingToolCall,
TrackedWaitingToolCall, type TrackedCancelledToolCall,
type TrackedWaitingToolCall,
} from './useToolScheduler.js'; } from './useToolScheduler.js';
import { useToolScheduler } from './useToolScheduler.js';
import type { import type {
Config, Config,
EditorType, EditorType,
@@ -4,8 +4,15 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import type { MockedFunction } from 'vitest'; import {
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; afterEach,
beforeEach,
describe,
expect,
it,
vi,
type MockedFunction,
} from 'vitest';
import { act } from 'react'; import { act } from 'react';
import { render } from '../../test-utils/render.js'; import { render } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
@@ -4,8 +4,15 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest'; import {
import type { Mock } from 'vitest'; vi,
describe,
it,
expect,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
import { useIncludeDirsTrust } from './useIncludeDirsTrust.js'; import { useIncludeDirsTrust } from './useIncludeDirsTrust.js';
+1 -2
View File
@@ -6,8 +6,7 @@
import type React from 'react'; import type React from 'react';
import { createContext, useContext } from 'react'; import { createContext, useContext } from 'react';
import type { KeyMatchers } from '../key/keyMatchers.js'; import { defaultKeyMatchers, type KeyMatchers } from '../key/keyMatchers.js';
import { defaultKeyMatchers } from '../key/keyMatchers.js';
export const KeyMatchersContext = export const KeyMatchersContext =
createContext<KeyMatchers>(defaultKeyMatchers); createContext<KeyMatchers>(defaultKeyMatchers);
+1 -2
View File
@@ -5,8 +5,7 @@
*/ */
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import type { Storage } from '@google/gemini-cli-core'; import { sessionId, Logger, type Storage } from '@google/gemini-cli-core';
import { sessionId, Logger } from '@google/gemini-cli-core';
/** /**
* Hook to manage the logger instance. * Hook to manage the logger instance.
+5 -2
View File
@@ -5,8 +5,11 @@
*/ */
import { useEffect } from 'react'; import { useEffect } from 'react';
import type { MouseHandler, MouseEvent } from '../contexts/MouseContext.js'; import {
import { useMouseContext } from '../contexts/MouseContext.js'; useMouseContext,
type MouseHandler,
type MouseEvent,
} from '../contexts/MouseContext.js';
export type { MouseEvent }; export type { MouseEvent };
@@ -16,9 +16,11 @@ import {
import { act } from 'react'; import { act } from 'react';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { usePermissionsModifyTrust } from './usePermissionsModifyTrust.js'; import { usePermissionsModifyTrust } from './usePermissionsModifyTrust.js';
import { TrustLevel } from '../../config/trustedFolders.js'; import {
TrustLevel,
type LoadedTrustedFolders,
} from '../../config/trustedFolders.js';
import type { LoadedSettings } from '../../config/settings.js'; import type { LoadedSettings } from '../../config/settings.js';
import type { LoadedTrustedFolders } from '../../config/trustedFolders.js';
import { coreEvents } from '@google/gemini-cli-core'; import { coreEvents } from '@google/gemini-cli-core';
// Hoist mocks // Hoist mocks
@@ -7,8 +7,12 @@
import { describe, it, expect, beforeEach, vi } from 'vitest'; import { describe, it, expect, beforeEach, vi } from 'vitest';
import { act } from 'react'; import { act } from 'react';
import { render } from '../../test-utils/render.js'; import { render } from '../../test-utils/render.js';
import type { Config, CodeAssistServer } from '@google/gemini-cli-core'; import {
import { UserTierId, getCodeAssistServer } from '@google/gemini-cli-core'; UserTierId,
getCodeAssistServer,
type Config,
type CodeAssistServer,
} from '@google/gemini-cli-core';
import { usePrivacySettings } from './usePrivacySettings.js'; import { usePrivacySettings } from './usePrivacySettings.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
@@ -5,8 +5,12 @@
*/ */
import { useState, useCallback, useRef, useEffect, useMemo } from 'react'; import { useState, useCallback, useRef, useEffect, useMemo } from 'react';
import type { Config } from '@google/gemini-cli-core'; import {
import { debugLogger, getResponseText, LlmRole } from '@google/gemini-cli-core'; debugLogger,
getResponseText,
LlmRole,
type Config,
} from '@google/gemini-cli-core';
import type { Content } from '@google/genai'; import type { Content } from '@google/genai';
import type { TextBuffer } from '../components/shared/text-buffer.js'; import type { TextBuffer } from '../components/shared/text-buffer.js';
import { isSlashCommand } from '../utils/commandUtils.js'; import { isSlashCommand } from '../utils/commandUtils.js';
+2 -2
View File
@@ -8,12 +8,12 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { act } from 'react'; import { act } from 'react';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { useRewind } from './useRewind.js'; import { useRewind } from './useRewind.js';
import * as rewindFileOps from '../utils/rewindFileOps.js';
import type { FileChangeStats } from '../utils/rewindFileOps.js';
import type { import type {
ConversationRecord, ConversationRecord,
MessageRecord, MessageRecord,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core';
import type { FileChangeStats } from '../utils/rewindFileOps.js';
import * as rewindFileOps from '../utils/rewindFileOps.js';
// Mock the dependency // Mock the dependency
vi.mock('../utils/rewindFileOps.js', () => ({ vi.mock('../utils/rewindFileOps.js', () => ({
@@ -8,18 +8,18 @@ import { useState, useCallback } from 'react';
import type { HistoryItemWithoutId } from '../types.js'; import type { HistoryItemWithoutId } from '../types.js';
import * as fs from 'node:fs/promises'; import * as fs from 'node:fs/promises';
import path from 'node:path'; import path from 'node:path';
import type {
Config,
ConversationRecord,
ResumedSessionData,
} from '@google/gemini-cli-core';
import { import {
coreEvents, coreEvents,
convertSessionToClientHistory, convertSessionToClientHistory,
uiTelemetryService, uiTelemetryService,
type Config,
type ConversationRecord,
type ResumedSessionData,
} from '@google/gemini-cli-core'; } from '@google/gemini-cli-core';
import type { SessionInfo } from '../../utils/sessionUtils.js'; import {
import { convertSessionToHistoryFormats } from '../../utils/sessionUtils.js'; convertSessionToHistoryFormats,
type SessionInfo,
} from '../../utils/sessionUtils.js';
import type { Part } from '@google/genai'; import type { Part } from '@google/genai';
export { convertSessionToHistoryFormats }; export { convertSessionToHistoryFormats };
@@ -11,8 +11,11 @@ import {
resolvePathCompletions, resolvePathCompletions,
scanPathExecutables, scanPathExecutables,
} from './useShellCompletion.js'; } from './useShellCompletion.js';
import type { FileSystemStructure } from '@google/gemini-cli-test-utils'; import {
import { createTmpDir, cleanupTmpDir } from '@google/gemini-cli-test-utils'; createTmpDir,
cleanupTmpDir,
type FileSystemStructure,
} from '@google/gemini-cli-test-utils';
describe('useShellCompletion utilities', () => { describe('useShellCompletion utilities', () => {
describe('getTokenAtCursor', () => { describe('getTokenAtCursor', () => {
@@ -9,8 +9,11 @@ import { act, useState } from 'react';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
import { useSlashCompletion } from './useSlashCompletion.js'; import { useSlashCompletion } from './useSlashCompletion.js';
import type { CommandContext, SlashCommand } from '../commands/types.js'; import {
import { CommandKind } from '../commands/types.js'; CommandKind,
type CommandContext,
type SlashCommand,
} from '../commands/types.js';
import type { Suggestion } from '../components/SuggestionsDisplay.js'; import type { Suggestion } from '../components/SuggestionsDisplay.js';
// Test utility type and helper function for creating test SlashCommands // Test utility type and helper function for creating test SlashCommands
@@ -7,8 +7,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'; import { describe, it, expect, vi, beforeEach } from 'vitest';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { act } from 'react'; import { act } from 'react';
import { useVim } from './vim.js'; import { useVim, type VimMode } from './vim.js';
import type { VimMode } from './vim.js';
import type { TextBuffer } from '../components/shared/text-buffer.js'; import type { TextBuffer } from '../components/shared/text-buffer.js';
import type { Key } from './useKeypress.js'; import type { Key } from './useKeypress.js';
+6 -7
View File
@@ -17,15 +17,14 @@ import type React from 'react';
import { act } from 'react'; import { act } from 'react';
import { renderHook } from '../../test-utils/render.js'; import { renderHook } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js'; import { waitFor } from '../../test-utils/async.js';
import { useVim } from './vim.js'; import { useVim, type VimMode } from './vim.js';
import type { VimMode } from './vim.js';
import type { Key } from './useKeypress.js'; import type { Key } from './useKeypress.js';
import type { import {
TextBuffer, textBufferReducer,
TextBufferState, type TextBuffer,
TextBufferAction, type TextBufferState,
type TextBufferAction,
} from '../components/shared/text-buffer.js'; } from '../components/shared/text-buffer.js';
import { textBufferReducer } from '../components/shared/text-buffer.js';
// Mock the VimModeContext // Mock the VimModeContext
const mockVimContext = { const mockVimContext = {
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import type { ColorsTheme } from '../theme.js'; import { Theme, type ColorsTheme } from '../theme.js';
import { Theme } from '../theme.js';
import type { SemanticColors } from '../semantic-tokens.js'; import type { SemanticColors } from '../semantic-tokens.js';
const noColorColorsTheme: ColorsTheme = { const noColorColorsTheme: ColorsTheme = {
@@ -11,11 +11,10 @@ if (process.env['NO_COLOR'] !== undefined) {
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { themeManager, DEFAULT_THEME } from './theme-manager.js'; import { themeManager, DEFAULT_THEME } from './theme-manager.js';
import type { CustomTheme } from '@google/gemini-cli-core'; import { debugLogger, type CustomTheme } from '@google/gemini-cli-core';
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import * as os from 'node:os'; import * as os from 'node:os';
import type * as osActual from 'node:os'; import type * as osActual from 'node:os';
import { debugLogger } from '@google/gemini-cli-core';
vi.mock('node:fs'); vi.mock('node:fs');
vi.mock('node:os', async (importOriginal) => { vi.mock('node:os', async (importOriginal) => {
+1 -2
View File
@@ -20,8 +20,7 @@ import { SolarizedLight } from './builtin/light/solarized-light.js';
import { XCode } from './builtin/light/xcode-light.js'; import { XCode } from './builtin/light/xcode-light.js';
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import * as path from 'node:path'; import * as path from 'node:path';
import type { Theme, ThemeType, ColorsTheme } from './theme.js'; import type { Theme, ThemeType, ColorsTheme, CustomTheme } from './theme.js';
import type { CustomTheme } from '@google/gemini-cli-core';
import { import {
createCustomTheme, createCustomTheme,
validateCustomTheme, validateCustomTheme,
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import type { Mock } from 'vitest'; import { vi, describe, it, expect, beforeEach, type Mock } from 'vitest';
import { vi, describe, it, expect, beforeEach } from 'vitest';
import { EventEmitter } from 'node:events'; import { EventEmitter } from 'node:events';
import clipboardy from 'clipboardy'; import clipboardy from 'clipboardy';
import { import {
+1 -2
View File
@@ -6,8 +6,7 @@
/// <reference types="vitest/globals" /> /// <reference types="vitest/globals" />
import type { MockInstance } from 'vitest'; import { vi, type MockInstance } from 'vitest';
import { vi } from 'vitest';
import { TextOutput } from './textOutput.js'; import { TextOutput } from './textOutput.js';
describe('TextOutput', () => { describe('TextOutput', () => {
+1 -2
View File
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import { debugLogger } from '@google/gemini-cli-core'; import { debugLogger, type Config } from '@google/gemini-cli-core';
import type { Config } from '@google/gemini-cli-core';
import WebSocket from 'ws'; import WebSocket from 'ws';
import { import {
initActivityLogger, initActivityLogger,
@@ -5,8 +5,7 @@
*/ */
import { describe, it, expect, vi, beforeEach } from 'vitest'; import { describe, it, expect, vi, beforeEach } from 'vitest';
import { SettingScope } from '../config/settings.js'; import { SettingScope, type LoadedSettings } from '../config/settings.js';
import type { LoadedSettings } from '../config/settings.js';
import { import {
getScopeItems, getScopeItems,
getScopeMessageForSetting, getScopeMessageForSetting,
+6 -2
View File
@@ -4,8 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import type { LoadableSettingScope, Settings } from '../config/settings.js'; import {
import { isLoadableSettingScope, SettingScope } from '../config/settings.js'; isLoadableSettingScope,
SettingScope,
type LoadableSettingScope,
type Settings,
} from '../config/settings.js';
import { isInSettingsScope } from './settingsUtils.js'; import { isInSettingsScope } from './settingsUtils.js';
/** /**
@@ -4,8 +4,15 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import type { Mock } from 'vitest'; import {
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; describe,
it,
expect,
vi,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import { getInstallationInfo, PackageManager } from './installationInfo.js'; import { getInstallationInfo, PackageManager } from './installationInfo.js';
import { updateEventEmitter } from './updateEventEmitter.js'; import { updateEventEmitter } from './updateEventEmitter.js';
import type { UpdateObject } from '../ui/utils/updateCheck.js'; import type { UpdateObject } from '../ui/utils/updateCheck.js';
+1 -2
View File
@@ -8,8 +8,7 @@ import type { UpdateObject } from '../ui/utils/updateCheck.js';
import type { LoadedSettings } from '../config/settings.js'; import type { LoadedSettings } from '../config/settings.js';
import { getInstallationInfo, PackageManager } from './installationInfo.js'; import { getInstallationInfo, PackageManager } from './installationInfo.js';
import { updateEventEmitter } from './updateEventEmitter.js'; import { updateEventEmitter } from './updateEventEmitter.js';
import type { HistoryItem } from '../ui/types.js'; import { MessageType, type HistoryItem } from '../ui/types.js';
import { MessageType } from '../ui/types.js';
import { spawnWrapper } from './spawnWrapper.js'; import { spawnWrapper } from './spawnWrapper.js';
import type { spawn } from 'node:child_process'; import type { spawn } from 'node:child_process';
import { debugLogger } from '@google/gemini-cli-core'; import { debugLogger } from '@google/gemini-cli-core';
+1 -2
View File
@@ -15,8 +15,7 @@ import {
} from 'vitest'; } from 'vitest';
import { EventEmitter } from 'node:events'; import { EventEmitter } from 'node:events';
import { RELAUNCH_EXIT_CODE } from './processUtils.js'; import { RELAUNCH_EXIT_CODE } from './processUtils.js';
import type { ChildProcess } from 'node:child_process'; import { spawn, type ChildProcess } from 'node:child_process';
import { spawn } from 'node:child_process';
const mocks = vi.hoisted(() => ({ const mocks = vi.hoisted(() => ({
writeToStderr: vi.fn(), writeToStderr: vi.fn(),
+5 -2
View File
@@ -12,8 +12,11 @@ import {
hasUserOrAssistantMessage, hasUserOrAssistantMessage,
SessionError, SessionError,
} from './sessionUtils.js'; } from './sessionUtils.js';
import type { Config, MessageRecord } from '@google/gemini-cli-core'; import {
import { SESSION_FILE_PREFIX } from '@google/gemini-cli-core'; SESSION_FILE_PREFIX,
type Config,
type MessageRecord,
} from '@google/gemini-cli-core';
import * as fs from 'node:fs/promises'; import * as fs from 'node:fs/promises';
import path from 'node:path'; import path from 'node:path';
import { randomUUID } from 'node:crypto'; import { randomUUID } from 'node:crypto';
+1 -2
View File
@@ -5,8 +5,7 @@
*/ */
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import type { Config } from '@google/gemini-cli-core'; import { ChatRecordingService, type Config } from '@google/gemini-cli-core';
import { ChatRecordingService } from '@google/gemini-cli-core';
import { listSessions, deleteSession } from './sessions.js'; import { listSessions, deleteSession } from './sessions.js';
import { SessionSelector, type SessionInfo } from './sessionUtils.js'; import { SessionSelector, type SessionInfo } from './sessionUtils.js';
+7 -8
View File
@@ -5,15 +5,14 @@
*/ */
import type { Settings } from '../config/settings.js'; import type { Settings } from '../config/settings.js';
import type { import {
SettingDefinition, getSettingsSchema,
SettingsSchema, type SettingDefinition,
SettingsType, type SettingsSchema,
SettingsValue, type SettingsType,
type SettingsValue,
} from '../config/settingsSchema.js'; } from '../config/settingsSchema.js';
import { getSettingsSchema } from '../config/settingsSchema.js'; import { ExperimentFlags, type Config } from '@google/gemini-cli-core';
import type { Config } from '@google/gemini-cli-core';
import { ExperimentFlags } from '@google/gemini-cli-core';
// The schema is now nested, but many parts of the UI and logic work better // The schema is now nested, but many parts of the UI and logic work better
// with a flattened structure and dot-notation keys. This section flattens the // with a flattened structure and dot-notation keys. This section flattens the