src/commands/ module contains wit’s 75+ CLI commands. Commands are implemented using Commander.js for argument parsing and Ink for terminal UI.
Overview
Key Files
| File | Purpose |
|---|---|
cli.ts | CLI entry point, command registration |
commands/index.ts | Command exports |
commands/smart-status.ts | The zero command (wit with no args) |
commands/command-help.ts | Help system |
Command Categories
Porcelain (User-Facing)
Standard Git commands with improvements:| Command | File | Description |
|---|---|---|
init | init.ts | Initialize repository |
add | add.ts | Stage files |
commit | commit.ts | Create commit |
status | status.ts | Show status |
log | log.ts | Show history |
branch | branch.ts | Branch operations |
checkout | checkout.ts | Checkout branches/files |
switch | switch.ts | Switch branches (with auto-stash) |
merge | merge.ts | Merge branches |
diff | diff.ts | Show differences |
restore | restore.ts | Restore files |
Quality of Life
Commands that make Git easier:| Command | File | Description |
|---|---|---|
amend | amend.ts | Amend last commit |
wip | wip.ts | Quick WIP commit |
uncommit | uncommit.ts | Undo last commit (keep changes) |
undo | undo.ts | Journal-based undo |
cleanup | cleanup.ts | Clean merged branches |
fixup | fixup.ts | Create fixup commits |
snapshot | snapshot.ts | Quick snapshots |
blame | blame.ts | Annotate file history |
stats | stats.ts | Repository statistics |
History Rewriting
| Command | File | Description |
|---|---|---|
cherry-pick | cherry-pick.ts | Apply commits |
rebase | rebase.ts | Rebase branches |
revert | revert.ts | Revert commits |
reset | reset.ts | Reset HEAD |
bisect | bisect.ts | Binary search for bugs |
Remote Operations
| Command | File | Description |
|---|---|---|
clone | clone.ts | Clone repository |
fetch | fetch.ts | Fetch from remote |
pull | pull.ts | Pull changes |
push | push.ts | Push changes |
remote | remote.ts | Manage remotes |
Plumbing (Low-Level)
Internal commands for scripting:| Command | File | Description |
|---|---|---|
cat-file | cat-file.ts | Show object contents |
hash-object | hash-object.ts | Compute hash |
ls-files | ls-files.ts | List tracked files |
ls-tree | ls-tree.ts | List tree contents |
rev-parse | rev-parse.ts | Parse revisions |
update-ref | update-ref.ts | Update references |
symbolic-ref | symbolic-ref.ts | Manage symbolic refs |
for-each-ref | for-each-ref.ts | Iterate refs |
show-ref | show-ref.ts | List references |
fsck | fsck.ts | Verify repository |
gc | gc.ts | Garbage collection |
reflog | reflog.ts | Reference log |
Platform Commands
wit-specific platform features:| Command | File | Description |
|---|---|---|
serve | serve.ts | Start wit server |
pr | pr.ts | Pull request management |
issue | issue.ts | Issue tracking |
review | review.ts | Code review |
stack | stack.ts | Stacked diffs |
cycle | cycle.ts | Sprint management |
project | project.ts | Project management |
inbox | inbox.ts | Notification inbox |
collaborator | collaborator.ts | Team management |
token | token.ts | Access tokens |
merge-queue | merge-queue.ts | Merge queue |
ci | ci.ts | CI/CD operations |
dashboard | dashboard.ts | Project dashboard |
wrapped | wrapped.ts | Activity insights |
journal | journal.ts | Documentation |
AI Commands
| Command | File | Description |
|---|---|---|
ai | ai.ts | AI assistant (commit, review, explain) |
agent | agent.ts | Interactive AI agent |
plan | plan.ts | AI planning |
search | search.ts | Semantic search |
Advanced
| Command | File | Description |
|---|---|---|
stash | stash.ts | Stash changes |
tag | tag.ts | Tag management |
clean | clean.ts | Remove untracked files |
show | show.ts | Show objects |
worktree | worktree.ts | Worktree management |
submodule | submodule.ts | Submodule operations |
scope | scope.ts | Monorepo scopes |
github | github.ts | GitHub integration |
github-import | github-import.ts | Import from GitHub |
Command Implementation
Basic Structure
With Terminal UI
With API Client
With AI Agent
CLI Entry Point
The Zero Command
Runningwit with no arguments shows intelligent status:
Subcommand Patterns
Subcommands with Commander
AI Subcommands
Terminal UI Components
wit uses Ink for rich terminal interfaces:Status Display
Interactive Selection
Progress Indicators
Error Handling
Commands provide helpful error messages:JSON Output
Most commands support--json for scripting:
Extension Points
Adding a New Command
- Create handler in
src/commands/:
- Register in CLI:
- Export from index: