Add project context init flow for Duo Agent Platform

What does this MR do and why?

Implements the GitLab monolith portion of the "Project Context Init Flow" for Duo Agent Platform (issue #592469). This allows users to initialize their project with AGENTS.md and related context files via a new onboarding page in the Automate section.

All changes are gated behind the duo_agent_onboarding feature flag (type: beta, group: group::ai coding, default: disabled).

Implementation

A new Onboarding page is added to the Automate sidebar at /automate/onboarding. When a user visits the page, the controller checks whether AGENTS.md (or .ai/AGENTS.md) already exists on the default branch and pushes the result to gon.

The frontend renders either a success alert (if already initialized) or an "Initialize project context" button. Clicking the button POSTs to a new onboarding/initialize controller action, which:

  1. Guards against duplicate runs using a Rails cache entry and an exclusive lease.
  2. Resolves a rendered goal prompt via Ai::Catalog::GoalTemplates::Developer (new :init_project_context event type) that instructs the agent to analyze the repo and open a draft MR with an AGENTS.md.
  3. Dispatches the workflow through the existing developer/v1 foundational flow via Ai::Catalog::Flows::ExecuteService, so no AIGW changes are required.

On success, the workflow ID is cached and the frontend shows a link to the agent session to track progress.

References

Screenshots

image image image image

How to set up and validate locally

  1. Enable the feature flag in the Rails console:
    Feature.enable(:duo_agent_onboarding)
  2. Navigate to any project's Automate section: http://127.0.0.1:3000/<namespace>/<project>/-/automate
  3. Verify the "Onboarding" item appears in the sidebar
  4. Visit http://127.0.0.1:3000/<namespace>/<project>/-/automate/onboarding
  5. Verify the page shows the "Initialize project context" button when no AGENTS.md exists
  6. Click the button and verify it calls the workflow API
  7. After initialization, verify the success alert is shown

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Allen Cook

Merge request reports

Loading