This package is an offshoot and integral part of the larger Kado project, which aims to streamline and enhance infrastructure operations through intelligent analysis and automation.
- Installation
- Configuration
- Usage
- Security Considerations
- Development
- Testing
- Continuous Integration and Deployment
- Contributing
- License
- Support
- Relationship to Kado
To use Kado AI in your Go project, run:
go get github.com/janpreet/kado-ai@latest
Ensure you're using Go 1.16 or later.
Kado AI requires a .kdconfig
file in the user's home directory. This file should contain the following configuration:
AI_API_KEY=your_api_key_here
AI_MODEL=your_model_here
AI_CLIENT=your_client_type_here
AI_API_KEY
: Your API key for the AI service (ChatGPT or Anthropic).AI_MODEL
: The AI model to use (e.g., "gpt-4" for ChatGPT or "claude-3-sonnet-20240229" for Anthropic).AI_CLIENT
: The AI client type ("chatgpt" or "anthropic_messages").
To set up the configuration:
-
Create the
.kdconfig
file in your home directory:touch ~/.kdconfig
-
Add your configuration to the file:
echo "AI_API_KEY=your_api_key_here" >> ~/.kdconfig echo "AI_MODEL=your_model_here" >> ~/.kdconfig echo "AI_CLIENT=your_client_type_here" >> ~/.kdconfig
-
Set appropriate permissions to protect your API key:
chmod 600 ~/.kdconfig
Here's a basic example of how to use Kado AI in your Go code:
package main
import (
"fmt"
"log"
kadoai "github.com/janpreet/kado-ai/ai"
)
func main() {
client, err := kadoai.NewAIClient("/path/to/your/iac/code", "")
if err != nil {
log.Fatalf("Error creating AI client: %v", err)
}
recommendations, err := client.RunAI()
if err != nil {
if err.Error() == "operation cancelled by user" {
fmt.Println("AI analysis cancelled.")
return
}
log.Fatalf("Error running AI: %v", err)
}
fmt.Println("Infrastructure Recommendations:")
fmt.Println(recommendations)
}
When you run this code:
- It will analyze your Infrastructure as Code files.
- It will save the sanitized input to a file named
ai_input.txt
in your specified IaC directory. - You will be prompted to review the input and confirm if you want to proceed with sending the data to the AI.
- If you confirm, it will send the data to the AI service and return the recommendations.
- If you cancel, the operation will stop without sending any data to the AI service.
This approach allows you to review the sanitized data before it's sent to the AI, providing an additional layer of security and control.
-
API Key Protection: Store your API key securely in the
.kdconfig
file and ensure it has restricted permissions (600). -
Data Sanitization: Kado AI sanitizes sensitive information before sending it to the AI service. This includes:
- Passwords
- API keys
- Tokens
- Private keys
- IP addresses
- URLs (domain parts are redacted)
-
Local Storage: The sanitized input is saved locally in
ai_input.txt
within your IaC directory. Ensure this file is protected and cleaned up after use. -
No Persistent Storage: The AI service does not store your data, but the interaction is part of the API call. Ensure compliance with your data handling policies.
-
HTTPS: All communications with AI services use HTTPS.
-
Version Control: Do not commit the
.kdconfig
file or any files containing sensitive information to version control. -
User Confirmation: Before sending any data to the AI service, the user is prompted to review the sanitized input and must explicitly confirm to proceed. This allows for a final check to ensure no sensitive information is being sent unintentionally.
To set up the development environment:
-
Clone the repository:
git clone https://github.com/janpreet/kado-ai.git cd kado-ai
-
Install dependencies:
go mod tidy
-
Make your changes to the code.
-
Run tests:
make test
-
Build the package:
make build
Run tests using:
make test
This will run all unit tests in the package. Ensure all tests pass before submitting a pull request.
This project uses GitHub Actions for CI/CD. The workflows are defined in .github/workflows/
:
ci.yml
: Runs tests and build on every push and pull request to the main branch.publish.yml
: Runs tests, builds the package, and publishes to pkg.go.dev when a new release is created.
To create a new release:
- Update the version in your code if necessary.
- Commit and push your changes.
- Create a new tag:
make tag VERSION=v0.1.0
- Go to the GitHub repository and create a new release based on this tag.
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and write tests for them.
- Run
make test
to ensure all tests pass. - Submit a pull request with a clear description of your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
For support, please open an issue in the GitHub repository. Provide as much context as possible, including:
- Your Go version
- Your operating system
- The version of Kado AI you're using
- A detailed description of the issue
- Steps to reproduce the issue
- Any relevant code snippets or error messages
Please do not share any sensitive information (like API keys) in your support requests.
Kado AI is a component of the larger Kado project, which is designed to provide comprehensive infrastructure management and optimization tools. While Kado AI focuses on AI-assisted recommendations for infrastructure configurations, it integrates seamlessly with other Kado components to offer a full-featured solution for modern infrastructure challenges.
For more information about the overall Kado project and how Kado AI fits into the broader ecosystem, please visit the main Kado project repository.