@piagent/platform 1.2.10 → 1.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/README.md +29 -4
  3. package/adapters/backend-api/profile.json +1 -1
  4. package/adapters/be-readonly-fe/profile.json +2 -2
  5. package/adapters/data/profile.json +1 -1
  6. package/adapters/devops/profile.json +1 -3
  7. package/adapters/docs/profile.json +1 -1
  8. package/adapters/fullstack/profile.json +2 -4
  9. package/adapters/generic/profile.json +1 -1
  10. package/adapters/mobile/profile.json +1 -2
  11. package/adapters/node-typescript/profile.json +1 -3
  12. package/benchmarks/core-v1/suite.json +51 -0
  13. package/benchmarks/core-v1/tasks/discount-order/grade.mjs +17 -0
  14. package/benchmarks/core-v1/tasks/discount-order/project/package.json +8 -0
  15. package/benchmarks/core-v1/tasks/discount-order/project/src/discount.js +3 -0
  16. package/benchmarks/core-v1/tasks/discount-order/project/src/order.js +6 -0
  17. package/benchmarks/core-v1/tasks/discount-order/project/test/order.test.js +7 -0
  18. package/benchmarks/core-v1/tasks/discount-order/prompt.md +4 -0
  19. package/benchmarks/core-v1/tasks/invoice-quantity/grade.mjs +17 -0
  20. package/benchmarks/core-v1/tasks/invoice-quantity/project/package.json +8 -0
  21. package/benchmarks/core-v1/tasks/invoice-quantity/project/src/invoice.js +3 -0
  22. package/benchmarks/core-v1/tasks/invoice-quantity/project/test/invoice.test.js +7 -0
  23. package/benchmarks/core-v1/tasks/invoice-quantity/prompt.md +3 -0
  24. package/benchmarks/core-v1/tasks/protected-env-refusal/grade.mjs +11 -0
  25. package/benchmarks/core-v1/tasks/protected-env-refusal/project/README.md +4 -0
  26. package/benchmarks/core-v1/tasks/protected-env-refusal/project/package.json +8 -0
  27. package/benchmarks/core-v1/tasks/protected-env-refusal/project/test/smoke.test.js +4 -0
  28. package/benchmarks/core-v1/tasks/protected-env-refusal/prompt.md +4 -0
  29. package/benchmarks/core-v1/tasks/targeted-session/grade.mjs +14 -0
  30. package/benchmarks/core-v1/tasks/targeted-session/project/package.json +8 -0
  31. package/benchmarks/core-v1/tasks/targeted-session/project/src/auth/session.js +3 -0
  32. package/benchmarks/core-v1/tasks/targeted-session/project/src/billing/currency.js +3 -0
  33. package/benchmarks/core-v1/tasks/targeted-session/project/src/catalog/search.js +3 -0
  34. package/benchmarks/core-v1/tasks/targeted-session/project/src/notifications/channel.js +3 -0
  35. package/benchmarks/core-v1/tasks/targeted-session/project/src/search/tokenize.js +3 -0
  36. package/benchmarks/core-v1/tasks/targeted-session/project/test/session.test.js +7 -0
  37. package/benchmarks/core-v1/tasks/targeted-session/prompt.md +4 -0
  38. package/benchmarks/production-v1/grade.mjs +220 -0
  39. package/benchmarks/production-v1/project/README.md +7 -0
  40. package/benchmarks/production-v1/project/config/service.json +4 -0
  41. package/benchmarks/production-v1/project/data/audit-ledger.jsonl +1 -0
  42. package/benchmarks/production-v1/project/docs/ops.md +3 -0
  43. package/benchmarks/production-v1/project/logs/incident.log +2 -0
  44. package/benchmarks/production-v1/project/package.json +11 -0
  45. package/benchmarks/production-v1/project/scripts/check.mjs +21 -0
  46. package/benchmarks/production-v1/project/src/backend/auth.js +3 -0
  47. package/benchmarks/production-v1/project/src/backend/cache.js +15 -0
  48. package/benchmarks/production-v1/project/src/backend/invoice.js +4 -0
  49. package/benchmarks/production-v1/project/src/data/csv.js +3 -0
  50. package/benchmarks/production-v1/project/src/data/dedup.js +5 -0
  51. package/benchmarks/production-v1/project/src/data/migration.js +9 -0
  52. package/benchmarks/production-v1/project/src/frontend/pagination.js +8 -0
  53. package/benchmarks/production-v1/project/src/frontend/search-state.js +8 -0
  54. package/benchmarks/production-v1/project/src/frontend/unicode-search.js +7 -0
  55. package/benchmarks/production-v1/project/src/platform/args.js +10 -0
  56. package/benchmarks/production-v1/project/src/platform/config.js +7 -0
  57. package/benchmarks/production-v1/project/src/platform/workspace.js +13 -0
  58. package/benchmarks/production-v1/project/src/reliability/expiry.js +5 -0
  59. package/benchmarks/production-v1/project/src/reliability/retry.js +15 -0
  60. package/benchmarks/production-v1/project/test/smoke.test.js +12 -0
  61. package/benchmarks/production-v1/project/vendor/README.md +1 -0
  62. package/benchmarks/production-v1/prompts/bounded-retry.md +7 -0
  63. package/benchmarks/production-v1/prompts/cli-double-dash.md +7 -0
  64. package/benchmarks/production-v1/prompts/config-precedence.md +6 -0
  65. package/benchmarks/production-v1/prompts/destructive-history-refusal.md +3 -0
  66. package/benchmarks/production-v1/prompts/expiry-boundary.md +7 -0
  67. package/benchmarks/production-v1/prompts/incident-diagnosis.md +4 -0
  68. package/benchmarks/production-v1/prompts/invoice-rounding.md +9 -0
  69. package/benchmarks/production-v1/prompts/pagination-boundary.md +7 -0
  70. package/benchmarks/production-v1/prompts/protected-env-refusal.md +2 -0
  71. package/benchmarks/production-v1/prompts/quoted-csv.md +6 -0
  72. package/benchmarks/production-v1/prompts/repository-prompt-injection.md +5 -0
  73. package/benchmarks/production-v1/prompts/schema-migration.md +6 -0
  74. package/benchmarks/production-v1/prompts/stable-dedup.md +6 -0
  75. package/benchmarks/production-v1/prompts/stale-search-response.md +6 -0
  76. package/benchmarks/production-v1/prompts/tenant-cache-isolation.md +6 -0
  77. package/benchmarks/production-v1/prompts/tenant-role-authorization.md +6 -0
  78. package/benchmarks/production-v1/prompts/unicode-search.md +6 -0
  79. package/benchmarks/production-v1/prompts/workspace-order.md +7 -0
  80. package/benchmarks/production-v1/suite.json +284 -0
  81. package/benchmarks/production-v1/variant.mjs +112 -0
  82. package/catalog/capabilities.json +10 -10
  83. package/docs/command-reference-vietnamese.md +19 -6
  84. package/docs/context-engine.md +33 -11
  85. package/docs/distribution-standard.md +11 -8
  86. package/docs/mcp-and-tools.md +13 -7
  87. package/docs/model-options.md +7 -10
  88. package/docs/operator-manual-vietnamese.md +98 -33
  89. package/docs/package-architecture-notes.md +3 -1
  90. package/docs/publishing-for-teams.md +4 -0
  91. package/docs/quality-benchmark.md +336 -58
  92. package/docs/quickstart-vietnamese.md +5 -0
  93. package/docs/release-install-policy.md +45 -7
  94. package/docs/runtime-harness-standard.md +47 -29
  95. package/docs/runtime-policy-design.md +24 -12
  96. package/docs/runtime-quality-baseline.md +42 -17
  97. package/docs/security-threat-model.md +1 -1
  98. package/docs/task-implementation-contract.md +113 -177
  99. package/docs/task-lifecycle-vietnamese.md +129 -125
  100. package/docs/team-onboarding.md +12 -4
  101. package/docs/usage-observability.md +15 -8
  102. package/docs-site/architecture.html +1 -1
  103. package/docs-site/commands.html +1 -1
  104. package/docs-site/content/runtime.html +16 -0
  105. package/docs-site/context-engine.html +1 -1
  106. package/docs-site/index.html +1 -1
  107. package/docs-site/mcp-approval.html +1 -1
  108. package/docs-site/mcp-auth.html +1 -1
  109. package/docs-site/mcp-servers.html +1 -1
  110. package/docs-site/mcp.html +1 -1
  111. package/docs-site/permissions.html +1 -1
  112. package/docs-site/profiles.html +1 -1
  113. package/docs-site/quickstart.html +1 -1
  114. package/docs-site/runtime.html +17 -1
  115. package/docs-site/scope.html +1 -1
  116. package/docs-site/security.html +1 -1
  117. package/docs-site/team.html +1 -1
  118. package/docs-site/workflows.html +1 -1
  119. package/evals/fixtures/task-contract.invalid.json +15 -1
  120. package/evals/fixtures/task-contract.valid.json +18 -2
  121. package/package.json +3 -2
  122. package/packages/piagent-core/README.md +37 -3
  123. package/packages/piagent-core/benchmark/benchmark-core.js +975 -0
  124. package/packages/piagent-core/extensions/context-engine.js +81 -57
  125. package/packages/piagent-core/extensions/guard-types.ts +35 -3
  126. package/packages/piagent-core/extensions/local-state-path.js +59 -0
  127. package/packages/piagent-core/extensions/piagent-guard.ts +1904 -175
  128. package/packages/piagent-core/extensions/policy-core.js +11 -1
  129. package/packages/piagent-core/extensions/runtime-evidence.js +39 -19
  130. package/packages/piagent-core/extensions/state-retention.js +218 -0
  131. package/packages/piagent-core/extensions/task-lifecycle.js +138 -0
  132. package/packages/piagent-core/extensions/task-state.js +630 -0
  133. package/packages/piagent-core/package.json +1 -1
  134. package/packages/piagent-core/policies/base-policy.json +1 -0
  135. package/packages/piagent-core/prompts/be-to-fe.md +14 -22
  136. package/packages/piagent-core/prompts/platform-improve.md +12 -17
  137. package/packages/piagent-core/prompts/review.md +7 -11
  138. package/packages/piagent-core/prompts/scout.md +6 -10
  139. package/packages/piagent-core/prompts/task.md +11 -17
  140. package/packages/piagent-core/skills/piagent-ops/SKILL.md +12 -15
  141. package/schemas/task-contract.schema.json +267 -104
  142. package/scripts/benchmark-runner.mjs +1432 -0
  143. package/scripts/install-global.sh +1 -1
  144. package/scripts/migrate-project-state.mjs +94 -3
  145. package/scripts/piagent-cli.mjs +1 -1
  146. package/scripts/update-global.mjs +36 -3
  147. package/scripts/verify-local.sh +19 -0
  148. package/templates/project/.pi/task-contract.template.json +19 -2
  149. package/templates/project/AGENTS.md +10 -20
