Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ The application uses consumer-defined interfaces and clear package boundaries:
- **`commentfilter/`** — Shared bot-loop prevention (ignored users, known bots, thread depth limits)
- **`recovery/`** — `StartupRunner` for crash recovery (orphan container cleanup, stuck ticket reset, workspace TTL)
- **`costtracker/`** — `FileTracker` for daily AI session cost tracking with budget enforcement
- **`services/`** — Infrastructure implementations: `JiraService` (Jira REST API), `GitHubService` (GitHub App auth, Git Data API, PR operations)
- **`services/`** — Infrastructure implementations: `JiraService` (Jira REST API), `GitHubService` (GitHub App auth, Git Data API, PR operations), `GitLabService` (GitLab PAT auth, MR operations), `GitOps` (shared provider-agnostic git commands)
- **`services/hosting/`** — `Router` that dispatches VCS operations to the correct backend (GitHub or GitLab) based on owner/repo mapping from project config
- **`models/`** — Configuration (`Config`), Jira API types, domain types (`WorkItem`, `SearchCriteria`, `ProjectSettings`)

### Design Principles
Expand All @@ -50,6 +51,8 @@ Key configuration features:
- `GetProjectConfigForTicket()` retrieves the appropriate project config based on ticket key
- `StatusTransitions` maps ticket types to their workflow statuses (todo, in_progress, in_review, and optionally merged)
- **Workspaces** group one or more repos into a named working environment. A single-repo project is a workspace with one entry. Multi-repo workspaces clone all repos into subdirectories and run one AI session against the whole workspace. An optional `root_repo` URL clones a scaffold repo as the workspace root before child repos are placed inside it; the scaffold provides context files (e.g., CLAUDE.md) but is never branched, committed to, or PR'd.
- **Hosting**: Each workspace declares a `hosting` field (`"github"` or `"gitlab"`, defaults to `"github"`). The hosting router in `services/hosting/` dispatches VCS operations to the correct backend based on this setting.
- **GitLab configuration**: When any workspace uses `hosting: gitlab`, the top-level `gitlab` section must be configured with `base_url`, `access_token`, `bot_username`, and `bot_email`. Auth uses Personal Access Tokens (PAT) or Project/Group Access Tokens.
- **Profiles** bundle container, imports, instructions, and workflow settings. Repos within workspaces reference profiles by name. Profile settings override repo-level `.ai-bot/` files when set, enabling prototyping without committing to the source repo.
- `Components` maps Jira component names to workspaces (case-insensitive). `DefaultWorkspace` is used when tickets have no matching component.
- **Fork mode**: `fork_mode: true` on a project config requires fork-based contributions. Commits are pushed to the assignee's fork (looked up via `jira.assignee_to_github_username`) and PRs are created as cross-repo PRs. When disabled (default), commits go directly to the upstream repo. Missing assignee mappings in fork-mode projects apply the `fork_user_missing` failure label and skip the ticket.
Expand Down Expand Up @@ -289,6 +292,8 @@ stub := &executortest.StubPipeline{
Environment variables follow the pattern `JIRA_AI_<SECTION>_<FIELD>`:
- `JIRA_AI_JIRA_BASE_URL` -> `jira.base_url`
- `JIRA_AI_GITHUB_APP_ID` -> `github.app_id`
- `JIRA_AI_GITLAB_BASE_URL` -> `gitlab.base_url`
- `JIRA_AI_GITLAB_ACCESS_TOKEN` -> `gitlab.access_token`
- `JIRA_AI_AI_PROVIDER` -> `ai_provider`
- `JIRA_AI_WORKSPACES_BASE_DIR` -> `workspaces.base_dir`
- `JIRA_AI_GUARDRAILS_MAX_CONCURRENT_JOBS` -> `guardrails.max_concurrent_jobs`
Expand All @@ -299,7 +304,8 @@ See `models/config.go` LoadConfig() for complete environment variable binding.

- `main.go`: Application entry point, service wiring, HTTP server, graceful shutdown
- `models/`: Configuration and data structures (Jira types, domain types)
- `services/`: Infrastructure service implementations (Jira REST API, GitHub App/Git Data API)
- `services/`: Infrastructure service implementations (Jira REST API, GitHub App/Git Data API, GitLab PAT/MR API, shared GitOps)
- `services/hosting/`: Multi-provider routing (dispatches to GitHub or GitLab based on workspace config)
- `tracker/`: IssueTracker interface and Jira adapter
- `workspace/`: Ticket-scoped workspace management
- `container/`: Container runtime detection, image resolution, lifecycle management
Expand Down
82 changes: 82 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ jira:
profile: go-dev
target_branch: master # older repos may use "master"

# GitLab workspace: set hosting to "gitlab" for repos on GitLab.
# Requires the gitlab section to be configured above.
# gitlab-backend:
# hosting: gitlab
# repos:
# - name: backend
# url: https://gitlab.com/your-org/backend.git
# profile: go-dev

# Multi-repo workspace: all repos cloned into subdirectories
# of the workspace and mounted into a single container.
# Requires a workspace-level container with all toolchains.
Expand Down Expand Up @@ -316,6 +325,79 @@ github:
# - "license/cla"
# - "codecov/patch"

# GitLab Configuration (OPTIONAL — only required when workspaces use hosting: gitlab)
#
# Uses Personal Access Token (PAT) or Project/Group Access Token for
# authentication. Unlike GitHub App auth, GitLab tokens are simpler to
# set up: create a token with the right scopes and paste it here.
#
# Token types (choose one):
# - Personal Access Token: tied to a user account. Simplest for testing.
# Create at: https://YOUR-GITLAB/-/user_settings/personal_access_tokens
# - Project Access Token: tied to a specific project. Survives employee
# offboarding. Create at: Project > Settings > Access Tokens.
# - Group Access Token: covers all projects in a group. Best for multi-repo.
# Create at: Group > Settings > Access Tokens.
#
# Required token scopes: api, read_repository, write_repository
#
# See docs/gitlab-support.md for full deployment guide.
#
# gitlab:
# # Base URL of the GitLab instance (REQUIRED when using GitLab hosting)
# # For gitlab.com: "https://gitlab.com"
# # For self-managed: "https://gitlab.your-company.com"
# base_url: "https://gitlab.com"
#
# # Access token (REQUIRED)
# # The token must have scopes: api, read_repository, write_repository
# # Environment variable: JIRA_AI_GITLAB_ACCESS_TOKEN
# access_token: "glpat-xxxxxxxxxxxxxxxxxxxx"
#
# # Bot identity for git commits (REQUIRED)
# # These appear as the commit author on merge requests.
# # For project tokens, use the token name and a team email.
# # For personal tokens, use your bot account's name and email.
# bot_username: "ai-bot"
# bot_email: "ai-bot@example.com"
#
# # Default label applied to merge requests created by the bot.
# # Useful for filtering bot MRs in GitLab's MR list.
# mr_label: ai-mr
#
# # Optional: Path to SSH private key for commit signing.
# # When set, commits are signed with this key and show as "Verified"
# # in GitLab (requires the public key to be added to the bot account).
# # ssh_key_path: "/path/to/ssh_signing_key"
#
# # GitLab label that tells the bot to skip an MR entirely.
# # When this label is present on an MR, the bot will not process review
# # comments, CI failures, or merge conflicts for that MR. Removing the
# # label re-enables processing on the next scan cycle.
# # Set to empty string to disable the feature.
# skip_mr_label: ai-bot-skip
#
# # Bot loop prevention settings
# # Maximum number of bot replies allowed in a single discussion thread.
# # Prevents infinite loops when two bots reply to each other.
# max_thread_depth: 5
#
# # Known bot usernames — prevents bot-to-bot conversation loops.
# # Comments from these users are processed initially but loop prevention
# # stops reply chains between bots.
# # NOTE: Do NOT include yourself (bot_username) — that's handled automatically.
# known_bot_usernames: []
# # - "project_123_bot"
# # - "another-automation"
#
# # Usernames whose MR comments are completely ignored.
# # Use for CI/pipeline bots whose comments are status updates, not code
# # review feedback. Differs from known_bot_usernames: ignored users'
# # comments are completely skipped (never processed), while known bots'
# # comments are processed initially but loop prevention stops chains.
# ignored_usernames: []
# # - "gitlab-ci-pipeline"

# AI Provider Selection (choose one: "claude" or "gemini")
ai_provider: claude

Expand Down
Loading