fix: merge duplicate imports in packages/core (3/4) (#20928)

This commit is contained in:
nityam
2026-03-04 05:42:59 +05:30
committed by GitHub
parent d25088956d
commit 28af4e127f
143 changed files with 909 additions and 712 deletions
@@ -6,11 +6,11 @@
import { describe, it, expect } from 'vitest';
import { convertToRestPayload } from './apiConversionUtils.js';
import type { GenerateContentParameters } from '@google/genai';
import {
FunctionCallingConfigMode,
HarmCategory,
HarmBlockThreshold,
type GenerateContentParameters,
} from '@google/genai';
describe('apiConversionUtils', () => {
+1 -2
View File
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect, vi, beforeEach } from 'vitest';
import type { Mock } from 'vitest';
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import readline from 'node:readline';
import process from 'node:process';
import { coreEvents } from './events.js';
@@ -5,8 +5,7 @@
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { Mocked } from 'vitest';
import { vi, describe, it, expect, beforeEach } from 'vitest';
import { vi, describe, it, expect, beforeEach, type Mocked } from 'vitest';
import type { BaseLlmClient } from '../core/baseLlmClient.js';
// MOCKS
+1 -1
View File
@@ -14,8 +14,8 @@ import {
type Mock,
} from 'vitest';
import * as actualNodeFs from 'node:fs'; // For setup/teardown
import fs from 'node:fs';
import * as actualNodeFs from 'node:fs'; // For setup/teardown
import fsPromises from 'node:fs/promises';
import path from 'node:path';
import os from 'node:os';
@@ -10,8 +10,7 @@ import * as path from 'node:path';
import * as cache from './crawlCache.js';
import { crawl } from './crawler.js';
import { createTmpDir, cleanupTmpDir } from '@google/gemini-cli-test-utils';
import type { Ignore } from './ignore.js';
import { loadIgnoreRules } from './ignore.js';
import { loadIgnoreRules, type Ignore } from './ignore.js';
import { GEMINI_IGNORE_FILE_NAME } from '../../config/constants.js';
import { FileDiscoveryService } from '../../services/fileDiscoveryService.js';
@@ -6,12 +6,10 @@
import path from 'node:path';
import picomatch from 'picomatch';
import type { Ignore } from './ignore.js';
import { loadIgnoreRules } from './ignore.js';
import { loadIgnoreRules, type Ignore } from './ignore.js';
import { ResultCache } from './result-cache.js';
import { crawl } from './crawler.js';
import type { FzfResultItem } from 'fzf';
import { AsyncFzf } from 'fzf';
import { AsyncFzf, type FzfResultItem } from 'fzf';
import { unescapePath } from '../paths.js';
import type { FileDiscoveryService } from '../../services/fileDiscoveryService.js';
@@ -16,14 +16,14 @@ import {
getCitations,
convertToFunctionResponse,
} from './generateContentResponseUtilities.js';
import type {
GenerateContentResponse,
Part,
SafetyRating,
CitationMetadata,
PartListUnion,
import {
FinishReason,
type GenerateContentResponse,
type Part,
type SafetyRating,
type CitationMetadata,
type PartListUnion,
} from '@google/genai';
import { FinishReason } from '@google/genai';
import {
DEFAULT_GEMINI_MODEL,
PREVIEW_GEMINI_MODEL,
@@ -12,8 +12,10 @@ import type {
FileDiscoveryService,
FilterFilesOptions,
} from '../services/fileDiscoveryService.js';
import type { FileFilteringOptions } from '../config/constants.js';
import { DEFAULT_FILE_FILTERING_OPTIONS } from '../config/constants.js';
import {
DEFAULT_FILE_FILTERING_OPTIONS,
type FileFilteringOptions,
} from '../config/constants.js';
import { debugLogger } from './debugLogger.js';
const MAX_ITEMS = 200;
+1 -2
View File
@@ -5,8 +5,7 @@
*/
import { describe, it, expect } from 'vitest';
import { parseGoogleApiError } from './googleErrors.js';
import type { QuotaFailure } from './googleErrors.js';
import { parseGoogleApiError, type QuotaFailure } from './googleErrors.js';
describe('parseGoogleApiError', () => {
it('should return null for non-gaxios errors', () => {
+7 -7
View File
@@ -4,14 +4,14 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type {
ErrorInfo,
GoogleApiError,
Help,
QuotaFailure,
RetryInfo,
import {
parseGoogleApiError,
type ErrorInfo,
type GoogleApiError,
type Help,
type QuotaFailure,
type RetryInfo,
} from './googleErrors.js';
import { parseGoogleApiError } from './googleErrors.js';
import { getErrorStatus, ModelNotFoundError } from './httpErrors.js';
/**
@@ -4,8 +4,15 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Mock } from 'vitest';
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
import {
vi,
describe,
it,
expect,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import { InstallationManager } from './installationManager.js';
import * as fs from 'node:fs';
import * as os from 'node:os';
@@ -20,10 +20,9 @@ import {
setGeminiMdFilename,
DEFAULT_CONTEXT_FILENAME,
} from '../tools/memoryTool.js';
import { flattenMemory } from '../config/memory.js';
import { flattenMemory, type HierarchicalMemory } from '../config/memory.js';
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
import { GEMINI_DIR, normalizePath, homedir as pathsHomedir } from './paths.js';
import type { HierarchicalMemory } from '../config/memory.js';
function flattenResult(result: {
memoryContent: HierarchicalMemory;
+4 -2
View File
@@ -11,8 +11,10 @@ import { bfsFileSearch } from './bfsFileSearch.js';
import { getAllGeminiMdFilenames } from '../tools/memoryTool.js';
import type { FileDiscoveryService } from '../services/fileDiscoveryService.js';
import { processImports } from './memoryImportProcessor.js';
import type { FileFilteringOptions } from '../config/constants.js';
import { DEFAULT_MEMORY_FILE_FILTERING_OPTIONS } from '../config/constants.js';
import {
DEFAULT_MEMORY_FILE_FILTERING_OPTIONS,
type FileFilteringOptions,
} from '../config/constants.js';
import { GEMINI_DIR, homedir, normalizePath } from './paths.js';
import type { ExtensionLoader } from './extensionLoader.js';
import { debugLogger } from './debugLogger.js';
@@ -4,14 +4,23 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Mock } from 'vitest';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import {
describe,
it,
expect,
vi,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import type { Content } from '@google/genai';
import { BaseLlmClient } from '../core/baseLlmClient.js';
import type { ContentGenerator } from '../core/contentGenerator.js';
import type { Config } from '../config/config.js';
import type { NextSpeakerResponse } from './nextSpeakerChecker.js';
import { checkNextSpeaker } from './nextSpeakerChecker.js';
import {
checkNextSpeaker,
type NextSpeakerResponse,
} from './nextSpeakerChecker.js';
import { GeminiChat } from '../core/geminiChat.js';
// Mock fs module to prevent actual file system operations during tests
+1 -2
View File
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { GenerateContentResponse } from '@google/genai';
import { ApiError } from '@google/genai';
import { ApiError, type GenerateContentResponse } from '@google/genai';
import {
TerminalQuotaError,
RetryableQuotaError,
+1 -2
View File
@@ -14,8 +14,7 @@ import {
type SpawnOptionsWithoutStdio,
} from 'node:child_process';
import * as readline from 'node:readline';
import type { Node, Tree } from 'web-tree-sitter';
import { Language, Parser, Query } from 'web-tree-sitter';
import { Language, Parser, Query, type Node, type Tree } from 'web-tree-sitter';
import { loadWasmBinary } from './fileUtils.js';
import { debugLogger } from './debugLogger.js';
+9 -2
View File
@@ -4,8 +4,15 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Mock } from 'vitest';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import {
describe,
it,
expect,
vi,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import { GeminiClient } from '../core/client.js';
import { Config } from '../config/config.js';
import {
+2 -1
View File
@@ -10,7 +10,6 @@ import {
getToolSuggestion,
shouldHideToolCall,
} from './tool-utils.js';
import type { AnyToolInvocation, Config } from '../index.js';
import {
ReadFileTool,
ApprovalMode,
@@ -19,6 +18,8 @@ import {
WRITE_FILE_DISPLAY_NAME,
EDIT_DISPLAY_NAME,
READ_FILE_DISPLAY_NAME,
type AnyToolInvocation,
type Config,
} from '../index.js';
import { createMockMessageBus } from '../test-utils/mock-message-bus.js';
+5 -2
View File
@@ -4,8 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { AnyDeclarativeTool, AnyToolInvocation } from '../index.js';
import { isTool } from '../index.js';
import {
isTool,
type AnyDeclarativeTool,
type AnyToolInvocation,
} from '../index.js';
import { SHELL_TOOL_NAMES } from './shell-utils.js';
import levenshtein from 'fast-levenshtein';
import { ApprovalMode } from '../policy/types.js';
@@ -4,8 +4,15 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type { Mock } from 'vitest';
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
import {
vi,
describe,
it,
expect,
beforeEach,
afterEach,
type Mock,
} from 'vitest';
import { UserAccountManager } from './userAccountManager.js';
import * as fs from 'node:fs';
import * as os from 'node:os';