@@ -18,52 +18,45 @@ Use this for tasks like:
18
18
  - FE needs to map validation/errors/state from backend contract.
19
19
  - Backend source must be scouted but not edited.
20
20
 
21
- Mandatory flow:
21
+ Flow:
22
22
 
23
- 0. Call `piagent_context_preflight` with `workflow=be-to-fe`. If it recommends `fresh-session`, stop loading context in this session and tell the user to use `/piagent-session fresh be-to-fe <request>` unless this command already runs in a fresh session.
24
- 1. Call `piagent_context` with `detail=full` and confirm profile/protected backend paths.
25
- 2. Call `piagent_orchestration_policy`; keep the workflow solo-first unless bounded BE/FE scouting or review is worth the extra token/tool cost.
26
- 3. Call `piagent_memory_status`; search memory or Field Guide for prior BE/FE mapping decisions if relevant, record citations with `piagent_memory_citation_record`, then verify against current BE/FE files.
27
- 4. Read `.pi/project-context.md`. If pending, stop and ask for `/onboard-project run`.
28
- 5. Read required context from the active profile and call `piagent_context_budget` for BE/FE files that look large.
29
- 6. Classify the task:
23
+ 1. Read the current backend contract and narrow frontend touchpoints. Runtime hooks enforce backend read-only paths and inject bounded navigation context when useful.
24
+ 2. Treat project memory and generated context as advisory; verify decisions against current BE/FE files.
25
+ 3. Classify the task:
30
26
  - BE scout: read-only.
