diff --git a/src/commands/exec.ts b/src/commands/exec.ts index 823fc3a..92bf5ed 100644 --- a/src/commands/exec.ts +++ b/src/commands/exec.ts @@ -19,6 +19,11 @@ const envConfigs: [string, string][] = [ ['__CFBundleIdentifier=dev.kiro.desktop', 'Kiro '], ['VSCODE_BRAND=Qoder', 'Qoder '], ['__CFBundleIdentifier=com.qoder.ide', 'Qoder '], // Use this unstable variable until Qoder has a better one + // Check env variables for IDEs in remove development environments + ['VSCODE_GIT_ASKPASS_MAIN=*.cursor-server*', 'Cursor '], + ['BROWSER=*.cursor-server*', 'Cursor '], + ['VSCODE_GIT_ASKPASS_MAIN=*.qoder-server*', 'Qoder '], + ['BROWSER=*.qoder-server*', 'Qoder '], ]; /** @@ -302,6 +307,21 @@ function getCoDevelopedBy(): string { // Continue to next configuration if value is falsy continue; } + + // For pattern matching cases (starts and ends with *, e.g., "*.cursor-server*") + if ( + expectedValue && + expectedValue.startsWith('*') && + expectedValue.endsWith('*') && + expectedValue.length > 2 + ) { + // Extract the pattern between the asterisks + const pattern = expectedValue.substring(1, expectedValue.length - 1); + if (actualValue.includes(pattern)) { + return coDevelopedBy; + } + continue; + } } // Return empty string if none of the environment configurations match diff --git a/test/commands/exec.test.ts b/test/commands/exec.test.ts index a51071a..f95db78 100644 --- a/test/commands/exec.test.ts +++ b/test/commands/exec.test.ts @@ -737,6 +737,33 @@ describe('exec command utilities', () => { process.env.CLAUDECODE = ''; expect(getCoDevelopedBy()).toBe(''); }); + + // Enhanced tests for Cursor and Qoder detection + it('should return Cursor CoDevelopedBy when VSCODE_GIT_ASKPASS_MAIN contains .cursor-server', () => { + clearCoDevelopedByEnvVars(); + process.env.VSCODE_GIT_ASKPASS_MAIN = + '/home/user/.cursor-server/bin/askpass-main.js'; + expect(getCoDevelopedBy()).toBe('Cursor '); + }); + + it('should return Cursor CoDevelopedBy when BROWSER contains .cursor-server', () => { + clearCoDevelopedByEnvVars(); + process.env.BROWSER = '/home/user/.cursor-server/bin/helpers/browser.sh'; + expect(getCoDevelopedBy()).toBe('Cursor '); + }); + + it('should return Qoder CoDevelopedBy when VSCODE_GIT_ASKPASS_MAIN contains .qoder-server', () => { + clearCoDevelopedByEnvVars(); + process.env.VSCODE_GIT_ASKPASS_MAIN = + '/home/user/.qoder-server/bin/askpass-main.js'; + expect(getCoDevelopedBy()).toBe('Qoder '); + }); + + it('should return Qoder CoDevelopedBy when BROWSER contains .qoder-server', () => { + clearCoDevelopedByEnvVars(); + process.env.BROWSER = '/home/user/.qoder-server/bin/helpers/browser.sh'; + expect(getCoDevelopedBy()).toBe('Qoder '); + }); }); describe('hasCoDevelopedBy', () => {