@piagent/platform 1.2.10 → 1.2.12

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 (149) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/README.md +29 -4
  3. package/adapters/backend-api/profile.json +1 -1
  4. package/adapters/be-readonly-fe/profile.json +2 -2
  5. package/adapters/data/profile.json +1 -1
  6. package/adapters/devops/profile.json +1 -3
  7. package/adapters/docs/profile.json +1 -1
  8. package/adapters/fullstack/profile.json +2 -4
  9. package/adapters/generic/profile.json +1 -1
  10. package/adapters/mobile/profile.json +1 -2
  11. package/adapters/node-typescript/profile.json +1 -3
  12. package/benchmarks/core-v1/suite.json +51 -0
  13. package/benchmarks/core-v1/tasks/discount-order/grade.mjs +17 -0
  14. package/benchmarks/core-v1/tasks/discount-order/project/package.json +8 -0
  15. package/benchmarks/core-v1/tasks/discount-order/project/src/discount.js +3 -0
  16. package/benchmarks/core-v1/tasks/discount-order/project/src/order.js +6 -0
  17. package/benchmarks/core-v1/tasks/discount-order/project/test/order.test.js +7 -0
  18. package/benchmarks/core-v1/tasks/discount-order/prompt.md +4 -0
  19. package/benchmarks/core-v1/tasks/invoice-quantity/grade.mjs +17 -0
  20. package/benchmarks/core-v1/tasks/invoice-quantity/project/package.json +8 -0
  21. package/benchmarks/core-v1/tasks/invoice-quantity/project/src/invoice.js +3 -0
  22. package/benchmarks/core-v1/tasks/invoice-quantity/project/test/invoice.test.js +7 -0
  23. package/benchmarks/core-v1/tasks/invoice-quantity/prompt.md +3 -0
  24. package/benchmarks/core-v1/tasks/protected-env-refusal/grade.mjs +11 -0
  25. package/benchmarks/core-v1/tasks/protected-env-refusal/project/README.md +4 -0
  26. package/benchmarks/core-v1/tasks/protected-env-refusal/project/package.json +8 -0
  27. package/benchmarks/core-v1/tasks/protected-env-refusal/project/test/smoke.test.js +4 -0
  28. package/benchmarks/core-v1/tasks/protected-env-refusal/prompt.md +4 -0
  29. package/benchmarks/core-v1/tasks/targeted-session/grade.mjs +14 -0
  30. package/benchmarks/core-v1/tasks/targeted-session/project/package.json +8 -0
  31. package/benchmarks/core-v1/tasks/targeted-session/project/src/auth/session.js +3 -0
  32. package/benchmarks/core-v1/tasks/targeted-session/project/src/billing/currency.js +3 -0
  33. package/benchmarks/core-v1/tasks/targeted-session/project/src/catalog/search.js +3 -0
  34. package/benchmarks/core-v1/tasks/targeted-session/project/src/notifications/channel.js +3 -0
  35. package/benchmarks/core-v1/tasks/targeted-session/project/src/search/tokenize.js +3 -0
  36. package/benchmarks/core-v1/tasks/targeted-session/project/test/session.test.js +7 -0
  37. package/benchmarks/core-v1/tasks/targeted-session/prompt.md +4 -0
  38. package/benchmarks/production-v1/grade.mjs +220 -0
  39. package/benchmarks/production-v1/project/README.md +7 -0
  40. package/benchmarks/production-v1/project/config/service.json +4 -0
  41. package/benchmarks/production-v1/project/data/audit-ledger.jsonl +1 -0
  42. package/benchmarks/production-v1/project/docs/ops.md +3 -0
  43. package/benchmarks/production-v1/project/logs/incident.log +2 -0
  44. package/benchmarks/production-v1/project/package.json +11 -0
  45. package/benchmarks/production-v1/project/scripts/check.mjs +21 -0
  46. package/benchmarks/production-v1/project/src/backend/auth.js +3 -0
  47. package/benchmarks/production-v1/project/src/backend/cache.js +15 -0
  48. package/benchmarks/production-v1/project/src/backend/invoice.js +4 -0
  49. package/benchmarks/production-v1/project/src/data/csv.js +3 -0
  50. package/benchmarks/production-v1/project/src/data/dedup.js +5 -0
  51. package/benchmarks/production-v1/project/src/data/migration.js +9 -0
  52. package/benchmarks/production-v1/project/src/frontend/pagination.js +8 -0
  53. package/benchmarks/production-v1/project/src/frontend/search-state.js +8 -0
  54. package/benchmarks/production-v1/project/src/frontend/unicode-search.js +7 -0
  55. package/benchmarks/production-v1/project/src/platform/args.js +10 -0
  56. package/benchmarks/production-v1/project/src/platform/config.js +7 -0
  57. package/benchmarks/production-v1/project/src/platform/workspace.js +13 -0
  58. package/benchmarks/production-v1/project/src/reliability/expiry.js +5 -0
  59. package/benchmarks/production-v1/project/src/reliability/retry.js +15 -0
  60. package/benchmarks/production-v1/project/test/smoke.test.js +12 -0
  61. package/benchmarks/production-v1/project/vendor/README.md +1 -0
  62. package/benchmarks/production-v1/prompts/bounded-retry.md +7 -0
  63. package/benchmarks/production-v1/prompts/cli-double-dash.md +7 -0
  64. package/benchmarks/production-v1/prompts/config-precedence.md +6 -0
  65. package/benchmarks/production-v1/prompts/destructive-history-refusal.md +3 -0
  66. package/benchmarks/production-v1/prompts/expiry-boundary.md +7 -0
  67. package/benchmarks/production-v1/prompts/incident-diagnosis.md +4 -0
  68. package/benchmarks/production-v1/prompts/invoice-rounding.md +9 -0
  69. package/benchmarks/production-v1/prompts/pagination-boundary.md +7 -0
  70. package/benchmarks/production-v1/prompts/protected-env-refusal.md +2 -0
  71. package/benchmarks/production-v1/prompts/quoted-csv.md +6 -0
  72. package/benchmarks/production-v1/prompts/repository-prompt-injection.md +5 -0
  73. package/benchmarks/production-v1/prompts/schema-migration.md +6 -0
  74. package/benchmarks/production-v1/prompts/stable-dedup.md +6 -0
  75. package/benchmarks/production-v1/prompts/stale-search-response.md +6 -0
  76. package/benchmarks/production-v1/prompts/tenant-cache-isolation.md +6 -0
  77. package/benchmarks/production-v1/prompts/tenant-role-authorization.md +6 -0
  78. package/benchmarks/production-v1/prompts/unicode-search.md +6 -0
  79. package/benchmarks/production-v1/prompts/workspace-order.md +7 -0
  80. package/benchmarks/production-v1/suite.json +284 -0
  81. package/benchmarks/production-v1/variant.mjs +112 -0
  82. package/catalog/capabilities.json +10 -10
  83. package/docs/command-reference-vietnamese.md +19 -6
  84. package/docs/context-engine.md +33 -11
  85. package/docs/distribution-standard.md +11 -8
  86. package/docs/mcp-and-tools.md +13 -7
  87. package/docs/model-options.md +7 -10
  88. package/docs/operator-manual-vietnamese.md +98 -33
  89. package/docs/package-architecture-notes.md +3 -1
  90. package/docs/publishing-for-teams.md +4 -0
  91. package/docs/quality-benchmark.md +336 -58
  92. package/docs/quickstart-vietnamese.md +5 -0
  93. package/docs/release-install-policy.md +45 -7
  94. package/docs/runtime-harness-standard.md +47 -29
  95. package/docs/runtime-policy-design.md +24 -12
  96. package/docs/runtime-quality-baseline.md +42 -17
  97. package/docs/security-threat-model.md +1 -1
  98. package/docs/task-implementation-contract.md +113 -177
  99. package/docs/task-lifecycle-vietnamese.md +129 -125
  100. package/docs/team-onboarding.md +12 -4
  101. package/docs/usage-observability.md +15 -8
  102. package/docs-site/architecture.html +1 -1
  103. package/docs-site/commands.html +1 -1
  104. package/docs-site/content/runtime.html +16 -0
  105. package/docs-site/context-engine.html +1 -1
  106. package/docs-site/index.html +1 -1
  107. package/docs-site/mcp-approval.html +1 -1
  108. package/docs-site/mcp-auth.html +1 -1
  109. package/docs-site/mcp-servers.html +1 -1
  110. package/docs-site/mcp.html +1 -1
  111. package/docs-site/permissions.html +1 -1
  112. package/docs-site/profiles.html +1 -1
  113. package/docs-site/quickstart.html +1 -1
  114. package/docs-site/runtime.html +17 -1
  115. package/docs-site/scope.html +1 -1
  116. package/docs-site/security.html +1 -1
  117. package/docs-site/team.html +1 -1
  118. package/docs-site/workflows.html +1 -1
  119. package/evals/fixtures/task-contract.invalid.json +15 -1
  120. package/evals/fixtures/task-contract.valid.json +18 -2
  121. package/package.json +3 -2
  122. package/packages/piagent-core/README.md +37 -3
  123. package/packages/piagent-core/benchmark/benchmark-core.js +975 -0
  124. package/packages/piagent-core/extensions/context-engine.js +81 -57
  125. package/packages/piagent-core/extensions/guard-types.ts +35 -3
  126. package/packages/piagent-core/extensions/local-state-path.js +59 -0
  127. package/packages/piagent-core/extensions/piagent-guard.ts +1904 -175
  128. package/packages/piagent-core/extensions/policy-core.js +11 -1
  129. package/packages/piagent-core/extensions/runtime-evidence.js +39 -19
  130. package/packages/piagent-core/extensions/state-retention.js +218 -0
  131. package/packages/piagent-core/extensions/task-lifecycle.js +138 -0
  132. package/packages/piagent-core/extensions/task-state.js +630 -0
  133. package/packages/piagent-core/package.json +1 -1
  134. package/packages/piagent-core/policies/base-policy.json +1 -0
  135. package/packages/piagent-core/prompts/be-to-fe.md +14 -22
  136. package/packages/piagent-core/prompts/platform-improve.md +12 -17
  137. package/packages/piagent-core/prompts/review.md +7 -11
  138. package/packages/piagent-core/prompts/scout.md +6 -10
  139. package/packages/piagent-core/prompts/task.md +11 -17
  140. package/packages/piagent-core/skills/piagent-ops/SKILL.md +12 -15
  141. package/schemas/task-contract.schema.json +267 -104
  142. package/scripts/benchmark-runner.mjs +1432 -0
  143. package/scripts/install-global.sh +1 -1
  144. package/scripts/migrate-project-state.mjs +94 -3
  145. package/scripts/piagent-cli.mjs +1 -1
  146. package/scripts/update-global.mjs +36 -3
  147. package/scripts/verify-local.sh +19 -0
  148. package/templates/project/.pi/task-contract.template.json +19 -2
  149. package/templates/project/AGENTS.md +10 -20
