Skip to content

[feat] Add Devin CLI provider #148

@ThePlenkov

Description

@ThePlenkov

Summary

Add Devin CLI as a new built-in provider alongside the existing 7 (Kiro CLI, Claude Code, Codex, Gemini CLI, Kimi CLI, Copilot CLI, Q CLI).

Devin is Cognition's terminal-based AI agent. It supports --permission-mode dangerous for autonomous operation and --prompt-file for system prompt injection, making it well-suited for CAO orchestration.

Implementation Details

We have a working DevinCliProvider (338 lines) implementing BaseProvider. Key aspects:

Terminal State Detection

Devin's TUI has a unique layout that requires special handling:

> user message           ← user input
Response text            ← agent reply
────────────────────     ← horizontal rule (fixed TUI chrome)
#                        ← input prompt (never disappears)
────────────────────     ← horizontal rule
Mode: ... Model: ...     ← status bar

Challenges solved:

  • The # prompt is fixed TUI chrome — it never disappears during processing. Processing must be detected by spinner text (Running tools, esc to interrupt) taking priority over prompt detection.
  • Ghost/autocomplete text appears after # (e.g. # may be). A relaxed prompt pattern (^[\s]*#) is used, but only when the status bar (Mode:.*Model:) is also visible — proving the TUI is rendered and avoiding false matches on # in code output.
  • Stateless completed detection: User input lines are prefixed with > in Devin's TUI. By scanning for ^> .+, we distinguish idle (no input yet) from completed (input was sent, prompt returned) without ephemeral flags that break on server restart.

Command Construction

devin --permission-mode dangerous --respect-workspace-trust false \
      --prompt-file /tmp/cao_devin_prompt_xxx.md \
      --config /tmp/cao_devin_config_xxx.json

MCP Config Merging

Agent profile MCP servers are merged into Devin's ~/.config/devin/config.json, with CAO_TERMINAL_ID injected into each server's env for cross-agent communication.

Response Extraction

Responses are extracted between the last > user input line and the horizontal rule preceding the # prompt — scanning backwards for 2 horizontal rules (Unicode box-drawing characters U+2500-U+257F).

Provider Properties

  • paste_enter_count: 1 (single Enter after paste)
  • exit_cli(): /exit
  • requires_workspace: true

Agent Profiles

Three ready-to-use agent profiles:

  • developer.md — Developer agent with MCP server config and multi-agent handoff protocol
  • reviewer.md — Code reviewer (review-only, structured APPROVE/REQUEST_CHANGES output)
  • supervisor.md — Supervisor that delegates to developer and reviewer in an iterative loop

Tool Mapping

tool_mapping:
  fs_read: Read
  fs_write: Write
  execute_bash: Bash
  web_search: WebSearch
  list_dir: List

Reference Implementation

Full working implementation available at cao-poc — tested and verified with Devin CLI v2.x in both native and containerized environments.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions