Metadata-Version: 2.4
Name: smart-cli-ai
Version: 0.2.0
Summary: A lightweight, zero-dependency AI terminal assistant
Home-page: https://github.com/jiu99203/smart-cli-ai
Author: jiu99203
Project-URL: Bug Tracker, https://github.com/jiu99203/smart-cli-ai/issues
Project-URL: Source Code, https://github.com/jiu99203/smart-cli-ai
Keywords: cli ai terminal openai shell git assistant productivity
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-python
Dynamic: summary

<div align="center">

# 🤖 Smart CLI AI

**Lightweight, Zero-Dependency AI Terminal Assistant**

*Convert Natural Language to Shell Commands · Diagnose Terminal Errors · Auto-Generate Git Commits*

[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Dependencies](https://img.shields.io/badge/dependencies-0%20third--party-brightgreen.svg)](#features)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/jiu99203/smart-cli-ai/pulls)

</div>

---

## 🔥 Key Features

- **⚡ Zero Third-Party Dependencies** — Built entirely with Python standard library (`argparse`, `json`, `urllib`). Instant startup, nothing to install.
- **💡 Natural Language to Shell** — `smart-cli do "find large files"` generates the exact command you need.
- **🔍 Intelligent Error Diagnosis** — Paste any terminal error into `smart-cli fix` and get root-cause analysis with step-by-step solutions.
- **📝 Auto Git Commit Messages** — `smart-cli commit` reads your staged diff and generates Conventional Commit messages.
- **🌐 Multi-Provider Support** — DeepSeek, OpenAI, Qwen, Moonshot (Kimi), SiliconFlow, Ollama, or any OpenAI-compatible endpoint.
- **🛡️ Human-Readable Diagnostics** — No raw HTTP status codes. Every error comes with a Chinese explanation and actionable fix.
- **🔑 Key Masking** — API keys are never printed in full; only first 4 and last 4 characters are shown.

---

## 🚀 Quick Start

### Installation

```bash
pip install smart-cli-ai
```

### Configuration (30 seconds)

```bash
smart-cli config
```

An interactive wizard will guide you through:
1. Pick a provider (DeepSeek / OpenAI / Qwen / Moonshot / SiliconFlow / Ollama / Custom)
2. Paste your API key (masked input, not echoed to terminal)
3. Connectivity test runs automatically — config is only saved on success

Or skip the wizard:

```bash
smart-cli config --preset deepseek --key sk-your-api-key
```

### Use It

```bash
# Convert natural language to shell command
smart-cli do "list all docker containers running and their port mappings"

# Diagnose a terminal error
smart-cli fix "npm ERR! code ERESOLVE unable to resolve dependency tree"

# Generate a commit message from staged changes
git add .
smart-cli commit
```

---

## 📖 Command Reference

| Command | Description |
|---------|-------------|
| `smart-cli config` | Launch interactive setup wizard |
| `smart-cli config --preset <NAME> --key <KEY>` | Quick setup with a provider preset |
| `smart-cli info` | View current configuration (API key masked) |
| `smart-cli check` | Test API connectivity and latency |
| `smart-cli reset` | Delete local configuration |
| `smart-cli do "<query>"` | Convert natural language to shell command |
| `smart-cli fix "<error>"` | Diagnose terminal errors with AI |
| `smart-cli commit` | Generate Conventional Commit from staged git diff |

---

## 🌐 Supported Providers

| Provider | Preset Key | Default Model |
|----------|-----------|---------------|
| DeepSeek | `deepseek` | `deepseek-chat` |
| OpenAI | `openai` | `gpt-4o-mini` |
| SiliconFlow | `siliconflow` | `deepseek-ai/DeepSeek-V3` |
| Qwen (通义千问) | `qwen` | `qwen-plus` |
| Moonshot (月之暗面/Kimi) | `moonshot` | `moonshot-v1-8k` |
| Ollama (Local) | `ollama` | `qwen2.5` |
| Custom | — | (your own endpoint) |

---

## ⚙️ Configuration

Configuration is stored at `~/.smart_cli_config.json` with UTF-8 encoding.

**Priority chain** (highest to lowest):
1. Values in `~/.smart_cli_config.json`
2. Environment variables: `DEEPSEEK_API_KEY` / `OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_MODEL`

If no configuration is found, the tool will prompt you to run `smart-cli config`.

---

## 🛡️ Error Diagnostics

Instead of raw HTTP codes, Smart CLI AI provides actionable messages:

| Scenario | What You See |
|----------|-------------|
| Invalid API Key | "401 — API Key 无效或服务商不匹配" + fix instructions |
| Rate Limited | "429 — 请检查账户余额与计费状态" |
| Network Down | "网络连接失败 — 请检查代理设置" |
| Corrupt Config | "JSON 格式损坏 — 运行 smart-cli reset" |

---

## 📦 Requirements

- Python 3.8 or higher
- No third-party packages required
- Works on Linux, macOS, and Windows

---

## 🤝 Contributing

Pull requests are welcome! For major changes, please open an issue first.

---

## 📄 License

MIT © [jiu99203](https://github.com/jiu99203)
