Skip to main content
Complete reference for the @morphllm/morph-git-sdk TypeScript SDK.

GitMorph (Client)

The main client. Handles authentication and provides access to repositories.

Constructor Options

repo(slug)

Returns a GitMorphRepo handle for the given repository.

getRepositoryInfo(slug)

Fetch metadata for a repository.
Returns a Repository object.

mirror(source, options?)

Mirror a repository from GitHub, GitLab, or another Gitea instance.
MirrorOptions: Returns { repository: Repository, repo: GitMorphRepo }.

grepAll(options)

Search code across all accessible repositories.
GrepAllOptions: Returns { matches: GrepAllMatch[], total: number }.

GitMorphRepo

Per-repository operations. Obtained via gm.repo("owner/name").

readFile(path, options?)

Read a file from the repository. Optionally read only specific line ranges.
ReadFileOptions: Returns { path, content, totalLines, lines? }.

grep(options)

Search code within the repository using server-side search.
GrepOptions: Returns { matches: GrepMatch[], total: number }. Each GrepMatch contains:
  • path - file path
  • lineNumber - line number
  • lineContent - the matching line (plain text)
  • submatches - array of { match, startOffset, endOffset } within the line

getFileContents(paths, options?)

Batch-read multiple files in a single request.
Returns an array of FileContentEntry | null (null for files that don’t exist). Content is automatically decoded from base64.

glob(options)

Find files matching glob patterns.
GlobOptions: Returns { entries: TreeEntry[], truncated: boolean }.

listDir(options?)

List directory contents.
ListDirOptions: Returns { entries: ListDirEntry[], truncated: boolean }.

listBranches(options?)

List repository branches.
Returns Branch[] with name, commit, and protected fields.

listCommits(options?)

List commits with optional filters.
ListCommitsOptions:

Error Handling

The SDK throws typed errors for different failure modes:

Types

Repository

User


CLI Reference

The gm CLI covers repositories, issues, PRs, releases, workflows, secrets, and more. It follows the same patterns as GitHub’s gh CLI.

Repositories

Issues

Pull Requests

Workflows & Runs

Releases

Secrets & Variables

Raw API

Configuration

Config is stored at ~/.config/gm/config.json (or $GM_CONFIG_DIR/config.json).