LibraLibra
LibraLibra
DocsBlogLibra
Getting Started
Architecture
Design
Commands
libra addlibra agentlibra alternateslibra applylibra archivelibra authlibra automationlibra bisectlibra blamelibra branchlibra bundlelibra cachelibra cat-filelibra check-attrlibra check-ignorelibra check-mailmaplibra checkoutlibra cherry-picklibra cleanlibra clonelibra cloudlibra code-controllibra codelibra commit-treelibra commitlibra completionslibra configlibra credentiallibra depslibra describelibra diff-fileslibra diff-indexlibra diff-treelibra difflibra dirtylibra fast-exportlibra fast-importlibra fetchlibra filelibra for-each-reflibra format-patchlibra fscklibra gclibra graphlibra greplibra hash-objectlibra hookslibra hydratelibra index-packlibra initlibra investigatelibra layerlibra lfslibra loglibra logfilelibra loginlibra logoutlibra ls-fileslibra ls-remotelibra ls-treelibra maintenancelibra medialibra merge-baselibra merge-filelibra mergelibra metadatalibra mvlibra noteslibra oplibra openlibra pack-objectslibra packagelibra prunelibra publishlibra pulllibra pushlibra read-treelibra rebaselibra refloglibra remotelibra repacklibra replacelibra rererelibra resetlibra restorelibra rev-listlibra rev-parselibra revertlibra reviewlibra revisionlibra rmlibra sandboxlibra servicelibra shortloglibra show-reflibra showlibra sparse-viewlibra stashlibra statslibra statuslibra switchlibra symbolic-reflibra taglibra update-indexlibra update-reflibra usagelibra verify-packlibra whoamilibra worktreelibra write-tree
API Reference
Policy
Commands

libra open

Command reference for `libra open`

Resolve a remote URL into a web URL and optionally launch the system browser.

Synopsis

libra open [<remote>]

Description

libra open determines the web-browsable URL for a repository and, in human-output mode, opens it in the default system browser. The command accepts an optional positional argument that can be either a configured remote name (e.g. origin) or a direct URL.

When no argument is given, the command tries the following in order:

  1. The current branch's configured upstream remote.
  2. A remote named origin.
  3. The first configured remote (alphabetically).

If the resolved URL uses SSH or SCP syntax (git@host:path or ssh://...), it is automatically transformed to an HTTPS URL. The final URL is validated to ensure it uses http:// or https:// before being passed to the OS browser launcher. This prevents local file access, javascript:, or other injection vectors.

On macOS the command uses open, on Linux xdg-open, and on Windows cmd /C start.

Options

Flag / ArgumentDescriptionExample
<remote>Remote name or direct URL. When omitted, auto-detects from tracking config or origin.libra open origin
--jsonEmit structured JSON envelope to stdout instead of opening a browser (global flag).libra open --json
--machineCompact single-line JSON without launching a browser (global flag).libra open --machine
--quietSuppress the "Opening ..." message on stdout.libra open --quiet

Common Commands

libra open
libra open origin
libra open https://github.com/libra-tools/libra
libra open --json

Human Output

Opening https://github.com/libra-tools/libra

--quiet suppresses stdout.

Structured Output (JSON examples)

{
  "ok": true,
  "command": "open",
  "data": {
    "remote": "origin",
    "remote_url": "[email protected]:libra-tools/libra.git",
    "web_url": "https://github.com/libra-tools/libra",
    "launched": false
  }
}

When the argument is a direct URL instead of a remote name, remote is null:

{
  "ok": true,
  "command": "open",
  "data": {
    "remote": null,
    "remote_url": "https://github.com/libra-tools/libra",
    "web_url": "https://github.com/libra-tools/libra",
    "launched": false
  }
}

Schema Notes

  • remote is the logical remote name, or null when a direct URL was provided
  • remote_url is the raw URL from config (or the direct URL argument)
  • web_url is the transformed browsable HTTPS URL
  • launched is true when the browser was successfully spawned in human mode
  • launched is false for --json / --machine, where browser launch is intentionally skipped

URL Transformation Rules

Input FormatTransformed Output
https://github.com/user/repo.githttps://github.com/user/repo
http://github.com/user/repo.githttp://github.com/user/repo
[email protected]:user/repo.git (SCP)https://github.com/user/repo
ssh://[email protected]/user/repo.githttps://github.com/user/repo
ssh://[email protected]:2222/repo.githttps://host.com/repo

Design Rationale

Why support direct URLs?

The primary use case for libra open is quickly jumping to a repository's web interface. Sometimes a developer or agent has a URL from a chat message, issue tracker, or log output and wants to open it without first configuring a remote. Accepting direct URLs alongside remote names makes the command a universal "open this repo in the browser" tool. If the argument matches a configured remote name, that takes precedence; otherwise it is treated as a literal URL. This dual-mode behavior eliminates a common friction point without adding complexity.

Why not just use git web--browse?

git web--browse is an internal Git helper that launches a browser but has several limitations: it does not transform SSH/SCP URLs to HTTPS, it does not validate URL safety, and it requires the instaweb or browse helpers to be configured. Libra's open command handles the full URL transformation pipeline (SCP to HTTPS, SSH to HTTPS, .git suffix stripping) and validates that the final URL uses a safe scheme before passing it to the OS launcher. This makes it work out-of-the-box for all common remote URL formats without additional configuration.

Why URL safety validation?

When a remote URL is transformed and passed to an OS command (open, xdg-open, cmd /C start), there is a risk of command injection or unintended file access if the URL uses a scheme like file://, javascript:, or contains shell metacharacters. Libra validates that the final URL uses only http:// or https:// before launching the browser. On Windows, the URL is additionally quoted to prevent cmd.exe metacharacter expansion. This defense-in-depth approach protects against both accidental misconfiguration and deliberate attacks via crafted remote URLs.

Parameter Comparison: Libra vs Git vs jj

FeatureLibraGitjj
Open repo in browserlibra opengit web--browse (manual)N/A
Open specific remotelibra open originN/AN/A
Open direct URLlibra open <url>N/AN/A
SSH-to-HTTPS transformAutomaticN/AN/A
SCP-to-HTTPS transformAutomaticN/AN/A
URL safety validationhttp/https onlyN/AN/A
Structured output--json / --machineNoNo
Auto-detect remoteTracking -> origin -> firstN/AN/A

Error Handling

ScenarioStableErrorCodeExitHint
Not in a repo and no explicit URLLBR-REPO-001128"run this command inside a libra repository, or pass a URL"
No remote configuredLBR-REPO-003128"add a remote first: 'libra remote add origin <url>'"
Remote configured but has no URLLBR-REPO-003128"configure the URL: 'libra config set remote.<name>.url <url>'"
Resolved URL is unsafe or invalidLBR-CLI-003129"pass an explicit https:// URL or configure a supported remote URL"
Failed to read remote configLBR-IO-001128--
Failed to launch browserLBR-IO-002128"check that a default browser is configured"

libra op

Command reference for `libra op`

libra pack-objects

Command reference for `libra pack-objects`

On this page

SynopsisDescriptionOptionsCommon CommandsHuman OutputStructured Output (JSON examples)Schema NotesURL Transformation RulesDesign RationaleWhy support direct URLs?Why not just use git web--browse?Why URL safety validation?Parameter Comparison: Libra vs Git vs jjError Handling