Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit 7014b7d

Browse files
committed
create branch name based on Linear suggestion
1 parent 7a6fb90 commit 7014b7d

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

src/Commands/CodyLinearCommand.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,45 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Support\Facades\Artisan;
7+
use Codinglabs\Cody\Concerns\RunsCodyCommands;
78

89
class CodyLinearCommand extends Command
910
{
10-
// use RunsCodyCommands;
11+
use RunsCodyCommands;
1112

1213
protected $signature = 'cody:linear {issueId}';
1314

1415
protected $description = 'Complete a Linear issue';
1516

1617
public function handle(): void
1718
{
18-
$issueId = $this->argument('issueID');
19+
$issueId = $this->argument('issueId');
20+
21+
$response = $this->executeAgentPrompt(
22+
prompt: <<<PROMPT
23+
Retrieve issue $issueId on Linear.
24+
25+
If the issue does not exist, return nothing.
26+
27+
The response should be in JSON format:
28+
29+
{
30+
"id": "issue ID",
31+
"branchName": "the branchName attribute on the issue"
32+
}
33+
PROMPT,
34+
message: 'Retrieving Linear issue details...',
35+
);
36+
37+
if (! is_array($response) || empty($response['branchName'])) {
38+
$this->error('Invalid response from AI agent.');
39+
40+
return;
41+
}
1942

2043
Artisan::call(CodyCommand::class, [
21-
'branch' => $issueId, // todo: first fetch and validate the issue, then retrieve the Linear-generated branch name
44+
'branch' => $response['branchName'],
2245
'--prompt' => "resolve Linear issue $issueId",
23-
]);
46+
], $this->output);
2447
}
2548
}

src/Concerns/RunsCodyCommands.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Illuminate\Support\Arr;
77
use Illuminate\Support\Str;
88
use Illuminate\Support\Facades\Process;
9-
109
use function Laravel\Prompts\spin;
1110

1211
trait RunsCodyCommands
@@ -71,7 +70,7 @@ protected function executeCommands(array $commands, ?string $path = null, array
7170

7271
protected function branchName(?string $branchName = null): string
7372
{
74-
return sprintf('cody/%s', $branchName ?? $this->argument('branch'));
73+
return $branchName ?? $this->argument('branch');
7574
}
7675

7776
protected function appDirectoryName(): string
@@ -81,7 +80,7 @@ protected function appDirectoryName(): string
8180

8281
protected function worktreeDirectory(?string $branchName = null): string
8382
{
84-
$branchName = $branchName ?? $this->argument('branch');
83+
$branchName = Str::replace('/', '-', ($branchName ?? $this->argument('branch')));
8584

8685
return base_path(sprintf("../%s-$branchName", $this->appDirectoryName()));
8786
}

0 commit comments

Comments
 (0)