mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Merge tag 'v0.1.21' of github.com:google-gemini/gemini-cli into chore/sync-gemini-cli-v0.1.21
This commit is contained in:
68
packages/core/src/ide/detect-ide.test.ts
Normal file
68
packages/core/src/ide/detect-ide.test.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect, afterEach, vi } from 'vitest';
|
||||
import { detectIde, DetectedIde } from './detect-ide.js';
|
||||
|
||||
describe('detectIde', () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
env: {},
|
||||
expected: DetectedIde.VSCode,
|
||||
},
|
||||
{
|
||||
env: { __COG_BASHRC_SOURCED: '1' },
|
||||
expected: DetectedIde.Devin,
|
||||
},
|
||||
{
|
||||
env: { REPLIT_USER: 'test' },
|
||||
expected: DetectedIde.Replit,
|
||||
},
|
||||
{
|
||||
env: { CURSOR_TRACE_ID: 'test' },
|
||||
expected: DetectedIde.Cursor,
|
||||
},
|
||||
{
|
||||
env: { CODESPACES: 'true' },
|
||||
expected: DetectedIde.Codespaces,
|
||||
},
|
||||
{
|
||||
env: { EDITOR_IN_CLOUD_SHELL: 'true' },
|
||||
expected: DetectedIde.CloudShell,
|
||||
},
|
||||
{
|
||||
env: { CLOUD_SHELL: 'true' },
|
||||
expected: DetectedIde.CloudShell,
|
||||
},
|
||||
{
|
||||
env: { TERM_PRODUCT: 'Trae' },
|
||||
expected: DetectedIde.Trae,
|
||||
},
|
||||
{
|
||||
env: { FIREBASE_DEPLOY_AGENT: 'true' },
|
||||
expected: DetectedIde.FirebaseStudio,
|
||||
},
|
||||
{
|
||||
env: { MONOSPACE_ENV: 'true' },
|
||||
expected: DetectedIde.FirebaseStudio,
|
||||
},
|
||||
])('detects the IDE for $expected', ({ env, expected }) => {
|
||||
vi.stubEnv('TERM_PROGRAM', 'vscode');
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
vi.stubEnv(key, value);
|
||||
}
|
||||
expect(detectIde()).toBe(expected);
|
||||
});
|
||||
|
||||
it('returns undefined for non-vscode', () => {
|
||||
vi.stubEnv('TERM_PROGRAM', 'definitely-not-vscode');
|
||||
expect(detectIde()).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -5,34 +5,54 @@
|
||||
*/
|
||||
|
||||
export enum DetectedIde {
|
||||
Devin = 'devin',
|
||||
Replit = 'replit',
|
||||
VSCode = 'vscode',
|
||||
VSCodium = 'vscodium',
|
||||
Cursor = 'cursor',
|
||||
CloudShell = 'cloudshell',
|
||||
Codespaces = 'codespaces',
|
||||
Windsurf = 'windsurf',
|
||||
FirebaseStudio = 'firebasestudio',
|
||||
Trae = 'trae',
|
||||
}
|
||||
|
||||
export function getIdeDisplayName(ide: DetectedIde): string {
|
||||
export interface IdeInfo {
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export function getIdeInfo(ide: DetectedIde): IdeInfo {
|
||||
switch (ide) {
|
||||
case DetectedIde.Devin:
|
||||
return {
|
||||
displayName: 'Devin',
|
||||
};
|
||||
case DetectedIde.Replit:
|
||||
return {
|
||||
displayName: 'Replit',
|
||||
};
|
||||
case DetectedIde.VSCode:
|
||||
return 'VS Code';
|
||||
case DetectedIde.VSCodium:
|
||||
return 'VSCodium';
|
||||
return {
|
||||
displayName: 'VS Code',
|
||||
};
|
||||
case DetectedIde.Cursor:
|
||||
return 'Cursor';
|
||||
return {
|
||||
displayName: 'Cursor',
|
||||
};
|
||||
case DetectedIde.CloudShell:
|
||||
return 'Cloud Shell';
|
||||
return {
|
||||
displayName: 'Cloud Shell',
|
||||
};
|
||||
case DetectedIde.Codespaces:
|
||||
return 'GitHub Codespaces';
|
||||
case DetectedIde.Windsurf:
|
||||
return 'Windsurf';
|
||||
return {
|
||||
displayName: 'GitHub Codespaces',
|
||||
};
|
||||
case DetectedIde.FirebaseStudio:
|
||||
return 'Firebase Studio';
|
||||
return {
|
||||
displayName: 'Firebase Studio',
|
||||
};
|
||||
case DetectedIde.Trae:
|
||||
return 'Trae';
|
||||
return {
|
||||
displayName: 'Trae',
|
||||
};
|
||||
default: {
|
||||
// This ensures that if a new IDE is added to the enum, we get a compile-time error.
|
||||
const exhaustiveCheck: never = ide;
|
||||
@@ -46,19 +66,25 @@ export function detectIde(): DetectedIde | undefined {
|
||||
if (process.env.TERM_PROGRAM !== 'vscode') {
|
||||
return undefined;
|
||||
}
|
||||
if (process.env.__COG_BASHRC_SOURCED) {
|
||||
return DetectedIde.Devin;
|
||||
}
|
||||
if (process.env.REPLIT_USER) {
|
||||
return DetectedIde.Replit;
|
||||
}
|
||||
if (process.env.CURSOR_TRACE_ID) {
|
||||
return DetectedIde.Cursor;
|
||||
}
|
||||
if (process.env.CODESPACES) {
|
||||
return DetectedIde.Codespaces;
|
||||
}
|
||||
if (process.env.EDITOR_IN_CLOUD_SHELL) {
|
||||
if (process.env.EDITOR_IN_CLOUD_SHELL || process.env.CLOUD_SHELL) {
|
||||
return DetectedIde.CloudShell;
|
||||
}
|
||||
if (process.env.TERM_PRODUCT === 'Trae') {
|
||||
return DetectedIde.Trae;
|
||||
}
|
||||
if (process.env.FIREBASE_DEPLOY_AGENT) {
|
||||
if (process.env.FIREBASE_DEPLOY_AGENT || process.env.MONOSPACE_ENV) {
|
||||
return DetectedIde.FirebaseStudio;
|
||||
}
|
||||
return DetectedIde.VSCode;
|
||||
|
||||
@@ -6,11 +6,7 @@
|
||||
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import {
|
||||
detectIde,
|
||||
DetectedIde,
|
||||
getIdeDisplayName,
|
||||
} from '../ide/detect-ide.js';
|
||||
import { detectIde, DetectedIde, getIdeInfo } from '../ide/detect-ide.js';
|
||||
import {
|
||||
ideContext,
|
||||
IdeContextNotificationSchema,
|
||||
@@ -68,7 +64,7 @@ export class IdeClient {
|
||||
private constructor() {
|
||||
this.currentIde = detectIde();
|
||||
if (this.currentIde) {
|
||||
this.currentIdeDisplayName = getIdeDisplayName(this.currentIde);
|
||||
this.currentIdeDisplayName = getIdeInfo(this.currentIde).displayName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +82,7 @@ export class IdeClient {
|
||||
`IDE integration is not supported in your current environment. To use this feature, run Qwen Code in one of these supported IDEs: ${Object.values(
|
||||
DetectedIde,
|
||||
)
|
||||
.map((ide) => getIdeDisplayName(ide))
|
||||
.map((ide) => getIdeInfo(ide).displayName)
|
||||
.join(', ')}`,
|
||||
false,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user