@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
@@ -4,7 +4,14 @@
4
4
  "title": "Pi Agent Task Implementation Contract",
5
5
  "type": "object",
6
6
  "required": [
7
+ "schemaVersion",
8
+ "taskRunId",
7
9
  "taskId",
10
+ "sessionId",
11
+ "changeMode",
12
+ "attempt",
13
+ "maxAttempts",
14
+ "previousAttempts",
8
15
  "summary",
9
16
  "riskLane",
10
17
  "expectedOutput",
@@ -15,15 +22,143 @@
15
22
  "requiredContext",
16
23
  "contextManifest",
17
24
  "memoryCitations",
25
+ "mcpCapabilities",
18
26
  "verifyCommands",
27
+ "workPlan",
28
+ "reviewLenses",
29
+ "baselineChangedFiles",
30
+ "baselineFileDigests",
31
+ "observedChangedFiles",
32
+ "finalWorkingTreeFiles",
33
+ "finalFileDigests",
19
34
  "changedFiles",
20
35
  "verifyEvidence",
21
- "trace"
36
+ "trace",
37
+ "createdAt",
38
+ "updatedAt"
22
39
  ],
40
+ "$defs": {
41
+ "nonEmptyString": {
42
+ "type": "string",
43
+ "minLength": 1
44
+ },
45
+ "stringList": {
46
+ "type": "array",
47
+ "items": {
48
+ "$ref": "#/$defs/nonEmptyString"
49
+ },
50
+ "uniqueItems": true
51
+ },
52
+ "citation": {
53
+ "type": "object",
54
+ "required": [
55
+ "path",
56
+ "reason"
57
+ ],
58
+ "properties": {
59
+ "path": {
60
+ "$ref": "#/$defs/nonEmptyString"
61
+ },
62
+ "reason": {
63
+ "$ref": "#/$defs/nonEmptyString"
64
+ }
65
+ },
66
+ "additionalProperties": false
67
+ },
68
+ "fileDigests": {
69
+ "type": "object",
70
+ "additionalProperties": {
71
+ "type": "string",
72
+ "minLength": 1
73
+ }
74
+ }
75
+ },
23
76
  "properties": {
77
+ "schemaVersion": {
78
+ "const": 2
79
+ },
80
+ "taskRunId": {
81
+ "type": "string",
82
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
83
+ "maxLength": 80
84
+ },
24
85
  "taskId": {
25
86
  "type": "string",
26
- "minLength": 1
87
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
88
+ "maxLength": 80
89
+ },
90
+ "sessionId": {
91
+ "$ref": "#/$defs/nonEmptyString"
92
+ },
93
+ "sessionName": {
94
+ "type": "string"
95
+ },
96
+ "changeMode": {
97
+ "enum": [
98
+ "source-change",
99
+ "read-only"
100
+ ]
101
+ },
102
+ "attempt": {
103
+ "type": "integer",
104
+ "minimum": 1,
105
+ "maximum": 10
106
+ },
107
+ "maxAttempts": {
108
+ "type": "integer",
109
+ "minimum": 1,
110
+ "maximum": 10
111
+ },
112
+ "previousAttempts": {
113
+ "type": "array",
114
+ "maxItems": 10,
115
+ "items": {
116
+ "type": "object",
117
+ "required": [
118
+ "taskRunId",
119
+ "attempt",
120
+ "outcome",
121
+ "recordedAt"
122
+ ],
123
+ "properties": {
124
+ "taskRunId": {
125
+ "$ref": "#/$defs/nonEmptyString"
126
+ },
127
+ "attempt": {
128
+ "type": "integer",
129
+ "minimum": 1
130
+ },
131
+ "outcome": {
132
+ "enum": [
133
+ "pending",
134
+ "completed",
135
+ "blocked",
136
+ "partial",
137
+ "failed"
138
+ ]
139
+ },
140
+ "failedAt": {
141
+ "enum": [
142
+ "research",
143
+ "plan",
144
+ "execute",
145
+ "verify",
146
+ "review"
147
+ ]
148
+ },
149
+ "reason": {
150
+ "type": "string"
151
+ },
152
+ "ruledOut": {
153
+ "type": "string"
154
+ },
155
+ "recordedAt": {
156
+ "type": "string",
157
+ "format": "date-time"
158
+ }
159
+ },
160
+ "additionalProperties": false
161
+ }
27
162
  },
28
163
  "summary": {
29
164
  "type": "string",
@@ -36,103 +171,68 @@
36
171
  "high-risk"
37
172
  ]
38
173
  },
174
+ "intakeMode": {
175
+ "enum": [
176
+ "model",
177
+ "runtime"
178
+ ]
179
+ },
39
180
  "expectedOutput": {
40
181
  "type": "string",
41
182
  "minLength": 10
42
183
  },
