fix: change .geminiignore to .qwenignore

This commit is contained in:
mingholy.lmh
2025-09-14 19:38:40 +08:00
parent 8bb8660c72
commit 1993156721
23 changed files with 120 additions and 118 deletions

View File

@@ -448,11 +448,11 @@ export const SETTINGS_SCHEMA = {
},
respectGeminiIgnore: {
type: 'boolean',
label: 'Respect .geminiignore',
label: 'Respect .qwenignore',
category: 'Context',
requiresRestart: true,
default: true,
description: 'Respect .geminiignore files when searching',
description: 'Respect .qwenignore files when searching',
showInDialog: true,
},
enableRecursiveFileSearch: {

View File

@@ -205,7 +205,7 @@ describe('AtFileProcessor', () => {
expect(context.ui.addItem).toHaveBeenCalledWith(
{
type: MessageType.INFO,
text: "File '@{ignored.txt}' was ignored by .gitignore or .geminiignore and was not included in the prompt.",
text: "File '@{ignored.txt}' was ignored by .gitignore or .qwenignore and was not included in the prompt.",
},
expect.any(Number),
);

View File

@@ -56,7 +56,7 @@ export class AtFileProcessor implements IPromptProcessor {
try {
const fileContentParts = await readPathFromWorkspace(pathStr, config);
if (fileContentParts.length === 0) {
const uiMessage = `File '@{${pathStr}}' was ignored by .gitignore or .geminiignore and was not included in the prompt.`;
const uiMessage = `File '@{${pathStr}}' was ignored by .gitignore or .qwenignore and was not included in the prompt.`;
context.ui.addItem(
{ type: MessageType.INFO, text: uiMessage },
Date.now(),

View File

@@ -581,7 +581,7 @@ describe('handleAtCommand', () => {
describe('gemini-ignore filtering', () => {
it('should skip gemini-ignored files in @ commands', async () => {
await createTestFile(
path.join(testRootDir, '.geminiignore'),
path.join(testRootDir, '.qwenignore'),
'build/output.js',
);
const geminiIgnoredFile = await createTestFile(
@@ -611,9 +611,9 @@ describe('handleAtCommand', () => {
);
});
});
it('should process non-ignored files when .geminiignore is present', async () => {
it('should process non-ignored files when .qwenignore is present', async () => {
await createTestFile(
path.join(testRootDir, '.geminiignore'),
path.join(testRootDir, '.qwenignore'),
'build/output.js',
);
const validFile = await createTestFile(
@@ -645,7 +645,7 @@ describe('handleAtCommand', () => {
it('should handle mixed gemini-ignored and valid files', async () => {
await createTestFile(
path.join(testRootDir, '.geminiignore'),
path.join(testRootDir, '.qwenignore'),
'dist/bundle.js',
);
const validFile = await createTestFile(

View File

@@ -53,8 +53,8 @@ describe('FileDiscoveryService', () => {
expect(service.shouldGitIgnoreFile('node_modules/foo.js')).toBe(false);
});
it('should load .geminiignore patterns even when not in a git repo', async () => {
await createTestFile('.geminiignore', 'secrets.txt');
it('should load .qwenignore patterns even when not in a git repo', async () => {
await createTestFile('.qwenignore', 'secrets.txt');
const service = new FileDiscoveryService(projectRoot);
expect(service.shouldGeminiIgnoreFile('secrets.txt')).toBe(true);
@@ -66,7 +66,7 @@ describe('FileDiscoveryService', () => {
beforeEach(async () => {
await fs.mkdir(path.join(projectRoot, '.git'));
await createTestFile('.gitignore', 'node_modules/\n.git/\ndist');
await createTestFile('.geminiignore', 'logs/');
await createTestFile('.qwenignore', 'logs/');
});
it('should filter out git-ignored and gemini-ignored files by default', () => {
@@ -140,7 +140,7 @@ describe('FileDiscoveryService', () => {
beforeEach(async () => {
await fs.mkdir(path.join(projectRoot, '.git'));
await createTestFile('.gitignore', 'node_modules/');
await createTestFile('.geminiignore', '*.log');
await createTestFile('.qwenignore', '*.log');
});
it('should return true for git-ignored files', () => {

View File

@@ -9,7 +9,7 @@ import { GitIgnoreParser } from '../utils/gitIgnoreParser.js';
import { isGitRepository } from '../utils/gitUtils.js';
import * as path from 'node:path';
const GEMINI_IGNORE_FILE_NAME = '.geminiignore';
const GEMINI_IGNORE_FILE_NAME = '.qwenignore';
export interface FilterFilesOptions {
respectGitIgnore?: boolean;
@@ -104,7 +104,7 @@ export class FileDiscoveryService {
}
/**
* Returns loaded patterns from .geminiignore
* Returns loaded patterns from .qwenignore
*/
getGeminiIgnorePatterns(): string[] {
return this.geminiIgnoreFilter?.getPatterns() ?? [];

View File

@@ -28,7 +28,7 @@ export interface LSToolParams {
ignore?: string[];
/**
* Whether to respect .gitignore and .geminiignore patterns (optional, defaults to true)
* Whether to respect .gitignore and .qwenignore patterns (optional, defaults to true)
*/
file_filtering_options?: {
respect_git_ignore?: boolean;
@@ -297,7 +297,7 @@ export class LSTool extends BaseDeclarativeTool<LSToolParams, ToolResult> {
},
file_filtering_options: {
description:
'Optional: Whether to respect ignore patterns from .gitignore or .geminiignore',
'Optional: Whether to respect ignore patterns from .gitignore or .qwenignore',
type: 'object',
properties: {
respect_git_ignore: {
@@ -307,7 +307,7 @@ export class LSTool extends BaseDeclarativeTool<LSToolParams, ToolResult> {
},
respect_gemini_ignore: {
description:
'Optional: Whether to respect .geminiignore patterns when listing files. Defaults to true.',
'Optional: Whether to respect .qwenignore patterns when listing files. Defaults to true.',
type: 'boolean',
},
},

View File

@@ -409,21 +409,21 @@ describe('ReadFileTool', () => {
);
});
describe('with .geminiignore', () => {
describe('with .qwenignore', () => {
beforeEach(async () => {
await fsp.writeFile(
path.join(tempRootDir, '.geminiignore'),
path.join(tempRootDir, '.qwenignore'),
['foo.*', 'ignored/'].join('\n'),
);
});
it('should throw error if path is ignored by a .geminiignore pattern', async () => {
it('should throw error if path is ignored by a .qwenignore pattern', async () => {
const ignoredFilePath = path.join(tempRootDir, 'foo.bar');
await fsp.writeFile(ignoredFilePath, 'content', 'utf-8');
const params: ReadFileToolParams = {
absolute_path: ignoredFilePath,
};
const expectedError = `File path '${ignoredFilePath}' is ignored by .geminiignore pattern(s).`;
const expectedError = `File path '${ignoredFilePath}' is ignored by .qwenignore pattern(s).`;
expect(() => tool.build(params)).toThrow(expectedError);
});
@@ -435,7 +435,7 @@ describe('ReadFileTool', () => {
const params: ReadFileToolParams = {
absolute_path: ignoredFilePath,
};
const expectedError = `File path '${ignoredFilePath}' is ignored by .geminiignore pattern(s).`;
const expectedError = `File path '${ignoredFilePath}' is ignored by .qwenignore pattern(s).`;
expect(() => tool.build(params)).toThrow(expectedError);
});

View File

@@ -194,7 +194,7 @@ export class ReadFileTool extends BaseDeclarativeTool<
const fileService = this.config.getFileService();
if (fileService.shouldGeminiIgnoreFile(params.absolute_path)) {
return `File path '${filePath}' is ignored by .geminiignore pattern(s).`;
return `File path '${filePath}' is ignored by .qwenignore pattern(s).`;
}
return null;

View File

@@ -68,7 +68,7 @@ describe('ReadManyFilesTool', () => {
tempDirOutsideRoot = fs.realpathSync(
fs.mkdtempSync(path.join(os.tmpdir(), 'read-many-files-external-')),
);
fs.writeFileSync(path.join(tempRootDir, '.geminiignore'), 'foo.*');
fs.writeFileSync(path.join(tempRootDir, '.qwenignore'), 'foo.*');
const fileService = new FileDiscoveryService(tempRootDir);
const mockConfig = {
getFileService: () => fileService,
@@ -466,7 +466,7 @@ describe('ReadManyFilesTool', () => {
]);
});
it('should return error if path is ignored by a .geminiignore pattern', async () => {
it('should return error if path is ignored by a .qwenignore pattern', async () => {
createFile('foo.bar', '');
createFile('bar.ts', '');
createFile('foo.quux', '');

View File

@@ -65,7 +65,7 @@ export interface ReadManyFilesParams {
useDefaultExcludes?: boolean;
/**
* Whether to respect .gitignore and .geminiignore patterns (optional, defaults to true)
* Whether to respect .gitignore and .qwenignore patterns (optional, defaults to true)
*/
file_filtering_options?: {
respect_git_ignore?: boolean;
@@ -149,13 +149,13 @@ ${finalExclusionPatternsForDescription
: 'none specified'
}`;
// Add a note if .geminiignore patterns contributed to the final list of exclusions
// Add a note if .qwenignore patterns contributed to the final list of exclusions
if (geminiIgnorePatterns.length > 0) {
const geminiPatternsInEffect = geminiIgnorePatterns.filter((p) =>
finalExclusionPatternsForDescription.includes(p),
).length;
if (geminiPatternsInEffect > 0) {
excludeDesc += ` (includes ${geminiPatternsInEffect} from .geminiignore)`;
excludeDesc += ` (includes ${geminiPatternsInEffect} from .qwenignore)`;
}
}
@@ -571,7 +571,7 @@ export class ReadManyFilesTool extends BaseDeclarativeTool<
},
file_filtering_options: {
description:
'Whether to respect ignore patterns from .gitignore or .geminiignore',
'Whether to respect ignore patterns from .gitignore or .qwenignore',
type: 'object',
properties: {
respect_git_ignore: {
@@ -581,7 +581,7 @@ export class ReadManyFilesTool extends BaseDeclarativeTool<
},
respect_gemini_ignore: {
description:
'Optional: Whether to respect .geminiignore patterns when listing files. Defaults to true.',
'Optional: Whether to respect .qwenignore patterns when listing files. Defaults to true.',
type: 'boolean',
},
},

View File

@@ -138,7 +138,7 @@ describe('bfsFileSearch', () => {
});
it('should ignore geminiignored files', async () => {
await createTestFile('node_modules/', 'project', '.geminiignore');
await createTestFile('node_modules/', 'project', '.qwenignore');
await createTestFile('content', 'project', 'node_modules', 'target.txt');
const targetFilePath = await createTestFile(
'content',

View File

@@ -22,9 +22,9 @@ describe('crawler', () => {
vi.restoreAllMocks();
});
it('should use .geminiignore rules', async () => {
it('should use .qwenignore rules', async () => {
tmpDir = await createTmpDir({
'.geminiignore': 'dist/',
'.qwenignore': 'dist/',
dist: ['ignored.js'],
src: ['not-ignored.js'],
});
@@ -48,16 +48,16 @@ describe('crawler', () => {
expect.arrayContaining([
'.',
'src/',
'.geminiignore',
'.qwenignore',
'src/not-ignored.js',
]),
);
});
it('should combine .gitignore and .geminiignore rules', async () => {
it('should combine .gitignore and .qwenignore rules', async () => {
tmpDir = await createTmpDir({
'.gitignore': 'dist/',
'.geminiignore': 'build/',
'.qwenignore': 'build/',
dist: ['ignored-by-git.js'],
build: ['ignored-by-gemini.js'],
src: ['not-ignored.js'],
@@ -82,7 +82,7 @@ describe('crawler', () => {
expect.arrayContaining([
'.',
'src/',
'.geminiignore',
'.qwenignore',
'.gitignore',
'src/not-ignored.js',
]),

View File

@@ -17,9 +17,9 @@ describe('FileSearch', () => {
vi.restoreAllMocks();
});
it('should use .geminiignore rules', async () => {
it('should use .qwenignore rules', async () => {
tmpDir = await createTmpDir({
'.geminiignore': 'dist/',
'.qwenignore': 'dist/',
dist: ['ignored.js'],
src: ['not-ignored.js'],
});
@@ -38,13 +38,13 @@ describe('FileSearch', () => {
await fileSearch.initialize();
const results = await fileSearch.search('');
expect(results).toEqual(['src/', '.geminiignore', 'src/not-ignored.js']);
expect(results).toEqual(['src/', '.qwenignore', 'src/not-ignored.js']);
});
it('should combine .gitignore and .geminiignore rules', async () => {
it('should combine .gitignore and .qwenignore rules', async () => {
tmpDir = await createTmpDir({
'.gitignore': 'dist/',
'.geminiignore': 'build/',
'.qwenignore': 'build/',
dist: ['ignored-by-git.js'],
build: ['ignored-by-gemini.js'],
src: ['not-ignored.js'],
@@ -66,7 +66,7 @@ describe('FileSearch', () => {
expect(results).toEqual([
'src/',
'.geminiignore',
'.qwenignore',
'.gitignore',
'src/not-ignored.js',
]);

View File

@@ -89,9 +89,9 @@ describe('loadIgnoreRules', () => {
expect(fileFilter('test.txt')).toBe(false);
});
it('should load rules from .geminiignore', async () => {
it('should load rules from .qwenignore', async () => {
tmpDir = await createTmpDir({
'.geminiignore': '*.log',
'.qwenignore': '*.log',
});
const ignore = loadIgnoreRules({
projectRoot: tmpDir,
@@ -104,10 +104,10 @@ describe('loadIgnoreRules', () => {
expect(fileFilter('test.txt')).toBe(false);
});
it('should combine rules from .gitignore and .geminiignore', async () => {
it('should combine rules from .gitignore and .qwenignore', async () => {
tmpDir = await createTmpDir({
'.gitignore': '*.log',
'.geminiignore': '*.txt',
'.qwenignore': '*.txt',
});
const ignore = loadIgnoreRules({
projectRoot: tmpDir,

View File

@@ -28,7 +28,7 @@ export function loadIgnoreRules(options: LoadIgnoreRulesOptions): Ignore {
}
if (options.useGeminiignore) {
const geminiignorePath = path.join(options.projectRoot, '.geminiignore');
const geminiignorePath = path.join(options.projectRoot, '.qwenignore');
if (fs.existsSync(geminiignorePath)) {
ignorer.add(fs.readFileSync(geminiignorePath, 'utf8'));
}

View File

@@ -295,7 +295,7 @@ ${testRootDir}${path.sep}
describe('with geminiignore', () => {
it('should ignore geminiignore files by default', async () => {
await fsPromises.writeFile(
nodePath.join(testRootDir, '.geminiignore'),
nodePath.join(testRootDir, '.qwenignore'),
'ignored.txt\nnode_modules/\n.gemini/\n!/.gemini/config.yaml',
);
await createTestFile('file1.txt');
@@ -315,7 +315,7 @@ ${testRootDir}${path.sep}
it('should not ignore files if respectGeminiIgnore is false', async () => {
await fsPromises.writeFile(
nodePath.join(testRootDir, '.geminiignore'),
nodePath.join(testRootDir, '.qwenignore'),
'ignored.txt\nnode_modules/\n.gemini/\n!/.gemini/config.yaml',
);
await createTestFile('file1.txt');

View File

@@ -82,16 +82,16 @@ node_modules/
it('should handle custom patterns file name', async () => {
// No .git directory for this test
await createTestFile('.geminiignore', 'temp/\n*.tmp');
await createTestFile('.qwenignore', 'temp/\n*.tmp');
parser.loadPatterns('.geminiignore');
parser.loadPatterns('.qwenignore');
expect(parser.getPatterns()).toEqual(['temp/', '*.tmp']);
expect(parser.isIgnored(path.join('temp', 'file.txt'))).toBe(true);
expect(parser.isIgnored(path.join('src', 'file.tmp'))).toBe(true);
});
it('should initialize without errors when no .geminiignore exists', () => {
expect(() => parser.loadPatterns('.geminiignore')).not.toThrow();
it('should initialize without errors when no .qwenignore exists', () => {
expect(() => parser.loadPatterns('.qwenignore')).not.toThrow();
});
});