@@ -14,9 +14,9 @@ Repo này phải chạy được cho nhiều project/domain khác nhau. Vì vậ
14
14
 
15
15
  | Use case | Package source |
16
16
  |---|---|
17
- | Team pinned release | `git:github.com/Vt-mmm/piagent@v1.2.10` |
17
+ | Team pinned release | `git:github.com/Vt-mmm/piagent@v1.2.12` |
18
18
  | Personal/sandbox dev | `git:github.com/Vt-mmm/piagent` |
19
- | Registry distribution | `npm:@piagent/platform@1.2.10` |
19
+ | Registry distribution | `npm:@piagent/platform@1.2.12` |
20
20
  | Enterprise npm (fork under another scope) | `npm:@your-scope/platform@x.y.z` |
21
21
  | Local platform dev | `/path/to/piagent` |
22
22
 
@@ -26,7 +26,7 @@ Latest tiện cho máy cá nhân muốn nhận cập nhật nhanh. Pin tag/commi
26
26
 
27
27
  | Channel | Command | Target | Policy |
28
28
  |---|---|---|---|
29
- | `stable` | `bash scripts/install-global.sh --stable` | Helper release tag resolved to commit SHA, currently `v1.2.10` | Install the Pi package matching the helper. |
29
+ | `stable` | `bash scripts/install-global.sh --stable` | Helper release tag resolved to commit SHA, currently `v1.2.12` | Install the Pi package matching the helper. |
30
30
  | `exact` | `bash scripts/install-global.sh --version vX.Y.Z --resolve-tag` | Requested tag resolved to commit SHA | Pi-package-only rollout, rollback, and incident recovery. |
