@piagent/platform 1.5.5 → 1.6.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 (323) hide show
  1. package/CHANGELOG.md +166 -0
  2. package/README.md +25 -21
  3. package/README.vi.md +34 -5
  4. package/adapters/web-frontend/profile.json +2 -4
  5. package/architecture/layers.json +18 -3
  6. package/benchmarks/deep-logic-v1/SPECIALIST_PROTOCOL.vi.md +122 -0
  7. package/benchmarks/deep-logic-v1/grade.mjs +272 -10
  8. package/benchmarks/deep-logic-v1/project/apps/admin/src/billing-summary.js +3 -0
  9. package/benchmarks/deep-logic-v1/project/benchmark-contract/public-smoke.test.js +166 -0
  10. package/benchmarks/deep-logic-v1/project/package.json +1 -1
  11. package/benchmarks/deep-logic-v1/project/packages/billing/src/close-period.js +3 -0
  12. package/benchmarks/deep-logic-v1/project/packages/billing/src/plan-timeline.js +3 -0
  13. package/benchmarks/deep-logic-v1/project/test/smoke.test.js +7 -1
  14. package/benchmarks/deep-logic-v1/prompts/budgeted-context-graph.md +2 -0
  15. package/benchmarks/deep-logic-v1/prompts/fair-dependency-scheduler.md +2 -0
  16. package/benchmarks/deep-logic-v1/prompts/layered-policy-resolution.md +2 -0
  17. package/benchmarks/deep-logic-v1/prompts/resumable-stream-assembly.md +3 -1
  18. package/benchmarks/deep-logic-v1/prompts/revision-event-reconciliation.md +2 -0
  19. package/benchmarks/deep-logic-v1/prompts/temporal-usage-billing-close.md +123 -0
  20. package/benchmarks/deep-logic-v1/prompts/transactional-config-merge.md +2 -0
  21. package/benchmarks/deep-logic-v1/suite.json +51 -3
  22. package/benchmarks/deep-logic-v1/variant.mjs +22 -1
  23. package/benchmarks/production-v1/spend-control.v1.json +92 -0
  24. package/benchmarks/production-v1/suite.json +46 -3
  25. package/catalog/capabilities.json +18 -18
  26. package/docs/authority-manifest.md +1 -1
  27. package/docs/auto-delegation-policy.md +38 -73
  28. package/docs/command-reference-vietnamese.md +27 -35
  29. package/docs/context-engine.md +12 -4
  30. package/docs/context-window-policy.md +37 -1
  31. package/docs/distribution-standard.md +7 -7
  32. package/docs/en/architecture.md +27 -13
  33. package/docs/languages.json +4 -4
  34. package/docs/model-options.md +8 -5
  35. package/docs/operator-manual-vietnamese.md +27 -45
  36. package/docs/project-adapters.md +2 -2
  37. package/docs/publishing-for-teams.md +10 -0
  38. package/docs/quality-benchmark.md +427 -62
  39. package/docs/release-install-policy.md +10 -9
  40. package/docs/runtime-harness-standard.md +3 -3
  41. package/docs/runtime-policy-design.md +4 -4
  42. package/docs/runtime-quality-baseline.md +13 -6
  43. package/docs/security-threat-model.md +2 -2
  44. package/docs/subagent-orchestration-capabilities.md +19 -51
  45. package/docs/subagents-and-multiagent.md +21 -47
  46. package/docs/task-implementation-contract.md +3 -3
  47. package/docs/task-lifecycle-vietnamese.md +3 -3
  48. package/docs/team-onboarding.md +2 -2
  49. package/docs/usage-observability.md +7 -2
  50. package/docs/vi/architecture.md +27 -13
  51. package/docs-site/architecture.html +1 -1
  52. package/docs-site/benchmark.html +89 -95
  53. package/docs-site/commands.html +1 -1
  54. package/docs-site/content/benchmark.html +88 -94
  55. package/docs-site/content/en/benchmark.html +134 -90
  56. package/docs-site/content/en/index.html +19 -19
  57. package/docs-site/content/en/runtime.html +4 -4
  58. package/docs-site/content/en/whats-new.html +12 -1
  59. package/docs-site/content/en/workflows.html +2 -2
  60. package/docs-site/content/index.html +19 -19
  61. package/docs-site/content/runtime.html +4 -4
  62. package/docs-site/content/whats-new.html +12 -1
  63. package/docs-site/content/workflows.html +2 -2
  64. package/docs-site/context-engine.html +1 -1
  65. package/docs-site/en/architecture.html +1 -1
  66. package/docs-site/en/benchmark.html +135 -91
  67. package/docs-site/en/commands.html +1 -1
  68. package/docs-site/en/context-engine.html +1 -1
  69. package/docs-site/en/index.html +20 -20
  70. package/docs-site/en/mcp-approval.html +1 -1
  71. package/docs-site/en/mcp-auth.html +1 -1
  72. package/docs-site/en/mcp-servers.html +1 -1
  73. package/docs-site/en/mcp.html +1 -1
  74. package/docs-site/en/permissions.html +1 -1
  75. package/docs-site/en/profiles.html +1 -1
  76. package/docs-site/en/quickstart.html +1 -1
  77. package/docs-site/en/runtime.html +5 -5
  78. package/docs-site/en/scope.html +1 -1
  79. package/docs-site/en/security.html +1 -1
  80. package/docs-site/en/team.html +1 -1
  81. package/docs-site/en/whats-new.html +13 -2
  82. package/docs-site/en/workflows.html +3 -3
  83. package/docs-site/index.html +20 -20
  84. package/docs-site/mcp-approval.html +1 -1
  85. package/docs-site/mcp-auth.html +1 -1
  86. package/docs-site/mcp-servers.html +1 -1
  87. package/docs-site/mcp.html +1 -1
  88. package/docs-site/permissions.html +1 -1
  89. package/docs-site/profiles.html +1 -1
  90. package/docs-site/quickstart.html +1 -1
  91. package/docs-site/runtime.html +5 -5
  92. package/docs-site/scope.html +1 -1
  93. package/docs-site/security.html +1 -1
  94. package/docs-site/team.html +1 -1
  95. package/docs-site/whats-new.html +13 -2
  96. package/docs-site/workflows.html +3 -3
  97. package/evals/fixtures/benchmark-assurance-evidence.invalid.json +1 -1
  98. package/evals/fixtures/benchmark-assurance-evidence.valid.json +1 -1
  99. package/evals/fixtures/codex-relative-efficiency-v1.invalid.json +4 -0
  100. package/evals/fixtures/codex-relative-efficiency-v1.valid.json +94 -0
  101. package/evals/fixtures/helper-request.invalid.json +1 -1
  102. package/evals/fixtures/helper-request.valid.json +1 -1
  103. package/evals/fixtures/piagent-webui/session-live-state-v1.invalid.json +18 -0
  104. package/evals/fixtures/piagent-webui/session-live-state-v1.valid.json +27 -0
  105. package/evals/fixtures/piagent-webui/subagent-tree-v1.valid.json +7 -0
  106. package/evals/fixtures/task-authority-snapshot.valid.json +4 -4
  107. package/evals/fs4-readiness-matrix.v1.json +2 -2
  108. package/evals/fs5-causal-arm.v1.json +3 -3
  109. package/evals/fs5-pilot-protocol.v1.json +3 -3
  110. package/evals/fs5-pilot-protocol.v2.json +8 -8
  111. package/evals/fs5-pilot-protocol.v3.json +8 -8
  112. package/evals/fs5-pilot-protocol.v4.json +7 -6
  113. package/evals/fs5-pilot-protocol.v5.json +9 -7
  114. package/evals/private-holdout-v1/public-exposure.v1.json +1 -1
  115. package/evals/runtime-conformance-v1/README.md +43 -0
  116. package/evals/runtime-conformance-v1/evaluate-paid-canary.mjs +198 -0
  117. package/evals/runtime-conformance-v1/lane.json +57 -0
  118. package/evals/runtime-conformance-v1/paid-canary.json +31 -0
  119. package/evals/runtime-conformance-v1/runner.mjs +456 -0
  120. package/package.json +3 -1
  121. package/packages/piagent-core/README.md +13 -4
  122. package/packages/piagent-core/benchmark/benchmark-assurance.js +4 -1
  123. package/packages/piagent-core/benchmark/benchmark-bootstrap.js +91 -9
  124. package/packages/piagent-core/benchmark/benchmark-claim-restrictions.js +38 -7
  125. package/packages/piagent-core/benchmark/benchmark-cli.js +7 -7
  126. package/packages/piagent-core/benchmark/benchmark-codex-relative-efficiency.js +698 -0
  127. package/packages/piagent-core/benchmark/benchmark-codex.js +3 -1
  128. package/packages/piagent-core/benchmark/benchmark-comparison.js +271 -2
  129. package/packages/piagent-core/benchmark/benchmark-core.js +736 -664
  130. package/packages/piagent-core/benchmark/benchmark-execution-guard.js +7 -5
  131. package/packages/piagent-core/benchmark/benchmark-forensics.js +441 -4
  132. package/packages/piagent-core/benchmark/benchmark-host-readiness.js +639 -0
  133. package/packages/piagent-core/benchmark/benchmark-matrix.js +22 -4
  134. package/packages/piagent-core/benchmark/benchmark-normalized-cost.js +317 -0
  135. package/packages/piagent-core/benchmark/benchmark-preflight.js +5 -1
  136. package/packages/piagent-core/benchmark/benchmark-process.js +6 -5
  137. package/packages/piagent-core/benchmark/benchmark-provider-free-evidence.js +345 -0
  138. package/packages/piagent-core/benchmark/benchmark-provider-wire.js +126 -0
  139. package/packages/piagent-core/benchmark/benchmark-record-validation.js +252 -0
  140. package/packages/piagent-core/benchmark/benchmark-report.js +130 -12
  141. package/packages/piagent-core/benchmark/benchmark-resume-recovery.js +14 -0
  142. package/packages/piagent-core/benchmark/benchmark-runner-policy.js +26 -0
  143. package/packages/piagent-core/benchmark/benchmark-runtime-causal.js +244 -0
  144. package/packages/piagent-core/benchmark/benchmark-stage-diagnostic.js +979 -0
  145. package/packages/piagent-core/benchmark/benchmark-statistics.js +64 -0
  146. package/packages/piagent-core/benchmark/benchmark-stop-policy.js +8 -5
  147. package/packages/piagent-core/benchmark/benchmark-suite-identity.js +31 -0
  148. package/packages/piagent-core/benchmark/benchmark-suite-runtime.js +13 -9
  149. package/packages/piagent-core/benchmark/benchmark-suite.js +149 -2
  150. package/packages/piagent-core/benchmark/benchmark-summary-support.js +380 -0
  151. package/packages/piagent-core/benchmark/benchmark-timing-diagnostics.js +971 -0
  152. package/packages/piagent-core/benchmark/benchmark-usage.js +322 -0
  153. package/packages/piagent-core/benchmark/benchmark-workflow.js +166 -0
  154. package/packages/piagent-core/capabilities/runtime-integrity.js +3 -0
  155. package/packages/piagent-core/docs/context-efficiency-improvement-plan.md +1080 -0
  156. package/packages/piagent-core/extensions/acceptance-behavior-proof.js +806 -0
  157. package/packages/piagent-core/extensions/acceptance-contract-semantics.js +83 -69
  158. package/packages/piagent-core/extensions/acceptance-error-classes.js +160 -0
  159. package/packages/piagent-core/extensions/acceptance-executable-evidence.js +12 -9
  160. package/packages/piagent-core/extensions/acceptance-receipt.js +123 -59
  161. package/packages/piagent-core/extensions/acceptance-state-machine-evidence.js +518 -0
  162. package/packages/piagent-core/extensions/acceptance-test-binding-evidence.js +60 -0
  163. package/packages/piagent-core/extensions/context-efficiency-metrics.js +302 -0
  164. package/packages/piagent-core/extensions/context-efficiency-report.js +167 -0
  165. package/packages/piagent-core/extensions/context-engine.js +149 -156
  166. package/packages/piagent-core/extensions/context-evidence.js +48 -0
  167. package/packages/piagent-core/extensions/context-import-links.js +296 -0
  168. package/packages/piagent-core/extensions/context-index-policy.js +4 -0
  169. package/packages/piagent-core/extensions/context-query-paths.js +57 -0
  170. package/packages/piagent-core/extensions/context-telemetry-integrity.js +65 -0
  171. package/packages/piagent-core/extensions/criterion-context-pack.js +435 -7
  172. package/packages/piagent-core/extensions/criterion-graph.js +82 -9
  173. package/packages/piagent-core/extensions/fallback-base-policy.ts +101 -0
  174. package/packages/piagent-core/extensions/guard-types.ts +6 -0
  175. package/packages/piagent-core/extensions/javascript-regex-evidence.js +32 -0
  176. package/packages/piagent-core/extensions/piagent-guard.ts +420 -260
  177. package/packages/piagent-core/extensions/task-contract-view.js +17 -3
  178. package/packages/piagent-core/extensions/task-lifecycle.js +39 -2
  179. package/packages/piagent-core/extensions/task-state.js +109 -142
  180. package/packages/piagent-core/extensions/verification-intelligence.js +52 -13
  181. package/packages/piagent-core/extensions/workspace-evidence-roots.js +193 -0
  182. package/packages/piagent-core/package.json +1 -1
  183. package/packages/piagent-core/policies/base-policy.json +44 -2
  184. package/packages/piagent-core/policy/authority-manifest.v1.json +3 -3
  185. package/packages/piagent-core/prompts/be-to-fe.md +2 -8
  186. package/packages/piagent-core/prompts/plan.md +1 -1
  187. package/packages/piagent-core/prompts/platform-improve.md +2 -6
  188. package/packages/piagent-core/prompts/review.md +2 -7
  189. package/packages/piagent-core/prompts/scout.md +1 -1
  190. package/packages/piagent-core/prompts/task.md +4 -3
  191. package/packages/piagent-core/runtime/context/context-delivery.ts +103 -0
  192. package/packages/piagent-core/runtime/context/context-delta-shadow.ts +53 -0
  193. package/packages/piagent-core/runtime/context/context-efficiency-format.ts +47 -0
  194. package/packages/piagent-core/runtime/context/context-evidence-qualification.ts +32 -0
  195. package/packages/piagent-core/runtime/context/prefix-telemetry.ts +47 -0
  196. package/packages/piagent-core/runtime/context/repository-memory-hints.ts +27 -0
  197. package/packages/piagent-core/runtime/hooks/agent-prompt-telemetry.ts +56 -0
  198. package/packages/piagent-core/runtime/hooks/agent-start-hook.ts +162 -102
  199. package/packages/piagent-core/runtime/hooks/completion-hook.ts +12 -12
  200. package/packages/piagent-core/runtime/hooks/input-hook.ts +17 -1
  201. package/packages/piagent-core/runtime/hooks/session-hooks.ts +22 -2
  202. package/packages/piagent-core/runtime/hooks/session-start-hook.ts +107 -3
  203. package/packages/piagent-core/runtime/hooks/tool-result-content-guards.ts +95 -0
  204. package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +134 -166
  205. package/packages/piagent-core/runtime/hooks/tool-result-value-helpers.ts +66 -0
  206. package/packages/piagent-core/runtime/inspection/activity-event-adapter.ts +4 -2
  207. package/packages/piagent-core/runtime/inspection/activity-recovery.ts +104 -0
  208. package/packages/piagent-core/runtime/inspection/bounded-emission-guard.ts +286 -0
  209. package/packages/piagent-core/runtime/inspection/runtime-event-store.ts +37 -7
  210. package/packages/piagent-core/runtime/inspection/task-compaction-history.ts +1 -1
  211. package/packages/piagent-core/runtime/inspection/task-handoff-history.ts +1 -1
  212. package/packages/piagent-core/runtime/inspection/task-subagent-tree.ts +27 -4
  213. package/packages/piagent-core/runtime/inspection/tool-failure-classification.ts +70 -0
  214. package/packages/piagent-core/runtime/inspection/webui-snapshot.ts +73 -9
  215. package/packages/piagent-core/runtime/model/authenticated-catalog.ts +17 -9
  216. package/packages/piagent-core/runtime/model/openai-codex-reasoning.ts +83 -0
  217. package/packages/piagent-core/runtime/model/provider-wire-fingerprint.ts +238 -0
  218. package/packages/piagent-core/runtime/orchestration/helper-lifecycle.ts +16 -12
  219. package/packages/piagent-core/runtime/orchestration/minimal-delegation-policy.ts +71 -0
  220. package/packages/piagent-core/runtime/orchestration/owned-work-budget.ts +28 -20
  221. package/packages/piagent-core/runtime/orchestration/role-policy.ts +27 -9
  222. package/packages/piagent-core/runtime/orchestration/subagent-tool-policy.ts +329 -0
  223. package/packages/piagent-core/runtime/policy/block-remedy.ts +0 -4
  224. package/packages/piagent-core/runtime/product/activity-inspector.ts +7 -2
  225. package/packages/piagent-core/runtime/product/efficiency-metrics.ts +7 -2
  226. package/packages/piagent-core/runtime/quality/edit-freshness-guard.ts +102 -0
  227. package/packages/piagent-core/runtime/quality/exact-output-contract.ts +22 -11
  228. package/packages/piagent-core/runtime/quality/performance-assurance-signals.ts +23 -0
  229. package/packages/piagent-core/runtime/quality/performance-assurance.ts +9 -5
  230. package/packages/piagent-core/runtime/recovery/continuation-budget.ts +1 -1
  231. package/packages/piagent-core/runtime/recovery/edit-recovery-context.ts +113 -0
  232. package/packages/piagent-core/runtime/recovery/edit-recovery-delivery.ts +42 -0
  233. package/packages/piagent-core/runtime/recovery/handoff-projection.ts +4 -1
  234. package/packages/piagent-core/runtime/recovery/pristine-task-policy-refresh.ts +91 -0
  235. package/packages/piagent-core/runtime/recovery/recovery-policy.ts +7 -4
  236. package/packages/piagent-core/runtime/recovery/resume-state.ts +112 -14
  237. package/packages/piagent-core/runtime/recovery/semantic-repair-handshake.ts +60 -13
  238. package/packages/piagent-core/runtime/recovery/semantic-repair-runtime.ts +55 -2
  239. package/packages/piagent-core/runtime/recovery/task-evidence-coverage-refresh.ts +217 -0
  240. package/packages/piagent-core/runtime/registration/context-commands.ts +82 -7
  241. package/packages/piagent-core/runtime/registration/knowledge-tools.ts +9 -5
  242. package/packages/piagent-core/runtime/registration/operator-request-intake.ts +49 -0
  243. package/packages/piagent-core/runtime/registration/policy-tools.ts +50 -15
  244. package/packages/piagent-core/runtime/registration/session-commands.ts +1 -1
  245. package/packages/piagent-core/runtime/registration/task-completion-tools.ts +61 -25
  246. package/packages/piagent-core/runtime/registration/task-evidence-tools.ts +21 -12
  247. package/packages/piagent-core/runtime/registration/task-start-guidance.ts +169 -0
  248. package/packages/piagent-core/runtime/registration/task-start-manifest.ts +54 -0
  249. package/packages/piagent-core/runtime/registration/task-start-retry-helpers.ts +37 -0
  250. package/packages/piagent-core/runtime/registration/task-start-tool.ts +108 -103
  251. package/packages/piagent-core/runtime/runtime-limits.ts +16 -2
  252. package/packages/piagent-core/runtime/session/adaptive-context-analysis.ts +461 -0
  253. package/packages/piagent-core/runtime/session/adaptive-context-governor.ts +464 -0
  254. package/packages/piagent-core/runtime/session/adaptive-context-ledger.ts +265 -0
  255. package/packages/piagent-core/runtime/session/message-signals.ts +7 -3
  256. package/packages/piagent-core/runtime/session/operator-request-carry.ts +44 -0
  257. package/packages/piagent-core/runtime/session/runtime-state.ts +161 -5
  258. package/packages/piagent-core/runtime/session/source-checkout-read-grants.ts +35 -0
  259. package/packages/piagent-core/runtime/session/system-prompt.ts +76 -14
  260. package/packages/piagent-core/runtime/session/task-contract-presentation.ts +39 -0
  261. package/packages/piagent-core/runtime/tools/apply-patch-tool.ts +500 -0
  262. package/packages/piagent-core/runtime/tools/phase-tools.ts +8 -8
  263. package/packages/piagent-core/runtime/tools/tool-groups.ts +12 -2
  264. package/packages/piagent-core/runtime/trajectory/trajectory-runtime.ts +2 -1
  265. package/packages/piagent-core/runtime/verification/exact-verifier-reuse.ts +101 -0
  266. package/packages/piagent-core/runtime/workflows/runtime-intake-compaction.ts +164 -0
  267. package/packages/piagent-core/runtime/workflows/task-intake.ts +207 -38
  268. package/packages/piagent-core/security/sensitive-data.js +13 -218
  269. package/packages/piagent-core/security/sensitive-project-file.js +42 -0
  270. package/packages/piagent-core/security/sensitive-source-expression.js +330 -0
  271. package/packages/piagent-core/security/sensitive-source-formats.js +394 -0
  272. package/packages/piagent-core/security/sensitive-text.js +234 -0
  273. package/packages/piagent-core/subagents/piagent-oracle.md +5 -3
  274. package/packages/piagent-core/subagents/piagent-planner.md +6 -4
  275. package/packages/piagent-core/subagents/piagent-reviewer.md +5 -3
  276. package/packages/piagent-core/subagents/piagent-scout.md +4 -2
  277. package/packages/piagent-core/subagents/piagent-worker.md +7 -5
  278. package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-rD9WJKxs.js → MarkdownMessage-B4XehTCU.js} +1 -1
  279. package/packages/piagent-webui/dist/client/assets/index-CgOEyRPG.js +176 -0
  280. package/packages/piagent-webui/dist/client/index.html +1 -1
  281. package/packages/piagent-webui/extension/piagent-webui.ts +3 -1
  282. package/packages/piagent-webui/extension/same-session-bridge.ts +1 -1
  283. package/packages/piagent-webui/extension/session-stream-adapter.ts +33 -10
  284. package/packages/piagent-webui/gateway/gateway-events.ts +109 -5
  285. package/packages/piagent-webui/gateway/gateway-service.ts +3 -0
  286. package/packages/piagent-webui/gateway/gateway-session-stream.ts +122 -20
  287. package/packages/piagent-webui/gateway/session-command-controller.ts +18 -3
  288. package/packages/piagent-webui/gateway/session-effective-options.ts +47 -0
  289. package/packages/piagent-webui/gateway/session-live-state.ts +21 -0
  290. package/packages/piagent-webui/gateway/session-operation-lifecycle.ts +237 -0
  291. package/packages/piagent-webui/gateway/session-operation-retry-control.ts +38 -0
  292. package/packages/piagent-webui/gateway/session-operation-start.ts +5 -1
  293. package/packages/piagent-webui/gateway/session-operation-watchdog.ts +165 -0
  294. package/packages/piagent-webui/gateway/session-runtime-factory.ts +45 -0
  295. package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +141 -125
  296. package/packages/piagent-webui/ownership/session-lease-store.ts +5 -2
  297. package/packages/piagent-webui/server/core-inspection-provider.ts +2 -1
  298. package/packages/piagent-webui/server/loopback-server.ts +8 -0
  299. package/packages/piagent-webui/server/transcript-projection.ts +113 -9
  300. package/packages/piagent-webui/shared/text-visibility.ts +10 -0
  301. package/schemas/codex-relative-efficiency-v1.schema.json +155 -0
  302. package/schemas/piagent-webui/catalog-v1.json +9 -0
  303. package/schemas/piagent-webui/gateway-protocol-v1.schema.json +53 -3
  304. package/schemas/piagent-webui/runtime-event-v2.schema.json +15 -5
  305. package/schemas/piagent-webui/session-live-state-v1.schema.json +76 -0
  306. package/schemas/piagent-webui/subagent-tree-v1.schema.json +11 -1
  307. package/schemas/project-profile.schema.json +1 -1
  308. package/schemas/task-contract.schema.json +27 -1
  309. package/scripts/benchmark-runner-core.mjs +367 -363
  310. package/scripts/benchmark-runner-finalization.mjs +313 -0
  311. package/scripts/benchmark-runner-host-readiness.mjs +94 -0
  312. package/scripts/benchmark-runner-support.mjs +200 -0
  313. package/scripts/benchmark-session.mjs +95 -41
  314. package/scripts/configure-model-scope.sh +4 -3
  315. package/scripts/configure-subagents.sh +42 -34
  316. package/scripts/helper-evaluation.mjs +2 -2
  317. package/scripts/install-global.sh +2 -2
  318. package/scripts/pi-usage-history.mjs +37 -10
  319. package/scripts/setup.sh +2 -2
  320. package/scripts/team-doctor.sh +1 -1
  321. package/scripts/verify-local.sh +10 -1
  322. package/templates/global/settings.json +2 -1
  323. package/packages/piagent-webui/dist/client/assets/index-BZRFw1u6.js +0 -174
