drahil / socraites
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/drahil/socraites
Requires
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- nikic/php-parser: ^5.4
- symfony/console: ^7.2
- symfony/process: ^7.2
Requires (Dev)
- pestphp/pest: ^3.8
- phpstan/phpstan: ^2.1
This package is auto-updated.
Last update: 2025-12-25 10:50:48 UTC
README
An intelligent Laravel-specific CLI tool that performs AI-assisted code reviews by analyzing your staged Git changes and their surrounding code context.
โ ๏ธ For development environments only
๐ฆ PostgreSQL is required
๐งฑ Laravel-only support
โจ Features
๐ง AI-Powered Reviews: Get actionable, context-aware code feedback using OpenAI
๐ ๏ธ Built for Laravel: Tailored to Laravel conventions and structure
๐ Function-Level Chunking: Your codebase is automatically broken down and vectorized by method/function
๐ Persistent Vector Context: Code context is stored in PostgreSQL for efficient retrieval
โ๏ธ Fully Configurable: Customize OpenAI model, temperature, max context size, etc.
โ
Simple Artisan Workflow: Setup and review your codebase with familiar Artisan commands
๐ฆ Installation
Install the package in development only:
composer require --dev drahil/socraites
Publish the config and migration files:
php artisan vendor:publish --provider="drahil\Socraites\Providers\SocraitesServiceProvider"
Run the migration to create the code_chunks table (PostgreSQL only):
php artisan migrate
๐ Usage
-
Setup Socraites
This interactive command configures your environment and generates .socraites.json:
php artisan socraites:setup
It collects and stores:
{ "maximum_context_size": 10000, "ignore_patterns": ["tests/", "vendor/"], "extensions": [".php"], "openai_model": "gpt-4", "openai_temperature": 0.2, "question_prompt": "Perform a detailed code review" } -
Vectorize Your Codebase
This command chunks your codebase by functions/methods and stores vectors in the
code_chunkstable:php artisan socraites:vectorize
-
Perform Code Review
After staging your changes via git add, run the review: Analyze your staged changes and surrounding context:
php artisan socraites:code-review
๐งพ Example Output
Analyzing your code... "Wisdom begins in wonder." - Socrates SOCRAITES CODE REVIEW โ Overall Summary: โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ The changes in 'src/Entity/User.php' aim to define a new User class that implements the UserInterface from Symfony's Security component. However, the methods required by the interface are declared but not implemented, which will lead to issues during runtime if the class is used. โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐ Files from context: โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ src/Entity/User.php โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐ Reviewing: src/Entity/User.php โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ Summary: Implementation of the User class which implements the UserInterface from Symfony Security. โ Major Issues: Unimplemented methods required by the UserInterface. โ ๏ธ Minor Issues: Missing newline at end of file. ๐ก Suggestions: Implement the methods 'getRoles', 'eraseCredentials', and 'getUserIdentifier' to fulfill the contract of the UserInterface. Add a newline at the end of the file to follow good coding standards. โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐ฌ Suggested Commit Message: โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Add User class skeleton implementing UserInterface โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Do you have a question about the code review? [no]: >
After the code review output, Socraites offers an optional interactive prompt.
You can type a custom question (e.g., "Why is this considered a major issue?" or "How can I improve this method further?"), and Socraites will generate a detailed AI response based on the review context.
๐ฆ PHP Dependencies
(Automatically installed via Composer)
PHP^8.0nikic/php-parser^5.4 (Code analysis)symfony/console^7.2 (CLI interface)symfony/process^7.2 (Git command execution)guzzlehttp/guzzle^7.0 (OpenAI API communication)
๐ License
Socraites is open-sourced software licensed under the MIT license.