Cyrus AI Agent Platform

repository·main·Indexed 20 days ago

https://github.com/cyrusagents/cyrus

An AI agent platform that automates software development workflows by monitoring issues in Linear, GitHub, and Slack, and executing code changes via AI models in isolated Git worktrees. Includes the cyrus-ai CLI for agent management, the F1 end-to-end testing framework for simulating production environments locally, and the cyrus-cloudflare-tunnel-client for exposing local services.

Tokens
181.5K
Snippets
550
Records
819
Agent score
71%

What's inside Cyrus

  1. Overview of Cyrus core packages

    main

    The Cyrus monorepo is composed of several specialized packages, each with a distinct scope. Developers can use these packages independently or combine them to build complex applications like CLI tools or Electron-based agents.

    Core Packages

    • @cyrus/core: Contains domain models (Session, Issue, Workspace, Comment), session lifecycle management, and shared TypeScript types.
    • @cyrus/claude-parser: Responsible for parsing Claude's stdout/stderr, specifically handling streaming JSON and emitting typed ClaudeEvents.
    • @cyrus/claude-runner: Manages the lifecycle of the Claude CLI process, including spawning processes, sending prompts, and configuring tools.
    • @cyrus/ndjson-client: Provides NDJSON streaming communication with an edge proxy, handling OAuth authentication and webhook events.
    • @cyrus/edge-worker: The primary orchestrator. It connects to the edge proxy, processes Linear webhooks, manages Claude sessions, and posts responses back to Linear.
  2. Overview of Cyrus Agent

    main
    Cyrus is an AI-powered agent designed to automate issue management across platforms like Linear, GitHub, GitLab, and Slack. It monitors assigned issues, creates isolated Git worktrees for each task, and executes AI sessions (using Claude Code, Codex, Cursor, or Gemini) to process them. Cyrus streams activity updates, dropdown selections, and approval requests back to the original issue tracking platform.
  3. Verify Codex sandbox and concurrency isolation

    main

    The Codex app-server (v0.137) implements several security and performance features that can be verified through testing:

    • Per-thread permission-profile sandbox: Agent writes (e.g., Edit activities) are confined to a specific worktree (e.g., worktrees/DEF-1/). Writes outside this path are blocked.
    • Pooled shared app-server isolation: Multiple sessions can run concurrently on a single pooled process. The system uses threadId routing to ensure that responses are delivered only to the correct session, preventing cross-talk between concurrent users.
    • Resume across turns: Sessions are stateful. You can resume a completed session by using its --session-id in a new prompt-session command, and the agent will recall prior context.
  4. Manage Debugging Sessions with Task Tools

    main

    To maintain a structured debugging process, use the specialized Task Tools for planning and tracking alongside the general Task tool for execution. This "Two-Tool Symphony" ensures you have a clear roadmap of the investigation.

    Planning & Tracking (Task Tools)

    • TaskCreate: Use this as the first step in a session to create a debugging checklist.
    • TaskUpdate: Use this to update the status of specific tasks as you progress.
    • TaskList: Use this to check your overall progress against the checklist.

    Execution (Task Tool)

    Use the Task tool for all investigative and corrective actions, such as searching the codebase, analyzing logic flow, or running test suites.

  5. How Claude Code discovers repo-local skills

    main

    Claude Code discovers skills located in the <repo>/.claude/skills/ directory. The discovery mechanism depends on how the repository is added to the session:

    1. Single-repo sessions: If the current working directory (cwd) is the repository itself, the CLI automatically discovers skills in <cwd>/.claude/skills/.
    2. Multi-repo or Subdirectory sessions: If a repository is a subdirectory of the cwd (or a sibling in a workspace container), the skills will not be discovered automatically. You must use the --add-dir <dir> flag to explicitly add the directory. This flag triggers the auto-loading of .claude/skills/ from that specific directory.

    Important: The skills flag in the SDK is a context filter, not a discovery mechanism. It determines which already discovered skills are enabled. If a skill is not discovered (e.g., because --add-dir was not used for a subdirectory), it cannot be enabled via the skills filter.

  6. Understand the Stop Hook behavior in RunnerConfigBuilder

    main

    The Stop hook is a mechanism used to intercept a session stop attempt. When implemented via RunnerConfigBuilder.buildStopHook(), it can block the first stop attempt to provide guidance to the agent (e.g., reminding them to commit or push code).

    Behavioral Logic:

    • First Stop Attempt: If the hook returns decision: "block" and a reason: "...", the SDK blocks the stop and injects a synthetic user message containing that reason text. This ensures the agent receives the guidance in its next turn.
    • Second Stop Attempt: When a stop is triggered while a hook is active (stop_hook_active === true), the hook should return an empty object {} to allow the session to complete cleanly without an infinite loop.

    SDK Signaling: Whenever a Stop hook returns decision: "block", the SDK emits a system/notification event with the key "stop-hook-error". This is a standard signal that a hook has intervened and does not indicate a code error.

  7. How the Codex app-server resume path works

    main

    The Codex app-server implements a session resumption lifecycle designed for production environments where follow-up comments occur after a turn has fully completed.

    The Workflow:

    1. Turn Completion: A turn finishes and the session is marked as completed (e.g., subtype: success).
    2. Resumption Trigger: When a new interaction occurs, the EdgeWorker calls resumeAgentSession.
    3. Session Identification: If a previous session exists, needsNewSession is set to false and a resumeSessionId is provided.
    4. Runner Initialization: The CodexRunner is initialized with the resumeSessionId.
    5. Context Recall: The backend uses thread/resume to load the prior context into a fresh app-server process, allowing the agent to recall information from previous turns.
    [resumeAgentSession] needsNewSession=false, resumeSessionId=019e952a-cc98-7621-aec4-7859117e9c6b
  8. CLI Interaction Tone and Style

    main

    The agent's communication style is optimized for a CLI environment:

    • Concise & Direct: Professional and direct tone.
    • Minimal Output: Aim for fewer than 3 lines of text output per response (excluding tool use/code generation).
    • No Chitchat: Avoid conversational filler, preambles (e.g., "Okay, I will now..."), or postambles.
    • Formatting: Uses GitHub-flavored Markdown for monospace rendering.
    • Handling Inability: If a request cannot be fulfilled, state so briefly (1-2 sentences) and offer alternatives if appropriate.
  9. Understand Cursor permission mapping and synchronization

    main

    In the Cyrus/F1 environment, Cursor permissions are mapped from Claude tool permissions and applied as a project-level configuration file located at .cursor/cli.json.

    Key Behaviors:

    • Pre-session Sync: The Cursor runner writes the .cursor/cli.json file before execution starts.
    • Subroutine Transitions: Permissions are re-synced automatically during subroutine transitions. For example, if a subroutine requires all tools to be disabled, the runner will update the .cursor/cli.json file to reflect (allow=0, deny=0).
    • Agent Selection: Using the [agent=cursor] label in an issue description ensures the session is routed to the Cursor runner.
  10. Understand the Validation Loop lifecycle

    main

    The validation loop is a core mechanism in Cyrus that ensures code quality by automatically handling test failures. The lifecycle follows this pattern:

    1. Coding Activity: The agent implements the requested feature.
    2. Verifications: The agent runs the test suite and type checking.
    3. Failure Detection: If tests fail, the AgentSessionManager identifies the failure reason and triggers the fixer.
    4. Validation Fixer: A specialized subroutine (validation-fixer) is invoked to resolve the identified bugs.
    5. Retry/Re-verification: The agent re-runs the verifications subroutine. If successful, it advances to the next stage (e.g., git-gh); if not, it continues the loop up to a maximum number of iterations.

    Key Events

    • validationLoopIteration: Fired when a validation attempt completes (pass or fail).
    • validationLoopRerun: Fired when re-running verifications after a fix has been applied.
  11. Manage orchestration state and logs

    main

    Orchestration state must be tracked in your internal responses, NOT in Linear comments to the current issue. Use the following structured formats for tracking:

    Orchestration Status

    Track the lifecycle of sub-issues:

    • Completed: List of merged sub-issues with verification results.
    • Active: The sub-issue currently being executed.
    • Pending: Queued sub-issues.
    • Blocked: Issues awaiting resolution.

    Verification Log

    For each sub-issue, maintain a detailed log:

    • [Sub-Issue ID]
    • Verification Commands: Commands executed.
    • Expected Outcomes: What was expected.
    • Actual Results: What actually occurred.
    • Evidence: Screenshots, logs, test outputs.
    • Visual Confirmation: Confirmation that screenshots were taken and visually inspected.
    • Status: PASSED, FAILED, or PARTIAL.
    • Notes: Additional observations.

    Decision and Risk Tracking

    • Key Decisions: Record decisions and their rationales.
    • Risks & Mitigations: Record identified risks and their mitigation strategies.
    ## Orchestration Status
    **Completed**: [List of merged sub-issues with verification results]
    **Active**: [Currently executing sub-issue]
    **Pending**: [Queued sub-issues]
    **Blocked**: [Issues awaiting resolution]
    
    ## Verification Log
    **[Sub-Issue ID]**:
    - Verification Commands: [Commands executed]
    - Expected Outcomes: [What was expected]
    - Actual Results: [What occurred]
    - Evidence: [Screenshots, logs, test outputs]
    - Visual Confirmation: [Screenshots taken and read/viewed with confirmation of visual elements]
    - Status: [PASSED/FAILED/PARTIAL]
    - Notes: [Additional observations]
    
    ## Key Decisions
    - [Decision]: [Rationale]
    
    ## Risks & Mitigations
    - [Risk]: [Mitigation strategy]
  12. How GeminiRunner and SimpleGeminiRunner differ from ClaudeRunner

    main

    While gemini-runner mirrors the architecture of claude-runner, it adapts to the Gemini CLI's specific streaming format and session management.

    AspectClaudeRunner
    CLI Commandclaude --output-format ndjson
    Session IDGenerated client-side or via --continue
    Stream FormatNDJSON with SDK-compatible messages
    Tool Use IDsNative SDK format
    Auto-ApprovalApproval callbacks or flags
    AspectGeminiRunner
    CLI Commandgemini --output-format stream-json
    Session IDAssigned by CLI in init event
    Stream FormatCustom JSON format requiring adapter
    Tool Use IDsGenerated client-side
    Auto-Approval--yolo flag and --approval-mode