Skip to content

Commit eefb18b

Browse files
authored
Consoldate cursor cli (#4)
* Consolidate Cursor and Cursor CLI * Fix Test
1 parent 4ed7817 commit eefb18b

7 files changed

Lines changed: 7 additions & 39 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ $result = detectAgent();
5050
| Agent | Detection Method |
5151
|-------|-----------------|
5252
| Custom | `AI_AGENT` env var |
53-
| Cursor | `CURSOR_TRACE_ID` env var |
54-
| Cursor CLI | `CURSOR_AGENT` env var |
53+
| Cursor | `CURSOR_AGENT` env var |
5554
| Gemini | `GEMINI_CLI` env var |
5655
| Codex | `CODEX_SANDBOX` or `CODEX_THREAD_ID` env var |
5756
| Augment CLI | `AUGMENT_AGENT` env var |

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
},
2424
"require-dev": {
2525
"laravel/pint": "^1.24.0",
26-
"peckphp/peck": "^0.1.3",
2726
"pestphp/pest": "^3.8.5|^4.1.0",
2827
"pestphp/pest-plugin-type-coverage": "^3.0|^4.0.2",
2928
"phpstan/phpstan": "^2.1.26",
@@ -59,15 +58,13 @@
5958
"lint": "pint",
6059
"refactor": "rector",
6160
"test:type-coverage": "pest --type-coverage --exactly=100",
62-
"test:typos": "peck",
6361
"test:lint": "pint --test",
6462
"test:unit": "pest --coverage --exactly=100",
6563
"test:types": "phpstan",
6664
"test:refactor": "rector --dry-run",
6765
"test": [
6866
"@test:lint",
6967
"@test:type-coverage",
70-
"@test:typos",
7168
"@test:unit",
7269
"@test:types",
7370
"@test:refactor"

peck.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

rector.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
76

87
return RectorConfig::configure()
98
->withPaths([
109
__DIR__.'/src',
1110
__DIR__.'/tests',
1211
])
13-
->withSkip([
14-
AddOverrideAttributeToOverriddenMethodsRector::class,
15-
])
1612
->withPreparedSets(
1713
deadCode: true,
1814
codeQuality: true,
1915
typeDeclarations: true,
2016
privatization: true,
2117
earlyReturn: true,
22-
strictBooleans: true,
2318
)
2419
->withPhpSets();

src/AgentDetector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public static function detect(): AgentResult
1515
}
1616

1717
$agentsWithEnvVars = [
18-
'cursor' => ['CURSOR_TRACE_ID'],
19-
'cursor-cli' => ['CURSOR_AGENT'],
18+
'cursor' => ['CURSOR_AGENT'],
2019
'gemini' => ['GEMINI_CLI'],
2120
'codex' => ['CODEX_SANDBOX', 'CODEX_THREAD_ID'],
2221
'augment-cli' => ['AUGMENT_AGENT'],

src/KnownAgent.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
enum KnownAgent: string
88
{
99
case Cursor = 'cursor';
10-
case CursorCli = 'cursor-cli';
1110
case Claude = 'claude';
1211
case Devin = 'devin';
1312
case Replit = 'replit';

tests/AgentDetectorTest.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
beforeEach(function (): void {
1111
foreach ([
1212
'AI_AGENT',
13-
'CURSOR_TRACE_ID',
1413
'CURSOR_AGENT',
1514
'GEMINI_CLI',
1615
'CODEX_SANDBOX',
@@ -32,7 +31,6 @@
3231
afterEach(function (): void {
3332
foreach ([
3433
'AI_AGENT',
35-
'CURSOR_TRACE_ID',
3634
'CURSOR_AGENT',
3735
'GEMINI_CLI',
3836
'CODEX_SANDBOX',
@@ -70,8 +68,8 @@
7068
});
7169

7270
// Known agent env var detection
73-
it('detects cursor via CURSOR_TRACE_ID', function (): void {
74-
putenv('CURSOR_TRACE_ID=some-trace-id');
71+
it('detects cursor via CURSOR_AGENT', function (): void {
72+
putenv('CURSOR_AGENT=1');
7573

7674
$result = AgentDetector::detect();
7775

@@ -80,16 +78,6 @@
8078
->and($result->knownAgent())->toBe(KnownAgent::Cursor);
8179
});
8280

83-
it('detects cursor-cli via CURSOR_AGENT', function (): void {
84-
putenv('CURSOR_AGENT=true');
85-
86-
$result = AgentDetector::detect();
87-
88-
expect($result->isAgent)->toBeTrue()
89-
->and($result->name)->toBe('cursor-cli')
90-
->and($result->knownAgent())->toBe(KnownAgent::CursorCli);
91-
});
92-
9381
it('detects gemini via GEMINI_CLI', function (): void {
9482
putenv('GEMINI_CLI=true');
9583

@@ -235,7 +223,7 @@
235223

236224
$result = AgentDetector::detect();
237225

238-
expect($result->name)->toBe('cursor-cli');
226+
expect($result->name)->toBe('cursor');
239227
});
240228

241229
it('prioritizes CLAUDECODE over REPL_ID', function (): void {
@@ -295,8 +283,7 @@
295283

296284
expect($result->knownAgent())->toBe($expected);
297285
})->with([
298-
'cursor' => ['CURSOR_TRACE_ID', 'trace', KnownAgent::Cursor],
299-
'cursor-cli' => ['CURSOR_AGENT', 'true', KnownAgent::CursorCli],
286+
'cursor' => ['CURSOR_AGENT', '1', KnownAgent::Cursor],
300287
'gemini' => ['GEMINI_CLI', 'true', KnownAgent::Gemini],
301288
'codex' => ['CODEX_SANDBOX', 'true', KnownAgent::Codex],
302289
'augment-cli' => ['AUGMENT_AGENT', 'true', KnownAgent::AugmentCli],
@@ -316,7 +303,7 @@
316303

317304
// Standalone function
318305
it('works via standalone detectAgent function', function (): void {
319-
putenv('CURSOR_TRACE_ID=trace');
306+
putenv('CURSOR_AGENT=1');
320307

321308
$result = detectAgent();
322309

0 commit comments

Comments
 (0)