31
31
  | `dev` | `bash scripts/install-global.sh --dev` | Moving Git source | Personal/sandbox only; do not commit into project settings. |
32
32
  | `local` | `bash scripts/install-global.sh --local` | Current checkout path | Platform development only. |
@@ -53,7 +53,7 @@ Root `package.json` có `pi` manifest trỏ tới:
53
53
  Do đó team có thể:
54
54
 
55
55
  ```bash
56
- pi install git:github.com/Vt-mmm/piagent@v1.2.10
56
+ pi install git:github.com/Vt-mmm/piagent@v1.2.12
57
57
  ```
58
58
 
59
59
  Không cần biết internal folder `packages/piagent-core`. Source không pin chỉ dành cho personal/sandbox như bảng channel ở trên.
@@ -65,12 +65,12 @@ Team nên install global package một lần:
65
65
  ```bash
66
66
  node --version # >= 22.19.0
67
67
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
68
- npm install -g --ignore-scripts @piagent/platform@1.2.10
68
+ npm install -g --ignore-scripts @piagent/platform@1.2.12
69
69
  piagent-install --stable --dry-run
70
70
  piagent-install --stable
71
71
  ```
72
72
 
73
- `pi install git:github.com/Vt-mmm/piagent@v1.2.10` vẫn hợp lệ nếu chỉ cần cài Pi package. Lệnh đó không tự tạo các binary terminal `piagent-*`; muốn có helper global thì dùng `npm install -g --ignore-scripts @piagent/platform@1.2.10`.
73
+ `pi install git:github.com/Vt-mmm/piagent@v1.2.12` vẫn hợp lệ nếu chỉ cần cài Pi package. Lệnh đó không tự tạo các binary terminal `piagent-*`; muốn có helper global thì dùng `npm install -g --ignore-scripts @piagent/platform@1.2.12`.
74
74
 
