@piagent/platform 1.2.10 → 1.2.11

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 (105) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +27 -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/catalog/capabilities.json +10 -10
  39. package/docs/command-reference-vietnamese.md +10 -6
  40. package/docs/context-engine.md +33 -11
  41. package/docs/distribution-standard.md +11 -8
  42. package/docs/mcp-and-tools.md +13 -7
  43. package/docs/model-options.md +7 -10
  44. package/docs/operator-manual-vietnamese.md +82 -33
  45. package/docs/package-architecture-notes.md +3 -1
  46. package/docs/publishing-for-teams.md +4 -0
  47. package/docs/quality-benchmark.md +225 -58
  48. package/docs/quickstart-vietnamese.md +5 -0
  49. package/docs/release-install-policy.md +41 -7
  50. package/docs/runtime-harness-standard.md +47 -29
  51. package/docs/runtime-policy-design.md +23 -12
  52. package/docs/runtime-quality-baseline.md +31 -17
  53. package/docs/security-threat-model.md +1 -1
  54. package/docs/task-implementation-contract.md +113 -177
  55. package/docs/task-lifecycle-vietnamese.md +129 -125
  56. package/docs/team-onboarding.md +12 -4
  57. package/docs/usage-observability.md +15 -8
  58. package/docs-site/architecture.html +1 -1
  59. package/docs-site/commands.html +1 -1
  60. package/docs-site/content/runtime.html +10 -0
  61. package/docs-site/context-engine.html +1 -1
  62. package/docs-site/index.html +1 -1
  63. package/docs-site/mcp-approval.html +1 -1
  64. package/docs-site/mcp-auth.html +1 -1
  65. package/docs-site/mcp-servers.html +1 -1
  66. package/docs-site/mcp.html +1 -1
  67. package/docs-site/permissions.html +1 -1
  68. package/docs-site/profiles.html +1 -1
  69. package/docs-site/quickstart.html +1 -1
  70. package/docs-site/runtime.html +11 -1
  71. package/docs-site/scope.html +1 -1
  72. package/docs-site/security.html +1 -1
  73. package/docs-site/team.html +1 -1
  74. package/docs-site/workflows.html +1 -1
  75. package/evals/fixtures/task-contract.invalid.json +15 -1
  76. package/evals/fixtures/task-contract.valid.json +18 -2
  77. package/package.json +3 -2
  78. package/packages/piagent-core/README.md +37 -3
  79. package/packages/piagent-core/benchmark/benchmark-core.js +691 -0
  80. package/packages/piagent-core/extensions/context-engine.js +81 -57
  81. package/packages/piagent-core/extensions/guard-types.ts +35 -3
  82. package/packages/piagent-core/extensions/local-state-path.js +59 -0
  83. package/packages/piagent-core/extensions/piagent-guard.ts +1865 -171
  84. package/packages/piagent-core/extensions/policy-core.js +11 -1
  85. package/packages/piagent-core/extensions/runtime-evidence.js +39 -19
  86. package/packages/piagent-core/extensions/state-retention.js +218 -0
  87. package/packages/piagent-core/extensions/task-lifecycle.js +138 -0
  88. package/packages/piagent-core/extensions/task-state.js +630 -0
  89. package/packages/piagent-core/package.json +1 -1
  90. package/packages/piagent-core/policies/base-policy.json +1 -0
  91. package/packages/piagent-core/prompts/be-to-fe.md +14 -22
  92. package/packages/piagent-core/prompts/platform-improve.md +12 -17
  93. package/packages/piagent-core/prompts/review.md +7 -11
  94. package/packages/piagent-core/prompts/scout.md +6 -10
  95. package/packages/piagent-core/prompts/task.md +11 -17
  96. package/packages/piagent-core/skills/piagent-ops/SKILL.md +12 -15
  97. package/schemas/task-contract.schema.json +267 -104
  98. package/scripts/benchmark-runner.mjs +1172 -0
  99. package/scripts/install-global.sh +1 -1
  100. package/scripts/migrate-project-state.mjs +94 -3
  101. package/scripts/piagent-cli.mjs +1 -1
  102. package/scripts/update-global.mjs +36 -3
  103. package/scripts/verify-local.sh +15 -0
  104. package/templates/project/.pi/task-contract.template.json +19 -2
  105. package/templates/project/AGENTS.md +10 -20