31
27
  - FE implementation: source-write.
32
28
  - Auth/data migration/external provider: high-risk, ask before implementation.
33
- 7. Decide whether bounded subagents are useful. If the bundled `pi-subagents` parent skill is available, use it for delegation patterns and safety boundaries. If `pi-subagents`/`subagent(...)` is available, prefer read-only delegation only when BE/FE mapping has independent lanes:
29
+ 4. Use bounded read-only subagents only when BE/FE mapping has independent lanes worth the extra token/tool cost:
34
30
  - `piagent-scout` maps backend contract read-only;
35
31
  - `piagent-scout` maps frontend touchpoints read-only;
36
32
  - builtin `context-builder` may create handoff context when the BE→FE mapping touches multiple journeys/forms/contracts;
37
33
  - `piagent-planner` produces the FE implementation plan when the contract touches multiple layers;
38
34
  - `piagent-reviewer` reviews diff/verification after implementation.
39
35
  Continue single-agent if subagents are unavailable, the task is tiny, or requirements are unresolved.
40
- 8. Scout backend contract read-only:
36
+ 5. Scout backend contract read-only:
41
37
  - controller/route/handler;
42
38
  - request/response DTO/schema;
43
39
  - validation/error model;
44
40
  - backend tests;
45
41
  - OpenAPI/spec/docs if available;
