refactor: remove imported multiple times (#1846)
This commit is contained in:
parent
e188daab91
commit
b980a47879
|
@ -4,8 +4,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { spawnSync } from 'child_process';
|
import { spawnSync, spawn } from 'child_process';
|
||||||
import { spawn } from 'child_process';
|
|
||||||
import { mkdirSync, rmSync, createWriteStream } from 'fs';
|
import { mkdirSync, rmSync, createWriteStream } from 'fs';
|
||||||
import { join, dirname, basename } from 'path';
|
import { join, dirname, basename } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
|
@ -21,10 +21,13 @@ import { ShellTool } from '../tools/shell.js';
|
||||||
import { WriteFileTool } from '../tools/write-file.js';
|
import { WriteFileTool } from '../tools/write-file.js';
|
||||||
import { WebFetchTool } from '../tools/web-fetch.js';
|
import { WebFetchTool } from '../tools/web-fetch.js';
|
||||||
import { ReadManyFilesTool } from '../tools/read-many-files.js';
|
import { ReadManyFilesTool } from '../tools/read-many-files.js';
|
||||||
import { MemoryTool, setGeminiMdFilename } from '../tools/memoryTool.js';
|
import {
|
||||||
|
MemoryTool,
|
||||||
|
setGeminiMdFilename,
|
||||||
|
GEMINI_CONFIG_DIR as GEMINI_DIR,
|
||||||
|
} from '../tools/memoryTool.js';
|
||||||
import { WebSearchTool } from '../tools/web-search.js';
|
import { WebSearchTool } from '../tools/web-search.js';
|
||||||
import { GeminiClient } from '../core/client.js';
|
import { GeminiClient } from '../core/client.js';
|
||||||
import { GEMINI_CONFIG_DIR as GEMINI_DIR } from '../tools/memoryTool.js';
|
|
||||||
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
||||||
import { GitService } from '../services/gitService.js';
|
import { GitService } from '../services/gitService.js';
|
||||||
import { getProjectTempDir } from '../utils/paths.js';
|
import { getProjectTempDir } from '../utils/paths.js';
|
||||||
|
|
|
@ -32,13 +32,13 @@ import { retryWithBackoff } from '../utils/retry.js';
|
||||||
import { getErrorMessage } from '../utils/errors.js';
|
import { getErrorMessage } from '../utils/errors.js';
|
||||||
import { tokenLimit } from './tokenLimits.js';
|
import { tokenLimit } from './tokenLimits.js';
|
||||||
import {
|
import {
|
||||||
|
AuthType,
|
||||||
ContentGenerator,
|
ContentGenerator,
|
||||||
ContentGeneratorConfig,
|
ContentGeneratorConfig,
|
||||||
createContentGenerator,
|
createContentGenerator,
|
||||||
} from './contentGenerator.js';
|
} from './contentGenerator.js';
|
||||||
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
||||||
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
||||||
import { AuthType } from './contentGenerator.js';
|
|
||||||
|
|
||||||
function isThinkingSupported(model: string) {
|
function isThinkingSupported(model: string) {
|
||||||
if (model.startsWith('gemini-2.5')) return true;
|
if (model.startsWith('gemini-2.5')) return true;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
CoreToolScheduler,
|
CoreToolScheduler,
|
||||||
ToolCall,
|
ToolCall,
|
||||||
ValidatingToolCall,
|
ValidatingToolCall,
|
||||||
|
convertToFunctionResponse,
|
||||||
} from './coreToolScheduler.js';
|
} from './coreToolScheduler.js';
|
||||||
import {
|
import {
|
||||||
BaseTool,
|
BaseTool,
|
||||||
|
@ -19,7 +20,6 @@ import {
|
||||||
Config,
|
Config,
|
||||||
} from '../index.js';
|
} from '../index.js';
|
||||||
import { Part, PartListUnion } from '@google/genai';
|
import { Part, PartListUnion } from '@google/genai';
|
||||||
import { convertToFunctionResponse } from './coreToolScheduler.js';
|
|
||||||
|
|
||||||
class MockTool extends BaseTool<Record<string, unknown>, ToolResult> {
|
class MockTool extends BaseTool<Record<string, unknown>, ToolResult> {
|
||||||
shouldConfirm = false;
|
shouldConfirm = false;
|
||||||
|
|
|
@ -18,9 +18,12 @@ import {
|
||||||
} from '../tools/tools.js';
|
} from '../tools/tools.js';
|
||||||
import { getResponseText } from '../utils/generateContentResponseUtilities.js';
|
import { getResponseText } from '../utils/generateContentResponseUtilities.js';
|
||||||
import { reportError } from '../utils/errorReporting.js';
|
import { reportError } from '../utils/errorReporting.js';
|
||||||
import { getErrorMessage } from '../utils/errors.js';
|
import {
|
||||||
|
getErrorMessage,
|
||||||
|
UnauthorizedError,
|
||||||
|
toFriendlyError,
|
||||||
|
} from '../utils/errors.js';
|
||||||
import { GeminiChat } from './geminiChat.js';
|
import { GeminiChat } from './geminiChat.js';
|
||||||
import { UnauthorizedError, toFriendlyError } from '../utils/errors.js';
|
|
||||||
|
|
||||||
// Define a structure for tools passed to the server
|
// Define a structure for tools passed to the server
|
||||||
export interface ServerTool {
|
export interface ServerTool {
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EditorType } from '../utils/editor.js';
|
import { EditorType, openDiff } from '../utils/editor.js';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import * as Diff from 'diff';
|
import * as Diff from 'diff';
|
||||||
import { openDiff } from '../utils/editor.js';
|
|
||||||
import { DEFAULT_DIFF_OPTIONS } from './diffOptions.js';
|
import { DEFAULT_DIFF_OPTIONS } from './diffOptions.js';
|
||||||
import { isNodeError } from '../utils/errors.js';
|
import { isNodeError } from '../utils/errors.js';
|
||||||
import { Tool } from './tools.js';
|
import { Tool } from './tools.js';
|
||||||
|
|
|
@ -8,9 +8,12 @@ import path from 'path';
|
||||||
import { SchemaValidator } from '../utils/schemaValidator.js';
|
import { SchemaValidator } from '../utils/schemaValidator.js';
|
||||||
import { makeRelative, shortenPath } from '../utils/paths.js';
|
import { makeRelative, shortenPath } from '../utils/paths.js';
|
||||||
import { BaseTool, ToolResult } from './tools.js';
|
import { BaseTool, ToolResult } from './tools.js';
|
||||||
import { isWithinRoot, processSingleFileContent } from '../utils/fileUtils.js';
|
import {
|
||||||
|
isWithinRoot,
|
||||||
|
processSingleFileContent,
|
||||||
|
getSpecificMimeType,
|
||||||
|
} from '../utils/fileUtils.js';
|
||||||
import { Config } from '../config/config.js';
|
import { Config } from '../config/config.js';
|
||||||
import { getSpecificMimeType } from '../utils/fileUtils.js';
|
|
||||||
import {
|
import {
|
||||||
recordFileOperationMetric,
|
recordFileOperationMetric,
|
||||||
FileOperation,
|
FileOperation,
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { vi } from 'vitest';
|
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||||
import type { Mock } from 'vitest';
|
import type { Mock } from 'vitest';
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
||||||
import { mockControl } from '../__mocks__/fs/promises.js';
|
import { mockControl } from '../__mocks__/fs/promises.js';
|
||||||
import { ReadManyFilesTool } from './read-many-files.js';
|
import { ReadManyFilesTool } from './read-many-files.js';
|
||||||
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
||||||
|
|
Loading…
Reference in New Issue