@@ -1,7 +1,7 @@
1
1
  # Solo-first orchestration policy
2
2
  <!-- language: vi; english-index: docs-site/content/en/workflows.html -->
3
3
 
4
- Mục tiêu: user không phải nhớ `/run`, `/parallel`, `/chain` cho workflow hằng ngày, nhưng platform cũng không tự biến mọi task thành swarm tốn token. Khi anh gõ `/workflow task`, `/workflow be-to-fe`, `/workflow platform-improve`, `/workflow plan`, hoặc `/workflow review`, parent agent đọc `piagent_orchestration_policy`, giữ mặc định **solo-first**, rồi chỉ dùng subagents nếu việc đó giúp giảm nhiễu context, tăng tốc read-heavy work, hoặc tăng chất lượng review. Alias cũ như `/task` vẫn giữ cùng policy.
4
+ Mục tiêu: parent model tự làm trọn task với đầy đủ năng lực. Helper không còn là phase mặc định để scout/plan/review; nó chỉ là một tối ưu token ngoại lệ. Piagent chỉ cho tối đa **một helper read-only, context fresh** khi runtime chứng minh có ít nhất hai lane độc lập và tổng token dự kiến sau handoff/merge giảm tối thiểu **30%**. Alias cũ như `/task` giữ cùng policy.
5
5
 