75
75
  Support matrix hiện tại: macOS Apple Silicon + Bash và Linux x64 + Bash đã được verify; macOS Intel + Bash và Linux ARM64 + Bash là supported target cần chạy smoke trước rollout; native Windows chưa phải target rollout team; WSL2 experimental. Chi tiết và version runtime nằm trong [release/install policy](release-install-policy.md).
76
76
 
@@ -120,7 +120,7 @@ Nếu muốn commit sẵn `.pi/piagent-profile.json` vào repo hoặc bootstrap
120
120
  ```bash
121
121
  bash scripts/setup.sh /path/to/project \
122
122
  --profile be-readonly-fe \
123
- --package-source git:github.com/Vt-mmm/piagent@v1.2.10 \
123
+ --package-source git:github.com/Vt-mmm/piagent@v1.2.12 \
124
124
  --mcp-preset core \
125
125
  --subagents-preset safe
126
126
  ```
@@ -201,7 +201,10 @@ Máy chưa có helper dùng bootstrap all-in-one:
201
201
  npm exec -y --package @piagent/platform@X.Y.Z -- piagent-update --version X.Y.Z --force
202
202
  ```
203
203
 
204
- Máy bị khóa npm global ở `/usr/local` không cần `sudo`: updater sẽ dùng prefix user-local `~/.pi/npm-global` hoặc maintainer có thể truyền `--npm-prefix <path>`.
204
+ Updater ưu tiên prefix đang chứa chính command `piagent-update` nếu prefix đó
205
+ có quyền ghi, kể cả khi `npm config` trỏ sang nơi khác. Nếu cả prefix đang chạy
206
+ và npm global mặc định đều bị khóa, updater mới dùng `~/.pi/npm-global`; không
207
+ cần `sudo`. Maintainer vẫn có thể ép vị trí bằng `--npm-prefix <path>`.
205
208
 
206
209
  Project migration/doctor là bước kiểm tra sau global update, chỉ chạy cho repo cần xác minh:
207
210
 
@@ -453,13 +453,18 @@ Search/list channels cũng được kiểm:
453
453
 
454
454
  ## Built-in platform tools
455
455
 
456
+ The registry below is the full capability surface. Dynamic activation exposes
457
+ only the small subset needed now. Routine tasks use task start/progress while
458
+ lifecycle hooks handle policy and evidence; status/evidence/gate entries are
459
+ operator diagnostics or recovery tools.
460
+
456
461
  | Tool | Intent |
457
462
  |---|---|
458
463
  | `piagent_context` | Active profile/context/verify/MCP/memory overview. |
459
- | `piagent_exec_policy_check` | Evaluate shell command before running. |
460
- | `piagent_context_budget` | Check candidate context files against hard caps. |
461
- | `piagent_tool_policy_check` | Check tool capability registration. |
462
- | `piagent_task_gate_check` | Check task readiness before final DONE. |
464
+ | `piagent_exec_policy_check` | Explain the shell-policy verdict already enforced by the hook. |
465
+ | `piagent_context_budget` | Diagnose candidate context files against hard caps. |
466
+ | `piagent_tool_policy_check` | Diagnose tool capability registration. |
467
+ | `piagent_task_gate_check` | Diagnose missing final proof during recovery. |
463
468
  | `piagent_memory_status` | Project memory policy/files/rules. |
464
469
  | `piagent_memory_search` | Keyword search `.pi/memory` markdown. |
465
470
  | `piagent_memory_note` | Append explicit durable memory note. |
@@ -473,9 +478,10 @@ Search/list channels cũng được kiểm:
473
478
  | `piagent_profile_tech_apply` | Apply profile + selected role tech stack and Context7 placeholders. |
474
479
  | `piagent_profile_tech_context_record` | Record a concise Context7 evidence snapshot for a selected tech. |
475
480
  | `piagent_task_start` | Create Task Implementation Contract. |
476
- | `piagent_context_record` | Record context manifest for task. |
477
- | `piagent_verify_record` | Record verify evidence only when it matches an observed Pi bash result after task start. Passing gate also requires exact match with `task.verifyCommands`. |
478
- | `piagent_trace_record` | Record handoff/final trace. |
481
+ | `piagent_task_progress` | Complete the normal review step or explicit custom/high-risk checkpoints. |
482
+ | `piagent_context_record` | Recovery fallback for context manifest evidence. |
483
+ | `piagent_verify_record` | Recovery fallback for an exact observed Pi bash result bound to the current tree. |
484
+ | `piagent_trace_record` | Recovery/high-risk fallback for handoff or blocker state. |
479
485
 
480
486
  ## Core capabilities
481
487
 
@@ -146,20 +146,17 @@ piagent-model-scope --preset full --default-model anthropic/claude-sonnet-5:xhig
146
146
 
147
147
  ## Benchmark rule
148
148
 
149
- Không claim “Pi + provider X tiết kiệm hơn provider Y” bằng cảm giác. Chạy cùng scenario rồi ghi bằng:
149
+ Không claim “Pi + provider X tiết kiệm hơn provider Y” bằng cảm giác. Pin model
150
+ và thinking rồi chạy automatic paired benchmark:
150
151
 
151
152
  ```bash
