Skip to content

feat: forge-agnostic workflow commands (Gitea/GitLab support) #1101

@truck0321

Description

@truck0321

Summary

Archon's Gitea and GitLab webhook adapters are implemented, but all default command files (.md) and workflow files (.yaml) hardcode gh CLI calls. Running workflows against a Gitea or GitLab repository fails because gh pr create, gh issue view, etc. only work with GitHub.

Proposed Solution

Three layers of change:

1. Forge Detection (@archon/git)

  • New detectForge(repoPath) utility that parses git remote get-url origin to determine forge type (github | gitea | gitlab | unknown)
  • Matches against GITEA_URL and GITLAB_URL env vars for self-hosted instances
  • Returns API base URL (e.g., https://git.example.com/api/v1)

2. Variable Injection + Env Passthrough

  • New workflow variables: $FORGE_TYPE, $FORGE_API_BASE, $FORGE_CLI
  • Detected at workflow start, substituted in all prompts and scripts
  • Added to SUBPROCESS_ENV_ALLOWLIST so AI subprocesses can read them
  • GITLAB_TOKEN and GITLAB_URL added to the allowlist alongside existing GITEA_TOKEN/GITEA_URL

3. forge-cli.ts Helper Script

  • TypeScript script (runs via bun, zero additional dependencies)
  • Unified interface: bun forge-cli.ts pr create, bun forge-cli.ts issue view, etc.
  • Routes to gh CLI for GitHub, native fetch() API calls for Gitea/GitLab
  • Bash nodes in workflows call it deterministically (no AI reasoning needed)
  • For AI command prompts, a compatibility preamble is auto-injected for non-GitHub forges

Files Changed

  • New: packages/git/src/forge.ts (detection), .archon/scripts/forge-cli.ts (CLI wrapper)
  • Modified: executor.ts, executor-shared.ts, dag-executor.ts (variable injection + plumbing)
  • Modified: env-allowlist.ts (GITLAB_TOKEN, GITLAB_URL, FORGE_TYPE, FORGE_API_BASE)
  • Modified: 3 workflow YAMLs (bash nodes: ghbun "$FORGE_CLI")
  • Modified: 3 command MDs (explicit forge notes)

Testing

  • Unit tests for forge detection (11 tests, all pass)
  • Full bun run validate passes (type-check + lint + format + all tests)
  • End-to-end tested against production Gitea instance (git.axiodev.com):

Backwards Compatibility

  • GitHub repos: zero behavior change (forge detection defaults to github)
  • Auto-injected preamble only activates for non-GitHub forges
  • All existing tests pass without modification (except index offsets for new params)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority - Nice to have, consider closing if stalearchitectureArchitectural changes and designarea: workflowsWorkflow engineeffort/highCross-cutting changes, multiple domains, requires design decisionsfeature-requestNew functionality (external suggestion, needs review)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions