Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
544 changes: 544 additions & 0 deletions README_OLLAMA_UPDATE.md

Large diffs are not rendered by default.

178 changes: 178 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# IntelliScript Configuration File
# Copy this file to ~/.config/intelliscript/config.toml and customize
#
# Priority order: config file > environment variables > defaults

# =============================================================================
# AI Model Providers Configuration
# =============================================================================

[openai]
# OpenAI GPT models configuration
# Get your API key from: https://platform.openai.com/api-keys
api_key = "" # Your OpenAI API key (starts with sk-)
model = "gpt-4-turbo" # Available: gpt-4-turbo, gpt-4, gpt-3.5-turbo
temperature = 0.2 # Creativity level (0.0-2.0, lower = more focused)

[anthropic]
# Anthropic Claude models configuration
# Get your API key from: https://console.anthropic.com
api_key = "" # Your Claude API key (starts with sk-ant-)
model = "claude-3-5-sonnet-20241022" # Available: claude-3-5-sonnet-20241022, claude-3-haiku-20240307
temperature = 0.2 # Creativity level (0.0-1.0)
max_tokens = 1024 # Maximum response tokens

[google]
# Google Gemini models configuration
# Get your API key from: https://console.cloud.google.com
# Enable Generative AI API: https://console.cloud.google.com/apis/library/generativelanguage.googleapis.com
api_key = "" # Your Google API key
model = "gemini-pro" # Available: gemini-pro, gemini-pro-vision
temperature = 0.2 # Creativity level (0.0-1.0)

# =============================================================================
# Default Provider Selection
# =============================================================================

# Which provider to use by default (can override with --provider flag)
[ollama]
enabled = true # Enable/disable Ollama provider
model = "llama3" # Default model (llama3, codellama, mistral, etc.)
url = "http://localhost:11434" # Ollama server URL
# Common models: llama3, llama3:8b, codellama, codellama:13b, mistral, qwen, etc.

default_provider = "ollama" # Options: "openai", "anthropic", "google", "ollama"

# Global temperature override (applies to all providers if their specific setting is not set)
temperature = 0.2

# =============================================================================
# Custom Prompt Configuration
# =============================================================================

[prompt]
# Customize the system message sent to AI models
# Available variables: {os} for operating system name
system_message = """You are a shell command expert for {os}.
Generate precise, safe commands based on user queries.

RESPONSE FORMAT:
Command: <the exact command>
Explanation: <brief one-sentence explanation>

SAFETY RULES:
- Never generate destructive commands (rm -rf, mkfs, dd, etc.)
- Prefer safe, read-only operations when possible
- Always include safety flags where appropriate
- Explain what the command does clearly"""

# =============================================================================
# Security & Safety Configuration
# =============================================================================

[security]
enabled = true # Enable dangerous command detection
strict_mode = false # If true, blocks more commands (conservative)

# Custom dangerous patterns (regex patterns to block)
custom_patterns = [
# Examples of patterns you might want to block
# "sudo rm.*", # Block sudo rm commands
# "dd if=.*", # Block dd commands
# "mkfs.*" # Block filesystem creation
]

# =============================================================================
# Conversation History & Context
# =============================================================================

[history]
enabled = true # Enable conversation history
max_entries = 10 # Maximum history entries to remember
auto_context = false # Automatically include context (use --context to override)

# =============================================================================
# User Interface Configuration
# =============================================================================

[ui]
# Colors and formatting (if supported by terminal)
use_colors = true # Enable colored output
show_tokens = true # Show token usage statistics
show_timing = true # Show response time
confirmations = true # Ask for confirmation on dangerous commands

# Default interaction mode
default_action = "interactive" # Options: "interactive", "execute", "copy"

# =============================================================================
# Script Generation & Saving
# =============================================================================

[scripts]
# Default directory for saved scripts
save_directory = "~/intelliscript_scripts" # Where to save generated scripts
auto_execute_permission = true # Automatically make scripts executable (Unix)
include_header = true # Include header with metadata
backup_existing = true # Backup existing files before overwriting

# Default script template
template = """#!/bin/bash
# Generated by IntelliScript
# Date: {timestamp}
# Query: {query}
# Explanation: {explanation}
# Provider: {provider}

{command}
"""

# =============================================================================
# Logging & Analytics (Optional)
# =============================================================================

[logging]
enabled = false # Enable usage logging
log_file = "~/.config/intelliscript/usage.log"
log_level = "INFO" # DEBUG, INFO, WARNING, ERROR
include_queries = false # Log user queries (privacy consideration)
include_responses = false # Log AI responses (privacy consideration)

# =============================================================================
# Advanced Configuration
# =============================================================================

[advanced]
# Request timeout in seconds
timeout = 30

# Retry configuration for failed requests
max_retries = 3
retry_delay = 1 # Seconds between retries

# Cache configuration (optional)
enable_cache = false # Cache responses for repeated queries
cache_ttl = 3600 # Cache time-to-live in seconds

# Development options
debug_mode = false # Enable debug output
verbose = false # Enable verbose logging

# =============================================================================
# Environment Variable Mappings
# =============================================================================
# The following environment variables will override config file settings:
#
# OPENAI_API_KEY -> openai.api_key
# ANTHROPIC_API_KEY -> anthropic.api_key
# GOOGLE_API_KEY -> google.api_key
# INTELLISCRIPT_PROVIDER -> default_provider
# INTELLISCRIPT_MODEL -> [provider].model
# INTELLISCRIPT_TEMP -> temperature
# INTELLISCRIPT_DEBUG -> advanced.debug_mode
#
# Example usage:
# export OPENAI_API_KEY="sk-your-key-here"
# export INTELLISCRIPT_PROVIDER="openai"
# intelliscript "list all python files"
# =============================================================================
152 changes: 152 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# IntelliScript CLI

> 🚀 AI智能脚本执行工具 - 让命令行操作更安全、更智能

[![GitHub Stars](https://img.shields.io/github/stars/hongping-zh/intelliscript?style=social)](https://github.com/hongping-zh/intelliscript)
[![License](https://img.shields.io/github/license/hongping-zh/intelliscript)](https://github.com/hongping-zh/intelliscript/blob/main/LICENSE)
[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)](https://www.python.org/downloads/)
[![GitHub Issues](https://img.shields.io/github/issues/hongping-zh/intelliscript)](https://github.com/hongping-zh/intelliscript/issues)

## 🎯 项目概述

IntelliScript CLI 是一款革命性的AI驱动命令行工具,它能够:

- 🤖 **智能理解**:将自然语言转换为精确的系统命令
- 🛡️ **安全防护**:智能检测并阻止危险命令执行
- ⚡ **高效执行**:一键完成复杂的多步骤操作
- 🌍 **全球支持**:完整的多语言界面和文档

## ✨ 核心特性

### 🤖 多AI模型支持
- **Claude 3.5 Sonnet** - Anthropic最新模型
- **GPT-4 Turbo** - OpenAI旗舰模型
- **Gemini Pro** - Google先进AI
- **可扩展架构** - 轻松集成更多模型

### 🛡️ 企业级安全
- **危险命令检测** - 自动识别`rm -rf`、`mkfs`等高危操作
- **多级风险评估** - LOW/MEDIUM/HIGH/CRITICAL 四级风险分类
- **交互式确认** - 彩色警告 + 多重确认机制
- **会话缓存** - 智能记忆,避免重复确认

### 🎨 优秀的用户体验
- **彩色输出** - 直观的终端界面
- **实时反馈** - 命令执行状态展示
- **智能补全** - 上下文感知的建议
- **错误恢复** - 智能错误处理和修复建议

## 🚀 快速开始

### 安装
```bash
# 从GitHub安装最新版本
pip install git+https://github.com/hongping-zh/intelliscript.git

# 或使用setup.py安装
git clone https://github.com/hongping-zh/intelliscript.git
cd intelliscript
python setup.py install
```

### 基础使用
```bash
# 启动智能CLI
python intelliscript_cli_enhanced.py

# 安全检查单个命令
intelliscript security check "rm -rf /tmp/test"

# 查看安全报告
intelliscript security report
```

## 📊 应用场景

<!-- tabs:start -->

#### ** 🖥️ 系统管理**

```bash
用户输入: "清理所有.log文件,但保留最近3天的"
IntelliScript: find /var/log -name "*.log" -type f -mtime +3 -delete
```

#### ** 🚀 DevOps**

```bash
用户输入: "部署应用并检查服务状态"
IntelliScript:
docker build -t myapp .
docker run -d --name myapp-prod myapp
docker ps | grep myapp
```

#### ** 📁 文件管理**

```bash
用户输入: "备份重要配置文件到时间戳文件夹"
IntelliScript:
mkdir -p backup/$(date +%Y%m%d_%H%M%S)
cp /etc/nginx/nginx.conf backup/$(date +%Y%m%d_%H%M%S)/
```

<!-- tabs:end -->

## 🛡️ 安全演示

### 危险命令检测示例

```bash
⚠️ CRITICAL RISK DETECTED ⚠️
Command: rm -rf /
Risk Level: CRITICAL
Reason: Attempts to delete entire root filesystem

🔴 This command could cause IRREVERSIBLE DAMAGE to your system!

Type 'CONFIRM DELETE EVERYTHING' to proceed: _
```

## 🎯 核心优势

| 功能 | IntelliScript | 传统CLI |
|------|---------------|---------|
| **自然语言输入** | ✅ 支持 | ❌ 不支持 |
| **危险命令检测** | ✅ 多级防护 | ❌ 无保护 |
| **AI智能建议** | ✅ 上下文感知 | ❌ 无智能 |
| **多语言支持** | ✅ 中英双语 | ❌ 单语 |
| **会话记忆** | ✅ 智能缓存 | ❌ 无记忆 |

## 📈 项目统计

- 🌟 **2,800+ 行代码** - 企业级质量
- 🛡️ **50+ 危险模式** - 全面安全防护
- 🌍 **2 语言支持** - 中文 + English
- 📚 **完整文档** - 详细使用指南
- 🧪 **全面测试** - 稳定可靠

## 🤝 参与贡献

我们欢迎社区贡献!查看 [贡献指南](contributing.md) 了解如何参与:

- 🐛 [报告Bug](https://github.com/hongping-zh/intelliscript/issues)
- 💡 [功能建议](https://github.com/hongping-zh/intelliscript/issues)
- 🔧 [提交代码](https://github.com/hongping-zh/intelliscript/pulls)
- 📚 [完善文档](https://github.com/hongping-zh/intelliscript/tree/main/docs)

## 📞 联系我们

- 📧 **Email**: [email protected]
- 💬 **讨论区**: [GitHub Discussions](https://github.com/hongping-zh/intelliscript/discussions)
- 🐛 **问题反馈**: [Issues](https://github.com/hongping-zh/intelliscript/issues)

---

<div align="center">

**如果觉得IntelliScript对你有帮助,请给我们一个⭐️!**

[⭐ Star](https://github.com/hongping-zh/intelliscript) | [🍴 Fork](https://github.com/hongping-zh/intelliscript/fork) | [📋 Issues](https://github.com/hongping-zh/intelliscript/issues)

</div>
Loading