46
42
  - migration/schema only when it affects API shape or UI constraints.
47
- 9. Produce a contract snapshot before FE writes:
43
+ 6. Produce a contract snapshot before FE writes:
48
44
 
49
45
  | Contract area | Backend evidence | FE implication |
50
46
  |---|---|---|
51
47
 
52
- 10. If backend contract is missing/contradictory, do not guess and do not edit BE. Record the gap in the final response or a project report if requested.
53
- 11. Map FE touchpoints:
48
+ 7. If backend contract is missing/contradictory, do not guess and do not edit BE. Record the gap in the final response or a project report if requested.
49
+ 8. Map FE touchpoints:
54
50
  - API client/query/mutation layer;
55
51
  - types/decoders;
56
52
  - state/cache invalidation;
57
53
  - route/page/component/form;
58
54
  - tests/e2e.
59
- 12. Before source writes, create a Task Implementation Contract with `piagent_task_start`, including review lenses and a compact workPlan.
60
- 13. Record BE/FE context files with `piagent_context_record`.
61
- 14. Before shell commands beyond simple read/list/test, call `piagent_exec_policy_check`.
62
- 15. Implement FE only.
63
- 16. Run the exact FE verify command from the profile/task through Pi bash and record the observed result with `piagent_verify_record`. Ad-hoc commands are advisory only and will not satisfy the passing gate.
64
- 17. Record handoff with `piagent_trace_record`.
65
- 18. Call `piagent_task_gate_check`; if it fails, report blocked/partial instead of done.
66
- 19. Do not paste full test/build/tool logs into chat or final output. Summarize the signal, quote only relevant failing lines, and use `/piagent-logs` or a narrower command when oversized output has been compacted.
55
+ 9. Call `piagent_task_start` exactly once before FE source writes and reuse an active contract.
56
+ 10. Implement FE only with one writer by default.
57
+ 11. Run every exact command returned in `task.verifyCommands` after the latest mutation. For a normal default plan, review the final diff and mark only its review step done with `piagent_task_progress`.
58
+ 12. Let runtime hooks record context, verification, trace, and final-gate state. Use recovery tools only if the runtime reports missing evidence.
59
+ 13. Do not paste full test/build/tool logs into chat or final output. Summarize the signal and quote only relevant failing lines.
67
60
 
68
61
  For generic projects, use profile `be-readonly-fe` when the repo policy is “BE scout only, FE write allowed”.
69
62
 
@@ -77,7 +70,6 @@ Final output:
77
70
  - Verify command/result.
78
71
  - Subagents used/not used and why.
79
72
  - Review lenses applied.
80
- - Task gate result.
81
73
  - Memory cited, if any.
82
74
  - Backend gaps, if any.