43
184
  "acceptanceCriteria": {
44
- "type": "array",
45
- "items": {
46
- "type": "string",
47
- "minLength": 1
48
- },
49
- "minItems": 1
185
+ "allOf": [
186
+ {
187
+ "$ref": "#/$defs/stringList"
188
+ },
189
+ {
190
+ "minItems": 1
191
+ }
192
+ ]
50
193
  },
51
194
  "scope": {
52
- "type": "array",
53
- "items": {
54
- "type": "string",
55
- "minLength": 1
56
- },
57
- "minItems": 1
195
+ "allOf": [
196
+ {
197
+ "$ref": "#/$defs/stringList"
198
+ },
199
+ {
200
+ "minItems": 1
201
+ }
202
+ ]
58
203
  },
59
204
  "outOfScope": {
60
- "type": "array",
61
- "items": {
62
- "type": "string",
63
- "minLength": 1
64
- }
205
+ "$ref": "#/$defs/stringList"
65
206
  },
66
207
  "protectedPaths": {
67
- "type": "array",
68
- "items": {
69
- "type": "string",
70
- "minLength": 1
71
- }
208
+ "$ref": "#/$defs/stringList"
72
209
  },
73
210
  "requiredContext": {
74
- "type": "array",
75
- "items": {
76
- "type": "string",
77
- "minLength": 1
78
- }
211
+ "$ref": "#/$defs/stringList"
79
212
  },
80
213
  "contextManifest": {
81
214
  "type": "array",
82
215
  "items": {
83
- "type": "object",
84
- "required": [
85
- "path",
86
- "reason"
87
- ],
88
- "properties": {
89
- "path": {
90
- "type": "string"
91
- },
92
- "reason": {
93
- "type": "string"
94
- }
95
- },
96
- "additionalProperties": true
216
+ "$ref": "#/$defs/citation"
97
217
  }
98
218
  },
99
219
  "memoryCitations": {
100
220
  "type": "array",
101
221
  "items": {
102
- "type": "object",
103
- "required": [
104
- "path",
105
- "reason"
106
- ],
107
- "properties": {
108
- "path": {
109
- "type": "string",
110
- "minLength": 1
111
- },
112
- "reason": {
113
- "type": "string",
114
- "minLength": 1
115
- }
116
- },
117
- "additionalProperties": false
222
+ "$ref": "#/$defs/citation"
118
223
  }
119
224
  },
120
225
  "mcpCapabilities": {
121
- "type": "array",
122
- "items": {
123
- "type": "string"
124
- }
226
+ "$ref": "#/$defs/stringList"
227
+ },
228
+ "verifyGroup": {
229
+ "$ref": "#/$defs/nonEmptyString"
125
230
  },
126
231
  "verifyCommands": {
127
- "type": "array",
128
- "items": {
129
- "type": "string",
130
- "minLength": 1
131
- }
232
+ "$ref": "#/$defs/stringList"
132
233
  },
133
234
  "workPlan": {
134
235
  "type": "array",
135
- "description": "Optional solo-first task tree for parent/subagent coordination.",
136
236
  "maxItems": 12,
137
237
  "items": {
138
238
  "type": "object",
@@ -146,7 +246,7 @@
146
246
  "properties": {
147
247
  "id": {
148
248
  "type": "string",
149
- "minLength": 1,
249
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
150
250
  "maxLength": 40
151
251
  },
152
252
  "title": {
@@ -176,16 +276,20 @@
176
276
  "pending",
177
277
  "in-progress",
178
278
  "done",
179
- "skipped"
279
+ "skipped",
280
+ "failed"
180
281
  ]
181
282
  },
182
283
  "dependsOn": {
183
- "type": "array",
184
- "items": {
185
- "type": "string",
186
- "minLength": 1,
187
- "maxLength": 40
188
- }
284
+ "$ref": "#/$defs/stringList"
285
+ },
286
+ "note": {
287
+ "type": "string",
288
+ "maxLength": 500
289
+ },
290
+ "updatedAt": {
291
+ "type": "string",
292
+ "format": "date-time"
189
293
  }
190
294
  },
191
295
  "additionalProperties": false
@@ -193,7 +297,6 @@
193
297
  },
