### Copy Example Environment File Source: https://github.com/cairn-dev/cairn/blob/main/README.md Copies the provided example environment file '.env.example' to create the actual '.env' file, which will be used for local configuration. ```bash cp .env.example .env ``` -------------------------------- ### Configure Repositories (repos.json) Source: https://github.com/cairn-dev/cairn/blob/main/README.md An example JSON structure for the 'repos.json' file, which defines connected repositories grouped by owner and their corresponding GitHub App installation IDs. ```json { "your-github-username-or-org": { "connected_repos": ["your-repo-name", "another-repo"], "installation_id": 12345678 }, "another-owner": { "connected_repos": ["different-repo"], "installation_id": 87654321 } } ``` -------------------------------- ### Install Node.js Frontend Dependencies Source: https://github.com/cairn-dev/cairn/blob/main/README.md Navigates into the 'frontend' directory of the project and installs all necessary Node.js packages using npm. ```bash cd frontend npm install cd .. ``` -------------------------------- ### Install Python Backend Dependencies Source: https://github.com/cairn-dev/cairn/blob/main/README.md Sets up a Python virtual environment named 'cairn-env', activates it, and installs all required backend packages listed in 'requirements.txt' using pip. ```bash python -m venv cairn-env source cairn-env/bin/activate # On Windows: cairn-env\Scripts\activate pip install -r requirements.txt ``` -------------------------------- ### Run Cairn Using Startup Script Source: https://github.com/cairn-dev/cairn/blob/main/README.md The recommended method to start both the backend and frontend servers simultaneously using a provided shell script, which also automatically opens the browser. ```bash chmod +x run.sh ./run.sh ``` -------------------------------- ### Gather GitHub App Credentials Source: https://github.com/cairn-dev/cairn/blob/main/README.md Instructions on how to obtain the three essential credentials (App ID, Private Key, and Installation ID) required from the GitHub App settings after its creation and installation. ```APIDOC • App ID: Copy from app settings page (displayed at top) • Private Key: Generate and download .pem file → save to cairn project root • Installation ID: Click "Install App" → Select repositories → Install Then check browser URL: https://github.com/settings/installations/[INSTALLATION_ID] ``` -------------------------------- ### GitHub App Configuration Settings Source: https://github.com/cairn-dev/cairn/blob/main/README.md Defines the required configuration parameters for creating a new GitHub App to be used by Cairn, including naming conventions, description, URL, webhook settings, repository permissions, and installation scope. ```APIDOC • App Name: "Cairn Agent for [Your-Username]" (must be globally unique) • Description: "Cairn automated development agent" • Homepage URL: https://try-cairn.com (or leave blank) • Webhook URL: Leave blank • Webhook Secret: Leave blank • ✅ Disable "Active" checkbox under Webhooks Repository Permissions: • Contents: Read & write ✅ • Pull requests: Read & write ✅ • Metadata: Read ✅ (auto-selected) Where can this GitHub App be installed? • Select "Only on this account" ✅ ``` -------------------------------- ### Clone Cairn Repository Source: https://github.com/cairn-dev/cairn/blob/main/README.md Clones the Cairn project repository from GitHub and navigates into the newly created project directory. ```bash git clone git@github.com:cairn-dev/cairn.git cd cairn ``` -------------------------------- ### Configure Environment Variables (.env) Source: https://github.com/cairn-dev/cairn/blob/main/README.md An example of the '.env' file content, showing placeholders for GitHub App credentials (ID, private key path), an optional GitHub Personal Access Token for analytics, and various optional LLM API keys. ```bash # GitHub App credentials GITHUB_APP_ID=your_app_id_here GITHUB_PRIVATE_KEY_PATH=your_private_key_file.pem # GitHub Personal Access Token (for repository analytics - optional) # Required for viewing repository statistics, contributors, and code ownership data # Get from: https://github.com/settings/tokens # Required scopes: repo (for private repos) or public_repo (for public repos only) GITHUB_TOKEN=your_github_token_here # LLM API keys. Each is optional, add the ones you want to use. ANTHROPIC_API_KEY=your_anthropic_api_key_here OPENAI_API_KEY=your_openai_api_key_here GEMINI_API_KEY=your_gemini_api_key_here ``` -------------------------------- ### Manually Start Cairn Frontend Source: https://github.com/cairn-dev/cairn/blob/main/README.md Navigates into the 'frontend' directory and starts the Node.js development server for Cairn. This is part of the manual startup process, typically run in a separate terminal from the backend. ```bash cd frontend npm run dev ``` -------------------------------- ### Manually Start Cairn Backend Source: https://github.com/cairn-dev/cairn/blob/main/README.md Starts the FastAPI backend server for Cairn by executing the main Python application file. This is part of the manual startup process, typically run in a dedicated terminal. ```bash python fastapi_app/app.py ``` -------------------------------- ### Cairn Project Directory Layout Source: https://github.com/cairn-dev/cairn/blob/main/README.md Details the file and folder organization of the Cairn repository, highlighting key components like `agent_worker`, `cairn_utils`, `fastapi_app`, `docs`, and `tests`, providing a clear overview of the codebase structure. ```text cairn/ ├── agent_worker/ # Agent execution engine │ ├── worker.py # Main worker implementation │ └── __main__.py # CLI entry point ├── cairn_utils/ # Core utilities and libraries │ ├── agents/ # Agent implementations, including prompts │ ├── github_utils.py # GitHub API integration │ ├── toolbox.py # Agent tools and capabilities │ ├── task_storage.py # Database operations │ └── agent_classes.py # Agent base classes ├── fastapi_app/ # Web interface │ └── app.py # FastAPI application ├── static/ # Web UI assets ├── docs/ # Documentation ├── examples/ # Usage examples ├── .github/ # GitHub templates and workflows │ ├── ISSUE_TEMPLATE/ # Issue templates │ └── pull_request_template.md # PR template └── tests/ # Test suite ``` -------------------------------- ### Cairn Local Configuration Directory Structure Source: https://github.com/cairn-dev/cairn/blob/main/README.md This snippet illustrates the directory structure created by Cairn in your project root (`.cairn/`) for local configuration and memory management. It includes `settings.json` for global/repo-specific rules and a `memory/` subdirectory for per-repository memory files. ```bash .cairn/ ├── settings.json # Global and repo-specific rules └── memory/ ├── repo1.json # Memory for repo1 ├── repo2.json # Memory for repo2 └── ... # Additional repo memory files ``` -------------------------------- ### Cairn Agent Rules Configuration in settings.json Source: https://github.com/cairn-dev/cairn/blob/main/README.md This JSON snippet demonstrates the structure of `.cairn/settings.json`, which allows defining custom rules for Cairn agents. It supports `general_rules` applicable to all tasks and `repo_specific_rules` for tailored instructions per repository. ```json { "general_rules": [ "Always use TypeScript instead of JavaScript", "Follow the existing code style and patterns", "Add comprehensive error handling" ], "repo_specific_rules": { "my-frontend": [ "Use React hooks instead of class components", "Follow the existing component structure in src/components/" ], "my-backend": [ "Use FastAPI async patterns", "Always validate input parameters" ] } } ``` -------------------------------- ### Cairn Multi-Agent Architecture Diagram Source: https://github.com/cairn-dev/cairn/blob/main/README.md Illustrates the hierarchical structure and communication flow within the Cairn system, from the Web Dashboard and FastAPI backend to the Worker Manager, Fullstack Planner, Project Managers, and SWE agents. It also shows integration with SQLite Database and Log Storage. ```mermaid graph TB UI[Web Dashboard] --> API[FastAPI Backend] API --> WM[Worker Manager] WM --> FP["Fullstack Planner Agent
(plans long running tasks,
coordinates overall workflow)"] subgraph PM_LEVEL[" "] direction LR PM1["Project Manager 1
(generates a full PR)"] PM2["Project Manager 2
(generates a full PR)"] PM_MORE["..."] end FP --> PM1 FP --> PM2 FP --> PM_MORE PM1 --> SWE1["SWE1
"] PM2 --> SWE2["SWE2
"] SWE1 <-.->|a2a comms| SWE2 WM --> DB[(SQLite Database)] WM --> LS[Log Storage] style PM_LEVEL fill:transparent,stroke:transparent ``` -------------------------------- ### Configure GitHub Personal Access Token in .env Source: https://github.com/cairn-dev/cairn/blob/main/README.md This snippet shows how to add your GitHub Personal Access Token to your project's `.env` file to enable repository analytics features in Cairn. The token should be generated with appropriate scopes (`public_repo` or `repo`) from GitHub settings. ```bash GITHUB_TOKEN=your_github_token_here ``` -------------------------------- ### Run Agent Worker as a Module Source: https://github.com/cairn-dev/cairn/blob/main/agent_worker/README.md Demonstrates how to execute the agent worker directly from the command line as a Python module, requiring a specific task ID as an argument. ```Bash python -m agent_worker ``` -------------------------------- ### Run Agent Task Programmatically in Python Source: https://github.com/cairn-dev/cairn/blob/main/agent_worker/README.md Illustrates how to integrate and run an agent task programmatically within a Python application. It uses `asyncio` to execute the `run_agent_task` function with a given task ID. ```Python import asyncio from agent_worker import run_agent_task # Run a specific task asyncio.run(run_agent_task("task_12345")) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.