Skip to content

Latest commit

 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Llamalias

AI-powered shell shortcuts for local Ollama workflows

Llamalias is a modular shell library that supercharges your terminal with local LLM capabilities. By wrapping Ollama's HTTP API into modular shell functions prefixed with ai-, it provides instant development shortcuts for code auditing, commit message generation, unit testing, log diagnosis, and interactive terminal chat—with zero cloud dependencies and zero API fees.

Load the Library into Your Shell

To automatically load these commands whenever you open a terminal, source the file in your ~/.bashrc:

echo "source ${LLAMALIAS_DIR}/llamalias" >> ~/.bashrc
source ~/.bashrc

Command Reference

Click here to see the command reference cheat sheet

How to Switch Models on the Fly

Temporary Switch (Current Shell Session Only):

ai-model llama3.2:3b

One-Off Command Override:

AI_MODEL="qwen2.5-coder:3b-instruct-q4_K_M" ai-commit

Permanent Default: Edit export AI_MODEL="..." at the top of ${LLAMALIAS_DIR}/config/settings.sh.

Token Performance Toggle

Ensure jq is installed:

sudo apt install -y jq

Enable token performance metrics:

ai-perf off   # Mutes performance bar
ai-perf on    # Re-enables performance bar

What the Metrics Measure

When AI_SHOW_PERF is enabled, every ai-* command appends a performance summary line at the bottom of its output:

[Perf] 2.14s total | Gen: 85 tok (39.72 tok/s) | Prompt: 312 tok (145.80 tok/s)
Metric Description
total End-to-end wall clock time in seconds.
Gen tok Total output tokens generated by the LLM.
tok/s (Gen) Tokens generated per second (measures model inference speed).
Prompt tok Input prompt + context token volume passed to Ollama.
tok/s (Prompt) Prompt prefill rate per second (measures context evaluation speed).

Compaction Filter & Toggle

The compaction filter strips blank lines, indentation fluff, and standalone comments from incoming piped code/text before it gets formatted into the JSON payload.

With Compaction OFF:

ai-compact off
cat main.py | ai-review
# Output: [Perf] 3.10s total | Gen: 92 tok | Prompt: 680 tok

With Compaction ON:

ai-compact on
cat main.py | ai-review
# Output: [Perf] 1.85s total | Gen: 90 tok | Prompt: 340 tok (50% context reduction)

Dependency-free Python AST Skeletonizer

How It Works Under the Hood

When you pipe commands:

  1. ai-skeleton parses the Python AST and strips method bodies.
  2. The skeletonized interface streams into the next ai-* command as stdin.
  3. The downstream command passes that slimmed-down context directly to Ollama.

Practical Chaining Recipes

1. High-Level Architecture Review

Review code structure, class design, or potential anti-patterns without flooding the context window with implementation details:

cat main.py | ai-skeleton | ai-review

2. Multi-File Codebase Mapping

Concatenate multiple Python files into a single skeleton before asking for an architectural breakdown:

cat models.py services.py controllers.py | ai-skeleton | ai-explain

3. Generate Unit Test Stubs

Ask Ollama to write test suites based purely on function signatures, type hints, and docstrings:

cat api/routes.py | ai-skeleton | ai-test

4. Custom Targeted Prompts (ai-ask)

Pass a skeletonized structure along with an explicit targeted question:

cat database.py | ai-skeleton | ai-ask "Suggest how to refactor this class hierarchy to use the Repository pattern."

5. Documenting Interfaces (ai-doc)

Ensure public APIs have thorough docstrings without distracting the LLM with method internals:

ai-skeleton legacy_service.py | ai-doc

Pro Tip: Bypassing AI_COMPACT

Explicitly chaining ai-skeleton | ai-... gives you granular control. Even if you turn auto-compaction off globally (ai-compact off), manually piping ai-skeleton lets you selectively skeletonize large files only when you need to:

ai-compact off

# Full code sent (detailed review)
cat small_utils.py | ai-review

# Explicitly skeletonized (lightweight review)
cat  huge_monolith.py | ai-skeleton | ai-review

License

Llamalias is licensed under the terms of the MIT License.

About

AI-powered shell shortcuts for local Ollama workflows

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages