diff --git a/README.md b/README.md index 3cce76e..5b06444 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # magic-code -**Open-source TUI agentic AI coding agent.** Built in Rust. Fast. Multi-provider. +[![CI](https://github.com/kienbui1995/mc-code/actions/workflows/ci.yml/badge.svg)](https://github.com/kienbui1995/mc-code/actions/workflows/ci.yml) +[![Security](https://github.com/kienbui1995/mc-code/actions/workflows/security.yml/badge.svg)](https://github.com/kienbui1995/mc-code/actions/workflows/security.yml) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![Release](https://img.shields.io/github/v/release/kienbui1995/mc-code)](https://github.com/kienbui1995/mc-code/releases) +[![crates.io](https://img.shields.io/crates/v/magic-code.svg)](https://crates.io/crates/magic-code) + +**Open-source TUI agentic AI coding agent.** Built in Rust. Fast. Multi-provider. Self-hostable. ``` ┌─ magic-code ████████░░ 62% ──────────────────────────────┐ @@ -32,6 +38,11 @@ curl -fsSL https://raw.githubusercontent.com/kienbui1995/mc-code/main/install.sh | sh ``` +### Via cargo +```bash +cargo install magic-code +``` + ### Download binary Pre-built binaries for Linux (x86_64, aarch64) and macOS (x86_64, aarch64): ```bash diff --git a/examples/batch-review.sh b/examples/batch-review.sh new file mode 100755 index 0000000..e35bc70 --- /dev/null +++ b/examples/batch-review.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Batch code review: review multiple files +# Usage: ./batch-review.sh src/*.rs + +TMPFILE=$(mktemp) +for file in "$@"; do + echo "Review $file for bugs, security issues, and improvements. Be specific about line numbers." >> "$TMPFILE" +done + +magic-code --yes --json --batch "$TMPFILE" +rm "$TMPFILE" diff --git a/examples/ci-fix.sh b/examples/ci-fix.sh new file mode 100755 index 0000000..5d48322 --- /dev/null +++ b/examples/ci-fix.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# CI/CD: Auto-fix failing tests with magic-code +# Usage: ./ci-fix.sh +set -e + +echo "Running tests..." +if cargo test --workspace 2>&1 | tail -5 | grep -q "FAILED"; then + echo "Tests failed. Asking magic-code to fix..." + magic-code --yes --json \ + "The tests are failing. Read the test output, find the bug, and fix it. Run tests again to verify." \ + -o fix-result.json + + if [ $? -eq 0 ]; then + echo "Fix applied. Re-running tests..." + cargo test --workspace + else + echo "magic-code could not fix the issue." + exit 1 + fi +else + echo "All tests pass." +fi diff --git a/examples/config-selfhosted.toml b/examples/config-selfhosted.toml new file mode 100644 index 0000000..1c25cb6 --- /dev/null +++ b/examples/config-selfhosted.toml @@ -0,0 +1,17 @@ +# Self-hosted config: Qwen 3.5 via LiteLLM (zero cost) +# Copy to .magic-code/config.toml + +[default] +model = "qwen3.5-9b" +provider = "litellm" +base_url = "http://localhost:4000" +max_tokens = 4096 +notifications = false + +# Memory +[memory] +max_facts = 100 + +# Managed agents (disabled for small models) +[managed_agents] +enabled = false diff --git a/examples/demo.sh b/examples/demo.sh new file mode 100755 index 0000000..5c33780 --- /dev/null +++ b/examples/demo.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Record a demo with: asciinema rec demo.cast +# Convert to GIF with: agg demo.cast demo.gif +# Or use: svg-term --in demo.cast --out demo.svg + +echo "=== magic-code demo ===" +echo "" +echo "# 1. Quick fix" +echo '$ magic-code "fix the typo in src/main.rs"' +echo "" +sleep 1 + +echo "# 2. Self-hosted (zero cost)" +echo '$ magic-code --provider ollama --model qwen3.5:9b "add error handling"' +echo "" +sleep 1 + +echo "# 3. CI/CD integration" +echo '$ magic-code --yes --json "fix failing tests" -o result.json' +echo "" +sleep 1 + +echo "# 4. Batch processing" +echo '$ magic-code --yes --batch tasks.txt' +echo "" +sleep 1 + +echo "# 5. NDJSON streaming" +echo '$ magic-code --ndjson "explain auth.rs" | jq .type' +echo "" + +echo "=== Install ===" +echo "curl -fsSL https://raw.githubusercontent.com/kienbui1995/mc-code/main/install.sh | sh" diff --git a/examples/stream-events.sh b/examples/stream-events.sh new file mode 100755 index 0000000..9c018c3 --- /dev/null +++ b/examples/stream-events.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# NDJSON streaming: pipe magic-code events to a web app +# Usage: ./stream-to-webapp.sh "your prompt" + +magic-code --yes --ndjson "$1" | while IFS= read -r line; do + type=$(echo "$line" | jq -r '.type // empty' 2>/dev/null) + case "$type" in + text) + echo "$line" | jq -r '.content' ;; + tool_call) + echo "[TOOL] $(echo "$line" | jq -r '.name')" ;; + tool_output) + echo "[OUTPUT] $(echo "$line" | jq -r '.content' | head -5)" ;; + esac +done diff --git a/mc/Cargo.toml b/mc/Cargo.toml index 44b32d9..0e1f189 100644 --- a/mc/Cargo.toml +++ b/mc/Cargo.toml @@ -10,6 +10,8 @@ publish = false rust-version = "1.75" repository = "https://github.com/kienbui1995/mc-code" description = "Open-source TUI agentic AI coding agent" +keywords = ["ai", "coding", "agent", "tui", "llm"] +categories = ["command-line-utilities", "development-tools"] [workspace.lints.rust] unsafe_code = "forbid"