1
0

rewrite: new aishell concept - split UI with auto command detection

This commit is contained in:
ai
2026-02-26 11:45:39 +00:00
parent bd060a5ad0
commit 335cda5ef9
2 changed files with 86 additions and 189 deletions

215
README.md
View File

@@ -1,177 +1,66 @@
# aishell
**AI-powered shell automation tool** - A generic alternative to Claude Code
aiosのシェル。OSの起動と同時に起動し、AIとの対話がデフォルトのインターフェースになる。
## Overview
## コンセプト
aishellは、AIがシェルを操作するための汎用的なツールです。Claude Codeのような機能を、より柔軟で拡張可能な形で提供します。
従来のOS: 起動 → shell → 人間がコマンドを打つ
aios: 起動 → aishell → 人間はAIと会話する
**主な特徴:**
- **マルチLLMプロバイダー対応**: OpenAI、Claude、ローカルLLMgpt-oss等
- **Function Calling**: LLMがツールを直接呼び出してシェルを操作
- **MCPサーバー**: Claude Desktopとの連携も可能
- **AIOS統合**: aigptと組み合わせてAIによるOS管理を実現
aishellはshellの置き換えではない。shellを内包したAIインターフェース。
## Installation
## UI
```bash
# Rust環境が必要
cargo build --release
# バイナリをインストール
cargo install --path .
```
## Usage
### 1. 対話型シェル (Interactive Shell)
```bash
# OpenAI互換APIを使用
export OPENAI_API_KEY="your-api-key"
aishell shell
# 別のモデルを指定
aishell shell -m gpt-4o
# gpt-ossなどのOpenAI互換サーバーを使用
export OPENAI_BASE_URL="http://localhost:8080/v1"
aishell shell
```
**使用例:**
```
aishell> List all Rust files in src/
[Executing tool: list]
src/main.rs
src/lib.rs
...
aishell> Create a new file hello.txt with "Hello, World!"
[Executing tool: write]
Successfully wrote to file: hello.txt
aishell> Show me the git status
[Executing tool: bash]
On branch main
...
```
### 2. ワンショット実行 (Single Command)
```bash
aishell exec "Show me the current directory structure"
```
### 3. MCPサーバーモード (Claude Desktop Integration)
```bash
aishell server
```
**Claude Desktop設定** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
```json
{
"mcpServers": {
"aishell": {
"command": "/path/to/aishell",
"args": ["server"]
}
}
}
```
## Architecture
画面は上下に分割される。
```
aishell/
├── src/
├── cli/ # 対話型インターフェイス (REPL)
├── llm/ # LLMプロバイダー (OpenAI互換)
├── shell/ # シェル実行エンジン
├── mcp/ # MCPサーバー実装
│ └── config/ # 設定管理
┌─────────────────────────────────┐
│ [上] shell │
$ pacman -Syu │
:: Synchronizing package... │
... │
├─────────────────────────────────┤
│ [下] ai │
│ > macbookのフリーズの原因を調べて │
│ │
│ アイね、dmesgとjournalctlを │
│ 確認してみるね。 │
│ │
└─────────────────────────────────┘
```
**実行フロー:**
## 入力の振り分け
入力は一つ。enterを押した時に
1. **有効なコマンドの場合** → 上のshellで実行される。下のAI入力バッファは取り消される
2. **有効なコマンドでない場合** → 下のAIに送信される
入力中のテキストはリアルタイムで下のAIバッファにも表示される。ユーザーは「コマンドを打っているのか、AIに話しかけているのか」を意識する必要がない。
## 判定ロジック
コマンド判定の基準:
- PATH上に存在する実行可能ファイルと一致するか
- shell builtin (cd, export, alias等) と一致するか
- パイプ (|)、リダイレクト (>, >>)、変数代入 (=) を含むか
上記に該当しなければAIへの入力として扱う。
## 技術スタック
- Rust
- Claude API (MCPまたは直接)
- PTY制御 (上のshell)
- TUIフレームワーク (ratatui等)
## aiosとの統合
```
User Input → LLM (Function Calling) → Tool Execution → Shell → Result → LLM → User
aios起動 → systemd → aishell (login shell)
├── [上] shell (PTY)
└── [下] AI (Claude API + core.md + memory.md)
```
## Available Tools
aishellは以下のツールをLLMに提供します:
- **bash**: シェルコマンドを実行
- **read**: ファイルを読み込み
- **write**: ファイルに書き込み
- **list**: ファイル一覧を取得
## Environment Variables
| 変数 | 説明 | デフォルト |
|------|------|----------|
| `OPENAI_API_KEY` | OpenAI APIキー | (必須) |
| `OPENAI_BASE_URL` | APIベースURL | `https://api.openai.com/v1` |
| `OPENAI_MODEL` | 使用するモデル | `gpt-4` |
## Integration with AIOS
aishellは[aigpt](https://github.com/syui/aigpt)と組み合わせることで、AIOSAI Operating Systemの一部として機能します:
- **aigpt**: AIメモリー、パーソナリティ分析
- **aishell**: シェル操作、自動化
- **AIOS**: これらを統合したAIによるOS管理システム
## Comparison with Claude Code
| 機能 | Claude Code | aishell |
|------|------------|---------|
| LLM | Claude専用 | **マルチプロバイダー** |
| 実行環境 | Electron Desktop | **CLI/MCP** |
| カスタマイズ | 限定的 | **完全制御** |
| ローカルLLM | 非対応 | **対応可能** |
| AIOS統合 | 不可 | **ネイティブ対応** |
## Development
```bash
# 開発ビルド
cargo build
# テスト実行
cargo test
# ログ有効化
RUST_LOG=debug aishell shell
```
## Technical Stack
- **Language**: Rust 2021
- **CLI**: clap 4.5
- **Async Runtime**: tokio 1.40
- **HTTP Client**: reqwest 0.12
- **Shell Execution**: duct 0.13
- **REPL**: rustyline 14.0
## Roadmap
- [ ] Anthropic Claude API対応
- [ ] Ollama対応ローカルLLM
- [ ] より高度なツールセットgit統合、ファイル検索等
- [ ] 設定ファイルサポート
- [ ] セッション履歴の永続化
- [ ] プラグインシステム
## License
MIT License
## Author
syui
## Related Projects
- [aigpt](https://github.com/syui/aigpt) - AI Memory System
aishellはaiosのエントリーポイント。起動した瞬間からAIが使える状態になる。