ci-copilot

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2025 License: MIT

README ΒΆ

CI Copilot

Your AI-powered assistant for GitLab CI/CD pipelines.

CI Copilot helps you analyze, fix, and understand your .gitlab-ci.yml files using large language models (LLMs).

It works both as a command-line tool and as a local HTTP API.

πŸš€ Features

CI Copilot supports 4 powerful AI-driven modes:


  • πŸ” Suggest
    Analyze your pipeline and get clear recommendations to improve reliability, structure, or efficiency.

  • πŸ›  Fix
    Automatically fix common issues in your .gitlab-ci.yml file. You can preview or apply the changes.

  • πŸ” Audit
    Perform a focused audit for security, speed, or cleanliness. Get prioritized recommendations.

  • πŸ“˜ Explain
    Understand what your pipeline is doing. The AI explains your .gitlab-ci.yml in simple language.

βš™οΈ Usage (CLI + API)

CI Copilot can be used as a command-line tool or as a local API.


πŸ–₯ CLI usage
# Get suggestions for improvements
ci-copilot suggest --in .gitlab-ci.yml

# Automatically fix and save to a new file
ci-copilot fix --in .gitlab-ci.yml --out .gitlab-ci.fixed.yml

# Audit the pipeline for security issues
ci-copilot audit --in .gitlab-ci.yml --focus security

# Get a simple explanation of the pipeline
ci-copilot explain --in .gitlab-ci.yml
🧩 API usage

You can use CI Copilot as a local HTTP API by running the Go server.

Start the server:

go run ./cmd/server/main.go
By default, the API runs at http://localhost:8080
POST /suggest
POST /fix
POST /audit
POST /explain
Example request (using curl)
Request:
curl -X POST http://localhost:8080/suggest \
  -H "Content-Type: application/json" \
  -d '{"message": "your .gitlab-ci.yml content here"}'
Response:
{
  "summary": "The pipeline is mostly correct but can be improved.",
  "recommendations": [
    {
      "issue": "Job 'build' is missing retry policy",
      "suggestion": "Add 'retry: 2' to ensure resilience",
      "priority": "medium"
    }
  ]
}

πŸ›  Installation

1. Clone the repository
git clone https://github.com/genov8/ci-copilot.git
cd ci-copilot
2. Alternatively, if you only need a single CLI command:
You can also install individual CLI tools:

go install github.com/genov8/ci-copilot/cmd/suggest@latest
go install github.com/genov8/ci-copilot/cmd/fix@latest
go install github.com/genov8/ci-copilot/cmd/audit@latest
go install github.com/genov8/ci-copilot/cmd/explain@latest

πŸ§ͺ Tests

Basic API behavior is covered with integration tests.

Since core functionality relies on AI model responses, we recommend manual review for output accuracy.

Run all tests with:

go test ./...

πŸ“ Project Structure

The project is organized into clearly separated modules:

ci-copilot/
β”œβ”€β”€ cmd/ # CLI entry points (suggest, fix, audit, explain)
β”œβ”€β”€ internal/
β”‚ β”œβ”€β”€ client/ # Main logic for interacting with the AI service
β”‚ β”œβ”€β”€ config/ # Centralized configuration (e.g. endpoint URLs)
β”‚ β”œβ”€β”€ server/ # HTTP API server for local AI access
β”‚ └── ui/ # Optional pretty output for CLI users
β”œβ”€β”€ prompts/ # All prompt templates used by AI interactions
β”œβ”€β”€ tests/ # Test cases (optional)
└── ai-service/ # Optional local AI service using Gemini via FastAPI

🧠 How It Works

CI Copilot combines CLI tools written in Go with a local AI-powered analysis service.

Here’s the flow:

  1. The CLI reads your .gitlab-ci.yml file.
  2. It loads a specific prompt (stored in the prompts/ folder).
  3. The content and prompt are combined and sent via HTTP to a local FastAPI AI service.
  4. The AI model (e.g., Gemini) generates a structured response.
  5. The CLI tool formats and prints the result β€” or applies changes if needed.

The architecture is modular:

  • Prompts are decoupled and easy to edit.
  • You can replace the AI backend without changing the CLI logic.

πŸ’‘ Potential Extensions

This project is designed to be extensible. Below are directions where CI Copilot could evolve:_

  • 🧠 Custom LLMs for CI/CD
    Train or fine-tune your own language models that specialize in DevOps and .gitlab-ci.yml pipelines.

  • πŸ” Pluggable AI Backends
    Support multiple AI providers β€” OpenAI, Gemini, or local LLMs β€” by switching via simple configuration.

  • πŸ§ͺ GitLab-native validation
    Add automatic .gitlab-ci.yml checks during push via GitLab Webhooks or server-side hooks β€” no changes to pipeline files needed.

  • πŸ›  Custom rule engines
    Allow teams to define internal rules or style guides that the assistant must enforce.

  • 🧩 IDE plugins
    Integrate with VS Code or JetBrains IDEs to provide in-editor suggestions and validation.

  • 🌐 Web dashboard
    Visualize suggestions, track history, and monitor best practice adoption across projects.

  • πŸ›‘ Enterprise mode
    Add support for self-hosted models, offline operation, and team-level controls in secure environments.

πŸ“œ License

This project is licensed under the MIT License.

Directories ΒΆ

Path Synopsis
cmd
api command
audit command
explain command
fix command
suggest command
internal
ui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL