Muxy

Git

muxy.git reads and changes the project's repository. It runs on the project's server, so it works for remote projects too, and is available everywhere.

Calls take an optional options object. Pass project in it to target a project or worktree by ID; otherwise a tab uses its own project and other views use the current one.

const status = await muxy.git.status();
await muxy.git.stage({ paths: ["src/main.rs"] });
await muxy.git.commit({ message: "Fix the parser" });
await muxy.git.push();

Reads need git:read. Writes need git:write and ask the user first, except switching worktrees.

Reading

CallOptionsReturns
statuslocal{ branch, aheadBehind, defaultBranch, branches, stagedFiles, unstagedFiles, pullRequest }
difffilePath, staged, raw, lineLimit{ additions, deletions, truncated, rows }, or { diff, truncated } with raw
logmaxCount (100), skip[{ hash, shortHash, subject, authorName, authorDate, isMerge, parentHashes, refs }]
repoInfo{ root, gitDir, isWorktree, currentBranch }
currentBranchBranch name, or null
aheadBehind{ ahead, behind, hasUpstream }
branches, remoteBranchesBranch names
worktrees[{ path, branch, head, isBare, isDetached, isPrunable }]

Files in status look like { path, oldPath, status, isStaged, isUnstaged, isBinary, additions, deletions }. Diff rows look like { kind, oldLineNumber, newLineNumber, oldText, newText, text }, where kind is hunk, context, addition, or deletion.

Changing

CallOptions
stage, unstagepaths (empty means all)
discardpaths, untrackedPaths
commitmessage, stageAll. Returns { hash }
pushsetUpstream
pull
checkout, cherryPick, reverthash
init
branch.createname
branch.switchTobranch
branch.deletename, force
branch.deleteRemotebranch
tag.createname, hash

Worktrees

CallOptions
worktree.addpath, branch, createBranch, baseBranch. Returns the new folder
worktree.removepath, force. Refuses uncommitted changes unless force
worktree.switchToidentifier

Paths are relative to the project folder, or start with ~/ for the home folder.

Pull requests

Pull request calls use the gh CLI on the project's server.

CallOptions
pr.infoReturns the branch's pull request, or null
pr.numberReturns its number, or null
pr.listfilter (open, closed, merged, all), limit (100), checks
pr.diffnumber, lineLimit
pr.createtitle, body, baseBranch, draft
pr.mergenumber, method (merge, squash, rebase), deleteBranch (default true)
pr.close, pr.checkoutnumber
pr.checkoutWorktreenumber, path

A pull request looks like { number, url, title, author, headBranch, headOid, baseBranch, state, isDraft, updatedAt, mergeable, mergeStateStatus, isCrossRepository, checks }, where checks is { passing, failing, pending, total, status }.

muxy.gh.user() (needs gh:read) returns the signed-in GitHub user from the desktop computer's gh CLI, even when the project is remote.