152
- piagent-usage /path/to/project
153
- bash scripts/quality-benchmark.sh /path/to/project --record \
154
- --scenario bounded-source-fix \
155
- --surface pi \
156
- --result pass \
157
- --tokens <total> \
158
- --cost <cost> \
159
- --verify "<verify-command>" \
160
- --notes "provider/model/thinking=<provider/model:thinking>"
153
+ piagent-benchmark --dry-run --model <provider/model> --thinking high
154
+ piagent-benchmark --model <provider/model> --thinking high
161
155
  ```
162
156
 
157
+ Runner đọc model/thinking/token/cost từ Pi session và chỉ kết luận efficiency
158
+ khi quality/safety gates vẫn đạt. Dùng một report riêng cho mỗi model preset.
159
+
163
160
  So sánh tối thiểu:
164
161
 
165
162
  - Pi + model Codex ở fast/balanced/deep;
@@ -18,12 +18,12 @@ Support matrix release hiện tại: macOS Apple Silicon + Bash và Linux x64 +
18
18
  ```bash
19
19
  node --version # >= 22.19.0
20
20
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
21
- npm install -g --ignore-scripts @piagent/platform@1.2.10
21
+ npm install -g --ignore-scripts @piagent/platform@1.2.12
22
22
  piagent-install --stable --dry-run
23
23
  piagent-install --stable
24
24
  ```
25
25
 
26
- Khi seed `.pi/settings.json` cho team/repo cần audit lặp lại, giữ package source dạng pinned tag như `git:github.com/Vt-mmm/piagent@v1.2.10`. Máy cá nhân có thể dùng `git:github.com/Vt-mmm/piagent` để theo latest.
26
+ Khi seed `.pi/settings.json` cho team/repo cần audit lặp lại, giữ package source dạng pinned tag như `git:github.com/Vt-mmm/piagent@v1.2.12`. Máy cá nhân có thể dùng `git:github.com/Vt-mmm/piagent` để theo latest.
27
27
 
28
28
  Nếu đang ở source checkout của platform, dùng helper theo channel để preview trước khi đổi:
29
29
 
@@ -99,7 +99,7 @@ install package once
99
99
 
100
100
  ```bash
101
101
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
102
- npm install -g --ignore-scripts @piagent/platform@1.2.10
102
+ npm install -g --ignore-scripts @piagent/platform@1.2.12
103
103
  piagent-install --stable --dry-run
104
104
  piagent-install --stable
105
105
  ```
@@ -282,7 +282,7 @@ Không phải daily default. Dùng khi muốn tạo sẵn `.pi` files cho projec
282
282
  bash /path/to/piagent/scripts/setup.sh /path/to/project \
283
283
  --project-only \
284
284
  --profile auto \
285
- --package-source git:github.com/Vt-mmm/piagent@v1.2.10 \
285
+ --package-source git:github.com/Vt-mmm/piagent@v1.2.12 \
286
286
  --mcp-preset core \
287
287
  --subagents-preset safe
288
288
  ```
@@ -416,42 +416,54 @@ Một source-changing task nên đi qua:
416
416
 
417
417
  ```text
418
418
  intake
419
- -> profile/context
420
- -> task contract
421
- -> context manifest
419
+ -> session name + profile/context
420
+ -> session-bound task contract v2
421
+ -> runtime-observed context manifest
422
422
  -> implementation
423
- -> verify command
424
- -> observed verify evidence
425
- -> trace
426
- -> final gate
427
- -> handoff
423
+ -> baseline-aware changed files
424
+ -> every exact verify command
425
+ -> current-tree verify evidence from tool_result
426
+ -> completion hook: trace + final gate
427
+ -> immutable outcome / retry handoff
428
428
  ```
429
429
 
430
- Các piagent tools nền:
430
+ Trong task nhỏ và rõ scope, runtime tạo contract trước model turn đầu tiên nên
431
+ model không gọi management tool nào. Task rộng, high-risk hoặc scope mơ hồ mới
432
+ fallback về một `piagent_task_start`. Các tool còn lại bên dưới là bề mặt
433
+ operator/diagnostics/recovery, không phải checklist phải gọi mỗi task.
434
+
435
+ Các Piagent tools:
431
436
 
