summaryrefslogtreecommitdiff
path: root/packages/core/src
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-07-22 17:18:57 -0700
committerGitHub <[email protected]>2025-07-23 00:18:57 +0000
commit30c68922a372755a5b9f918baf053e0d1f156fc5 (patch)
treef2889f7f89fc3609071f943ce110a0d755d78b7f /packages/core/src
parenta00f1bb916b551fc17fa5bab80fb51dcdc88f00d (diff)
Fix windows bugs in atCommandProcessor.ts (#4684)
Diffstat (limited to 'packages/core/src')
-rw-r--r--packages/core/src/tools/read-many-files.ts38
-rw-r--r--packages/core/src/utils/getFolderStructure.test.ts21
2 files changed, 28 insertions, 31 deletions
diff --git a/packages/core/src/tools/read-many-files.ts b/packages/core/src/tools/read-many-files.ts
index 7ea6c722..fb160a79 100644
--- a/packages/core/src/tools/read-many-files.ts
+++ b/packages/core/src/tools/read-many-files.ts
@@ -128,8 +128,6 @@ export class ReadManyFilesTool extends BaseTool<
> {
static readonly Name: string = 'read_many_files';
- private readonly geminiIgnorePatterns: string[] = [];
-
constructor(private config: Config) {
const parameterSchema: Schema = {
type: Type.OBJECT,
@@ -213,9 +211,6 @@ Use this tool when the user's query implies needing the content of several files
Icon.FileSearch,
parameterSchema,
);
- this.geminiIgnorePatterns = config
- .getFileService()
- .getGeminiIgnorePatterns();
}
validateParams(params: ReadManyFilesParams): string | null {
@@ -233,17 +228,19 @@ Use this tool when the user's query implies needing the content of several files
// Determine the final list of exclusion patterns exactly as in execute method
const paramExcludes = params.exclude || [];
const paramUseDefaultExcludes = params.useDefaultExcludes !== false;
-
+ const geminiIgnorePatterns = this.config
+ .getFileService()
+ .getGeminiIgnorePatterns();
const finalExclusionPatternsForDescription: string[] =
paramUseDefaultExcludes
- ? [...DEFAULT_EXCLUDES, ...paramExcludes, ...this.geminiIgnorePatterns]
- : [...paramExcludes, ...this.geminiIgnorePatterns];
+ ? [...DEFAULT_EXCLUDES, ...paramExcludes, ...geminiIgnorePatterns]
+ : [...paramExcludes, ...geminiIgnorePatterns];
let excludeDesc = `Excluding: ${finalExclusionPatternsForDescription.length > 0 ? `patterns like \`${finalExclusionPatternsForDescription.slice(0, 2).join('`, `')}${finalExclusionPatternsForDescription.length > 2 ? '...`' : '`'}` : 'none specified'}`;
// Add a note if .geminiignore patterns contributed to the final list of exclusions
- if (this.geminiIgnorePatterns.length > 0) {
- const geminiPatternsInEffect = this.geminiIgnorePatterns.filter((p) =>
+ if (geminiIgnorePatterns.length > 0) {
+ const geminiPatternsInEffect = geminiIgnorePatterns.filter((p) =>
finalExclusionPatternsForDescription.includes(p),
).length;
if (geminiPatternsInEffect > 0) {
@@ -305,15 +302,18 @@ Use this tool when the user's query implies needing the content of several files
}
try {
- const entries = await glob(searchPatterns, {
- cwd: this.config.getTargetDir(),
- ignore: effectiveExcludes,
- nodir: true,
- dot: true,
- absolute: true,
- nocase: true,
- signal,
- });
+ const entries = await glob(
+ searchPatterns.map((p) => p.replace(/\\/g, '/')),
+ {
+ cwd: this.config.getTargetDir(),
+ ignore: effectiveExcludes,
+ nodir: true,
+ dot: true,
+ absolute: true,
+ nocase: true,
+ signal,
+ },
+ );
const gitFilteredEntries = fileFilteringOptions.respectGitIgnore
? fileDiscovery
diff --git a/packages/core/src/utils/getFolderStructure.test.ts b/packages/core/src/utils/getFolderStructure.test.ts
index 8694fe20..3f1b4534 100644
--- a/packages/core/src/utils/getFolderStructure.test.ts
+++ b/packages/core/src/utils/getFolderStructure.test.ts
@@ -4,42 +4,37 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import fsPromises from 'fs/promises';
import * as nodePath from 'path';
import * as os from 'os';
import { getFolderStructure } from './getFolderStructure.js';
-import * as gitUtils from './gitUtils.js';
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
import * as path from 'path';
-vi.mock('./gitUtils.js');
-
describe('getFolderStructure', () => {
let testRootDir: string;
- const createEmptyDir = async (...pathSegments: string[]) => {
+ async function createEmptyDir(...pathSegments: string[]) {
const fullPath = path.join(testRootDir, ...pathSegments);
await fsPromises.mkdir(fullPath, { recursive: true });
- };
+ }
- const createTestFile = async (...pathSegments: string[]) => {
+ async function createTestFile(...pathSegments: string[]) {
const fullPath = path.join(testRootDir, ...pathSegments);
await fsPromises.mkdir(path.dirname(fullPath), { recursive: true });
await fsPromises.writeFile(fullPath, '');
return fullPath;
- };
+ }
beforeEach(async () => {
testRootDir = await fsPromises.mkdtemp(
path.join(os.tmpdir(), 'folder-structure-test-'),
);
- vi.resetAllMocks();
});
afterEach(async () => {
await fsPromises.rm(testRootDir, { recursive: true, force: true });
- vi.restoreAllMocks();
});
it('should return basic folder structure', async () => {
@@ -246,8 +241,10 @@ ${testRootDir}${path.sep}
});
describe('with gitignore', () => {
- beforeEach(() => {
- vi.mocked(gitUtils.isGitRepository).mockReturnValue(true);
+ beforeEach(async () => {
+ await fsPromises.mkdir(path.join(testRootDir, '.git'), {
+ recursive: true,
+ });
});
it('should ignore files and folders specified in .gitignore', async () => {