@@ -1,5 +1,13 @@
1
1
  {
2
- "taskId": "TASK-0001",
2
+ "schemaVersion": 2,
3
+ "taskRunId": "task-0001-20260731120000-a1b2c3d4e5",
4
+ "taskId": "task-0001",
5
+ "sessionId": "pi-session-example",
6
+ "sessionName": "TASK-0001 Example task",
7
+ "changeMode": "source-change",
8
+ "attempt": 1,
9
+ "maxAttempts": 3,
10
+ "previousAttempts": [],
3
11
  "summary": "Replace with one-sentence task outcome.",
4
12
  "riskLane": "normal",
5
13
  "expectedOutput": "Replace with exact artifact or behavior expected.",
@@ -17,6 +25,7 @@
17
25
  "contextManifest": [],
18
26
  "memoryCitations": [],
19
27
  "mcpCapabilities": [],
28
+ "verifyGroup": "source",
20
29
  "verifyCommands": [
21
30
  "Replace with verify command."
22
31
  ],
@@ -66,9 +75,16 @@
66
75
  "watchdog": "Use a strong model only for final risk review, security, release, or high-impact changes."
67
76
  }
68
77
  },
78
+ "baselineChangedFiles": [],
79
+ "baselineFileDigests": {},
80
+ "observedChangedFiles": [],
81
+ "finalWorkingTreeFiles": [],
82
+ "finalFileDigests": {},
69
83
  "changedFiles": [],
70
84
  "verifyEvidence": [],
71
85
  "trace": {
72
86
  "outcome": "pending"
73
- }
87
+ },
88
+ "createdAt": "2026-07-31T12:00:00.000Z",
89
+ "updatedAt": "2026-07-31T12:00:00.000Z"
74
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piagent/platform",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -30,6 +30,7 @@
30
30
  "SECURITY.md",
31
31
  ".gitattributes",
32
32
  "adapters/",
33
+ "benchmarks/",
33
34
  "catalog/",
34
35
  "docs/",
35
36
  "!docs/journals/",
@@ -113,7 +114,7 @@
113
114
  "install-global": "bash scripts/install-global.sh",
114
115
  "init-project": "bash scripts/init-project.sh",
115
116
  "doctor": "bash scripts/team-doctor.sh",
116
- "benchmark": "bash scripts/quality-benchmark.sh",
117
+ "benchmark": "node scripts/benchmark-runner.mjs",
117
118
  "benchmark:redaction": "node scripts/redaction-benchmark.mjs",
118
119
  "audit:runtime": "bash scripts/audit-runtime-host.sh",
119
120
  "release:identity": "node scripts/verify-release-identity.mjs",
@@ -6,13 +6,23 @@ Shared Pi package for reusable project workflows.
6
6
 
7
7
  - `extensions/piagent-guard.ts`: runtime guard tools and policy hooks.
8
8
  - `prompts/*.md`: workflow aliases that intentionally launch an agent turn.
9
- - `skills/piagent-ops/SKILL.md`: operating guidance for implementation tasks.
9
+ - `skills/piagent-ops/SKILL.md`: operator-invoked reference for manual intake, recovery, and high-risk controls; routine runtime-managed tasks do not advertise or load it.
10
10
  - `skills/piagent-source-cache/`: local cache for user-provided external source repositories.
11
11
  - `subagents/*.md`: piagent roles for `pi-subagents`.
12
+ - `benchmark/benchmark-core.js`: deterministic suite validation, evidence scoring, usage comparison, and report rendering for `piagent-benchmark`.
12
13
  - `policies/base-policy.json`: default runtime policy, including protected path and shell protected path defaults.
13
14
  - input hook support for local screenshot/image paths pasted into chat; supported images are attached as `[image1]`, `[image2]`, ...
14
15
  - compact tool-result rendering: oversized redacted output is previewed in Pi and captured under `.pi/piagent-state/tool-results/` for offline audit/reporting.
15
- - local Context Engine v2: incremental FTS5/symbol/import index, hybrid retrieval, token-budgeted packs, test-impact mapping, dynamic Piagent tools, and Agent Watch compatible telemetry.
16
+ - local Context Engine v2: incremental FTS5/symbol/import index, hybrid retrieval, token-budgeted packs, bounded current-turn source/test snapshots, test-impact mapping, dynamic Piagent tools, and Agent Watch compatible telemetry.
17
+
18
+ The root package exposes `piagent-benchmark` for an automatic paired Piagent
19
+ steady-state benchmark against Raw Pi or the `codex-cli` surface. Treatment
20
+ onboarding/context preparation happens before measured model usage;
21
+ post-baseline mutations remain scope violations. Codex runs through a strict
22
+ streaming JSONL adapter and defaults to controlled ephemeral execution with an
23
+ isolated temporary Codex home. Run
24
+ `piagent-benchmark --dry-run` before starting billed model sessions; see
25
+ `docs/quality-benchmark.md` for score and verdict rules.
16
26
 
