Skip to content

fix(cli): name the forge for self-hosted issue references - #43931

Draft
TuanNancy wants to merge 2 commits into
stablyai:mainfrom
TuanNancy:feat/reference-provider-hint
Draft

TuanNancy wants to merge 2 commits into
stablyai:mainfrom
TuanNancy:feat/reference-provider-hint

Conversation

@TuanNancy

@TuanNancy TuanNancy commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Some self-hosted Git servers use the same /issues/42 address shape as GitHub and Gitea. From the URL alone Orca cannot tell which one it is, so it refuses to attach the issue. This adds a flag that lets the caller say which forge it is.

What Changed

  • Before: orca reference add https://gitea.example.com/org/repo/issues/42 and orca worktree create --reference https://gitea.example.com/org/repo/issues/42 fail with Unsupported reference URL…, even though the same host's /pulls/42 URL works.
  • After: pass --reference-provider gitea (or github for GitHub Enterprise) and the URL resolves, stores provider: gitea, and appears on the workspace like any other issue link. The flag also works on reference remove, so a URL added with it can be removed by URL.
  • Mechanism: parseWorkspaceReferenceUrl already accepts a provider hint. The CLI now reads --reference-provider, validates it as github or gitea, and tries each URL without the hint first. Only a URL whose host and path cannot name a provider falls back to the hint, so a mixed batch keeps its known-host links. Nothing new reaches the runtime or the stored schema.
  • Why not infer it: reference add and worktree create parse URLs client-side before a worktree exists, and ReferenceWorkspace carries no forge fact. Guessing Gitea for every unknown host would mislabel GitHub Enterprise, so the caller names the ambiguous forge instead.
  • Validation: --reference-provider without --reference on worktree create is refused, matching --reference-site. An unknown provider is refused before any URL is parsed.

Linked Issue

Fixes #43714

Visual Proof

N/A — CLI parsing only; no UI change. The user-visible surface is the new --help flag line and the reference docs.

Testing

  • Added src/cli/references/reference-input.test.ts: a self-hosted /issues/42 URL resolves with gitea, a mixed batch keeps its known-host GitHub link, the flag survives the worktree create --reference path, and a provider without --reference or with an unknown value is refused. Those cases fail on main.
  • pnpm test src/cli/references/reference-input.test.ts --maxWorkers=2 — 4/4 pass.
  • pnpm tc:cli — pass.
  • pnpm check:changed — 22/22 checks pass (includes unit tests, typecheck, lint, format).

Performance

None, because it only widens CLI reference parsing; no extra process, network call or file read.

Risk

Level: Low

  • The flag is additive: without it, every existing URL is parsed exactly as before. It only affects CLI argument parsing and reuses the provider-hint path already covered by workspace-reference-identity.test.ts.
  • The riskiest part is allowing a caller to label an ambiguous URL as github or gitea; a wrong label makes the link point at the wrong forge, but only for the command that passed the flag.
  • No stored schema, RPC, remote-host, SSH, mobile, or older-runtime behavior changes. A plain revert restores the previous rejection.

AI Disclosure

Implemented with DeepSeek V4.1 Flash via OpenCode. I reviewed the diff, ran the checks above, and did not manually exercise a built CLI against a running Orca host.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
  • I manually tested these changes locally

Notes for reviewers

  • The flag only names the forge for ambiguous /issues/ routes; URLs that already identify their provider (github.com, gitlab.com, Codeberg, /pulls/, GitLab /-/issues/, and so on) keep working unchanged.
  • reference find needs no flag because its query already matches an ambiguous issue URL by host and path across GitHub/Gitea.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CLI accepts --reference-provider github|gitea for reference add, reference remove, and worktree create. Input parsing validates the value and passes it to URL parsing. A provider hint without a reference and unsupported provider values produce errors. Command help, documentation, and examples describe the option.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to efbc9

