Overview
Magpie supports dynamic repository resolution through theMAGPIE_GITHUB_ORG environment variable. When enabled, the pipeline parses the target repository name directly from the user’s task message, validates it belongs to the allowed GitHub organization, clones it into a temporary workspace, and executes the pipeline.
This enables a single Magpie deployment to service multiple repositories within an organization without hardcoding repo paths.
Configuration
Environment Variable
SetMAGPIE_GITHUB_ORG to restrict repo access to a specific GitHub organization:
- Parse the repo name from the task message
- Validate it belongs to
myorg - Clone
myorg/repo-nameinto a temporary sandbox - Execute the pipeline in that workspace
- Clean up the temporary directory on completion
Validation Rules
Magpie enforces strict org-scoping to prevent unauthorized access:- Case-sensitive:
MyOrg/repodoes NOT matchmyorg/repo - Exact prefix match:
myorgx/repodoes NOT match when org ismyorg - No bare names:
api-serviceis rejected (must bemyorg/api-service)
Message Parsing
Recognized Patterns
Magpie recognizes two natural language patterns for specifying the target repository:in <repo>
“fix login bug in api-service”Extracts:
api-servicerepo <name>
“fix bug repo api-service”Extracts:
api-serviceWith Org Prefix
Users can optionally include the org prefix — Magpie strips it during parsing:evil-org/api-service), the pipeline fails with a setup error.
Noise Filtering
Magpie filters out common noise words after “in” to avoid false matches:Implementation Details
Parsing Logic
The parser performs two passes over the task message:Pass 1: 'repo' keyword
Searches for
repo <name> and extracts the next token if it’s a valid repo name.Cloning
Magpie clones repositories using the GitHub CLI (gh repo clone):
Automatic Cleanup
TheResolvedRepo struct owns a tempfile::TempDir that is automatically cleaned up when the pipeline completes:
ResolvedRepo is dropped (end of pipeline), the temporary directory and all cloned files are deleted.
Pipeline Integration
Sandbox Creation
Whengithub_org is set in PipelineConfig, the pipeline creates the sandbox differently:
Example Usage
Discord Bot
"fix the CI flakiness in goose""add health check endpoint repo api-service""update README in block/web-app"
CLI (Single-Repo Mode)
Security Considerations
Error Handling
Setup Failures
The pipeline returnsPipelineStatus::SetupFailed when:
No repo found in message
No repo found in message
in <repo-name> or repo <repo-name>.Org validation failed
Org validation failed
MAGPIE_GITHUB_ORG matches the intended org.Clone failed
Clone failed
gh is authenticated, and the token has read access.Testing
Therepo.rs module includes comprehensive tests:
- ✅
test_parse_repo_from_message_in_pattern - ✅
test_parse_repo_from_message_with_org_prefix - ✅
test_parse_repo_from_message_ignores_noise_words - ✅
test_validate_org_accepts_correct_org - ✅
test_validate_org_rejects_wrong_org - ✅
test_validate_org_case_sensitive
gh CLI + network):
Related Topics
Daytona Integration
Use remote sandboxes for org-scoped repos
Warm Pool
Pre-provision sandboxes for faster acquisition