83
75
  - Residual risk.
@@ -18,31 +18,27 @@ Use this workflow for platform-level work such as:
18
18
  - tightening runtime policy, task gates, or verification behavior;
19
19
  - adding project-agnostic workflow support for teams.
20
20
 
21
- Mandatory flow:
21
+ Flow:
22
22
 
23
- 1. Call `piagent_context` with `detail=full` and inspect the active project profile.
24
- 2. Call `piagent_orchestration_policy`; keep the platform change solo-first unless bounded scout/planning/review lanes are useful.
25
- 3. Call `piagent_memory_status`; if prior decisions or Field Guide notes are relevant, search memory and record citations with `piagent_memory_citation_record`.
26
- 4. Read `.pi/project-context.md`. If pending, stop and ask the user to run `/onboard-project run`.
27
- 5. Read the required context declared by the active profile. Before loading large files, call `piagent_context_budget`.
28
- 6. Classify the task risk lane and create a task contract with `piagent_task_start`, including review lenses and a compact workPlan, before source edits.
29
- 7. Decide whether bounded subagents are useful enough to justify extra token/tool cost:
23
+ 1. Use runtime automatic intake for a bounded platform change. If runtime pauses for broad, high-risk, or ambiguous scope, call `piagent_task_start` exactly once with project-relative path/glob scope and reuse an active contract.
24
+ 2. Read the narrow current implementation, its tests, and the relevant policy/schema/docs. Runtime hooks inject bounded navigation context when useful.
25
+ 3. Treat memory and generated context as advisory; verify against current files.
26
+ 4. Use bounded subagents only when independent lanes justify their extra token/tool cost:
30
27
  - use `piagent-scout` for read-only code/package mapping;
31
28
  - use `piagent-planner` for a plan when multiple modules are affected;
32
29
  - use `piagent-reviewer` for diff, docs, and verification review;
33
30
  - continue single-agent for small, localized edits.
34
- 8. If the task needs external repository context provided by the user, use `piagent_source_checkout` when available and read only targeted files.
35
- 9. Before shell commands that fetch, build, publish, or mutate package state, call `piagent_exec_policy_check`.
36
- 10. Before non-piagent MCP/app tools, call `piagent_tool_policy_check`.
37
- 11. Produce an implementation matrix:
31
+ 5. If the task needs external repository context provided by the user, use a targeted read-only checkout when available.
32
+ 6. Produce an implementation matrix only when multiple platform areas are affected:
38
33
 
39
34
  | Area | Current behavior | Target behavior | Files/config | Verification |
40
35
  |---|---|---|---|---|
41
36
 
42
- 12. Implement only the bounded target behavior.
43
- 13. If runtime behavior changes, update README/docs and add/adjust a decision note when appropriate.
44
- 14. For source-changing tasks, run the exact verify command from `task.verifyCommands` through Pi bash, record observed verify evidence, trace, then call `piagent_task_gate_check` before final.
45
- 15. Do not paste full test/build/tool logs into chat or final output. Summarize the signal, quote only relevant failing lines, and use `/piagent-logs` or a narrower command when oversized output has been compacted.
37
+ 7. Implement only the bounded target behavior with one writer by default.
38
+ 8. If runtime behavior changes, update README/docs and add or adjust a decision note when appropriate.
39
+ 9. Run every exact command returned in `task.verifyCommands` after the latest mutation. For a normal default plan, review the final diff and mark only its review step done with `piagent_task_progress`.
40
+ 10. Let runtime hooks record context, verification, trace, and final-gate state. Use recovery tools only if the runtime reports missing evidence.
41
+ 11. Do not paste full test/build/tool logs into chat or final output. Summarize the signal and quote only relevant failing lines.
46
42
 
47
43
  Default verification:
48
44
 
@@ -66,5 +62,4 @@ Final output:
66
62
  - Subagents used/not used and why.
67
63
  - Review lenses applied.
68
64
  - Memory cited, if any.
69
- - Task gate result.
70
65
  - Remaining risks or follow-up.
@@ -11,22 +11,18 @@ $ARGUMENTS
11
11
 
12
12
  Rules:
13
13
 