194
298
  "reviewLenses": {
195
299
  "type": "array",
196
- "description": "Explicit review lenses for the task, used instead of blanket swarm review.",
197
300
  "uniqueItems": true,
198
301
  "items": {
199
302
  "enum": [
@@ -209,7 +312,6 @@
209
312
  },
210
313
  "orchestration": {
211
314
  "type": "object",
212
- "description": "Resolved solo-first orchestration policy captured when the task starts.",
213
315
  "properties": {
214
316
  "mode": {
215
317
  "enum": [
@@ -226,31 +328,49 @@
226
328
  ]
227
329
  },
228
330
  "reason": {
229
- "type": "string",
230
- "minLength": 1
331
+ "$ref": "#/$defs/nonEmptyString"
231
332
  },
232
333
  "fieldGuidePath": {
233
- "type": "string",
234
- "minLength": 1
334
+ "$ref": "#/$defs/nonEmptyString"
235
335
  },
236
336
  "modelRoles": {
237
337
  "type": "object",
238
338
  "properties": {
239
- "planner": { "type": "string" },
240
- "worker": { "type": "string" },
241
- "reviewer": { "type": "string" },
242
- "watchdog": { "type": "string" }
339
+ "planner": {
340
+ "type": "string"
341
+ },
342
+ "worker": {
343
+ "type": "string"
344
+ },
345
+ "reviewer": {
346
+ "type": "string"
347
+ },
348
+ "watchdog": {
349
+ "type": "string"
350
+ }
243
351
  },
244
352
  "additionalProperties": false
245
353
  }
246
354
  },
247
355
  "additionalProperties": false
248
356
  },
357
+ "baselineChangedFiles": {
358
+ "$ref": "#/$defs/stringList"
359
+ },
360
+ "baselineFileDigests": {
361
+ "$ref": "#/$defs/fileDigests"
362
+ },
363
+ "observedChangedFiles": {
364
+ "$ref": "#/$defs/stringList"
365
+ },
366
+ "finalWorkingTreeFiles": {
367
+ "$ref": "#/$defs/stringList"
368
+ },
369
+ "finalFileDigests": {
370
+ "$ref": "#/$defs/fileDigests"
371
+ },
249
372
  "changedFiles": {
250
- "type": "array",
251
- "items": {
252
- "type": "string"
253
- }
373
+ "$ref": "#/$defs/stringList"
254
374
  },
255
375
  "verifyEvidence": {
256
376
  "type": "array",
@@ -259,36 +379,42 @@
259
379
  "required": [
260
380
  "command",
261
381
  "exitCode",
262
- "summary"
382
+ "summary",
383
+ "recordedAt"
263
384
  ],
264
385
  "properties": {
265
386
  "command": {
266
- "type": "string"
387
+ "$ref": "#/$defs/nonEmptyString"
267
388
  },
268
389
  "exitCode": {
269
390
  "type": "integer"
270
391
  },
271
392
  "summary": {
272
- "type": "string"
393
+ "$ref": "#/$defs/nonEmptyString"
394
+ },
395
+ "recordedAt": {
396
+ "type": "string",
397
+ "format": "date-time"
273
398
  },
274
399
  "observed": {
275
- "type": "boolean",
276
- "description": "True only when the verify command was matched against an observed bash tool_result after task start."
400
+ "type": "boolean"
277
401
  },
278
402
  "observedAt": {
279
403
  "type": "string",
280
- "description": "Timestamp of the matching bash tool_result observation."
404
+ "format": "date-time"
281
405
  },
282
406
  "isError": {
283
- "type": "boolean",
284
- "description": "Observed Pi tool_result isError flag."
407
+ "type": "boolean"
285
408
  },
286
409
  "matchedProfileCommand": {
287
- "type": "boolean",
288
- "description": "True only when the observed verify command exactly matches one of task.verifyCommands."
410
+ "type": "boolean"
411
+ },
412
+ "workingTreeDigest": {
413
+ "type": "string",
414
+ "pattern": "^[a-f0-9]{64}$"
289
415
  }
290
416
  },
291
- "additionalProperties": true
417
+ "additionalProperties": false
292
418
  }
293
419
  },
294
420
  "trace": {
@@ -305,10 +431,47 @@
305
431
  "partial",
306
432
  "failed"
307
433
  ]
434
+ },
435
+ "friction": {
436
+ "type": "string"
437
+ },
438
+ "notes": {
439
+ "type": "string"
440
+ },
441
+ "recordedAt": {
442
+ "type": "string",
443
+ "format": "date-time"
308
444
  }
309
445
  },
310
- "additionalProperties": true
446
+ "additionalProperties": false
447
+ },
448
+ "failedAt": {
449
+ "enum": [
450
+ "research",
451
+ "plan",
452
+ "execute",
453
+ "verify",
454
+ "review"
455
+ ]
456
+ },
457
+ "failureReason": {
458
+ "type": "string"
459
+ },
460
+ "ruledOut": {
461
+ "type": "string"
462
+ },
463
+ "migratedFromSchemaVersion": {
464
+ "type": "integer",
465
+ "minimum": 1
466
+ },
467
+ "createdAt": {
468
+ "type": "string",
469
+ "format": "date-time"
470
+ },
471
+ "updatedAt": {
472
+ "type": "string",
473
+ "format": "date-time"
311
474
  }
312
475
  },
313
- "additionalProperties": true
476
+ "additionalProperties": false
314
477
  }