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が使える状態になる。

View File

@@ -1,41 +1,49 @@
# aishell
## これは何か
## 概要
aiosのシェル。OSのlogin shellとして起動し、AIとの対話がデフォルトになる。
claude codeの代替ではなく、shellとAIを統合した新しいインターフェース。
Claude Codeのような、AIがshellを操作するためのツール。
例えば、gpt-ossのようなllmを使用することを想定。場合によっては、MCPを駆使する。
## 設計原則
## 主な機能
1. **マルチLLMプロバイダー対応**
- OpenAI API互換OpenAI, gpt-oss, etc.
- 将来的にClaude API、Ollamaなども対応予定
2. **Function Calling (Tool use)**
- LLMが直接ツールを呼び出してシェルを操作
- bash, read, write, list等のツールを提供
3. **MCPサーバーモード**
- Claude Desktopとの連携が可能
- aigptと同様のMCPプロトコル実装
- 画面は上下分割。上がshell、下がAI
- 入力は一つ。コマンドかどうかを自動判定して振り分ける
- AIはcore.md + memory.mdを読み込んだ状態で起動する
- shellの出力もAIのコンテキストに入る
## アーキテクチャ
```
User → CLI → LLM Provider → Function Calling → Shell Executor → Result
aishell
├── input_handler ← 入力を受け取り、コマンドかAIかを判定
├── shell_pane ← 上画面。PTYでbash/zshを制御
├── ai_pane ← 下画面。AI応答を表示
├── ai_client ← Claude API / MCP接続
└── memory_loader ← core.md + memory.mdの読み込み・更新
```
## AIOS統合
## 入力判定
- **aigpt**: メモリー、パーソナリティ分析
- **aishell**: シェル操作、自動化
- **統合**: AIによるOS管理の実現
1. PATH上の実行ファイル、shell builtin、パイプ・リダイレクト・変数代入 → shell
2. それ以外 → AI
3. 入力中はリアルタイムで下のAIバッファにプレビュー表示
## 技術スタック
## 技術
- Rust 2021
- tokio (async runtime)
- reqwest (HTTP client)
- duct (shell execution)
- clap (CLI framework)
- ratatui (TUI)
- tokio (async)
- portable-pty または nix (PTY制御)
- Claude API (claude-code CLIまたは直接API)
## 記憶との連携
起動時にcore.md + memory.mdを読む。セッション終了時に会話をmemory.mdに圧縮。
aigpt (MCP server) が記憶の読み書きを担当する。
## 開発方針
- まず最小限: 上下分割 + 入力振り分け + AI応答
- 次に記憶: core.md/memory.md読み込み
- 最後に統合: aigpt MCP連携、音声入力