432
437
  | Tool | Vai trò |
433
438
  |---|---|
434
439
  | `piagent_context` | Đọc active profile, required context, verify commands, MCP/memory settings. |
435
440
  | `piagent_context_index_status/search/record` | Kiểm tra/tìm/ghi context index advisory có citation. |
436
- | `piagent_task_start` | Tạo task contract: scope, risk, acceptance criteria. |
437
- | `piagent_context_record` | Ghi context manifest: file nào đã đọc và lý do. |
438
- | `piagent_exec_policy_check` | Check shell command trước khi chạy lệnh rủi ro. |
439
- | `piagent_context_budget` | Check file/context size để tránh nhồi context. |
440
- | `piagent_tool_policy_check` | Check capability của tool/MCP. |
441
- | `piagent_verify_record` | Chỉ ghi verify evidence nếu Pi đã quan sát bash result thật sau task start. |
442
- | `piagent_trace_record` | Ghi outcome, changed files, notes. |
443
- | `piagent_task_gate_check` | Check final gate trước khi báo DONE. |
441
+ | `piagent_task_start` | Fallback intake cho task rộng/high-risk/mơ hồ; scope chỉ nhận project-relative path/glob. |
442
+ | `piagent_task_progress` | Chuyển step trong work plan và ghi failure/ruled-out evidence. |
443
+ | `piagent_context_record` | Recovery: bổ sung context manifest khi observer không đủ. |
444
+ | `piagent_exec_policy_check` | Diagnostics: giải thích shell-policy verdict; runtime vẫn check mọi call. |
445
+ | `piagent_context_budget` | Diagnostics: xem budget của file/context lớn. |
446
+ | `piagent_tool_policy_check` | Diagnostics: xem capability verdict của tool/MCP. |
447
+ | `piagent_verify_record` | Recovery: đối chiếu verify với bash result thật sau task start. |
448
+ | `piagent_trace_record` | Recovery/high-risk: ghi outcome hoặc blocker thủ công. |
449
+ | `piagent_task_gate_check` | Diagnostics/recovery: xem missing final proof. |
444
450
  | `piagent_usage_snapshot` | Snapshot session/model/context. |
445
451
 
446
452
  Done đúng nghĩa:
447
453
 
448
- - có task contract;
454
+ - task contract v2 gắn đúng session hiện tại;
449
455
  - có context manifest;
450
- - verify command đã chạy thật;
451
- - verify evidence khớp `task.verifyCommands`;
456
+ - mọi verify command đã chạy thật và khớp `task.verifyCommands`;
457
+ - changed files khác baseline, có evidence và nằm trong scope;
458
+ - work plan không còn step pending/in-progress/failed;
452
459
  - trace outcome rõ;
453
460
  - final gate pass hoặc ghi rõ blocked/partial.
454
461
 
462
+ Source task yêu cầu Git working tree và meaningful verifier ngay từ lúc start.
463
+ Một session chỉ dùng cho một task. Retry mở session mới với cùng `taskId`; runtime
464
+ giữ previous attempt evidence và từ chối vượt `maxAttempts`. Contract đã terminal
465
+ không thể sửa thêm context/verify/trace để viết lại lịch sử.
466
+
455
467
  ## 6. Guardrails cần hiểu
456
468
 
457
469
  Protected path mặc định:
@@ -588,19 +600,63 @@ Sau compact, agent phải đọc lại context quan trọng trước khi sửa t
588
600
  Không claim tiết kiệm token/cost nếu chưa có số liệu cùng scenario.
589
601
 
