drahil/socraites

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/drahil/socraites

v0.1.0 2025-09-25 10:14 UTC

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

  1. 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"
    }
  2. Vectorize Your Codebase

    This command chunks your codebase by functions/methods and stores vectors in the code_chunks table:

    php artisan socraites:vectorize
  3. 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.0
  • nikic/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.