6
6
  Kiểm tra policy hiện tại trong Pi:
7
7
 
@@ -15,11 +15,11 @@ Slash command này chỉ hiện status compact, không gửi follow-up cho model
15
15
 
16
16
  Subagent không nên hiểu là “luôn tự sinh khi task lớn”. Hành vi đúng là:
17
17
 
18
- 1. Parent agent đánh giá task có phần việc độc lập không.
19
- 2. Nếu có và `pi-subagents`/subagent tool khả dụng, parent có thể tự spawn subagent.
20
- 3. Nếu không có tool/package, parent tiếp tục single-agent và ghi rõ `Subagents: unavailable/not used`.
21
- 4. User vẫn có thể gọi command trực tiếp khi muốn ép orchestration cụ thể.
22
- 5. Parallel read-only có thể dùng cho scout/review; parallel writers không phải default và cần approval + isolation.
18
+ 1. Parent làm trực tiếp nếu runtime chưa có bằng chứng định lượng.
19
+ 2. Helper chỉ đủ điều kiện khi có ít nhất hai workstream độc lập, helper không chờ output tiếp theo của parent, context transfer không quá 2.048 token, không inherit transcript, và tổng dự kiến tiết kiệm ít nhất 30%.
20
+ 3. Mỗi task run chỉ có một lần thử helper. Lỗi runtime/scope xác định không được relaunch.
21
+ 4. Helper luôn read-only; worker/writer helper bị tắt. Parent giữ toàn bộ mutation và quyết định.
22
+ 5. UI/telemetry phải ghi `dispatch` hoặc `skip`, reason codes, và projected net saving; không có số liệu thì `skip`.
23
23
 
