Skip to content

machine-machine/m2-cmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

m2-cmd

m2-cmd is the headless Ornith-backed command agent.

Welcome to m2-cmd: your lazy, slightly suspicious but mostly reliable unix sidekick. It reads your sentence, whispers a single command to the terminal, and runs it (unless it smells like chaos).

If you treat it like a caffeinated intern with good manners, it is fast, polite, and rarely drops things in /dev/null unless you ask.

Quick start (very easy)

Type:

m2 "list files in current directory"

It runs:

ls

Type:

m2 "delete logs in /tmp"

It prints a colorful warning and asks before executing destructive commands.

Type:

m2 --dry-run "show current directory files"

It prints the generated command without running it.

Install (one command, no checkout needed)

curl -fsSL https://github.com/machine-machine/m2-cmd/raw/refs/heads/main/install-m2.sh | bash -s -- --add-path

This installs a m2 command that turns your prompt into safe shell commands.

Works in macOS (zsh default) and Linux shells. The --add-path flag adds the install directory to your shell profile for future shells.

If you do not want the installer to edit your shell profile, run:

curl -fsSL https://github.com/machine-machine/m2-cmd/raw/refs/heads/main/install-m2.sh | bash -s --

If a CDN serves a stale raw GitHub file, this cache-busting variant is equivalent:

curl -fsSL 'https://raw.githubusercontent.com/machine-machine/m2-cmd/main/install-m2.sh?cachebust=1' | bash -s -- --add-path

If you already have the repo checked out:

cd /home/m2spark1/tools/m2-cmd
./install-m2.sh
# or
./tools/m2-cmd/install.sh

# If PATH wasn't updated, do:
./tools/m2-cmd/install.sh --add-path

Update / force reinstall (one command)

Use this when you already installed m2 and want to pull the latest installer + agent files, or if your local copy got stuck on stale raw GitHub content:

rm -rf "$HOME/.local/share/m2-cmd" && M2_CMD_REMOTE_BASE_URL="https://github.com/machine-machine/m2-cmd/raw/refs/heads/main" bash -c 'curl -fsSL "$M2_CMD_REMOTE_BASE_URL/install-m2.sh" | bash -s -- --add-path'

Then either open a new shell or run:

export PATH="$HOME/.local/bin:$PATH"

Verify the installed copy:

m2 --help

Remove

./tools/m2-cmd/uninstall.sh --yes

If you want to keep captured state files:

./tools/m2-cmd/uninstall.sh --yes --keep-state

Notes

  • Uses model ornith-coding by default
  • Uses endpoint http://192.168.31.99:4000/v1/chat/completions
  • Blocks destructive commands (rm, mv, dd, etc.) by default, prints a colorful warning to stderr, asks for y/N confirmation in interactive terminals, and keeps stdout pipe-friendly
  • Preserves complete multi-line shell snippets, heredocs, and composed pipelines when a task needs more than one command
  • For complex tasks, asks the model to decompose the generated snippet into comment-labeled sections and then prints the complete assembled snippet before execution
  • Uses continuation requests for truncated snippets, keeps a smart line-aware sliding context (LAST_LINE, LAST_CHARS, and a tail window), de-duplicates repeated overlap, and writes the in-progress snippet to ~/.config/m2-agent/last-generated-snippet.sh.tmp for recovery/debugging
  • Baseline host context is saved to ~/.config/m2-agent/baseline-context.json on install

About

A command for unix that generates commands

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors