1
0

fix config

This commit is contained in:
syui 2025-06-02 00:32:00 +09:00
parent 0f3776e75e
commit 81ae0037d9
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
12 changed files with 57 additions and 52 deletions

View File

@ -2,7 +2,10 @@
"permissions": { "permissions": {
"allow": [ "allow": [
"Bash(chmod:*)", "Bash(chmod:*)",
"Bash(cargo:*)" "Bash(cargo:*)",
"Bash(grep:*)",
"Bash(find:*)",
"Bash(lsof:*)"
], ],
"deny": [] "deny": []
} }

2
.gitignore vendored
View File

@ -14,7 +14,7 @@ venv/
.venv .venv
# ai.shell specific # ai.shell specific
~/.ai-shell/ ~/.config/syui/ai/shell/
*.log *.log
# IDE # IDE

View File

@ -1,5 +1,5 @@
[package] [package]
name = "ai-shell" name = "aishell"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
authors = ["syui"] authors = ["syui"]
@ -30,5 +30,5 @@ default = []
# tui = ["ratatui", "crossterm"] # tui = ["ratatui", "crossterm"]
[[bin]] [[bin]]
name = "ai-shell" name = "aishell"
path = "src/main.rs" path = "src/main.rs"

View File

@ -2,7 +2,7 @@
all: build all: build
# Initial setup (creates venv in ~/.config/ai-shell) # Initial setup (creates venv in ~/.config/syui/ai/shell)
setup: setup:
@./scripts/setup.sh @./scripts/setup.sh
@ -12,29 +12,29 @@ build:
# Run MCP server (after setup) # Run MCP server (after setup)
run-server: run-server:
@if [ ! -d "$$HOME/.config/ai-shell/venv" ]; then \ @if [ ! -d "$$HOME/.config/syui/ai/shell/venv" ]; then \
echo "Please run 'make setup' first"; \ echo "Please run 'make setup' first"; \
exit 1; \ exit 1; \
fi fi
@$$HOME/.config/ai-shell/bin/mcp-server @$$HOME/.config/syui/ai/shell/bin/mcp-server
# Run CLI in development mode # Run CLI in development mode
run-cli: run-cli:
cargo run cargo run
# Run ai-shell (after setup) # Run aishell (after setup)
run: run:
@if [ ! -d "$$HOME/.config/ai-shell/venv" ]; then \ @if [ ! -d "$$HOME/.config/syui/ai/shell/venv" ]; then \
echo "Please run 'make setup' first"; \ echo "Please run 'make setup' first"; \
exit 1; \ exit 1; \
fi fi
@$$HOME/.config/ai-shell/bin/ai-shell @$$HOME/.config/syui/ai/shell/bin/aishell
# Run tests # Run tests
test: test:
cargo test cargo test
@if [ -d "$$HOME/.config/ai-shell/venv" ]; then \ @if [ -d "$$HOME/.config/syui/ai/shell/venv" ]; then \
source $$HOME/.config/ai-shell/venv/bin/activate && python -m pytest tests/; \ source $$HOME/.config/syui/ai/shell/venv/bin/activate && python -m pytest tests/; \
fi fi
# Clean build artifacts # Clean build artifacts
@ -45,5 +45,5 @@ clean:
# Remove all installed files (complete uninstall) # Remove all installed files (complete uninstall)
uninstall: uninstall:
rm -rf $$HOME/.config/ai-shell rm -rf $$HOME/.config/syui/ai/shell
@echo "ai.shell has been uninstalled" @echo "ai.shell has been uninstalled"

View File

@ -20,11 +20,11 @@ ai.shellは、ローカルLLMを活用してコード生成、ファイル操作
git clone https://git.syui.ai/ai/shell.git git clone https://git.syui.ai/ai/shell.git
cd shell cd shell
# 2. セットアップvenv環境を~/.config/ai-shellに構築 # 2. セットアップvenv環境を~/.config/syui/ai/shellに構築
make setup make setup
# 3. PATHに追加~/.zshrcまたは~/.bash_profileに追記 # 3. PATHに追加~/.zshrcまたは~/.bash_profileに追記
export PATH="$HOME/.config/ai-shell/bin:$PATH" export PATH="$HOME/.config/syui/ai/shell/bin:$PATH"
``` ```
## 使い方 ## 使い方
@ -33,7 +33,7 @@ export PATH="$HOME/.config/ai-shell/bin:$PATH"
```bash ```bash
# ai.shellを起動 # ai.shellを起動
ai-shell aishell
# または、プロジェクトディレクトリから # または、プロジェクトディレクトリから
make run make run
@ -49,8 +49,8 @@ ai> /analyze src/main.rs
ai> /create rust my-project ai> /create rust my-project
# ワンショット実行 # ワンショット実行
ai-shell exec "create a fibonacci function" aishell exec "create a fibonacci function"
ai-shell analyze src/main.rs aishell analyze src/main.rs
``` ```
## 機能 ## 機能
@ -63,7 +63,7 @@ ai-shell analyze src/main.rs
## 設定 ## 設定
設定ファイル: `~/.config/ai-shell/config.toml` 設定ファイル: `~/.config/syui/ai/shell/config.toml`
```toml ```toml
[server] [server]

