Workspace CLI (ws)
English | δΈζ
ws is a command-line tool designed to solve the pain points of multi-repository microservice development. By leveraging Git Worktrees, ws helps you effortlessly manage multiple service repositories under isolated, feature-specific workspaces.
No more constantly stashing changes, checking out branches, or dealing with mixed-up local environments when switching between different tasks.
π Features
- Isolated Feature Workspaces: Group multiple related microservices into a single directory based on a feature branch.
- Git Worktree Powered: Fast and lightweight. No need to clone repositories multiple times.
- Interactive Service Resolution: Fuzzy search for service names; if multiple match, interactively pick the one you need.
- Auto-Sync: Easily synchronize your local feature branches with their remote tracking branches.
- CoW Cache Warm-up (macOS): Copy-on-write clone git-ignored codegen directories (e.g. Kitex's
kitex_gen) from the main repo into new worktrees β near-instant, near-zero extra disk.
- Self-Updating: Built-in update checker to ensure you are always using the latest version.
- Cross-Platform: Works on macOS, Linux, and Windows.
π¦ Installation
Option 1: Download Pre-compiled Binary (Recommended)
You can download the latest pre-compiled binaries for your operating system from the Releases page.
Option 2: Using go install
If you have Go installed (1.20+), you can install ws directly:
go install github.com/coegle/workspace_cli/cmd/ws@latest
βοΈ Configuration
Required
Before using ws, you need to tell it where your base repositories are located and where you want to create your feature workspaces.
# Set the directory where your main git clones live
ws config base_repos /path/to/your/main/repos
# Set the directory where new feature workspaces should be created
ws config base_ws /path/to/your/workspaces
By default, the configuration is stored in ~/.ws/config.yaml.
Optional
All of the following are optional β ws works out of the box with just the two settings above. See config.example.yaml for the full set (e.g. replace_slash, symlinks for sharing IDE configs across workspaces, and cow_dirs below).
CoW Cache Warm-up (macOS / APFS)
Some repos keep large git-ignored codegen outputs (e.g. Kitex's kitex_gen, Hertz's hertz_gen, or protobuf/gRPC generated gen/ dirs). Since these are ignored, git worktree add never checks them out, so every new worktree would have to regenerate them β slow and disk-hungry.
With cow_dirs, ws copy-on-write clones these directories from the main repo into each new worktree using APFS clonefile. The data blocks are shared with the main repo's copy, so it's near-instant and uses almost no extra disk.
# in ~/.ws/config.yaml
cow_dirs:
- kitex_gen
Notes:
- The donor is always the main repo (
base_repos/<service>/kitex_gen), so make sure you've run codegen there at least once.
- It's a pure cache/warm-up: cloned as-is with no IDL consistency check. If the worktree's IDL differs, just re-run codegen in the worktree.
- If the donor dir doesn't exist, the entry is silently skipped.
- Only works on the same APFS volume; cross-volume / non-APFS is skipped (never falls back to a full copy).
π οΈ Core Workflow
1. Create a Workspace & Add Services
Imagine you are working on a new feature called feat_login that requires modifying the user_service and auth_service.
# Syntax: ws add [-b base_branch] <feature_branch> <service1> <service2> ...
ws add feat_login user_service auth_service
This command will:
- Create a new directory
feat_login in your base_ws path.
- Create a git worktree for
user_service on the branch feat_login.
- Create a git worktree for
auth_service on the branch feat_login.
Tip: If you want to branch off from a specific branch (e.g., origin/develop), use the -b flag: ws add -b origin/develop feat_login user_service.
2. Open Workspace in IDE
Quickly open the entire feature workspace in your IDE (currently supports GoLand):
ws open feat_login
3. Sync Branches
When the base branch (e.g., master) has updates, you can quickly fast-forward your local branches (if they haven't diverged):
ws sync user_service
4. Remove a Service from Workspace
Done with user_service? Remove it from the workspace without affecting the main repository:
ws remove feat_login user_service
5. Destroy the Workspace
Once the feature is merged and done, clean up the entire workspace:
ws destroy feat_login
(If there are uncommitted changes, ws will prompt you before destroying).
π Self Update
ws checks for updates periodically. If a new version is available, it will prompt you.
You can also trigger an update manually:
ws update
π License
This project is licensed under the MIT License - see the LICENSE file for details.