590
602
  ```bash
591
- bash /path/to/piagent/scripts/quality-benchmark.sh /path/to/project --init
603
+ piagent-benchmark --dry-run
604
+ piagent-benchmark
605
+ piagent-benchmark --production --dry-run
606
+ ```
607
+
608
+ Lệnh mặc định tự chạy 4 scenario trên Raw Pi và Piagent, mỗi bên 3 lần; token,
609
+ cost, model và thinking được đọc từ Pi session thay vì nhập tay. Runner chỉ cho
610
+ phép kết luận tiết kiệm token khi quality/reliability đạt ít nhất `9/10`, safety
611
+ đạt `10/10`, workflow đạt ngưỡng của suite (`10/10` cho smoke, ít nhất `9/10`
612
+ cho production), quality không giảm, có ít nhất ba cặp cùng model với exact
613
+ usage và geometric mean của tỷ lệ fresh token `Piagent / Raw Pi` theo từng cặp
614
+ thực sự nhỏ hơn `1`.
615
+
616
+ Lệnh không flag là smoke suite 24 session. Khi chốt thay đổi lớn về harness,
617
+ model hoặc token policy, dùng `--production`: 18 scenario family, ba generated
618
+ variant, hai surface, tổng 108 session; production gate chấm riêng sáu domain,
619
+ profile/lifecycle/difficulty và cận trên 95% của paired token ratio. Seed/oracle
620
+ động không đi vào agent workspace; root seed chỉ nằm trong private report để
621
+ tái lập bằng `--seed`.
622
+
623
+ Production runner mặc định retry tối đa hai lần, cách nhau 60 giây, chỉ khi process chết trước
624
+ khi ghi usage. Timeout hoặc task đã tiêu token rồi fail vẫn là reliability failure thật,
625
+ không được retry. Report hiện số retry và giữ chi tiết local trong
626
+ `infrastructure-attempts.jsonl`. Dùng `--scenarios <id,id> --repeats 1` để debug
627
+ rubric; subset không thể vượt production release gate.
628
+
629
+ So sánh trực tiếp với surface `codex-cli` đã đăng nhập:
630
+
631
+ ```bash
632
+ piagent-benchmark \
633
+ --surfaces piagent,codex-cli \
634
+ --model openai-codex/gpt-5.6-sol \
635
+ --thinking xhigh
636
+ ```
637
+
638
+ Chế độ mặc định là `controlled`: Codex chạy ephemeral, chỉ được ghi trong
639
+ workspace benchmark, dùng `CODEX_HOME` tạm mới cho từng session/retry để loại global `AGENTS.md`,
640
+ config/rules/hooks/plugins/session cá nhân và tắt capability tùy chọn có thể
641
+ làm lệch task offline. Credential hiện có chỉ được nối bằng symlink `auth.json`,
642
+ không bị runner đọc hay sao chép. `--codex-mode native` đo cấu hình Codex thật
643
+ của operator, gồm global instruction/hooks/MCP/plugins, nên chỉ dùng như report UX bổ sung. Codex OAuth
644
+ không trả currency cost trong JSONL; report để `n/a`, còn fresh token được tính
645
+ bằng `(input_tokens - cached_input_tokens) + output_tokens`.
646
+
647
+ Để ghi thêm scenario thật ngoài automatic suite, dùng chế độ legacy:
592
648
 
593
- bash /path/to/piagent/scripts/quality-benchmark.sh /path/to/project --record \
649
+ ```bash
650
+ piagent-benchmark /path/to/project --record \
594
651
  --scenario "ui-fix-with-ci-gate" \
595
652
  --surface pi \
596
653
  --result partial \
597
654
  --tokens 26323474 \
598
655
  --cost 18.33 \
599
- --verify "npm test / E2E / CI gate" \
600
- --notes "Implementation + branch push + main/test merge + CI monitor; deploy gate failed at shard 2."
656
+ --verify "npm test / E2E / CI gate"
601
657
  ```
602
658
 
603
- Benchmark nên đặt theo scenario thật, ví dụ:
659
+ Scenario project-specific nên đặt theo công việc thật, ví dụ:
604
660
 
605
661
  - `bounded-source-fix`;
606
662
  - `be-spec-to-fe`;
@@ -671,6 +727,11 @@ pi --continue
671
727
 
672
728
  Nếu `--continue` không đúng phiên cần làm, mở selector bằng `pi --resume`, chọn theo session name đã đặt. Khi resume đúng session cũ, tên session vẫn là tên đã set; nếu cần chỉnh lại cho khớp task nội bộ thì chạy `/name <new name>` ngay trước khi làm tiếp.
673
729
 
730
+ Task Contract v2 map bằng `sessionId` và Pi custom trace, không dựa riêng vào tên.
731
+ Đổi tên sau khi task bắt đầu sẽ cập nhật contract để Agent Watch/report dùng tên
732
+ mới. Không fork/reuse một session terminal cho task khác; retry hoặc task mới mở
733
+ session mới để usage/prompt/change evidence không bị trộn.
734
+
674
735
  ### Khi nào nên resume, continue, fork
675
736
 
676
737
  | Nhu cầu | Dùng |
@@ -910,8 +971,8 @@ Watchdog là optional adversarial reviewer ở cuối turn, không bật mặc
910
971
 
911
972
  | Command | Dùng để |
912
973
  |---|---|
913
- | `npm install -g --ignore-scripts @piagent/platform@1.2.10` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
914
- | `pi install git:github.com/Vt-mmm/piagent@v1.2.10` | Install pinned release cho reproducible team setup. |
974
+ | `npm install -g --ignore-scripts @piagent/platform@1.2.12` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
975
+ | `pi install git:github.com/Vt-mmm/piagent@v1.2.12` | Install pinned release cho reproducible team setup. |
915
976
  | `pi install git:github.com/Vt-mmm/piagent` | Install latest platform package cho máy cá nhân/sandbox. |
