Automate the application of best practices to your git repositories
SLIM CLI is a command-line tool designed to infuse SLIM best practices seamlessly with your development workflow. It fetches and applies structured SLIM best practices directly into your Git repositories. The tool leverages artificial intelligence capabilities to customize and tailor the application of SLIM best practices based on your repository's specifics.
Website | Docs/Wiki | Discussion Board | Issue Tracker
- Command-line interface for applying SLIM best practices into Git development workflows.
- Fetches the latest SLIM best practices dynamically from SLIM's registry.
- Allows customization of best practices using advanced AI models before applying them to repositories.
- Deploys, or git adds, commits, and pushes changes to your repository's remote.
- Features
- Contents
- Quick Start
- Changelog
- Frequently Asked Questions (FAQ)
- Contributing
- License
- Support
This guide provides a quick way to get started with our project. Please see our docs for a more comprehensive overview.
- Python 3.7+
- Git
.env
file to properly configure the environment for Azure and OpenAI APIs# .env for Azure AZURE_TENANT_ID=<Your-Azure-Tenant-ID> AZURE_CLIENT_ID=<Your-Azure-Client-ID> AZURE_CLIENT_SECRET=<Your-Azure-Client-Secret> API_ENDPOINT=<Your-Azure-OpenAI-API-Endpoint> API_VERSION=<Azure-OpenAI-API-Version> APIM_SUBSCRIPTION_KEY=<Your-Azure-Subscription-Key>
# .env for OpenAI OPENAI_API_KEY=<Your-OpenAI-API-Key>
As the SLIM CLI is written in Python, you'll need Python 3.7 or later. Usually, you'll want to create a virtual environment in order to isolate the dependencies of SLIM from other Python-using applications. Install into that environment using pip
:
pip install slim-cli
This installs the latest SLIM CLI and its dependencies from the Python Package Index. The new console script slim
is now ready for use. Confirm by running either:
slim --version
slim --help
To upgrade:
pip install --upgrade slim-cli
Or select a specific version, such as X.Y.Z
:
pip install slim-cli==X.Y.Z
This section provides detailed commands to interact with the SLIM CLI. Each command includes various options that you can specify to tailor the tool's behavior to your needs.
-
List all available best practices
- This command lists all best practices fetched from the SLIM registry.
slim list
-
Apply best practices to repositories
- This command applies specified best practices to one or more repositories. It supports applying multiple practices simultaneously across multiple repositories, with AI customization options available.
--best-practice-ids
: List of best practice IDs to apply.--repo-urls
: List of repository URLs to apply the best practices to; not used if--repo-dir
is specified.--repo-dir
: Local directory path of the repository where the best practices will be applied.--clone-to-dir
: Path where the repository should be cloned if not present locally. Compatible with--repo-urls
.--use-ai
: Enables AI features to customize the application of best practices based on the project’s specific needs. Specify the model provider and model name as an argument (e.g.,azure/gpt-4o
).
slim apply --best-practice-ids SLIM-123 SLIM-456 --repo-urls https://github.com/your-username/your-repo1 https://github.com/your-username/your-repo2
- To apply a best practice using AI customization:
# Apply a specific best practice using AI customization slim apply --best-practice-ids SLIM-123 --repo-urls https://github.com/your_org/your_repo.git --use-ai <model provider>/<model name>
Example usage:
# Apply and deploy a best practice using Azure's GPT-4o model slim apply --best-practice-ids SLIM-3.1 --repo-urls https://github.com/riverma/terraformly/ --use-ai azure/gpt-4o
# Apply and deploy a best practice using Ollama's LLaMA 3.1 model slim apply --best-practice-ids SLIM-3.1 --repo-urls https://github.com/riverma/terraformly/ --use-ai ollama/llama3.1:405b
-
Deploy a best practice
- After applying best practices, you may want to deploy (commit and push) them to a remote repository.
--best-practice-ids
: List of best practice IDs that have been applied and are ready for deployment.--repo-dir
: The local directory of the repository where changes will be committed and pushed.--remote-name
: Specifies the remote name in the git configuration to which the changes will be pushed.--commit-message
: A message describing the changes for the commit.
slim deploy --best-practice-ids SLIM-123 SLIM-456 --repo-dir /path/to/repo --remote-name origin --commit-message "Apply SLIM best practices"
-
Apply and deploy a best practice
- Combines the application and deployment of a best practice into one step.
--best-practice-ids
: List of best practice IDs to apply and then deploy.--repo-urls
: List of repository URLs for cloning if not already cloned; not used if--repo-dir
is specified.--repo-dir
: Specifies the directory of the repository where the best practice will be applied and changes committed.--remote-name
: Specifies the remote to which the changes will be pushed. Format should be a GitHub-like URL base. For examplehttps://github.com/my_github_user
--commit-message
: A message describing the changes for the commit.--use-ai
: If specified, enables AI customization of the best practice before applying. False by default.
slim apply-deploy --best-practice-ids SLIM-123 --repo-urls https://github.com/your-username/your-repo1 https://github.com/your-username/your-repo2 --remote-name origin --commit-message "Integrated SLIM best practice with AI customization"
Example output:
AI features disabled Applied best practice SLIM-123 and committed to branch slim-123 Pushed changes to remote origin on branch slim-123
Each command can be modified with additional flags as needed for more specific tasks or environments.
The SLIM CLI includes a website generator that can automatically create Docusaurus documentation from your repository content. This feature can analyze your codebase and generate comprehensive documentation including API references and installation guides.
Generate documentation for your repository using:
python -m jpl.slim.cli generate-docs \
--repo-dir /path/to/your/repo \
--output-dir /path/to/output
You can enable AI enhancement of the documentation using supported language models:
python -m jpl.slim.cli generate-docs \
--repo-dir /path/to/your/repo \
--output-dir /path/to/output \
--use-ai azure/gpt-4o
Example usage:
python -m jpl.slim.cli generate-docs --repo-dir ./hysds --output-dir ./hysds/outputs --use-ai azure/gpt-4o
The documentation generator creates the following sections:
- Overview: Project description, features, and key concepts (from README)
- Installation: Setup instructions and prerequisites
- API Reference: Auto-generated API documentation from source code
- Guides: User guides and tutorials
- Contributing: Contributing guidelines
- Changelog: Version history and recent changes
- Deployment: Deployment instructions and configurations
- Architecture: System architecture and design documentation
- Testing: Testing documentation and examples
- Security: Security considerations and guidelines
After generating the documentation, follow these steps to view it:
- Install Docusaurus if you haven't already:
npx create-docusaurus@latest my-docs classic
- Copy the generated files to your Docusaurus docs directory:
cp -r /path/to/output/* my-docs/docs/
- Start the Docusaurus development server:
cd my-docs
npm start
The slim CLI includes an AI-powered test generation feature that can automatically create unit tests for your codebase. This tool analyzes your source code and generates appropriate test files using testing frameworks for each supported language.
- Multi-Language Support: Generates tests for Python, JavaScript, TypeScript, Java, C++, and C#
- Framework-Specific: Uses appropriate testing frameworks for each language:
- Python: pytest
- JavaScript/TypeScript: Jest
- Java: JUnit
- C++: Google Test
- C#: NUnit
- Comprehensive Testing: Generates tests for normal operations, edge cases, and error scenarios
- Dependency Mocking: Includes appropriate mocking setup for external dependencies
Generate tests for an entire repository:
python -m jpl.slim.cli generate-tests --repo-dir ./my-project --output-dir ./my-project/tests
--repo-dir
(Required): Path to your repository directory--output-dir
(Optional): Custom output directory for generated tests--model
(Optional): AI model to use (default: "azure/gpt-4o")--verbose
,-v
(Optional): Enable detailed logging
Generated test files follow language-specific conventions:
Language | Test File Format | Example |
---|---|---|
Python | test_*.py |
test_utils.py |
JavaScript | *.test.js |
utils.test.js |
TypeScript | *.spec.ts |
utils.spec.ts |
Java | Test*.java |
TestUtils.java |
C++ | *_test.cpp |
utils_test.cpp |
C# | *Tests.cs |
UtilsTests.cs |
Tests are generated with:
- Appropriate imports and framework setup
- Test class/suite organization
- Setup and teardown methods when needed
- Comprehensive test cases covering:
- Normal operation
- Edge cases
- Error handling
- External dependency mocking
The CLI can be run using Python's module syntax.
python -m jpl.slim.cli [options]
- Apply deployment best practices:
python -m jpl.slim.cli apply-deploy \
--best-practice-ids SLIM-3.1 \
--repo-urls https://github.com/yunks128/maap-py \
--use-ai azure/gpt-4o
See our CHANGELOG.md for a history of our changes.
See our releases page for our key versioned releases.
Questions about our project? Please see our: FAQ
Interested in contributing to our project? Please see our: CONTRIBUTING.md
For guidance on how to interact with our team, please see our code of conduct located at: CODE_OF_CONDUCT.md
For guidance on our governance approach, including decision-making process and our various roles, please see our governance model at: GOVERNANCE.md
For local development of SLIM CLI, clone the GitHub repository, create a virtual environment, and then install the package in editable mode into it:
git clone --quiet https://github.com/NASA-AMMOS/slim-cli.git
cd slim-cli
python3 -m venv .venv
source .venv/bin/activate
pip install --editable .
The slim
console-script is now ready in editable mode; changes you make to the source files under src
are immediately reflected when run.
We use pytest
for testing. The test files are located within the tests
subdirectory. To run the tests, ensure you are in the root directory of the project (where the pyproject.toml
or setup.py
is located) and have pytest
installed. You can install pytest
via pip:
pip install pytest
To execute all tests, simply run:
pytest
If you want to run a specific test file, you can specify the path to the test file:
pytest tests/jpl/slim/test_cli.py
This will run all the tests in the specified file. You can also use pytest
options like -v
for verbose output or -s
to see print statements in the output:
pytest -v -s
To publish a new version of SLIM CLI to the Python Package Index, typically you'll update the VERSION.txt
file; then do:
pip install build wheel twine
python3 -m build .
twine upload dist/*
(Note: this can and should eventually be automated with GitHub Actions.)
See our: LICENSE