Metadata-Version: 2.4
Name: schema-refiner-cli
Version: 3.1.0
Summary: 自动化诊断、量化并修复关系型数据库模式中词汇歧义的CLI工具套件
Home-page: https://github.com/schema-refiner/puritas-cli
Author: Schema-Refiner Team
Author-email: Schema-Refiner Team <dev@schema-refiner.org>
Maintainer-email: Schema-Refiner Team <dev@schema-refiner.org>
License: MIT
Project-URL: Homepage, https://github.com/schema-refiner/puritas-cli
Project-URL: Bug Reports, https://github.com/schema-refiner/puritas-cli/issues
Project-URL: Source, https://github.com/schema-refiner/puritas-cli
Project-URL: Documentation, https://schema-refiner.readthedocs.io/
Keywords: database,schema,refining,ambiguity,cli,nlp,sql
Platform: any
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
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 :: Database
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: sqlglot>=18.0.0
Requires-Dist: openai>=1.0.0
Requires-Dist: requests>=2.25.0
Requires-Dist: rich>=10.0.0
Requires-Dist: tqdm>=4.60.0
Requires-Dist: numpy>=1.20.0
Requires-Dist: scikit-learn>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0.0; extra == "dev"
Requires-Dist: pytest-cov>=2.10.0; extra == "dev"
Requires-Dist: black>=21.0.0; extra == "dev"
Requires-Dist: flake8>=3.8.0; extra == "dev"
Requires-Dist: mypy>=0.800; extra == "dev"
Requires-Dist: pre-commit>=2.10.0; extra == "dev"
Requires-Dist: sphinx>=4.0.0; extra == "dev"
Requires-Dist: sphinx-rtd-theme>=0.5.0; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest>=6.0.0; extra == "test"
Requires-Dist: pytest-cov>=2.10.0; extra == "test"
Requires-Dist: pytest-mock>=3.5.0; extra == "test"
Dynamic: author
Dynamic: home-page
Dynamic: platform
Dynamic: requires-python

# Schema-Refiner 工具套件

[![Version](https://img.shields.io/badge/version-3.1--CLI-blue.svg)](https://github.com/schema-refiner/schema-refiner)
[![Python](https://img.shields.io/badge/python-3.8+-green.svg)](https://python.org)
[![License](https://img.shields.io/badge/license-MIT-orange.svg)](LICENSE)

**项目代号**: Puritas-CLI  
**目标**: 自动化诊断、量化并修复关系型数据库模式中的词汇歧义

## 🚀 快速开始

### 安装

```bash
pip install schema-refiner-cli
```

### 基本使用

#### 单步执行模式
```bash
# 步骤1: 构建模式图谱
schema-graph-builder --db-path ./academic.sqlite --output ./outputs/schema_graph.json

# 步骤2: 进行歧义审计
ambiguity-auditor --schema-graph ./outputs/schema_graph.json --config ./config/audit_config.json --output ./outputs/audit_report.json

# 步骤3: 生成视图和转换日志
view-generator --audit-report ./outputs/audit_report.json --schema-graph ./outputs/schema_graph.json --output-dir ./outputs --db-name academic
```

#### 一键执行模式
```bash
# 使用主编排工具一键完成所有步骤
schema-refiner --db-path ./academic.sqlite --config ./config/main_config.json --output-dir ./outputs
```

## 🛠️ CLI工具

### 🗂️ schema-graph-builder
模式图谱构建工具，将数据库模式解析并构建成标准图谱结构。

### 🧠 semantic-predictor  
语义预测工具，调用LLM推断数据库列的语义信息。

### 🔍 ambiguity-auditor
歧义审计工具，对数据库模式进行歧义检测和量化评估。

### 📊 view-generator
视图生成工具，基于审计结果生成CREATE VIEW语句和转换日志。

### 🎯 schema-refiner
主编排工具，协调整个Schema-Refiner流程的执行。

## 📁 输出文件

完整流程执行后将生成以下文件：

```
outputs/
├── refined_schema_prompt.txt       # Text-to-SQL上下文提示
├── transformation_log.json         # 查询重写器输入
├── refinement_scripts.sql          # 视图创建脚本
├── audit_report.json              # 详细审计报告
├── schema_graph.json              # 模式图谱（如果保留中间文件）
└── schema_refiner.log             # 执行日志
```

## ⚙️ 配置

### 环境变量
- `OPENAI_API_KEY`: OpenAI API密钥
- `SCHEMA_REFINER_CONFIG_DIR`: 配置文件目录

### 配置文件优先级
命令行参数 > 项目配置 > 全局配置 > 默认值

## 📖 文档

- [用户指南](docs/user_guide/)
- [API文档](docs/api/)
- [架构设计](docs/architecture/)
- [使用示例](docs/examples/)

## 🧪 测试

```bash
# 运行所有测试
python -m pytest tests/

# 运行单元测试
python -m pytest tests/unit/

# 运行集成测试
python -m pytest tests/integration/
```

## 🤝 贡献

欢迎提交Issues和Pull Requests！

## 📄 许可证

本项目采用MIT许可证 - 详见 [LICENSE](LICENSE) 文件。

## 🔗 相关链接

- [需求文档](.roo/rules/00-requirements.md)
- [开发任务](.roo/rules/99-tasks.md)
- [开发规则](.roo/rules/01-core-rules.md)
