Download the PHP package md/phpspec-intelligence-extension without Composer
On this page you can find all versions of the php package md/phpspec-intelligence-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download md/phpspec-intelligence-extension
More information about md/phpspec-intelligence-extension
Files in md/phpspec-intelligence-extension
Package phpspec-intelligence-extension
Short Description A PhpSpec extension to get a AI suggestion about what to spec next
License MIT
Informations about the package phpspec-intelligence-extension
PhpSpec Intelligence Extension
The PhpSpec Intelligence Extension introduces a next
command to PhpSpec, leveraging OpenAI's GPT models to suggest the
next specification to implement in your test-driven development workflow.
Table of Contents
- Introduction
- Features
- Installation
- Configuration
- Usage
- Examples
- Contributing
- License
Introduction
Test-driven development (TDD) encourages writing tests before implementing code. However, deciding what to test next can sometimes be challenging. This extension integrates with OpenAI's API to analyze your existing specs and provide intelligent suggestions for the next spec to write, streamlining your TDD process.
Features
- Automated Spec Suggestions: Get suggestions for your next spec based on existing specifications.
- Seamless Integration: Adds a
next
command to PhpSpec without disrupting your workflow. - Configurable Parameters: Customize API settings like model, max tokens, and temperature.
Installation
Install the extension via Composer:
Configuration
To use the extension, you need to:
- Enable the Extension: Add it to your
phpspec.yml
configuration file. - Set the OpenAI API Key: Provide your OpenAI API key securely.
1. Enable the Extension
Update your phpspec.yml
file:
2. Set the OpenAI API Key
For security, it's recommended to use environment variables to store your API key.
Using Environment Variables
Set the OPENAI_API_KEY
environment variable in your shell or server configuration.
Alternative: Configuration File (Less Secure)
You can also set the API key in the phpspec.yml
file (not recommended for shared repositories):
Warning: Avoid committing API keys to version control.
Usage
After installation and configuration, you can use the next
command:
The command will analyze your existing specs and suggest the next one to implement.
Command Options
--config
: Specify a custom configuration file.--verbose
: Increase the verbosity of messages.
Example:
Examples
Basic Usage
Output:
Using a Custom Configuration File
Handling API Limits
If you encounter rate limits or quota issues, the command will display an appropriate error message. Ensure your OpenAI account has sufficient quota and consider implementing retry logic if needed.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Write specs for your changes.
- Submit a pull request with a detailed description.
Running Tests
License
This project is licensed under the MIT License. See the LICENSE file for details.
Note: This extension uses the OpenAI API, which may incur costs. Monitor your usage to avoid unexpected charges. Always handle API keys securely and follow best practices to protect sensitive information.