View File

@ -15,13 +15,13 @@ timeout_seconds = 300
[logging] [logging]
# Log configuration # Log configuration
level = "info" # debug, info, warn, error level = "info" # debug, info, warn, error
file = "~/.ai-shell/ai-shell.log" file = "~/.config/syui/ai/shell/aishell.log"
max_size_mb = 10 max_size_mb = 10
max_backups = 3 max_backups = 3
[cli] [cli]
# CLI behavior # CLI behavior
history_file = "~/.ai-shell/history" history_file = "~/.config/syui/ai/shell/history"
max_history = 1000 max_history = 1000
prompt = "ai> " prompt = "ai> "
color_output = true color_output = true

View File

@ -4,7 +4,7 @@
``` ```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ User Input │ │ ai-shell CLI │ │ MCP Server │ │ User Input │ │ aishell CLI │ │ MCP Server │
│ (Terminal) │────▶│ (Rust) │────▶│ (Python) │ │ (Terminal) │────▶│ (Rust) │────▶│ (Python) │
└─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │ │

View File

@ -16,15 +16,15 @@
- HTTP REST API通信 - HTTP REST API通信
2. **環境構築** 2. **環境構築**
- `~/.config/ai-shell/` にPython venv環境 - `~/.config/syui/ai/shell/` にPython venv環境
- セットアップスクリプト (`make setup`) - セットアップスクリプト (`make setup`)
- 起動スクリプト - 起動スクリプト
3. **CLI機能** 3. **CLI機能**
- インタラクティブモード - インタラクティブモード
- ワンショット実行 (`ai-shell exec "prompt"`) - ワンショット実行 (`aishell exec "prompt"`)
- ファイル分析 (`ai-shell analyze file`) - ファイル分析 (`aishell analyze file`)
- ヘルスチェック (`ai-shell health`) - ヘルスチェック (`aishell health`)
4. **コマンド** 4. **コマンド**
- `/help` - ヘルプ表示 - `/help` - ヘルプ表示
@ -96,12 +96,12 @@
├── setup.sh # セットアップスクリプト ├── setup.sh # セットアップスクリプト
└── start.sh # 起動スクリプト └── start.sh # 起動スクリプト
~/.config/ai-shell/ # ユーザー設定ディレクトリ ~/.config/syui/ai/shell/ # ユーザー設定ディレクトリ
├── venv/ # Python仮想環境 ├── venv/ # Python仮想環境
├── config.toml # ユーザー設定 ├── config.toml # ユーザー設定
├── mcp_server.py # MCPサーバーコピー ├── mcp_server.py # MCPサーバーコピー
└── bin/ └── bin/
├── ai-shell # CLIラッパー ├── aishell # CLIラッパー
└── mcp-server # サーバーラッパー └── mcp-server # サーバーラッパー
``` ```
@ -123,10 +123,10 @@ git status
make run-server make run-server
# CLIを起動Terminal 2 # CLIを起動Terminal 2
./target/debug/ai-shell ./target/debug/aishell
# または、セットアップ済みなら # または、セットアップ済みなら
ai-shell aishell
``` ```
## 重要な設計思想 ## 重要な設計思想

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# ai.shell setup script for macOS # ai.shell setup script for macOS
# Sets up Python venv environment in ~/.config/ai-shell # Sets up Python venv environment in ~/.config/syui/ai/shell
set -e set -e
@ -12,7 +12,7 @@ YELLOW='\033[1;33m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
# Directories # Directories
CONFIG_DIR="$HOME/.config/ai-shell" CONFIG_DIR="$HOME/.config/syui/ai/shell"
VENV_DIR="$CONFIG_DIR/venv" VENV_DIR="$CONFIG_DIR/venv"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")" PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
@ -72,7 +72,7 @@ cat > "$CONFIG_DIR/bin/mcp-server" << 'EOF'
#!/bin/bash #!/bin/bash
# MCP Server startup script # MCP Server startup script
CONFIG_DIR="$HOME/.config/ai-shell" CONFIG_DIR="$HOME/.config/syui/ai/shell"
VENV_DIR="$CONFIG_DIR/venv" VENV_DIR="$CONFIG_DIR/venv"
# Activate virtual environment # Activate virtual environment
@ -85,12 +85,12 @@ EOF
chmod +x "$CONFIG_DIR/bin/mcp-server" chmod +x "$CONFIG_DIR/bin/mcp-server"
# Create ai-shell wrapper script # Create aishell wrapper script
cat > "$CONFIG_DIR/bin/ai-shell" << EOF cat > "$CONFIG_DIR/bin/aishell" << EOF
#!/bin/bash #!/bin/bash
# ai-shell wrapper script # aishell wrapper script
CONFIG_DIR="\$HOME/.config/ai-shell" CONFIG_DIR="\$HOME/.config/syui/ai/shell"
PROJECT_DIR="$PROJECT_DIR" PROJECT_DIR="$PROJECT_DIR"
# Check if MCP server is running # Check if MCP server is running
@ -107,12 +107,12 @@ if ! curl -s http://localhost:8765/health > /dev/null 2>&1; then
done done
fi fi
# Run ai-shell CLI # Run aishell CLI
cd "\$PROJECT_DIR" cd "\$PROJECT_DIR"
cargo run --release -- "\$@" cargo run --release -- "\$@"
EOF EOF
chmod +x "$CONFIG_DIR/bin/ai-shell" chmod +x "$CONFIG_DIR/bin/aishell"
# Check if Ollama is installed # Check if Ollama is installed
echo -e "${YELLOW}🦙 Checking Ollama...${NC}" echo -e "${YELLOW}🦙 Checking Ollama...${NC}"
@ -140,9 +140,9 @@ cargo build --release
echo -e "\n${GREEN}✨ Setup complete!${NC}" echo -e "\n${GREEN}✨ Setup complete!${NC}"
echo -e "\n${BLUE}To use ai.shell:${NC}" echo -e "\n${BLUE}To use ai.shell:${NC}"
echo -e "1. Add to your PATH: ${YELLOW}export PATH=\"\$HOME/.config/ai-shell/bin:\$PATH\"${NC}" echo -e "1. Add to your PATH: ${YELLOW}export PATH=\"\$HOME/.config/syui/ai/shell/bin:\$PATH\"${NC}"
echo -e "2. Run: ${YELLOW}ai-shell${NC}" echo -e "2. Run: ${YELLOW}aishell${NC}"
echo -e "\nOr use the full path: ${YELLOW}~/.config/ai-shell/bin/ai-shell${NC}" echo -e "\nOr use the full path: ${YELLOW}~/.config/syui/ai/shell/bin/aishell${NC}"
# Deactivate virtual environment # Deactivate virtual environment
deactivate deactivate

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
# ai.shell startup script (uses ~/.config/ai-shell setup) # ai.shell startup script (uses ~/.config/syui/ai/shell setup)
set -e set -e
CONFIG_DIR="$HOME/.config/ai-shell" CONFIG_DIR="$HOME/.config/syui/ai/shell"
# Check if setup has been run # Check if setup has been run
if [ ! -d "$CONFIG_DIR/venv" ]; then if [ ! -d "$CONFIG_DIR/venv" ]; then
@ -12,5 +12,5 @@ if [ ! -d "$CONFIG_DIR/venv" ]; then
exit 1 exit 1
fi fi
# Run ai-shell # Run aishell
exec "$CONFIG_DIR/bin/ai-shell" "$@" exec "$CONFIG_DIR/bin/aishell" "$@"

