Add GitLab support alongside GitHub
Summary
Mach10 currently assumes GitHub as the sole git hosting platform, with all 15 commands using the gh CLI directly. To serve teams using GitLab, the plugin should support GitLab as an alternative platform -- ideally auto-detected from the repository remote, requiring no manual configuration.
Current Behavior
All commands hardcode gh CLI calls for issue management, PR operations, CI status checks, and comment posting. Users on GitLab-hosted repositories cannot use any of the issue or PR workflow commands.
Proposed Behavior
Mach10 should detect the git hosting platform from the repository remote and adapt its commands accordingly. The goal is a "just works" experience -- no manual configuration required for the common case.
Open Questions
The right approach needs further investigation before committing to a solution. Key questions include:
- Abstraction level: Should commands branch internally (e.g., "if GitLab, use
glab; if GitHub, usegh"), or should there be a shared abstraction layer? - CLI parity: GitLab's
glabCLI has similar commands toghbut different flags, JSON field names, and API paths. How deep do the differences go across all 15 commands? - CI differences: GitHub Actions vs GitLab CI have very different log structures and status APIs. Commands like
pr-ci-fixmay need significant platform-specific logic. - Terminology mapping: GitHub "pull requests" vs GitLab "merge requests", "checks" vs "pipelines", etc. How should this be handled in command output and GitHub/GitLab comment formatting?
- Naming: An environment variable for the detected platform should avoid implying GitHub is Mach10's "provider" -- something like
MACH10_GIT_HOSTorMACH10_PLATFORMrather thanMACH10_PROVIDER.
One Possible Approach (Not Prescriptive)
One direction explored in early discussion:
- A
SessionStarthook detects the platform fromgit remote get-url originand exports an environment variable (e.g.,MACH10_GIT_HOST=githuborMACH10_GIT_HOST=gitlab) - The same hook validates the appropriate CLI is installed (
ghorglab) - Each command's natural language body includes branching instructions for platform-specific CLI calls
This is one option among several. MCP server abstraction, wrapper scripts in bin/, and other approaches should also be evaluated during planning.
Acceptance Criteria
- Mach10 auto-detects whether the repository is hosted on GitHub or GitLab from the git remote
- No manual configuration is required for the common case (public GitHub/GitLab remotes)
- All issue workflow commands work with GitLab issues
- All PR workflow commands work with GitLab merge requests
- CI-related commands work with GitLab CI pipelines
- Existing GitHub workflows continue to work without regression
- The solution handles self-hosted instances (e.g.,
gitlab.company.com) in addition togithub.comandgitlab.com
Technical Notes
- GitLab CLI (
glab) is the GitLab equivalent ofgh: https://gitlab.com/gitlab-org/cli - Commands with the deepest GitHub integration:
pr-review(comment posting, feature-completeness-checker),pr-ci-fix(CI log parsing),issue-plan(plan comment with HTML markers) - The
<!-- mach10-plan -->and<!-- mach10-decisions -->HTML markers used in GitHub comments should work identically in GitLab markdown - This is a large scope change that will likely need staged implementation across multiple PRs
Research Findings and Proposed Approach
How gh and glab compare
Analysis of the gh and glab CLIs shows significant command overlap. Most issue commands are syntactically identical (gh issue view / glab issue view). The major divergences are:
- PR vs MR: All
gh prsubcommands becomeglab mrsubcommands - CI:
gh runbecomesglab ci, with different log access patterns - JSON output:
--json field1,field2(gh) vs-F json/--output json(glab) - API paths:
gh api repos/OWNER/REPO/...vsglab api projects/OWNER%2FREPO/... - Comments:
gh issue comment/gh pr commentvsglab issue note/glab mr note - GitHub-only extensions: gh-sub-issue (no GitLab equivalent -- use milestones), gh-pm (use labels), gh-pr-review (use
glab mr note+mr note resolve)
Proposed approach
After evaluating several options (MCP server abstraction, per-topic reference files, per-command inline crosswalks, full dual-provider reference files), the recommended approach is "differences only" with GitHub as baseline:
1. SessionStart hook (hooks/detect-provider.sh)
- Detects platform from
git remote get-url origin(matchinggithub.com,gitlab.com, self-hosted patterns) - Writes
MACH10_GIT_HOST=github|gitlabto$CLAUDE_ENV_FILE - Validates the appropriate CLI (
ghorglab) is installed and authenticated
2. One GitLab differences reference file (references/gitlab.md, ~30-40 lines)
- Documents only where
glabdiverges fromgh: command renames (gh pr->glab mr,gh run->glab ci), flag differences, API path changes, and features without GitLab equivalents (gh-sub-issue -> milestones, gh-pm -> labels) - NOT a full CLI reference -- just the exceptions
3. One conditional line per command
- Each command gets: "If
$MACH10_GIT_HOSTisgitlab, read${CLAUDE_PLUGIN_ROOT}/references/gitlab.mdand apply its substitutions to allghcommands below." - Commands keep their existing
ghsyntax as the baseline - On GitHub repos, no reference file is read (zero overhead). On GitLab repos, one small file read per command.
Why this approach
- Minimal change surface: Commands stay written in
ghsyntax. No structural rewrites. - Zero overhead for existing users: GitHub repos work exactly as before with no extra file reads.
- One source of truth for GitLab differences: A single ~30-40 line file vs. crosswalk sections duplicated across 15 commands.
- SessionStart hook pulls double duty: Also validates prerequisites (
gh/glabinstalled and authenticated), addressing first-session setup failures. - Self-hosted support: The hook can match
gitlab.company.compatterns, not justgitlab.com.
Key divergences to document in the reference file
GitHub (gh) |
GitLab (glab) |
Notes |
|---|---|---|
gh pr subcommands |
glab mr subcommands |
All PR operations become MR operations |
gh run (CI) |
glab ci |
Different log access: glab ci trace vs gh run view --log |
gh issue comment |
glab issue note |
|
gh pr comment |
glab mr note |
|
--json field1,field2 |
-F json / --output json |
Different JSON output flags |
gh api repos/OWNER/REPO/... |
glab api projects/OWNER%2FREPO/... |
Different API path structure |
| gh-sub-issue (extension) | Milestones | Group stage issues under a milestone |
| gh-pm (extension) | Label updates | glab issue update --label for workflow state |
| gh-pr-review (extension) | glab mr note + mr note resolve |
No pending review thread equivalent |