@piagent/platform 1.0.0
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.
- package/.gitattributes +7 -0
- package/AGENTS.md +31 -0
- package/CHANGELOG.md +296 -0
- package/CODE_OF_CONDUCT.md +36 -0
- package/CONTRIBUTING.md +66 -0
- package/LICENSE +21 -0
- package/README.md +588 -0
- package/SECURITY.md +38 -0
- package/adapters/backend-api/profile.json +88 -0
- package/adapters/be-readonly-fe/profile.json +120 -0
- package/adapters/data/profile.json +88 -0
- package/adapters/devops/profile.json +92 -0
- package/adapters/docs/profile.json +74 -0
- package/adapters/fullstack/profile.json +94 -0
- package/adapters/generic/profile.json +95 -0
- package/adapters/mobile/profile.json +87 -0
- package/adapters/node-typescript/profile.json +76 -0
- package/adapters/python/profile.json +75 -0
- package/adapters/web-frontend/profile.json +101 -0
- package/catalog/capabilities.json +206 -0
- package/docs/architecture.md +64 -0
- package/docs/auto-delegation-policy.md +192 -0
- package/docs/capability-packs.md +234 -0
- package/docs/command-reference-vietnamese.md +484 -0
- package/docs/context-window-policy.md +85 -0
- package/docs/distribution-standard.md +229 -0
- package/docs/herdr-workflow.md +58 -0
- package/docs/mcp-and-tools.md +316 -0
- package/docs/memory-policy.md +164 -0
- package/docs/model-options.md +165 -0
- package/docs/oauth-providers.md +53 -0
- package/docs/operator-manual-vietnamese.md +1080 -0
- package/docs/package-architecture-notes.md +101 -0
- package/docs/project-adapters.md +174 -0
- package/docs/project-onboarding.md +135 -0
- package/docs/publishing-for-teams.md +64 -0
- package/docs/quality-benchmark.md +74 -0
- package/docs/quickstart-vietnamese.md +350 -0
- package/docs/release-install-policy.md +223 -0
- package/docs/runtime-harness-standard.md +118 -0
- package/docs/runtime-policy-design.md +132 -0
- package/docs/runtime-quality-baseline.md +257 -0
- package/docs/security-redaction-benchmark.md +56 -0
- package/docs/security-threat-model.md +66 -0
- package/docs/subagent-orchestration-capabilities.md +104 -0
- package/docs/subagents-and-multiagent.md +346 -0
- package/docs/task-implementation-contract.md +200 -0
- package/docs/team-onboarding.md +333 -0
- package/docs/usage-observability.md +130 -0
- package/docs/vercel-docs-site.md +115 -0
- package/docs/workflow-recipes.md +125 -0
- package/docs-site/assets/piagent-logo.svg +35 -0
- package/docs-site/favicon.svg +18 -0
- package/docs-site/index.html +1613 -0
- package/docs-site/vercel.json +24 -0
- package/evals/fixtures/action-proposal.invalid.json +34 -0
- package/evals/fixtures/action-proposal.valid.json +34 -0
- package/evals/fixtures/capability-pack.invalid.json +123 -0
- package/evals/fixtures/capability-pack.valid.json +123 -0
- package/evals/fixtures/capability-recipe.invalid.json +81 -0
- package/evals/fixtures/capability-recipe.valid.json +82 -0
- package/evals/fixtures/context-index.invalid.json +25 -0
- package/evals/fixtures/context-index.valid.json +25 -0
- package/evals/fixtures/eval-scenario.invalid.json +40 -0
- package/evals/fixtures/eval-scenario.valid.json +45 -0
- package/evals/fixtures/project-profile.invalid.json +88 -0
- package/evals/fixtures/project-profile.valid.json +95 -0
- package/evals/fixtures/task-contract.invalid.json +73 -0
- package/evals/fixtures/task-contract.valid.json +74 -0
- package/evals/golden/enforcement-decisions.json +329 -0
- package/evals/scenarios/capability-resolution.json +45 -0
- package/package.json +132 -0
- package/packages/piagent-core/README.md +147 -0
- package/packages/piagent-core/capabilities/capability-core.js +1023 -0
- package/packages/piagent-core/capabilities/capability-sources.js +265 -0
- package/packages/piagent-core/extensions/guard-io.js +45 -0
- package/packages/piagent-core/extensions/guard-shell-analysis.ts +558 -0
- package/packages/piagent-core/extensions/guard-types.ts +406 -0
- package/packages/piagent-core/extensions/piagent-guard.ts +5760 -0
- package/packages/piagent-core/extensions/policy-core.js +1070 -0
- package/packages/piagent-core/extensions/redaction-core.js +4 -0
- package/packages/piagent-core/extensions/runtime-evidence.js +215 -0
- package/packages/piagent-core/package.json +46 -0
- package/packages/piagent-core/policies/base-policy.json +249 -0
- package/packages/piagent-core/prompts/be-to-fe.md +82 -0
- package/packages/piagent-core/prompts/commit.md +27 -0
- package/packages/piagent-core/prompts/discuss.md +35 -0
- package/packages/piagent-core/prompts/memory-policy.md +52 -0
- package/packages/piagent-core/prompts/model-options.md +68 -0
- package/packages/piagent-core/prompts/onboard-project.md +147 -0
- package/packages/piagent-core/prompts/piagent-commands.md +68 -0
- package/packages/piagent-core/prompts/plan.md +35 -0
- package/packages/piagent-core/prompts/platform-improve.md +69 -0
- package/packages/piagent-core/prompts/pr.md +26 -0
- package/packages/piagent-core/prompts/review.md +38 -0
- package/packages/piagent-core/prompts/scout.md +50 -0
- package/packages/piagent-core/prompts/task.md +69 -0
- package/packages/piagent-core/security/sensitive-data.js +187 -0
- package/packages/piagent-core/skills/piagent-ops/SKILL.md +44 -0
- package/packages/piagent-core/skills/piagent-source-cache/SKILL.md +59 -0
- package/packages/piagent-core/skills/piagent-source-cache/checkout-source-repo.sh +144 -0
- package/packages/piagent-core/subagents/piagent-oracle.md +29 -0
- package/packages/piagent-core/subagents/piagent-planner.md +46 -0
- package/packages/piagent-core/subagents/piagent-reviewer.md +48 -0
- package/packages/piagent-core/subagents/piagent-scout.md +37 -0
- package/packages/piagent-core/subagents/piagent-worker.md +44 -0
- package/packs/engineering-base/pack.json +123 -0
- package/packs/engineering-base/recipes/bounded-change.json +82 -0
- package/packs/web-delivery/pack.json +72 -0
- package/packs/web-delivery/recipes/verified-web-change.json +57 -0
- package/schemas/action-proposal.schema.json +90 -0
- package/schemas/capability-pack.schema.json +190 -0
- package/schemas/capability-recipe.schema.json +72 -0
- package/schemas/context-index.schema.json +258 -0
- package/schemas/eval-scenario.schema.json +67 -0
- package/schemas/project-profile.schema.json +555 -0
- package/schemas/task-contract.schema.json +314 -0
- package/scripts/audit-runtime-host.sh +78 -0
- package/scripts/bootstrap-local.sh +25 -0
- package/scripts/capability-catalog.mjs +290 -0
- package/scripts/check-runtime-advisories.mjs +114 -0
- package/scripts/configure-mcp.sh +301 -0
- package/scripts/configure-model-scope.sh +143 -0
- package/scripts/configure-subagents.sh +241 -0
- package/scripts/import-agent-instructions.mjs +199 -0
- package/scripts/init-project.sh +369 -0
- package/scripts/install-global.sh +532 -0
- package/scripts/link-project.sh +25 -0
- package/scripts/migrate-project-state.mjs +176 -0
- package/scripts/pi-auto.sh +79 -0
- package/scripts/pi-model-catalog.sh +154 -0
- package/scripts/pi-session-stats.sh +135 -0
- package/scripts/piagent-cli.mjs +53 -0
- package/scripts/profile-doctor.sh +238 -0
- package/scripts/quality-benchmark.sh +185 -0
- package/scripts/redaction-benchmark.mjs +227 -0
- package/scripts/runtime-policy-smoke.sh +48 -0
- package/scripts/setup.sh +425 -0
- package/scripts/team-doctor.sh +461 -0
- package/scripts/verify-local.sh +540 -0
- package/scripts/verify-release-identity.mjs +85 -0
- package/scripts/verify-vercel-link.mjs +64 -0
- package/templates/global/mcp.json +9 -0
- package/templates/global/settings.json +37 -0
- package/templates/project/.mcp.json +9 -0
- package/templates/project/.pi/context-index.json +25 -0
- package/templates/project/.pi/gitignore.template +22 -0
- package/templates/project/.pi/mcp.json +9 -0
- package/templates/project/.pi/memory/MEMORY.md +11 -0
- package/templates/project/.pi/memory/memory_summary.md +9 -0
- package/templates/project/.pi/piagent-profile.json +107 -0
- package/templates/project/.pi/project-context.md +30 -0
- package/templates/project/.pi/settings.json +17 -0
- package/templates/project/.pi/task-contract.template.json +74 -0
- package/templates/project/.pi/tech-context/README.md +7 -0
- package/templates/project/.pi/tech-stack.json +10 -0
- package/templates/project/AGENTS.md +34 -0
- package/templates/project/REVIEW_GUIDELINES.md +23 -0
- package/types/pi-runtime-shims.d.ts +13 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Runtime policy design
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Runtime policy là lớp kiểm soát cách agent đọc context, gọi tool, sửa source, chạy verify, và kết thúc task. Tài liệu này mô tả thiết kế trung lập của Pi Agent Platform, không phụ thuộc vào một project cụ thể.
|
|
6
|
+
|
|
7
|
+
## Design principles
|
|
8
|
+
|
|
9
|
+
1. Profile first: mọi task phải biết project mode, permission profile, protected paths, required context, verify commands, và MCP capabilities.
|
|
10
|
+
2. Bounded context: file lớn phải qua budget check; context manifest phải ghi lý do.
|
|
11
|
+
3. Guarded execution: shell/destructive actions đi qua exec policy. Đây là accident brake, không phải OS sandbox.
|
|
12
|
+
4. Tool capability: tool ngoài phải map vào capability được profile cho phép.
|
|
13
|
+
5. Evidence before done: source-changing task phải có verify evidence và trace.
|
|
14
|
+
6. Human gate for high risk: auth, release, deploy, destructive command, provider config, database migration, production data, broad Git staging, hoặc external Git/GitHub write action cần explicit confirmation.
|
|
15
|
+
|
|
16
|
+
## Runtime modules
|
|
17
|
+
|
|
18
|
+
| Module | Tool/hook | Purpose |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| Project context | `piagent_context` | Load profile, settings, policy, and local state summary. |
|
|
21
|
+
| Context index | `piagent_context_index_status/search/record` | Maintain a compact advisory node/edge/citation map for profile/project/tech/task navigation. |
|
|
22
|
+
| Permission profile | `piagent_permission_status` | Show active `read-only`, `workspace-write`, or `trusted-full-access` boundary. |
|
|
23
|
+
| Exec policy | `piagent_exec_policy_check` | Evaluate shell command risk before execution. |
|
|
24
|
+
| Context budget | `piagent_context_budget` | Enforce size/count limits for context files. |
|
|
25
|
+
| Tool registry | `piagent_tool_policy_check` | Check external tool capability against profile. |
|
|
26
|
+
| Task contract | `piagent_task_start` | Persist scope, acceptance criteria, risk lane, and verify plan. |
|
|
27
|
+
| Context manifest | `piagent_context_record` | Record files read for a task. |
|
|
28
|
+
| Verify evidence | `piagent_verify_record` | Record command result only after matching an observed Pi `bash` tool result after task start. |
|
|
29
|
+
| Final gate | `piagent_task_gate_check` | Validate readiness before final handoff. |
|
|
30
|
+
| Trace | `piagent_trace_record` | Persist changed files, outcome, and handoff state. |
|
|
31
|
+
| Usage | `piagent_usage_snapshot` | Show session/context/token usage when available. |
|
|
32
|
+
|
|
33
|
+
## Policy precedence
|
|
34
|
+
|
|
35
|
+
Effective policy is derived from:
|
|
36
|
+
|
|
37
|
+
1. safe defaults in `packages/piagent-core/policies/base-policy.json`;
|
|
38
|
+
2. installed package prompts/skills/extensions;
|
|
39
|
+
3. project `.pi/piagent-profile.json`;
|
|
40
|
+
4. explicit user instruction in the active session.
|
|
41
|
+
|
|
42
|
+
User instruction can narrow scope or raise safety requirements. It should not silently bypass protected paths, destructive command checks, or final task gates.
|
|
43
|
+
|
|
44
|
+
## Profiles
|
|
45
|
+
|
|
46
|
+
Profiles define:
|
|
47
|
+
|
|
48
|
+
- `mode`
|
|
49
|
+
- `permissionProfile`
|
|
50
|
+
- `rootMarkers`
|
|
51
|
+
- `protectedPaths`
|
|
52
|
+
- `shellProtectedPaths` — shell-only deny list for bash/exec parsing.
|
|
53
|
+
- `readOnlyPaths` — path tools may read, but write/edit and shell access are denied.
|
|
54
|
+
- `requiredContext`
|
|
55
|
+
- `verifyCommands`
|
|
56
|
+
- `mcpCapabilities`
|
|
57
|
+
- `runtimePolicy`
|
|
58
|
+
- `hardGates`
|
|
59
|
+
|
|
60
|
+
The same platform can operate as `web-frontend`, `backend-api`, `fullstack`, `be-readonly-fe`, `data`, `devops`, `docs`, `python`, `node-typescript`, or `mobile` by switching profile.
|
|
61
|
+
|
|
62
|
+
`protectedPaths` blocks read/write path-tool access and is also used for shell matching when `shellProtectedPaths` is omitted. `readOnlyPaths` is for contracts such as `be-readonly-fe`: path tools may inspect these files with `read`, `grep`, `find`, and `ls`, but write/edit and shell access are blocked automatically.
|
|
63
|
+
|
|
64
|
+
`shellProtectedPaths` is intentionally shell-only. A path declared only there blocks `bash`/`exec` access, but does not block `read`, `write`, or `edit` path tools. `profile-doctor` and `team-doctor` warn on shell-only entries so older custom profiles can migrate write-sensitive paths to `protectedPaths` or `readOnlyPaths`.
|
|
65
|
+
|
|
66
|
+
## Permission profiles
|
|
67
|
+
|
|
68
|
+
The runtime separates the active autonomy profile from the project profile:
|
|
69
|
+
|
|
70
|
+
| Profile | Meaning |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `read-only` | Allows source inspection through `read`, `grep`, `find`, `ls`, plus piagent state tools. Blocks shell, write/edit, and unknown non-piagent tools before execution. |
|
|
73
|
+
| `workspace-write` | Default governed implementation mode. Existing protected-path, shell, capability, context, verify, and final gates remain active. |
|
|
74
|
+
| `trusted-full-access` | Trusted automation mode for known repos. It can relax tool-registry blocks and capability filesystem scopes inside the guard, but protected paths, secret redaction, capability-lock integrity, and destructive/external confirmation still apply. |
|
|
75
|
+
|
|
76
|
+
`PIAGENT_PERMISSION_PROFILE` can override the profile for a single run. Invalid values fail closed to `read-only`. Inside Pi, `/read-only`, `/workspace-write`, and `/full-access` set a session-local override without writing the project profile. Precedence is launch env, then session command, then project profile, then policy default. `permissionProfiles.allowedModes` in base policy acts like a managed allowlist; removing `trusted-full-access` from that list disables it for the installation.
|
|
77
|
+
|
|
78
|
+
## Task lifecycle
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
intake
|
|
82
|
+
-> profile/context
|
|
83
|
+
-> task contract
|
|
84
|
+
-> context manifest
|
|
85
|
+
-> plan
|
|
86
|
+
-> guarded implementation
|
|
87
|
+
-> observed verify evidence
|
|
88
|
+
-> trace
|
|
89
|
+
-> final gate
|
|
90
|
+
-> handoff
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This lifecycle is intentionally explicit. It makes task quality auditable and avoids relying on a long prompt as the only control layer.
|
|
94
|
+
|
|
95
|
+
## Verify evidence ledger
|
|
96
|
+
|
|
97
|
+
Pi `bash` results are observed through the runtime `tool_result` hook and appended to:
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
.pi/piagent-state/observed-bash.jsonl
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The ledger stores cwd, timestamp, status, a hash of the normalized command, and redacted command text for audit. It does not need the raw command text to validate a later `piagent_verify_record` call.
|
|
104
|
+
|
|
105
|
+
This file-based ledger is intentionally shared by parent and subagent processes that run in the same project cwd. If a worker subagent runs `npm test`, the parent can later record that exact verify command without depending on process-local memory.
|
|
106
|
+
|
|
107
|
+
The ledger and task/profile control files are self-protected:
|
|
108
|
+
|
|
109
|
+
- raw path-like tool access to `.pi/piagent-state/**` is blocked before execution;
|
|
110
|
+
- raw path-like tool access to `.pi/piagent-profile.json` is blocked before execution;
|
|
111
|
+
- the same protected-path gate covers Pi built-ins such as `read`, `write`, `edit`, `grep`, `find`, `ls`;
|
|
112
|
+
- custom/MCP tools are also blocked when a tool call contains path-like strings pointing at a protected path, including nested objects, arrays, and `file://` URIs;
|
|
113
|
+
- path-like strings are percent-decoded once before matching;
|
|
114
|
+
- input nesting above `MAX_TOOL_INPUT_INSPECTION_DEPTH=32` fails closed because an uninspectable input cannot be safely classified;
|
|
115
|
+
- generic extraction skips known leaf content fields such as `content`, `query`, `pattern`, `text`, and `command`, so normal search/edit strings do not become path false positives;
|
|
116
|
+
- `grep.glob` and `find.pattern` are checked when they explicitly name protected targets such as `.env*`, `auth.json`, `.pi/piagent-state/**`, or `piagent-profile.json`;
|
|
117
|
+
- broad `grep`, `find`, and `ls` results are filtered through the `tool_result` hook so protected content lines or protected path metadata are redacted before the model sees them;
|
|
118
|
+
- piagent tools still write/read these files through internal extension code, so normal task evidence and profile workflows continue to work.
|
|
119
|
+
|
|
120
|
+
This gate is independent from the tool registry. The registry can stay `advisory` for compatibility with changing Pi/MCP tool names, while protected-path access remains fail-closed whenever the event exposes a path-like input.
|
|
121
|
+
|
|
122
|
+
Final-gate semantics are stricter than simple observation:
|
|
123
|
+
|
|
124
|
+
- `observed=true`: Pi actually saw a matching bash result after `task.createdAt`;
|
|
125
|
+
- `matchedProfileCommand=true`: the command exactly matches one entry in `task.verifyCommands`;
|
|
126
|
+
- passing final gate: requires `observed=true`, `matchedProfileCommand=true`, and `exitCode=0`.
|
|
127
|
+
|
|
128
|
+
Ad-hoc commands can still be recorded for traceability, but they do not satisfy the passing verify gate unless they are part of the task verify plan. Exact matching is deliberate; if the task says `npm test`, record `npm test`, not `npm test || true` or `npm test`.
|
|
129
|
+
|
|
130
|
+
## Benchmark discipline
|
|
131
|
+
|
|
132
|
+
Quality/token/cost claims must be recorded through `scripts/quality-benchmark.sh` or equivalent project evidence. The benchmark unit is a real task scenario with the same acceptance criteria and verification command.
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# Runtime quality baseline
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Runtime quality baseline định nghĩa bộ kiểm soát để Pi Agent Platform có thể chạy task một cách có kỷ luật cho solo, internal team, và public package.
|
|
6
|
+
|
|
7
|
+
Các module chính:
|
|
8
|
+
|
|
9
|
+
1. Permission profile
|
|
10
|
+
2. Exec policy
|
|
11
|
+
3. Context budget
|
|
12
|
+
4. Tool registry
|
|
13
|
+
5. Final task gate
|
|
14
|
+
6. Local verification
|
|
15
|
+
7. Quality benchmark
|
|
16
|
+
|
|
17
|
+
Trạng thái hiện tại: platform đã có runtime modules đủ cho guarded implementation task. Các tuyên bố về chất lượng, token, cost, hoặc tốc độ phải dựa trên benchmark theo project/model thật.
|
|
18
|
+
|
|
19
|
+
## 0. Permission profile
|
|
20
|
+
|
|
21
|
+
Tool:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
piagent_permission_status
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Runtime behavior:
|
|
28
|
+
|
|
29
|
+
- `read-only` chặn shell, write/edit, và unknown non-piagent tools;
|
|
30
|
+
- `workspace-write` là default cho implementation có guard;
|
|
31
|
+
- `trusted-full-access` nới tool/scope autonomy trong môi trường trusted nhưng không tắt protected paths, redaction, capability lock, hoặc human gate cho destructive/external action.
|
|
32
|
+
- `/full-access <task>` bật `trusted-full-access` cho session hiện tại rồi gửi phần task còn lại cho agent; `/permission-status` hiển thị mode và boundary đang active.
|
|
33
|
+
|
|
34
|
+
## 1. Exec policy
|
|
35
|
+
|
|
36
|
+
Tool:
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
piagent_exec_policy_check
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Runtime behavior:
|
|
43
|
+
|
|
44
|
+
- phân tích shell command trước khi chạy lệnh rủi ro;
|
|
45
|
+
- block destructive patterns;
|
|
46
|
+
- đệ quy vào shell wrapper phổ biến như `sudo`, `env`, `bash -c`, subshell, command substitution, và backtick;
|
|
47
|
+
- check `shellProtectedPaths` cho bash, mặc định bảo vệ `.git`, `auth.json`, `.env`, `.env.*`; path chỉ nằm trong `shellProtectedPaths` là shell-only và không chặn write/edit;
|
|
48
|
+
- kiểm tra cả bare filename, partial glob (`*`, `?`, character class, brace), symbolic-link alias đã canonicalize, và redirect shell có hoặc không có khoảng trắng;
|
|
49
|
+
- redact sensitive text trong text result và JSON-like result details trước khi output được trả về model; non-text media block được giữ nguyên;
|
|
50
|
+
- cảnh báo broad command prefix như `bash`, `python`, `node`, `git`, `sudo`;
|
|
51
|
+
- áp dụng policy rule `allow | prompt | forbid`;
|
|
52
|
+
- ghi lý do để agent/human đánh giá trước khi tiếp tục.
|
|
53
|
+
|
|
54
|
+
Config:
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
packages/piagent-core/policies/base-policy.json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Mục tiêu không phải cấm mọi command mạnh hoặc thay thế sandbox OS. Đây là lớp phanh chống tai nạn: giảm rủi ro agent tự ý chạy lệnh có tác động cao, đọc secret, hoặc đụng protected path mà thiếu policy/human gate.
|
|
61
|
+
|
|
62
|
+
## 2. Context budget
|
|
63
|
+
|
|
64
|
+
Tool:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
piagent_context_budget
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Runtime behavior:
|
|
71
|
+
|
|
72
|
+
- giới hạn số file trong context manifest;
|
|
73
|
+
- giới hạn kích thước file context;
|
|
74
|
+
- cảnh báo fragment lớn;
|
|
75
|
+
- buộc context phải có lý do đọc rõ ràng.
|
|
76
|
+
|
|
77
|
+
Default:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"maxContextFileChars": 50000,
|
|
82
|
+
"maxMemoryFileChars": 20000,
|
|
83
|
+
"maxManifestFiles": 80,
|
|
84
|
+
"warnFragmentChars": 4000
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Context nên được chọn theo profile/task, không đọc tràn toàn repo.
|
|
89
|
+
|
|
90
|
+
## 3. Tool registry
|
|
91
|
+
|
|
92
|
+
Tool:
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
piagent_tool_policy_check
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Runtime behavior:
|
|
99
|
+
|
|
100
|
+
- map tools sang capability như `filesystem-readonly`, `filesystem-write`, `shell`, `github`, `browser`;
|
|
101
|
+
- `piagent_*` tools luôn allowed;
|
|
102
|
+
- default `advisory` để không phá Pi runtime khi tool names thay đổi;
|
|
103
|
+
- project ổn định có thể nâng `toolRegistry=enforce`.
|
|
104
|
+
|
|
105
|
+
Profile capability ví dụ:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"mcpCapabilities": [
|
|
110
|
+
"filesystem-readonly",
|
|
111
|
+
"filesystem-write",
|
|
112
|
+
"shell",
|
|
113
|
+
"github",
|
|
114
|
+
"browser",
|
|
115
|
+
"memory"
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 4. Final task gate
|
|
121
|
+
|
|
122
|
+
Tool:
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
piagent_task_gate_check
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Runtime behavior:
|
|
129
|
+
|
|
130
|
+
- kiểm tra task contract;
|
|
131
|
+
- kiểm tra context manifest;
|
|
132
|
+
- kiểm tra verify evidence đã đối chiếu với Pi `bash` `tool_result` thật;
|
|
133
|
+
- yêu cầu observed passing verify khớp exact `task.verifyCommands` khi task có source changes;
|
|
134
|
+
- block `piagent_trace_record completed` nếu final gate đang enforce và proof chưa đủ.
|
|
135
|
+
|
|
136
|
+
Agent vẫn phải gọi `piagent_task_gate_check` trước final handoff.
|
|
137
|
+
|
|
138
|
+
`piagent_verify_record` không còn tin `exitCode` tự khai báo. Lệnh verify phải khớp một bash tool result đã quan sát sau `task.createdAt`, và claimed `exitCode` phải khớp trạng thái `isError` của Pi. Observed result được ghi vào `.pi/piagent-state/observed-bash.jsonl` để parent/subagent process có thể share evidence trong cùng project cwd.
|
|
139
|
+
|
|
140
|
+
Gate phân biệt hai mức:
|
|
141
|
+
|
|
142
|
+
- observed evidence: command thật sự đã chạy qua Pi bash;
|
|
143
|
+
- profile-matched evidence: command đó exact-match một dòng trong `task.verifyCommands`.
|
|
144
|
+
|
|
145
|
+
`true`, `echo ok`, hoặc `npm test || true` có thể được ghi trace nếu đã chạy thật, nhưng không đủ để pass final gate trừ khi profile/task verify plan khai đúng command đó.
|
|
146
|
+
|
|
147
|
+
Guard state tự bảo vệ:
|
|
148
|
+
|
|
149
|
+
- raw path-like access vào `.pi/piagent-state/**` bị block trước khi tool chạy;
|
|
150
|
+
- raw path-like access vào `.pi/piagent-profile.json` bị block trước khi tool chạy;
|
|
151
|
+
- Pi built-ins `read`, `write`, `edit`, `grep`, `find`, `ls` đi qua cùng protected-path gate;
|
|
152
|
+
- custom/MCP tools cũng bị block nếu tool call chứa path-like string trỏ vào protected path, kể cả nested object, array, và `file://` URI;
|
|
153
|
+
- path-like string được percent-decode một lần trước khi match, nên `%2Eenv` và `.%65nv` không đi vòng qua guard;
|
|
154
|
+
- tool input lồng quá sâu vượt `MAX_TOOL_INPUT_INSPECTION_DEPTH=32` sẽ fail-closed;
|
|
155
|
+
- generic extractor chỉ skip leaf field nội dung đã biết như `content`, `query`, `pattern`, `text`, và `command`;
|
|
156
|
+
- `grep.glob` và `find.pattern` bị block khi pattern nhắm protected path rõ ràng như `.env*`, `auth.json`, `.pi/piagent-state/**`, hoặc `piagent-profile.json`; broad glob như `*.json` được phép và để result backstop xử lý;
|
|
157
|
+
- broad `grep`, `find`, và `ls` sweep có thêm `tool_result` backstop để redact content line hoặc path metadata từ protected files;
|
|
158
|
+
- mọi text block trong `tool_result` và string leaf trong JSON-like `details` có thêm shared sensitive-data redaction; key như `password`, `token`, `credential` được dùng làm context phát hiện;
|
|
159
|
+
- `npm run benchmark:redaction` gate contextual recall, benign preservation, structured objects/arrays, và large-output correctness bằng synthetic data; opaque entropy không có credential context được báo riêng và không gate release;
|
|
160
|
+
- bash evidence chỉ giữ command text đã redact ở memory/disk; raw command hash vẫn dùng để exact-match verify evidence;
|
|
161
|
+
- `piagent_task_start`, `piagent_verify_record`, và `tool_result` hook vẫn ghi state được qua internal extension path.
|
|
162
|
+
|
|
163
|
+
## 5. Local verification
|
|
164
|
+
|
|
165
|
+
Platform verification:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm run typecheck
|
|
169
|
+
npm test
|
|
170
|
+
npm run benchmark:redaction
|
|
171
|
+
bash scripts/verify-local.sh
|
|
172
|
+
bash scripts/verify-local.sh --offline # CI / clean machine without Pi login catalog
|
|
173
|
+
bash scripts/team-doctor.sh . --strict-share
|
|
174
|
+
pi list --approve
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`verify-local.sh` kiểm tra:
|
|
178
|
+
|
|
179
|
+
- package manifests;
|
|
180
|
+
- JSON parse;
|
|
181
|
+
- required docs/scripts/prompts;
|
|
182
|
+
- protected-path, shell protected path, recursive path-like tool access, `grep/find/ls` result backstops, guard-state self-protection, exec-policy, observed-verify, cross-process ledger, profile verify-command matching, and redaction regression tests;
|
|
183
|
+
- profile doctor;
|
|
184
|
+
- team doctor;
|
|
185
|
+
- TypeScript syntax for extension;
|
|
186
|
+
- smoke test for runtime policy;
|
|
187
|
+
- public documentation wording guard.
|
|
188
|
+
|
|
189
|
+
## 6. Quality benchmark
|
|
190
|
+
|
|
191
|
+
Script:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
bash scripts/quality-benchmark.sh <project-path> --init
|
|
195
|
+
bash scripts/quality-benchmark.sh <project-path> --record \
|
|
196
|
+
--scenario bounded-source-fix \
|
|
197
|
+
--surface pi \
|
|
198
|
+
--result pass \
|
|
199
|
+
--tokens 12345 \
|
|
200
|
+
--cost 0.12 \
|
|
201
|
+
--verify "npm test" \
|
|
202
|
+
--notes "verify passed; no manual correction"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Output:
|
|
206
|
+
|
|
207
|
+
```text
|
|
208
|
+
<project>/.pi/benchmarks/quality-scenarios.md
|
|
209
|
+
<project>/.pi/benchmarks/quality-runs.jsonl
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Chỉ claim chất lượng/token/cost khi cùng scenario có:
|
|
213
|
+
|
|
214
|
+
- cùng task prompt/spec;
|
|
215
|
+
- cùng acceptance criteria;
|
|
216
|
+
- verify command rõ;
|
|
217
|
+
- token/cost/duration được ghi lại;
|
|
218
|
+
- quality notes và số vòng sửa lại.
|
|
219
|
+
|
|
220
|
+
## Runtime policy trong profile
|
|
221
|
+
|
|
222
|
+
Project có thể override:
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"runtimePolicy": {
|
|
227
|
+
"execPolicy": "enforce",
|
|
228
|
+
"contextBudget": "enforce",
|
|
229
|
+
"toolRegistry": "advisory",
|
|
230
|
+
"finalGate": "enforce"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Mode:
|
|
236
|
+
|
|
237
|
+
| Mode | Ý nghĩa |
|
|
238
|
+
|---|---|
|
|
239
|
+
| `off` | Không áp dụng module policy đó. |
|
|
240
|
+
| `advisory` | Tool trả warning/check result nhưng không block mọi thứ. |
|
|
241
|
+
| `enforce` | Runtime hook/tool block khi vi phạm policy. |
|
|
242
|
+
|
|
243
|
+
## Khuyến nghị vận hành
|
|
244
|
+
|
|
245
|
+
Setup solo/internal nên bắt đầu với:
|
|
246
|
+
|
|
247
|
+
1. `execPolicy=enforce`
|
|
248
|
+
2. `contextBudget=enforce`
|
|
249
|
+
3. `toolRegistry=advisory` trong giai đoạn đầu, sau đó nâng lên `enforce` khi tool registry ổn định
|
|
250
|
+
4. `finalGate=enforce`
|
|
251
|
+
|
|
252
|
+
## Roadmap
|
|
253
|
+
|
|
254
|
+
- Hard final assistant stop-hook nếu Pi extension API expose stable hook.
|
|
255
|
+
- Disposable integration test chạy Pi runtime end-to-end.
|
|
256
|
+
- Optional process/filesystem/network sandbox ngoài Pi khi môi trường yêu cầu isolation mạnh.
|
|
257
|
+
- Auto-discovery tool names từ Pi/MCP để giảm registry thủ công.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Sensitive-data redaction benchmark
|
|
2
|
+
|
|
3
|
+
The redaction benchmark measures the text and structured-data backstop used by the runtime guard. It uses deterministic synthetic values only; real credentials must never be added to the corpus. This is an internal regression benchmark, not an independent security audit, and the detector model should be treated as still maturing.
|
|
4
|
+
|
|
5
|
+
Run it from the repository root:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run benchmark:redaction
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The command returns JSON and exits non-zero when a release gate fails.
|
|
12
|
+
|
|
13
|
+
The v0.4.2 frozen-tree baseline is 52/52 contextual cases detected, 0/30 benign text false positives, 8/8 structured sensitive values redacted, and 7/7 structured benign values preserved. The six unlabeled-entropy cases remain observational and non-gated.
|
|
14
|
+
|
|
15
|
+
## Release gates
|
|
16
|
+
|
|
17
|
+
- Every contextual or known-format case must be redacted.
|
|
18
|
+
- Benign text must have zero false positives in the committed corpus.
|
|
19
|
+
- Structured sensitive fields and approved plural collections must be redacted.
|
|
20
|
+
- Structured identifiers, checksums, labels, and semantic/design token fields must remain unchanged.
|
|
21
|
+
- A large text result with a contextual credential must be redacted successfully.
|
|
22
|
+
|
|
23
|
+
The corpus covers known token formats, private-key blocks, credential-bearing URLs, authorization headers, query parameters, quoted and multiline assignments, camelCase/hyphenated keys, nested objects, arrays, placeholders, existing redaction markers, hashes, identifiers, and documentation prose.
|
|
24
|
+
|
|
25
|
+
## Interpreting the output
|
|
26
|
+
|
|
27
|
+
| Field | Meaning | Gated |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `contextual` | Known formats or values paired with a credential-bearing key/header/URL context | Yes |
|
|
30
|
+
| `benign` | Text that must remain unchanged | Yes |
|
|
31
|
+
| `structured` | Key-aware redaction and preservation inside objects/arrays | Yes |
|
|
32
|
+
| `largeOutput` | Redaction result for a bounded large text sample | Yes for correctness; timing is informational |
|
|
33
|
+
| `unlabeledEntropy` | Opaque values without a credential-bearing context | No; observational only |
|
|
34
|
+
| `performance` | Local execution measurements | No; compare only on the same machine/runtime |
|
|
35
|
+
|
|
36
|
+
Unlabeled high-entropy values are not automatically treated as secrets. A generic entropy rule cannot reliably distinguish a credential from a checksum, content hash, artifact identifier, or opaque public ID. Add a known format or a clear key/header context when stronger coverage is required.
|
|
37
|
+
|
|
38
|
+
## Security boundary
|
|
39
|
+
|
|
40
|
+
This benchmark measures pattern-based output containment. It does not authorize secret handling and does not turn the extension into an operating-system sandbox. It does not decode every transformed output form before matching; for example, base64-encoded or otherwise re-encoded secret material can evade the redaction backstop. Workloads that execute untrusted code or process untrusted prompts still require process, filesystem, network, and credential isolation.
|
|
41
|
+
|
|
42
|
+
The current scope, assumptions, controls, and residual risks are documented in [security-threat-model.md](security-threat-model.md), and private intake/disclosure is documented in [SECURITY.md](../SECURITY.md). Before using redaction results as a stronger assurance claim, continue to complete and maintain:
|
|
43
|
+
|
|
44
|
+
- Linux, macOS, Windows, and shell-behavior compatibility matrix;
|
|
45
|
+
- parser fuzzing for shell/path extraction;
|
|
46
|
+
- symlink and path-traversal adversarial tests;
|
|
47
|
+
- third-party audit or independent review;
|
|
48
|
+
- LTS support and backport policy for affected releases.
|
|
49
|
+
|
|
50
|
+
When extending the detector:
|
|
51
|
+
|
|
52
|
+
1. Add synthetic positive and benign controls first.
|
|
53
|
+
2. Record the failing benchmark result.
|
|
54
|
+
3. Make the smallest context-aware detector change.
|
|
55
|
+
4. Run the benchmark, full test suite, typecheck, capability doctor, and offline verification.
|
|
56
|
+
5. Keep the unlabeled-entropy result separate from release claims.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Security threat model
|
|
2
|
+
|
|
3
|
+
## Scope and objective
|
|
4
|
+
|
|
5
|
+
Pi Agent Platform adds application-level policy enforcement to Pi tool calls used in a trusted project. Its objective is to reduce accidental damage, common prompt-injection impact, secret exposure, unauthorized external mutations, and non-reproducible team installs. It is not an operating-system sandbox and does not claim to contain hostile code running with the operator's account permissions.
|
|
6
|
+
|
|
7
|
+
This document covers the packaged guard, project profiles, capability locks, installer, release workflow, and packaged artifact. Project-specific applications, provider infrastructure, the Pi host implementation, third-party add-ons, and the operating system remain separate security domains.
|
|
8
|
+
|
|
9
|
+
## Protected assets
|
|
10
|
+
|
|
11
|
+
- credentials, OAuth sessions, `.env`, auth files, and private runtime state;
|
|
12
|
+
- source and configuration outside the resolved filesystem scopes;
|
|
13
|
+
- paths declared read-only by the active project profile;
|
|
14
|
+
- protected guard, profile, settings, capability-lock, and evidence files;
|
|
15
|
+
- external GitHub, HTTP, MCP, and provider resources that can be mutated;
|
|
16
|
+
- release identity, installer sources, dependency pins, and package contents;
|
|
17
|
+
- observed verification evidence used to approve task completion.
|
|
18
|
+
|
|
19
|
+
## Trust assumptions
|
|
20
|
+
|
|
21
|
+
- The operator, operating-system account, Pi host, and explicitly trusted project repository are trusted to execute code.
|
|
22
|
+
- Project-local Pi resources are loaded only after Pi project trust or an explicit operator override.
|
|
23
|
+
- A human remains available to approve destructive and external-provider actions.
|
|
24
|
+
- Supported release verification covers macOS Apple Silicon + Bash, Linux x64 + Bash, Node.js `>=22.19.0`, and the exact Pi host version declared by the release. macOS Intel + Bash and Linux ARM64 + Bash are supported targets that need local smoke verification before broad rollout. Native Windows is not a team-rollout target for v1.0.0, and WSL2 is experimental/unverified.
|
|
25
|
+
- Registry, GitHub, model-provider, MCP-provider, and Vercel controls are external dependencies. Their account security and platform guarantees are not replaced by this repository.
|
|
26
|
+
|
|
27
|
+
## Threat actors and failure modes
|
|
28
|
+
|
|
29
|
+
- an agent making an incorrect tool call or selecting an overly broad command;
|
|
30
|
+
- prompt injection contained in repository text, web content, tool output, or an MCP response;
|
|
31
|
+
- malformed, nested, encoded, or aliased tool input intended to bypass path or action classification;
|
|
32
|
+
- a project profile or capability lock modified to request more authority;
|
|
33
|
+
- a moved release tag, unexpected package content, or vulnerable transitive dependency;
|
|
34
|
+
- an untrusted repository, dependency install script, interpreter payload, binary, or process executing with the operator's OS permissions.
|
|
35
|
+
|
|
36
|
+
The final category is outside the containment capability of the Piagent guard. It requires isolation at the filesystem, process, network, and credential layers.
|
|
37
|
+
|
|
38
|
+
## Attack-vector and control map
|
|
39
|
+
|
|
40
|
+
| Vector | Current control | Residual risk |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| Direct or nested path-like tool input | Bounded recursive input inspection, protected-path precedence, repository boundary checks, filesystem capability scopes, and read-only profile paths | A new carrier or field name must be classified before it can be treated as controlled. Unknown/ambiguous tools fail closed where policy requires confirmation. |
|
|
43
|
+
| Encoding, case variation, traversal, or symbolic-link alias | Single percent decode, case-insensitive protected matching, canonical resolution for existing paths, traversal/repository escape rejection | Filesystem races and code executing outside observed tool paths require an OS boundary. |
|
|
44
|
+
| Shell glob, brace, redirection, wrapper, assignment, or command composition | Static Bash operand/action analysis with bounded expansion and regression cases; protected input is denied and external mutation is confirmation-gated | Runtime-generated interpreter payloads cannot be fully understood by static parsing. Sensitive output redaction is a backstop, not containment. |
|
|
45
|
+
| Secret returned in tool output | Shared contextual redaction across guarded text/results and synthetic recall benchmark | High-entropy, novel secret formats, or transformed output such as base64-encoded content can evade pattern-based redaction. Never intentionally print real secrets. |
|
|
46
|
+
| Malicious project profile or relaxed capability lock | Trust-aware profile loading, deterministic lock digest, base-policy/source integrity, protected self-state, and fail-closed verification | An already trusted malicious repository can execute code through mechanisms outside the guard. |
|
|
47
|
+
| External GitHub/HTTP/MCP/provider mutation | Direct and proxied action classification plus explicit operator confirmation, including guarded shell carriers | Provider semantics and new tool schemas can change; new integrations require policy and regression review. |
|
|
48
|
+
| Destructive local action | Exec-policy classification and explicit confirmation; protected paths remain denied in every permission profile | Confirmation is not isolation. A trusted process outside the observed tool path retains OS authority. |
|
|
49
|
+
| Forged verification result | Observed Bash result ledger, command hash, task-start ordering, exit-code and verify-command matching | Compromise of the trusted Pi/process environment is outside this evidence model. |
|
|
50
|
+
| Mutable or substituted release source | Exact team tags, stable tag-to-commit resolution, release-commit binding in tag CI, annotated-tag requirement, add-on integrity checks, and documented tag ruleset requirement | Bootstrap helper installation still relies on GitHub tag immutability; repository administrators must prevent tag update/deletion. Signed provenance remains future work. |
|
|
51
|
+
| Dependency or package-content compromise | `--ignore-scripts` bootstrap installs, root and exact runtime dependency audits, immutable Action SHAs, package allowlist, artifact tests, CodeQL, Dependabot, secret scanning, and push protection | Audits are point-in-time and lower-severity/upstream findings remain. Review alerts and refresh pins continuously. |
|
|
52
|
+
| Parser resource exhaustion | Bounded nested input, command length, expansion, and result processing | Fuzzing breadth is still evolving; report hangs or unusually expensive inputs privately. |
|
|
53
|
+
|
|
54
|
+
## Permission model
|
|
55
|
+
|
|
56
|
+
`read-only`, `workspace-write`, and `trusted-full-access` change the allowed working scope; they do not disable protected paths, secret redaction, capability integrity, destructive confirmation, or external-provider confirmation. `trusted-full-access` is intended for an already trusted repository in an externally safe environment. It is not a bypass or sandbox mode.
|
|
57
|
+
|
|
58
|
+
## Security verification
|
|
59
|
+
|
|
60
|
+
Release gates include policy regression tests, TypeScript checking, runtime smoke tests, redaction benchmarks, package-content inspection, release-identity checks, installer tests, exact Pi host/add-on dependency audit, and CI on Linux x64 plus the current macOS runner. CodeQL covers JavaScript/TypeScript and GitHub Actions.
|
|
61
|
+
|
|
62
|
+
These are internal engineering controls, not an independent third-party audit. The project currently has no LTS promise. Stronger assurance still benefits from broader parser fuzzing, a larger OS/shell matrix, independent review, signed provenance, and continued adversarial testing.
|
|
63
|
+
|
|
64
|
+
## Reporting and disclosure
|
|
65
|
+
|
|
66
|
+
Follow [the security policy](../SECURITY.md). Report suspected bypasses privately with a synthetic reproduction and do not include live credentials or customer data.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Subagent orchestration capabilities
|
|
2
|
+
|
|
3
|
+
Review date: 2026-07-19
|
|
4
|
+
|
|
5
|
+
Package used:
|
|
6
|
+
|
|
7
|
+
- `pi-subagents`
|
|
8
|
+
- Package docs: https://pi.dev/packages/pi-subagents
|
|
9
|
+
|
|
10
|
+
## Kết luận
|
|
11
|
+
|
|
12
|
+
Pi Agent Platform uses `pi-subagents` for child sessions, parallel read-only work, review loops, and structured handoffs. The platform keeps a safe default configuration and documents advanced commands separately so daily users can still start with `/task`.
|
|
13
|
+
|
|
14
|
+
Core decisions:
|
|
15
|
+
|
|
16
|
+
1. natural-language delegation is preferred over requiring users to remember `/run`;
|
|
17
|
+
2. parent agent should decide whether independent read-only work deserves subagents;
|
|
18
|
+
3. piagent roles remain narrow and policy-aware;
|
|
19
|
+
4. background, watchdog, scheduled, and parallel-writer behavior stays opt-in;
|
|
20
|
+
5. long child output should use file handoff when possible.
|
|
21
|
+
|
|
22
|
+
## Capabilities
|
|
23
|
+
|
|
24
|
+
| Capability | Meaning | Platform decision |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| Natural language delegation | User can ask for scout/review/planning without exact syntax. | Covered by auto-delegation policy and workflow prompts. |
|
|
27
|
+
| Builtin agents | General roles such as researcher, planner, reviewer, and context-builder. | Use when they fit the task and installed tools are available. |
|
|
28
|
+
| Piagent agents | `piagent-scout`, `piagent-planner`, `piagent-worker`, `piagent-reviewer`, `piagent-oracle`. | Default roles for governed project work. |
|
|
29
|
+
| Prompt shortcuts | `/parallel-review`, `/review-loop`, `/parallel-research`, `/parallel-context-build`, `/parallel-handoff-plan`. | Documented for explicit orchestration. |
|
|
30
|
+
| Supervisor channel | Child can ask parent for a decision. | Allowed for blocked or high-context child work. |
|
|
31
|
+
| Output controls | `output`, `outputMode=file-only`, `reads`, `outputSchema`, `acceptance`. | Recommended for large reports and handoff context. |
|
|
32
|
+
| Worktree isolation | Separate checkout for parallel writer agents. | Non-default; use only with explicit scope and disjoint write sets. |
|
|
33
|
+
| Watchdog | Additional opt-in review at session end. | Off by default to control token/cost. |
|
|
34
|
+
| Scheduled runs | Delayed one-shot subagent. | Disabled by default; only for explicit monitor/wait tasks. |
|
|
35
|
+
|
|
36
|
+
## Applied in platform
|
|
37
|
+
|
|
38
|
+
- `scripts/configure-subagents.sh`
|
|
39
|
+
- `waitTool.enabled: true`
|
|
40
|
+
- `intercomBridge.mode: always`
|
|
41
|
+
- stable `defaultSessionDir`, `singleRunOutputBaseDir`, `worktreeBaseDir`
|
|
42
|
+
- `scheduledRuns.enabled: false`
|
|
43
|
+
- bounded `maxSubagentDepth`, spawn cap, and parallel concurrency
|
|
44
|
+
- `scripts/setup.sh` / `scripts/install-global.sh`
|
|
45
|
+
- optional `--with-web-access` installs `npm:pi-web-access@0.13.0` for web/docs research
|
|
46
|
+
- Workflow prompts
|
|
47
|
+
- `/task`, `/plan`, `/review`, `/be-to-fe`, `/platform-improve` instruct the parent to auto-delegate when work is independent and bounded
|
|
48
|
+
- Docs
|
|
49
|
+
- command reference lists prompt shortcuts, watchdog/profile commands, supervisor control, output/fork/worktree options
|
|
50
|
+
|
|
51
|
+
## Keep non-default
|
|
52
|
+
|
|
53
|
+
| Feature | Reason |
|
|
54
|
+
|---|---|
|
|
55
|
+
| Watchdog always-on | Extra review can increase token/cost. |
|
|
56
|
+
| `asyncByDefault: true` | Background work can surprise interactive users. |
|
|
57
|
+
| Scheduled subagents | Useful for monitoring, unrelated to normal implementation. |
|
|
58
|
+
| Parallel writers | Correct only with clean repo, worktree isolation, and non-overlapping files. |
|
|
59
|
+
| Research agent without web tooling | It needs appropriate web/search/fetch tools installed. |
|
|
60
|
+
|
|
61
|
+
## Recommended usage
|
|
62
|
+
|
|
63
|
+
Daily implementation:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
/task Implement <task>.
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Review until clean:
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
/review-loop current diff max 3 rounds
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Parallel review:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
/parallel-review current diff
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Research-heavy task:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pi install npm:pi-web-access@0.13.0
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
/parallel-research Compare available implementation options for <topic>.
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Context handoff before a large implementation:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
/parallel-context-build Build context for <large task>.
|
|
95
|
+
/parallel-handoff-plan Build implementation handoff plan for <large task>.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Watchdog for a high-risk session:
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
/subagents-watchdog recommend-model
|
|
102
|
+
/subagents-watchdog session model recommended
|
|
103
|
+
/subagents-watchdog on
|
|
104
|
+
```
|