# Code Guardian
**Generate tests with swarms of agents**
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)
**CodeGuardian** is an intelligent agent designed to automate the generation of production-grade unit tests for your Python code. It not only creates and runs these tests but also monitors them in real-time, providing you with comprehensive summaries of your code health. With CodeGuardian, you can enhance code reliability, maintainability, and accelerate your development workflow.
## Features
- **Automated Test Generation**: Automatically generate unit tests for your existing Python codebase.
- **Test Execution**: Run generated tests seamlessly and view results instantly.
- **Real-Time Monitoring**: Watch tests in real-time to observe code behavior and performance.
- **Code Health Summaries**: Receive detailed reports on test coverage, code quality, and potential issues.
- **Easy Integration**: Integrate effortlessly with existing projects and CI/CD pipelines.
- **Customizable Configurations**: Tailor settings to match your project requirements.
### Prerequisites
- **Python 3.7** or higher
- **pip** package manager
## Installation
```bash
pip3 install -U code-guardian
```
## Example
```python
import os
from dotenv import load_dotenv
from swarms import Agent, OpenAIChat
from code_guardian.main import CodeGuardian
load_dotenv()
# Get the OpenAI API key from the environment variable
api_key = os.getenv("OPENAI_API_KEY")
# Create an instance of the OpenAIChat class
model = OpenAIChat(
openai_api_key=api_key,
model_name="gpt-4o-mini",
temperature=0.1,
max_tokens=2000,
)
# Initialize the agent for generating unit tests
agent = Agent(
agent_name="Unit-Test-Generator-Agent", # Changed agent name
system_prompt="Generate unit tests for the provided classes using pytest.", # Updated system prompt
llm=model,
max_loops=1,
autosave=True,
dashboard=False,
verbose=True,
dynamic_temperature_enabled=True,
saved_state_path="unit_test_agent.json", # Updated saved state path
user_name="swarms_corp",
retry_attempts=1,
context_length=200000,
return_step_meta=False,
# output_type="json",
)
# Classes you want to generate tests for
classes_to_test = [CodeGuardian]
# Initialize CodeGuardian and run
guardian = CodeGuardian(
classes=classes_to_test, # classes to test
agent=agent, # agent to use
dir_path="tests", # directory to save tests
package_name="code-guardian", # package name
module_name="code_guardian.main", # module name
)
guardian.run()
```
### Configuration Options
- **test_directory**: Directory where tests are stored.
- **source_directory**: Directory containing your source code.
- **exclude_patterns**: Files or directories to exclude.
- **report_format**: Format of the code health report (`html`, `json`, `xml`).
- **watch**: Settings for real-time monitoring.
## Roadmap
- **Multi-language Support**: Extend functionality to other programming languages.
- **Advanced Static Analysis**: Integrate deeper code analysis tools.
- **IDE Plugins**: Develop plugins for popular IDEs like VSCode and PyCharm.
- **Enhanced Reporting**: Add more detailed metrics and visualizations.
## Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on how to get started.
## License
CodeGuardian is licensed under the [MIT License](LICENSE).
## Acknowledgements
- Inspired by the need for robust automated testing tools.
- Thanks to the open-source community for their invaluable contributions.
Raw data
{
"_id": null,
"home_page": "https://github.com/The-Swarm-Corporation/CodeGuardian",
"name": "code-guardian",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "artificial intelligence, deep learning, optimizers, Prompt Engineering",
"author": "Kye Gomez",
"author_email": "kye@apac.ai",
"download_url": "https://files.pythonhosted.org/packages/1d/4e/c3276ad884702862c47ea200cce13e199231ecb9a1d3ef8a1dad9072eee8/code_guardian-0.1.4.tar.gz",
"platform": null,
"description": "\n# Code Guardian\n\n**Generate tests with swarms of agents**\n\n[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)\n\n\n**CodeGuardian** is an intelligent agent designed to automate the generation of production-grade unit tests for your Python code. It not only creates and runs these tests but also monitors them in real-time, providing you with comprehensive summaries of your code health. With CodeGuardian, you can enhance code reliability, maintainability, and accelerate your development workflow.\n\n## Features\n\n- **Automated Test Generation**: Automatically generate unit tests for your existing Python codebase.\n- **Test Execution**: Run generated tests seamlessly and view results instantly.\n- **Real-Time Monitoring**: Watch tests in real-time to observe code behavior and performance.\n- **Code Health Summaries**: Receive detailed reports on test coverage, code quality, and potential issues.\n- **Easy Integration**: Integrate effortlessly with existing projects and CI/CD pipelines.\n- **Customizable Configurations**: Tailor settings to match your project requirements.\n\n\n### Prerequisites\n\n- **Python 3.7** or higher\n- **pip** package manager\n\n\n## Installation\n```bash\npip3 install -U code-guardian\n```\n\n## Example\n\n```python\nimport os\n\nfrom dotenv import load_dotenv\nfrom swarms import Agent, OpenAIChat\n\nfrom code_guardian.main import CodeGuardian\n\nload_dotenv()\n\n# Get the OpenAI API key from the environment variable\napi_key = os.getenv(\"OPENAI_API_KEY\")\n\n# Create an instance of the OpenAIChat class\nmodel = OpenAIChat(\n openai_api_key=api_key,\n model_name=\"gpt-4o-mini\",\n temperature=0.1,\n max_tokens=2000,\n)\n\n# Initialize the agent for generating unit tests\nagent = Agent(\n agent_name=\"Unit-Test-Generator-Agent\", # Changed agent name\n system_prompt=\"Generate unit tests for the provided classes using pytest.\", # Updated system prompt\n llm=model,\n max_loops=1,\n autosave=True,\n dashboard=False,\n verbose=True,\n dynamic_temperature_enabled=True,\n saved_state_path=\"unit_test_agent.json\", # Updated saved state path\n user_name=\"swarms_corp\",\n retry_attempts=1,\n context_length=200000,\n return_step_meta=False,\n # output_type=\"json\",\n)\n\n# Classes you want to generate tests for\nclasses_to_test = [CodeGuardian]\n\n# Initialize CodeGuardian and run\nguardian = CodeGuardian(\n classes=classes_to_test, # classes to test\n agent=agent, # agent to use\n dir_path=\"tests\", # directory to save tests\n package_name=\"code-guardian\", # package name\n module_name=\"code_guardian.main\", # module name\n)\nguardian.run()\n```\n\n\n### Configuration Options\n\n- **test_directory**: Directory where tests are stored.\n- **source_directory**: Directory containing your source code.\n- **exclude_patterns**: Files or directories to exclude.\n- **report_format**: Format of the code health report (`html`, `json`, `xml`).\n- **watch**: Settings for real-time monitoring.\n\n\n## Roadmap\n\n- **Multi-language Support**: Extend functionality to other programming languages.\n- **Advanced Static Analysis**: Integrate deeper code analysis tools.\n- **IDE Plugins**: Develop plugins for popular IDEs like VSCode and PyCharm.\n- **Enhanced Reporting**: Add more detailed metrics and visualizations.\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on how to get started.\n\n## License\n\nCodeGuardian is licensed under the [MIT License](LICENSE).\n\n## Acknowledgements\n\n- Inspired by the need for robust automated testing tools.\n- Thanks to the open-source community for their invaluable contributions.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Code-Guardian by TGSC",
"version": "0.1.4",
"project_urls": {
"Documentation": "https://github.com/The-Swarm-Corporation/CodeGuardian",
"Homepage": "https://github.com/The-Swarm-Corporation/CodeGuardian",
"Repository": "https://github.com/The-Swarm-Corporation/CodeGuardian"
},
"split_keywords": [
"artificial intelligence",
" deep learning",
" optimizers",
" prompt engineering"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "86edf05a2d8ce462167112f51d31f2d4f0c87891c33d7eec4be7c51fb9e3d50f",
"md5": "b5e496a0b3422feeec80576ddd83508f",
"sha256": "dad3a855725d528a9c9e1a80d651de84954b18d62b566bfcc51d7b0cafe1d33d"
},
"downloads": -1,
"filename": "code_guardian-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b5e496a0b3422feeec80576ddd83508f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 9272,
"upload_time": "2024-09-17T01:37:56",
"upload_time_iso_8601": "2024-09-17T01:37:56.857650Z",
"url": "https://files.pythonhosted.org/packages/86/ed/f05a2d8ce462167112f51d31f2d4f0c87891c33d7eec4be7c51fb9e3d50f/code_guardian-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1d4ec3276ad884702862c47ea200cce13e199231ecb9a1d3ef8a1dad9072eee8",
"md5": "5dffbbf98629e95d6688b13dc433ad98",
"sha256": "2f31f48a891bfe37d40a30e30303b34e91fa796a10dc6dd0563f3eb696513755"
},
"downloads": -1,
"filename": "code_guardian-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "5dffbbf98629e95d6688b13dc433ad98",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 8651,
"upload_time": "2024-09-17T01:37:58",
"upload_time_iso_8601": "2024-09-17T01:37:58.140562Z",
"url": "https://files.pythonhosted.org/packages/1d/4e/c3276ad884702862c47ea200cce13e199231ecb9a1d3ef8a1dad9072eee8/code_guardian-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-17 01:37:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "The-Swarm-Corporation",
"github_project": "CodeGuardian",
"github_not_found": true,
"lcname": "code-guardian"
}