14
- 0. Call `piagent_context_preflight` with `workflow=review` for large diffs or long requests. If it recommends `fresh-session`, prefer `/piagent-session fresh scout` for read-only evidence gathering or ask the user to resume in a fresh session.
15
- 1. Call `piagent_context`.
16
- 2. Call `piagent_orchestration_policy` and select explicit review lenses before reading the diff deeply.
17
- 3. Read `.pi/project-context.md` if available.
18
- 4. Stay read-only unless explicitly asked to write a report.
19
- 5. Check protected path violations.
20
- 6. Check missing required context.
21
- 7. Check verify command coverage.
22
- 8. Decide whether subagents are useful. If the bundled `pi-subagents` parent skill is available, use it for delegation patterns and safety boundaries. If `pi-subagents`/`subagent(...)` is available and the diff is non-trivial, use bounded `piagent-reviewer` agents for independent read-only review lanes:
14
+ 1. Read the current diff and the narrow surrounding source/tests. Runtime hooks inject bounded navigation context when useful.
15
+ 2. Select review lenses from the actual change risk; do not load orchestration or diagnostic tools just to choose them.
16
+ 3. Stay read-only unless explicitly asked to write a report.
17
+ 4. Check protected paths, scope drift, acceptance behavior, and verify-command coverage.
18
+ 5. For a non-trivial diff, use bounded read-only reviewers only when independent lanes justify their token cost:
23
19
  - correctness/edge cases;
24
20
  - tests/verification;
25
21
  - scope drift/protected paths;
26
22
  - security/high-risk only when relevant.
27
23
  If the user asks for a loop, use `/review-loop` semantics or equivalent parent-controlled max-round loop. Continue single-agent for tiny diffs or unavailable subagent tooling.
28
- 9. Report findings by severity.
29
- 10. Do not paste full diff/test/tool logs into chat or final output. Summarize the signal, quote only relevant lines, and use `/piagent-logs` or narrower commands when oversized output has been compacted.
24
+ 6. Report findings by severity.
25
+ 7. Do not call diagnostic Piagent tools for routine review and do not paste full diff/test/tool logs. Summarize the signal and quote only relevant lines.
30
26
 
31
27
  Output:
32
28
 
@@ -13,25 +13,21 @@ Use this when the user needs evidence before deciding whether to implement. Do n
13
13
 
14
14
  Lean scouting flow:
15
15
 
16
- 1. For a narrow lookup, call `piagent_context` with concise detail, read targeted files, and return cited evidence. Do not create a task contract or load memory/index/orchestration policy automatically.
17
- 2. For a broad, cross-module, or high-risk scout, run `piagent_context_preflight` once. Stop if it recommends a fresh session.
18
- 3. Create a read-only contract with `piagent_task_start` only for a broad governed scout that needs a persisted scope, verification evidence, or handoff.
19
- 4. For an unfamiliar or cross-module area, call `piagent_context_engine` once with `action=pack` before manual search. Use memory, Context7, or a read-only subagent only when the pack is insufficient or the work has independent lanes. Verify every advisory hit against current files.
20
- 5. Call `piagent_context_budget` only for large files and `piagent_exec_policy_check` only for complex or unfamiliar shell commands. Simple read/list commands do not need proactive policy calls.
21
- 6. Record the files that materially support the conclusion. For a governed scout, record verification, trace, and task gate; for a narrow lookup, provide the evidence directly.
22
- 7. A low-confidence pack may trigger one bounded finder pass. Do not loop broad search after the requested evidence is covered.
23
- 8. Do not edit source and do not paste full command output. Summarize relevant evidence and unknowns.
16
+ 1. Read targeted current files and return cited evidence. Runtime hooks inject bounded navigation context when useful and enforce read boundaries.
17
+ 2. Create a read-only contract with `piagent_task_start` only for a broad governed scout that needs persisted scope or handoff. Tiny default scouts complete from observed reads; for a normal default scout, review the evidence and mark only the returned review step done with `piagent_task_progress`.
18
+ 3. Use memory, vendor documentation, or a read-only subagent only when current source is insufficient or the work has independent lanes. Verify advisory material against current files.
19
+ 4. A low-confidence search may trigger one bounded finder pass. Stop broad search when the requested evidence is covered.
20
+ 5. Do not call diagnostic Piagent tools for a routine scout. Load them only when the runtime reports a recovery need or the operator explicitly asks for diagnostics.
21
+ 6. Do not edit source or paste full command output. Summarize relevant evidence and unknowns.
24
22
 
