# F5 Framework CLI

[![npm version](https://badge.fury.io/js/f5-framework-cli.svg)](https://www.npmjs.com/package/f5-framework-cli)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**Enterprise Spec-Driven Development Toolkit**

F5 Framework combines Business Analysis (BA/SRS) capabilities with code generation for comprehensive software development.

## Features

- 🏢 **12 Business Domains** - Fintech, E-commerce, Healthcare, Education, and more
- 📋 **Domain Knowledge** - Entities, business rules, workflows, use cases
- 🤖 **20 Specialized Agents** - BA, design, implementation, validation
- 🔄 **Quality Gates** - D1-D4 (design), G2-G4 (implementation)
- 🇻🇳 **Vietnamese Support** - Documentation in Vietnamese with English technical terms
- 📄 **Multi-Format Import** - Import from Excel, Word, PDF (with OCR)
- 🔀 **Requirement Consolidation** - Merge requirements with deduplication
- 📊 **Prioritization** - MoSCoW, WSJF, Value-Effort matrix
- 🔗 **Dependency Mapping** - Mermaid diagram generation
- 🧪 **Test Generation** - BDD/Gherkin feature files from requirements

## Installation

```bash
npm install -g f5-framework-cli
```

## Quick Start

```bash
# Check version
f5 --version

# Initialize project with domain
f5 init my-project --domain fintech --subdomain stock-trading

# Research a feature
f5 research "user authentication"

# Generate SRS
f5 spec --srs
```

## Available Domains

| Category | Domains |
|----------|---------|
| **Fintech** | Banking, Stock Trading, P2P Lending, Payment, Crypto |
| **E-commerce** | B2C Retail, Marketplace, Subscription |
| **Healthcare** | EHR, Telemedicine, Clinic Management |
| **Education** | LMS, E-learning, School Management |
| **Entertainment** | Streaming, Gaming, Events |
| **Logistics** | Warehouse, Delivery, Fleet Management |
| **Insurance** | Life, Property, Claims |
| **HR Management** | Recruitment, Payroll, Performance |
| **SaaS Platform** | Multi-tenant, Billing, Analytics |
| **Manufacturing** | MES, Quality, Inventory |
| **Real Estate** | Property, Rental, CRM |
| **Travel** | Booking, Hotel, Tours |

## Commands

| Command | Description |
|---------|-------------|
| `f5 init <name>` | Initialize new project |
| `f5 research <topic>` | Deep research with evidence |
| `f5 spec --srs` | Generate SRS document |
| `f5 design` | Create design documents |
| `f5 plan` | Create implementation plan |
| `f5 implement` | Generate code |
| `f5 validate` | Multi-agent validation |
| `f5 gate` | Check quality gates |
| `f5 status` | Show project status |
| `f5 doc` | Document pipeline (Excel/Word/PDF → Markdown) |
| `f5 req` | Requirement analysis tools |

## Document Pipeline

Multi-format document pipeline with version control, conflict resolution, and export options.

### Import Documents (v1.1.5+)

```bash
# Import from Excel
f5 doc import requirements.xlsx

# Import from Word
f5 doc import specification.docx -o ./docs

# Import from PDF (with OCR for scanned documents)
f5 doc import scanned-notes.pdf --ocr --ocr-lang eng+vie

# Import multiple files
f5 doc import requirements.xlsx spec.docx notes.pdf -o ./docs
```

### Multi-Source Consolidation (v1.2.0)

```bash
# Merge requirements from multiple files
f5 doc merge-req team1.md team2.md team3.md -o consolidated.md

# With custom similarity threshold
f5 doc merge-req *.md --threshold 0.9 -o merged.md

# Compare two requirement files
f5 doc compare-req old-version.md new-version.md -o diff-report.md
```

### Basic Commands

```bash
# List versions
f5 doc list

# Show diff between versions
f5 doc diff v1.0.0 v2.0.0

# Export to Markdown
f5 doc export v1.0.0 -o ./output
```

## Requirement Analysis (v1.1.6-v1.1.8)

### Prioritization

```bash
# MoSCoW prioritization
f5 req prioritize requirements.md --method moscow

# WSJF with interactive scoring
f5 req prioritize requirements.md --method wsjf --interactive

# Value-Effort matrix
f5 req prioritize requirements.md --method value-effort
```

### Dependency Mapping

```bash
# Analyze dependencies
f5 req deps requirements.md

# Export Mermaid diagram
f5 req deps requirements.md --mermaid diagram.mmd
```

### Test Case Generation

```bash
# Generate test cases
f5 req to-tests requirements.md

# Export BDD feature file
f5 req to-tests requirements.md --bdd tests.feature

# Export traceability matrix
f5 req to-tests requirements.md --matrix matrix.md

# Include boundary tests
f5 req to-tests requirements.md --boundary --bdd tests.feature
```

### Advanced Features

#### 1. Watch Mode - Auto Import

Tự động theo dõi thư mục và import khi có file Excel mới:

```bash
# Watch directory for new Excel files
f5 doc watch ./input/

# With version bump type
f5 doc watch ./input/ -t minor

# With notifications
f5 doc watch ./input/ --notify slack,email

# Custom patterns
f5 doc watch ./input/ --patterns "*.xlsx" "*.xls"
```

#### 2. Export Multiple Formats

Export requirements sang PDF, DOCX, HTML hoặc Confluence:

```bash
# Export to PDF
f5 doc export-format v1.0.0 -f pdf -o ./output

# Export to Word (DOCX)
f5 doc export-format v1.0.0 -f docx -o ./output --title "Requirements v1.0"

# Export to HTML
f5 doc export-format v1.0.0 -f html -o ./output

# Export to Confluence
f5 doc export-format v1.0.0 -f confluence \
  --confluence-url https://your-domain.atlassian.net/wiki \
  --confluence-space PROJECT \
  --title "Requirements Document"
```

#### 3. Validation Rules

Validate requirements theo các rules có thể tùy chỉnh:

```bash
# Validate with default rules
f5 doc validate

# Validate specific version
f5 doc validate --version v1.0.0

# Use custom rules file
f5 doc validate --rules ./my-rules.yaml

# Generate rules template
f5 doc validate --init

# Output as JSON
f5 doc validate --json
```

**Default Validation Rules:**
- `REQ_ID_REQUIRED` - ID bắt buộc
- `REQ_ID_FORMAT` - Format ID (REQ-XXX, FR-XXX, etc.)
- `REQ_ID_UNIQUE` - ID phải unique
- `DESCRIPTION_REQUIRED` - Description bắt buộc
- `DESCRIPTION_MIN_LENGTH` - Độ dài tối thiểu 20 ký tự
- `PRIORITY_VALID` - Priority hợp lệ (Critical/High/Medium/Low)
- `STATUS_VALID` - Status hợp lệ

#### 4. Notification Integration

Gửi thông báo qua Slack, Email, hoặc Webhook:

**Environment Variables:**
```bash
# Slack
export F5_SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."
export F5_SLACK_CHANNEL="#requirements"

# Email (SMTP)
export F5_EMAIL_HOST="smtp.gmail.com"
export F5_EMAIL_PORT="587"
export F5_EMAIL_USER="your-email@gmail.com"
export F5_EMAIL_PASS="your-app-password"
export F5_EMAIL_FROM="f5-framework@your-domain.com"
export F5_EMAIL_TO="team@your-domain.com"

# Webhook
export F5_WEBHOOK_URL="https://your-api.com/webhook"
```

**Usage:**
```bash
# Import with notifications
f5 doc import file.xlsx --notify slack

# Watch with multiple notification channels
f5 doc watch ./input/ --notify slack,email,webhook
```

### Merge & Conflict Resolution

```bash
# Merge two versions
f5 doc merge v1.0.0 v2.0.0 --strategy prefer_newer

# Show conflicts
f5 doc conflicts

# Resolve conflict interactively
f5 doc resolve <conflict-id>

# Rollback to previous version
f5 doc rollback v1.0.0
```

## Documentation

📚 **Full Documentation**: [f5-framework.gitbook.io](https://fujigo.gitbook.io/fujigo-docs/)

## Support & Contact

🌐 **Fujigo Software**: [fujigo-soft.com](https://fujigo-soft.com)

📧 **Contact**: [Contact Us](https://fujigo-soft.com/en/contact.html)

## Version

Current: **1.2.0**

## License

MIT © [Fujigo Software](https://fujigo-soft.com)

---

**Built with ❤️ by Fujigo Software**
