MergeGate: deterministic execution protocol for AI-assisted development and the execution layer for GitNexus-style code intelligence https://github.com/ShunsukeHayashi/mergegate
Find a file
林 駿甫 (Shunsuke Hayashi) f5fe5f36cf [調査] L-Step/Funnel/Analytics 利用状況レポート (#85)
Polaris (miyabi gate) で管理した調査タスク。
タグ251個、4段ファネル構造、自動化3件を確認。
改善点5件を特定(ログ不在、KPI統合、Polaris連携等)。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 09:44:24 +09:00
.claude [追加] Claude Code hooks: ファイル編集前にロック自動チェック (#73 関連) 2026-04-10 08:58:58 +09:00
.codex [整備] Codex + Claude Code スキルを強化: バイナリパス明記 + 全コマンド例 + init 2026-04-10 09:07:49 +09:00
.github feat(ci): add Copilot full automation pipeline 2026-03-29 21:48:22 +09:00
.miyabi feat: Add hooks, workflow, MCP support and core modules 2025-11-22 23:37:14 +09:00
autorun [文書] Sprint 3 に Web + TUI ダッシュボードを追加 2026-04-10 06:40:10 +09:00
crates [追加] miyabi gate init: Git/GitHub チェック + .gitignore 自動更新 (#75) 2026-04-10 09:28:47 +09:00
docs [調査] L-Step/Funnel/Analytics 利用状況レポート (#85) 2026-04-10 09:44:24 +09:00
project_memory [文書] Phase C 修正計画 + GitHub Issue 6件起票 + ラベル設定 2026-04-10 06:36:57 +09:00
scripts [追加] Claude Code hooks: ファイル編集前にロック自動チェック (#73 関連) 2026-04-10 08:58:58 +09:00
skills [整備] MiyabiGate スキル: miyabi-gate と miyabi の区別を明記 2026-04-10 09:23:57 +09:00
.env.example chore: Initialize Miyabi project with full planning 2025-11-22 17:45:08 +09:00
.gitattributes [整備] IP保護強化: .gitattributes + Copilot学習除外 + シークレットスキャン 2026-04-10 07:59:38 +09:00
.gitignore [追加] DTP (Deterministic Task Protocol) 設計文書・指示書を移植 2026-04-10 01:07:32 +09:00
.miyabi.yml feat: Add config system, agent mode, and session management 2025-11-22 22:22:11 +09:00
.miyabirules feat: Add hooks, workflow, MCP support and core modules 2025-11-22 23:37:14 +09:00
AGENTS.md [整備] Polaris 運用設定: CLAUDE.md + Codex + グローバルルール + dream cron 2026-04-10 08:15:24 +09:00
Cargo.lock [追加] ドリーミング: event log → 学び抽出 (#59) 2026-04-10 07:29:03 +09:00
Cargo.toml [整備] OpenSSL 依存を排除: rustls-tls + vendored-openssl で全ノード対応 2026-04-10 08:24:42 +09:00
CLAUDE.md [整備] Polaris 運用設定: CLAUDE.md + Codex + グローバルルール + dream cron 2026-04-10 08:15:24 +09:00
GOALS.md feat: Add config system, agent mode, and session management 2025-11-22 22:22:11 +09:00
LICENSE [整備] ライセンスを MIT → BSL 1.1 に変更 2026-04-10 07:50:40 +09:00
MIYABI.md feat: Add hooks, workflow, MCP support and core modules 2025-11-22 23:37:14 +09:00
README.github.md docs: Add project documentation and Miyabi config 2025-11-22 22:23:43 +09:00
README.md docs: Add 60-second setup and troubleshooting to README 2025-11-23 01:51:38 +09:00

Miyabi CLI

A powerful terminal-based AI assistant with TUI (Terminal User Interface) built in Rust.

60-Second Setup

# 1. Clone and build
git clone https://github.com/ShunsukeHayashi/miyabi-cli-standalone.git
cd miyabi-cli-standalone
cargo build --release

# 2. Set API key
export ANTHROPIC_API_KEY="sk-ant-..."

# 3. Run
./target/release/miyabi tui

That's it! Start chatting with Claude in your terminal.


Features

  • Interactive TUI - Beautiful terminal interface with markdown rendering
  • Chat Mode - Conversational AI assistant
  • Agent Mode - Autonomous task execution with tool approval
  • Session Management - Persist and resume conversations
  • Configurable - TOML-based configuration
  • Extended Thinking - Support for Claude 4.5+ extended thinking

Installation

Prerequisites

  • Rust 1.70+
  • Anthropic API key

Build from Source

git clone https://github.com/ShunsukeHayashi/miyabi-cli-standalone.git
cd miyabi-cli-standalone
cargo build --release

Binary will be at target/release/miyabi.

Quick Start

1. Generate Config

./target/release/miyabi init

This creates ~/.miyabi/config.toml.

2. Set API Key

Edit ~/.miyabi/config.toml:

[api]
api_key = "sk-ant-..."

Or use environment variable:

export ANTHROPIC_API_KEY="sk-ant-..."

3. Launch TUI

./target/release/miyabi tui
# or simply
./target/release/miyabi

Usage

CLI Commands

miyabi                    # Start TUI (default)
miyabi tui                # Start TUI explicitly
miyabi status             # Show status
miyabi init               # Generate default config
miyabi sessions           # List sessions
miyabi sessions -d <id>   # Delete session
miyabi sessions -e <id>   # Export session to JSON
miyabi version            # Show version info
miyabi agent <prompt>     # Run autonomous agent

CLI Options

miyabi --model claude-sonnet-4-5-20250929    # Override model
miyabi --max-tokens 16384                     # Override max tokens
miyabi --thinking                             # Enable extended thinking
miyabi --config /path/to/config.toml          # Custom config
miyabi --session <id>                         # Resume session

TUI Keybindings

Key Action
Enter Send message
Ctrl+P Command palette
F1 Help
Esc Close overlay / Cancel
Ctrl+C Quit
j/k Scroll down/up
Page Up/Down Page scroll

Configuration

Config file: ~/.miyabi/config.toml

[api]
api_key = "sk-ant-..."                        # Anthropic API key
model = "claude-sonnet-4-5-20250929"          # Model to use
max_tokens = 8192                             # Max response tokens
thinking = false                              # Extended thinking
system_prompt = "You are a helpful assistant" # System prompt
timeout_secs = 120                            # Request timeout
max_retries = 3                               # Retry attempts

[ui]
show_sidebar = false      # Show sidebar
show_status_bar = true    # Show status bar
show_breadcrumb = true    # Show breadcrumb
theme = "tokyo-night"     # Color theme
vim_mode = false          # Vim keybindings
show_line_numbers = true  # Line numbers in code

[session]
auto_save = true          # Auto-save sessions
auto_save_interval = 30   # Save interval (seconds)
max_sessions = 100        # Max stored sessions

[tools]
enable_bash = true        # Enable bash tool
enable_file_tools = true  # Enable file read/write
enable_search_tools = true # Enable glob/grep
auto_approve_low_risk = false # Auto-approve safe tools
bash_timeout = 120        # Bash command timeout

Environment Variables

Override config with environment variables:

ANTHROPIC_API_KEY=...     # API key
MIYABI_MODEL=...          # Model name
MIYABI_MAX_TOKENS=...     # Max tokens
MIYABI_THINKING=true      # Enable thinking

Agent Mode

Run autonomous tasks with tool execution:

# Basic usage
miyabi agent "Create a hello world Python script"

# With options
miyabi agent "Refactor the utils module" \
  --max-iterations 20 \
  --auto-approve \
  --system "You are an expert Rust developer"

Agent mode features:

  • Autonomous tool execution (bash, file operations, search)
  • Approval workflow for risky operations
  • Iteration limits for safety
  • JSON output format option

Core Library Features

The miyabi-core crate provides powerful utilities for building AI applications.

Git Utilities

use miyabi_core::{find_git_root, get_current_branch, is_in_git_repo};

// Find repository root
let root = find_git_root()?;

// Get current branch
let branch = get_current_branch(&root)?;

// Check if in git repo
if is_in_git_repo(&path) {
    println!("In a git repository");
}

Logger System

use miyabi_core::{init_logger, LogLevel, LogFormat};

// Initialize with defaults
init_logger();

// Or with custom config
use miyabi_core::LoggerConfig;
let config = LoggerConfig {
    level: LogLevel::Debug,
    format: LogFormat::Json,
    ..Default::default()
};
init_logger_with_config(config);

Retry with Backoff

use miyabi_core::{retry_with_backoff, BackoffRetryConfig};

let config = BackoffRetryConfig::default();
let result = retry_with_backoff(config, || async {
    // Your operation that might fail
    make_api_call().await
}).await?;

Circuit Breaker

use miyabi_core::{CircuitBreaker, CircuitState};

let breaker = CircuitBreaker::default();

let result = breaker.call(|| {
    Box::pin(async {
        // Your operation
        Ok::<_, std::io::Error>(())
    })
}).await;

// Check state
match breaker.state().await {
    CircuitState::Closed => println!("Normal operation"),
    CircuitState::Open => println!("Circuit open - blocking calls"),
    CircuitState::HalfOpen => println!("Testing recovery"),
}

Rules System (.miyabirules)

Support for project-specific rules via .miyabirules files:

# .miyabirules
version: 1
rules:
  - name: "no-unwrap"
    pattern: ".unwrap()"
    suggestion: "Use ? operator or proper error handling"
    file_extensions: ["rs"]
    severity: "warning"

agent_preferences:
  codegen:
    style: "functional"
    error_handling: "result"
use miyabi_core::{RulesLoader, MiyabiRules};

let loader = RulesLoader::new(project_root);
let rules = loader.load_or_default()?;

// Get rules for a file
let applicable = rules.rules_for_file(Path::new("src/main.rs"));

Cache System

use miyabi_core::{create_llm_cache, create_api_cache, LLMCacheKey};

// LLM response cache (1 hour TTL)
let cache = create_llm_cache();
let key = LLMCacheKey::new("prompt", "model", Some(0.7));

cache.insert(key.clone(), "response".to_string()).await;
let cached = cache.get(&key).await;

// API cache (30 min TTL)
let api_cache = create_api_cache();

Plugin System

use miyabi_core::{Plugin, PluginManager, PluginMetadata, PluginContext, PluginResult};
use anyhow::Result;

struct MyPlugin;

impl Plugin for MyPlugin {
    fn metadata(&self) -> PluginMetadata {
        PluginMetadata {
            name: "my-plugin".to_string(),
            version: "1.0.0".to_string(),
            description: Some("My custom plugin".to_string()),
            author: None,
        }
    }

    fn init(&mut self) -> Result<()> {
        Ok(())
    }

    fn execute(&self, ctx: &PluginContext) -> Result<PluginResult> {
        Ok(PluginResult {
            success: true,
            message: Some("Done".to_string()),
            data: None,
        })
    }
}

// Register and execute
let manager = PluginManager::new();
manager.register(Box::new(MyPlugin))?;
let result = manager.execute("my-plugin", &PluginContext::default())?;

Feature Flags

use miyabi_core::{FeatureFlagManager, FeatureFlag};

let flags = FeatureFlagManager::new();

// Simple flag
flags.set_flag("new_feature", true);

if flags.is_enabled("new_feature") {
    // Use new feature
}

// With rollout percentage
flags.set_flag_with_options(
    "beta_feature",
    true,
    Some("Beta testing".to_string()),
    Some(0.5), // 50% rollout
);

// Load from config
use std::collections::HashMap;
let mut config = HashMap::new();
config.insert("flag1".to_string(), true);
flags.load_from_map(config);

Project Structure

miyabi-cli-standalone/
├── crates/
│   ├── miyabi-cli/         # CLI entry point
│   ├── miyabi-core/        # Core library
│   │   ├── agent.rs        # Agent system
│   │   ├── anthropic.rs    # Anthropic API client
│   │   ├── cache.rs        # TTL cache system
│   │   ├── config.rs       # Configuration
│   │   ├── error_policy.rs # Circuit breaker
│   │   ├── feature_flags.rs # Feature flag management
│   │   ├── git.rs          # Git utilities
│   │   ├── logger.rs       # Logging system
│   │   ├── plugin.rs       # Plugin system
│   │   ├── retry.rs        # Retry with backoff
│   │   ├── rules.rs        # .miyabirules support
│   │   ├── session.rs      # Session management
│   │   ├── tools.rs        # Built-in tools
│   │   └── ...
│   └── miyabi-tui/         # TUI implementation
│       ├── app.rs          # Main application
│       ├── views.rs        # UI views
│       └── ...
├── .miyabi/                # Local config
├── Cargo.toml              # Workspace config
└── README.md

Development

Build

cargo build              # Debug build
cargo build --release    # Release build

Test

cargo test --all         # Run all tests

Lint

cargo clippy --all-targets -- -D warnings
cargo fmt --all --check

Models

Supported models:

  • claude-sonnet-4-5-20250929 (default)
  • claude-haiku-4-5-20251001
  • claude-sonnet-4-20250514

Troubleshooting

Common Issues

"API key not found"

# Check if environment variable is set
echo $ANTHROPIC_API_KEY

# Or add to config file
vim ~/.miyabi/config.toml
# [api]
# api_key = "sk-ant-..."

"Device not configured" error on TUI start

This usually means the terminal doesn't support the required features. Try:

# Use a different terminal emulator (iTerm2, Alacritty, etc.)
# Or run with explicit terminal type
TERM=xterm-256color ./target/release/miyabi tui

Build errors

# Make sure Rust is up to date
rustup update

# Clean and rebuild
cargo clean
cargo build --release

Session not saving

# Check permissions on sessions directory
ls -la ~/.miyabi/sessions/

# Create if missing
mkdir -p ~/.miyabi/sessions

Debug Mode

For verbose logging:

RUST_LOG=debug ./target/release/miyabi tui

Getting Help

License

MIT


Built with Rust, Ratatui, and Claude API.