opencode-agent-skill 13.0.0-beta.1 → 14.2.0-beta.1

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 (95) hide show
  1. package/README.md +1557 -606
  2. package/bin/ocskill.mjs +172 -24
  3. package/docs/OPENCODE-COMPAT.md +34 -95
  4. package/docs/PI-COMPAT.md +188 -0
  5. package/docs/V14-CONTEXT-MEMORY-FABRIC.md +70 -0
  6. package/docs/V14.1-QUALITY-PERFORMANCE-FABRIC.md +114 -0
  7. package/docs/V14.2-TURBO-WEAK-MODEL-RUNTIME.md +448 -0
  8. package/evals/v14/tasks.json +46 -0
  9. package/global-config/agents/executor.md +7 -0
  10. package/global-config/agents/visual-verifier.md +22 -3
  11. package/global-config/commands/run.md +27 -20
  12. package/global-config/plugins/ues-router/command-runtime.js +54 -0
  13. package/global-config/plugins/ues-router/index.js +30 -24
  14. package/global-config/plugins/ues-router/policy-runtime.js +7 -0
  15. package/global-config/plugins/ues-router/router.js +12 -2
  16. package/global-config/skills/ecommerce-engineering/SKILL.md +1 -1
  17. package/global-config/skills/file-upload-engineering/SKILL.md +1 -1
  18. package/global-config/skills/git-safety/SKILL.md +1 -1
  19. package/global-config/skills/nestjs-engineering/SKILL.md +1 -1
  20. package/global-config/skills/performance-engineering/SKILL.md +1 -1
  21. package/global-config/skills/react-native-engineering/SKILL.md +1 -1
  22. package/global-config/skills/rest-api-design/SKILL.md +1 -1
  23. package/global-config/skills/ui-ux-engineering/SKILL.md +1 -1
  24. package/lib/adaptive-context-budget.mjs +97 -0
  25. package/lib/affected-tests.mjs +260 -0
  26. package/lib/benchmark-confidence.mjs +41 -2
  27. package/lib/browser-mcp-routing.mjs +166 -0
  28. package/lib/capability-fabric.mjs +336 -0
  29. package/lib/capability-registry.mjs +9 -0
  30. package/lib/context-engine-v11.mjs +65 -1
  31. package/lib/context-graph-rank.mjs +118 -0
  32. package/lib/context-manifest.mjs +97 -18
  33. package/lib/control-center.mjs +19 -1
  34. package/lib/dynamic-workflow.mjs +3 -1
  35. package/lib/evidence-store.mjs +82 -1
  36. package/lib/hierarchical-context.mjs +215 -0
  37. package/lib/memory-engine.mjs +465 -0
  38. package/lib/model-performance.mjs +33 -8
  39. package/lib/model-policy.mjs +3 -3
  40. package/lib/orchestrator-policy.mjs +5 -209
  41. package/lib/performance-fabric.mjs +229 -0
  42. package/lib/pi-rpc-pool.mjs +433 -0
  43. package/lib/process-hang-detector.mjs +83 -0
  44. package/lib/process-supervisor.mjs +193 -0
  45. package/lib/prompt-cache.mjs +2 -0
  46. package/lib/repo-graph.mjs +53 -2
  47. package/lib/runtime-config.mjs +31 -0
  48. package/lib/safety.mjs +132 -0
  49. package/lib/semantic-index.mjs +52 -3
  50. package/lib/skill-compiler.mjs +128 -0
  51. package/lib/skill-quality.mjs +48 -2
  52. package/lib/task-engine.mjs +66 -5
  53. package/lib/task-policy.mjs +235 -0
  54. package/lib/verification-broker.mjs +284 -0
  55. package/lib/verification-command.mjs +111 -0
  56. package/lib/windows-shim.mjs +35 -0
  57. package/lib/workspace-fingerprint.mjs +198 -0
  58. package/package.json +52 -42
  59. package/pi/extensions/ues-child-runtime.ts +238 -0
  60. package/pi/extensions/ues.ts +3200 -0
  61. package/pi/prompts/ues-audit.md +9 -0
  62. package/pi/prompts/ues-critique.md +9 -0
  63. package/pi/prompts/ues-debug.md +9 -0
  64. package/pi/prompts/ues-feature.md +9 -0
  65. package/pi/prompts/ues-fix.md +9 -0
  66. package/pi/prompts/ues-plan.md +9 -0
  67. package/pi/prompts/ues-research.md +9 -0
  68. package/pi/prompts/ues-resume.md +9 -0
  69. package/pi/prompts/ues-review.md +7 -0
  70. package/pi/prompts/ues-run.md +17 -0
  71. package/pi/prompts/ues-verify.md +9 -0
  72. package/scripts/check-release-consistency.mjs +119 -185
  73. package/scripts/check-runtime-exports.mjs +66 -0
  74. package/scripts/check-source-integrity.mjs +184 -0
  75. package/scripts/eval-pi.mjs +492 -0
  76. package/scripts/install.mjs +16 -0
  77. package/scripts/smoke-package-closure.mjs +110 -0
  78. package/scripts/smoke-packed-install.mjs +24 -11
  79. package/scripts/smoke-pi-extension.mjs +144 -0
  80. package/scripts/uninstall.mjs +44 -0
  81. package/CHANGELOG.md +0 -405
  82. package/docs/DETERMINISTIC-TOOLS.md +0 -105
  83. package/docs/ENGINEERING-DESIGN.md +0 -194
  84. package/docs/EVALS.md +0 -158
  85. package/docs/GITHUB-RULESET.md +0 -50
  86. package/docs/NPM-PUBLISH.md +0 -116
  87. package/docs/RESEARCH-SOURCES.md +0 -37
  88. package/docs/TRACE-SCHEMA.md +0 -122
  89. package/docs/V11-PERCEPTION-ADAPTIVE-EXECUTION.md +0 -75
  90. package/docs/V11-PERCEPTION-ADAPTIVE.md +0 -220
  91. package/docs/V12-WEAK-MODEL-INTELLIGENCE.md +0 -27
  92. package/docs/V13-PARALLEL-WEAK-MODEL-RUNTIME.md +0 -75
  93. package/docs/V7-INTELLIGENCE-RUNTIME.md +0 -166
  94. package/docs/V8-INTELLIGENCE-RELIABILITY.md +0 -206
  95. package/docs/V9-SPEED-INTELLIGENCE.md +0 -102
package/README.md CHANGED
@@ -1,847 +1,1798 @@
1
- # OpenCode Universal Engineering System (UES)
1
+ # UES for Pi Agent
2
2
 
3
- > **V13 beta: 13.0.0-beta.1** — parallel weak-model runtime với same-model worker pool, event-driven DAG, transactional worktree integration và hardened CLI/Windows runtime.
4
- > **Stable latest vẫn là V11: 11.0.0.** V13 được đóng gói dưới prerelease `13.0.0-beta.1`; npm prerelease dùng dist-tag `next`, còn `latest` tiếp tục giữ V11 cho đến khi V13 được promote stable.
3
+ > Universal Engineering System (UES) là một engineering runtime dành cho **Pi Agent**, tập trung vào việc giúp model coding nhỏ/yếu làm việc có cấu trúc hơn trên repository thật: lấy đúng context, chia task, giữ trạng thái dài hạn, cô lập thay đổi, thu evidence và chỉ kết luận khi có verification.
5
4
 