This adds an optional flag to disambiguate self-hosted issue URLs and leaves existing behavior unchanged. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: the CLI now lets callers name the forge (github or gitea) for self-hosted issue references. It follows the conventional-commit form and is 57 characters. It is specific to …
Linked Issues check Passed Issue #43714 asks that /issues/ URLs on self-hosted Gitea hosts be accepted by reference add and worktree create --reference. The issue says either an inferred provider or an explicit flag works…
Out of Scope Changes check Passed Each changed file supports the flag:
- reference-input.ts and reference.ts implement hint parsing, validation, and forwarding. The hint is ignored for Jira keys, which keep their existing `referen…
Description check Passed The description follows the repository template closely. It has ELI5, What Changed (before/after and mechanism), Why (explains why the caller names the forge instead of inferring it), Linked Issue (Fi…
Full details: Title check

Explanation

The title names the change: the CLI now lets callers name the forge (github or gitea) for self-hosted issue references. It follows the conventional-commit form and is 57 characters. It is specific to the primary change, which adds the --reference-provider flag.

Full details: Linked Issues check

Explanation

Issue #43714 asks that /issues/ URLs on self-hosted Gitea hosts be accepted by reference add and worktree create --reference. The issue says either an inferred provider or an explicit flag works. The PR implements the explicit flag, --reference-provider github|gitea.

Verified at the reviewed head (src/cli/references/reference-input.ts):

  • getReferenceProviderHint reads reference-provider and rejects any value other than github or gitea with invalid_argument.
  • parseReferenceUrl first calls the provider-independent parseWorkspaceReferenceUrl(url). It retries with the hint only when the first call throws. If the retry also fails, it rethrows the original error. Known-provider URLs in a mixed batch therefore keep their detected provider.
  • parseReferenceUrls and parseReferenceInputs forward the hint. getCreateReferenceInputs passes it for worktree create.
  • The previous assessment covered src/cli/references/reference.ts, which forwards the hint for both add and remove. That verdict is carried forward.

Verified at the reviewed head (src/cli/references/reference-input.test.ts): the tests cover a self-hosted /issues/42 URL resolving as gitea, a GitHub PR URL in a mixed batch keeping github, the flag passing through worktree create inputs, and refusal of a provider without --reference and of an unknown provider.

The stored provider: gitea value already exists in the runtime linkedItems schema, so the resolved issue reaches the workspace like other issue links. The coding requirement is met. Manual testing is non-coding and does not apply.

Full details: Out of Scope Changes check

Explanation

Each changed file supports the flag:

  • reference-input.ts and reference.ts implement hint parsing, validation, and forwarding. The hint is ignored for Jira keys, which keep their existing reference-site path.
  • src/cli/specs/reference.ts, src/cli/specs/worktree-create.ts, and src/cli/discovery/command-scoped-flag-help.ts register the flag and its usage and help text.
  • src/cli/references/reference-input.test.ts tests the new behavior. Its content was read at the reviewed head.
  • The docs (docs/site/content/docs/cli/reference.mdx, skill-guides/orca-cli.md, src/cli/skills/bundled-skill-guides.ts) describe the same flag.

No changed code alters the URL parser's behavior for URLs that already identify a provider. The help and docs files were not read directly. Their connection to the flag rests on their summaries and file names. No unrelated change was found in the evidence read.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed (before/after and mechanism), Why (explains why the caller names the forge instead of inferring it), Linked Issue (Fixes #43714), Visual Proof (N/A with reason), Testing (tests added, commands run), Performance ("None, because" with reason), Risk (Level: Low with rollback), AI Disclosure, and the upstream boundary checkbox. The main gap is that the first Testing checkbox ("I manually tested these changes locally") is unchecked, and the author states in AI Disclosure that no built CLI was exercised against a running Orca host. The Review section is empty. The template's Notes checklist items (security, cross-platform, SSH, mobile, backwards compatibility) are not explicitly addressed beyond the Risk section, which covers SSH, remote-host, and older-runtime behavior. These gaps are non-critical, so the description is mostly complete.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 47cd73d2-e602-4202-9db0-ed2679b67198
Commits

Reviewing files that changed from the base of the PR and between 0d04259 and efbc930.

Files selected for processing: 3

  • skill-guides/orca-cli.md
  • src/cli/discovery/command-scoped-flag-help.ts
  • src/cli/skills/bundled-skill-guides.ts
Files skipped from review as they are similar to previous changes: 1

  • src/cli/discovery/command-scoped-flag-help.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5a1bfa85-8d08-47ea-b876-4a37fd376dc2
Commits

Reviewing files that changed from the base of the PR and between 9c6d2ed and 4b961a1.

Files selected for processing: 9

  • docs/site/content/docs/cli/reference.mdx
  • skill-guides/orca-cli.md
  • src/cli/discovery/command-scoped-flag-help.ts
  • src/cli/references/reference-input.test.ts
  • src/cli/references/reference-input.ts
  • src/cli/references/reference.ts
  • src/cli/skills/bundled-skill-guides.ts
  • src/cli/specs/reference.ts
  • src/cli/specs/worktree-create.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment thread src/cli/references/reference-input.ts Resolved
Comment thread src/cli/skills/bundled-skill-guides.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1

src/cli/references/reference-input.ts-53-53: 1

53-53: Major · Functional Correctness · Heavy lift

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Support self-hosted issue URLs with a deployment prefix.

For https://git.example.com/git/org/repo/issues/42, --reference-provider gitea does not resolve the issue. The hinted retry still requires exactly two path segments before /issues/. Add, remove, and create therefore report invalid_argument before writing.

Allow a deployment prefix for explicitly hinted issue URLs. Preserve the prefix in the canonical URL and keep the existing behavior for root-mounted URLs and mixed-provider batches.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b78890e-06af-4147-84ca-1b9b1e1bc904
Commits

Reviewing files that changed from the base of the PR and between 4b961a1 and 0d04259.

Files selected for processing: 7

  • docs/site/content/docs/cli/reference.mdx
  • skill-guides/orca-cli.md
  • src/cli/references/reference-input.test.ts
  • src/cli/references/reference-input.ts
  • src/cli/skills/bundled-skill-guides.ts
  • src/cli/specs/reference.ts
  • src/cli/specs/worktree-create.ts
Files skipped from review as they are similar to previous changes: 1

  • src/cli/specs/worktree-create.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

A self-hosted /issues/ URL cannot prove GitHub vs Gitea from its path. Add --reference-provider github|gitea to reference add/remove and worktree create --reference so those URLs resolve instead of being rejected.
Try each reference URL without the hint first, so a mixed batch keeps a GitHub link when only the self-hosted issue URL needs --reference-provider. Update the help and docs to state that known hosts keep their provider.
@TuanNancy

Copy link
Copy Markdown
Contributor Author

Issue #43714 is assigned to @nwparker — is a community fix still wanted here? Happy to close #43931 if the assignment covers it, or to keep this if it helps.

@TuanNancy
TuanNancy marked this pull request as draft November 26, 2026 08:23
@TuanNancy

Copy link
Copy Markdown
Contributor Author

Parked this PR as a draft so the active review queue stays at 5 PRs. This is not abandoned; I will mark it ready again once the active PRs have been reviewed. No action needed from maintainers right now.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gitea issue URLs on self-hosted instances are rejected as references

1 participant