npm package: @hapico/cli
Description: A simple CLI tool for project management
Author: Your Name
Latest version: 0.0.33

# Hapico CLI Orchestrator

**Hapico CLI** is a high-performance development lifecycle tool engineered for the **[com.ai.vn](https://com.ai.vn)** ecosystem. It bridges the gap between local high-fidelity development and cloud-native execution, leveraging binary-compressed synchronization and neural-enhanced code intelligence.

[![NPM Version](https://img.shields.io/npm/v/hapico.svg?style=flat-square&color=007acc)](https://www.npmjs.com/package/hapico)
[![Platform](https://img.shields.io/badge/Platform-COM.AI.VN-orange.svg?style=flat-square)](https://com.ai.vn)
[![License](https://img.shields.io/badge/License-Proprietary-red.svg?style=flat-square)](https://com.ai.vn)

---

## 🛠 Core Architecture

- **Stateful Sync Engine**: Utilizes WebSockets with **Pako (Zlib) compression** for ultra-low latency differential state synchronization.
- **Neural Orchestration (`vibe`)**: Integrated AI agent capable of contextual project analysis and non-destructive refactoring.
- **Cross-Platform Bridge**: Unified pipeline supporting Web (React), Mobile (Expo/React Native), and Zalo Mini App ecosystems.
- **Atomic Deployment**: Guarantees consistency across main projects and distributed replicas through transactional push-to-publish cycles.

---

## 📦 Rapid Deployment

Bootstrap your environment globally via your preferred package manager:

```bash
npm install -g @hapico/cli
# - or -
yarn global add @hapico/cli
```

---

## 🎮 Command Specification

### 1. Identity & Security

| Command | Capability | Implementation |
| :--- | :--- | :--- |
| `hapico login` | **Device Authorization** | Initiates OAuth2 Device Flow (RFC 8628). Stores encrypted tokens in local secure context. |
| `hapico logout` | **Session Termination** | Revokes local authorization state and flushes cache. |

### 2. Workspace Provisioning

#### `hapico clone <project_id>`
Provision a new workspace. This command performs a three-stage initialization:
1.  **Metadata Discovery**: Resolves project architecture and type.
2.  **Template Injection**: Hydrates the local environment with standardized scaffolds.
3.  **State Recovery**: Synchronizes the latest production and draft source files via binary decompression.

#### `hapico pull`
Synchronizes the local `src` directory with the upstream server state. Essential for multi-agent collaboration and IDE parity.

### 3. Continuous Integration & Delivery

#### `hapico push`
Triggers a delta-update to the remote server. 
- Orchestrates multi-target sync for all **Replicas** defined in `hapico.config.json`.
- Transpiles and synchronizes critical root-level assets (`.env`, `package.json`, `tsconfig.json`).

#### `hapico publish`
Executes an atomic **Push + Build + Deploy** sequence. This ensures that the code currently in your local buffer is the exact version promoted to production across all primary and replica endpoints.

### 4. Development & Intelligence

#### `hapico dev [--zversion <v>]`
Spawns the local development runtime:
- **Hot-Reload Watcher**: Monitors filesystem I/O and streams updates via binary WebSocket packets.
- **Dynamic Previews**: 
    - **Web**: Instant browser orchestration.
    - **Mobile**: Real-time QR generation for Expo Go and Zalo testing environments.
- **NativeWind JIT**: Integrated Just-In-Time compilation for Tailwind-based mobile styling.

#### `hapico vibe`
The **Neural Intelligence** interface. It injects an AI agent into your local context to perform high-order refactoring, logic optimization, and feature synthesis based on the current project's AST.

#### `hapico mirror`
Generates an LLM-optimized context snapshot (`hapico_files.txt`). This aggregates the entire codebase into a single formatted stream for feeding into Large Language Models.

---

## ⚙️ Infrastructure Configuration

Project behavior is governed by `hapico.config.json` at the root level:

```json
{
  "projectId": "12345",
  "replicate": ["67890", "11223"]
}
```

- **`projectId`**: The authoritative UUID for the primary cloud container.
- **`replicate`**: A vector of IDs for automated mirroring during deployment cycles.

---

## 📂 System Topology

Hapico mandates a strict, high-efficiency directory structure:
- **`/src`**: Authoritative source code container (TSX/JSX/CSS).
- **`.env*`**: Context-aware environment variables (synced securely).
- **`nativewind.json`**: Styling configuration for mobile runtimes.

---

## 🌐 Preview Matrix

| Runtime Environment | Protocol | Access Method |
| :--- | :--- | :--- |
| **Enterprise Web** | HTTP/S | Browser Orchestration |
| **Expo (Native)** | `exp://` | Expo Go QR Code |
| **Zalo Mini App** | `zalo://` | Zalo Player QR Code |

---

## ⚖️ Proprietary Notice

Copyright © 2024 **COM.AI.VN**. 
Engineered for professionals who demand low-latency, AI-augmented development workflows.