@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.
Files changed (159) hide show
  1. package/.gitattributes +7 -0
  2. package/AGENTS.md +31 -0
  3. package/CHANGELOG.md +296 -0
  4. package/CODE_OF_CONDUCT.md +36 -0
  5. package/CONTRIBUTING.md +66 -0
  6. package/LICENSE +21 -0
  7. package/README.md +588 -0
  8. package/SECURITY.md +38 -0
  9. package/adapters/backend-api/profile.json +88 -0
  10. package/adapters/be-readonly-fe/profile.json +120 -0
  11. package/adapters/data/profile.json +88 -0
  12. package/adapters/devops/profile.json +92 -0
  13. package/adapters/docs/profile.json +74 -0
  14. package/adapters/fullstack/profile.json +94 -0
  15. package/adapters/generic/profile.json +95 -0
  16. package/adapters/mobile/profile.json +87 -0
  17. package/adapters/node-typescript/profile.json +76 -0
  18. package/adapters/python/profile.json +75 -0
  19. package/adapters/web-frontend/profile.json +101 -0
  20. package/catalog/capabilities.json +206 -0
  21. package/docs/architecture.md +64 -0
  22. package/docs/auto-delegation-policy.md +192 -0
  23. package/docs/capability-packs.md +234 -0
  24. package/docs/command-reference-vietnamese.md +484 -0
  25. package/docs/context-window-policy.md +85 -0
  26. package/docs/distribution-standard.md +229 -0
  27. package/docs/herdr-workflow.md +58 -0
  28. package/docs/mcp-and-tools.md +316 -0
  29. package/docs/memory-policy.md +164 -0
  30. package/docs/model-options.md +165 -0
  31. package/docs/oauth-providers.md +53 -0
  32. package/docs/operator-manual-vietnamese.md +1080 -0
  33. package/docs/package-architecture-notes.md +101 -0
  34. package/docs/project-adapters.md +174 -0
  35. package/docs/project-onboarding.md +135 -0
  36. package/docs/publishing-for-teams.md +64 -0
  37. package/docs/quality-benchmark.md +74 -0
  38. package/docs/quickstart-vietnamese.md +350 -0
  39. package/docs/release-install-policy.md +223 -0
  40. package/docs/runtime-harness-standard.md +118 -0
  41. package/docs/runtime-policy-design.md +132 -0
  42. package/docs/runtime-quality-baseline.md +257 -0
  43. package/docs/security-redaction-benchmark.md +56 -0
  44. package/docs/security-threat-model.md +66 -0
  45. package/docs/subagent-orchestration-capabilities.md +104 -0
  46. package/docs/subagents-and-multiagent.md +346 -0
  47. package/docs/task-implementation-contract.md +200 -0
  48. package/docs/team-onboarding.md +333 -0
  49. package/docs/usage-observability.md +130 -0
  50. package/docs/vercel-docs-site.md +115 -0
  51. package/docs/workflow-recipes.md +125 -0
  52. package/docs-site/assets/piagent-logo.svg +35 -0
  53. package/docs-site/favicon.svg +18 -0
  54. package/docs-site/index.html +1613 -0
  55. package/docs-site/vercel.json +24 -0
  56. package/evals/fixtures/action-proposal.invalid.json +34 -0
  57. package/evals/fixtures/action-proposal.valid.json +34 -0
  58. package/evals/fixtures/capability-pack.invalid.json +123 -0
  59. package/evals/fixtures/capability-pack.valid.json +123 -0
  60. package/evals/fixtures/capability-recipe.invalid.json +81 -0
  61. package/evals/fixtures/capability-recipe.valid.json +82 -0
  62. package/evals/fixtures/context-index.invalid.json +25 -0
  63. package/evals/fixtures/context-index.valid.json +25 -0
  64. package/evals/fixtures/eval-scenario.invalid.json +40 -0
  65. package/evals/fixtures/eval-scenario.valid.json +45 -0
  66. package/evals/fixtures/project-profile.invalid.json +88 -0
  67. package/evals/fixtures/project-profile.valid.json +95 -0
  68. package/evals/fixtures/task-contract.invalid.json +73 -0
  69. package/evals/fixtures/task-contract.valid.json +74 -0
  70. package/evals/golden/enforcement-decisions.json +329 -0
  71. package/evals/scenarios/capability-resolution.json +45 -0
  72. package/package.json +132 -0
  73. package/packages/piagent-core/README.md +147 -0
  74. package/packages/piagent-core/capabilities/capability-core.js +1023 -0
  75. package/packages/piagent-core/capabilities/capability-sources.js +265 -0
  76. package/packages/piagent-core/extensions/guard-io.js +45 -0
  77. package/packages/piagent-core/extensions/guard-shell-analysis.ts +558 -0
  78. package/packages/piagent-core/extensions/guard-types.ts +406 -0
  79. package/packages/piagent-core/extensions/piagent-guard.ts +5760 -0
  80. package/packages/piagent-core/extensions/policy-core.js +1070 -0
  81. package/packages/piagent-core/extensions/redaction-core.js +4 -0
  82. package/packages/piagent-core/extensions/runtime-evidence.js +215 -0
  83. package/packages/piagent-core/package.json +46 -0
  84. package/packages/piagent-core/policies/base-policy.json +249 -0
  85. package/packages/piagent-core/prompts/be-to-fe.md +82 -0
  86. package/packages/piagent-core/prompts/commit.md +27 -0
  87. package/packages/piagent-core/prompts/discuss.md +35 -0
  88. package/packages/piagent-core/prompts/memory-policy.md +52 -0
  89. package/packages/piagent-core/prompts/model-options.md +68 -0
  90. package/packages/piagent-core/prompts/onboard-project.md +147 -0
  91. package/packages/piagent-core/prompts/piagent-commands.md +68 -0
  92. package/packages/piagent-core/prompts/plan.md +35 -0
  93. package/packages/piagent-core/prompts/platform-improve.md +69 -0
  94. package/packages/piagent-core/prompts/pr.md +26 -0
  95. package/packages/piagent-core/prompts/review.md +38 -0
  96. package/packages/piagent-core/prompts/scout.md +50 -0
  97. package/packages/piagent-core/prompts/task.md +69 -0
  98. package/packages/piagent-core/security/sensitive-data.js +187 -0
  99. package/packages/piagent-core/skills/piagent-ops/SKILL.md +44 -0
  100. package/packages/piagent-core/skills/piagent-source-cache/SKILL.md +59 -0
  101. package/packages/piagent-core/skills/piagent-source-cache/checkout-source-repo.sh +144 -0
  102. package/packages/piagent-core/subagents/piagent-oracle.md +29 -0
  103. package/packages/piagent-core/subagents/piagent-planner.md +46 -0
  104. package/packages/piagent-core/subagents/piagent-reviewer.md +48 -0
  105. package/packages/piagent-core/subagents/piagent-scout.md +37 -0
  106. package/packages/piagent-core/subagents/piagent-worker.md +44 -0
  107. package/packs/engineering-base/pack.json +123 -0
  108. package/packs/engineering-base/recipes/bounded-change.json +82 -0
  109. package/packs/web-delivery/pack.json +72 -0
  110. package/packs/web-delivery/recipes/verified-web-change.json +57 -0
  111. package/schemas/action-proposal.schema.json +90 -0
  112. package/schemas/capability-pack.schema.json +190 -0
  113. package/schemas/capability-recipe.schema.json +72 -0
  114. package/schemas/context-index.schema.json +258 -0
  115. package/schemas/eval-scenario.schema.json +67 -0
  116. package/schemas/project-profile.schema.json +555 -0
  117. package/schemas/task-contract.schema.json +314 -0
  118. package/scripts/audit-runtime-host.sh +78 -0
  119. package/scripts/bootstrap-local.sh +25 -0
  120. package/scripts/capability-catalog.mjs +290 -0
  121. package/scripts/check-runtime-advisories.mjs +114 -0
  122. package/scripts/configure-mcp.sh +301 -0
  123. package/scripts/configure-model-scope.sh +143 -0
  124. package/scripts/configure-subagents.sh +241 -0
  125. package/scripts/import-agent-instructions.mjs +199 -0
  126. package/scripts/init-project.sh +369 -0
  127. package/scripts/install-global.sh +532 -0
  128. package/scripts/link-project.sh +25 -0
  129. package/scripts/migrate-project-state.mjs +176 -0
  130. package/scripts/pi-auto.sh +79 -0
  131. package/scripts/pi-model-catalog.sh +154 -0
  132. package/scripts/pi-session-stats.sh +135 -0
  133. package/scripts/piagent-cli.mjs +53 -0
  134. package/scripts/profile-doctor.sh +238 -0
  135. package/scripts/quality-benchmark.sh +185 -0
  136. package/scripts/redaction-benchmark.mjs +227 -0
  137. package/scripts/runtime-policy-smoke.sh +48 -0
  138. package/scripts/setup.sh +425 -0
  139. package/scripts/team-doctor.sh +461 -0
  140. package/scripts/verify-local.sh +540 -0
  141. package/scripts/verify-release-identity.mjs +85 -0
  142. package/scripts/verify-vercel-link.mjs +64 -0
  143. package/templates/global/mcp.json +9 -0
  144. package/templates/global/settings.json +37 -0
  145. package/templates/project/.mcp.json +9 -0
  146. package/templates/project/.pi/context-index.json +25 -0
  147. package/templates/project/.pi/gitignore.template +22 -0
  148. package/templates/project/.pi/mcp.json +9 -0
  149. package/templates/project/.pi/memory/MEMORY.md +11 -0
  150. package/templates/project/.pi/memory/memory_summary.md +9 -0
  151. package/templates/project/.pi/piagent-profile.json +107 -0
  152. package/templates/project/.pi/project-context.md +30 -0
  153. package/templates/project/.pi/settings.json +17 -0
  154. package/templates/project/.pi/task-contract.template.json +74 -0
  155. package/templates/project/.pi/tech-context/README.md +7 -0
  156. package/templates/project/.pi/tech-stack.json +10 -0
  157. package/templates/project/AGENTS.md +34 -0
  158. package/templates/project/REVIEW_GUIDELINES.md +23 -0
  159. package/types/pi-runtime-shims.d.ts +13 -0