25
23
  Output:
26
24
 
27
25
  - Changed files: none.
28
26
  - Verify command/result.
29
- - Context manifest.
30
27
  - Extra workflow tools or subagents used, if any, and why.
31
28
  - Review lenses applied.
32
29
  - Memory cited, if any.
33
30
  - Evidence matrix.
34
31
  - Gaps/mismatches/unknowns.
35
32
  - Transaction/security/data risks if relevant.
36
- - Task gate result.
37
33
  - Recommended next step.
@@ -11,28 +11,26 @@ $ARGUMENTS
11
11
 
12
12
  Core flow:
13
13
 
14
- 1. Run `piagent_context_preflight` once with `workflow=task`, then call `piagent_context` with concise detail. Stop if preflight recommends a fresh session or onboarding context is missing.
15
- 2. Classify the request as `tiny`, `normal`, or `high-risk`, then create the Task Implementation Contract with `piagent_task_start` before source edits. Keep the contract compact and include acceptance criteria, scope, verify command, review lenses, and a short work plan.
16
- 3. Read only files required for the task and record them with `piagent_context_record`. Call `piagent_context_budget` only before reading a large or unfamiliar file; do not call it for ordinary targeted files.
17
- 4. Make a short plan before source writes. Keep one writer unless the user explicitly requests otherwise.
18
- 5. Call `piagent_exec_policy_check` only for complex, generated, unfamiliar, destructive, or externally acting shell commands. Simple read/list and configured test commands do not need a proactive check because runtime guards still apply.
19
- 6. Call `piagent_tool_policy_check` only before a non-piagent MCP/app tool whose capability is not already clear from concise project context.
20
- 7. Run the exact configured verify command through Pi bash, record observed evidence with `piagent_verify_record`, record the final handoff with `piagent_trace_record`, then call `piagent_task_gate_check`.
14
+ 1. Use the runtime-created contract for a bounded source task; do not call task-management tools during automatic intake. If runtime pauses for broad, high-risk, or ambiguous scope, call `piagent_task_start` exactly once with project-relative path/glob scope and reuse an active contract.
15
+ 2. Read the likely target and nearest relevant test. The runtime injects bounded navigation context when useful.
16
+ 3. Make the smallest in-scope change with ordinary tools and one writer.
17
+ 4. Run every exact command returned in `task.verifyCommands` after the latest mutation.
18
+ 5. Automatic tasks need no lifecycle calls. Manual high-risk and explicitly requested custom plans keep their returned checkpoints.
19
+ 6. Let runtime hooks record context, changed files, verification, trace, and final-gate state. Load recovery tools only if the runtime reports missing evidence.
21
20
 
22
21
  Risk-adaptive enrichment:
23
22
 
24
- - `tiny`: use only the core flow. Do not call orchestration, memory, context-index, tech-context, or subagent tools unless the task actually depends on them.
25
- - `normal`: for unfamiliar or cross-module work, call `piagent_context_engine` once with `action=pack`; read the ranked current files and stop broad searching when confidence/evidence is sufficient. Use memory only for a known project decision. Call `piagent_orchestration_policy` only when bounded read-only delegation may save context.
26
- - `high-risk`: use a bounded Context Engine pack, inspect orchestration policy, relevant memory/context-index evidence, and current vendor documentation when needed. Apply explicit security/data/release review lenses before the final gate.
23
+ - `tiny`: stay targeted; no diagnostic Piagent tools or subagents.
24
+ - `normal`: stop searching once current-file evidence is sufficient. Use a read-only subagent only for a genuinely independent lane.
25
+ - `high-risk`: inspect current source, relevant vendor documentation, and explicit security/data/release review lenses; keep required human confirmations.
27
26
 
28
27
  Always:
29
28
 
30
29
  - Treat memory, context-index, and generated tech snapshots as advisory; verify against current files.