17
27
  ## Trusted run wrapper
18
28
 
@@ -70,12 +80,20 @@ Legacy aliases still work: `/permission-status`, `/read-only`, `/workspace-write
70
80
  - `piagent_profile_tech_context_record`
71
81
  - `piagent_project_onboarding_record`
72
82
  - `piagent_task_start`
83
+ - `piagent_task_progress`
73
84
  - `piagent_source_checkout`
74
85
  - `piagent_document_read` — reads `.md`/`.txt`/`.csv`/`.json`/`.yaml`/`.pdf`/`.docx` from the project or a granted `additionalReadRoots` directory; read-only, and `protectedPaths` still wins
75
86
  - `piagent_context_record`
76
87
  - `piagent_verify_record` — records verify evidence only after matching an observed bash tool result after task start
77
88
  - `piagent_trace_record`
78
89
 
90
+ These tools are registered capabilities, not a per-task call sequence. Runtime
91
+ starts bounded source tasks directly and exposes no Piagent management schema
92
+ to the model. Broad, high-risk, or ambiguous intake activates
93
+ `piagent_task_start`; lifecycle hooks still collect context, changes,
94
+ current-tree verification, trace and final-gate evidence. Diagnostic/recovery
95
+ groups load only when requested.
96
+
79
97
  ## Runtime commands and workflow recipes
80
98
 
81
99
  - `/commands`: runtime menu/help for terminal, Pi, MCP, model, memory, session, context, permission, and subagent commands.
@@ -132,6 +150,7 @@ If no trusted profile is available, the extension still applies baseline secret
132
150
  Runtime task tools write local state to:
133
151
 
134
152
  - `.pi/piagent-state/tasks/*.json`
153
+ - `.pi/piagent-state/session-tasks/*.json`
135
154
  - `.pi/project-context.md`
136
155
  - `.pi/tech-stack.json`
137
156
  - `.pi/tech-context/*.json`
@@ -147,12 +166,27 @@ Runtime task tools write local state to:
147
166
 
148
167
  Project-local state belongs in `.pi/.gitignore`.
149
168
 
169
+ Task files use schema v2 and bind one unique `taskRunId` to one Pi `sessionId`.
170
+ They record attempt/max-attempt history, dependency-safe work-plan progress,
171
+ Git baseline/final digests, observed changes, all exact verify results and final
172
+ trace. A terminal task is immutable; retry starts in a fresh session and carries
173
+ the prior failure/ruled-out evidence. Legacy v1 state is migrated and archived
174
+ without requiring project onboarding again.
175
+
176
+ Local state directories are owner-only. Task state, context telemetry, trace,
177
+ bash evidence and captures refuse ancestor symlinks out of the project. JSONL
178
+ files rotate under a cross-process lock; compacted tool captures are pruned by
179
+ age, count and aggregate bytes.
180
+
150
181
  The Context Engine SQLite index contains allowed source bodies. Its directory is
151
182
  kept at mode `0700`, with database/WAL/SHM at `0600`; core and FTS5 secure-delete
152
183
  cover normal refreshes, while exclusion-policy changes trigger a retryable FTS
153
184
  rebuild and database vacuum before the new policy is considered clean.
154
185
 
155
- Passing final gates require an observed exit `0` command that exactly matches one entry in `task.verifyCommands`. Other observed commands are traceable but advisory.
186
+ Passing source final gates require an observed exit `0` result for every
187
+ meaningful entry in `task.verifyCommands`. Other observed commands are traceable
188
+ but advisory. Declared changed files must also differ from the task baseline,
189
+ match observed tool results and remain inside `task.scope`.
156
190
 
157
191
  Raw path-like tool access to protected paths is blocked before execution. This includes Pi built-ins (`read`, `write`, `edit`, `grep`, `find`, `ls`) and custom/MCP tools with nested path-like strings, arrays, or `file://` URIs. Path-like strings are percent-decoded once, and input nesting above `MAX_TOOL_INPUT_INSPECTION_DEPTH=32` fails closed. Known content fields such as `content`, `query`, `pattern`, `text`, and `command` are excluded from generic extraction. `grep.glob` and `find.pattern` are checked when they explicitly target protected paths, while broad `grep`, `find`, and `ls` results are filtered so protected content lines or path metadata are redacted before reaching the model.
158
192