Skip to content

Commit

Permalink
Merge pull request #1 from bootstrapguru/fixes_composer_installable_bug
Browse files Browse the repository at this point in the history
Bug Fix: Package is not installable globally via composer
  • Loading branch information
vijaythecoder authored Jul 4, 2024
2 parents 791d81b + 80dd569 commit 01b8f76
Show file tree
Hide file tree
Showing 16 changed files with 3,903 additions and 3,899 deletions.
4 changes: 1 addition & 3 deletions app/Attributes/Description.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

namespace App\Attributes;


use Attribute;

#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PARAMETER)]
final class Description
{
public function __construct(
public string $value,
) {
}
) {}
}
7 changes: 4 additions & 3 deletions app/Commands/DroidCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
use App\Utils\OnBoardingSteps;
use Exception;
use Illuminate\Console\Command;
use function Termwind\{ask, render};

use function Termwind\ask;
use function Termwind\render;

class DroidCommand extends Command
{
Expand All @@ -21,7 +22,7 @@ class DroidCommand extends Command
public function handle(): int
{
$onBoardingSteps = new OnBoardingSteps();
if (!$onBoardingSteps->isCompleted()) {
if (! $onBoardingSteps->isCompleted()) {
return self::FAILURE;
}

Expand All @@ -39,7 +40,7 @@ public function handle(): int
break;
}

$chatAssistant->getAnswer($threadRun, $message);
$chatAssistant->getAnswer($threadRun, $message);
}

return self::SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace App\Providers;

use App\Utils\OnBoardingSteps;
use Dotenv\Dotenv;
use Exception;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @throws Exception
*/
public function boot(): void
Expand Down
9 changes: 4 additions & 5 deletions app/Services/ChatAssistant.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
use OpenAI;
use OpenAI\Client;
use OpenAI\Responses\Threads\Runs\ThreadRunResponse;

use function Laravel\Prompts\spin;
use function Termwind\render;

class ChatAssistant
{

use HasTools;

private Client $client;
Expand All @@ -40,7 +40,7 @@ public function __construct()

public function createAssistant()
{
return $this->client->assistants()->create([
return $this->client->assistants()->create([
'name' => 'Droid Dev',
'model' => config('droid.model'),
'description' => 'Droid Dev is a code generation assistant for Web applications',
Expand Down Expand Up @@ -98,7 +98,7 @@ public function loadAnswer(ThreadRunResponse $threadRun): string
'Fetching response...'
);

if ($threadRun->status === 'requires_action' && $threadRun->requiredAction->type === 'submit_tool_outputs') {
if ($threadRun->status === 'requires_action' && $threadRun->requiredAction->type === 'submit_tool_outputs') {
$requiredAction = $threadRun->requiredAction->toArray();
$toolCalls = $requiredAction['submit_tool_outputs']['tool_calls'];

Expand Down Expand Up @@ -128,7 +128,7 @@ public function loadAnswer(ThreadRunResponse $threadRun): string

public function retrieveThread($threadRun)
{
while(in_array($threadRun->status, ['queued', 'in_progress'])) {
while (in_array($threadRun->status, ['queued', 'in_progress'])) {
$threadRun = $this->client->threads()->runs()->retrieve(
threadId: $threadRun->threadId,
runId: $threadRun->id,
Expand All @@ -137,5 +137,4 @@ public function retrieveThread($threadRun)

return $threadRun;
}

}
12 changes: 6 additions & 6 deletions app/Services/FileTreeLister.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public function __construct()
$this->loadGitignore();
}

public function listTree(string $path = null): string
public function listTree(?string $path = null): string
{
$path = $path ?? Storage::path(DIRECTORY_SEPARATOR);

if (!File::exists($path) || !File::isDirectory($path)) {
if (! File::exists($path) || ! File::isDirectory($path)) {
return "The path {$path} does not exist or is not a directory.";
}

Expand Down Expand Up @@ -62,7 +62,7 @@ protected function listDirectoryContents(string $path, string $prefix = ''): str
$items = File::directories($path);
$files = File::files($path);
} catch (DirectoryNotFoundException $e) {
throw new DirectoryNotFoundException("Error: " . $e->getMessage());
throw new DirectoryNotFoundException('Error: '.$e->getMessage());
}

foreach ($items as $index => $directory) {
Expand All @@ -73,8 +73,8 @@ protected function listDirectoryContents(string $path, string $prefix = ''): str
continue;
}

$output .= $prefix . '├── ' . $directoryName . PHP_EOL;
$output .= $this->listDirectoryContents($directory, $prefix . ($index === array_key_last($items) && empty($files) ? ' ' : ''));
$output .= $prefix.'├── '.$directoryName.PHP_EOL;
$output .= $this->listDirectoryContents($directory, $prefix.($index === array_key_last($items) && empty($files) ? ' ' : ''));
}

foreach ($files as $file) {
Expand All @@ -85,7 +85,7 @@ protected function listDirectoryContents(string $path, string $prefix = ''): str
continue;
}

$output .= $prefix . '├── ' . $fileName . PHP_EOL;
$output .= $prefix.'├── '.$fileName.PHP_EOL;
}

return $output;
Expand Down
7 changes: 4 additions & 3 deletions app/Tools/ListFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
use App\Attributes\Description;
use App\Services\FileTreeLister;
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;

use function Termwind\render;

#[Description('List all files and sub directories in the specified path. Use this when you need to list all files and directories.')]
final class ListFiles {

final class ListFiles
{
public function handle(
#[Description('directory name to list files from. Default is the base path.')]
string $path,
Expand All @@ -19,7 +20,7 @@ public function handle(
$fileTreeLister = new FileTreeLister();
$list = $fileTreeLister->listTree($path);
render(view('tool', [
'name' => 'ListFiles from ' . $path,
'name' => 'ListFiles from '.$path,
'output' => $list,
]));

Expand Down
7 changes: 4 additions & 3 deletions app/Tools/ReadFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Attributes\Description;
use Illuminate\Support\Facades\Storage;

use function Termwind\render;

#[Description('Read content from an existing file at the specified path. Use this when you need to read content from a file.')]
final class ReadFile {

final class ReadFile
{
public function handle(
#[Description('Absolute File path to read content from')]
string $file_path,
Expand All @@ -24,6 +25,7 @@ public function handle(
'name' => 'ReadFile',
'output' => $file_path,
]));

return Storage::get($file_path);
}

Expand All @@ -35,5 +37,4 @@ public function handle(

return $output;
}

}
10 changes: 5 additions & 5 deletions app/Tools/UpdateFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Attributes\Description;
use Illuminate\Support\Facades\Storage;

use function Termwind\render;

#[Description('Update the content of an existing file at the specified path. Use this when you need to update the existing of a file after write_to_file returns a suggestion to merge the content.')]
final class UpdateFile {

final class UpdateFile
{
public function handle(
#[Description('File path to write content to')]
string $file_path,
Expand All @@ -25,10 +26,10 @@ public function handle(
$directory = dirname($file_path);

// Ensure the directory exists
if (!Storage::exists($directory)) {
if (! Storage::exists($directory)) {
render(view('tool', [
'name' => 'WriteToFile',
'output' => 'Directory not found. Creating '. $directory,
'output' => 'Directory not found. Creating '.$directory,
]));
Storage::makeDirectory($directory, 0755, true);
}
Expand All @@ -43,5 +44,4 @@ public function handle(

return $output;
}

}
11 changes: 6 additions & 5 deletions app/Tools/WriteToFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use App\Attributes\Description;
use Illuminate\Support\Facades\Storage;

use function Termwind\render;

#[Description('Write content to an existing file at the specified path. Use this when you need to write content to a file.')]
final class WriteToFile {

final class WriteToFile
{
public function handle(
#[Description('Relative File path to write content to')]
string $file_path,
Expand All @@ -30,14 +31,15 @@ public function handle(
'name' => 'WriteToFile',
'output' => 'The file already exists in the path, attempting to merge....',
]));

// Append the new content to the file
return 'The file already exists in the path, Make sure to merge your suggestion with the existing file without any breaking changes. Once, they are merged, call the update_file function. The current contents of the file are '. $fileContent;
return 'The file already exists in the path, Make sure to merge your suggestion with the existing file without any breaking changes. Once, they are merged, call the update_file function. The current contents of the file are '.$fileContent;
}

$directory = dirname($file_path);

// Ensure the directory exists
if (!Storage::exists($directory)) {
if (! Storage::exists($directory)) {
Storage::makeDirectory($directory, 0755, true);
}

Expand All @@ -51,5 +53,4 @@ public function handle(

return $output;
}

}
Loading

0 comments on commit 01b8f76

Please sign in to comment.