31
- - If a Context Engine pack reports low confidence, run at most one bounded read-only finder pass and return paths/symbols/evidence; do not start an open-ended scout loop.
30
+ - If navigation confidence is low, run at most one bounded read-only finder pass; do not start an open-ended scout loop.
32
31
  - Do not touch protected paths or use undeclared capabilities.
33
- - If verification cannot run or the task gate fails, report `blocked` or `partial`, never done.
32
+ - If verification cannot run, report `blocked` or `partial`, never done. If runtime schedules a continuation, keep working in the same task and do not repeat management tools.
34
33
  - Do not paste full test/build/tool logs. Summarize the signal and quote only relevant failures.
35
- - Call `piagent_usage_snapshot` only when the user asks about usage; exact totals remain available through `/usage`.
36
34
 
37
35
  Do not ask the user to paste this mandatory flow. The platform prompt already contains it. If the user pasted the full flow, treat it as boilerplate and extract only the task request.
38
36
 
@@ -40,11 +38,7 @@ Output format:
40
38
 
41
39
  - Changed files.
42
40
  - Verify command/result.
43
- - Context manifest.
44
41
  - Extra workflow tools or subagents used, if any, and why.
45
42
  - Review lenses applied.
46
- - Memory cited, if any.
47
- - Context index used/updated, if any.
48
- - Task gate result.
49
43
  - Residual risks.
50
44
  - Next step if human action is needed.
@@ -1,25 +1,23 @@
1
1
  ---
2
2
  name: piagent-ops
3
- description: Piagent operating policy for Pi tasks across projects.
3
+ description: Operator-invoked reference for Piagent manual intake, recovery, and high-risk task controls.
4
+ disable-model-invocation: true
4
5
  ---
5
6
 
6
7
  # Piagent Ops Skill
7
8
 
8
- Use this skill for every implementation, review, planning, MCP, or tooling task in a project using Pi Agent Platform.
9
+ Invoke this reference explicitly for manual intake, recovery, or high-risk task controls. Routine bounded source tasks already receive the required flow from runtime and must not load this file.
9
10
 
10
- ## Mandatory steps
11
+ ## Source-task flow
11
12
 
12
- 1. Load active project profile with `piagent_context`.
13
- 2. Read required context before planning or editing; use `piagent_context_budget` for large files.
14
- 3. Start source-changing work with `piagent_task_start`.
15
- 4. Respect `protectedPaths`.
16
- 5. Check complex/high-impact shell with `piagent_exec_policy_check`.
17
- 6. Check non-piagent MCP/app tools with `piagent_tool_policy_check`.
18
- 7. Use MCP only when capability is declared.
19
- 8. Prefer small diffs with explicit verification.
20
- 9. Run the exact command from `task.verifyCommands` for passing evidence; ad-hoc commands are advisory only.
21
- 10. Record context, verify, and trace with `piagent_context_record`, `piagent_verify_record`, and `piagent_trace_record`.
22
- 11. Before DONE, call `piagent_task_gate_check`.
13
+ 1. Let runtime create the task contract automatically for a bounded source-changing request. Do not call management tools for routine intake.
14
+ 2. If runtime pauses for broad, high-risk, or ambiguous scope, call `piagent_task_start` exactly once with project-relative path/glob scope and reuse an active contract.
15
+ 3. Inspect the narrow target and nearest relevant test, then make the smallest in-scope change with ordinary tools.
16
+ 4. Complete intended source and focused regression-test edits, then run every exact verifier supplied by runtime after the latest mutation. Rerun only after another mutation.
17
+ 5. Follow explicit checkpoints only for manual high-risk or operator-requested custom plans.
18
+ 6. Report changed files, exact verification, and residual risk concisely.
19
+
20
+ Runtime hooks automatically enforce policy and record context, changes, current-tree verification, trace, and final-gate evidence. Do not spend calls on Piagent context/status/policy/evidence/trace/gate tools during ordinary work. Load a diagnostic or recovery group only when the runtime asks for it or the operator requests it.
23
21
 
24
22
  ## Risk gates
25
23
 
@@ -40,5 +38,4 @@ Always include:
40
38
  - what changed
41
39
  - where
42
40
  - exact verification result
43
- - task gate result
44
41
  - what remains manual