package/README.md ADDED
@@ -0,0 +1,588 @@
1
+ # Pi Agent Platform
2
+
3
+ Reusable Pi package for project onboarding, profile-based coding workflows, guarded tool usage, multi-agent orchestration, MCP setup, memory policy, and task verification.
4
+
5
+ Public docs: [piagent.io.vn](https://piagent.io.vn)
6
+
7
+ The goal is a simple daily flow:
8
+
9
+ ```bash
10
+ cd /path/to/project
11
+ pi
12
+ ```
13
+
14
+ From there, Pi can onboard the project, select an operating profile, use the right tools, record task evidence, and hand off verified implementation work.
15
+
16
+ For a trusted project where you want Pi to load project-local `.pi` resources without another trust prompt on that run:
17
+
18
+ ```bash
19
+ cd /path/to/project
20
+ piagent-auto
21
+ ```
22
+
23
+ Read-only scout mode:
24
+
25
+ ```bash
26
+ piagent-auto --read-only -p "Scout payment mapping. Do not edit source."
27
+ ```
28
+
29
+ Trusted full-access style run:
30
+
31
+ ```bash
32
+ piagent-auto --full-access -p "Run the trusted local benchmark suite."
33
+ ```
34
+
35
+ `piagent-auto` is a convenience wrapper for Pi project trust (`pi --approve`). It does not bypass protected-path checks, destructive shell checks, task gates, or verification evidence.
36
+
37
+ ## What it provides
38
+
39
+ - Global Pi package with prompts, skills, guard extensions, and piagent subagents.
40
+ - Runtime onboarding via `/onboard-project`.
41
+ - Runtime profile selection via `/profile`, plus select-style tech stack setup via `/profile setup` and `/profile tech`.
42
+ - Explicit project memory via `/memory-policy` and `piagent_memory_*` tools.
43
+ - Compact project context index via `/context-index` and `piagent_context_index_*` tools. This is an advisory navigation graph, not a security boundary or source of truth.
44
+ - MCP setup helpers for Context7, Chrome DevTools, GitHub, Playwright, and Figma.
45
+ - Subagent setup helpers for read-only scouting, planning, implementation, review, and risk challenge.
46
+ - Chat image-path intake: paste a local screenshot path into the Pi chat box and the guard attaches it as `[image1]` before the model sees the prompt.
47
+ - Trusted-run wrapper: `piagent-auto` launches Pi with `--approve` for the current run while keeping piagent guardrails active.
48
+ - Runtime policy tools:
49
+ - `piagent_permission_status`
50
+ - `piagent_exec_policy_check`
51
+ - `piagent_context_budget`
52
+ - `piagent_tool_policy_check`
53
+ - `piagent_task_gate_check`
54
+ - `piagent_usage_snapshot`
55
+ - `piagent_context_preflight`
56
+ - `piagent_orchestration_policy`
57
+ - Context7-ready tech stack manifest and concise `.pi/tech-context/*` snapshots for selected profile roles.
58
+ - Accident-brake guardrails for protected paths, destructive shell commands, task contracts, context manifests, observed verification evidence, and trace records.
59
+ - Quality benchmark recorder for comparing approved agent surfaces, models, and workflow presets on the same task scenarios.
60
+ - Built-in profiles for frontend, backend, fullstack, BE-readonly/FE-write, data, DevOps, mobile, docs, Python, and Node TypeScript.
61
+ - Versioned capability packs with deterministic catalog, profile resolution, integrity lock, and permission checks.
62
+
63
+ ## Permission profiles
64
+
65
+ Project profiles can declare a runtime `permissionProfile`:
66
+
67
+ | Profile | Use when | Guard behavior |
68
+ |---|---|---|
69
+ | `read-only` | Scout, audit, review | Allows `read`, `grep`, `find`, `ls`, and piagent state tools; blocks shell, write/edit, and unknown tools. |
70
+ | `workspace-write` | Normal implementation | Default profile. Keeps current protected-path, shell, capability, task, and verify gates. |
71
+ | `trusted-full-access` | Trusted local automation | Expands workspace tool/scope autonomy, but still enforces protected paths, secret redaction, capability lock integrity, and destructive/external confirmation. |
72
+
73
+ For one run, set `PIAGENT_PERMISSION_PROFILE=read-only|workspace-write|trusted-full-access`, or use `piagent-auto --read-only`, `--workspace-write`, or `--full-access`.
74
+
75
+ Inside an active Pi session, use slash commands for a session-local switch:
76
+
77
+ ```text
78
+ /permission-status
79
+ /read-only
80
+ /workspace-write
81
+ /full-access
82
+ /full-access Implement the requested trusted repo task.
83
+ ```
84
+
85
+ `/full-access` also accepts a task after the command. The guard switches the current session to `trusted-full-access`, then forwards the remaining text as the next user request.
86
+
87
+ ## Solo-first orchestration
88
+
89
+ Pi Agent Platform supports subagents, but the default operating model is solo-first: one parent agent owns the task contract, uses explicit review lenses, and only calls bounded subagents when scout/planning/review work is independent enough to justify the extra token/tool cost.
90
+
91
+ Inside Pi:
92
+
93
+ ```text
94
+ /piagent-orchestration
95
+ ```
96
+
97
+ This shows the active mode, max subagents, review lenses, Field Guide path, and writer policy without triggering a model follow-up.
98
+
99
+ ## Install
100
+
101
+ Supported for this release:
102
+
103
+ | Runtime surface | Team rollout status |
104
+ |---|---|
105
+ | macOS Apple Silicon (`darwin/arm64`) + Bash | Verified for this release. |
106
+ | Linux x64 + Bash | Verified in CI for this release. |
107
+ | macOS Intel (`darwin/x64`) + Bash | Supported target, but run `piagent-doctor` and project smoke tests before wide rollout. |
108
+ | Linux ARM64 + Bash | Supported target, but run `piagent-doctor` and project smoke tests before wide rollout. |
109
+ | Native Windows | Not a team-rollout target yet; terminal helpers and shell policy rely on Bash/POSIX semantics. |
110
+ | WSL2 | Experimental and not release-gated yet. |
111
+
112
+ Node.js `>=22.19.0` and Pi Coding Agent `0.81.1` are required. Pi Coding Agent is installed as a Node CLI; the project release matrix above defines which OS/CPU surfaces this platform has verified.
113
+
114
+ ```bash
115
+ node --version # >= 22.19.0
116
+ npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.81.1
117
+ npm install -g --ignore-scripts github:Vt-mmm/piagent#v1.0.0
118
+ piagent-install --stable --dry-run
119
+ piagent-install --stable
120
+ ```
121
+
122
+ The npm command installs the `piagent-*` terminal helpers. `piagent-install --stable` then resolves the helper's release tag to a commit SHA and installs the matching Pi package. In its output, `currentRelease` is the version of the terminal helper currently executing.
123
+
124
+ If you only need to install the Pi package and do not need the `piagent-*` terminal commands, pin the current release tag or a reviewed commit directly:
125
+
126
+ ```bash
127
+ pi install git:github.com/Vt-mmm/piagent@v1.0.0
128
+ ```
129
+
130
+ From a checked-out platform repo, the same helper is available as a script:
131
+
132
+ ```bash
133
+ bash scripts/install-global.sh --stable --dry-run
134
+ bash scripts/install-global.sh --stable
135
+ ```
136
+
137
+ For a full update, update the exact Pi host first, then the npm-global helper, then apply its matching stable Pi package:
138
+
139
+ ```bash
140
+ npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.81.1
141
+ npm install -g --ignore-scripts github:Vt-mmm/piagent#vX.Y.Z
142
+ piagent-install --stable --dry-run
143
+ piagent-install --stable
144
+ ```
145
+
146
+ For rollback, read the target release's compatibility section and install its exact Pi host before changing the helper to `vPREVIOUS`; older hosts may reintroduce known dependency findings. If you intentionally want to change only the Pi package while keeping the terminal helper at its current version:
147
+
148
+ ```bash
149
+ piagent-install --version vX.Y.Z --resolve-tag --dry-run
150
+ piagent-install --version vX.Y.Z --resolve-tag
151
+ ```
152
+
153
+ Use latest only for a personal machine or sandbox where fast updates are acceptable:
154
+
155
+ ```bash
156
+ bash scripts/install-global.sh --dev --dry-run
157
+ bash scripts/install-global.sh --dev
158
+ ```
159
+
160
+ Optional Herdr integration:
161
+
162
+ ```bash
163
+ herdr integration install pi
164
+ ```
165
+
166
+ ## Daily use
167
+
168
+ ```bash
169
+ cd /path/to/project
170
+ pi
171
+ ```
172
+
173
+ First run inside a project:
174
+
175
+ ```text
176
+ /login
177
+ /model
178
+ /scoped-models # optional: customize Ctrl+P model cycle
179
+ /piagent-commands
180
+ /mcp # inspect MCP servers
181
+ /subagents-doctor # health check
182
+ /onboard-project
183
+ /memory-policy
184
+ ```
185
+
186
+ `/onboard-project` will inspect the repository with bounded context, recommend a profile, explain tradeoffs, ask before applying, then write:
187
+
188
+ - `.pi/piagent-profile.json`
189
+ - `.pi/piagent-profile.lock.json`
190
+ - `.pi/tech-stack.json`
191
+ - `.pi/tech-context/*`
192
+ - `.pi/project-context.md`
193
+ - `.pi/memory/*`
194
+
195
+ Switch profiles later:
196
+
197
+ ```text
198
+ /profile # short status, no model follow-up
199
+ /profile list # compact profile list
200
+ /profile fullstack # apply immediately
201
+ /profile be-readonly-fe # apply immediately
202
+ /profile web-frontend # apply immediately
203
+ /profile backend-api # apply immediately
204
+ /profile auto # apply detected recommendation
205
+ /profile fe # alias for web-frontend
206
+ /profile be-fe # alias for be-readonly-fe
207
+ /profile setup # select profile, then select role tech
208
+ /profile setup fullstack # select FE, BE, and database tech
209
+ /profile tech # short tech stack status
210
+ /profile tech setup fullstack
211
+ /profile tech apply fullstack frontend=nextjs backend=nestjs database=prisma
212
+ ```
213
+
214
+ The setup flow prefers native select UI. If the Pi host does not expose a select control yet, it falls back to a compact options card and an exact `/profile tech apply ...` command instead of asking the model to explain every option.
215
+
216
+ ## Capability packs
217
+
218
+ Capability packs group governed prompts, skills, subagents, policies, adapters, recipes, and eval scenarios behind a declarative manifest. Project profiles select exact pack versions and explicitly grant owner, lifecycle, filesystem, network, and external-action boundaries.
219
+
220
+ ```bash
221
+ piagent-capabilities catalog --check
222
+ piagent-capabilities doctor \
223
+ --profile .pi/piagent-profile.json \
224
+ --lock .pi/piagent-profile.lock.json
225
+ piagent-capabilities resolve \
226
+ --profile .pi/piagent-profile.json \
227
+ --output .pi/piagent-profile.lock.json \
228
+ --package-source ../
229
+ ```
230
+
231
+ The generated lock is deterministic and records profile, pack, artifact, and permission digests. See [Capability packs](docs/capability-packs.md).
232
+
233
+ ## Built-in profiles
234
+
235
+ | Profile | Use when |
236
+ |---|---|
237
+ | `generic` | Unknown or low-structure repository |
238
+ | `web-frontend` | Frontend-only work |
239
+ | `backend-api` | Backend/API work |
240
+ | `be-readonly-fe` | Backend is source-of-truth/read-only; frontend is write target |
241
+ | `fullstack` | Frontend and backend may both be changed when the task allows |
242
+ | `node-typescript` | Node/TypeScript library or tooling |
243
+ | `python` | Python app/library |
244
+ | `data` | ETL, dbt, DVC, notebook, or data pipeline |
245
+ | `devops` | Docker, Terraform, Kubernetes, Helm, GitHub Actions |
246
+ | `mobile` | React Native or Flutter |
247
+ | `docs` | Documentation portal/manual |
248
+
249
+ ## Main workflows
250
+
251
+ ### General implementation
252
+
253
+ ```text
254
+ /task Implement <bounded task>. Follow profile, required context, protected paths, verify commands, and trace.
255
+ ```
256
+
257
+ Use `/task` when the requirement is clear enough to implement.
258
+
259
+ ### Guarded Git workflows
260
+
261
+ Pi Agent intentionally keeps Git as a capability instead of adding a `/git-*` namespace. Use short workflow commands or natural language:
262
+
263
+ ```text
264
+ /commit docs: update onboarding notes
265
+ /pr Add guarded git workflow
266
+ ```
267
+
268
+ `/commit` starts a governed local-commit workflow: inspect status/diff, stage only the intended files, run relevant verification, then commit locally. It does not push.
269
+
270
+ `/pr` starts a governed pull-request workflow: inspect branch/status/commits, handle uncommitted changes explicitly, then ask for confirmation before any `git push` or GitHub PR create/update action. Draft PRs are the default unless the user asks for ready-for-review.
271
+
272
+ Broad staging commands such as `git add .`, `git add -A`, `git add --all`, `git add -- .`, and `git add :/` require confirmation so unrelated or private files are not swept into a commit silently.
273
+
274
+ For read-only investigation:
275
+
276
+ ```text
277
+ /scout Scout <module/spec/contract/risk>. Do not edit source.
278
+ ```
279
+
280
+ Use `/scout` for payment/auth/data/BE-contract mapping before deciding whether to implement.
281
+
282
+ When the current session is already heavy, use the fresh workflow commands. They open a new governed Pi session and replay the compact workflow prompt automatically:
283
+
284
+ ```text
285
+ /fresh-task <request>
286
+ /fresh-scout <read-only request>
287
+ /fresh-be-to-fe <backend-readonly/frontend request>
288
+ ```
289
+
290
+ The input guard also collapses pasted mandatory-flow boilerplate automatically. Users should not paste the full piagent checklist into every task.
291
+
292
+ ### Screenshots and local images
293
+
294
+ If a chat box paste or screen capture produces a local image path instead of a native Pi image attachment, paste the path directly in the task:
295
+
296
+ ```text
297
+ /scout Check this UI state from screenshot /var/folders/.../screenshot.png
298
+ ```
299
+
300
+ The input guard converts supported local image paths (`.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp`) into Pi image attachments and rewrites the prompt to:
301
+
302
+ ```text
303
+ /scout Check this UI state from screenshot [image1]
304
+ ```
305
+
306
+ Limits: up to 4 chat images, 8 MB each. For oversized images, use Pi's `read` tool on the file so Pi can resize it.
307
+
308
+ ### Project improvement
309
+
310
+ ```text
311
+ /platform-improve Improve <platform/setup/workflow behavior>. Update docs and verification.
312
+ ```
313
+
314
+ Use `/platform-improve` for package-level work such as setup, MCP, model scope, memory, runtime policy, prompts, skills, or subagent workflows.
315
+
316
+ ### Backend spec to frontend
317
+
318
+ ```text
319
+ /profile be-readonly-fe
320
+ /be-to-fe Implement frontend support for <backend endpoint/spec>. Backend is read-only.
321
+ ```
322
+
323
+ Use `/be-to-fe` when the backend/spec must be inspected read-only and the implementation target is frontend.
324
+
325
+ ### Planning and clarification
326
+
327
+ ```text
328
+ /discuss <rough request>
329
+ /plan <goal>
330
+ /review current diff
331
+ ```
332
+
333
+ ## Model selection
334
+
335
+ Model selection is handled by Pi’s native UI.
336
+
337
+ ```text
338
+ /model # selector
339
+ Ctrl+L # selector hotkey
340
+ /scoped-models # edit model cycle scope
341
+ Ctrl+P # cycle scoped models
342
+ Shift+Tab # cycle thinking level when supported by the selected model
343
+ ```
344
+
345
+ Global setup can seed `enabledModels`. To inspect or re-apply:
346
+
347
+ ```bash
348
+ piagent-models
349
+ piagent-model-scope --preset full
350
+ ```
351
+
352
+ ## MCP setup
353
+
354
+ Global setup installs `pi-mcp-adapter` and seeds the `core` MCP preset unless disabled.
355
+
356
+ ```bash
357
+ piagent-mcp --preset core --scope global --replace
358
+ piagent-mcp --preset popular --scope global --replace
359
+ piagent-mcp --preset design --scope project --project /path/to/project
360
+ piagent-mcp --list
361
+ ```
362
+
363
+ If the repo is cloned from Git and npm bins are not linked yet:
364
+
365
+ ```bash
366
+ bash /path/to/piagent/scripts/configure-mcp.sh --preset core --scope global --replace
367
+ ```
368
+
369
+ Preset summary:
370
+
371
+ | Preset | Includes |
372
+ |---|---|
373
+ | `core` | Context7, Chrome DevTools, GitHub |
374
+ | `popular` | core + Playwright + Figma remote |
375
+ | `all` | popular + Figma desktop/local |
376
+
377
+ Keep secrets in environment variables, never in committed config:
378
+
379
+ ```bash
380
+ export CONTEXT7_API_KEY=ctx7sk_...
381
+ export GITHUB_PERSONAL_ACCESS_TOKEN=<github-token>
382
+ ```
383
+
384
+ ## Subagents
385
+
386
+ Global setup installs `pi-subagents` and applies the `safe` preset unless disabled.
387
+
388
+ ```bash
389
+ piagent-subagents --preset safe
390
+ ```
391
+
392
+ Fallback when cloned from Git without npm bins:
393
+
394
+ ```bash
395
+ bash /path/to/piagent/scripts/configure-subagents.sh --preset safe
396
+ ```
397
+
398
+ Common Pi commands:
399
+
400
+ ```text
401
+ /subagents-doctor
402
+ /subagents-models
403
+ /subagents-fleet
404
+ /subagent-cost
405
+ /run piagent-scout "Map the auth flow. Read-only."
406
+ /run piagent-planner "Plan implementation from context.md."
407
+ /run piagent-worker "Implement the approved plan."
408
+ /run piagent-reviewer "Review current diff."
409
+ ```
410
+
411
+ Daily task prompts are solo-first: they can delegate bounded scout/planning/review work when useful, and the final handoff should state whether subagents were used and why.
412
+
413
+ Optional web/docs research support:
414
+
415
+ ```bash
416
+ pi install npm:pi-web-access@0.13.0
417
+ ```
418
+
419
+ ## Optional preseed setup
420
+
421
+ Most projects do not need shell init. Use this only when you want to pre-create `.pi` files in a repo or bootstrap team templates:
422
+
423
+ ```bash
424
+ bash /path/to/piagent/scripts/setup.sh /path/to/project \
425
+ --profile be-readonly-fe \
426
+ --package-source git:github.com/Vt-mmm/piagent@v1.0.0 \
427
+ --mcp-preset core \
428
+ --subagents-preset safe
429
+ ```
430
+
431
+ ## Repository layout
432
+
433
+ ```text
434
+ piagent/
435
+ ├─ adapters/ reusable project profiles
436
+ ├─ catalog/ deterministic capability index
437
+ ├─ docs/ Vietnamese documentation and operating notes
438
+ ├─ evals/ governed evaluation scenarios
439
+ ├─ packs/ versioned capability manifests and recipes
440
+ ├─ packages/
441
+ │ └─ piagent-core/ Pi package: extensions, prompts, skills
442
+ ├─ schemas/ JSON schemas
443
+ ├─ scripts/ setup, doctor, verification helpers
444
+ └─ templates/ project/global templates
445
+ ```
446
+
447
+ ## Verification
448
+
449
+ ```bash
450
+ npm ci --ignore-scripts --legacy-peer-deps
451
+ npm run typecheck
452
+ npm test
453
+ npm run benchmark:redaction
454
+ bash scripts/verify-local.sh
455
+ bash scripts/team-doctor.sh . --strict-share
456
+ pi list --approve
457
+ ```
458
+
459
+ Quality benchmark:
460
+
461
+ ```bash
462
+ bash scripts/quality-benchmark.sh /path/to/project --init
463
+ bash scripts/quality-benchmark.sh /path/to/project --record \
464
+ --scenario bounded-source-fix \
465
+ --surface pi \
466
+ --result pass \
467
+ --tokens 12345 \
468
+ --verify "npm test"
469
+ ```
470
+
471
+ Sensitive-data redaction benchmark:
472
+
473
+ ```bash
474
+ npm run benchmark:redaction
475
+ ```
476
+
477
+ Usage / token follow-up:
478
+
479
+ ```text
480
+ /task-preflight
481
+ /task-preflight compact
482
+ /piagent-usage
483
+ /session
484
+ ```
485
+
486
+ From another terminal:
487
+
488
+ ```bash
489
+ piagent-usage /path/to/project
490
+ bash scripts/pi-session-stats.sh /path/to/project
491
+ ```
492
+
493
+ ## Public safety
494
+
495
+ This repository intentionally excludes:
496
+
497
+ - OAuth tokens and `auth.json`;
498
+ - `.env` files;
499
+ - MCP API keys and provider tokens;
500
+ - Pi sessions, todos, caches, and local trust files;
501
+ - project-private data dumps;
502
+ - local machine paths.
503
+
504
+ ## Documentation
505
+
506
+ - [Public docs site](https://piagent.io.vn)
507
+ - [Static team docs site](docs-site/index.html)
508
+ - [Changelog](CHANGELOG.md)
509
+ - [Vercel docs site deploy](docs/vercel-docs-site.md)
510
+ - [Operator manual tiếng Việt](docs/operator-manual-vietnamese.md)
511
+ - [Quickstart tiếng Việt](docs/quickstart-vietnamese.md)
512
+ - [Command reference tiếng Việt](docs/command-reference-vietnamese.md)
513
+ - [Team onboarding](docs/team-onboarding.md)
514
+ - [Project onboarding](docs/project-onboarding.md)
515
+ - [Workflow recipes](docs/workflow-recipes.md)
516
+ - [Project adapters](docs/project-adapters.md)
517
+ - [Architecture](docs/architecture.md)
518
+ - [Distribution standard](docs/distribution-standard.md)
519
+ - [Release and install policy](docs/release-install-policy.md)
520
+ - [Publishing for teams](docs/publishing-for-teams.md)
521
+ - [OAuth providers](docs/oauth-providers.md)
522
+ - [Herdr workflow](docs/herdr-workflow.md)
523
+ - [MCP and tools](docs/mcp-and-tools.md)
524
+ - [Subagents and multi-agent](docs/subagents-and-multiagent.md)
525
+ - [Auto-delegation policy](docs/auto-delegation-policy.md)
526
+ - [Subagent orchestration capabilities](docs/subagent-orchestration-capabilities.md)
527
+ - [Context-window policy](docs/context-window-policy.md)
528
+ - [Memory policy](docs/memory-policy.md)
529
+ - [Task implementation contract](docs/task-implementation-contract.md)
530
+ - [Runtime quality baseline](docs/runtime-quality-baseline.md)
531
+ - [Usage observability](docs/usage-observability.md)
532
+ - [Model options](docs/model-options.md)
533
+ - [Quality benchmark guide](docs/quality-benchmark.md)
534
+ - [Sensitive-data redaction benchmark](docs/security-redaction-benchmark.md)
535
+ - [Runtime policy design](docs/runtime-policy-design.md)
536
+ - [Security threat model](docs/security-threat-model.md)
537
+ - [Package architecture notes](docs/package-architecture-notes.md)
538
+
539
+ ## Maturity
540
+
541
+ The current package version is read from package metadata and release tags. Personal machines may follow the unpinned package source when accepting ongoing updates; production/team quickstarts and committed project settings should pin an explicit tag such as `v1.0.0` or a reviewed commit.
542
+
543
+ Ready for:
544
+
545
+ - global Pi setup;
546
+ - project onboarding;
547
+ - profile-driven guarded implementation tasks;
548
+ - read-only scouting and planning;
549
+ - backend-readonly/frontend-write workflows;
550
+ - bounded subagent scouting, planning, implementation, and review;
551
+ - runtime checks for exec policy, context budget, context preflight, tool policy, task gate, and usage snapshot;
552
+ - project-level quality/token/cost benchmarking.
553
+
554
+ Application-level policy layer:
555
+
556
+ - The guard extension is an accident-prevention layer for agent mistakes and common prompt-injection patterns.
557
+ - Raw path-like tool access to protected paths is blocked before execution. This covers Pi built-ins such as `read`, `write`, `edit`, `grep`, `find`, `ls`, and custom/MCP tools when their input contains path-like strings, including nested objects, arrays, and `file://` URIs.
558
+ - The default MCP proxy carrier is decoded only from bounded object-shaped JSON. Provider/action confirmation and protected/read-only path checks then apply to the effective MCP tool; malformed, oversized, scalar, array, or excessively nested proxy payloads fail closed.
559
+ - Runtime permission profiles control autonomy: `read-only`, `workspace-write`, and `trusted-full-access`. The full-access profile is explicit and auditable; it does not disable protected-path checks, secret redaction, capability lock integrity, or destructive/external confirmations.
560
+ - Protected paths are matched case-insensitively, existing aliases are resolved to their canonical repository path, and scope-aware filesystem tools reject repository escape or symbolic-link traversal.
561
+ - Path-like strings are percent-decoded once before matching. Excessively nested tool input fails closed instead of being silently skipped.
562
+ - Known content fields such as `content`, `query`, `pattern`, `text`, and `command` are excluded from generic path extraction to preserve normal search/edit behavior. Tool-specific checks still validate `grep.glob` and `find.pattern` when they explicitly target protected paths.
563
+ - The ambiguous `source` field remains metadata for configured external providers and piagent tools, but is treated as a filesystem path for file-oriented tools and unknown/local tools; protected-path and read-scope checks then apply before execution.
564
+ - Broad `grep`, `find`, and `ls` sweeps get result-filter backstops: protected file content lines or protected path metadata are redacted before the model sees output. Text tool results and JSON-like result details also pass through shared sensitive-data redaction; image, audio, and resource payloads are left intact.
565
+ - The redaction release gate is a synthetic/internal benchmark for contextual recall, benign preservation, structured fields, and bounded large output. The public security threat model maps current assumptions, attack vectors, controls, and residual risks; it is not an independent audit. Stronger assurance still requires a broader OS/shell matrix, more parser fuzzing, continued symlink/path-traversal testing, third-party review, and an LTS/backport policy. Opaque entropy without a credential-bearing context and transformed output such as base64-encoded content remain outside the redaction guarantee.
566
+ - Raw `bash` access to protected paths is blocked through shell operand extraction. The guard covers partial shell globs, bare filenames, canonical symbolic-link aliases, and attached input/output redirections. `.pi/piagent-state/**` and `.pi/piagent-profile.json` are self-protected; use `piagent_context` and piagent task tools instead.
567
+ - External writes launched through guarded shell tools are confirmation-gated as well as direct provider tools. This includes GitHub CLI write actions and non-read-only `curl`/`wget` forms, including common execution wrappers; known read/list/GET forms remain non-interactive.
568
+ - Verify evidence is accepted only when it matches an observed Pi bash tool result after task start. The observed ledger is persisted under `.pi/piagent-state/observed-bash.jsonl`, so parent agents can validate bash results produced by guarded subagent processes.
569
+ - Observed command identity is retained as a SHA-256 hash while sensitive command text is redacted at both the in-memory and persisted evidence boundaries.
570
+ - Passing final gates require an observed exit `0` command that exactly matches one of the task/profile `verifyCommands`; ad-hoc commands such as `true`, `echo ok`, or `npm test || true` are advisory only.
571
+ - Project memory files are private-by-default in generated projects; opt in to shared memory only after review/redaction.
572
+ - It is not an OS sandbox or complete security boundary. It depends on the controlled tool paths and shell parsing that the platform observes, and it cannot stop another process with the same OS permissions from reading or writing outside the guard. For untrusted code, untrusted prompts, or adversarial workloads, run Pi inside an isolated container/VM with filesystem, process, network, and credential boundaries.
573
+ - Release verification audits the small helper dependency tree separately from the exact Pi host and pinned optional add-ons at the high-severity gate. Upstream lower-severity findings are still reported and tracked; a green helper-only audit is not treated as proof that the deployed runtime tree is clean.
574
+
575
+ Still requires project-specific validation for:
576
+
577
+ - high-risk production changes;
578
+ - provider/model changes with materially different behavior;
579
+ - complex parallel writer workflows;
580
+ - environments requiring hard filesystem, network, or process sandboxing outside Pi.
581
+
582
+ ## Security reports
583
+
584
+ Report suspected vulnerabilities privately using the process in [SECURITY.md](SECURITY.md). Do not put live credentials, OAuth sessions, customer data, or exploit details in a public issue.
585
+
586
+ ## License
587
+
588
+ MIT License. See [LICENSE](LICENSE).
package/SECURITY.md ADDED
@@ -0,0 +1,38 @@
1
+ # Security policy
2
+
3
+ ## Supported versions
4
+
5
+ Security fixes are provided for the latest published release only. Older releases and moving development sources do not receive a long-term support guarantee. Team deployments should use an exact release tag or reviewed commit and upgrade after reviewing the changelog and compatibility matrix.
6
+
7
+ ## Report a vulnerability privately
8
+
9
+ Do not open a public issue for a suspected vulnerability. Use [GitHub private vulnerability reporting](https://github.com/Vt-mmm/piagent/security/advisories/new) so maintainers can investigate before details are disclosed.
10
+
11
+ Include:
12
+
13
+ - the affected release tag or commit SHA;
14
+ - operating system, shell, Node.js version, Pi version, permission profile, and relevant tool name;
15
+ - a minimal reproduction using synthetic credentials or files only;
16
+ - the observed impact and the result you expected;
17
+ - any proposed mitigation or regression test.
18
+
19
+ Never include real tokens, OAuth sessions, `auth.json`, `.env` contents, customer data, or production credentials. Revoke any credential that may have been exposed before submitting the report.
20
+
21
+ Maintainers handle reports on a best-effort basis and will coordinate validation, remediation, release notes, and disclosure with the reporter. Accepted reports may use a GitHub Security Advisory and CVE request when appropriate. This project does not currently promise a fixed response-time SLA or long-term support window.
22
+
23
+ ## Security scope
24
+
25
+ In scope:
26
+
27
+ - protected-path, path-scope, read-only, confirmation, and secret-redaction bypasses in controlled Pi tool calls;
28
+ - capability-lock or policy-integrity bypasses;
29
+ - installer, release identity, packaged-artifact, or dependency provenance issues;
30
+ - unintended publication of credentials or local runtime state by project templates or package output.
31
+
32
+ The Piagent guard is an application-level policy enforcement layer, not an operating-system security boundary. Pi packages and trusted repository code run with the operator's OS permissions. A process, dependency, interpreter payload, or tool path outside the guard's observation can access anything allowed by those permissions. Untrusted repositories, prompts, and workloads require a separate container or VM with filesystem, process, network, and credential isolation.
33
+
34
+ Reports that apply only to an upstream dependency should also be coordinated with that upstream maintainer. Public feature requests, documentation corrections without security impact, and attacks that already require full control of the trusted operating-system account are normally outside this policy.
35
+
36
+ ## Disclosure
37
+
38
+ Please allow maintainers a reasonable opportunity to reproduce and release a fix before public disclosure. Security fixes will describe affected versions, impact, mitigation, verification, and remaining limitations without publishing live secrets or exploit material that creates unnecessary risk.