# DeepSeek Harness (dsh) — Hướng dẫn cài đặt trên Linux

## Giới thiệu
DeepSeek Harness (`dsh`) là agent harness mã nguồn mở do **DeepSeek AI** phát triển.
- Kiến trúc: **mọi thứ là plugin** (everything is a plugin)
- Nền tảng: **Cordis**
- Ngôn ngữ: TypeScript (Node.js ^22.19 hoặc >=24), có thêm phần Python SDK + native Landlock

## Yêu cầu hệ thống
- **Node.js** >= 22.19 (khuyến nghị 22 LTS)
- **pnpm** >= 9
- **Git** >= 2.26
- Linux (hỗ trợ Landlock cho sandbox)

## Cách 1: Cài trực tiếp từ npm (đơn giản nhất)
```sh
# Cài Node.js trước (nếu chưa có) — khuyến nghị dùng nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install 22

# Cài pnpm
npm install -g pnpm

# Chạy DeepSeek Harness Web UI
npx @deepseek-ai/dsh web
# Mở trình duyệt: http://127.0.0.1:3080
```

## Cách 2: Chạy từ source (bản đầy đủ)
```sh
git clone https://github.com/deepseek-ai/deepseek-harness.git
cd deepseek-harness
pnpm install
pnpm run build
pnpm dsh web
```

## Cách 3: Chạy headless (CLI, không server)
```sh
pnpm dsh --profile headless run "viết game flappy bird bằng python"
```

## Cấu trúc repo
```
deepseek-harness/
├── apps/
│   ├── cli/          # CLI chính (bin: dsh)
│   └── web/          # Web UI frontend
├── packages/         # ~50 packages (core, llm, tools, sandbox, mcp, session...)
├── python/           # Python SDK + runtime
├── native/           # landlock-run (C11, sandbox Linux)
├── docs/             # Tài liệu
└── examples/         # Ví dụ
```

## Các lệnh dsh chính
```sh
dsh web                    # Chạy Web UI (port 3080 mặc định)
dsh --profile web --dump-config  # Xem cấu hình plugin tree
dsh --profile headless run "prompt"  # Chạy 1 lần không server
```

## Ghi chú Linux
- VPS Ubuntu 20.04 cần **Git >= 2.26** (bản mặc định 2.25 quá cũ):
  ```sh
  add-apt-repository ppa:git-core/ppa && apt-get update && apt-get install -y git
  ```
- Sandbox dùng **Landlock** — nếu kernel không hỗ trợ sẽ fail-closed (an toàn)

## Bản phân phối đi kèm
- `deepseek-harness-src.tar.gz` — source code đầy đủ (sau khi build: node_modules có sẵn)