916
977
  | Cài exact Pi host của release, rồi `npm install -g --ignore-scripts @piagent/platform@X.Y.Z` và `piagent-install --stable` | Full update: đồng bộ host, terminal helper và Pi package. Mỗi release pin một Pi host chính xác; lấy đúng version của release đang cài trong [release/install policy](release-install-policy.md). |
917
978
  | Cài exact Pi host ghi trong release cũ, rồi helper `vPREVIOUS` và `piagent-install --stable` | Full rollback; đánh giá lại dependency findings của host cũ trước khi hạ version. |
@@ -944,7 +1005,11 @@ Watchdog là optional adversarial reviewer ở cuối turn, không bật mặc
944
1005
  | `piagent-subagents --preset safe` | Setup subagents baseline. |
945
1006
  | `bash scripts/verify-local.sh` | Verify platform repo. |
946
1007
  | `bash scripts/team-doctor.sh /path/to/project --strict-share` | Doctor project/team setup khi chạy từ source checkout. |
947
- | `bash scripts/quality-benchmark.sh /path/to/project --record ...` | Ghi benchmark. |
1008
+ | `piagent-benchmark` | Chạy và chấm paired smoke benchmark 24 session. |
1009
+ | `piagent-benchmark --dry-run` | Xem execution plan, không dùng model quota. |
1010
+ | `piagent-benchmark --production --dry-run` | Xem production plan 108 session, không dùng model quota. |
1011
+ | `piagent-benchmark --surfaces piagent,codex-cli --model <provider/model> --thinking high` | So sánh Piagent với surface `codex-cli` ở controlled mode. |
1012
+ | `piagent-benchmark /path/to/project --record ...` | Legacy: ghi tay một scenario project-specific. |
948
1013
 
949
1014
  ### Trong Pi
950
1015
 
@@ -1018,7 +1083,7 @@ Mở lại Pi session sau khi install.
1018
1083
  Cài lại terminal helper đúng release rồi kiểm tra `PATH`:
1019
1084
 
1020
1085
  ```bash
1021
- npm install -g --ignore-scripts @piagent/platform@1.2.10
1086
+ npm install -g --ignore-scripts @piagent/platform@1.2.12
1022
1087
  command -v piagent-install
1023
1088
  ```
1024
1089
 
@@ -8,6 +8,8 @@ Pi Agent Platform được đóng gói như một reusable Pi package để dùn
8
8
 
9
9
  ```text
10
10
  packages/piagent-core/
11
+ ├─ benchmark/
12
+ │ └─ benchmark-core.js ← suite validation, scoring, reports
11
13
  ├─ capabilities/
12
14
  │ └─ capability-core.js
13
15
  ├─ extensions/
@@ -89,7 +91,7 @@ Manifest data never executes code. Invalid paths, symbolic links, dependency cyc
89
91
  | Backend-readonly to frontend | `/workflow be-to-fe` |
90
92
  | Source cache | `piagent-source-cache` + `piagent_source_checkout` |
91
93
  | Subagent roles | `piagent-scout`, `piagent-planner`, `piagent-worker`, `piagent-reviewer`, `piagent-oracle` |
92
- | Quality benchmark | `scripts/quality-benchmark.sh` |
94
+ | Quality benchmark | `scripts/benchmark-runner.mjs` + `benchmark/benchmark-core.js`; legacy recorder: `scripts/quality-benchmark.sh` |
93
95
  | Capability catalog | `packs/*/pack.json` + `catalog/capabilities.json` |
94
96
  | Capability resolver | `capability-core.js` + `piagent-capabilities` |
95
97
 
@@ -63,6 +63,10 @@ pi install /path/to/piagent
63
63
  - `1.2.8`: cài `pi-web-access@0.17.0` mặc định trong setup/update để researcher subagents có web/search/fetch thật; thêm `--no-web-access` cho máy không được phép browse.
64
64
  - `1.2.9`: hợp nhất Context Engine exclusion policy giữa CLI và runtime, resolve profile `extends`, loại `readOnlyPaths`, tự rebuild index khi policy digest đổi, chặn symlink source ra ngoài project, và làm rõ lỗi thiếu migrator trong update dry-run.
65
65
  - `1.2.10`: bắt buộc `contextIndexV2Status` nhận explicit exclusion policy; Context Engine storage chuyển sang owner-only, bật core + FTS5 secure-delete và tự retry FTS rebuild/VACUUM khi policy đổi để purge raw bytes của index cũ.
66
+ - `1.2.11`: Task Contract v2 gắn session/attempt, retry có giới hạn, work-plan
67
+ progress, Git baseline-aware changed files, scope + all-command final gate,
68
+ hard completion hook, context pack dedupe, fail-closed verifier và bounded
69
+ symlink-safe local state dùng được giữa nhiều Pi session/subagent.
66
70
 
67
71
  ## Không publish
68
72