Skip to main content

Git Workspace

@twonines/git-workspacev2026.07.22.1· 3d agoMODELS
01README

Local git operations model — clone, branch, read, commit, push. Designed for agent-driven development workflows where code changes are authored locally and pushed to a remote forge. Supports a configurable workspace layout (default: $HOME/{host}/{group}/{project}) and commit message format enforcement.

02Release Notes

Add forge ref fetching to the branch method. GitLab MR refs (merge-requests/N/head) and GitHub/Forgejo PR refs (pull/N/head) are now explicitly fetched and checked out in detached HEAD mode. Previously these refs were silently missed by the default fetch refspec, causing the method to fall through to creating a new branch from default. Output schema adds optional 'detached: true' field when on a forge ref.

03Models1
@twonines/git-workspacev2026.07.20.1mod.ts

Global Arguments

ArgumentTypeDescription
hoststringGit remote host (e.g. gitlab.example.com, codeberg.org). Used to construct clone URLs and workspace paths.
baseDir?stringBase directory for workspaces. Default: $HOME. Repos are placed at {baseDir}/{host}/{group}/{project}.
defaultBranch?stringDefault branch name (default: main). Used as the base for new branches.
commitFormat?stringCommit message format hint for the agent. Example: 'leading-verb, 50 char title, blank line, body explains why'.
protocol?enumClone protocol. 'ssh' (default) uses git@host:project.git; 'https' uses https://host/project.git.
fn ensure(project: string, localPath?: string, protocol?: enum, ref?: string)
Clone the repo if it doesn't exist locally, or fetch + pull if it does.
ArgumentTypeDescription
projectstringProject path (e.g. myorg/my-repo, team/infra-dns).
localPath?stringOverride the computed local path.
protocol?enumOverride the global clone protocol for this project.
ref?stringCheckout this branch/tag after clone or fetch instead of the default branch.
fn branch(project: string, branch: string, localPath?: string)
Switch to a branch. If it exists on the remote, tracks it.
ArgumentTypeDescription
projectstringProject path.
branchstringBranch name to switch to or create (e.g. feat/add-txt-record).
localPath?stringOverride the computed local path.
fn read_file(project: string, path: string, localPath?: string)
Read a file from the workspace. Run ensure first to clone.
ArgumentTypeDescription
projectstringProject path.
pathstringFile path relative to repo root.
localPath?stringOverride the computed local workspace path.
fn list_files(project: string, pattern?: string, localPath?: string)
List tracked files matching a pattern (via git ls-files).
ArgumentTypeDescription
projectstringProject path.
pattern?stringGlob pattern or directory (e.g. 'terraform/**/*.tf'). Default: all tracked files.
localPath?stringOverride the computed local workspace path.
fn commit(project: string, message: string, files?: array, amend?: boolean, localPath?: string)
Stage files and commit. Message should follow commitFormat if set.
ArgumentTypeDescription
projectstringProject path.
messagestringCommit message.
files?arrayFiles to stage (relative to repo root). Omit to stage all changes.
amend?booleanAmend the last commit instead of creating a new one. Default: false.
localPath?stringOverride the computed local workspace path.
fn push(project: string, force?: boolean, localPath?: string)
Push the current branch to origin with -u tracking.
ArgumentTypeDescription
projectstringProject path.
force?booleanForce push (--force-with-lease). Default: false.
localPath?stringOverride the computed local workspace path.
fn rm(project: string, files: array, localPath?: string)
Stage file deletions via git rm. Files are removed from the working
ArgumentTypeDescription
projectstringProject path.
filesarrayFiles to remove (relative to repo root).
localPath?stringOverride the computed local workspace path.
fn status(project: string, localPath?: string)
Show workspace status: current branch, clean/dirty, modified files, ahead/behind remote.
ArgumentTypeDescription
projectstringProject path.
localPath?stringOverride the computed local workspace path.
fn diff(project: string, ref?: string, nameOnly?: boolean, localPath?: string)
Show diff output. Defaults to working tree diff; provide a ref to diff against (e.g. origin/main, HEAD~3).
ArgumentTypeDescription
projectstringProject path.
ref?stringRef to diff against (e.g. origin/main, HEAD~1). Default: working tree diff.
nameOnly?booleanOnly list changed file names, no patch content. Default: false.
localPath?stringOverride the computed local workspace path.

Resources

workspace(1h)— State of a cloned/updated workspace
branch(1h)— Created branch metadata
file(30m)— Contents of a file read from the workspace
files(30m)— File listing from the workspace
commit(infinite)— Result of a git commit
push(infinite)— Result of a git push
rm(30m)— Result of staged file removals
status(5m)— Current workspace status (branch, clean/dirty, ahead/behind)
diff(10m)— Diff output between refs or working tree
04Previous Versions9
2026.07.21.1

Modified 1 models

2026.07.20.1

Add rm method: stage file deletions via git rm for subsequent commit.

Modified 1 models

2026.07.16.1
2026.07.15.3
2026.07.15.2

Modified 1 models

2026.07.15.1
2026.07.14.3

Fix instance name sanitization (slashes in project paths and branch names caused writeResource failures). Add test coverage for the bug. 12 tests passing.

2026.07.14.2

Auto-detects default branch from remote HEAD. Sanitized resource instance names. Generic docs.

2026.07.14.1yanked
05Stats
A
100 / 100
Downloads
12
Archive size
15.8 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License declared1/1earned
  • Verified public repository2/2earned
06Platforms
07Labels