View File

@ -65,7 +65,9 @@ impl Config {
home_dir() home_dir()
.unwrap_or_else(|| PathBuf::from(".")) .unwrap_or_else(|| PathBuf::from("."))
.join(".config") .join(".config")
.join("ai-shell") .join("syui")
.join("ai")
.join("shell")
.join("config.toml") .join("config.toml")
} }
@ -99,12 +101,12 @@ impl Default for Config {
}, },
logging: LoggingConfig { logging: LoggingConfig {
level: "info".to_string(), level: "info".to_string(),
file: "~/.config/ai-shell/ai-shell.log".to_string(), file: "~/.config/syui/ai/shell/aishell.log".to_string(),
max_size_mb: 10, max_size_mb: 10,
max_backups: 3, max_backups: 3,
}, },
cli: CLIConfig { cli: CLIConfig {
history_file: "~/.config/ai-shell/history".to_string(), history_file: "~/.config/syui/ai/shell/history".to_string(),
max_history: 1000, max_history: 1000,
prompt: "ai> ".to_string(), prompt: "ai> ".to_string(),
color_output: true, color_output: true,

View File

@ -2,11 +2,11 @@ use clap::{Parser, Subcommand};
use colored::*; use colored::*;
use tokio; use tokio;
use ai_shell::{Config, MCPClient, Prompt}; use aishell::{Config, MCPClient, Prompt};
use ai_shell::commands::CommandHandler; use aishell::commands::CommandHandler;
#[derive(Parser)] #[derive(Parser)]
#[command(name = "ai-shell")] #[command(name = "aishell")]
#[command(about = "AI-powered shell for code generation and automation")] #[command(about = "AI-powered shell for code generation and automation")]
#[command(version = "0.1.0")] #[command(version = "0.1.0")]
struct Cli { struct Cli {