6
- [![npm version](https://img.shields.io/npm/v/opencode-agent-skill.svg)](https://www.npmjs.com/package/opencode-agent-skill)
7
- [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+ **Package:** <code>opencode-agent-skill</code>
6
+ **Host chính:** Pi Agent
7
+ **Phiên bản package hiện tại:** <code>14.2.0-beta.1</code>
8
+ **Nhánh phát triển hiện tại:** V14.2 Turbo Weak-Model Runtime
9
+ **Runtime:** Node.js 22.19+
10
+ **License:** MIT
8
11
 
9
- ## Giới thiệu
12
+ > UES không biến một model nhỏ thành model lớn theo nghĩa năng lực nền tảng. UES cố gắng giảm phần suy luận hạ tầng mà model phải tự gánh bằng deterministic tooling, bounded context, specialist roles, durable state và evidence-gated verification.
10
13
 
11
- **OpenCode Universal Engineering System (UES)** là một engineering harness dành cho OpenCode. UES không thay đổi năng lực nền tảng của model, mà tổ chức cách model làm việc để:
14
+ ---
15
+
16
+ ## Mục lục
17
+
18
+ 1. [UES giải quyết vấn đề gì?](#ues-giải-quyết-vấn-đề-gì)
19
+ 2. [Kiến trúc tổng thể](#kiến-trúc-tổng-thể)
20
+ 3. [Luồng /ues-run end-to-end](#luồng-ues-run-end-to-end)
21
+ 4. [Task Policy: FAST / STANDARD / DEEP](#task-policy-fast--standard--deep)
22
+ 5. [12 specialist agents](#12-specialist-agents)
23
+ 6. [48 skills](#48-skills)
24
+ 7. [11 slash prompts](#11-slash-prompts)
25
+ 8. [Context Engine L0/L1/L2](#context-engine-l0l1l2)
26
+ 9. [Semantic index, repo graph và ACI](#semantic-index-repo-graph-và-aci)
27
+ 10. [Model routing và recovery](#model-routing-và-recovery)
28
+ 11. [Task graph, Dynamic Workflow và parallel runtime](#task-graph-dynamic-workflow-và-parallel-runtime)
29
+ 12. [Worktree sandbox](#worktree-sandbox)
30
+ 13. [Evidence Store, receipts và verification gates](#evidence-store-receipts-và-verification-gates)
31
+ 14. [V14.1 reversible output compaction](#v141-reversible-output-compaction)
32
+ 15. [V14.2 Turbo Weak-Model Runtime](#v142-turbo-weak-model-runtime)
33
+ 16. [Verified Persistent Memory](#verified-persistent-memory)
34
+ 17. [Capability Fabric](#capability-fabric)
35
+ 18. [Playwright / Browser MCP on-demand](#playwright--browser-mcp-on-demand)
36
+ 19. [Trajectory và observability](#trajectory-và-observability)
37
+ 20. [Learning engine và benchmark confidence](#learning-engine-và-benchmark-confidence)
38
+ 21. [Durable long-horizon work](#durable-long-horizon-work)
39
+ 22. [Control Center](#control-center)
40
+ 23. [Safety model](#safety-model)
41
+ 24. [Cài đặt](#cài-đặt)
42
+ 25. [Cập nhật](#cập-nhật)
43
+ 26. [Đóng gói npm](#đóng-gói-npm)
44
+ 27. [Các CLI quan trọng](#các-cli-quan-trọng)
45
+ 28. [Benchmark model yếu](#benchmark-model-yếu)
46
+ 29. [Cấu trúc repository](#cấu-trúc-repository)
47
+ 30. [Triết lý thiết kế](#triết-lý-thiết-kế)
48
+ 31. [Giới hạn có chủ đích](#giới-hạn-có-chủ-đích)
49
+
50
+ ---
51
+
52
+ # UES giải quyết vấn đề gì?
12
53
 
13
- - giảm lượng thông tin phải giữ trong một context dài;
14
- - chia tác vụ lớn thành các bước rõ ràng;
15
- - lưu trạng thái ra filesystem để có thể tiếp tục sau khi session bị ngắt;
16
- - chạy executor bằng context mới cho từng tác vụ;
17
- - yêu cầu bằng chứng kiểm thử trước khi đánh dấu hoàn tất;
18
- - kiểm tra thay đổi ở mức task và mức tích hợp toàn hệ thống;
19
- - hỗ trợ routing skill, model tier, task policy và recovery theo trạng thái thực tế của repository.
54
+ Một coding model yếu thường gặp các vấn đề sau khi làm việc trên repository thật:
20
55
 
21
- Mục tiêu của UES là giúp quá trình làm việc với coding agent **ổn định hơn, có thể kiểm chứng hơn và phù hợp hơn với repository lớn**.
56
+ | Vấn đề | Nếu để model tự xử lý | UES xử lý thế nào |
57
+ |---|---|---|
58
+ | Repository lớn | đọc quá nhiều file, mất context | semantic index + hierarchy L0/L1/L2 + bounded context |
59
+ | Task dài | quên mục tiêu, lặp lại việc | durable work state + PLAN/STATE/EVENTS |
60
+ | Nhiều thay đổi song song | đụng file, ghi đè nhau | task graph + safe waves + worktree sandbox |
61
+ | Không biết test gì | chạy full CI hoặc đoán | detect-tests + verification plan + declared verification commands |
62
+ | Model báo xong quá sớm | false PASS | verifier + integration-verifier + receipts |
63
+ | Retry mù | vá chồng vá | diagnosis-first recovery policy |
64
+ | Log quá lớn | token phình | reversible model-visible compaction |
65
+ | Tool quá nhiều | model chọn sai tool | role allowlist + capability-based routing |
66
+ | UI/browser | đoán thay vì quan sát | Playwright/Browser MCP lane + visual verifier |
67
+ | Kinh nghiệm cũ | nhớ sai hoặc nhiễm | verified persistent memory |
68
+ | Tối ưu không có bằng chứng | nhanh hơn nhưng yếu đi | baseline-vs-UES eval + promotion confidence |
22
69
 
23
70
  ---
24
71
 
72
+ # Kiến trúc tổng thể
73
+
74
+ ~~~mermaid
75
+ flowchart TD
76
+ U[User task] --> P[Pi Agent]
77
+ P --> X[UES extension]
78
+
79
+ X --> TP[Task Policy]
80
+ TP --> C[Context Engine]
81
+ TP --> M[Model Policy]
82
+ TP --> W[Workflow Policy]
83
+
84
+ C --> H[Hierarchy L0 L1 L2]
85
+ C --> SI[Semantic Index]
86
+ C --> MEM[Verified Memory]
87
+ C --> CAP[Capability Fabric]
88
+ C --> EV[Evidence Store]
89
+
90
+ W --> A[Specialist Agents]
91
+ W --> TG[Task Graph]
92
+ W --> DW[Dynamic Workflow]
93
+ W --> SB[Worktree Sandbox]
94
+
95
+ A --> EX[Executor]
96
+ A --> VE[Verifier]
97
+ A --> IV[Integration Verifier]
98
+ A --> VV[Visual Verifier]
99
+
100
+ EX --> CHECK[Project-native checks]
101
+ VE --> CHECK
102
+ IV --> CHECK
103
+ VV --> BROWSER[Playwright Browser evidence]
25
104
 
26
- ## V13 beta: Parallel Weak-Model Runtime
105
+ CHECK --> R[Fresh Evidence]
106
+ BROWSER --> R
107
+ R --> G{Verification gates}
108
+ G -->|PASS| DONE[Verified completion]
109
+ G -->|FAIL| REC[Diagnosis and bounded retry]
110
+ REC --> C
111
+ ~~~
27
112
 
28
- V13 cho phép **một model duy nhất** chạy nhiều fresh child sessions song song. `ues.dispatch_parallel` chọn một shared model (hoặc giữ OpenCode default model), chạy các task độc lập theo event-driven DAG, dùng resource lease để tránh writer conflict, tạo worktree riêng cho writer, dùng fresh same-model `ues-verifier`, rồi tích hợp tuần tự. Nếu bước receipt/complete thất bại sau khi patch đã áp dụng, integration transaction tự rollback patch của task đó.
113
+ ## Các lớp chính
29
114
 
30
- ```text
31
- approved PLAN
32
- ↓
33
- event-driven DAG
34
- ↓
35
- same model × N fresh sessions
36
- ↓
37
- isolated worktrees + resource leases
38
- ↓
39
- fresh same-model verifier
40
- ↓
41
- transactional integration queue
42
- ↓
43
- unlock dependencies immediately
44
- ```
115
+ ### 1. Pi host layer
45
116
 
46
- CLI V13 cũng xử lý `--help` trước positional parsing, hỗ trợ `ocskill work status .`, structured errors với `--json`, đọc UTF-8/UTF-16 an toàn và cung cấp `ocskill diff . --out dirty.diff` để tránh PowerShell tạo diff UTF-16 bị OpenCode nhận nhầm là binary.
117
+ Pi chịu trách nhiệm session, model provider, thinking level, built-in tools và extension runtime.
47
118
 
48
- Parallel resume không còn yêu cầu root phải sạch tuyệt đối. Nếu repository đã có dirty diff hợp lệ từ phiên trước, V13 chụp baseline đó vào worktree cô lập và chỉ tích hợp delta của task; thay đổi cũ được giữ nguyên. Root vẫn phải là Git repository và resource leases vẫn chặn các writer xung đột.
119
+ ### 2. UES Pi extension
49
120
 
50
- > **Compatibility:** V13 CLI/durable-state/verification hardening vẫn dùng được trên OpenCode 1.x. Native `ues.dispatch_task` / `ues.dispatch_parallel` cần router plugin và fresh-session APIs của OpenCode V2; nếu capability không đủ, runtime fail closed thay vì giả vờ chạy song song.
121
+ File chính: <code>pi/extensions/ues.ts</code>.
51
122
 
52
- ### V13 beta validation baseline
123
+ Extension đăng ký ba tool orchestration:
53
124
 
54
- Baseline beta.0 đã được kiểm tra local trên Windows 10 với OpenCode V2.0.15; beta.1 phải chạy lại full gate trước khi publish:
125
+ | Tool | Vai trò |
126
+ |---|---|
127
+ | <code>ues_execute</code> | Chạy task engineering end-to-end |
128
+ | <code>ues_cli</code> | Gọi deterministic UES CLI không qua shell interpolation |
129
+ | <code>ues_dispatch</code> | Gọi specialist child agents theo single / chain / bounded parallel |
130
+
131
+ ### 3. Deterministic engine
132
+
133
+ Thư mục <code>lib/</code> chứa các engine cho:
134
+
135
+ - task/risk classification;
136
+ - semantic index;
137
+ - repo graph;
138
+ - context manifest;
139
+ - evidence storage;
140
+ - receipts;
141
+ - work state;
142
+ - task graph;
143
+ - safe-wave scheduling;
144
+ - model routing;
145
+ - memory;
146
+ - capability selection;
147
+ - browser evidence;
148
+ - benchmark/learning;
149
+ - safety;
150
+ - Windows compatibility.
151
+
152
+ ### 4. Specialist layer
153
+
154
+ UES không dùng một prompt khổng lồ cho mọi việc. Nó có 12 specialist roles với tool boundary khác nhau.
55
155
 
56
- - `npm run evals:v13`: **36/36 PASS**;
57
- - `npm test`: **298 tests**, **296 pass**, **0 fail**, **2 platform-specific skip**;
58
- - managed `ues-router` load thành công dưới `~/.config/opencode/plugins/ues-router`;
59
- - router không còn phụ thuộc runtime bare import `@opencode/plugin`, nên clean global OpenCode config vẫn load được;
60
- - các subprocess nội bộ của router (`where`, `ocskill`, Node shim và Git probes) dùng hidden-window spawn trên Windows để tránh cửa sổ CMD nháy liên tục;
61
- - npm 11+ vẫn có thể chặn lifecycle script theo `allowScripts`; `ocskill install` là resource-sync fallback chính thức.
156
+ ### 5. Verification layer
157
+
158
+ Hoàn thành không đồng nghĩa model nói “done”. UES cố gắng ràng buộc completion với fresh evidence, receipt và verifier độc lập.
62
159
 
63
160
  ---
64
161
 
162
+ # Luồng /ues-run end-to-end
163
+
164
+ <code>/ues-run</code> là entry point khuyến nghị cho engineering task.
165
+
166
+ ~~~mermaid
167
+ sequenceDiagram
168
+ participant U as User
169
+ participant P as Pi
170
+ participant UES as UES Controller
171
+ participant CTX as Context Engine
172
+ participant EX as Executor
173
+ participant V as Verifier
174
+ participant IV as Integration Verifier
175
+ participant VV as Visual Verifier
176
+
177
+ U->>P: /ues-run task
178
+ P->>UES: ues_execute(task)
179
+ UES->>UES: classify task/risk/profile
180
+ UES->>CTX: build bounded context
181
+ CTX-->>UES: hierarchy + evidence + memory + capability hints
182
+
183
+ alt long/high risk
184
+ UES->>UES: architect + structured plan
185
+ UES->>UES: plan-checker gate
186
+ end
187
+
188
+ UES->>EX: fresh specialist execution
189
+ EX-->>UES: implementation handoff
190
+
191
+ UES->>V: independent verification
192
+ V-->>UES: PASS / FAIL / PARTIAL
193
+
194
+ alt integration required
195
+ UES->>IV: cross-task/final repository verification
196
+ IV-->>UES: PASS / FAIL / PARTIAL
197
+ end
198
+
199
+ alt visual/browser evidence required
200
+ UES->>VV: rendered-state verification
201
+ VV-->>UES: PASS / FAIL / PARTIAL
202
+ end
203
+
204
+ alt all required gates PASS
205
+ UES-->>P: verified completion
206
+ P-->>U: final result
207
+ else failure
208
+ UES->>UES: diagnosis / recovery / bounded retry
209
+ end
210
+ ~~~
211
+
212
+ ## UES không làm gì ở luồng này?
213
+
214
+ - không tự push;
215
+ - không tự publish npm;
216
+ - không tự deploy production;
217
+ - không coi executor report là bằng chứng hoàn thành;
218
+ - không bỏ verifier chỉ vì compile pass;
219
+ - không lưu hidden chain-of-thought.
220
+
221
+ ---
222
+
223
+ # Task Policy: FAST / STANDARD / DEEP
224
+
225
+ Task Policy nằm trong <code>lib/task-policy.mjs</code> và phân loại task theo tín hiệu có thể quan sát.
65
226
 
66
- ## Cài đặt
227
+ ~~~mermaid
228
+ flowchart LR
229
+ T[Task text + repo facts] --> S[Risk and complexity signals]
67
230
 
68
- Yêu cầu:
231
+ S --> F{Classification}
232
+ F -->|low + bounded| FAST[FAST]
233
+ F -->|medium| STD[STANDARD]
234
+ F -->|long horizon or high risk| DEEP[DEEP]
69
235
 
70
- - Node.js 20 trở lên;
71
- - npm;
72
- - OpenCode.
236
+ FAST --> F1[8k context budget]
237
+ FAST --> F2[max 2 skills]
238
+ FAST --> F3[targeted verification]
73
239
 
74
- Cài đặt stable hiện tại từ npm:
240
+ STD --> S1[20k context budget]
241
+ STD --> S2[max 4 skills]
242
+ STD --> S3[targeted + affected verification]
75
243
 
76
- ```cmd
77
- npm install -g opencode-agent-skill
78
- ```
244
+ DEEP --> D1[48k context budget]
245
+ DEEP --> D2[max 5 skills]
246
+ DEEP --> D3[plan + integration + durable state]
247
+ ~~~
79
248
 
80
- Cài V13 beta từ npm sau khi prerelease đã có trên registry:
249
+ ## FAST
81
250
 
82
- ```cmd
83
- npm install -g opencode-agent-skill@next
84
- ocskill install
85
- ```
251
+ Dành cho task nhỏ, low-risk, bounded.
86
252
 
87
- Nếu đang kiểm thử một commit mới hơn bản registry, cài trực tiếp từ checkout:
253
+ Đặc điểm:
88
254
 
89
- ```cmd
90
- npm install -g .
91
- ocskill install
92
- ```
255
+ - context budget mặc định khoảng 8k;
256
+ - tối đa 2 skills;
257
+ - direct skill loading;
258
+ - không bắt durable work;
259
+ - verification targeted;
260
+ - không bật full CI mặc định.
93
261
 
94
- Kiểm tra:
262
+ ## STANDARD
95
263
 
96
- ```cmd
97
- ocskill version
98
- ocskill status
99
- ocskill doctor
100
- ```
264
+ Dành cho task vừa, có debugging/change scope đáng kể.
101
265
 
102
- Nếu npm không chạy lifecycle script trong lúc cài đặt (npm 11+ có thể cảnh báo `install-scripts ... not yet covered by allowScripts`), package CLI vẫn có thể đã được cài. Chạy resource sync rõ ràng:
266
+ Đặc điểm:
103
267
 
104
- ```cmd
105
- ocskill install
106
- ```
268
+ - context budget khoảng 20k;
269
+ - tối đa 4 skills;
270
+ - selective skill loading;
271
+ - affected verification;
272
+ - worktree khi có conflict.
107
273
 
108
- Đây là fallback được CI smoke kiểm tra; không cần dùng `--force` chỉ để vượt cảnh báo lifecycle script.
274
+ ## DEEP
109
275
 
110
- Sau khi cài hoặc cập nhật UES, hãy restart OpenCode service rồi mở một session mới để skill, command, subagent và plugin được nạp lại đầy đủ:
276
+ Dành cho long-horizon/high-risk.
111
277
 
112
- ```cmd
113
- opencode service restart
114
- ```
278
+ Đặc điểm:
115
279
 
116
- Trên OpenCode V2 có thể kiểm tra router bằng `/plugins`, sau đó gọi `ues.capabilities`. Native parallel chỉ nên dùng khi `freshDispatch` báo `true`.
280
+ - context budget đến khoảng 48k;
281
+ - tối đa 5 skills;
282
+ - structured plan;
283
+ - durable state;
284
+ - plan checker;
285
+ - worktree cho writers;
286
+ - integration verification;
287
+ - full CI policy;
288
+ - critic ở high-risk/final paths.
289
+
290
+ ## High-risk signals
291
+
292
+ UES phân biệt “chỉ nhắc tới database/security” với “thực sự thay đổi database/security”.
293
+
294
+ Những thay đổi như sau có thể nâng risk:
295
+
296
+ - auth/permission/security mutation;
297
+ - payment flow;
298
+ - database/schema migration;
299
+ - production deploy;
300
+ - secret/credential rotation;
301
+ - breaking public API;
302
+ - destructive Git/database action.
117
303
 
118
304
  ---
119
305
 
120
- ## Bắt đầu nhanh
306
+ # 12 specialist agents
307
+
308
+ Thư mục: <code>global-config/agents/</code>.
309
+
310
+ | Agent | Nhiệm vụ | Có ghi file? | Khi dùng |
311
+ |---|---|---:|---|
312
+ | architect | thiết kế plan/contract/dependency | không | task phức tạp, long-horizon |
313
+ | codebase-mapper | đọc repo và map scope | không | repo lớn/không rõ vị trí |
314
+ | critic | phản biện plan/solution | không | high-risk hoặc recovery sâu |
315
+ | debugger | tìm nguyên nhân gốc từ evidence | không | bug/failure/retry |
316
+ | executor | thực thi thay đổi nhỏ nhất hợp lý | có | implementation |
317
+ | integration-verifier | kiểm tra final cross-task state | không | standard/deep/high-risk |
318
+ | merge-arbiter | xử lý integration/merge boundary | có | conflict/merge workflow |
319
+ | plan-checker | kiểm tra plan có grounded không | không | trước long/high-risk execution |
320
+ | researcher | nghiên cứu bằng chứng | không | uncertainty/external facts |
321
+ | reviewer | review thay đổi | không | code review/audit |
322
+ | verifier | fresh independent verification | không | completion gate |
323
+ | visual-verifier | verify rendered UI/browser state | không | visual/browser task |
324
+
325
+ ## Quan hệ giữa các agent
326
+
327
+ ~~~mermaid
328
+ flowchart TD
329
+ MAP[codebase-mapper] --> ARCH[architect]
330
+ ARCH --> PC[plan-checker]
331
+ PC --> EX[executor]
332
+
333
+ EX --> V[verifier]
334
+ V -->|PASS| IV[integration-verifier]
335
+ V -->|FAIL| D[debugger]
336
+
337
+ D --> EX
338
+ D --> C[critic]
339
+ C --> ARCH
340
+
341
+ IV -->|visual task| VV[visual-verifier]
342
+ IV -->|non visual| DONE[complete]
343
+ VV --> DONE
344
+
345
+ R[researcher] -. evidence .-> ARCH
346
+ R -. evidence .-> D
347
+ REV[reviewer] -. review .-> V
348
+ ~~~
121
349
 
122
- Với tác vụ lớn, dùng:
350
+ ---
123
351
 
124
- ```text
125
- /ues-run <yêu cầu>
126
- ```
352
+ # 48 skills
353
+
354
+ UES hiện có 48 skill directories trong <code>global-config/skills/</code>. Skills không phải 48 agent độc lập; chúng là bounded domain instructions để UES chỉ nạp đúng chuyên môn cần thiết.
355
+
356
+ ## Nhóm orchestration và reasoning
357
+
358
+ - engineering-orchestrator
359
+ - dynamic-workflow
360
+ - task-planner
361
+ - software-architect
362
+ - context-engineering
363
+ - change-impact-analysis
364
+ - repo-explorer
365
+ - research-verification
366
+ - long-task-state
367
+ - implementation-engineer
368
+ - bug-diagnosis
369
+ - code-review
370
+ - skill-authoring
371
+ - skill-evaluation
372
+
373
+ ## Nhóm verification và testing
374
+
375
+ - test-driven-development
376
+ - test-verification
377
+ - accessibility
378
+ - responsive-verification
379
+ - component-visual-testing
380
+ - visual-fidelity
381
+ - browser-qa
382
+ - browser-security
383
+ - web-security-review
384
+ - performance-engineering
385
+
386
+ ## Nhóm backend / API / data
387
+
388
+ - api-contract
389
+ - rest-api-design
390
+ - auth-security
391
+ - database-engineering
392
+ - payment-engineering
393
+ - ecommerce-engineering
394
+ - file-upload-engineering
395
+ - dependency-management
396
+ - devops-engineering
397
+ - documentation-engineering
398
+ - git-safety
399
+
400
+ ## Nhóm framework / language
401
+
402
+ - nodejs-engineering
403
+ - nextjs-engineering
404
+ - react-engineering
405
+ - react-native-engineering
406
+ - nestjs-engineering
407
+ - fastapi-engineering
408
+ - django-engineering
409
+ - python-engineering
410
+ - java-spring-engineering
411
+ - dotnet-engineering
412
+ - flutter-engineering
413
+
414
+ ## Nhóm UI/design
415
+
416
+ - ui-ux-engineering
417
+ - design-source
418
+
419
+ > Mục tiêu của skill routing là progressive disclosure: model không phải đọc tất cả 48 skills cho một task.
127
420
 
128
- Nếu session bị ngắt hoặc context bị compact:
421
+ ---
129
422
 
130
- ```text
131
- /ues-resume <slug>
132
- ```
423
+ # 11 slash prompts
133
424
 
134
- Một số lệnh hữu ích:
425
+ Pi package cung cấp 11 slash prompts:
135
426
 
136
- ```cmd
137
- ocskill inspect .
138
- ocskill repo-graph . --compact
139
- ocskill verification-plan .
140
- ocskill task-policy "refactor auth across the whole repository"
141
- ocskill dashboard . --serve
142
- ```
427
+ | Command | Ý nghĩa |
428
+ |---|---|
429
+ | <code>/ues-run</code> | controller end-to-end |
430
+ | <code>/ues-plan</code> | lập kế hoạch |
431
+ | <code>/ues-feature</code> | triển khai feature |
432
+ | <code>/ues-fix</code> | sửa bug |
433
+ | <code>/ues-debug</code> | điều tra failure |
434
+ | <code>/ues-review</code> | review code/scope |
435
+ | <code>/ues-verify</code> | xác minh claim |
436
+ | <code>/ues-audit</code> | audit scope |
437
+ | <code>/ues-research</code> | research |
438
+ | <code>/ues-critique</code> | phản biện proposal |
439
+ | <code>/ues-resume</code> | tiếp tục durable work |
440
+
441
+ ~~~mermaid
442
+ flowchart LR
443
+ CMD[Slash command] --> ROUTE[UES router/controller]
444
+ ROUTE --> POLICY[Task policy]
445
+ POLICY --> AGENT[Relevant specialist path]
446
+ AGENT --> EVIDENCE[Fresh evidence]
447
+ EVIDENCE --> RESULT[Result]
448
+ ~~~
143
449
 
144
450
  ---
145
451
 
146
- ## V11 có gì?
452
+ # Context Engine L0/L1/L2
147
453
 
148
- V11 chuyển UES từ một reliability harness thành **perception-aware adaptive execution engine**. Mục tiêu là model yếu chỉ nhận đúng bằng chứng cần thiết, dùng đúng capability/model/tool và có thể kiểm chứng UI bằng semantic structure + geometry + pixels thay vì đoán từ screenshot.
454
+ Một trong các mục tiêu lớn của UES là **nạp ít context hơn nhưng đúng hơn**.
149
455
 
150
- - content-addressed Evidence Store dưới `.ues-cache/evidence-v1/`; output lớn được lưu theo SHA-256 và context nhận bounded excerpt + `evidence:sha256:...` pointer;
151
- - adaptive EvidenceBudget chia context cho instructions/task/source/tests/references/history/tools theo rủi ro và loại task thay vì luôn tiêu hết FAST/STANDARD/DEEP budget;
152
- - prompt-envelope telemetry tách stable prefix và dynamic tail để đo cacheable ratio/repeated stable input;
153
- - capability-aware model routing bổ sung `vision`, `browser`, `reasoning`, `toolCalling`, `filesystem`, `longContext` nhưng vẫn giữ light/standard/heavy để tương thích;
154
- - `VISUAL_SPEC.json` + geometry receipt kiểm tra vị trí/kích thước element có tolerance rõ ràng;
155
- - zero-dependency PNG diff/crop định vị vùng pixel sai rồi chỉ đưa crop cần thiết cho vision model;
156
- - browser QA dùng targeted semantic/accessibility evidence + bounding boxes + screenshots; webpage content luôn được xem là untrusted;
157
- - responsive viewport matrix và component visual testing/Storybook routing;
158
- - dynamic workflow scheduler tách deterministic task khỏi LLM/vision fan-out, serialize overlapping writers và giới hạn concurrency;
159
- - skill linter đo entrypoint size và description collisions; catalog tăng từ 39 lên **48 skills** nhưng router chỉ load skill có tín hiệu hẹp;
160
- - hai subagent mới: `ues-visual-verifier` và `ues-merge-arbiter`, tổng **12 subagents**;
161
- - Hermes được nâng thành optional sidecar: UES vẫn sở hữu durable state/evidence/safety, Hermes chỉ nhận bounded schedule/context khi được dùng;
162
- - Control Center hiển thị Evidence Store và V11 runtime efficiency state.
456
+ ~~~mermaid
457
+ flowchart TD
458
+ Q[Task query] --> TERM[Extract bounded terms]
459
+ TERM --> IDX[Semantic index]
460
+ IDX --> H0[L0 routing abstract]
461
+ H0 --> H1[L1 subtree overview]
462
+ H1 --> H2[L2 exact excerpts on demand]
163
463
 
164
- Các CLI V11 chính:
464
+ GIT[Git changed files] --> RANK[Ranking]
465
+ DECL[Declared files] --> RANK
466
+ TEST[Likely tests] --> RANK
467
+ SYM[Symbol hits] --> RANK
468
+ MEM[Verified memory] --> RANK
165
469
 
166
- ```cmd
167
- ocskill store status .
168
- ocskill store get evidence:sha256:<hash> . --max 12000
169
- ocskill capabilities "match this screenshot in the browser"
170
- ocskill visual spec VISUAL_SPEC.json
171
- ocskill visual geometry VISUAL_SPEC.json actual-boxes.json
172
- ocskill visual compare expected.png actual.png --threshold 16
173
- ocskill visual crop actual.png failed-region.png --x 10 --y 20 --width 300 --height 120
174
- ocskill visual viewports
175
- ocskill browser capability .
176
- ocskill browser plan http://localhost:3000 --target Checkout
177
- ocskill browser inspect http://localhost:3000 . --selector "button" --width 1440 --height 900
178
- ocskill ui tokens src/styles.css
179
- ocskill ui layout boxes.json --width 390 --height 844
180
- ocskill workflow-plan PLAN.json --max-concurrent 4
181
- ocskill skills lint .
182
- ocskill models capability provider/model --vision on --browser on --quality 0.9
183
- ```
184
-
185
- V11 stable được promote sau full local CI trên Windows PASS: 234 tests, 232 pass, 0 fail, 2 platform-specific skips; router/contract/package/install smoke đều PASS. Stable npm install dùng `npm install -g opencode-agent-skill`.
186
-
187
- ---
188
-
189
- ## V10 có gì?
190
-
191
- V10 tập trung vào **minimum context necessary for maximum task success**: giảm context luôn nạp nhưng không cắt các lớp correctness, verification hay recovery.
192
-
193
- - telemetry đo riêng **initial input tokens** bên cạnh total tokens, tool calls, latency và cost;
194
- - global `AGENTS.md` được nén đáng kể, giữ lại contract, evidence, verification, safety và long-horizon invariants;
195
- - FAST context budget giảm từ 12k xuống **8k**, STANDARD từ 24k xuống **20k**, còn DEEP vẫn giữ **48k** cho task rủi ro/lớn;
196
- - OpenCode V2 runtime dùng policy-aware selective routing: FAST ưu tiên domain/debug/review skill trực tiếp thay vì tự động nạp generic orchestrator;
197
- - failed attempt tự mở rộng context theo tầng `initial -> diagnose -> deep-recovery`; retry tăng evidence, graph/critic và model tier khi cấu hình cho phép;
198
- - FAST không tự hạ executor thấp hơn tier đã cấu hình, nên tối ưu context không đồng nghĩa hạ năng lực model;
199
- - benchmark confidence gate kiểm tra thêm initial-input ratio và total-token ratio;
200
- - `npm run evals:ablation -- <reference> <candidate> --require-gate` so V10 với một reference run và từ chối candidate giảm pass-rate dù token có thấp hơn;
201
- - runtime reliability guard phát hiện no-progress/stall, chặn duplicate `read/grep/glob`, phát hiện loop và cắt output exploration quá lớn trước khi nó làm ngập context;
202
- - pre-compaction checkpoint lưu `currentTaskId`, `runId`, plan hash, workspace fingerprint, evidence pointers và structured `nextAction`; post-compaction bắt buộc thực thi action trước khi session được coi là hoàn tất;
203
- - provider recovery thử fresh session cùng model một lần, sau lỗi lặp lại dùng configured escalation model/provider nếu có;
204
- - lease supervisor tự thu hồi executor lease hết hạn sang trạng thái `retryable`, và explicit `long/high-risk` hard-override FAST thành DEEP/heavy.
205
-
206
- V10 stable kế thừa toàn bộ RC.2 reliability hardening. Local full gate trên Windows/Node 24 đã PASS với 182 test pass, 0 fail, 2 skip cùng package/install smoke PASS trước khi promote.
207
-
208
- ---
209
-
210
- ## UES 9.0.0 có gì?
211
-
212
- UES 9.0.0 cung cấp các khả năng sau (kế thừa từ 8.0.0):
213
-
214
- - **39 engineering skills**;
215
- - **11 slash commands**;
216
- - **10 subagents**;
217
- - long-task engine bền vững dưới `.ues-work/<slug>/`;
218
- - `PLAN.json`, `STATE.json`, `EVIDENCE.json` và append-only `EVENTS.jsonl`;
219
- - structured plan/integration receipts gắn với plan hash hoặc workspace fingerprint;
220
- - task lease với `runId`, heartbeat, session owner, lease expiry và task-scoped stale recovery;
221
- - strict verification cho long/high-risk task: receipt phải PASS đúng active run và đúng workspace hiện tại;
222
- - context manifest v3 với Git-change awareness, symbol hits, TF-IDF-style relevance, tests/instructions và centered excerpts;
223
- - task policy `inline / standard / long-horizon` cùng model tier `light / standard / heavy`;
224
- - bounded fresh executor với hard timeout, interrupt/cancel và recovery;
225
- - safe-wave scheduling cùng Git worktree isolation/integration có conflict detection;
226
- - learning v2: failure clustering, explicit acceptance và shadow-benchmark promotion;
227
- - benchmark matrix standard + long-horizon + polyglot;
228
- - optional Hermes adapter;
229
- - UES Control Center hiển thị runtime events, receipts và stale recovery;
230
- - OpenCode V2 router plugin với multilingual routing, safety gate, cancel/recover tools và fresh-session dispatch.
231
-
232
- V9 bổ sung:
233
-
234
- - persistent incremental source index dưới `.ues-cache/semantic-index-v1.json` cùng ACI search/refs/view/text;
235
- - FAST / STANDARD / DEEP execution profiles với bounded context budget, skill cap và verification depth;
236
- - context manifest v4 tiêu thụ incremental evidence index trước khi mở rộng graph;
237
- - redacted operational trajectory dưới `.ues-traces/*.jsonl` để replay/debug mà không lưu hidden chain-of-thought;
238
- - optional container verification sandbox (Docker/Podman) với network-off, dropped capabilities và resource bounds;
239
- - paired baseline-vs-UES confidence gate qua `npm run evals:matrix:gate`.
240
-
241
- ---
242
-
243
- ## Kiến trúc tác vụ dài
244
-
245
- Luồng long-horizon chính:
246
-
247
- ```text
248
- Yêu cầu
249
- ↓
250
- Khảo sát repository / bằng chứng
251
- ↓
252
- SPEC.md
253
- ↓
254
- PLAN.json
255
- ↓
256
- ues-plan-checker
257
- ↓
258
- Phê duyệt kế hoạch
259
- ↓
260
- Các task theo dependency graph
261
- ↓
262
- Fresh ues-executor session cho từng task
263
- ↓
264
- Task evidence + durable state
265
- ↓
266
- ues-integration-verifier
267
- ↓
268
- Integration PASS
269
- ↓
270
- Kiểm tra workspace không thay đổi
271
- ↓
272
- Finalize
273
- ```
274
-
275
- Mỗi work item dùng cấu trúc:
276
-
277
- ```text
278
- .ues-work/<slug>/
279
- ├── SPEC.md
280
- ├── PLAN.json
281
- ├── STATE.json
282
- ├── EVIDENCE.json
283
- ├── EVENTS.jsonl
284
- ├── tasks/
285
- └── reports/
286
- ```
470
+ H2 --> RANK
471
+ RANK --> PACK[Bounded context pack]
472
+ PACK --> CHILD[Fresh child agent]
473
+ ~~~
474
+
475
+ ## L0
476
+
477
+ Routing abstract rất ngắn:
478
+
479
+ - khu vực nào có vẻ liên quan;
480
+ - key symbols;
481
+ - child areas.
482
+
483
+ ## L1
484
+
485
+ Scope overview:
486
+
487
+ - file count;
488
+ - extension mix;
489
+ - symbols;
490
+ - bounded file names;
491
+ - subtree relation.
492
+
493
+ ## L2
494
+
495
+ Exact excerpts chỉ load khi cần.
496
+
497
+ ## Context pack có thể bao gồm
498
+
499
+ - declared files;
500
+ - import neighbors;
501
+ - likely tests;
502
+ - nearby instructions;
503
+ - Git-changed files;
504
+ - semantic references;
505
+ - symbol hits;
506
+ - evidence refs;
507
+ - verified memories;
508
+ - provider hints;
509
+ - recent failure.
510
+
511
+ ---
512
+
513
+ # Semantic index, repo graph và ACI
287
514
 
288
- `.ues-work/` là trạng thái thực thi của workflow, không phải hidden chain-of-thought.
515
+ UES có ba lớp khác nhau; chúng không phải một thứ.
289
516
 
290
- ### Gate 1 — Phê duyệt kế hoạch
517
+ ## Semantic Index
291
518
 
292
- Sau khi tạo plan, task chưa được chạy ngay. Trạng thái sẽ ở:
519
+ <code>lib/semantic-index.mjs</code>
293
520
 
294
- ```text
295
- awaiting-plan-approval
296
- ```
521
+ Dùng để tạo persistent incremental index phục vụ retrieval.
297
522
 
298
- Sau khi `ues-plan-checker` trả PASS, với long/high-risk work hãy tạo receipt gắn với đúng plan hiện tại rồi mới approve:
523
+ ~~~mermaid
524
+ flowchart LR
525
+ SRC[Source files] --> PARSE[Bounded parse]
526
+ PARSE --> SYMBOLS[Symbols]
527
+ PARSE --> TERMS[Terms]
528
+ SYMBOLS --> INDEX[Persistent semantic index]
529
+ TERMS --> INDEX
530
+ INDEX --> QUERY[Task query]
531
+ QUERY --> RANK[Ranked references]
532
+ ~~~
299
533
 
300
- ```cmd
301
- ocskill work gate-receipt <slug> plan . --verifier ues-plan-checker --evidence "plan checker PASS" --out .ues-work/<slug>/reports/plan-receipt.json
302
- ocskill work approve-plan <slug> . --evidence "plan checker PASS" --receipt-file .ues-work/<slug>/reports/plan-receipt.json
303
- ```
534
+ CLI:
304
535
 
305
- Nếu thiếu structured receipt ở workflow strict, `ocskill work start` sẽ không được mở gate.
536
+ ~~~text
537
+ ues index status .
538
+ ues index build .
539
+ ues index rebuild .
540
+ ~~~
306
541
 
307
- ### Gate 2 — Bằng chứng cho từng task
542
+ ## Repo Graph
308
543
 
309
- Có thể ghi verification receipt trực tiếp từ command:
544
+ <code>lib/repo-graph.mjs</code>
310
545
 
311
- ```cmd
312
- ocskill work verify-command <slug> <task-id> . --run-id <run-id> -- npm test
313
- ```
546
+ Tạo bounded import/dependency graph:
314
547
 
315
- Receipt gắn kết kết quả command với đúng task run. Với long/high-risk work, receipt PASS còn phải khớp workspace fingerprint hiện tại; nếu code thay đổi sau khi test thì phải verify lại.
548
+ - local edges;
549
+ - external imports;
550
+ - coupling hotspots.
316
551
 
317
- ### Gate 3 — Kiểm tra tích hợp
552
+ Nó **không tự nhận là full language-server call graph**.
318
553
 
319
- Sau khi toàn bộ task hoàn tất, tạo integration receipt gắn với workspace hiện tại rồi ghi PASS:
554
+ ~~~mermaid
555
+ flowchart LR
556
+ FILES[Source files] --> IMPORTS[Import extraction]
557
+ IMPORTS --> LOCAL[Local dependency edges]
558
+ IMPORTS --> EXT[External import frequency]
559
+ LOCAL --> HOT[Coupling hotspots]
560
+ EXT --> HOT
561
+ ~~~
320
562
 
321
- ```cmd
322
- ocskill work gate-receipt <slug> integration . --verifier ues-integration-verifier --verdict PASS --evidence "integration PASS" --out .ues-work/<slug>/reports/integration-receipt.json
323
- ocskill work verify-integration <slug> . --verdict PASS --evidence "integration PASS" --receipt-file .ues-work/<slug>/reports/integration-receipt.json
324
- ```
563
+ CLI:
325
564
 
326
- Sau đó:
565
+ ~~~text
566
+ ues repo-graph .
567
+ ues repo-graph . --compact
568
+ ~~~
327
569
 
328
- ```cmd
329
- ocskill work finalize <slug> . --evidence "final acceptance verified"
330
- ```
570
+ ## ACI
331
571
 
332
- `finalize` sẽ bị từ chối nếu còn task chưa hoàn tất, còn blocker, chưa có integration PASS hoặc workspace đã thay đổi sau lần kiểm tra tích hợp.
572
+ <code>lib/aci.mjs</code>
573
+
574
+ Evidence-first code interface cho:
575
+
576
+ - search;
577
+ - references;
578
+ - view;
579
+ - bounded text search.
580
+
581
+ CLI:
582
+
583
+ ~~~text
584
+ ues aci search ...
585
+ ues aci refs ...
586
+ ues aci view ...
587
+ ues aci text ...
588
+ ~~~
333
589
 
334
590
  ---
335
591
 
336
- ## Fresh-context executor trên OpenCode V2
592
+ # Model routing và recovery
593
+
594
+ UES không hard-code tên model “mạnh nhất”. Model IDs do người dùng cấu hình.
595
+
596
+ ## Tier
597
+
598
+ - light
599
+ - standard
600
+ - heavy
601
+
602
+ Role có default tier, và attempt có thể escalate trong giới hạn cấu hình.
603
+
604
+ ~~~mermaid
605
+ flowchart TD
606
+ TASK[Task] --> CLASS[Task class + risk]
607
+ CLASS --> BASE[Base tier]
608
+ BASE --> CAPS[Required capabilities]
609
+ CAPS --> PERF[Historical model performance]
610
+ PERF --> SELECT[Select configured model]
611
+
612
+ SELECT --> RUN[Attempt]
613
+ RUN -->|PASS| DONE[Done]
614
+ RUN -->|FAIL attempt 1| DIAG[Diagnosis]
615
+ DIAG --> RETRY[Attempt 2]
616
+ RETRY -->|FAIL| DEEP[Deep recovery + critic]
617
+ DEEP --> STRONGER[Eligible stronger tier]
618
+ ~~~
619
+
620
+ ## Recovery policy
337
621
 
338
- OpenCode V2 plugin cung cấp tool:
622
+ ### Attempt 1
339
623
 
340
- ```text
341
- ues.dispatch_task
342
- ```
624
+ - normal bounded context;
625
+ - smallest coherent implementation.
343
626
 
344
- Luồng thực thi:
627
+ ### Attempt 2
345
628
 
346
- ```text
347
- work start
348
- ↓
349
- đọc bounded context pack
350
- ↓
351
- chọn model tier theo task + attempt
352
- ↓
353
- tạo OpenCode session mới
354
- ↓
355
- switchAgent(ues-executor)
356
- ↓
357
- switchModel(...) nếu đã cấu hình
358
- ↓
359
- gửi đúng một task
360
- ↓
361
- heartbeat + bounded wait
362
- ↓
363
- interrupt nếu timeout/cancel
364
- ↓
365
- isolate writer khi cần
366
- ↓
367
- trả child-session report
368
- ```
629
+ - dedicated diagnosis;
630
+ - mở rộng context vừa phải;
631
+ - caller/test/failure-adjacent evidence;
632
+ - không vá speculative chồng lên patch cũ.
369
633
 
370
- Parent session vẫn chịu trách nhiệm kiểm tra diff, evidence và quyết định gọi `work complete` hoặc `work fail`.
634
+ ### Attempt 3
371
635
 
372
- Child session không được tự động merge, push, publish hoặc deploy.
636
+ - deep recovery;
637
+ - semantic + graph + Git context;
638
+ - critic;
639
+ - re-investigate failed hypothesis;
640
+ - architecture/coupling review khi cần.
373
641
 
374
642
  ---
375
643
 
376
- ## Subagents
644
+ # Task graph, Dynamic Workflow và parallel runtime
377
645
 
378
- | Subagent | Vai trò |
379
- |---|---|
380
- | `ues-codebase-mapper` | Lập bản đồ repository, entry point, boundary, hotspot, contract và test surface |
381
- | `ues-architect` | Phân tích kiến trúc và phạm vi ảnh hưởng |
382
- | `ues-plan-checker` | Kiểm tra SPEC/PLAN trước khi cho phép thực thi |
383
- | `ues-executor` | Thực hiện một task đã được phê duyệt trong context mới |
384
- | `ues-debugger` | Điều tra nguyên nhân gốc của lỗi |
385
- | `ues-researcher` | Kiểm tra tài liệu, API và phiên bản hiện hành |
386
- | `ues-reviewer` | Review correctness, regression, security và compatibility |
387
- | `ues-critic` | Tìm giả định sai, counterexample và điểm yếu trong phương án |
388
- | `ues-verifier` | Xác minh độc lập theo acceptance criteria |
389
- | `ues-integration-verifier` | Kiểm tra tích hợp giữa nhiều task và luồng end-to-end |
390
- | `ues-visual-verifier` | Xác minh độc lập screenshot/geometry/responsive/interaction mà không sửa code |
391
- | `ues-merge-arbiter` | Hòa giải conflict giữa các task đã verify theo intent/evidence, không push/publish/deploy |
646
+ Structured plan dùng JSON schema version 1.
647
+
648
+ Mỗi task có thể khai báo:
649
+
650
+ - id;
651
+ - title;
652
+ - summary;
653
+ - dependsOn;
654
+ - files create/modify/test/delete/read;
655
+ - acceptance;
656
+ - verification;
657
+ - optional verificationCommands;
658
+ - risk.
659
+
660
+ ## Dependency validation
661
+
662
+ UES kiểm tra:
663
+
664
+ - duplicate IDs;
665
+ - missing dependency;
666
+ - self dependency;
667
+ - cycles;
668
+ - path escape;
669
+ - acceptance/verification thiếu;
670
+ - invalid risk.
671
+
672
+ ## Safe waves
673
+
674
+ ~~~mermaid
675
+ flowchart TD
676
+ PLAN[PLAN tasks] --> DAG[Dependency DAG]
677
+ DAG --> READY[Ready tasks]
678
+ READY --> FILES[Read/write file scope]
679
+ FILES --> CONFLICT{Conflict?}
680
+
681
+ CONFLICT -->|No| SAME[Same safe wave]
682
+ CONFLICT -->|Yes| SERIAL[Serialize]
683
+
684
+ SAME --> PAR[Bounded parallel execution]
685
+ SERIAL --> NEXT[Later wave]
686
+ ~~~
687
+
688
+ Read/read overlap có thể chạy cùng wave. Writer xung đột với reader/writer sẽ bị serialize nếu scope overlap hoặc không đủ rõ.
392
689
 
393
- `ues-executor` là subagent chính có quyền sửa code theo scope được giao. Các agent còn lại chủ yếu phục vụ phân tích, review và xác minh.
690
+ ## Dynamic Workflow
691
+
692
+ <code>lib/dynamic-workflow.mjs</code> phân task thành:
693
+
694
+ - deterministic;
695
+ - inline;
696
+ - agent;
697
+ - vision-related work.
698
+
699
+ ~~~mermaid
700
+ flowchart LR
701
+ T[Task] --> K{Kind}
702
+ K -->|test lint typecheck compile| DET[Deterministic]
703
+ K -->|small bounded reasoning| INLINE[Inline]
704
+ K -->|independent substantial work| AG[Agent]
705
+ K -->|visual judgment| VISION[Vision agent]
706
+
707
+ DET --> SAVE[No unnecessary executor slot]
708
+ INLINE --> SAVE
709
+ AG --> SLOT[LLM slot]
710
+ VISION --> VSLOT[Vision slot]
711
+ ~~~
712
+
713
+ V14.1 có fast path: deterministic read-only task có thể bỏ executor nhưng **verifier vẫn phải PASS**.
394
714
 
395
715
  ---
396
716
 
397
- ## Slash commands
717
+ # Worktree sandbox
398
718
 
399
- Trên OpenCode 1.x, UES tiếp tục cài các command Markdown native. Trên OpenCode V2, 11 lệnh `/ues-*` được cài dưới dạng **prompt aliases** của `ues-router`: UI gửi chúng qua đường `session.prompt` đang ổn định, router mới mở rộng template UES. Cách này tránh phụ thuộc vào `session.command` V2 khi endpoint custom-command trả lỗi transport/content-type. Cú pháp người dùng không đổi, cả hai dạng đều hợp lệ:
719
+ Parallel writers không được cùng sửa một checkout.
400
720
 
401
- ```text
402
- /ues-run <yêu cầu>
403
- ```
721
+ ~~~mermaid
722
+ sequenceDiagram
723
+ participant R as Root repo
724
+ participant U as UES Scheduler
725
+ participant W1 as Worktree T1
726
+ participant W2 as Worktree T2
404
727
 
405
- hoặc:
728
+ U->>R: inspect dirty state
729
+ U->>W1: create isolated worktree
730
+ U->>W2: create isolated worktree
406
731
 
407
- ```text
408
- /ues-run
732
+ W1->>W1: execute + verify T1
733
+ W2->>W2: execute + verify T2
409
734
 
410
- <yêu cầu nhiều dòng>
411
- ```
735
+ U->>W1: inspect changed files
736
+ U->>W2: inspect changed files
737
+ U->>R: conflict check
412
738
 
413
- Trên V2 các alias này có thể không xuất hiện trong autocomplete slash menu vì UES chủ động không đăng ký native custom-command để tránh đường `session.command` đang lỗi; vẫn có thể gõ trực tiếp `/ues-run`, `/ues-fix`, v.v.
739
+ alt safe integration
740
+ U->>R: apply T1 patch
741
+ U->>R: apply T2 patch
742
+ else conflict/failure
743
+ U->>R: refuse or rollback integrated wave
744
+ end
745
+ ~~~
414
746
 
415
- Sau khi nâng cấp từ bản V13 cũ, chạy `ocskill install`; installer sẽ xóa các native UES command file cũ do chính UES quản lý để OpenCode V2 không còn bắt chúng qua `session.command`.
747
+ ## Safety của worktree
416
748
 
417
- | Lệnh | Công dụng |
418
- |---|---|
419
- | `/ues-feature` | Triển khai feature theo workflow UES |
420
- | `/ues-fix` | Điều tra nguyên nhân rồi sửa bug |
421
- | `/ues-plan` | Lập kế hoạch triển khai có thể thực thi |
422
- | `/ues-debug` | Điều tra lỗi build, runtime hoặc test |
423
- | `/ues-research` | Kiểm tra docs, API, package hoặc version |
424
- | `/ues-review` | Review code hoặc diff |
425
- | `/ues-verify` | Xác minh bằng evidence mới |
426
- | `/ues-critique` | Tìm assumption sai và counterexample |
427
- | `/ues-audit` | Audit repository hoặc một khu vực |
428
- | `/ues-run` | Chạy workflow long-horizon với durable state |
429
- | `/ues-resume` | Tiếp tục work item từ `.ues-work` |
749
+ - root dirty mặc định bị chặn nếu không dùng explicit inheritance;
750
+ - dirty root có thể được snapshot vào sandbox theo policy;
751
+ - integration kiểm tra overlap với thay đổi root;
752
+ - branch cleanup chỉ xóa branch namespace UES;
753
+ - rollback dùng reverse patch;
754
+ - không force-push.
430
755
 
431
756
  ---
432
757
 
433
- ## Task policy và model policy
758
+ # Evidence Store, receipts và verification gates
434
759
 
435
- Phân loại yêu cầu kỹ thuật:
760
+ ## Evidence Store
436
761
 
437
- ```cmd
438
- ocskill task-policy "your engineering request"
439
- ```
762
+ UES có content-addressed Evidence Store.
440
763
 
441
- Kiểm tra model policy:
764
+ ~~~mermaid
765
+ flowchart LR
766
+ RAW[Raw output / artifact] --> HASH[SHA-256]
767
+ HASH --> STORE[Evidence Store]
768
+ STORE --> REF[evidence:sha256:...]
769
+ REF --> RECEIPT[Verification / memory / gate receipt]
770
+ REF --> GET[Bounded retrieval]
771
+ ~~~
442
772
 
443
- ```cmd
444
- ocskill model-policy executor --attempt 1 --text "your engineering request"
445
- ```
773
+ CLI:
446
774
 
447
- UES dùng ba model tier:
775
+ ~~~text
776
+ ues store status .
777
+ ues store put ...
778
+ ues store get evidence:sha256:<hash>
779
+ ues store gc .
780
+ ~~~
448
781
 
449
- ```text
450
- light
451
- standard
452
- heavy
453
- ```
782
+ ## Verification receipts
454
783
 
455
- Xem cấu hình:
784
+ Receipt có thể bind:
456
785
 
457
- ```cmd
458
- ocskill models status
459
- ```
786
+ - command result;
787
+ - output digest;
788
+ - before/after workspace fingerprint;
789
+ - verifier;
790
+ - verdict;
791
+ - active run/task.
460
792
 
461
- Bật model policy:
793
+ Mục tiêu là tránh tình trạng:
462
794
 
463
- ```cmd
464
- ocskill models on
465
- ```
795
+ ~~~text
796
+ test từng PASS ở trạng thái A
797
+ → code thay đổi sang trạng thái B
798
+ → model vẫn dùng PASS cũ để tuyên bố hoàn thành
799
+ ~~~
466
800
 
467
- Gán model cho từng tier:
801
+ ## Gate model
468
802
 
469
- ```cmd
470
- ocskill models set light provider/cheap
471
- ocskill models set standard provider/mid
472
- ocskill models set heavy provider/strong
473
- ```
803
+ ~~~mermaid
804
+ flowchart TD
805
+ PLAN[Plan] --> PG[Plan checker]
806
+ PG --> PR[Plan receipt]
807
+ PR --> EXEC[Execution]
474
808
 
475
- Gán tier theo role:
809
+ EXEC --> TV[Task verifier]
810
+ TV --> TR[Task verification receipt]
476
811
 
477
- ```cmd
478
- ocskill models role executor standard
479
- ocskill models role plan-checker heavy
480
- ```
812
+ TR --> INT[Integration verifier]
813
+ INT --> IR[Integration receipt]
481
814
 
482
- Model ID do người dùng cấu hình vẫn là nguồn quyết định cuối cùng; UES không tự đoán provider/model ID.
815
+ IR --> FP{Workspace fingerprint unchanged?}
816
+ FP -->|Yes| FINAL[Finalize]
817
+ FP -->|No| INVALID[Receipt stale - reverify]
818
+ ~~~
483
819
 
484
820
  ---
485
821
 
486
- ## Công cụ CLI
822
+ # V14.1 reversible output compaction
823
+
824
+ Mục tiêu của V14.1 là giảm model-visible noise mà **không bỏ raw evidence**.
825
+
826
+ ~~~mermaid
827
+ flowchart TD
828
+ OUT[Large CLI/tool output] --> SIZE{Over limit?}
829
+ SIZE -->|No| RAW[Return unchanged]
830
+ SIZE -->|Yes| SAVE[Store exact raw bytes in Evidence Store]
831
+ SAVE --> PREVIEW[Build head + high-signal + tail preview]
832
+ PREVIEW --> MODEL[Send bounded preview to model]
833
+ MODEL --> NEED{Need more?}
834
+ NEED -->|Yes| REF[Retrieve exact slices by evidence ref]
835
+ NEED -->|No| CONT[Continue]
836
+ ~~~
837
+
838
+ Default model-visible limit hiện khoảng 64 KiB.
839
+
840
+ High-signal lines ưu tiên các pattern như:
841
+
842
+ - error;
843
+ - failed;
844
+ - exception;
845
+ - warning;
846
+ - timeout;
847
+ - traceback;
848
+ - mismatch;
849
+ - conflict;
850
+ - passed;
851
+ - tests;
852
+ - exit code;
853
+ - changed.
854
+
855
+ ## Quan trọng
856
+
857
+ - thinking level không bị hạ bởi compaction;
858
+ - raw output được lưu trước khi compact;
859
+ - small output giữ nguyên;
860
+ - failure của compaction fail-open về raw output.
487
861
 
488
- | Lệnh | Công dụng |
489
- |---|---|
490
- | `ocskill inspect [dir]` | Phát hiện stack, package manager, root và test command |
491
- | `ocskill repo-graph [dir] [--compact] [--max-files N]` | Lập import graph; dùng `--compact` để lấy hotspot/counts trước, tránh đổ toàn bộ edges trên repo lớn |
492
- | `ocskill impact <query> [dir]` | Tìm phạm vi ảnh hưởng theo symbol hoặc từ khóa |
493
- | `ocskill evidence [dir]` | Thu thập snapshot về repository, verification và Git |
494
- | `ocskill working-tree [dir]` | Kiểm tra branch, HEAD và working tree |
495
- | `ocskill text-read <file> [--start N] [--max N]` | Đọc bounded UTF-8/UTF-16 an toàn khi generic Read nhận nhầm text là binary |
496
- | `ocskill review-scope [base] [dir]` | Phân tích changed-file coverage và risk hint |
497
- | `ocskill verification-plan [dir]` | Đề xuất verification phù hợp với project |
498
- | `ocskill task-graph <PLAN.json>` | Kiểm tra DAG và tính safe waves |
499
- | `ocskill context-pack <slug> <task> [dir]` | Tạo bounded handoff cho executor |
500
- | `ocskill work ...` | Điều khiển durable long-task state machine |
862
+ ---
501
863
 
502
- Ví dụ:
864
+ # V14.2 Turbo Weak-Model Runtime
865
+
866
+ V14.2 tối ưu hot path cho model yếu/siêu yếu mà không hạ thinking hoặc bỏ verification gate.
867
+
868
+ ~~~mermaid
869
+ flowchart TD
870
+ T[Task] --> P[Task Policy]
871
+ P --> C[Adaptive context]
872
+ C --> G[Semantic + dependency graph rank]
873
+ G --> S[Bounded micro-skills]
874
+ S --> W[Warm Pi RPC worker]
875
+
876
+ W --> E[Executor]
877
+ E --> R[Tool-boundary verification receipts]
878
+ R --> V[Verifier]
879
+
880
+ V -->|fresh receipt fully covers check| REUSE[Reuse exact PASS receipt]
881
+ V -->|missing/stale/high-risk| RUN[Run fresh check]
882
+
883
+ REUSE --> IV[Integration verification when required]
884
+ RUN --> IV
885
+
886
+ E --> O[Large tool output]
887
+ O --> COMP[Command-aware compaction]
888
+ COMP --> RAW[Raw bytes in Evidence Store]
889
+ RAW --> REC[Selective recovery on demand]
890
+ ~~~
891
+
892
+ Các thay đổi chính:
893
+
894
+ - warm Pi RPC worker pool với fresh session giữa specialist runs;
895
+ - interactive steering/abort khi một child đang active;
896
+ - unified process-tree supervisor + bounded I/O drain;
897
+ - rolling Jest/open-handle detection;
898
+ - adaptive role-aware context budgets;
899
+ - runtime context + dependency-graph cache theo workspace fingerprint;
900
+ - bounded micro-skill compiler thay vì load toàn bộ skill catalog;
901
+ - affected-test hints;
902
+ - verification receipt reuse chỉ khi fingerprint còn nguyên;
903
+ - high-risk verifier không dùng receipt reuse optimization;
904
+ - child test/lint/typecheck/build có timeout theo profile;
905
+ - full shell output được recover từ Pi `fullOutputPath` khi có;
906
+ - command-aware reversible compaction ngay ở child tool-result boundary;
907
+ - JSON evidence selector để lấy đúng subtree;
908
+ - personalized dependency graph ranking;
909
+ - task-specific Browser MCP subset;
910
+ - confidence-bound weak-model routing;
911
+ - DEEP task auto-promote sang `.ues-work` durable workflow;
912
+ - paired benchmark có turbo promotion gate: **quality non-regression + efficiency gain + zero controller false-PASS**.
913
+
914
+ Các optimization quan trọng có thể rollback riêng:
915
+
916
+ ~~~text
917
+ UES_CHILD_RUNTIME=cli
918
+ UES_ADAPTIVE_CONTEXT=0
919
+ UES_MICRO_SKILLS=0
920
+ UES_AFFECTED_TEST_HINTS=0
921
+ UES_CHILD_TOOL_COMPACTION=0
922
+ ~~~
923
+
924
+ Chi tiết: `docs/V14.2-TURBO-WEAK-MODEL-RUNTIME.md`.
925
+
926
+ ---
503
927
 
504
- ```cmd
505
- ocskill repo-graph . --compact
506
- ocskill review-scope main .
507
- ocskill verification-plan .
508
- ocskill task-graph .ues-work/checkout/PLAN.json
509
- ocskill work status checkout .
510
- ```
928
+ # Verified Persistent Memory
929
+
930
+ Memory của UES không phải “chat memory tự do”. Retrieval chỉ dùng memory đủ điều kiện.
931
+
932
+ ~~~mermaid
933
+ flowchart TD
934
+ EXPERIENCE[Task outcome] --> CAND[Memory candidate]
935
+ CAND --> EVID{Has durable evidence?}
936
+ EVID -->|No| DROP[Not retrievable]
937
+ EVID -->|Yes| VER{Verifier PASS?}
938
+ VER -->|No| DROP
939
+ VER -->|Yes| VM[Verified memory]
940
+
941
+ VM --> RANK[Hybrid retrieval]
942
+ RANK --> LEX[Lexical relevance]
943
+ RANK --> VEC[Deterministic vector similarity]
944
+ RANK --> FILE[File affinity]
945
+ RANK --> REC[Recency/confidence]
946
+ RANK --> TASK[Task-class affinity]
947
+
948
+ LEX --> TOP[Bounded top memories]
949
+ VEC --> TOP
950
+ FILE --> TOP
951
+ REC --> TOP
952
+ TASK --> TOP
953
+ ~~~
954
+
955
+ Memory hỗ trợ:
956
+
957
+ - candidate / verified / superseded lifecycle;
958
+ - confidence;
959
+ - expiry;
960
+ - task-class affinity;
961
+ - usage accounting;
962
+ - evidence references;
963
+ - supersession.
964
+
965
+ CLI:
966
+
967
+ ~~~text
968
+ ues memory status .
969
+ ues memory retrieve ...
970
+ ues memory propose ...
971
+ ues memory verify ...
972
+ ues memory supersede ...
973
+ ~~~
511
974
 
512
975
  ---
513
976
 
514
- ## Skills
977
+ # Capability Fabric
515
978
 
516
- V11 stable hiện có **48 skills**; V10 stable có 39. Router vẫn chỉ chọn tập skill phù hợp thay vì nạp toàn bộ catalog vào mỗi task.
979
+ Capability Fabric giúp model không phải tự đoán backend/tool nào đang khỏe.
517
980
 
518
- Một số process skill quan trọng:
981
+ ## Built-in capability groups
519
982
 
520
- - `ues-engineering-orchestrator`
521
- - `ues-repo-explorer`
522
- - `ues-context-engineering`
523
- - `ues-task-planner`
524
- - `ues-change-impact-analysis`
525
- - `ues-bug-diagnosis`
526
- - `ues-test-driven-development`
527
- - `ues-test-verification`
528
- - `ues-code-review`
529
- - `ues-research-verification`
530
- - `ues-long-task-state`
531
- - `ues-git-safety`
983
+ Source hiện có các nhóm như:
532
984
 
533
- Nhóm domain/framework hiện bao gồm React, Next.js, React Native, Node.js, NestJS, Python, Django, FastAPI, .NET, Java/Spring, Flutter, database, REST/API contract, authentication/security, payment, ecommerce, file upload, DevOps, UI/UX, accessibility và performance.
985
+ - code.search;
986
+ - memory;
987
+ - evidence;
988
+ - output.compaction;
989
+ - filesystem;
990
+ - git;
991
+ - agent.host;
992
+ - github;
993
+ - browser.
994
+
995
+ ~~~mermaid
996
+ flowchart TD
997
+ NEED[Required capability] --> REG[Provider registry]
998
+ REG --> PROBE[Health probe]
999
+ PROBE --> SCORE[Score]
1000
+
1001
+ OBS[Persisted success/failure/latency] --> SCORE
1002
+ QUALITY[Quality] --> SCORE
1003
+ COST[Cost class] --> SCORE
1004
+ LAT[Latency class] --> SCORE
1005
+
1006
+ SCORE --> PRIMARY[Selected provider]
1007
+ SCORE --> FALLBACK[Fallback providers]
1008
+ ~~~
1009
+
1010
+ Provider score xét:
1011
+
1012
+ - configured priority;
1013
+ - quality;
1014
+ - current health;
1015
+ - historical success/failure;
1016
+ - cost class;
1017
+ - latency class.
1018
+
1019
+ ## Output compaction providers
1020
+
1021
+ V14.1 có registry cho:
1022
+
1023
+ - built-in <code>ues-reversible-compactor</code> — mặc định;
1024
+ - RTK CLI — optional;
1025
+ - Caveman CLI — optional experimental;
1026
+ - Headroom CLI — optional experimental.
1027
+
1028
+ Detection **không có nghĩa auto-enable** external provider.
534
1029
 
535
1030
  ---
536
1031
 
537
- ## Tương thích OpenCode
1032
+ # Playwright / Browser MCP on-demand
1033
+
1034
+ UES có browser adapter/runtime riêng và thêm routing cho Playwright/Browser MCP đang có trong Pi host.
538
1035
 
539
- ### OpenCode 1.x
1036
+ Mục tiêu: browser tools chỉ xuất hiện khi task thực sự cần browser/visual evidence.
540
1037
 
541
- - cài skill, command và subagent;
542
- - dùng frontmatter tương thích V1;
543
- - không cài V2 runtime plugin;
544
- - durable long-task CLI vẫn dùng được;
545
- - không có V2 `ues.dispatch_task`.
1038
+ ~~~mermaid
1039
+ flowchart TD
1040
+ TASK[Task] --> NEED{Needs browser or visual evidence?}
546
1041
 
547
- ### OpenCode 2.x
1042
+ NEED -->|No| NORMAL[Normal agent tool allowlist]
1043
+ NEED -->|Yes| DISCOVER[Inspect host Pi tool registry]
548
1044
 
549
- Ngoài resource file, UES cài managed plugin tại:
1045
+ DISCOVER --> SELECT[Select Playwright/browser tools]
1046
+ SELECT --> CHILD[Add selected names to child --tools]
550
1047
 
551
- ```text
552
- ~/.config/opencode/plugins/ues-router/
553
- ```
1048
+ CHILD --> SNAP[Semantic/accessibility snapshot]
1049
+ CHILD --> INT[Targeted interaction]
1050
+ CHILD --> LOG[Console/network evidence]
1051
+ CHILD --> SHOT[Screenshot when visual proof needed]
554
1052
 
555
- Plugin cung cấp:
1053
+ SNAP --> VV[Visual verifier]
1054
+ INT --> VV
1055
+ LOG --> VV
1056
+ SHOT --> VV
556
1057
 
557
- - automatic skill routing;
558
- - context guardrail;
559
- - permission safety gate;
560
- - read-only long-task helpers;
561
- - fresh-session executor runtime qua `ues.dispatch_task` và same-model parallel runtime qua `ues.dispatch_parallel`.
1058
+ VV -->|PASS| DONE[Visual claim verified]
1059
+ VV -->|FAIL / no evidence| STOP[No browser-visible PASS claim]
1060
+ ~~~
562
1061
 
563
- Điều khiển router:
1062
+ ## Routing behavior
564
1063
 
565
- ```cmd
566
- ocskill router status
567
- ocskill router on --max 4
568
- ocskill router off
569
- ```
1064
+ ### Backend task
1065
+
1066
+ Ví dụ:
1067
+
1068
+ ~~~text
1069
+ /ues-run sửa transaction inventory backend và chạy test
1070
+ ~~~
1071
+
1072
+ Playwright không cần được thêm vào child agent.
1073
+
1074
+ ### Browser E2E task
1075
+
1076
+ Ví dụ:
1077
+
1078
+ ~~~text
1079
+ /ues-run kiểm tra checkout form bằng browser, click flow và console error
1080
+ ~~~
1081
+
1082
+ Browser MCP lane được yêu cầu.
1083
+
1084
+ ### Visual task
1085
+
1086
+ Ví dụ:
1087
+
1088
+ ~~~text
1089
+ /ues-run sửa giao diện theo ảnh mẫu và kiểm tra responsive
1090
+ ~~~
1091
+
1092
+ Sau code verifier/integration verifier, UES có thể chạy thêm <code>ues-visual-verifier</code>.
1093
+
1094
+ ## Evidence order
1095
+
1096
+ UES ưu tiên:
1097
+
1098
+ 1. semantic/accessibility snapshot;
1099
+ 2. DOM/target state;
1100
+ 3. targeted interaction;
1101
+ 4. console/network evidence;
1102
+ 5. viewport checks;
1103
+ 6. screenshot khi cần visual proof.
1104
+
1105
+ ## Browser security
1106
+
1107
+ Webpage text, accessibility content, console output và network payload được coi là **untrusted external evidence**.
1108
+
1109
+ Page content không được:
1110
+
1111
+ - thay đổi permissions;
1112
+ - yêu cầu secret;
1113
+ - override system/task instructions;
1114
+ - tự cấp quyền external/destructive side effect.
1115
+
1116
+ ## Optional overrides
1117
+
1118
+ Nếu Browser MCP dùng tên tool lạ:
1119
+
1120
+ ~~~cmd
1121
+ set UES_BROWSER_MCP_TOOL_NAMES=browser_navigate,browser_snapshot,browser_screenshot,browser_click
1122
+ set UES_BROWSER_MCP_TOOL_LIMIT=14
1123
+ ~~~
570
1124
 
571
1125
  ---
572
1126
 
573
- ## Safety
1127
+ # Trajectory và observability
1128
+
1129
+ <code>lib/trajectory.mjs</code> lưu **operational events**, không lưu hidden chain-of-thought.
1130
+
1131
+ ~~~mermaid
1132
+ flowchart LR
1133
+ RUN[Agent run] --> EVT[Observable event]
1134
+ EVT --> SCRUB[Secret redaction]
1135
+ SCRUB --> LIMIT[Bound event size]
1136
+ LIMIT --> JSONL[.ues-traces trace.jsonl]
1137
+
1138
+ JSONL --> SHOW[trace show]
1139
+ JSONL --> DEBUG[Debug/replay analysis]
1140
+ ~~~
1141
+
1142
+ Trajectory scrub các dạng dữ liệu như:
574
1143
 
575
- OpenCode V2 permission gate yêu cầu xác nhận rõ ràng trước các thao tác có tác động lớn, ví dụ:
1144
+ - Authorization Bearer;
1145
+ - OpenAI-style API keys;
1146
+ - GitHub tokens;
1147
+ - npm tokens;
1148
+ - generic api_key/token/secret/password/credential fields.
576
1149
 
577
- - `git push --force` hoặc `git push -f`;
578
- - `git reset --hard`;
579
- - destructive `git clean`;
580
- - `npm publish`;
581
- - recursive forced deletion;
582
- - `DROP` hoặc `TRUNCATE`;
583
- - Terraform, Kubernetes hoặc Helm action có tác động lớn.
1150
+ Large event payload được bounded và có SHA-256 digest.
584
1151
 
585
- Safety hook là lớp bảo vệ deterministic bổ sung, không thay thế review của người dùng.
1152
+ CLI:
1153
+
1154
+ ~~~text
1155
+ ues trace append ...
1156
+ ues trace show ...
1157
+ ~~~
586
1158
 
587
1159
  ---
588
1160
 
589
- ## Learning loop
1161
+ # Learning engine và benchmark confidence
1162
+
1163
+ Learning của UES được thiết kế theo hướng **proposal → shadow evidence → promotion**, không phải “agent fail một lần rồi tự sửa rule vĩnh viễn”.
590
1164
 
591
- Phân tích eval trace:
1165
+ ~~~mermaid
1166
+ flowchart TD
1167
+ EVAL[Eval artifacts] --> ANALYZE[Analyze recurring failures]
1168
+ ANALYZE --> PROP[Learning proposal]
1169
+ PROP --> ACCEPT[Manual acceptance]
1170
+ ACCEPT --> SHADOW[Shadow benchmark required]
592
1171
 
593
- ```cmd
594
- ocskill learn analyze . --eval-dir .ues-evals
595
- ```
1172
+ SHADOW --> PAIR[Paired baseline vs UES]
1173
+ PAIR --> CONF[Statistical confidence checks]
596
1174
 
597
- Xem trạng thái:
1175
+ CONF -->|Eligible| PROMOTE[Promote learning]
1176
+ CONF -->|Not eligible| HOLD[Keep unpromoted]
1177
+ ~~~
598
1178
 
599
- ```cmd
600
- ocskill learn status .
601
- ```
1179
+ ## Failure patterns được phân tích
602
1180
 
603
- Chấp nhận một proposal trước khi thử nghiệm:
1181
+ Ví dụ:
604
1182
 
605
- ```cmd
606
- ocskill learn accept <proposal-id> .
607
- ```
1183
+ - hard-timeout;
1184
+ - idle-timeout;
1185
+ - agent-exit;
1186
+ - grader-failure;
1187
+ - orchestration-failure;
1188
+ - telemetry parse errors.
608
1189
 
609
- Sau khi shadow benchmark chứng minh candidate tốt hơn baseline:
1190
+ ## Promotion confidence
610
1191
 
611
- ```cmd
612
- ocskill learn promote <proposal-id> . --baseline 0.50 --candidate 0.75 --samples 4
613
- ```
1192
+ <code>lib/benchmark-confidence.mjs</code> so sánh paired baseline/UES:
614
1193
 
615
- Proposal có `shadowRequired` chỉ được đưa trở lại context sau khi vừa được chấp nhận rõ ràng vừa có benchmark improvement đo được.
1194
+ - total paired samples;
1195
+ - both pass;
1196
+ - both fail;
1197
+ - baseline-only win;
1198
+ - UES-only win;
1199
+ - pass-rate delta;
1200
+ - exact sign-test p-value;
1201
+ - per-suite regression;
1202
+ - duration ratio;
1203
+ - initial input ratio;
1204
+ - token ratio;
1205
+ - cost summary.
1206
+
1207
+ Promotion yêu cầu nhiều điều kiện cùng đạt, không chỉ “UES thắng một vài task”.
616
1208
 
617
1209
  ---
618
1210
 
619
- ## Hermes adapter
1211
+ # Durable long-horizon work
620
1212
 
621
- V11 giữ Hermes theo dạng **optional sidecar**, không nhúng Hermes runtime vào core. UES vẫn sở hữu durable state, evidence và safety boundaries:
1213
+ Task dài có thể dùng <code>.ues-work/&lt;slug&gt;/</code> làm source of truth.
622
1214
 
623
- ```cmd
624
- ocskill hermes status
625
- ocskill hermes prompt <slug> <task> .
626
- ocskill hermes exec <slug> <task> .
627
- ```
1215
+ ~~~text
1216
+ .ues-work/<slug>/
1217
+ SPEC.md
1218
+ PLAN.json
1219
+ STATE.json
1220
+ EVIDENCE.json
1221
+ EVENTS.jsonl
1222
+ ACTIVE_PLAN.json
1223
+ tasks/
1224
+ reports/
1225
+ plans/
1226
+ ~~~
1227
+
1228
+ ## State machine khái quát
1229
+
1230
+ ~~~mermaid
1231
+ stateDiagram-v2
1232
+ [*] --> Initialized
1233
+ Initialized --> Planned
1234
+ Planned --> PlanApproved
1235
+ PlanApproved --> Running
1236
+ Running --> Running: next task
1237
+ Running --> Blocked
1238
+ Blocked --> Running
1239
+ Running --> IntegrationVerification
1240
+ IntegrationVerification --> Finalized: PASS + fresh fingerprint
1241
+ IntegrationVerification --> Running: FAIL / rework
1242
+ Running --> Recovering: stale lease / interruption
1243
+ Recovering --> Running
1244
+ ~~~
1245
+
1246
+ ## Locking
1247
+
1248
+ State/evidence mutation dùng:
1249
+
1250
+ - per-work lock;
1251
+ - heartbeat;
1252
+ - stale lock recovery;
1253
+ - atomic file replacement.
1254
+
1255
+ ## Runtime events
1256
+
1257
+ <code>EVENTS.jsonl</code> append-only cho operational observability.
628
1258
 
629
- Nếu máy không có Hermes CLI, các tính năng Hermes chỉ báo unavailable và không ảnh hưởng đến core UES.
1259
+ ---
1260
+
1261
+ # Control Center
1262
+
1263
+ UES có local Control Center qua:
1264
+
1265
+ ~~~text
1266
+ ues dashboard .
1267
+ ues dashboard . --serve
1268
+ ~~~
1269
+
1270
+ Control Center tổng hợp các loại dữ liệu như:
1271
+
1272
+ - durable work;
1273
+ - task state;
1274
+ - blockers;
1275
+ - receipts;
1276
+ - recent events;
1277
+ - eval summaries;
1278
+ - learning state;
1279
+ - evidence store;
1280
+ - verified memory;
1281
+ - capability fabric health.
1282
+
1283
+ ~~~mermaid
1284
+ flowchart LR
1285
+ WORK[.ues-work] --> CC[Control Center]
1286
+ EVENTS[EVENTS.jsonl] --> CC
1287
+ EV[Evidence Store] --> CC
1288
+ MEM[Memory] --> CC
1289
+ CAP[Capability Fabric] --> CC
1290
+ LEARN[Learning] --> CC
1291
+ EVAL[Eval artifacts] --> CC
1292
+ ~~~
1293
+
1294
+ Control Center là observer/controller cục bộ; nó không bypass verification/safety gates.
630
1295
 
631
1296
  ---
632
1297
 
633
- ## UES Control Center
1298
+ # Safety model
1299
+
1300
+ UES cố gắng đưa safety vào code thay vì chỉ nhắc model.
1301
+
1302
+ ## Shell safety
1303
+
1304
+ Có detection/gate cho các thao tác rủi ro như:
1305
+
1306
+ - force push;
1307
+ - history rewrite;
1308
+ - reset hard;
1309
+ - recursive destructive deletion;
1310
+ - destructive database commands;
1311
+ - deploy/apply;
1312
+ - publish.
1313
+
1314
+ ## Scope safety
1315
+
1316
+ Structured task phải khai báo file scope. Scheduler kiểm tra actual changed files so với declared write scope.
1317
+
1318
+ ## Parallel safety
1319
+
1320
+ Writer agents chạy parallel phải ở distinct worktree/cwd.
634
1321
 
635
- Tạo dashboard tĩnh:
1322
+ ## Evidence safety
636
1323
 
637
- ```cmd
638
- ocskill dashboard .
639
- ```
1324
+ Old PASS không tự được coi là hợp lệ nếu workspace đã thay đổi.
640
1325
 
641
- Chạy dashboard có tự refresh:
1326
+ ## Browser safety
642
1327
 
643
- ```cmd
644
- ocskill dashboard . --serve --port 4177
645
- ```
1328
+ External page content là untrusted.
646
1329
 
647
- Control Center hiển thị work state, verification receipts, runtime events, learning proposals và eval summary; server mode có safe stale-recovery action.
1330
+ ## Memory safety
1331
+
1332
+ Candidate hoặc superseded memory không được retrieval như verified memory.
1333
+
1334
+ ## Learning safety
1335
+
1336
+ Proposal không tự promote nếu chưa có benchmark evidence phù hợp.
648
1337
 
649
1338
  ---
650
1339
 
651
- ## Sandbox cho tác vụ ghi song song
1340
+ # Cài đặt
652
1341
 
653
- Tạo isolated Git worktree:
1342
+ ## Yêu cầu
654
1343
 
655
- ```cmd
656
- ocskill sandbox create <slug> <task-id> .
657
- ```
1344
+ - Node.js 22.19+
1345
+ - Git
1346
+ - Pi Agent
658
1347
 
659
- Tích hợp sandbox sau khi đã inspect/verify:
1348
+ Cài Pi:
660
1349
 
661
- ```cmd
662
- ocskill sandbox integrate <worktree-path> .
663
- ```
1350
+ ~~~cmd
1351
+ npm install -g @earendil-works/pi-coding-agent
1352
+ pi --version
1353
+ ~~~
664
1354
 
665
- Liệt kê sandbox:
1355
+ Cài UES trực tiếp từ GitHub:
666
1356
 
667
- ```cmd
668
- ocskill sandbox list .
669
- ```
1357
+ ~~~cmd
1358
+ pi install git:github.com/laivannha0202/opencode-agent-skill-
1359
+ pi list
1360
+ pi
1361
+ ~~~
670
1362
 
671
- Integration sẽ từ chối ghi đè lên file đang dirty ở root. Safe-wave scheduling chỉ bảo vệ declared file scope. Generated file, lockfile hoặc shared write surface ngầm định vẫn nên được serialize khi cần.
1363
+ Nếu đã clone repo local:
1364
+
1365
+ ~~~cmd
1366
+ cd /d E:\Code\opencode-agent-skill-
1367
+ npm install
1368
+ pi install .
1369
+ ~~~
672
1370
 
673
1371
  ---
674
1372
 
675
- ## Evaluation
1373
+ # Cập nhật
676
1374
 
677
- V11 hiện có:
1375
+ Nếu cài từ clone local:
678
1376
 
679
- - **43 static skill-routing scenarios** phủ 48 skills;
680
- - **129 V2 router cases** với required routes và negative guards;
681
- - **13 V11 contract tasks** across 6 categories;
682
- - **20 standard live tasks**;
683
- - **5 long-horizon tasks**;
684
- - **8 polyglot tasks** cho Python, Java, .NET, Next.js, React Native, SQL migration, monorepo và generated contract;
685
- - benchmark matrix baseline-vs-UES nhiều trial;
686
- - một long task tích hợp tới **15 source modules**.
1377
+ ~~~cmd
1378
+ cd /d E:\Code\opencode-agent-skill-
1379
+ git status
1380
+ git pull --ff-only origin main
1381
+ pi install .
1382
+ ~~~
687
1383
 
688
- Kiểm tra static routing:
1384
+ Nếu local có thay đổi chưa commit, hãy backup/stash hoặc xử lý diff trước khi pull. Không nên reset/clean mù quáng.
689
1385
 
690
- ```cmd
691
- npm run evals
692
- ```
1386
+ ---
693
1387
 
694
- Kiểm tra V2 router:
1388
+ # Đóng gói npm
695
1389
 
696
- ```cmd
697
- npm run evals:router
698
- ```
1390
+ Kiểm tra đầy đủ trước khi pack:
699
1391
 
700
- Kiểm tra standard hidden graders:
1392
+ ~~~cmd
1393
+ npm install
1394
+ npm run ci
1395
+ npm pack --dry-run
1396
+ npm pack
1397
+ ~~~
701
1398
 
702
- ```cmd
703
- npm run evals:live:validate
704
- ```
1399
+ Package version hiện tại trong <code>package.json</code> là:
705
1400
 
706
- Kiểm tra long-horizon và polyglot suite:
1401
+ ~~~text
1402
+ 14.2.0-beta.1
1403
+ ~~~
707
1404
 
708
- ```cmd
709
- npm run evals:long:validate
710
- npm run evals:polyglot:validate
711
- npm run evals:v11:validate
712
- ```
1405
+ V14.2 Turbo Weak-Model Runtime hiện là incremental work trên package version đó.
713
1406
 
714
- Chạy benchmark với model thật:
1407
+ Test file packed với Pi:
715
1408
 
716
- ```cmd
717
- ocskill eval-live --model provider/model --trials 3
718
- ocskill eval-live --suite long --model provider/model --trials 3
719
- npm run evals:matrix -- --model provider/model --trials 3
720
- ```
1409
+ ~~~cmd
1410
+ pi install .\opencode-agent-skill-14.2.0-beta.1.tgz
1411
+ pi list
1412
+ ~~~
721
1413
 
722
- Live eval hỗ trợ heartbeat, hard timeout, idle timeout và Ctrl+C process-tree cancellation.
1414
+ Publish thật chỉ nên thực hiện sau khi CI và package smoke tests PASS.
723
1415
 
724
- Với long suite, một run UES chỉ được tính PASS khi hidden grader PASS, durable work state tồn tại, plan approval hợp lệ, toàn bộ task hoàn tất, integration verification PASS và finalization hoàn tất.
1416
+ ---
1417
+
1418
+ # Các CLI quan trọng
1419
+
1420
+ CLI ưu tiên là <code>ues</code>; <code>ocskill</code> vẫn là compatibility alias.
1421
+
1422
+ ## Repository intelligence
1423
+
1424
+ ~~~text
1425
+ ues inspect .
1426
+ ues impact <query> .
1427
+ ues evidence .
1428
+ ues working-tree .
1429
+ ues repo-graph .
1430
+ ues index status .
1431
+ ues index build .
1432
+ ues aci search ...
1433
+ ~~~
1434
+
1435
+ ## Task và verification
1436
+
1437
+ ~~~text
1438
+ ues task-policy "<task>"
1439
+ ues verification-plan .
1440
+ ues task-graph PLAN.json
1441
+ ues workflow-plan PLAN.json
1442
+ ues review-scope main .
1443
+ ~~~
1444
+
1445
+ ## Durable work
1446
+
1447
+ ~~~text
1448
+ ues work init <slug> . --goal "..."
1449
+ ues work plan <slug> PLAN.json .
1450
+ ues work approve-plan <slug> . --evidence "..."
1451
+ ues work start <slug> <task-id> .
1452
+ ues work verify-command <slug> <task-id> . --run-id <id> -- npm test
1453
+ ues work complete <slug> <task-id> . --run-id <id> --evidence "..."
1454
+ ues work verify-integration <slug> . --verdict PASS --evidence "..."
1455
+ ues work finalize <slug> . --evidence "..."
1456
+ ues work events <slug> .
1457
+ ues work resume <slug> .
1458
+ ~~~
1459
+
1460
+ ## Sandbox
1461
+
1462
+ ~~~text
1463
+ ues sandbox list .
1464
+ ues sandbox create ...
1465
+ ues sandbox integrate ...
1466
+ ues sandbox rollback ...
1467
+ ues sandbox remove ...
1468
+ ~~~
1469
+
1470
+ ## Context / memory / capability
1471
+
1472
+ ~~~text
1473
+ ues hierarchy "<query>" .
1474
+ ues hierarchy "<query>" . --full
1475
+ ues memory status .
1476
+ ues capability-fabric status .
1477
+ ues capabilities "<task>"
1478
+ ~~~
1479
+
1480
+ ## Evidence / trace
1481
+
1482
+ ~~~text
1483
+ ues store status .
1484
+ ues store get evidence:sha256:<hash>
1485
+ ues trace show ...
1486
+ ~~~
1487
+
1488
+ ## Browser / visual
1489
+
1490
+ ~~~text
1491
+ ues browser capability .
1492
+ ues browser plan ...
1493
+ ues browser inspect ...
1494
+ ues visual ...
1495
+ ues ui tokens ...
1496
+ ues ui layout ...
1497
+ ~~~
1498
+
1499
+ ## Models
1500
+
1501
+ ~~~text
1502
+ ues models status
1503
+ ues models on
1504
+ ues models set light <provider/model>
1505
+ ues models set standard <provider/model>
1506
+ ues models set heavy <provider/model>
1507
+ ues models role verifier standard
1508
+ ~~~
1509
+
1510
+ ## Learning / eval
1511
+
1512
+ ~~~text
1513
+ ues eval-pi --model provider/model --thinking low --suite live --trials 3 --mode both
1514
+ ues learn analyze . --eval-dir .ues-evals
1515
+ ~~~
725
1516
 
726
1517
  ---
727
1518
 
728
- ## Phát triển và CI
1519
+ # Benchmark model yếu
729
1520
 
730
- Yêu cầu:
1521
+ UES có Pi-native baseline-vs-UES benchmark.
731
1522
 
732
- - Node.js 20+;
733
- - npm;
734
- - Git.
1523
+ ~~~mermaid
1524
+ flowchart LR
1525
+ TASKS[Same benchmark tasks] --> B[Baseline Pi]
1526
+ TASKS --> U[Pi + UES]
735
1527
 
736
- Cài dependency mà không chạy lifecycle script:
1528
+ B --> BG[External grader]
1529
+ U --> UG[External grader]
737
1530
 
738
- ```cmd
739
- npm ci --ignore-scripts
740
- ```
1531
+ B --> BT[Tokens/cost/tool telemetry]
1532
+ U --> UT[Tokens/cost/tool telemetry]
741
1533
 
742
- Chạy toàn bộ CI:
1534
+ BG --> PAIR[Paired comparison]
1535
+ UG --> PAIR
1536
+ BT --> PAIR
1537
+ UT --> PAIR
743
1538
 
744
- ```cmd
745
- npm run ci
746
- ```
1539
+ PAIR --> CONF[Confidence / regression checks]
1540
+ ~~~
747
1541
 
748
- Pipeline hiện kiểm tra:
1542
+ Ví dụ:
1543
+
1544
+ ~~~cmd
1545
+ ues eval-pi --model provider/model --thinking low --suite live --trials 3 --mode both
1546
+ ~~~
1547
+
1548
+ Eval script thu thập:
1549
+
1550
+ - pass/fail;
1551
+ - duration;
1552
+ - parent tool calls;
1553
+ - child tool calls;
1554
+ - input/output/cache token telemetry;
1555
+ - reported cost;
1556
+ - controller usage;
1557
+ - workspace changes;
1558
+ - external grader result.
1559
+
1560
+ ## Eval suites trong repo
749
1561
 
750
- ```text
751
- syntax
752
- → resource validation
753
- → docs:check
754
- → static skill routing
755
- → V2 router matrix
756
- → standard hidden-grader integrity
757
- → long hidden-grader integrity
758
- → polyglot hidden-grader integrity
759
- → V11 contract validation
760
- → Node tests
761
- → npm pack --dry-run
762
- → packed global-install smoke
763
- → plain one-command install compatibility smoke
764
- ```
1562
+ Hiện có các nhóm như:
765
1563
 
766
- Packed smoke xác minh package cài được từ tarball và kiểm tra OpenCode V2 path, skills, commands, subagents, router plugin, task graph, durable state và model config.
1564
+ - live;
1565
+ - long;
1566
+ - polyglot;
1567
+ - repo-scale;
1568
+ - v11;
1569
+ - v14;
1570
+ - routing/router trigger suites.
767
1571
 
768
1572
  ---
769
1573
 
770
- ## Cập nhật và gỡ cài đặt
1574
+ # Cấu trúc repository
1575
+
1576
+ ~~~text
1577
+ opencode-agent-skill-/
1578
+ ├─ bin/
1579
+ │ └─ ocskill.mjs
1580
+ │
1581
+ ├─ lib/
1582
+ │ ├─ task-policy.mjs
1583
+ │ ├─ task-engine.mjs
1584
+ │ ├─ task-graph.mjs
1585
+ │ ├─ dynamic-workflow.mjs
1586
+ │ ├─ context-engine-v11.mjs
1587
+ │ ├─ hierarchical-context.mjs
1588
+ │ ├─ semantic-index.mjs
1589
+ │ ├─ repo-graph.mjs
1590
+ │ ├─ aci.mjs
1591
+ │ ├─ evidence-store.mjs
1592
+ │ ├─ evidence-receipt.mjs
1593
+ │ ├─ gate-receipt.mjs
1594
+ │ ├─ memory-engine.mjs
1595
+ │ ├─ capability-fabric.mjs
1596
+ │ ├─ model-policy.mjs
1597
+ │ ├─ model-performance.mjs
1598
+ │ ├─ worktree-sandbox.mjs
1599
+ │ ├─ container-sandbox.mjs
1600
+ │ ├─ performance-fabric.mjs
1601
+ │ ├─ trajectory.mjs
1602
+ │ ├─ learning-engine.mjs
1603
+ │ ├─ benchmark-confidence.mjs
1604
+ │ ├─ browser-adapter.mjs
1605
+ │ ├─ browser-runtime.mjs
1606
+ │ ├─ browser-mcp-routing.mjs
1607
+ │ └─ ...
1608
+ │
1609
+ ├─ pi/
1610
+ │ ├─ extensions/
1611
+ │ │ └─ ues.ts
1612
+ │ └─ prompts/
1613
+ │ └─ 11 UES slash prompts
1614
+ │
1615
+ ├─ global-config/
1616
+ │ ├─ agents/
1617
+ │ │ └─ 12 specialist agents
1618
+ │ └─ skills/
1619
+ │ └─ 48 domain/workflow skills
1620
+ │
1621
+ ├─ evals/
1622
+ │ ├─ live/
1623
+ │ ├─ long/
1624
+ │ ├─ polyglot/
1625
+ │ ├─ repo-scale/
1626
+ │ ├─ v11/
1627
+ │ └─ v14/
1628
+ │
1629
+ ├─ scripts/
1630
+ │ └─ eval, validation, smoke, install helpers
1631
+ │
1632
+ ├─ test/
1633
+ │ └─ deterministic/runtime/regression tests
1634
+ │
1635
+ └─ docs/
1636
+ ├─ ENGINEERING-DESIGN.md
1637
+ ├─ DETERMINISTIC-TOOLS.md
1638
+ ├─ V11-PERCEPTION-ADAPTIVE-EXECUTION.md
1639
+ ├─ V12-WEAK-MODEL-INTELLIGENCE.md
1640
+ ├─ V13-PARALLEL-WEAK-MODEL-RUNTIME.md
1641
+ ├─ V14-CONTEXT-MEMORY-FABRIC.md
1642
+ └─ V14.1-QUALITY-PERFORMANCE-FABRIC.md
1643
+ ~~~
1644
+
1645
+ ---
1646
+
1647
+ # Một ví dụ đầy đủ
1648
+
1649
+ Task:
1650
+
1651
+ ~~~text
1652
+ /ues-run sửa checkout inventory reservation, chạy test liên quan và xác minh UI checkout
1653
+ ~~~
771
1654
 
772
- Cập nhật lên bản npm mới nhất:
1655
+ Luồng có thể diễn ra:
773
1656
 
774
- ```cmd
775
- ocskill update
776
- ```
1657
+ ~~~mermaid
1658
+ flowchart TD
1659
+ T[User task] --> P[Task Policy STANDARD/DEEP]
1660
+ P --> C[Context selection]
1661
+ C --> R[Repo graph + semantic refs + likely tests]
1662
+ R --> E[Executor]
1663
+ E --> TEST[Targeted backend tests]
1664
+ TEST --> V[Verifier]
777
1665
 
778
- Gỡ UES:
1666
+ V -->|PASS| I[Integration verifier]
1667
+ V -->|FAIL| D[Debugger]
1668
+ D --> E
779
1669
 
780
- ```cmd
781
- ocskill remove
782
- ```
1670
+ I --> B{Visual/browser required?}
1671
+ B -->|No| DONE[Verified completion]
1672
+ B -->|Yes| MCP[Playwright MCP lane]
1673
+ MCP --> VV[Visual verifier]
1674
+ VV -->|PASS| DONE
1675
+ VV -->|FAIL| D
1676
+ ~~~
783
1677
 
784
- UES chỉ quản lý resource có namespace/marker của chính nó và cố gắng giữ nguyên resource không thuộc quyền quản lý của UES.
1678
+ Điểm khác với “một model tự làm tất cả” là:
1679
+
1680
+ 1. context được bounded;
1681
+ 2. implementation và verification tách vai;
1682
+ 3. browser evidence chỉ nạp khi cần;
1683
+ 4. retry có diagnosis;
1684
+ 5. long task có state;
1685
+ 6. parallel writers có isolation;
1686
+ 7. completion bị ràng buộc bởi evidence.
785
1687
 
786
1688
  ---
787
1689
 
788
- ## Tài liệu
1690
+ # Triết lý thiết kế
1691
+
1692
+ ## Deterministic facts trước probabilistic reasoning
1693
+
1694
+ Những việc có thể tính bằng code thì ưu tiên tính bằng code:
1695
+
1696
+ - Git state;
1697
+ - dependency graph;
1698
+ - changed files;
1699
+ - plan cycle;
1700
+ - file overlap;
1701
+ - command exit status;
1702
+ - workspace fingerprint;
1703
+ - provider health;
1704
+ - token/cost telemetry.
1705
+
1706
+ Model tập trung vào phần cần semantic judgment.
1707
+
1708
+ ## Progressive disclosure
1709
+
1710
+ Không nạp:
1711
+
1712
+ - toàn repo;
1713
+ - toàn bộ 48 skills;
1714
+ - mọi MCP tool;
1715
+ - mọi memory;
1716
+ - mọi log.
1717
+
1718
+ Chỉ nạp bounded evidence phù hợp.
1719
+
1720
+ ## Fresh specialists
1721
+
1722
+ Child specialist được tạo với prompt/tool boundary hẹp hơn để giảm contamination từ conversation dài.
789
1723
 
790
- - [Thiết kế hệ thống](docs/ENGINEERING-DESIGN.md)
791
- - [Tương thích OpenCode](docs/OPENCODE-COMPAT.md)
792
- - [Công cụ deterministic](docs/DETERMINISTIC-TOOLS.md)
793
- - [Evaluation](docs/EVALS.md)
794
- - [Trace schema](docs/TRACE-SCHEMA.md)
795
- - [Hướng dẫn publish npm](docs/NPM-PUBLISH.md)
796
- - [Nguồn nghiên cứu](docs/RESEARCH-SOURCES.md)
797
- - [V7 Intelligence Runtime](docs/V7-INTELLIGENCE-RUNTIME.md)
798
- - [V8 Intelligence & Reliability](docs/V8-INTELLIGENCE-RELIABILITY.md)
799
- - [V9 Speed & Intelligence](docs/V9-SPEED-INTELLIGENCE.md)
800
- - [V12 Weak-Model Intelligence (beta)](docs/V12-WEAK-MODEL-INTELLIGENCE.md)
801
- - [V13 Parallel Weak-Model Runtime (beta)](docs/V13-PARALLEL-WEAK-MODEL-RUNTIME.md)
1724
+ ## Evidence-first completion
1725
+
1726
+ “Agent nói đã xong” không phải completion gate.
1727
+
1728
+ ## Reversible optimization
1729
+
1730
+ Tối ưu output/context phải giữ đường lấy raw evidence trở lại.
1731
+
1732
+ ## Benchmark-gated learning
1733
+
1734
+ Không promote rule/tool/provider chỉ vì cảm giác “có vẻ nhanh”.
802
1735
 
803
1736
  ---
804
1737
 
805
- ## npm
1738
+ # Giới hạn có chủ đích
806
1739
 
807
- Package:
1740
+ UES cố ý **không**:
808
1741
 
809
- ```text
810
- opencode-agent-skill
811
- ```
1742
+ - tạo hàng trăm agents;
1743
+ - load mọi skill cho mọi task;
1744
+ - auto push;
1745
+ - auto publish;
1746
+ - auto deploy;
1747
+ - ghi hidden chain-of-thought;
1748
+ - coi keyword routing là semantic truth tuyệt đối;
1749
+ - coi import scan là full compiler/LSP semantic graph;
1750
+ - coi một benchmark là bằng chứng model-equivalence;
1751
+ - bỏ verifier chỉ để tăng tốc;
1752
+ - dùng browser tool cho backend task không cần browser.
812
1753
 
813
- Cài đặt:
1754
+ ---
814
1755
 
815
- ```cmd
816
- npm install -g opencode-agent-skill
817
- ```
1756
+ # Quick start
818
1757
 
819
- Phiên bản hiện tại:
1758
+ ~~~cmd
1759
+ npm install -g @earendil-works/pi-coding-agent
1760
+ pi install git:github.com/laivannha0202/opencode-agent-skill-
1761
+ pi
1762
+ ~~~
820
1763
 
821
- ```text
822
- 13.0.0-beta.1
823
- ```
1764
+ Trong Pi:
824
1765
 
825
- V13 beta dùng npm dist-tag `next`; `latest` tiếp tục trỏ tới V11 stable cho đến khi các release gate V13 hoàn tất.
1766
+ ~~~text
1767
+ /ues-run kiểm tra project, tìm lỗi, sửa lỗi cần thiết và chạy test xác minh
1768
+ ~~~
826
1769
 
827
- Maintainer packaging gate:
1770
+ Kiểm tra deterministic runtime:
828
1771
 
829
- ```cmd
830
- npm run ci
831
- npm pack --dry-run
832
- npm pack
833
- ```
1772
+ ~~~cmd
1773
+ ues task-policy "fix checkout bug" --json
1774
+ ues capability-fabric status .
1775
+ ues hierarchy "checkout inventory" .
1776
+ ues memory status .
1777
+ ~~~
834
1778
 
835
- Trước khi publish, kiểm tra version chưa tồn tại trên registry:
1779
+ ---
836
1780
 
837
- ```cmd
838
- npm view opencode-agent-skill@13.0.0-beta.1 version --registry=https://registry.npmjs.org/
839
- ```
1781
+ # Tài liệu sâu hơn
840
1782
 
841
- Nếu version chưa tồn tại, prerelease được publish với dist-tag `next`.
1783
+ - <code>docs/ENGINEERING-DESIGN.md</code> — engineering architecture.
1784
+ - <code>docs/DETERMINISTIC-TOOLS.md</code> — deterministic CLI/evidence tools.
1785
+ - <code>docs/V11-PERCEPTION-ADAPTIVE-EXECUTION.md</code> — perception/adaptive execution.
1786
+ - <code>docs/V12-WEAK-MODEL-INTELLIGENCE.md</code> — weak-model intelligence.
1787
+ - <code>docs/V13-PARALLEL-WEAK-MODEL-RUNTIME.md</code> — parallel runtime.
1788
+ - <code>docs/V14-CONTEXT-MEMORY-FABRIC.md</code> — context, memory, capability fabric.
1789
+ - <code>docs/V14.1-QUALITY-PERFORMANCE-FABRIC.md</code> — quality-preserving performance.
1790
+ - <code>docs/EVALS.md</code> — evaluation.
1791
+ - <code>docs/PI-COMPAT.md</code> — Pi compatibility.
1792
+ - <code>docs/NPM-PUBLISH.md</code> — npm publishing.
842
1793
 
843
1794
  ---
844
1795
 
845
- ## License
1796
+ # License
846
1797
 
847
- MIT
1798
+ MIT