@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,229 @@
|
|
|
1
|
+
# Distribution standard
|
|
2
|
+
|
|
3
|
+
## Nguyên tắc
|
|
4
|
+
|
|
5
|
+
Repo này phải chạy được cho nhiều project/domain khác nhau. Vì vậy:
|
|
6
|
+
|
|
7
|
+
- default adapter không chứa domain riêng;
|
|
8
|
+
- `.pi/settings.json` trong project phải dùng package source portable: `git:` hoặc `npm:`;
|
|
9
|
+
- local absolute path chỉ dùng khi dev platform;
|
|
10
|
+
- OAuth, trust, sessions, cache, piagent-state không commit;
|
|
11
|
+
- project-specific/private profiles không nằm trong default `adapters/`.
|
|
12
|
+
|
|
13
|
+
## Package source chuẩn
|
|
14
|
+
|
|
15
|
+
| Use case | Package source |
|
|
16
|
+
|---|---|
|
|
17
|
+
| Team pinned release | `git:github.com/Vt-mmm/piagent@v1.0.0` |
|
|
18
|
+
| Personal/sandbox dev | `git:github.com/Vt-mmm/piagent` |
|
|
19
|
+
| Enterprise npm | `npm:@your-scope/platform@x.y.z` |
|
|
20
|
+
| Local platform dev | `/path/to/piagent` |
|
|
21
|
+
|
|
22
|
+
Latest tiện cho máy cá nhân muốn nhận cập nhật nhanh. Pin tag/commit cho `.pi/settings.json` trong project nghiêm túc để tránh workflow đổi bất ngờ giữa các developer.
|
|
23
|
+
|
|
24
|
+
## Release/install channels
|
|
25
|
+
|
|
26
|
+
| Channel | Command | Target | Policy |
|
|
27
|
+
|---|---|---|---|
|
|
28
|
+
| `stable` | `bash scripts/install-global.sh --stable` | Helper release tag resolved to commit SHA, currently `v1.0.0` | Install the Pi package matching the helper. |
|
|
29
|
+
| `exact` | `bash scripts/install-global.sh --version vX.Y.Z --resolve-tag` | Requested tag resolved to commit SHA | Pi-package-only rollout, rollback, and incident recovery. |
|
|
30
|
+
| `dev` | `bash scripts/install-global.sh --dev` | Moving Git source | Personal/sandbox only; do not commit into project settings. |
|
|
31
|
+
| `local` | `bash scripts/install-global.sh --local` | Current checkout path | Platform development only. |
|
|
32
|
+
|
|
33
|
+
Always preview non-local rollout first:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bash scripts/install-global.sh --stable --dry-run
|
|
37
|
+
bash scripts/install-global.sh --version vX.Y.Z --resolve-tag --dry-run
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Stable and resolved exact installs fail closed when the release tag cannot be resolved from GitHub. The install output prints the tag, resolved commit, and final `git:` package source before running `pi install`.
|
|
41
|
+
|
|
42
|
+
`currentRelease` trong output là version của npm-global helper đang chạy. `--version` chỉ đổi Pi package; nó không tự thay binary `piagent-*` trên `PATH`.
|
|
43
|
+
|
|
44
|
+
## Repo root là Pi package
|
|
45
|
+
|
|
46
|
+
Root `package.json` có `pi` manifest trỏ tới:
|
|
47
|
+
|
|
48
|
+
- `packages/piagent-core/extensions/piagent-guard.ts`
|
|
49
|
+
- `packages/piagent-core/skills`
|
|
50
|
+
- `packages/piagent-core/prompts`
|
|
51
|
+
|
|
52
|
+
Do đó team có thể:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pi install git:github.com/Vt-mmm/piagent@v1.0.0
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Không cần biết internal folder `packages/piagent-core`. Source không pin chỉ dành cho personal/sandbox như bảng channel ở trên.
|
|
59
|
+
|
|
60
|
+
## Default team setup
|
|
61
|
+
|
|
62
|
+
Team nên install global package một lần:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
node --version # >= 22.19.0
|
|
66
|
+
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.81.1
|
|
67
|
+
npm install -g --ignore-scripts github:Vt-mmm/piagent#v1.0.0
|
|
68
|
+
piagent-install --stable --dry-run
|
|
69
|
+
piagent-install --stable
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`pi install git:github.com/Vt-mmm/piagent@v1.0.0` vẫn hợp lệ nếu chỉ cần cài Pi package. Lệnh đó không tự tạo các binary terminal `piagent-*`; muốn có helper global thì dùng `npm install -g --ignore-scripts github:Vt-mmm/piagent#v1.0.0`.
|
|
73
|
+
|
|
74
|
+
Support matrix hiện tại: macOS Apple Silicon + Bash và Linux x64 + Bash đã được verify; macOS Intel + Bash và Linux ARM64 + Bash là supported target cần chạy smoke trước rollout; native Windows chưa phải target rollout team; WSL2 experimental. Chi tiết và version runtime nằm trong [release/install policy](release-install-policy.md).
|
|
75
|
+
|
|
76
|
+
Sau đó project nào cũng:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cd /path/to/project
|
|
80
|
+
pi
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Project profile được chọn trong Pi bằng `/onboard-project` hoặc `/profile`, không bắt buộc chạy bash init.
|
|
84
|
+
|
|
85
|
+
Sau setup, bước first-run trong Pi là:
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
/login
|
|
89
|
+
<select provider/model>
|
|
90
|
+
/mcp
|
|
91
|
+
/subagents-doctor
|
|
92
|
+
/onboard-project
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`/onboard-project` ghi `.pi/project-context.md`; đây là snapshot context dùng chung cho các task sau.
|
|
96
|
+
Nó cũng ghi `.pi/context-index.json`; đây là compact advisory map có citation để agent tìm đúng điểm vào repo mà không scout rộng lại.
|
|
97
|
+
|
|
98
|
+
## Optional preseed setup
|
|
99
|
+
|
|
100
|
+
Nếu muốn commit sẵn `.pi/piagent-profile.json` vào repo hoặc bootstrap bằng CI:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
bash scripts/setup.sh /path/to/project \
|
|
104
|
+
--profile be-readonly-fe \
|
|
105
|
+
--package-source git:github.com/Vt-mmm/piagent@v1.0.0 \
|
|
106
|
+
--mcp-preset core \
|
|
107
|
+
--subagents-preset safe
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Với project cần scout BE nhưng chỉ implement FE, có thể chọn trong Pi:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
/profile be-readonly-fe
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Project init output
|
|
117
|
+
|
|
118
|
+
`scripts/setup.sh` hoặc `scripts/init-project.sh` tạo scaffold project:
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
project/
|
|
122
|
+
├─ AGENTS.md
|
|
123
|
+
├─ .gitignore
|
|
124
|
+
├─ REVIEW_GUIDELINES.md
|
|
125
|
+
├─ .mcp.json
|
|
126
|
+
└─ .pi/
|
|
127
|
+
├─ settings.json
|
|
128
|
+
├─ piagent-profile.json
|
|
129
|
+
├─ project-context.md
|
|
130
|
+
├─ context-index.json
|
|
131
|
+
├─ memory/
|
|
132
|
+
│ ├─ memory_summary.md
|
|
133
|
+
│ └─ MEMORY.md
|
|
134
|
+
├─ mcp.json
|
|
135
|
+
└─ .gitignore
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Files nên commit:
|
|
139
|
+
|
|
140
|
+
- `AGENTS.md`
|
|
141
|
+
- `.gitignore`
|
|
142
|
+
- `REVIEW_GUIDELINES.md`
|
|
143
|
+
- `.mcp.json`
|
|
144
|
+
- `.pi/settings.json`
|
|
145
|
+
- `.pi/piagent-profile.json`
|
|
146
|
+
- `.pi/project-context.md`
|
|
147
|
+
- `.pi/context-index.json`
|
|
148
|
+
- `.pi/mcp.json`
|
|
149
|
+
- `.pi/.gitignore`
|
|
150
|
+
|
|
151
|
+
Files không commit:
|
|
152
|
+
|
|
153
|
+
- `.pi/piagent-state/`
|
|
154
|
+
- `.pi/task-inbox/`
|
|
155
|
+
- `.pi/benchmarks/`
|
|
156
|
+
- `.pi/memory/memory_summary.md`
|
|
157
|
+
- `.pi/memory/MEMORY.md`
|
|
158
|
+
- `.pi/memory/local/`
|
|
159
|
+
- `.pi/memory/state.sqlite`
|
|
160
|
+
- `.pi/memory/raw_memories.md`
|
|
161
|
+
- `.pi/memory/rollout_summaries/`
|
|
162
|
+
- `.pi/memory/extensions/ad_hoc/`
|
|
163
|
+
- `.pi/sessions/`
|
|
164
|
+
- `.pi/todos/`
|
|
165
|
+
- `.pi/auth.json`
|
|
166
|
+
- `.env`
|
|
167
|
+
- `.pi-subagents/`
|
|
168
|
+
- `progress.md` nếu chỉ là scratch runtime
|
|
169
|
+
|
|
170
|
+
## Release, update và rollback
|
|
171
|
+
|
|
172
|
+
[Release/install policy](release-install-policy.md) là checklist canonical duy nhất. Production docs chỉ được promote sau khi tag đã tồn tại và stable dry-run resolve đúng commit SHA.
|
|
173
|
+
|
|
174
|
+
Full platform update phải đồng bộ Pi host, npm-global helper và Pi package:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.81.1
|
|
178
|
+
npm install -g --ignore-scripts github:Vt-mmm/piagent#vX.Y.Z
|
|
179
|
+
piagent-install --stable --dry-run
|
|
180
|
+
piagent-install --stable
|
|
181
|
+
piagent-doctor /path/to/project --strict-share
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Full rollback dùng cùng flow với target trước đó. Lấy exact host version từ release policy của target; không giả định host hiện tại tương thích với release cũ:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
TARGET_PI_VERSION=x.y.z
|
|
188
|
+
npm install -g --ignore-scripts "@earendil-works/pi-coding-agent@$TARGET_PI_VERSION"
|
|
189
|
+
npm install -g --ignore-scripts github:Vt-mmm/piagent#vPREVIOUS
|
|
190
|
+
piagent-install --stable --dry-run
|
|
191
|
+
piagent-install --stable
|
|
192
|
+
piagent-doctor /path/to/project --strict-share
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Nếu chủ ý chỉ đổi Pi package và giữ terminal helper hiện tại:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
piagent-install --version vX.Y.Z --resolve-tag --dry-run
|
|
199
|
+
piagent-install --version vX.Y.Z --resolve-tag
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Security review
|
|
203
|
+
|
|
204
|
+
Pi packages run with full system access. Before team rollout:
|
|
205
|
+
|
|
206
|
+
- review every extension file;
|
|
207
|
+
- no network call during startup;
|
|
208
|
+
- network only inside explicit tools;
|
|
209
|
+
- no secret logging;
|
|
210
|
+
- destructive bash blocked;
|
|
211
|
+
- project local profile loaded only after Pi trust or explicit env override.
|
|
212
|
+
|
|
213
|
+
## Herdr standard
|
|
214
|
+
|
|
215
|
+
Herdr integration is user-local:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
herdr integration install pi
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Do not assume Herdr is running. Scripts must degrade cleanly.
|
|
222
|
+
|
|
223
|
+
## Official docs
|
|
224
|
+
|
|
225
|
+
- Pi packages: https://pi.dev/docs/latest/packages
|
|
226
|
+
- Pi settings/project trust: https://pi.dev/docs/latest/settings
|
|
227
|
+
- Pi extensions/dependencies: https://pi.dev/docs/latest/extensions
|
|
228
|
+
- Pi MCP adapter: https://pi.dev/packages/pi-mcp-adapter
|
|
229
|
+
- Herdr integrations: https://herdr.dev/docs/integrations/
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Herdr workflow
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Herdr dùng để quản lý nhiều session/pane agent. Pi core không cần tự làm subagent ngay từ đầu.
|
|
6
|
+
|
|
7
|
+
## Setup integration
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
herdr integration install pi
|
|
11
|
+
herdr integration status
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Nếu dùng custom Pi agent dir:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
PI_CODING_AGENT_DIR=/path/to/pi-agent herdr integration install pi
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Daily flow
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
cd <project>
|
|
24
|
+
herdr
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Lần đầu trong project, mở pane Pi rồi chạy:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
/login
|
|
31
|
+
<select provider/model>
|
|
32
|
+
/onboard-project
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Sau khi `.pi/project-context.md` đã được ghi, mới chạy `/task` cho implementation.
|
|
36
|
+
|
|
37
|
+
Pane đề xuất:
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
project
|
|
41
|
+
├─ pi-task implement current task
|
|
42
|
+
├─ pi-review read-only review
|
|
43
|
+
├─ pi-qa verify/test
|
|
44
|
+
└─ pi-notes decisions, handoff, and follow-up
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Rule
|
|
48
|
+
|
|
49
|
+
- Herdr là orchestrator terminal/session, không phải security boundary.
|
|
50
|
+
- Destructive/action gate vẫn nằm ở Pi extension/policy.
|
|
51
|
+
- OAuth vẫn login trong Pi.
|
|
52
|
+
|
|
53
|
+
## Nguồn
|
|
54
|
+
|
|
55
|
+
- Herdr install: https://herdr.dev/docs/install/
|
|
56
|
+
- Herdr integrations: https://herdr.dev/docs/integrations/
|
|
57
|
+
- Herdr workflow: https://herdr.dev/docs/how-to-work/
|
|
58
|
+
- Herdr CLI reference: https://herdr.dev/docs/cli-reference/
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# MCP và tool policy
|
|
2
|
+
|
|
3
|
+
## Kết luận hiện tại
|
|
4
|
+
|
|
5
|
+
Pi core không hard-code MCP. Platform của mình cài `pi-mcp-adapter` để Pi dùng MCP theo kiểu token-efficient: một proxy tool `mcp(...)`, server lazy-connect, metadata cache, output guard. Project profile chỉ khai báo capability được phép; MCP config mới khai báo server thật.
|
|
6
|
+
|
|
7
|
+
Từ `v0.3.7`, repo có thêm:
|
|
8
|
+
|
|
9
|
+
- `piagent-mcp` / `scripts/configure-mcp.sh`;
|
|
10
|
+
- MCP preset `core`, `popular`, `all`, `design`, `design-local`, `browser`, `docs`, `github`;
|
|
11
|
+
- template `.mcp.json` project-shared;
|
|
12
|
+
- doctor warning khi adapter có nhưng không có MCP server nào.
|
|
13
|
+
|
|
14
|
+
## Cấu hình một lần cho máy cá nhân/team
|
|
15
|
+
|
|
16
|
+
Global install mặc định sẽ cài adapter và seed preset `core` nếu dùng `scripts/setup.sh` hoặc `scripts/install-global.sh --with-mcp`:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bash /path/to/piagent/scripts/setup.sh . \
|
|
20
|
+
--profile auto \
|
|
21
|
+
--package-source git:github.com/Vt-mmm/piagent@vX.Y.Z \
|
|
22
|
+
--mcp-preset core
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Chỉnh MCP sau này:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
piagent-mcp --preset popular --scope global --replace
|
|
29
|
+
piagent-mcp --preset design --scope global --replace
|
|
30
|
+
piagent-mcp --preset all --scope project --project /path/to/project
|
|
31
|
+
piagent-mcp --list
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Nếu clone repo GitHub và chưa link npm bin:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
bash /path/to/piagent/scripts/configure-mcp.sh --preset popular --scope global --replace
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`--replace` cập nhật các server ID thuộc preset về baseline đã pin và vẫn giữ nguyên server ID khác. Luồng install/upgrade toàn cục luôn dùng chế độ này để không duy trì dependency động từ cấu hình cũ.
|
|
41
|
+
|
|
42
|
+
Trong Pi:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
/mcp
|
|
46
|
+
/mcp setup
|
|
47
|
+
/mcp tools
|
|
48
|
+
/mcp reconnect
|
|
49
|
+
/mcp-auth figma
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## MCP config layers
|
|
53
|
+
|
|
54
|
+
Theo `pi-mcp-adapter`, thứ tự config nên giữ như sau:
|
|
55
|
+
|
|
56
|
+
| File | Scope | Nên dùng khi nào |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `~/.config/mcp/mcp.json` | shared global MCP config | mặc định cho nhiều agent/client và nhiều project |
|
|
59
|
+
| `~/.pi/agent/mcp.json` | Pi global override | chỉ khi cần override riêng cho Pi |
|
|
60
|
+
| `.mcp.json` | project shared MCP config | config server đặc thù repo, có thể commit |
|
|
61
|
+
| `.pi/mcp.json` | Pi project override | override riêng Pi trong một repo |
|
|
62
|
+
|
|
63
|
+
Quy ước của platform:
|
|
64
|
+
|
|
65
|
+
- global baseline viết vào `~/.config/mcp/mcp.json`;
|
|
66
|
+
- project baseline viết vào `.mcp.json`;
|
|
67
|
+
- `.pi/mcp.json` để override Pi-specific, không nhét secret;
|
|
68
|
+
- token strategy mặc định: `directTools: false`, dùng proxy `mcp(...)`;
|
|
69
|
+
- chỉ bật `directTools` cho server nhỏ hoặc tool thật sự dùng thường xuyên.
|
|
70
|
+
|
|
71
|
+
## Preset MCP
|
|
72
|
+
|
|
73
|
+
| Preset | Server | Mục đích |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `minimal` | none | chỉ seed settings an toàn |
|
|
76
|
+
| `docs` | Context7 | docs mới của framework/library |
|
|
77
|
+
| `browser` | Chrome DevTools, Playwright | inspect UI/runtime/browser automation |
|
|
78
|
+
| `github` | GitHub MCP | issue/PR/repo/release workflow |
|
|
79
|
+
| `design` | Figma remote | design-to-code qua Figma OAuth |
|
|
80
|
+
| `design-local` | Figma desktop | Figma desktop Dev Mode MCP local |
|
|
81
|
+
| `web` | Context7, Chrome DevTools, Playwright | FE/web workflow |
|
|
82
|
+
| `core` | Context7, Chrome DevTools, GitHub | default team baseline |
|
|
83
|
+
| `popular` | core + Playwright + Figma remote | baseline nhiều team dev dùng |
|
|
84
|
+
| `all` | popular + Figma desktop | đầy đủ, dùng khi muốn sẵn cả local Figma |
|
|
85
|
+
|
|
86
|
+
## Server baseline
|
|
87
|
+
|
|
88
|
+
### Context7
|
|
89
|
+
|
|
90
|
+
MCP config:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"context7": {
|
|
96
|
+
"command": "npx",
|
|
97
|
+
"args": ["-y", "@upstash/context7-mcp@3.2.4"],
|
|
98
|
+
"env": {
|
|
99
|
+
"CONTEXT7_API_KEY": "${CONTEXT7_API_KEY}"
|
|
100
|
+
},
|
|
101
|
+
"lifecycle": "lazy",
|
|
102
|
+
"directTools": false
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Khuyến nghị cho Pi: có thể cài thêm Pi-native package nếu muốn tool/docs tự nhiên hơn MCP:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pi install npm:@upstash/context7-pi@0.1.1
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
API key là optional nhưng nên dùng cho quota tốt hơn:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
export CONTEXT7_API_KEY=ctx7sk_...
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Figma
|
|
121
|
+
|
|
122
|
+
Remote MCP:
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"mcpServers": {
|
|
127
|
+
"figma": {
|
|
128
|
+
"url": "https://mcp.figma.com/mcp",
|
|
129
|
+
"auth": "oauth",
|
|
130
|
+
"lifecycle": "lazy",
|
|
131
|
+
"directTools": false
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Local desktop MCP:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"figma-desktop": {
|
|
143
|
+
"url": "http://127.0.0.1:3845/mcp",
|
|
144
|
+
"lifecycle": "lazy",
|
|
145
|
+
"directTools": false
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Khuyến nghị thực tế:
|
|
152
|
+
|
|
153
|
+
- dùng remote Figma MCP khi account/org hỗ trợ OAuth;
|
|
154
|
+
- dùng desktop local khi cần selection-based Dev Mode trong app Figma;
|
|
155
|
+
- nếu muốn Pi-native thay vì MCP, có thể cài `pi install npm:pi-mono-figma@0.2.2` sau khi hoàn tất security và license review.
|
|
156
|
+
|
|
157
|
+
### Browser
|
|
158
|
+
|
|
159
|
+
Chrome DevTools:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcpServers": {
|
|
164
|
+
"chrome-devtools": {
|
|
165
|
+
"command": "npx",
|
|
166
|
+
"args": ["-y", "chrome-devtools-mcp@1.6.0", "--no-performance-crux"],
|
|
167
|
+
"env": {
|
|
168
|
+
"CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS": "1",
|
|
169
|
+
"CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS": "1"
|
|
170
|
+
},
|
|
171
|
+
"lifecycle": "lazy",
|
|
172
|
+
"directTools": false
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Playwright:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"mcpServers": {
|
|
183
|
+
"playwright": {
|
|
184
|
+
"command": "npx",
|
|
185
|
+
"args": ["-y", "@playwright/mcp@0.0.78"],
|
|
186
|
+
"lifecycle": "lazy",
|
|
187
|
+
"directTools": false
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### GitHub
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"mcpServers": {
|
|
198
|
+
"github": {
|
|
199
|
+
"command": "docker",
|
|
200
|
+
"args": [
|
|
201
|
+
"run",
|
|
202
|
+
"-i",
|
|
203
|
+
"--rm",
|
|
204
|
+
"-e",
|
|
205
|
+
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
|
206
|
+
"-e",
|
|
207
|
+
"GITHUB_READ_ONLY=1",
|
|
208
|
+
"-e",
|
|
209
|
+
"GITHUB_LOCKDOWN_MODE=1",
|
|
210
|
+
"ghcr.io/github/github-mcp-server@sha256:2b0c48b070f61e9d3969269ead600f62d00fb237b60ac849ef3d166ee7de9ad3"
|
|
211
|
+
],
|
|
212
|
+
"env": {
|
|
213
|
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
|
|
214
|
+
},
|
|
215
|
+
"lifecycle": "lazy",
|
|
216
|
+
"directTools": false
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Token không được commit:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
export GITHUB_PERSONAL_ACCESS_TOKEN=<github-token>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Preset mặc định chạy GitHub MCP ở read-only và lockdown mode. Bất kỳ cấu hình write nào cũng phải được tách riêng, giới hạn credential và yêu cầu human confirmation.
|
|
229
|
+
|
|
230
|
+
## Tool policy
|
|
231
|
+
|
|
232
|
+
Runtime tool registry nằm trong `packages/piagent-core/policies/base-policy.json`.
|
|
233
|
+
|
|
234
|
+
Tool:
|
|
235
|
+
|
|
236
|
+
```text
|
|
237
|
+
piagent_tool_policy_check
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Default `toolRegistry=advisory`: agent nhận warning khi tool chưa map capability. Project ổn định có thể bật `toolRegistry=enforce` trong `.pi/piagent-profile.json`.
|
|
241
|
+
|
|
242
|
+
Protected-path gate độc lập với registry mode. Dù tool registry đang `advisory`, mọi raw tool call có path-like string trỏ vào protected path sẽ bị block trước khi tool chạy. Cơ chế này áp dụng cho Pi built-ins (`read`, `write`, `edit`, `grep`, `find`, `ls`) và custom/MCP tools nếu tool call đi qua Pi `tool_call` hook.
|
|
243
|
+
|
|
244
|
+
Extractor walk nested object/array và `file://` URI. Path-like string được percent-decode một lần trước khi match. Field lạ mặc định được coi là path-like; chỉ leaf field nội dung đã biết như `content`, `query`, `pattern`, `text`, và `command` được skip để tránh false positive search/edit. Input lồng quá sâu vượt `MAX_TOOL_INPUT_INSPECTION_DEPTH=32` sẽ fail-closed.
|
|
245
|
+
|
|
246
|
+
Search/list channels cũng được kiểm:
|
|
247
|
+
|
|
248
|
+
- `grep.glob` bị block nếu glob nhắm protected path rõ ràng như `.env*`, `auth.json`, `.pi/piagent-state/**`, hoặc `piagent-profile.json`;
|
|
249
|
+
- `find.pattern` bị block nếu pattern nhắm protected path rõ ràng;
|
|
250
|
+
- broad pattern như `*.json` được phép để không phá search workflow phổ biến;
|
|
251
|
+
- broad `grep/find/ls` được phép chạy khi không target trực tiếp, nhưng `tool_result` sẽ redact content line hoặc path metadata từ protected files trước khi model thấy output.
|
|
252
|
+
|
|
253
|
+
| Mode | Allowed intent |
|
|
254
|
+
|---|---|
|
|
255
|
+
| `readOnly` | đọc file, grep, find, list, MCP read-only |
|
|
256
|
+
| `memory` | đọc/search memory, ghi note explicit-only |
|
|
257
|
+
| `docsWrite` | sửa docs/plans/report |
|
|
258
|
+
| `sourceWrite` | sửa source theo protected path + verify |
|
|
259
|
+
| `ship` | release/commit/push/deploy, cần human gate |
|
|
260
|
+
|
|
261
|
+
## Rule bắt buộc
|
|
262
|
+
|
|
263
|
+
- Capability chưa đăng ký: clean skip, không tự đoán tool.
|
|
264
|
+
- Tool destructive: block hoặc hỏi xác nhận.
|
|
265
|
+
- Tool external-provider: hỏi xác nhận nếu có side effect/cost.
|
|
266
|
+
- MCP response phải ngắn; server tự build phải có concise/detailed mode.
|
|
267
|
+
- Memory tool không được lưu secret/raw private data; memory là advisory, source hiện tại là authority.
|
|
268
|
+
- Không commit token/API key/OAuth file.
|
|
269
|
+
- Không bật `directTools: true` đại trà cho server lớn; sẽ phá lợi thế token của Pi.
|
|
270
|
+
|
|
271
|
+
## Built-in platform tools
|
|
272
|
+
|
|
273
|
+
| Tool | Intent |
|
|
274
|
+
|---|---|
|
|
275
|
+
| `piagent_context` | Active profile/context/verify/MCP/memory overview. |
|
|
276
|
+
| `piagent_exec_policy_check` | Evaluate shell command before running. |
|
|
277
|
+
| `piagent_context_budget` | Check candidate context files against hard caps. |
|
|
278
|
+
| `piagent_tool_policy_check` | Check tool capability registration. |
|
|
279
|
+
| `piagent_task_gate_check` | Check task readiness before final DONE. |
|
|
280
|
+
| `piagent_memory_status` | Project memory policy/files/rules. |
|
|
281
|
+
| `piagent_memory_search` | Keyword search `.pi/memory` markdown. |
|
|
282
|
+
| `piagent_memory_note` | Append explicit durable memory note. |
|
|
283
|
+
| `piagent_memory_citation_record` | Record memory evidence in task contract. |
|
|
284
|
+
| `piagent_context_index_status` | Inspect the compact advisory project context index. |
|
|
285
|
+
| `piagent_context_index_search` | Search context-index nodes before broad re-scouting. |
|
|
286
|
+
| `piagent_context_index_record` | Record cited project/profile/tech/task context after onboarding or approved handoff. |
|
|
287
|
+
| `piagent_profile_options` | Return reusable project profile choices. |
|
|
288
|
+
| `piagent_profile_apply` | Apply a selected profile and deterministic capability lock. |
|
|
289
|
+
| `piagent_profile_tech_options` | Return select-style tech options for a profile family. |
|
|
290
|
+
| `piagent_profile_tech_apply` | Apply profile + selected role tech stack and Context7 placeholders. |
|
|
291
|
+
| `piagent_profile_tech_context_record` | Record a concise Context7 evidence snapshot for a selected tech. |
|
|
292
|
+
| `piagent_task_start` | Create Task Implementation Contract. |
|
|
293
|
+
| `piagent_context_record` | Record context manifest for task. |
|
|
294
|
+
| `piagent_verify_record` | Record verify evidence only when it matches an observed Pi bash result after task start. Passing gate also requires exact match with `task.verifyCommands`. |
|
|
295
|
+
| `piagent_trace_record` | Record handoff/final trace. |
|
|
296
|
+
|
|
297
|
+
## Core capabilities
|
|
298
|
+
|
|
299
|
+
| Capability | Meaning |
|
|
300
|
+
|---|---|
|
|
301
|
+
| `filesystem-readonly` | Read/list/search repository files. |
|
|
302
|
+
| `filesystem-write` | Edit/write non-protected project files. |
|
|
303
|
+
| `shell` | Run shell commands through exec policy. |
|
|
304
|
+
| `github` | GitHub/MCP/CLI workflows when configured. |
|
|
305
|
+
| `browser` | Browser/UI/runtime inspection when configured. |
|
|
306
|
+
| `memory` | Project memory tools. |
|
|
307
|
+
|
|
308
|
+
## Nguồn
|
|
309
|
+
|
|
310
|
+
- Pi MCP adapter: https://pi.dev/packages/pi-mcp-adapter
|
|
311
|
+
- Context7 Pi package: https://pi.dev/packages/@upstash/context7-pi
|
|
312
|
+
- Figma remote MCP docs: https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/
|
|
313
|
+
- Figma desktop MCP docs: https://developers.figma.com/docs/figma-mcp-server/local-server-installation/
|
|
314
|
+
- GitHub MCP server: https://github.com/github/github-mcp-server
|
|
315
|
+
- MCP protocol: https://modelcontextprotocol.io/
|
|
316
|
+
- Pi extension tool events: https://pi.dev/docs/latest/extensions
|