24
24
  Nếu bundled skill `pi-subagents` có trong skill list của parent, parent nên dùng skill đó cho orchestration patterns thay vì tự đoán syntax. Skill này là parent-only; child subagents không nhận nó.
25
25
 
@@ -28,43 +28,45 @@ Nếu bundled skill `pi-subagents` có trong skill list của parent, parent nê
28
28
  | Setting | Default |
29
29
  |---|---|
30
30
  | Mode | `solo-first` |
31
- | Max concurrent subagents | `2` |
31
+ | Helper budget | `1` read-only total; concurrent `1`; retry `0`; worker `0` |
32
+ | Minimum projected net saving | `30%` |
33
+ | Context transfer | fresh/isolated; tối đa `2.048` token; không inherit parent history |
32
34
  | Review lenses | `correctness`, `tests`, `scope` |
33
35
  | Field Guide | `.pi/memory/MEMORY.md`, advisory, explicit-write only |
34
- | Writer policy | Một writer cho một write set. |
36
+ | Writer policy | Parent model là writer duy nhất. |
35
37
 
36
38
  Model role guidance:
37
39
 
38
40
  - planner: model mạnh nhất hợp lý cho decomposition, architecture, risk, acceptance criteria;
39
- - worker: model nhanh/ổn định cho bounded implementation đã có plan;
40
- - reviewer: model/thinking decorrelated với worker khi review quan trọng;
41
- - watchdog/oracle: model mạnh chỉ cho final risk/security/release/high-impact.
41
+ - worker: disabled; parent model implement trực tiếp;
42
+ - reviewer/oracle: role read-only ngoại lệ; không tự chạy chỉ vì review quan trọng;
43
+ - builtin agents và watchdog: disabled trong baseline Piagent.
42
44
 
43
45
  ## Khi nào parent nên tự spawn
44
46
 
45
- Parent nên tự spawn subagents khi có ít nhất một điều kiện:
47
+ Chỉ spawn khi **đồng thời** thỏa tất cả điều kiện:
46
48
 
47
- - cần scout nhiều vùng source độc lập;
48
- - cần map BE contract read-only trong khi FE implementation là write target;
49
- - cần đọc external source docs/repo và repo hiện tại song song;
50
- - cần external research có nguồn dẫn, và `pi-web-access`/web tools đang available;
51
- - cần tạo context handoff trước task lớn (`context-builder`);
52
- - cần review nhiều góc độc lập: correctness, tests, security, scope drift;
53
- - task có từ 3 touchpoint trở lên;
54
- - task medium/high-risk nhưng có phần audit read-only trước khi edit;
55
- - context có nguy cơ phình to nếu parent tự đọc toàn bộ log/spec/source.
49
+ - runtime xác định ít nhất hai workstream thật sự độc lập;
50
+ - helper có thể hoàn tất mà không chờ output tiếp theo của parent;
51
+ - helper chỉ cần read/grep/find/ls;
52
+ - request dùng fresh isolated context, seed không quá 2.048 token;
53
+ - estimate gồm parent + helper + transfer + merge thấp hơn solo ít nhất 30%;
54
+ - task run chưa từng launch helper và không retry một lỗi runtime/scope xác định.
56
55
 
57
56
  ## Khi nào không nên tự spawn
58
57
 
59
58
  Không spawn nếu:
60
59
 
61
60
  - task nhỏ, một file, verify đơn giản;
61
+ - không có runtime estimate hoặc projected saving dưới 30%;
62
62
  - requirement chưa rõ và cần hỏi user trước;
63
63
  - chỉ có một write target nhỏ;
64
64
  - subagent tool/package chưa available;
65
65
  - repo dirty hoặc write set có nguy cơ overlap mà chưa phân tách được;
66
66
  - task high-risk cần human gate trước khi edit;
67
- - muốn spawn nhiều writer song song nhưng không có worktree isolation/approval.
67
+ - cần bất kỳ mutation nào từ child;
68
+ - muốn planner/reviewer chỉ để “tăng chất lượng” nhưng không giảm tổng token;
69
+ - đã có một helper attempt, kể cả attempt failed/orphaned.
68
70
 
69
71
  ## Default agent mapping
70
72
 
@@ -72,13 +74,10 @@ Không spawn nếu:
72
74
  |---|---|---|
73
75
  | Map unfamiliar repo/module/spec | `piagent-scout` | read-only |
74
76
  | Build implementation plan | `piagent-planner` | read-only |
75
- | Implement approved bounded change | `piagent-worker` | single writer |
76
77
  | Review current diff | `piagent-reviewer` | review-first |
77
78
  | Challenge architecture/risk | `piagent-oracle` | read-only |
78
- | External docs/web research | builtin `researcher` | read-only; requires web tools |
79
- | Large context handoff | builtin `context-builder` or `piagent-scout` | writes handoff artifact only |
80
79
 
81
- Default rule: parallel read-only is OK; parallel writers are not default.
80
+ Default rule: parent direct. Tối đa một role read-only ở bảng trên; không parallel và không worker.
82
81
 
83
82
  ## Workflow policy
84
83
 
@@ -89,42 +88,26 @@ Parent should:
89
88
  1. load piagent context/profile/memory/project context;
90
89
  2. load `piagent_orchestration_policy`;
91
90
  3. create a compact task tree/workPlan and review lenses in `piagent_task_start`;
92
- 4. decide whether subagents are useful enough to justify extra token cost;
93
- 5. if useful, spawn bounded read-only scout/planner/reviewer before or after implementation;
94
- 6. keep implementation single-writer unless user explicitly approves otherwise;
91
+ 4. runtime tính projected total tokens; thiếu estimate hoặc saving dưới 30% thì skip;
92
+ 5. nếu đủ điều kiện, spawn đúng một helper fresh/read-only;
93
+ 6. parent tự implement và review;
95
94
  7. summarize subagent outputs into task contract/context manifest/final response.
96
95
 
97
96
  ### `/workflow be-to-fe`
98
97
 
99
- Recommended auto-delegation:
100
-
101
- - `piagent-scout`: map backend contract read-only;
102
- - `piagent-scout`: map frontend touchpoints read-only;
103
- - `piagent-planner`: produce FE implementation plan;
104
- - parent or `piagent-worker`: implement FE only;
105
- - `piagent-reviewer`: review diff and verify coverage.
98
+ Parent map BE contract, map FE touchpoints, implement và review. Runtime chỉ được chọn **một** trong hai lane mapping cho `piagent-scout` nếu estimate toàn task đạt ngưỡng 30%; lane còn lại vẫn do parent làm.
106
99
 
107
100
  ### `/workflow platform-improve`
108
101
 
109
- Recommended auto-delegation:
110
-
111
- - `piagent-scout`: inspect current platform source/docs;
112
- - builtin `researcher`: inspect official docs/web evidence when `pi-web-access` is installed;
113
- - builtin `context-builder`: create handoff context/meta-prompt for large platform changes;
114
- - `piagent-scout`: inspect official docs/external source repo targeted evidence;
115
- - `piagent-planner`: produce implementation matrix;
116
- - parent or `piagent-worker`: implement bounded changes;
117
- - `piagent-reviewer`: review docs/runtime behavior.
102
+ Parent inspect, research, plan, implement và review. Một fresh read-only helper chỉ được map một lane độc lập khi runtime estimate tổng token đạt ngưỡng; không dùng chain scout → planner → worker → reviewer.
118
103
 
119
104
  ### `/review`
120
105
 
121
- Recommended auto-delegation:
106
+ Parent-owned review:
122
107
 
123
108
  - select explicit review lenses first;
124
- - optional parallel `piagent-reviewer` for correctness;
125
- - optional parallel `piagent-reviewer` for tests/verification;
126
- - optional parallel `piagent-reviewer` for scope/protected-path drift;
127
- - optional `piagent-oracle` for architecture/high-risk concerns.
109
+ - parent cover các lens trong cùng context;
110
+ - chỉ dùng một fresh read-only reviewer/oracle nếu nó thay thế một lane độc lập và estimate tiết kiệm ít nhất 30%.
128
111
 
129
112
  If the user explicitly asks for a review loop, use `/review-loop` or an equivalent parent-controlled loop with max rounds. Do not blindly apply all reviewer suggestions.
