Skip to content

Commit e70eeda

Browse files
committed
refactor(Generators): simplify code for generating prompt file
- Use a single line for file_put_contents call - Remove unnecessary variable assignment - Refactor mustRun callback to handle both stdout and stderr
1 parent b521fa9 commit e70eeda

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

app/Generators/BitoGenerator.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,11 @@ public function __construct(array $config)
4242
*/
4343
public function generate(string $prompt): string
4444
{
45-
file_put_contents(
46-
$promptFile = ConfigManager::globalPath($this->config['prompt_filename']),
47-
$prompt
48-
);
49-
50-
return resolve(
51-
Process::class,
52-
['command' => ['bito', '-p', $promptFile]] + $this->config['parameters']
53-
)
54-
->mustRun(function ($type, $data): void {
55-
$this->output->write($data);
45+
file_put_contents($promptFile = ConfigManager::globalPath($this->config['prompt_filename']), $prompt);
46+
47+
return resolve(Process::class, ['command' => ['bito', '-p', $promptFile]] + $this->config['parameters'])
48+
->mustRun(function (string $type, string $data): void {
49+
Process::OUT === $type ? $this->output->write($data) : $this->output->write("<fg=red>$data</>");
5650
})
5751
->getOutput();
5852
}

config/ai-commit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
'http_options' => [
3131
GuzzleHttp\RequestOptions::VERIFY => false,
3232
GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 30,
33-
GuzzleHttp\RequestOptions::TIMEOUT => 180,
33+
GuzzleHttp\RequestOptions::TIMEOUT => 120,
3434
],
3535

3636
// The options of retry.
@@ -106,7 +106,7 @@
106106
'cwd' => null,
107107
'env' => null,
108108
'input' => null,
109-
'timeout' => 60,
109+
'timeout' => 120,
110110
],
111111
],
112112
],

0 commit comments

Comments
 (0)