feat: add production init wizard UX

This commit is contained in:
thanhnv
2026-07-24 12:30:37 +07:00
parent eb3525456f
commit bfebfa9d39
7 changed files with 597 additions and 255 deletions
+9 -7
View File
@@ -60,17 +60,19 @@ pwsh .\install.ps1
cd C:\work\my-project
# Menu chọn Claude / Codex / VS Code Copilot
# Project mới: menu chọn Managed/Vendored, sau đó chọn client
casan init
# Hoặc non-interactive, chọn chính xác client
casan init --client claude,codex --mode enforce
casan init --client vscode-copilot --mode enforce --vscode-install yes
# Hoặc non-interactive, chọn chính xác runtime và client
casan init --non-interactive --runtime managed --client claude,codex --mode enforce
casan init --non-interactive --runtime vendored --client vscode-copilot --mode enforce --vscode-install yes
```
`init` merge CASAN handlers vào config hiện hữu, ghi bootstrap
`.casan\casan-hook.py`, pin harness global, và tạo VSIX `@casan` khi Copilot
được chọn. Bootstrap tự load `config.json`; không cần source env thủ công.
`.casan\casan-hook.py`, pin Core runtime đã resolve, và tạo VSIX `@casan` khi
Copilot được chọn. Managed dùng global installation; Vendored copy Core
production-only vào `.casan\runtime\casan-core`. Bootstrap tự load
`config.json`; không cần source env thủ công.
> Đường dẫn có dấu cách được xử lý đúng (ví dụ `C:\Users\Nguyen Van A\project`).
@@ -117,5 +119,5 @@ cho automation tương thích cũ.
| Codex không chạy hook | Chưa qua trust review | Mở repo trong Codex, chấp nhận trust; chạy lại doctor |
| Turn hiện `observed_only` | Đang ở observe mode hoặc client ngoài allowlist | Chạy lại `casan init --mode enforce --client ...` |
| Token/cost là `null` | Client chưa cấp nguồn usage đáng tin | Đúng theo thiết kế — không bịa số; `telemetry_quality=partial` |
| `casan doctor` báo integrity/bootstrap missing | Global install hoặc project init chưa đầy đủ | Chạy lại `install.ps1`, rồi `casan init` |
| `casan doctor` báo integrity/bootstrap missing | Runtime đã chọn hoặc project init chưa đầy đủ | Managed: chạy lại `install.ps1`; Vendored: chạy `casan init --runtime vendored`; sau đó chạy doctor |
| Mọi turn hiện `observed_only` trên Windows | Không có `bash` (thiếu Git Bash) → gate H4/H2 không chạy | Cài Git for Windows hoặc set `CASAN_AGENTIC_BASH`; `doctor` sẽ báo `gates_runnable=true` |
+22 -7
View File
@@ -64,7 +64,7 @@ cục bộ), `CASAN_DIST_URL` (tải tarball), `CASAN_NO_PATH_LINK=1` (không t
```bash
cd <dự-án-của-bạn>
casan init # mặc định project Level 1/core; interactive chọn client
casan init # project mới: interactive chọn runtime rồi client
# hoặc chọn level áp dụng cho project:
casan init --level 1 --project my-app --client claude
casan init --level 2 --project my-app --client claude,codex
@@ -74,8 +74,14 @@ casan level show # xem level đã cài + level project
casan level set 2 # đổi level project (không cần init lại)
```
Project mới chạy trong terminal tương tác sẽ được hỏi vị trí Core trước:
`Managed (Recommended)` hoặc `Vendored`, sau đó mới chọn client. Nhấn Enter dùng
Managed và Claude+Codex. Nhập sai sẽ được hỏi lại thay vì kết thúc bằng payload
khó đọc.
`init` và `level show` luôn in runtime mode/path. Project mới mặc định
`managed`; chạy lại init giữ nguyên mode đã chọn. Chuyển mode phải explicit:
`managed`; chạy lại init giữ nguyên mode đã chọn và không hỏi lại runtime.
Chuyển mode phải explicit:
```bash
casan init --runtime managed
@@ -111,7 +117,7 @@ file đã chỉnh sửa được giữ lại. Thêm `--purge` để xóa cả ru
| `.casan/config.json` | project id, enforcement/integration mode, clients |
| `.casan/version.lock` | **pin** harness version + hash gate-code |
| `.casan/agentic.env` | feature flags bridge Plan-20 |
| `.casan/casan-hook.py` | bootstrap stdlib: load config, resolve + verify harness global, dispatch adapter |
| `.casan/casan-hook.py` | bootstrap stdlib: load config, resolve + verify Core managed/vendored, dispatch adapter |
| `.specify/` | thư mục state runtime (logs/trace/admission) |
| `.claude/settings.json` | hook Claude Code (Plan-20) |
| `.codex/hooks.json` | hook Codex theo schema hiện hành; cần review/trust bằng `/hooks` |
@@ -120,8 +126,16 @@ file đã chỉnh sửa được giữ lại. Thêm `--purge` để xóa cả ru
Tham số `--client` có thể lặp hoặc comma-separated:
`claude`, `codex`, `vscode-copilot`, `all`, `none`. Khi chạy `casan init` trực
tiếp trong terminal, CLI hiển thị menu chọn. Trong automation không có TTY,
mặc định tương thích ngược là `claude,codex`.
tiếp trong terminal, CLI hiển thị menu chọn. Trong automation, dùng
`--non-interactive` và khai báo rõ runtime/client:
```bash
casan init --non-interactive --level core --runtime managed \
--mode enforce --client claude,codex
```
`--non-interactive`, `--json` hoặc môi trường không có TTY không bao giờ chờ
input. Khi không truyền lựa chọn, mặc định là Managed và `claude,codex`.
Các command dành cho người vận hành (`init`, `doctor`, `verify-harness`,
`level show`, `uninstall`) mặc định in bản tóm tắt dễ đọc. Thêm `--json` sau
@@ -139,8 +153,9 @@ telemetry-only. `--integration-mode` nhận
hiện tại.
Bootstrap `.casan/casan-hook.py` tự đọc `config.json`; developer không còn phải
source `.casan/agentic.env` trước khi mở IDE. Mỗi invocation kiểm tra live hash
của harness global so với `version.lock` trước khi chạy adapter.
source `.casan/agentic.env` trước khi mở IDE. Mỗi invocation resolve Core theo
runtime mode rồi kiểm tra live hash so với `version.lock` trước khi chạy
adapter.
### Project đã có `.claude`, `.github`, agents, skills hoặc CASAN vendored