130
113
 
@@ -136,17 +119,7 @@ Single scout:
136
119
  Use piagent-scout to map the target module read-only. Return files, ownership, invariants, and likely change points only.
137
120
  ```
138
121
 
139
- Parallel scout:
140
-
141
- ```text
142
- Run parallel piagent-scout agents: one maps backend contract read-only, one maps frontend touchpoints read-only. Wait for both and summarize the contract-to-FE map.
143
- ```
144
-
145
- Parallel review:
146
-
147
- ```text
148
- Run parallel piagent-reviewer agents for correctness, tests/verification, and scope/protected-path drift. Wait for all and summarize findings by severity.
149
- ```
122
+ The parent must attach runtime evidence equivalent to: `independent lanes >= 2`, `context=fresh`, `inheritedParentTokens=0`, and `projectedNetSaving>=30%`. Without it, do not call the helper tool.
150
123
 
151
124
  Tool syntax fallback:
152
125
 
@@ -159,7 +132,7 @@ subagent({ agent: "piagent-scout", task: "Map target area read-only. Return conc
159
132
  Final response should include one line:
160
133
 
161
134
  ```text
162
- Subagents: <not used / unavailable / used: piagent-scout, piagent-reviewer>
135
+ Helper: <skip reason=<code> projectedSaving=<unknown|N%> / dispatch role=<role> projectedSaving=N%>
163
136
  ```
164
137
 
165
138
  If not used, give the reason briefly:
@@ -172,19 +145,11 @@ If not used, give the reason briefly:
172
145
 
173
146
  ## Token rule
174
147
 
175
- Subagents can reduce parent context pollution, but total token usage can increase because each child does its own model/tool work. Use them for parallelizable read-heavy work and review quality, not as a blanket token-saving switch.
148
+ Projected saving phải so sánh **tổng parent + child + handoff + merge**, không so child với một đoạn parent context riêng lẻ. Ngưỡng 30% là dispatch gate, không phải bằng chứng rằng Piagent đã rẻ hơn `codex-cli` 30–40%; kết luận đó chỉ được đưa ra từ paired benchmark Piagent/`codex-cli` cùng model, thinking, task và success gate.
176
149
 
177
- ## Package shortcuts worth using
150
+ ## Package shortcuts
178
151
 
179
- | Shortcut | Use when |
180
- |---|---|
181
- | `/parallel-review` | Need distinct review angles; add `autofix` only when user permits fixes. |
182
- | `/review-loop` | Need worker/reviewer/fix loop until clean or capped. |
183
- | `/parallel-research` | Need external evidence + local code context. |
184
- | `/parallel-context-build` | Need context/meta-prompt handoff before a large plan. |
185
- | `/parallel-handoff-plan` | Need research + context-builder + implementation handoff. |
186
- | `/gather-context-and-clarify` | Need scout/research first, then ask only meaningful questions. |
187
- | `/parallel-cleanup` | Need post-implementation cleanup review. |
152
+ Các shortcut `/parallel-*`, worker/reviewer loop và grant-spawn-budget thuộc package upstream nhưng không nằm trong Piagent governed default. Absolute Piagent budget vẫn là một read-only helper total; daily workflow không dùng các shortcut này.
188
153
 
189
154
  See `docs/subagent-orchestration-capabilities.md`.
190
155
 
@@ -325,7 +325,7 @@ Các command này thuộc Pi core hoặc package Pi chính. Tên/availability c
325
325
 
326
326
  Các command này đến từ package `pi-subagents`. Tên hơi “package terminology”, nên bảng dưới dịch ra nghĩa thực tế.
327
327
 
328
- Quan trọng: daily flow không bắt anh phải nhớ các lệnh này. Các workflow `/workflow task`, `/workflow be-to-fe`, `/workflow platform-improve`, `/workflow plan`, `/workflow review` dùng solo-first orchestration: parent agent lập task tree/review lenses trước, rồi chỉ spawn subagent khi task có phần việc độc lập và đáng token. Slash command dưới đây dùng khi anh muốn ép orchestration cụ thể hoặc debug.
328
+ Quan trọng: Piagent mặc định parent-direct và helpers `off`. Các lệnh dưới đây phần lớn là capability upstream để inspect/debug. Piagent config chặn builtin, worker, parallel, nested và retry; operator chỉ có thể opt-in một helper read-only context fresh, và runtime vẫn yêu cầu hai lane độc lập cùng projected net saving từ 30%.
329
329
 
330
330
  | Command | Dịch nghĩa dễ hiểu | Dùng khi nào | Kết quả mong đợi |
331
331
  |---|---|---|---|
@@ -342,16 +342,10 @@ Quan trọng: daily flow không bắt anh phải nhớ các lệnh này. Các wo
342
342
  | `/subagents-generate-profiles <provider>` | Sinh quota/quality profiles | Khi muốn profile model theo quota/chất lượng. | Tạo profile cho provider. |
343
343
  | `/subagents-check-profile <name>` | Check profile | Khi profile/model có thể stale. | Re-check model availability/auth. |
344
344
  | `/run <agent> "<task>"` | Chạy 1 subagent | Khi cần 1 scout/reviewer/planner riêng context. | Child session chạy task rồi trả summary về parent. |
345
- | `/run <agent> "<task>" --bg` | Chạy background | Khi muốn agent chạy nền rồi mình xem sau. | Dùng `/subagents-fleet` để follow. |
346
- | `/run <agent> "<task>" --fork` | Chạy từ forked session | Khi child cần inherited conversation/context branch. | Fork thật từ parent leaf; dùng fresh nếu không cần history. |
347
- | `/parallel ...` | Chạy nhiều agent song song | Khi các việc độc lập, nhất là read-only review/scout/test analysis. | Parent đợi hoặc gom kết quả tùy flow. |
348
- | `/chain ...` | Chạy tuần tự | Khi output agent trước là input agent sau. | Dùng `{previous}` để truyền summary trước đó. |
349
- | `/run-chain <name>` | Chạy chain đã lưu | Khi có workflow lặp lại. | Package chạy recipe chain đã định nghĩa. |
350
- | `/parallel-review` | Review song song | Khi cần nhiều reviewer theo góc nhìn độc lập. | Có thể thêm `autofix` nếu đã cho phép sửa. |
351
- | `/review-loop` | Worker/reviewer/fix loop | Khi muốn review đến khi sạch hoặc hết vòng. | Nên set max rounds, thường dùng tối đa 3 vòng. |
352
- | `/parallel-research` | Research song song | Khi cần external evidence + local scout. | Builtin `researcher` cần `pi-web-access`. |
353
- | `/parallel-context-build` | Build context handoff | Khi task lớn cần `context.md`/meta-prompt trước planning. | Dùng `context-builder` agents. |
354
- | `/parallel-handoff-plan` | Research + context + plan | Khi muốn handoff plan đầy đủ cho implementation. | Tốt cho architecture hoặc platform change lớn. |
345
+ | `/run <agent> "<task>" --bg` | Capability upstream | Piagent không bật async mặc định. | Không dùng trong governed default. |
346
+ | `/run <agent> "<task>" --fork` | Capability upstream | Inherit history trái policy context fresh. | Piagent từ chối. |
347
+ | `/parallel ...`, `/chain ...`, `/run-chain ...` | Capability upstream | Nhân số turn/context. | Piagent config giới hạn 1 và không dispatch parallel/chain. |
348
+ | `/parallel-review`, `/review-loop`, `/parallel-research`, `/parallel-context-build`, `/parallel-handoff-plan` | Capability upstream | Tạo nhiều helper hoặc retry loop. | Piagent config không cho dùng. |
355
349
  | `/gather-context-and-clarify` | Scout rồi hỏi đúng câu | Khi requirement chưa rõ nhưng cần đọc trước. | Trả clarification questions có evidence. |
356
350
  | `/parallel-cleanup` | Cleanup review sau implement | Khi muốn rà cleanup đáng làm. | Có thể thêm `autofix`. |
357
351
 
@@ -364,7 +358,7 @@ Glossary:
364
358
  | `fleet` | “Đội” child sessions đang chạy hoặc vừa chạy xong. |
365
359
  | `scout` | Agent đọc/map code read-only. |
366
360
  | `planner` | Agent lập plan và verify gate, không sửa code. |
367
- | `worker` | Agent sửa code theo plan. |
361
+ | `worker` | Metadata compatibility; bị Piagent disable. |
368
362
  | `reviewer` | Agent review diff/test/scope. |
369
363
  | `oracle` | Agent phản biện/risk challenge. |
370
364
  | `researcher` | Builtin agent nghiên cứu web/docs có nguồn; cần `pi-web-access`. |
@@ -372,7 +366,7 @@ Glossary:
372
366
  | `chain` | Làm A rồi dùng kết quả A để làm B. |
373
367
  | `parallel` | Làm nhiều nhánh độc lập cùng lúc. |
374
368
  | `bg` | Background run, không block parent ngay. |
375
- | `fork` | Child bắt đầu từ nhánh session hiện tại thay vì context fresh. |
369
+ | `fork` | Capability upstream; Piagent cấm vì helper phải context fresh. |
376
370
  | `watchdog` | Opt-in adversarial reviewer ở cuối turn; không phải `reviewer` subagent. |
377
371
  | `worktree` | Checkout riêng cho parallel writers để tránh đè file nhau. |
378
372
 
@@ -382,7 +376,7 @@ Piagent subagents:
382
376
  |---|---|---|
383
377
  | `piagent-scout` | Map repo/module/spec trước khi sửa. | Read-only. |
384
378
  | `piagent-planner` | Lập implementation plan. | Read-only. |
385
- | `piagent-worker` | Implement task đã rõ/đã approve. | Có thể write trong scope. |
379
+ | `piagent-worker` | Compatibility metadata; bị Piagent config disable. | Không dispatch. |
386
380
  | `piagent-reviewer` | Review diff, verify coverage, scope drift. | Review-first. |
387
381
  | `piagent-oracle` | Challenge architecture/risk. | Read-only. |
388
382
 
@@ -416,24 +410,21 @@ Một số option hữu ích:
416
410
  ```text
