merge duplicate imports packages/cli/src subtask1 (#22040)

This commit is contained in:
nityam
2026-03-11 23:20:42 +05:30
committed by GitHub
parent 6900fe5527
commit 016d5d8eb6
45 changed files with 144 additions and 104 deletions
+6 -4
View File
@@ -57,15 +57,17 @@ function hasMeta(obj: unknown): obj is { _meta?: Record<string, unknown> } {
return typeof obj === 'object' && obj !== null && '_meta' in obj;
}
import type { Content, Part, FunctionCall } from '@google/genai';
import type { LoadedSettings } from '../config/settings.js';
import { SettingScope, loadSettings } from '../config/settings.js';
import {
SettingScope,
loadSettings,
type LoadedSettings,
} from '../config/settings.js';
import * as fs from 'node:fs/promises';
import * as path from 'node:path';
import { z } from 'zod';
import { randomUUID } from 'node:crypto';
import type { CliArgs } from '../config/config.js';
import { loadCliConfig } from '../config/config.js';
import { loadCliConfig, type CliArgs } from '../config/config.js';
import { runExitCleanup } from '../utils/cleanup.js';
import { SessionSelector } from '../utils/sessionUtils.js';
+1 -2
View File
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { listExtensions } from '@google/gemini-cli-core';
import { listExtensions, type Config } from '@google/gemini-cli-core';
import { SettingScope } from '../../config/settings.js';
import {
ExtensionManager,
@@ -18,7 +18,6 @@ import type {
CommandContext,
CommandExecutionResponse,
} from './types.js';
import type { Config } from '@google/gemini-cli-core';
export class ExtensionsCommand implements Command {
readonly name = 'extensions';
@@ -17,8 +17,10 @@ import {
import { handleInstall, installCommand } from './install.js';
import yargs from 'yargs';
import * as core from '@google/gemini-cli-core';
import type { inferInstallMetadata } from '../../config/extension-manager.js';
import { ExtensionManager } from '../../config/extension-manager.js';
import {
ExtensionManager,
type inferInstallMetadata,
} from '../../config/extension-manager.js';
import type {
promptForConsentNonInteractive,
requestConsentNonInteractive,
+1 -2
View File
@@ -6,8 +6,7 @@
import { describe, it, expect, vi } from 'vitest';
import { mcpCommand } from './mcp.js';
import { type Argv } from 'yargs';
import yargs from 'yargs';
import yargs, { type Argv } from 'yargs';
describe('mcp command', () => {
it('should have correct command definition', () => {
@@ -5,11 +5,10 @@
*/
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
import { coreEvents } from '@google/gemini-cli-core';
import { coreEvents, type Config } from '@google/gemini-cli-core';
import { handleList, listCommand } from './list.js';
import { loadSettings, type LoadedSettings } from '../../config/settings.js';
import { loadCliConfig } from '../../config/config.js';
import type { Config } from '@google/gemini-cli-core';
import chalk from 'chalk';
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
@@ -9,7 +9,7 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { ExtensionManager } from './extension-manager.js';
import { createTestMergedSettings } from './settings.js';
import { createTestMergedSettings, type MergedSettings } from './settings.js';
import { createExtension } from '../test-utils/createExtension.js';
import { EXTENSIONS_DIRECTORY_NAME } from './extensions/variables.js';
import {
@@ -18,7 +18,6 @@ import {
isWorkspaceTrusted,
} from './trustedFolders.js';
import { getRealPath } from '@google/gemini-cli-core';
import type { MergedSettings } from './settings.js';
const mockHomedir = vi.hoisted(() => vi.fn(() => '/tmp/mock-home'));
@@ -15,11 +15,10 @@ import {
type ExtensionUpdateStatus,
} from '../../ui/state/extensions.js';
import { ExtensionStorage } from './storage.js';
import { copyExtension } from '../extension-manager.js';
import { copyExtension, type ExtensionManager } from '../extension-manager.js';
import { checkForExtensionUpdate } from './github.js';
import { loadInstallMetadata } from '../extension.js';
import * as fs from 'node:fs';
import type { ExtensionManager } from '../extension-manager.js';
import type { GeminiCLIExtension } from '@google/gemini-cli-core';
// Mock dependencies
@@ -19,9 +19,8 @@ import {
isWorkspaceTrusted,
resetTrustedFoldersForTesting,
} from './trustedFolders.js';
import { loadEnvironment } from './settings.js';
import { loadEnvironment, type Settings } from './settings.js';
import { createMockSettings } from '../test-utils/settings.js';
import type { Settings } from './settings.js';
// We explicitly do NOT mock 'fs' or 'proper-lockfile' here to ensure
// we are testing the actual behavior on the real file system.
+8 -2
View File
@@ -4,7 +4,14 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect, vi, beforeEach } from 'vitest';
import {
describe,
it,
expect,
vi,
beforeEach,
type MockInstance,
} from 'vitest';
import {
runDeferredCommand,
defer,
@@ -14,7 +21,6 @@ import {
import { ExitCodes } from '@google/gemini-cli-core';
import type { ArgumentsCamelCase, CommandModule } from 'yargs';
import { createMockSettings } from './test-utils/settings.js';
import type { MockInstance } from 'vitest';
const { mockRunExitCleanup, mockCoreEvents } = vi.hoisted(() => ({
mockRunExitCleanup: vi.fn(),
+6 -3
View File
@@ -21,15 +21,18 @@ import {
startInteractiveUI,
getNodeMemoryArgs,
} from './gemini.js';
import { loadCliConfig, parseArguments } from './config/config.js';
import {
loadCliConfig,
parseArguments,
type CliArgs,
} from './config/config.js';
import { loadSandboxConfig } from './config/sandboxConfig.js';
import { terminalCapabilityManager } from './ui/utils/terminalCapabilityManager.js';
import { start_sandbox } from './utils/sandbox.js';
import { validateNonInteractiveAuth } from './validateNonInterActiveAuth.js';
import os from 'node:os';
import v8 from 'node:v8';
import { type CliArgs } from './config/config.js';
import { type LoadedSettings, loadSettings } from './config/settings.js';
import { loadSettings, type LoadedSettings } from './config/settings.js';
import {
createMockConfig,
createMockSettings,
+6 -2
View File
@@ -16,12 +16,16 @@ import v8 from 'node:v8';
import os from 'node:os';
import dns from 'node:dns';
import { start_sandbox } from './utils/sandbox.js';
import type { DnsResolutionOrder, LoadedSettings } from './config/settings.js';
import {
loadSettings,
SettingScope,
type DnsResolutionOrder,
type LoadedSettings,
} from './config/settings.js';
import {
loadTrustedFolders,
type TrustedFoldersError,
} from './config/trustedFolders.js';
import { loadSettings, SettingScope } from './config/settings.js';
import { getStartupWarnings } from './utils/startupWarnings.js';
import { getUserStartupWarnings } from './utils/userStartupWarnings.js';
import { ConsolePatcher } from './ui/utils/ConsolePatcher.js';
+1 -2
View File
@@ -6,8 +6,7 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { main } from './gemini.js';
import { debugLogger } from '@google/gemini-cli-core';
import { type Config } from '@google/gemini-cli-core';
import { debugLogger, type Config } from '@google/gemini-cli-core';
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
const actual =
@@ -52,8 +52,7 @@ vi.mock('../ui/commands/permissionsCommand.js', async () => {
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import { BuiltinCommandLoader } from './BuiltinCommandLoader.js';
import type { Config } from '@google/gemini-cli-core';
import { isNightly } from '@google/gemini-cli-core';
import { isNightly, type Config } from '@google/gemini-cli-core';
import { CommandKind } from '../ui/commands/types.js';
import { restoreCommand } from '../ui/commands/restoreCommand.js';
@@ -6,8 +6,7 @@
import * as glob from 'glob';
import * as path from 'node:path';
import type { Config } from '@google/gemini-cli-core';
import { GEMINI_DIR, Storage } from '@google/gemini-cli-core';
import { GEMINI_DIR, Storage, type Config } from '@google/gemini-cli-core';
import mock from 'mock-fs';
import { FileCommandLoader } from './FileCommandLoader.js';
import { assert, vi } from 'vitest';
@@ -9,8 +9,7 @@ import path from 'node:path';
import toml from '@iarna/toml';
import { glob } from 'glob';
import { z } from 'zod';
import type { Config } from '@google/gemini-cli-core';
import { Storage, coreEvents } from '@google/gemini-cli-core';
import { Storage, coreEvents, type Config } from '@google/gemini-cli-core';
import type { ICommandLoader } from './types.js';
import type {
CommandContext,
+10 -7
View File
@@ -4,14 +4,17 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Config } from '@google/gemini-cli-core';
import { getErrorMessage, getMCPServerPrompts } from '@google/gemini-cli-core';
import type {
CommandContext,
SlashCommand,
SlashCommandActionReturn,
import {
getErrorMessage,
getMCPServerPrompts,
type Config,
} from '@google/gemini-cli-core';
import {
CommandKind,
type CommandContext,
type SlashCommand,
type SlashCommandActionReturn,
} from '../ui/commands/types.js';
import { CommandKind } from '../ui/commands/types.js';
import type { ICommandLoader } from './types.js';
import type { PromptArgument } from '@modelcontextprotocol/sdk/types.js';
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { SlashCommand } from '../ui/commands/types.js';
import { CommandKind } from '../ui/commands/types.js';
import { CommandKind, type SlashCommand } from '../ui/commands/types.js';
import type { CommandConflict } from './types.js';
/**
@@ -6,8 +6,7 @@
import { vi } from 'vitest';
import type { CommandContext } from '../ui/commands/types.js';
import type { LoadedSettings } from '../config/settings.js';
import { mergeSettings } from '../config/settings.js';
import { mergeSettings, type LoadedSettings } from '../config/settings.js';
import type { GitService } from '@google/gemini-cli-core';
import type { SessionStatsState } from '../ui/contexts/SessionContext.js';
+5 -2
View File
@@ -6,8 +6,11 @@
import { vi } from 'vitest';
import type { Config } from '@google/gemini-cli-core';
import type { LoadedSettings, Settings } from '../config/settings.js';
import { createTestMergedSettings } from '../config/settings.js';
import {
createTestMergedSettings,
type LoadedSettings,
type Settings,
} from '../config/settings.js';
/**
* Creates a mocked Config object with default values and allows overrides.
+1 -1
View File
@@ -11,10 +11,10 @@ import {
} from 'ink';
import { EventEmitter } from 'node:events';
import { Box } from 'ink';
import type React from 'react';
import { Terminal } from '@xterm/headless';
import { vi } from 'vitest';
import stripAnsi from 'strip-ansi';
import type React from 'react';
import { act, useState } from 'react';
import os from 'node:os';
import path from 'node:path';
+5 -2
View File
@@ -4,8 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { CommandContext, SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import {
CommandKind,
type CommandContext,
type SlashCommand,
} from './types.js';
import process from 'node:process';
import { MessageType, type HistoryItemAbout } from '../types.js';
import {
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Mock } from 'vitest';
import { vi, describe, it, expect, beforeEach } from 'vitest';
import { vi, describe, it, expect, beforeEach, type Mock } from 'vitest';
import { clearCommand } from './clearCommand.js';
import { type CommandContext } from './types.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
@@ -22,8 +21,7 @@ vi.mock('@google/gemini-cli-core', async () => {
};
});
import type { GeminiClient } from '@google/gemini-cli-core';
import { uiTelemetryService } from '@google/gemini-cli-core';
import { uiTelemetryService, type GeminiClient } from '@google/gemini-cli-core';
describe('clearCommand', () => {
let mockContext: CommandContext;
+1 -2
View File
@@ -10,8 +10,7 @@ import {
SessionStartSource,
flushTelemetry,
} from '@google/gemini-cli-core';
import type { SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import { CommandKind, type SlashCommand } from './types.js';
import { MessageType } from '../types.js';
import { randomUUID } from 'node:crypto';
@@ -4,10 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { HistoryItemCompression } from '../types.js';
import { MessageType } from '../types.js';
import type { SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import { MessageType, type HistoryItemCompression } from '../types.js';
import { CommandKind, type SlashCommand } from './types.js';
export const compressCommand: SlashCommand = {
name: 'compress',
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Mock } from 'vitest';
import { vi, describe, it, expect, beforeEach } from 'vitest';
import { vi, describe, it, expect, beforeEach, type Mock } from 'vitest';
import { copyCommand } from './copyCommand.js';
import { type CommandContext } from './types.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
+5 -2
View File
@@ -6,8 +6,11 @@
import { debugLogger } from '@google/gemini-cli-core';
import { copyToClipboard } from '../utils/commandUtils.js';
import type { SlashCommand, SlashCommandActionReturn } from './types.js';
import { CommandKind } from './types.js';
import {
CommandKind,
type SlashCommand,
type SlashCommandActionReturn,
} from './types.js';
export const copyCommand: SlashCommand = {
name: 'copy',
@@ -4,8 +4,15 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
import type { Mock } from 'vitest';
import {
vi,
describe,
it,
expect,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import { directoryCommand } from './directoryCommand.js';
import {
expandHomeDir,
@@ -9,16 +9,21 @@ import {
loadTrustedFolders,
} from '../../config/trustedFolders.js';
import { MultiFolderTrustDialog } from '../components/MultiFolderTrustDialog.js';
import type { SlashCommand, CommandContext } from './types.js';
import { CommandKind } from './types.js';
import {
CommandKind,
type SlashCommand,
type CommandContext,
} from './types.js';
import { MessageType, type HistoryItem } from '../types.js';
import { refreshServerHierarchicalMemory } from '@google/gemini-cli-core';
import {
refreshServerHierarchicalMemory,
type Config,
} from '@google/gemini-cli-core';
import {
expandHomeDir,
getDirectorySuggestions,
batchAddDirectories,
} from '../utils/directoryUtils.js';
import type { Config } from '@google/gemini-cli-core';
import * as path from 'node:path';
import * as fs from 'node:fs';
@@ -6,10 +6,9 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { helpCommand } from './helpCommand.js';
import { type CommandContext } from './types.js';
import { CommandKind, type CommandContext } from './types.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
import { MessageType } from '../types.js';
import { CommandKind } from './types.js';
describe('helpCommand', () => {
let mockContext: CommandContext;
+1 -2
View File
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import { CommandKind, type SlashCommand } from './types.js';
import { MessageType, type HistoryItemHelp } from '../types.js';
export const helpCommand: SlashCommand = {
@@ -7,8 +7,12 @@
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
import { hooksCommand } from './hooksCommand.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
import type { HookRegistryEntry } from '@google/gemini-cli-core';
import { HookType, HookEventName, ConfigSource } from '@google/gemini-cli-core';
import {
HookType,
HookEventName,
ConfigSource,
type HookRegistryEntry,
} from '@google/gemini-cli-core';
import type { CommandContext } from './types.js';
import { SettingScope } from '../../config/settings.js';
@@ -4,8 +4,15 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { MockInstance } from 'vitest';
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
import {
vi,
describe,
it,
expect,
beforeEach,
afterEach,
type MockInstance,
} from 'vitest';
import { ideCommand } from './ideCommand.js';
import { type CommandContext } from './types.js';
import { IDE_DEFINITIONS } from '@google/gemini-cli-core';
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Mock } from 'vitest';
import { vi, describe, it, expect, beforeEach } from 'vitest';
import { vi, describe, it, expect, beforeEach, type Mock } from 'vitest';
import { memoryCommand } from './memoryCommand.js';
import type { SlashCommand, CommandContext } from './types.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
@@ -11,8 +11,11 @@ import {
showMemory,
} from '@google/gemini-cli-core';
import { MessageType } from '../types.js';
import type { SlashCommand, SlashCommandActionReturn } from './types.js';
import { CommandKind } from './types.js';
import {
CommandKind,
type SlashCommand,
type SlashCommandActionReturn,
} from './types.js';
export const memoryCommand: SlashCommand = {
name: 'memory',
@@ -4,8 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { OpenDialogActionReturn, SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import {
CommandKind,
type OpenDialogActionReturn,
type SlashCommand,
} from './types.js';
export const privacyCommand: SlashCommand = {
name: 'privacy',
@@ -4,8 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { OpenDialogActionReturn, SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import {
CommandKind,
type OpenDialogActionReturn,
type SlashCommand,
} from './types.js';
export const settingsCommand: SlashCommand = {
name: 'settings',
@@ -17,8 +17,7 @@ import {
} from './setupGithubCommand.js';
import type { CommandContext } from './types.js';
import * as commandUtils from '../utils/commandUtils.js';
import type { ToolActionReturn } from '@google/gemini-cli-core';
import { debugLogger } from '@google/gemini-cli-core';
import { debugLogger, type ToolActionReturn } from '@google/gemini-cli-core';
vi.mock('child_process');
@@ -17,8 +17,11 @@ import {
getGitHubRepoInfo,
} from '../../utils/gitUtils.js';
import type { SlashCommand, SlashCommandActionReturn } from './types.js';
import { CommandKind } from './types.js';
import {
CommandKind,
type SlashCommand,
type SlashCommandActionReturn,
} from './types.js';
import { getUrlOpenCommand } from '../../ui/utils/commandUtils.js';
import { debugLogger } from '@google/gemini-cli-core';
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import { CommandKind, type SlashCommand } from './types.js';
export const shortcutsCommand: SlashCommand = {
name: 'shortcuts',
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import { CommandKind, type SlashCommand } from './types.js';
import { terminalSetup } from '../utils/terminalSetup.js';
import { type MessageActionReturn } from '@google/gemini-cli-core';
+5 -2
View File
@@ -4,8 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { OpenDialogActionReturn, SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import {
CommandKind,
type OpenDialogActionReturn,
type SlashCommand,
} from './types.js';
export const themeCommand: SlashCommand = {
name: 'theme',
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { vi } from 'vitest';
import { describe, it, expect } from 'vitest';
import { describe, it, expect, type vi } from 'vitest';
import { toolsCommand } from './toolsCommand.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
import { MessageType } from '../types.js';
@@ -10,8 +10,7 @@ import {
shouldLaunchBrowser,
UPGRADE_URL_PAGE,
} from '@google/gemini-cli-core';
import type { SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import { CommandKind, type SlashCommand } from './types.js';
/**
* Command to open the upgrade page for Gemini Code Assist.
+1 -2
View File
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import { CommandKind, type SlashCommand } from './types.js';
export const vimCommand: SlashCommand = {
name: 'vim',
@@ -4,16 +4,16 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Config, AuthType } from '@google/gemini-cli-core';
import {
debugLogger,
OutputFormat,
ExitCodes,
getAuthTypeFromEnv,
type Config,
type AuthType,
} from '@google/gemini-cli-core';
import { USER_SETTINGS_PATH } from './config/settings.js';
import { USER_SETTINGS_PATH, type LoadedSettings } from './config/settings.js';
import { validateAuthMethod } from './config/auth.js';
import { type LoadedSettings } from './config/settings.js';
import { handleError } from './utils/errors.js';
import { runExitCleanup } from './utils/cleanup.js';