承接 drahil/socraites 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drahil/socraites

最新稳定版本:v0.1.0

Composer 安装命令:

composer require drahil/socraites

包简介

README 文档

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.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-03