417
411
  /run reviewer[model=anthropic/claude-sonnet-5:high] "Review this diff"
418
412
  /run scout[output=context.md,outputMode=file-only] "Map auth flow"
419
- /chain scout[output=context.md,as=context] "Scan" -> planner[reads=context.md] "Plan from {outputs.context}"
420
413
  subagent({ action: "status", view: "fleet" })
421
414
  subagent({ action: "status", id: "<run-id>", view: "transcript", lines: 120 })
422
- subagent({ action: "grant-spawn-budget", additional: 10 })
423
415
  ```
424
416
 
425
417
  `outputMode=file-only` hữu ích khi child tạo report dài: parent chỉ nhận đường dẫn file, không bị nhồi full report vào context.
426
418
 
427
419
  ## Khi nào nên spawn subagent
428
420
 
429
- Theo provider docs, subagent tốt nhất cho việc độc lập và bounded:
421
+ Trong Piagent, helper chỉ được dispatch khi tất cả điều kiện sau đúng:
430
422
 
431
- - codebase exploration;
432
- - map contract/API/schema;
433
- - đọc docs/spec dài rồi tóm tắt;
434
- - review correctness/security/tests/scope drift theo nhiều góc nhìn;
435
- - chạy/test analysis không cần sửa cùng file;
436
- - compress context trước khi parent/worker implement.
423
+ - operator đã bật `PIAGENT_HELPERS_MODE=on`;
424
+ - runtime chứng minh ít nhất hai lane độc lập;
425
+ - helper không cần chờ output tiếp theo của parent;
426
+ - handoff context fresh, không inherit history, tối đa 2.048 token;
427
+ - projected tổng token sau cả handoff/merge tiết kiệm ít nhất 30%.
437
428
 
438
429
  Không nên spawn bừa khi:
439
430
 
@@ -446,11 +437,11 @@ Không nên spawn bừa khi:
446
437
  Default của platform là an toàn:
447
438
 
448
439
  - `maxSubagentDepth: 1`: parent spawn child, child không fan-out tiếp.
449
- - `parallel.concurrency: 3`: không mở quá nhiều child cùng lúc.
440
+ - `parallel.concurrency: 1`: compatibility ceiling, không chạy song song.
450
441
  - `asyncByDefault: false`: không tự chạy background nếu anh không yêu cầu.
451
- - Một `piagent-worker` tại một thời điểm; parallel chủ yếu dùng cho scout/reviewer.
442
+ - Tổng 1 read-only helper, 0 worker, 0 retry.
452
443
 
453
- Nếu anh không gọi gì thêm, `/workflow task` vẫn chạy solo-first và chỉ tự dùng subagent theo `docs/auto-delegation-policy.md` khi có scout/planning/review độc lập đáng làm. Alias `/task` giữ cùng policy.
444
+ Nếu anh không bật gì thêm, `/workflow task` chạy parent-direct và không tạo model turn phụ. Alias `/task` giữ cùng policy.
454
445
 
455
446
  ## Prompt mẫu cho bài toán thật
456
447
 
@@ -480,7 +471,7 @@ Use piagent-reviewer before final.
480
471
  Nếu muốn parallel read-only:
481
472
 
482
473
  ```text
