mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-08-09 00:16:57 -07:00
Merge remote-tracking branch 'origin/main' into rename-directory-to-workspace
# Conflicts: # docs/cli/settings.md # docs/reference/configuration.md # packages/cli/src/config/settings.test.ts # packages/cli/src/config/settingsSchema.ts # packages/cli/src/services/CommandService.test.ts # packages/cli/src/services/FileCommandLoader.ts # packages/cli/src/ui/components/RewindViewer.test.tsx # packages/cli/src/ui/constants/tips.ts # packages/cli/src/ui/utils/borderStyles.test.tsx # packages/cli/src/utils/processUtils.test.ts # packages/cli/src/utils/sessionUtils.ts # packages/core/src/commands/memory.test.ts # packages/core/src/config/config.ts # packages/core/src/config/storage.test.ts # packages/core/src/core/__snapshots__/prompts.test.ts.snap # packages/core/src/scheduler/tool-executor.ts # packages/core/src/services/contextManager.ts # packages/core/src/utils/memoryDiscovery.test.ts # packages/core/src/utils/memoryDiscovery.ts # schemas/settings.schema.json
This commit is contained in:
@@ -162,7 +162,6 @@ describe('commandUtils', () => {
|
||||
it('should return true when query starts with @', () => {
|
||||
expect(isAtCommand('@file')).toBe(true);
|
||||
expect(isAtCommand('@path/to/file')).toBe(true);
|
||||
expect(isAtCommand('@')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true when query contains @ preceded by whitespace', () => {
|
||||
@@ -171,17 +170,36 @@ describe('commandUtils', () => {
|
||||
expect(isAtCommand(' @file')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when query does not start with @ and has no spaced @', () => {
|
||||
it('should return true when @ is preceded by non-whitespace (external editor scenario)', () => {
|
||||
// When a user composes a prompt in an external editor, @-references may
|
||||
// appear after punctuation characters such as ':' or '(' without a space.
|
||||
// The processor must still recognise these as @-commands so that the
|
||||
// referenced files are pre-loaded before the query is sent to the model.
|
||||
expect(isAtCommand('check:@file.py')).toBe(true);
|
||||
expect(isAtCommand('analyze(@file.py)')).toBe(true);
|
||||
expect(isAtCommand('hello@file')).toBe(true);
|
||||
expect(isAtCommand('text@path/to/file')).toBe(true);
|
||||
expect(isAtCommand('user@host')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when query does not contain any @<path> pattern', () => {
|
||||
expect(isAtCommand('file')).toBe(false);
|
||||
expect(isAtCommand('hello')).toBe(false);
|
||||
expect(isAtCommand('')).toBe(false);
|
||||
expect(isAtCommand('email@domain.com')).toBe(false);
|
||||
expect(isAtCommand('user@host')).toBe(false);
|
||||
// A bare '@' with no following path characters is not an @-command.
|
||||
expect(isAtCommand('@')).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when @ is not preceded by whitespace', () => {
|
||||
expect(isAtCommand('hello@file')).toBe(false);
|
||||
expect(isAtCommand('text@path')).toBe(false);
|
||||
it('should return false when @ is escaped with a backslash', () => {
|
||||
expect(isAtCommand('\\@file')).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true for multi-line external editor prompts with @-references', () => {
|
||||
expect(isAtCommand('Please review:\n@src/main.py\nand fix bugs.')).toBe(
|
||||
true,
|
||||
);
|
||||
// @file after a colon on the same line.
|
||||
expect(isAtCommand('Files:@src/a.py,@src/b.py')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user