483
- Run parallel piagent-scout agents: one maps backend contract read-only, one maps frontend route/state usage. Wait for both, then plan FE implementation.
474
+ Keep the parent direct. If helper mode was explicitly enabled and the runtime proves at least 30% net saving, run one fresh read-only piagent-scout for the single highest-value independent lane.
484
475
  ```
485
476
 
486
477
  ### Review trước khi ship
@@ -502,8 +493,8 @@ Các lệnh này chạy ngoài Pi.
502
493
  | Command | Dùng khi nào |
503
494
  |---|---|
504
495
  | `npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.84.1` | Cài Pi CLI tương thích với release hiện tại. |
505
- | `npm install -g --ignore-scripts @piagent/platform@1.5.5` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
506
- | `pi install git:github.com/Vt-mmm/piagent@v1.5.5` | Cài pinned release khi cần reproducible team setup. |
496
+ | `npm install -g --ignore-scripts @piagent/platform@1.6.1` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
497
+ | `pi install git:github.com/Vt-mmm/piagent@v1.6.1` | Cài pinned release khi cần reproducible team setup. |
507
498
  | `pi install git:github.com/Vt-mmm/piagent` | Cài latest package platform cho máy cá nhân/sandbox. |
508
499
  | `piagent-update --check` | Báo version hiện tại vs version sẽ lên cho cả ba thành phần; không cài gì. |
509
500
  | `piagent-update` | Full update global một lệnh cho cả máy: Pi host → npm-global helper → Pi package, đúng thứ tự release yêu cầu. |
@@ -547,17 +538,18 @@ Các lệnh này chạy ngoài Pi.
547
538
  | `piagent-uninstall --apply` | Gỡ Pi package của platform khỏi Pi settings global. |
548
539
  | `piagent-uninstall --apply --with-addons --with-host` | Gỡ thêm pi-mcp-adapter, pi-subagents, pi-web-access và Pi host. |
549
540
  | `piagent-uninstall --apply --project /path/to/project` | Gỡ thêm state của platform trong project: profile, lock, `piagent-state/`. |
550
- | `piagent-benchmark` | Chạy smoke suite `core-v1`: paired Raw Pi/Piagent, 24 session, hidden grader + scope + workflow + exact usage. |
541
+ | `piagent-benchmark` | Chạy smoke suite `core-v1`: paired Piagent/controlled `codex-cli` bằng Luna/medium, 24 session, hidden grader + scope + workflow + exact usage. |
551
542
  | `piagent-benchmark --dry-run` | Validate suite và xem số model session, không gọi model. |
552
- | `npm run benchmark:deep -- --dry-run` | Validate `deep-logic-v1`: 6 family difficulty large x 2 repeat x Piagent/`codex-cli` = 24 session, pin Luna/medium và chưa dùng quota. |
553
- | `npm run benchmark:deep` | Chạy paired deep-logic benchmark Luna/medium cho event/state, scheduler, policy, context graph, stream recovery và transactional config. |
543
+ | `npm run benchmark:deep -- --dry-run` | Validate `deep-logic-v1`: 7 family difficulty large × 3 repeat × Piagent/`codex-cli` = 42 session, khóa Luna/medium và chưa dùng quota. |
544
+ | `npm run benchmark:deep` | Chạy paired deep-logic benchmark Luna/medium cho event/state, scheduler, policy, context graph, stream recovery, transactional config và temporal usage billing chính xác. |
554
545
  | `piagent-benchmark --production --dry-run` | Xem ma trận production 18 family x 3 variant x 2 surface = 108 session, chưa dùng quota. |
555
- | `piagent-benchmark --production --surfaces piagent,codex-cli --model <provider/model> --thinking high --piagent-treatment candidate` | Chạy production release gate đa domain/profile/lifecycle với controlled Codex, treatment Piagent đã pin, paired outcome và 95% token-ratio confidence. |
546
+ | `piagent-benchmark --production --preflight-only` | Trước lượt trả phí, tự chạy/cache ba lane provider-free cùng exact source/tree/config/runner binding; lần đầu có long-horizon tối thiểu 30 phút, 0 provider call/model token. |
547
+ | `piagent-benchmark --production --surfaces piagent,codex-cli --model openai-codex/gpt-5.6-luna --thinking medium --piagent-treatment candidate` | Chạy production release gate đa domain/profile/lifecycle với controlled Codex; S12/S36/S72 chặn pooled fresh ratio >1.10, observed family >1.25 hoặc subagent vượt 1 attempt/5% traffic; S108 dùng upper-95 <=0.60. |
556
548
  | `piagent-benchmark --piagent-treatment release-defaults\|local-safe\|candidate\|feature-off ...` | Pin treatment Piagent; chỉ surface `piagent` nhận feature env, manifest/resume/replay/report giữ nguyên treatment. |
557
549
  | `piagent-benchmark --codex-mode native ...` | Đo UX Codex theo cấu hình operator; protocol gate fail closed nên report không được claim tiết kiệm token. |
558
550
  | `piagent-benchmark --production --seed <value> ...` | Tái lập đúng generated variant của một production report riêng tư. |
559
551
  | `piagent-benchmark --production --scenarios <id,id> --repeats 1 ...` | Chẩn đoán family/rubric đã chọn; không đủ điều kiện nhận production verdict. |
560
- | `piagent-benchmark --production --infrastructure-retries 2 ...` | Retry đúng lỗi process chết trước usage; timeout/task failure không retry và vẫn chấm reliability. |
552
+ | `piagent-benchmark --production --infrastructure-retries 2 ...` | Diagnostic recovery run; retry chỉ áp lỗi process chết trước usage, được report đầy đủ và làm production claim fail. |
561
553
  | `piagent-benchmark --production --retry-delay 60 ...` | Đặt backoff trước infrastructure retry; production mặc định 60 giây. |
562
554
  | `bash scripts/verify-local.sh` | Verify repo platform trước khi commit/tag. |
563
555
  | `bash scripts/verify-local.sh --offline` | Verify trong CI/máy sạch, bỏ qua local Pi model catalog. |
@@ -576,7 +568,7 @@ Khi đang develop chính repo `piagent`, có thể dùng npm scripts tương ứ
576
568
  | `npm run init-project -- <project>` | `bash scripts/init-project.sh <project>` |
577
569
  | `npm run doctor -- <project> --strict-share` | `bash scripts/team-doctor.sh <project> --strict-share` |
578
570
  | `npm run benchmark -- ...` | `node scripts/benchmark-runner.mjs ...` |
579
- | `npm run benchmark:webui-parity` | Gate provider-free cho 10 workflow, 32 Project Controls, contract/security, Chromium flow và ba cỡ performance stress. |
571
+ | `npm run benchmark:webui-parity` | Gate provider-free cho 10 workflow, 32 Project Controls, contract/security, bảy deterministic UI-stability suite, Chromium flow và ba cỡ performance stress. |
580
572
  | `npm run usage -- <project>` | `bash scripts/pi-session-stats.sh <project>` |
581
573
  | `npm run usage -- --history <project> --days 7` | `bash scripts/pi-session-stats.sh --history <project> --days 7` |
582
574
  | `npm run models` | `bash scripts/pi-model-catalog.sh` |
@@ -21,9 +21,11 @@ task
21
21
 
22
22
  ## P0: runtime context controls
23
23
 
24
- - Piagent tools được chia thành `governance`, `policy`, `retrieval`,
25
- `knowledge`, `onboarding`, và `usage`. Code retrieval không tự kéo theo
26
- memory, document intake, source checkout hoặc orchestration.
24
+ - Piagent tools được chia thành `governance`, `policy`, `retrieval`, `source`,
25
+ `knowledge`, `onboarding`, và `usage`. URL GitHub/GitLab/Bitbucket do operator
26
+ cung cấp chỉ bật schema `source`; code retrieval không tự kéo theo memory,
27
+ document intake hoặc orchestration. Checkout được cấp quyền đọc đúng session
28
+ qua `read`/`grep`/`find`/`ls`, còn shared cache không mở cho shell hay mutation.
27
29
  - Session bắt đầu không mang schema quản trị Piagent. Input hook bật thẳng nhóm
28
30
  tối thiểu cần cho task trước khi system prompt được tạo.
29
31
  - `piagent_tools` chỉ xuất hiện khi operator yêu cầu rõ tool loader; runtime
@@ -46,6 +48,10 @@ task
46
48
  - Telemetry không lưu prompt hoặc tool output thô. Nó lưu hash, kích thước, tool,
47
49
  model, thinking, active-tool count, usage, retrieval confidence và đường dẫn
48
50
  tương đối đã được guard redaction.
51
+ - Mỗi telemetry row có provenance envelope do writer đóng sau payload; event
52
+ không thể ghi đè schema/provenance. Nếu source snapshot phải redact, receipt
53
+ chỉ giữ `sanitizedContentDigest` và `fileContentHash` trên nội dung đã sanitize;
54
+ raw-content digest không được tính hoặc lưu.
49
55
 
50
56
  Bốn cơ chế `PIAGENT_DYNAMIC_TOOLS`, `PIAGENT_AUTO_CONTEXT`,
51
57
  `PIAGENT_CONTEXT_TELEMETRY` và `PIAGENT_AUTO_RECOVERY` đều **bật mặc định**.
@@ -180,7 +186,9 @@ không bị trừ điểm. `contextSelections`, `contextSelectionsUsed` và
180
186
  ranking. Runtime chỉ đọc phần đuôi telemetry có giới hạn khi tính report hoặc
181
187
  feedback, nên lịch sử dài không làm chậm từng prompt theo thời gian.
182
188
 
183
- `contextWasteScore` nằm trong khoảng `0..100`, thấp hơn là tốt hơn:
189
+ Khi toàn bộ evidence lane đầy đủ, `contextWasteScore` nằm trong khoảng `0..100`,
190
+ thấp hơn là tốt hơn. Nếu coverage chưa đầy đủ, score chính là `null` và chỉ
191
+ `contextWasteScoreEstimate` được giữ như chẩn đoán partial:
184
192
 
185
193
  ```text
186
194
  30% duplicate read rate
@@ -36,7 +36,11 @@ Trước task lớn/risk cao trong Pi TUI:
36
36
  /context compact
37
37
  ```
38
38
 
39
- Nếu recommendation là `fresh-session`, dùng `/fresh task`, `/fresh scout`, hoặc `/fresh be-to-fe` thay vì tiếp tục nhồi context vào session hiện tại.
39
+ Với task/phase tiếp theo trong cùng phiên hiển thị, runtime tự tạo working set
40
+ gọn trước mỗi provider call; người dùng không phải mở session mới chỉ để đổi từ
41
+ scout sang plan, implement hay verify. `/fresh task`, `/fresh scout` và
42
+ `/fresh be-to-fe` vẫn là đường phục hồi tường minh khi preflight xác định input
43
+ quá lớn hoặc working set không thể rút gọn an toàn.
40
44
 
41
45
  ## Context manifest
42
46
 
@@ -68,6 +72,38 @@ Pi settings template dùng:
68
72
  }
69
73
  ```
70
74
 
75
+ Host compaction trên chỉ là overflow guard. Adaptive context governor của
76
+ Piagent chạy sớm hơn và không đổi model/thinking:
77
+
78
+ - phát hiện ranh giới task/phase, context pressure, số tool round, read-output
79
+ cũ và kết quả lặp;
80
+ - giữ yêu cầu/quyết định gần nhất của người dùng, Task Contract, acceptance
81
+ criteria, changed files, verifier và lỗi chưa giải quyết;
82
+ - bỏ raw read/test log cũ khỏi provider working set nhưng giữ nguyên transcript
83
+ hiển thị và audit source;
84
+ - giữ nguyên nhóm assistant tool-call/tool-result để không tạo orphan protocol;
85
+ - giữ nguyên tối thiểu 6 nhóm ranh giới gần nhất; nếu transcript hoặc projected
86
+ candidate đã có orphan tool message thì fail closed và không thay context;
87
+ - chỉ project khi ước tính tiết kiệm đạt ngưỡng thích ứng: ít nhất 8K token,
88
+ 15% transcript occupancy và không đòi quá 20K; không đạt thì no-op thay vì gọi
89
+ thêm một model summarizer có phí;
90
+ - chỉ ghi durable compaction sau khi agent đã settled; coding task dùng summary
91
+ deterministic từ state/file-backed evidence để không tốn thêm model call;
92
+ - trước khi lặp exact verifier, dùng current-tree gate: một durable pass trên
93
+ cùng working-tree digest được tái sử dụng bằng receipt nhỏ thay vì chạy lại.
94
+ Code đổi, pass thiếu/stale, test từng fail, hoặc operator yêu cầu chạy lại thì
95
+ verifier thật vẫn chạy;
96
+ - giữ model summarizer cho thảo luận không có Task Contract và ít tool evidence,
97
+ nơi sắc thái hội thoại quan trọng hơn tiết kiệm tuyệt đối.
98
+
99
+ Telemetry tách `contextOccupancy` (working set ước tính/được provider báo) khỏi
100
+ `billedTraffic` (input/output/cache thực sự đo được). Vì context hook không có
101
+ usage hóa đơn theo lần gọi, runtime không được suy diễn hai con số này là một.
102
+
103
+ Mốc vận hành hiện tại bắt đầu tạo áp lực ở khoảng 160K token, giữ provider prompt
104
+ dưới 240K khi có thể và chủ động tránh vùng pricing 272K+. Đây là giới hạn
105
+ working set, không phải giới hạn năng lực hay context window của model.
106
+
71
107
  ## Rule
72
108
 
73
109
  - Nếu task là read-only, không mở write-capable prompt.
@@ -15,9 +15,9 @@ Repo này phải chạy được cho nhiều project/domain khác nhau. Vì vậ
15
15
 
16
16
  | Use case | Package source |
17
17
  |---|---|
18
- | Team pinned release | `git:github.com/Vt-mmm/piagent@v1.5.5` |
18
+ | Team pinned release | `git:github.com/Vt-mmm/piagent@v1.6.1` |
19
19
  | Personal/sandbox dev | `git:github.com/Vt-mmm/piagent` |
20
- | Registry distribution | `npm:@piagent/platform@1.5.5` |
20
+ | Registry distribution | `npm:@piagent/platform@1.6.1` |
21
21
  | Enterprise npm (fork under another scope) | `npm:@your-scope/platform@x.y.z` |
22
22
  | Local platform dev | `/path/to/piagent` |
23
23
 
@@ -27,7 +27,7 @@ Latest tiện cho máy cá nhân muốn nhận cập nhật nhanh. Pin tag/commi
27
27
 
28
28
  | Channel | Command | Target | Policy |
29
29
  |---|---|---|---|
30
- | `stable` | `bash scripts/install-global.sh --stable` | Helper release tag resolved to commit SHA, currently `v1.5.5` | Install the Pi package matching the helper. |
30
+ | `stable` | `bash scripts/install-global.sh --stable` | Helper release tag resolved to commit SHA, currently `v1.6.1` | Install the Pi package matching the helper. |
31
31
  | `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. |
32
32
  | `dev` | `bash scripts/install-global.sh --dev` | Moving Git source | Personal/sandbox only; do not commit into project settings. |
33
33
  | `local` | `bash scripts/install-global.sh --local` | Current checkout path | Platform development only. |
@@ -54,7 +54,7 @@ Root `package.json` có `pi` manifest trỏ tới:
54
54
  Do đó team có thể:
55
55
 
56
56
  ```bash
57
- pi install git:github.com/Vt-mmm/piagent@v1.5.5
57
+ pi install git:github.com/Vt-mmm/piagent@v1.6.1
58
58
  ```
59
59
 
60
60
  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.
@@ -66,12 +66,12 @@ Team nên install global package một lần:
66
66
  ```bash
67
67
  node --version # >= 22.19.0
68
68
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.84.1
69
- npm install -g --ignore-scripts @piagent/platform@1.5.5
69
+ npm install -g --ignore-scripts @piagent/platform@1.6.1
70
70
  piagent-install --stable --dry-run
71
71
  piagent-install --stable
72
72
  ```
73
73
 
74
- `pi install git:github.com/Vt-mmm/piagent@v1.5.5` 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.5.5`.
74
+ `pi install git:github.com/Vt-mmm/piagent@v1.6.1` 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.6.1`.
75
75
 
76
76
  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).
77
77
 
@@ -121,7 +121,7 @@ Nếu muốn commit sẵn `.pi/piagent-profile.json` vào repo hoặc bootstrap
121
121
  ```bash
122
122
  bash scripts/setup.sh /path/to/project \
123
123
  --profile be-readonly-fe \
124
- --package-source git:github.com/Vt-mmm/piagent@v1.5.5 \
124
+ --package-source git:github.com/Vt-mmm/piagent@v1.6.1 \
125
125
  --mcp-preset core \
126
126
  --subagents-preset safe
127
127
  ```
@@ -44,6 +44,7 @@ The machine-readable rule is `architecture/layers.json`; `npm run architecture:c
44
44
  | Security foundation | `packages/piagent-core/security/` | Sensitive-data primitives | Workflow behavior |
45
45
  | Benchmark | `packages/piagent-core/benchmark/`, `benchmarks/` | Suite validation, scoring, evidence | Runtime enforcement |
46
46
  | WebUI contracts | `packages/piagent-webui/contracts/` | Wire types shared by browser and server | Any runtime behavior; it depends on nothing |
47
+ | WebUI shared | `packages/piagent-webui/shared/` | Dependency-free deterministic helpers shared by browser, server, and gateway | Browser state, transport, filesystem access, or runtime policy |
47
48
  | WebUI client | `packages/piagent-webui/client/` | Browser views, view models, UI preferences | Server state, filesystem, Pi APIs |
48
49
  | WebUI server | `packages/piagent-webui/server/` | HTTP/WS endpoints, session reads, diff assembly | Browser rendering; it may not import the client |
49
50
  | WebUI extension | `packages/piagent-webui/extension/` | The in-Pi `/piagent-webui` command surface | Wire types the client also needs |
@@ -93,10 +94,23 @@ the verified journal second; corruption blocks automatic resume for review.
93
94
  The journal hash chain and acceptance receipts are same-runtime operational
94
95
  evidence, not independent attestation or a separate audit authority.
95
96
 
97
+ The Gateway binds each browser send to one operation lifecycle shared by the
98
+ stream and supervisor. It permits at most one pristine provider retry within an
99
+ 8-second delay, and refuses replay after any visible assistant output or tool
100
+ call. Compaction has a separate phase, terminal settlement is emitted once, and
101
+ post-settlement events cannot put the UI back into `Working`. A bounded local
102
+ emission guard removes repeated/filler activity or reviewer notes, while final
103
+ assistant messages always bypass that guard.
104
+
105
+ Exact edits and local patches may also bind to the full-file digest from the
106
+ latest successful read in the same task run. Proven concurrent drift blocks the
107
+ whole mutation before the first hunk and requires one fresh read; an unobserved
108
+ file retains the host's normal exact-anchor behavior.
109
+
96
110
  Recovery is classification-driven and bounded across task attempts. Only an
97
- in-scope source-owned failure may receive one repair pass; transient verifier or
111
+ evidence-backed source-owned failure may receive one repair pass; transient verifier or
98
112
  provider failures receive at most one exact retry and never source-mutation
99
- authority. Environment, permission, policy, scope, and unknown failures stay
113
+ authority. Environment, permission, protected-path policy, and unknown failures stay
100
114
  non-mutating. `PIAGENT_AUTO_RECOVERY=off` restores ordinary P3 handoff behavior
101
115
  without migrating state. Every final path writes a redacted Handoff v1
102
116
  projection from operational truth. Resume binds task/session identity, journal
@@ -110,7 +124,7 @@ Semantic specialist review is a separate strict-high-risk CAP-13 path, not a
110
124
  universal parser-driven recovery path. It is pinned to one shared continuation,
111
125
  one current-tree diff, two targeted reads, exact eligible source/test paths, and
112
126
  the configured verifier after any mutation. Denied, failed, no-op, stale,
113
- out-of-scope, unsupported, or exhausted work locks the opportunity and hands
127
+ target-unresolved, unsupported, or exhausted work locks the opportunity and hands
114
128
  off. Broad-default observation/advice never schedules this review or blocks a
115
129
  tool call.
116
130
 
@@ -126,7 +140,7 @@ Task Contract v2 also carries an additive Criterion Graph v1 planning
126
140
  projection. It maps every operator criterion exactly once to a closed planning
127
141
  kind, scoped target hints, proof kinds, and dependency order. The graph has no
128
142
  `satisfied` state and cannot override acceptance or exact-verifier truth. It
129
- selects relevant in-scope context before older observations, survives
143
+ selects relevant focus-ranked context before older observations, survives
130
144
  compaction/resume by digest, and adds no tool-schema change or provider follow-up
131
145
  turn. `PIAGENT_INTELLIGENCE_ENGINE=off` selects the mechanical control for
132
146
  causal tests and emergency rollback; new tasks otherwise use the criterion
@@ -165,17 +179,17 @@ authority, and combined automatic dispatch authority is capped at one unit per
165
179
  task. These interaction checks are snapshot-bound and cannot change the
166
180
  provider-visible tool schema.
167
181
 
168
- Piagent-owned helpers use RolePolicy v1 and HelperRequest v1. The request binds
169
- a hashed session/task identity, bounded objective, read/write scope, exact tool
182
+ Piagent-owned helpers use RolePolicy v1 and HelperRequest v2. The request binds
183
+ a hashed session/task identity, bounded objective, read-only scope, exact tool
170
184
  allowlist, authenticated model/effort source, context/time/call ceilings, output
171
185
  schema, stopping rule, approval restrictions, and deduplication key. Read-only
172
- roles cannot receive mutation tools. Worker remains disabled by default and
173
- requires an explicit single-writer lease. `PIAGENT_HELPERS_MODE=off|recommend|on`
174
- defaults to `recommend`; `on` permits only read-only dispatch through an
175
- installed provider adapter. CAP-14 permits at most one automatic helper dispatch
176
- per task/run; the lower-level owner budget still caps two concurrent and three
177
- total explicitly owned helper reservations, deduplicates equivalent work, recovers
178
- expired reservations without adding budget, and cancels late work when the
186
+ roles cannot receive mutation tools, and worker dispatch is disabled.
187
+ `PIAGENT_HELPERS_MODE=off|recommend|on` defaults to `off`; `on` is explicit
188
+ opt-in but still requires two independent lanes and at least 30% projected net
189
+ token saving. CAP-14 and the lower-level owner budget enforce one fresh read-only
190
+ helper total and concurrent, zero writers, zero retries, eight calls, and at most
191
+ 2,048 transferred context tokens. Failed or expired work consumes the only slot,
192
+ and late work is cancelled when the
179
193
  parent Task Contract becomes terminal. It does not claim control over unrelated
180
194
  Pi sessions or account usage, and never changes the user-pinned parent model.
181
195
  Dispatch enforces the request's time, call, and token ceilings at result merge: