@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,1080 @@
|
|
|
1
|
+
# Pi Agent Platform - Operator manual tiếng Việt
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Tài liệu này là hướng dẫn vận hành end-to-end cho anh/team:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd /path/to/project
|
|
9
|
+
pi
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Từ đó Pi có thể login provider, chọn model, onboard project, chạy task, kiểm soát tool, theo dõi token, resume session, dùng MCP, và dùng subagent khi task đủ lớn.
|
|
13
|
+
|
|
14
|
+
Runtime team nên pin release tag hoặc commit đã review. Latest chỉ dùng cho máy cá nhân/sandbox khi chấp nhận cập nhật nhanh.
|
|
15
|
+
|
|
16
|
+
Support matrix release 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 `piagent-doctor` + smoke test trước khi rollout rộng; native Windows chưa phải target rollout team; WSL2 experimental/chưa release-gate. Node.js tối thiểu là `22.19.0`, Pi Coding Agent là `0.81.1`.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
node --version # >= 22.19.0
|
|
20
|
+
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.81.1
|
|
21
|
+
npm install -g --ignore-scripts github:Vt-mmm/piagent#v1.0.0
|
|
22
|
+
piagent-install --stable --dry-run
|
|
23
|
+
piagent-install --stable
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Khi seed `.pi/settings.json` cho team/repo cần audit lặp lại, giữ package source dạng pinned tag như `git:github.com/Vt-mmm/piagent@v1.0.0`. Máy cá nhân có thể dùng `git:github.com/Vt-mmm/piagent` để theo latest.
|
|
27
|
+
|
|
28
|
+
Nếu đang ở source checkout của platform, dùng helper theo channel để preview trước khi đổi:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
bash scripts/install-global.sh --stable --dry-run
|
|
32
|
+
bash scripts/install-global.sh --stable
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`--stable` sẽ resolve tag release hiện tại thành commit SHA, in ra `tag`, `resolvedCommit`, `source`, rồi mới gọi `pi install`. `currentRelease` là version của npm-global helper đang chạy. Nếu không resolve được tag thì fail-closed.
|
|
36
|
+
|
|
37
|
+
Full update phải đồng bộ exact Pi host trước, rồi npm-global helper và Pi package matching:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.81.1
|
|
41
|
+
npm install -g --ignore-scripts github:Vt-mmm/piagent#vX.Y.Z
|
|
42
|
+
piagent-install --stable --dry-run
|
|
43
|
+
piagent-install --stable
|
|
44
|
+
piagent-doctor /path/to/project --strict-share
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Khi rollback, lấy exact host version từ release policy của `vPREVIOUS`, hạ host có chủ ý rồi mới cài helper `vPREVIOUS`. Host cũ có thể tái đưa dependency finding đã được sửa ở release hiện tại. Nếu chủ ý chỉ đổi Pi package và giữ host/helper hiện tại, dùng `piagent-install --version vX.Y.Z --resolve-tag`. Checklist canonical nằm tại [release/install policy](release-install-policy.md).
|
|
48
|
+
|
|
49
|
+
## Phạm vi đúng của guard
|
|
50
|
+
|
|
51
|
+
Platform này là:
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
Accident brake + prompt-injection speed bump, not a security boundary.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Nghĩa thực tế:
|
|
58
|
+
|
|
59
|
+
- Guard chặn agent gọi tool sai qua `tool_call`.
|
|
60
|
+
- Guard giúp giảm rủi ro đọc `.env`, auth file, guard state, hoặc chạy shell phá hoại.
|
|
61
|
+
- Guard buộc task có context manifest, verify evidence quan sát thật, trace, và final gate.
|
|
62
|
+
- Guard không chặn code đã chạy bên trong process khác, ví dụ `npm test` chạy script độc, dependency bị nhiễm, binary mới build, hoặc repo lạ có script nguy hiểm.
|
|
63
|
+
|
|
64
|
+
Scope dùng phù hợp:
|
|
65
|
+
|
|
66
|
+
- solo/internal;
|
|
67
|
+
- repo tin được;
|
|
68
|
+
- human-in-the-loop;
|
|
69
|
+
- project có thể audit và rollback.
|
|
70
|
+
|
|
71
|
+
Nếu input/repo không tin được hoặc chạy tự động trên CI không có người giám sát, phải thêm isolation tầng OS như container/VM/seccomp/network/credential boundary.
|
|
72
|
+
|
|
73
|
+
## Mental model
|
|
74
|
+
|
|
75
|
+
Có 3 lớp:
|
|
76
|
+
|
|
77
|
+
| Lớp | Nằm ở đâu | Vai trò |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| Pi core | `pi` CLI | Model UI, session, built-in tools `read/bash/edit/write/grep/find/ls`, provider/OAuth, MCP hooks. |
|
|
80
|
+
| Platform package | repo `piagent` | Commands, prompts, guard extension, profiles, MCP/subagent setup, task evidence. |
|
|
81
|
+
| Project state | `<project>/.pi/*` | Profile, project context, task state, memory, MCP override, local benchmark. |
|
|
82
|
+
|
|
83
|
+
Luồng mong muốn:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
install package once
|
|
87
|
+
-> cd project
|
|
88
|
+
-> pi
|
|
89
|
+
-> login/model
|
|
90
|
+
-> onboard project
|
|
91
|
+
-> run task
|
|
92
|
+
-> verify/trace/gate
|
|
93
|
+
-> handoff
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 1. Base setup lần đầu
|
|
97
|
+
|
|
98
|
+
### Cài Pi và package platform
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.81.1
|
|
102
|
+
npm install -g --ignore-scripts github:Vt-mmm/piagent#v1.0.0
|
|
103
|
+
piagent-install --stable --dry-run
|
|
104
|
+
piagent-install --stable
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Nếu dùng Herdr:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
herdr integration install pi
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Kiểm tra package đã load:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
pi list
|
|
117
|
+
pi list --approve
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Nếu project đã tin cậy và muốn mở Pi không bị hỏi trust lại trong lần chạy hiện tại:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
piagent-auto
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Read-only auto-run cho scout/audit:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
piagent-auto --read-only -p "Scout payment mapping. Do not edit source."
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Trusted full-access style run cho repo đã kiểm soát:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
piagent-auto --full-access -p "Run the trusted local benchmark suite."
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`piagent-auto` chỉ wrap `pi --approve` và set permission profile cho lần chạy. Nó không tắt piagent guard: protected paths, redaction, destructive shell checks, task gate, và verify evidence vẫn chạy.
|
|
139
|
+
|
|
140
|
+
### Mở project
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
cd /path/to/project
|
|
144
|
+
pi
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Daily UX không cần set shell profile, không cần chạy bash init trước. Profile chọn trong Pi qua onboarding hoặc `/profile`.
|
|
148
|
+
|
|
149
|
+
### Login provider
|
|
150
|
+
|
|
151
|
+
Trong Pi:
|
|
152
|
+
|
|
153
|
+
```text
|
|
154
|
+
/login
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Chọn provider/account như OpenAI/Codex hoặc Anthropic/Claude. Credential nằm trong Pi user dir, không nằm trong repo và không được commit.
|
|
158
|
+
|
|
159
|
+
### Chọn model và thinking
|
|
160
|
+
|
|
161
|
+
Trong Pi:
|
|
162
|
+
|
|
163
|
+
```text
|
|
164
|
+
/model
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Hotkey:
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
Ctrl+L # mở model selector
|
|
171
|
+
Ctrl+P # cycle model trong scoped list
|
|
172
|
+
Shift+Ctrl+P # cycle ngược
|
|
173
|
+
Shift+Tab # đổi thinking level nếu model hỗ trợ
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Terminal options khi cần mở Pi với model cụ thể:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
pi --model openai-codex/gpt-5.5 --thinking xhigh
|
|
180
|
+
pi --model anthropic/claude-sonnet-5:high
|
|
181
|
+
pi --models "openai-codex/*,anthropic/*sonnet*"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Gợi ý:
|
|
185
|
+
|
|
186
|
+
- Scout/plan đơn giản: dùng model nhanh/thấp hơn.
|
|
187
|
+
- Implement/debug/risk cao: dùng model mạnh/thinking cao.
|
|
188
|
+
- Deploy monitor/CI follow-up: tách session riêng, không giữ context implement quá dài.
|
|
189
|
+
|
|
190
|
+
## 2. Onboard project lần đầu
|
|
191
|
+
|
|
192
|
+
Sau `/login` và `/model`, chạy:
|
|
193
|
+
|
|
194
|
+
```text
|
|
195
|
+
/piagent-commands
|
|
196
|
+
/mcp
|
|
197
|
+
/subagents-doctor
|
|
198
|
+
/onboard-project
|
|
199
|
+
/memory-policy
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`/onboard-project` sẽ:
|
|
203
|
+
|
|
204
|
+
1. đọc repo theo context budget;
|
|
205
|
+
2. detect profile phù hợp;
|
|
206
|
+
3. mở select-style profile/tech setup;
|
|
207
|
+
4. hỏi user trước khi apply nếu workflow chạy qua tool write;
|
|
208
|
+
5. ghi project profile, tech stack và context.
|
|
209
|
+
|
|
210
|
+
File chính được tạo/cập nhật:
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
.pi/piagent-profile.json
|
|
214
|
+
.pi/piagent-profile.lock.json
|
|
215
|
+
.pi/tech-stack.json
|
|
216
|
+
.pi/tech-context/*.json
|
|
217
|
+
.pi/project-context.md
|
|
218
|
+
.pi/context-index.json
|
|
219
|
+
.pi/piagent-state/project-onboarding.json
|
|
220
|
+
.pi/memory/memory_summary.md
|
|
221
|
+
.pi/memory/MEMORY.md
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Nếu `.pi/project-context.md` còn `Generated: not yet`, hoặc `/context-index` báo index đang pending/stale, không nên chạy `/task` implementation lớn. Chạy lại `/onboard-project` trước.
|
|
225
|
+
|
|
226
|
+
### Đổi profile sau này
|
|
227
|
+
|
|
228
|
+
Trong Pi:
|
|
229
|
+
|
|
230
|
+
```text
|
|
231
|
+
/profile list
|
|
232
|
+
/profile setup
|
|
233
|
+
/profile tech setup fullstack
|
|
234
|
+
/profile fullstack
|
|
235
|
+
/profile be-readonly-fe
|
|
236
|
+
/profile web-frontend
|
|
237
|
+
/profile backend-api
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
`/profile setup` ưu tiên UI select: chọn profile trước, rồi chọn tech theo role. Với `fullstack`, team phải chọn frontend, backend và database. Nếu Pi host chưa có select control, command sẽ trả card ngắn kèm lệnh apply deterministic, ví dụ:
|
|
241
|
+
|
|
242
|
+
```text
|
|
243
|
+
/profile tech apply fullstack frontend=nextjs backend=nestjs database=prisma
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Sau khi chọn tech, đọc docs mới qua Context7 rồi record snapshot ngắn vào `.pi/tech-context/*`; không lưu nguyên văn docs dài hoặc secret.
|
|
247
|
+
|
|
248
|
+
Profile thường dùng:
|
|
249
|
+
|
|
250
|
+
| Profile | Khi dùng |
|
|
251
|
+
|---|---|
|
|
252
|
+
| `generic` | Repo chưa rõ cấu trúc. |
|
|
253
|
+
| `web-frontend` | FE-only. |
|
|
254
|
+
| `backend-api` | BE/API work. |
|
|
255
|
+
| `be-readonly-fe` | BE là source-of-truth/read-only, FE là write target. |
|
|
256
|
+
| `fullstack` | FE và BE đều có thể sửa nếu task cho phép. |
|
|
257
|
+
| `node-typescript` | Node/TypeScript library/tooling. |
|
|
258
|
+
| `python` | Python app/library. |
|
|
259
|
+
| `data` | ETL/data pipeline/notebook. |
|
|
260
|
+
| `devops` | Docker/Terraform/Kubernetes/CI/CD. |
|
|
261
|
+
| `mobile` | React Native/Flutter. |
|
|
262
|
+
| `docs` | Docs/manual/portal. |
|
|
263
|
+
|
|
264
|
+
## 3. Optional preseed setup
|
|
265
|
+
|
|
266
|
+
Không phải daily default. Dùng khi muốn tạo sẵn `.pi` files cho project/team:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
bash /path/to/piagent/scripts/setup.sh /path/to/project \
|
|
270
|
+
--project-only \
|
|
271
|
+
--profile auto \
|
|
272
|
+
--package-source git:github.com/Vt-mmm/piagent@v1.0.0 \
|
|
273
|
+
--mcp-preset core \
|
|
274
|
+
--subagents-preset safe
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Nếu npm bins đã link:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
piagent-init /path/to/project --profile auto
|
|
281
|
+
piagent-mcp --preset core --scope global --replace
|
|
282
|
+
piagent-subagents --preset safe
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Khi command không có trên PATH, dùng script trực tiếp:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
bash /path/to/piagent/scripts/init-project.sh /path/to/project --profile auto
|
|
289
|
+
bash /path/to/piagent/scripts/configure-mcp.sh --preset core --scope global --replace
|
|
290
|
+
bash /path/to/piagent/scripts/configure-subagents.sh --preset safe
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## 4. Daily task workflow
|
|
294
|
+
|
|
295
|
+
### Requirement chưa rõ
|
|
296
|
+
|
|
297
|
+
```text
|
|
298
|
+
/discuss Cải tiến workflow onboarding cho team mới. Chưa implement, chỉ hỏi phần thiếu và đề xuất plan.
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Cần plan trước
|
|
302
|
+
|
|
303
|
+
```text
|
|
304
|
+
/plan Implement header sale menu hover stabilization. Include scope, files, verify commands, and risks.
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Task rõ, cho implement
|
|
308
|
+
|
|
309
|
+
```text
|
|
310
|
+
/task Implement header sale menu hover stabilization. Add component tests and run relevant verify.
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Scout/audit read-only
|
|
314
|
+
|
|
315
|
+
```text
|
|
316
|
+
/scout Scout payment FE mapping vs BE contract. Backend read-only. Do not edit source.
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Use `/scout` cho payment/auth/data/contract mapping khi mục tiêu là chốt evidence trước, chưa sửa code.
|
|
320
|
+
|
|
321
|
+
### Task mới khi session đã nặng
|
|
322
|
+
|
|
323
|
+
Nếu `/piagent-usage` cho thấy context cao, hoặc Pi báo context overflow, dùng fresh workflow:
|
|
324
|
+
|
|
325
|
+
```text
|
|
326
|
+
/fresh-scout Scout payment FE mapping vs BE contract. Backend read-only. Do not edit source.
|
|
327
|
+
/fresh-task Implement <bounded task>.
|
|
328
|
+
/fresh-be-to-fe Implement FE support for <BE contract>. Backend read-only.
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Các command này tự mở session mới và replay prompt workflow ngắn. Anh không cần tự chạy `pi --name ...` rồi paste lại.
|
|
332
|
+
|
|
333
|
+
Input guard của platform cũng tự collapse prompt có full `Mandatory flow` boilerplate. Quy tắc vận hành: user chỉ mô tả task; checklist nằm trong platform prompt/piagent tools.
|
|
334
|
+
|
|
335
|
+
### Gửi ảnh/screenshot trong chat
|
|
336
|
+
|
|
337
|
+
Nếu Pi/chat box không tạo native image attachment mà chỉ hiện local path kiểu `/var/folders/.../Ảnh màn hình ...png`, cứ để nguyên path trong prompt:
|
|
338
|
+
|
|
339
|
+
```text
|
|
340
|
+
/scout Scout UI issue from screenshot /var/folders/.../screenshot.png
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Piagent guard sẽ xử lý trước khi model nhận input:
|
|
344
|
+
|
|
345
|
+
1. đọc local image path;
|
|
346
|
+
2. attach ảnh vào Pi input;
|
|
347
|
+
3. thay path trong prompt bằng marker `[image1]`;
|
|
348
|
+
4. báo `Piagent image input: attached [image1]`.
|
|
349
|
+
|
|
350
|
+
Hỗ trợ `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp`. Giới hạn mặc định: tối đa 4 ảnh/input, 8 MB/ảnh.
|
|
351
|
+
|
|
352
|
+
Nếu ảnh quá lớn, lưu ảnh nhỏ hơn hoặc yêu cầu agent dùng Pi `read` tool trên file ảnh để Pi resize. Không cần copy ảnh vào repo và không commit screenshot tạm.
|
|
353
|
+
|
|
354
|
+
### BE spec lên FE
|
|
355
|
+
|
|
356
|
+
```text
|
|
357
|
+
/profile be-readonly-fe
|
|
358
|
+
/be-to-fe Implement frontend support from backend endpoint/spec <name>. Backend is read-only.
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Cải tiến platform
|
|
362
|
+
|
|
363
|
+
```text
|
|
364
|
+
/platform-improve Improve MCP setup docs and subagent command guidance for team usage.
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Review trước final
|
|
368
|
+
|
|
369
|
+
```text
|
|
370
|
+
/review current diff
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Commit và pull request
|
|
374
|
+
|
|
375
|
+
Git trong Pi Agent là capability + guard, không có namespace `/git-*`. Khi muốn gom việc hiện tại:
|
|
376
|
+
|
|
377
|
+
```text
|
|
378
|
+
/commit docs: update onboarding notes
|
|
379
|
+
/pr Add guarded git workflow
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
`/commit` inspect status/diff, stage đúng scope, verify phù hợp, rồi commit local; không push. `/pr` inspect branch/diff/commit rồi hỏi xác nhận trước khi `git push` hoặc tạo/cập nhật GitHub PR. Các lệnh stage rộng như `git add .`, `git add -A`, `git add --all`, `git add -- .`, `git add :/` cũng phải qua confirmation.
|
|
383
|
+
|
|
384
|
+
## 5. Control flow của một task chuẩn
|
|
385
|
+
|
|
386
|
+
Một source-changing task nên đi qua:
|
|
387
|
+
|
|
388
|
+
```text
|
|
389
|
+
intake
|
|
390
|
+
-> profile/context
|
|
391
|
+
-> task contract
|
|
392
|
+
-> context manifest
|
|
393
|
+
-> implementation
|
|
394
|
+
-> verify command
|
|
395
|
+
-> observed verify evidence
|
|
396
|
+
-> trace
|
|
397
|
+
-> final gate
|
|
398
|
+
-> handoff
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Các piagent tools nền:
|
|
402
|
+
|
|
403
|
+
| Tool | Vai trò |
|
|
404
|
+
|---|---|
|
|
405
|
+
| `piagent_context` | Đọc active profile, required context, verify commands, MCP/memory settings. |
|
|
406
|
+
| `piagent_context_index_status/search/record` | Kiểm tra/tìm/ghi context index advisory có citation. |
|
|
407
|
+
| `piagent_task_start` | Tạo task contract: scope, risk, acceptance criteria. |
|
|
408
|
+
| `piagent_context_record` | Ghi context manifest: file nào đã đọc và lý do. |
|
|
409
|
+
| `piagent_exec_policy_check` | Check shell command trước khi chạy lệnh rủi ro. |
|
|
410
|
+
| `piagent_context_budget` | Check file/context size để tránh nhồi context. |
|
|
411
|
+
| `piagent_tool_policy_check` | Check capability của tool/MCP. |
|
|
412
|
+
| `piagent_verify_record` | Chỉ ghi verify evidence nếu Pi đã quan sát bash result thật sau task start. |
|
|
413
|
+
| `piagent_trace_record` | Ghi outcome, changed files, notes. |
|
|
414
|
+
| `piagent_task_gate_check` | Check final gate trước khi báo DONE. |
|
|
415
|
+
| `piagent_usage_snapshot` | Snapshot session/model/context. |
|
|
416
|
+
|
|
417
|
+
Done đúng nghĩa:
|
|
418
|
+
|
|
419
|
+
- có task contract;
|
|
420
|
+
- có context manifest;
|
|
421
|
+
- verify command đã chạy thật;
|
|
422
|
+
- verify evidence khớp `task.verifyCommands`;
|
|
423
|
+
- trace outcome rõ;
|
|
424
|
+
- final gate pass hoặc ghi rõ blocked/partial.
|
|
425
|
+
|
|
426
|
+
## 6. Guardrails cần hiểu
|
|
427
|
+
|
|
428
|
+
Protected path mặc định:
|
|
429
|
+
|
|
430
|
+
```text
|
|
431
|
+
.git/**
|
|
432
|
+
**/auth.json
|
|
433
|
+
**/.env
|
|
434
|
+
**/.env.*
|
|
435
|
+
.pi/piagent-state/**
|
|
436
|
+
.pi/piagent-profile.json
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Guard chặn:
|
|
440
|
+
|
|
441
|
+
- shell command chạm protected path;
|
|
442
|
+
- raw path-like access qua `read/write/edit/grep/find/ls`;
|
|
443
|
+
- custom/MCP tool có path-like string trỏ protected path;
|
|
444
|
+
- nested object/array/path URI;
|
|
445
|
+
- percent-encoded protected path;
|
|
446
|
+
- tool input quá sâu vượt inspection limit.
|
|
447
|
+
|
|
448
|
+
Broad `grep/find/ls` sweep được phép nếu không target trực tiếp protected path, nhưng output protected content/path metadata sẽ bị redact trước khi model thấy.
|
|
449
|
+
|
|
450
|
+
High-risk action phải human-gate:
|
|
451
|
+
|
|
452
|
+
- auth/OAuth/provider config;
|
|
453
|
+
- database migration;
|
|
454
|
+
- deploy/release/publish;
|
|
455
|
+
- destructive shell;
|
|
456
|
+
- external provider side effect/cost;
|
|
457
|
+
- production data;
|
|
458
|
+
- broad git operations.
|
|
459
|
+
|
|
460
|
+
## 7. Token, context, benchmark
|
|
461
|
+
|
|
462
|
+
### Trong Pi
|
|
463
|
+
|
|
464
|
+
```text
|
|
465
|
+
/task-preflight
|
|
466
|
+
/task-preflight compact
|
|
467
|
+
/piagent-usage
|
|
468
|
+
/session
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
`/task-preflight` cho biết task tiếp theo nên chạy trực tiếp, compact trước, hay mở fresh session. `compact` dùng khi muốn Pi nén session có hướng dẫn giữ lại decisions/open blockers/verify command.
|
|
472
|
+
|
|
473
|
+
`/piagent-usage` cho biết:
|
|
474
|
+
|
|
475
|
+
- session file;
|
|
476
|
+
- session id/name;
|
|
477
|
+
- model/thinking;
|
|
478
|
+
- live context usage;
|
|
479
|
+
- command lấy exact token/cost từ terminal khác.
|
|
480
|
+
|
|
481
|
+
Live context không phải billed tokens. Ví dụ `111k / 272k` là context đang giữ trong cửa sổ hiện tại, không phải tổng input/output/cost.
|
|
482
|
+
|
|
483
|
+
### Từ terminal khác
|
|
484
|
+
|
|
485
|
+
Nếu bin có trên PATH:
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
piagent-usage /path/to/project
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Fallback:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
bash /path/to/piagent/scripts/pi-session-stats.sh /path/to/project
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Nếu biết session file:
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
bash /path/to/piagent/scripts/pi-session-stats.sh \
|
|
501
|
+
/path/to/project \
|
|
502
|
+
/Users/<user>/.pi/agent/sessions/<project-key>/<session>.jsonl
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
### Cách đọc số
|
|
506
|
+
|
|
507
|
+
| Field | Ý nghĩa |
|
|
508
|
+
|---|---|
|
|
509
|
+
| `input` | Fresh input tokens gửi vào model. |
|
|
510
|
+
| `output` | Tokens model sinh ra. |
|
|
511
|
+
| `cacheRead` | Tokens đọc từ prompt cache. Có thể rất lớn, không tương đương fresh input cost. |
|
|
512
|
+
| `cacheWrite` | Tokens ghi cache. |
|
|
513
|
+
| `total` | Tổng theo Pi stats. |
|
|
514
|
+
| `cost` | Cost Pi tính theo provider/model pricing metadata. |
|
|
515
|
+
| `contextUsage.percent` | Phần trăm context window đang dùng. |
|
|
516
|
+
|
|
517
|
+
### Khi nào compact hoặc tách session
|
|
518
|
+
|
|
519
|
+
| Context | Khuyến nghị |
|
|
520
|
+
|---|---|
|
|
521
|
+
| `< 50%` | Bình thường. |
|
|
522
|
+
| `50-75%` | Tránh đọc file lớn không cần thiết. |
|
|
523
|
+
| `> 75%` | Cân nhắc `/compact` trước task dài tiếp theo. |
|
|
524
|
+
| Task chuyển từ implement sang deploy monitor | Nên tách session mới hoặc compact. |
|
|
525
|
+
| Task đã xong nhưng CI cần follow lâu | Tách session monitor riêng để không kéo context cũ. |
|
|
526
|
+
|
|
527
|
+
Trong Pi:
|
|
528
|
+
|
|
529
|
+
```text
|
|
530
|
+
/compact
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
Sau compact, agent phải đọc lại context quan trọng trước khi sửa tiếp.
|
|
534
|
+
|
|
535
|
+
### Ghi benchmark
|
|
536
|
+
|
|
537
|
+
Không claim tiết kiệm token/cost nếu chưa có số liệu cùng scenario.
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
bash /path/to/piagent/scripts/quality-benchmark.sh /path/to/project --init
|
|
541
|
+
|
|
542
|
+
bash /path/to/piagent/scripts/quality-benchmark.sh /path/to/project --record \
|
|
543
|
+
--scenario "ui-fix-with-ci-gate" \
|
|
544
|
+
--surface pi \
|
|
545
|
+
--result partial \
|
|
546
|
+
--tokens 26323474 \
|
|
547
|
+
--cost 18.33 \
|
|
548
|
+
--verify "npm test / E2E / CI gate" \
|
|
549
|
+
--notes "Implementation + branch push + main/test merge + CI monitor; deploy gate failed at shard 2."
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
Benchmark nên đặt theo scenario thật, ví dụ:
|
|
553
|
+
|
|
554
|
+
- `bounded-source-fix`;
|
|
555
|
+
- `be-spec-to-fe`;
|
|
556
|
+
- `ui-fix-with-ci-gate`;
|
|
557
|
+
- `platform-docs-update`;
|
|
558
|
+
- `deploy-monitor`.
|
|
559
|
+
|
|
560
|
+
Không benchmark theo số file changed đơn thuần.
|
|
561
|
+
|
|
562
|
+
## 8. Resume session khi tắt nhầm
|
|
563
|
+
|
|
564
|
+
### Cách nhanh nhất
|
|
565
|
+
|
|
566
|
+
Trong project:
|
|
567
|
+
|
|
568
|
+
```bash
|
|
569
|
+
cd /path/to/project
|
|
570
|
+
pi --continue
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
Hoặc mở selector:
|
|
574
|
+
|
|
575
|
+
```bash
|
|
576
|
+
pi --resume
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
Nếu biết session id hoặc file:
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
pi --session 019f7ad3-0ce3-77f3-b34d-72d8c37c5fb6
|
|
583
|
+
pi --session /Users/<user>/.pi/agent/sessions/<project-key>/<session>.jsonl
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
Fork một session cũ sang session mới:
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
pi --fork 019f7ad3-0ce3-77f3-b34d-72d8c37c5fb6
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
Đặt tên session ngay từ đầu để dễ tìm:
|
|
593
|
+
|
|
594
|
+
```bash
|
|
595
|
+
pi --name "V-Nexus header menu fix"
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
Trong Pi:
|
|
599
|
+
|
|
600
|
+
```text
|
|
601
|
+
/session
|
|
602
|
+
/piagent-usage
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
`/piagent-usage` sẽ in session id và session file. Ghi lại khi task dài hoặc có nhiều pane Herdr.
|
|
606
|
+
|
|
607
|
+
### Khi nào nên resume, continue, fork
|
|
608
|
+
|
|
609
|
+
| Nhu cầu | Dùng |
|
|
610
|
+
|---|---|
|
|
611
|
+
| Tắt nhầm, muốn quay lại phiên gần nhất | `pi --continue` |
|
|
612
|
+
| Không nhớ phiên nào | `pi --resume` |
|
|
613
|
+
| Có session id/file từ `/piagent-usage` | `pi --session <id-or-file>` |
|
|
614
|
+
| Muốn thử hướng mới nhưng giữ history cũ | `pi --fork <id-or-file>` |
|
|
615
|
+
| Muốn session mới sạch sau task quá dài | `pi --name "<new task>"` |
|
|
616
|
+
|
|
617
|
+
## 9. MCP setup và cách dùng
|
|
618
|
+
|
|
619
|
+
### Preset
|
|
620
|
+
|
|
621
|
+
| Preset | Includes | Khi dùng |
|
|
622
|
+
|---|---|---|
|
|
623
|
+
| `minimal` | none | Muốn giữ surface nhỏ. |
|
|
624
|
+
| `docs` | Context7 | Cần docs framework/library mới. |
|
|
625
|
+
| `browser` | Chrome DevTools, Playwright | FE/browser/runtime inspection. |
|
|
626
|
+
| `github` | GitHub MCP | Issue/PR/repo/release workflow. |
|
|
627
|
+
| `design` | Figma remote | Design-to-code qua Figma OAuth. |
|
|
628
|
+
| `design-local` | Figma desktop | Figma Dev Mode local selection. |
|
|
629
|
+
| `web` | Context7 + browser tools | Web/FE default. |
|
|
630
|
+
| `core` | Context7, Chrome DevTools, GitHub | Team baseline. |
|
|
631
|
+
| `popular` | core + Playwright + Figma remote | Full dev baseline. |
|
|
632
|
+
| `all` | popular + Figma desktop | Cần cả remote + local design. |
|
|
633
|
+
|
|
634
|
+
### Cấu hình global
|
|
635
|
+
|
|
636
|
+
```bash
|
|
637
|
+
piagent-mcp --preset core --scope global --replace
|
|
638
|
+
piagent-mcp --preset popular --scope global --replace
|
|
639
|
+
piagent-mcp --list
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
Fallback:
|
|
643
|
+
|
|
644
|
+
```bash
|
|
645
|
+
bash /path/to/piagent/scripts/configure-mcp.sh --preset core --scope global --replace
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### Cấu hình project
|
|
649
|
+
|
|
650
|
+
```bash
|
|
651
|
+
piagent-mcp --preset design --scope project --project /path/to/project
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
Fallback:
|
|
655
|
+
|
|
656
|
+
```bash
|
|
657
|
+
bash /path/to/piagent/scripts/configure-mcp.sh \
|
|
658
|
+
--preset design \
|
|
659
|
+
--scope project \
|
|
660
|
+
--project /path/to/project
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
### Trong Pi
|
|
664
|
+
|
|
665
|
+
```text
|
|
666
|
+
/mcp
|
|
667
|
+
/mcp setup
|
|
668
|
+
/mcp tools
|
|
669
|
+
/mcp reconnect
|
|
670
|
+
/mcp-auth figma
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
### Config layers
|
|
674
|
+
|
|
675
|
+
| File | Scope | Ghi chú |
|
|
676
|
+
|---|---|---|
|
|
677
|
+
| `~/.config/mcp/mcp.json` | Shared global | Baseline cho nhiều agent/client. |
|
|
678
|
+
| `~/.pi/agent/mcp.json` | Pi global override | Chỉ khi Pi cần override riêng. |
|
|
679
|
+
| `.mcp.json` | Project shared | Có thể commit nếu không chứa secret. |
|
|
680
|
+
| `.pi/mcp.json` | Pi project override | Pi-specific; không nhét secret. |
|
|
681
|
+
|
|
682
|
+
Quy ước:
|
|
683
|
+
|
|
684
|
+
- `directTools: false` mặc định để giảm tool explosion/token.
|
|
685
|
+
- Dùng proxy `mcp(...)` qua `pi-mcp-adapter`.
|
|
686
|
+
- Secret để trong environment variable, không commit.
|
|
687
|
+
|
|
688
|
+
Ví dụ:
|
|
689
|
+
|
|
690
|
+
```bash
|
|
691
|
+
export CONTEXT7_API_KEY=ctx7sk_...
|
|
692
|
+
export GITHUB_PERSONAL_ACCESS_TOKEN=<github-token>
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
## 10. Subagents và multi-agent
|
|
696
|
+
|
|
697
|
+
### Setup
|
|
698
|
+
|
|
699
|
+
```bash
|
|
700
|
+
piagent-subagents --preset safe
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
Fallback:
|
|
704
|
+
|
|
705
|
+
```bash
|
|
706
|
+
bash /path/to/piagent/scripts/configure-subagents.sh --preset safe
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
Check trong Pi:
|
|
710
|
+
|
|
711
|
+
```text
|
|
712
|
+
/subagents-doctor
|
|
713
|
+
/subagents-models
|
|
714
|
+
/subagents
|
|
715
|
+
/subagents-fleet
|
|
716
|
+
/subagent-cost
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
### Safe preset
|
|
720
|
+
|
|
721
|
+
Default safe config:
|
|
722
|
+
|
|
723
|
+
- `toolDescriptionMode: compact`;
|
|
724
|
+
- `asyncByDefault: false`;
|
|
725
|
+
- `parallel.concurrency: 3`;
|
|
726
|
+
- `parallel.maxTasks: 6`;
|
|
727
|
+
- `maxSubagentDepth: 1`;
|
|
728
|
+
- `maxSubagentSpawnsPerSession: 32`;
|
|
729
|
+
- scheduled runs off;
|
|
730
|
+
- worktree base stable;
|
|
731
|
+
- intercom bridge on.
|
|
732
|
+
|
|
733
|
+
### Piagent agents
|
|
734
|
+
|
|
735
|
+
| Agent | Role | Write policy |
|
|
736
|
+
|---|---|---|
|
|
737
|
+
| `piagent-scout` | Map source/spec read-only. | No write. |
|
|
738
|
+
| `piagent-planner` | Plan implementation + verify gates. | No write. |
|
|
739
|
+
| `piagent-worker` | Implement approved bounded task. | Write in scope. |
|
|
740
|
+
| `piagent-reviewer` | Review diff/tests/scope. | Review-first. |
|
|
741
|
+
| `piagent-oracle` | Risk/architecture challenge. | No write. |
|
|
742
|
+
|
|
743
|
+
### Auto-delegation
|
|
744
|
+
|
|
745
|
+
Với `/task`, `/be-to-fe`, `/platform-improve`, `/plan`, `/review`, parent agent dùng solo-first orchestration: lập task tree/review lenses trước, rồi chỉ spawn subagent khi có phần việc độc lập và đáng token.
|
|
746
|
+
|
|
747
|
+
Kiểm tra nhanh policy:
|
|
748
|
+
|
|
749
|
+
```text
|
|
750
|
+
/piagent-orchestration
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
Không cần tự gọi `/run` cho task bình thường. Chỉ dùng `/run` khi muốn ép rõ role hoặc debug.
|
|
754
|
+
|
|
755
|
+
Parent nên spawn khi:
|
|
756
|
+
|
|
757
|
+
- cần scout codebase rộng;
|
|
758
|
+
- cần map BE/spec read-only trước khi FE implement;
|
|
759
|
+
- cần reviewer độc lập;
|
|
760
|
+
- cần context builder cho task lớn;
|
|
761
|
+
- cần oracle/risk challenge.
|
|
762
|
+
|
|
763
|
+
Không nên spawn khi:
|
|
764
|
+
|
|
765
|
+
- task nhỏ, một file;
|
|
766
|
+
- requirement chưa rõ;
|
|
767
|
+
- nhiều writer cùng sửa chung vùng;
|
|
768
|
+
- repo dirty chưa rõ của ai;
|
|
769
|
+
- đang cần quyết định user/product.
|
|
770
|
+
|
|
771
|
+
### Slash examples
|
|
772
|
+
|
|
773
|
+
```text
|
|
774
|
+
/run piagent-scout "Map listing page state flow. Read-only."
|
|
775
|
+
/run piagent-planner "Plan FE implementation from this backend contract."
|
|
776
|
+
/run piagent-worker "Implement the approved plan. Do not touch backend."
|
|
777
|
+
/run piagent-reviewer "Review current diff for correctness, tests, and scope drift."
|
|
778
|
+
/run piagent-oracle "Challenge this architecture decision before implementation."
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
Parallel read-only review:
|
|
782
|
+
|
|
783
|
+
```text
|
|
784
|
+
/parallel piagent-reviewer "Review correctness" -> piagent-reviewer "Review tests" -> piagent-reviewer "Review scope drift"
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
Chain:
|
|
788
|
+
|
|
789
|
+
```text
|
|
790
|
+
/chain piagent-scout "Scout target area" -> piagent-planner "Plan from {previous}" -> piagent-worker "Implement from {previous}" -> piagent-reviewer "Review implementation"
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
Background:
|
|
794
|
+
|
|
795
|
+
```text
|
|
796
|
+
/run piagent-scout "Map this module" --bg
|
|
797
|
+
/subagents-fleet
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
### Tool syntax khi cần chính xác
|
|
801
|
+
|
|
802
|
+
```text
|
|
803
|
+
subagent({ agent: "piagent-scout", task: "Map auth flow. Read-only.", context: "fresh" })
|
|
804
|
+
subagent({ action: "status", view: "fleet" })
|
|
805
|
+
subagent({ action: "status", id: "<run-id>", view: "transcript" })
|
|
806
|
+
subagent({ action: "steer", id: "<run-id>", message: "Focus only on tests." })
|
|
807
|
+
subagent({ action: "stop", id: "<run-id>" })
|
|
808
|
+
subagent({ action: "resume", id: "<run-id>", message: "Continue after this clarification." })
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
Output file mode để giảm parent context:
|
|
812
|
+
|
|
813
|
+
```text
|
|
814
|
+
/run scout[output=context.md,outputMode=file-only] "Map target area"
|
|
815
|
+
/chain scout[output=context.md,as=context] "Scan" -> planner[reads=context.md] "Plan from {outputs.context}"
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
### Worktree isolation
|
|
819
|
+
|
|
820
|
+
Chỉ bật writer parallel/worktree khi:
|
|
821
|
+
|
|
822
|
+
- repo là Git repo;
|
|
823
|
+
- worktree clean;
|
|
824
|
+
- write sets không overlap;
|
|
825
|
+
- parent review/merge outputs.
|
|
826
|
+
|
|
827
|
+
Default solo/internal: một `piagent-worker`, parallel read-only reviewers/scouts.
|
|
828
|
+
|
|
829
|
+
### Watchdog
|
|
830
|
+
|
|
831
|
+
Watchdog là optional adversarial reviewer ở cuối turn, không bật mặc định vì tốn thêm model pass.
|
|
832
|
+
|
|
833
|
+
```text
|
|
834
|
+
/subagents-watchdog recommend-model
|
|
835
|
+
/subagents-watchdog session model recommended
|
|
836
|
+
/subagents-watchdog on
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
## 11. Command cheat sheet
|
|
840
|
+
|
|
841
|
+
### Terminal
|
|
842
|
+
|
|
843
|
+
| Command | Dùng để |
|
|
844
|
+
|---|---|
|
|
845
|
+
| `npm install -g --ignore-scripts github:Vt-mmm/piagent#v1.0.0` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
|
|
846
|
+
| `pi install git:github.com/Vt-mmm/piagent@v1.0.0` | Install pinned release cho reproducible team setup. |
|
|
847
|
+
| `pi install git:github.com/Vt-mmm/piagent` | Install latest platform package cho máy cá nhân/sandbox. |
|
|
848
|
+
| Cài exact Pi host của release, rồi `npm install -g --ignore-scripts github:Vt-mmm/piagent#vX.Y.Z` và `piagent-install --stable` | Full update: đồng bộ host, terminal helper và Pi package. v1.0.0 yêu cầu Pi `0.81.1`. |
|
|
849
|
+
| Cài exact Pi host ghi trong release cũ, rồi helper `vPREVIOUS` và `piagent-install --stable` | Full rollback; đánh giá lại dependency findings của host cũ trước khi hạ version. |
|
|
850
|
+
| `piagent-install --stable --dry-run` | Preview Pi package matching với helper hiện tại; stable resolve tag → commit SHA. |
|
|
851
|
+
| `piagent-install --stable` | Apply Pi package matching với helper hiện tại bằng resolved commit SHA. |
|
|
852
|
+
| `piagent-install --version vX.Y.Z --resolve-tag` | Chỉ đổi Pi package; terminal helper giữ nguyên version. |
|
|
853
|
+
| `piagent-install --version vX.Y.Z` | Chỉ đổi Pi package theo exact tag literal khi cần giữ behavior cũ. |
|
|
854
|
+
| `piagent-install --dev` | Dùng moving source cho máy cá nhân/sandbox. |
|
|
855
|
+
| `piagent-doctor /path/to/project --strict-share` | Kiểm profile/package/runtime surface. Dùng bắt buộc khi rollout trên macOS Intel, Linux ARM64 hoặc môi trường chưa nằm trong release gate. |
|
|
856
|
+
| `pi update --extensions` | Refresh package đã cài; với pinned tag/commit, muốn nâng version thì install lại bằng ref mới. |
|
|
857
|
+
| `pi list --approve` | Kiểm package/resources đã load. |
|
|
858
|
+
| `piagent-auto` | Mở Pi với project trust `--approve` cho lần chạy hiện tại; guard vẫn bật. |
|
|
859
|
+
| `piagent-auto --read-only -p "<task>"` | Auto-run read-only scout với tool set `read,grep,find,ls`. |
|
|
860
|
+
| `piagent-auto --full-access -p "<task>"` | Auto-run trusted full-access cho repo đã kiểm soát; protected paths/redaction/human gates vẫn bật. |
|
|
861
|
+
| `pi --continue` | Continue session gần nhất. |
|
|
862
|
+
| `pi --resume` | Chọn session để resume. |
|
|
863
|
+
| `pi --session <id-or-file>` | Resume session cụ thể. |
|
|
864
|
+
| `pi --fork <id-or-file>` | Fork session cũ sang session mới. |
|
|
865
|
+
| `pi --name "<name>"` | Đặt tên session. |
|
|
866
|
+
| `pi --tools read,grep,find,ls -p "Review src"` | Read-only one-shot. |
|
|
867
|
+
| `piagent-usage /path/to/project` | Exact token/cost stats. |
|
|
868
|
+
| `piagent-mcp --preset core --scope global --replace` | Setup or update the governed MCP baseline. |
|
|
869
|
+
| `piagent-subagents --preset safe` | Setup subagents baseline. |
|
|
870
|
+
| `bash scripts/verify-local.sh` | Verify platform repo. |
|
|
871
|
+
| `bash scripts/team-doctor.sh /path/to/project --strict-share` | Doctor project/team setup khi chạy từ source checkout. |
|
|
872
|
+
| `bash scripts/quality-benchmark.sh /path/to/project --record ...` | Ghi benchmark. |
|
|
873
|
+
|
|
874
|
+
### Trong Pi
|
|
875
|
+
|
|
876
|
+
| Command | Dùng để |
|
|
877
|
+
|---|---|
|
|
878
|
+
| `/login` | Login provider. |
|
|
879
|
+
| `/model` / `Ctrl+L` | Chọn model. |
|
|
880
|
+
| `Ctrl+P` | Cycle scoped models. |
|
|
881
|
+
| `Shift+Tab` | Cycle thinking level. |
|
|
882
|
+
| `/piagent-commands` | Xem command help theo ngữ cảnh. |
|
|
883
|
+
| `/permission-status` | Xem permission profile hiện tại. |
|
|
884
|
+
| `/read-only` | Chuyển session sang read-only. |
|
|
885
|
+
| `/workspace-write` | Chuyển session sang write chuẩn. |
|
|
886
|
+
| `/full-access` | Bật trusted full-access cho session hiện tại. |
|
|
887
|
+
| `/full-access <task>` | Bật trusted full-access rồi gửi `<task>` cho agent làm tiếp. |
|
|
888
|
+
| `/onboard-project` | Onboard/read project lần đầu. |
|
|
889
|
+
| `/context-index` | Xem compact context index, không gọi model follow-up. |
|
|
890
|
+
| `/context-index search <keyword>` | Tìm node/edge/citation trong context index. |
|
|
891
|
+
| `/profile` | Xem profile ngắn, không gọi model follow-up. |
|
|
892
|
+
| `/profile list` | Xem profile có sẵn dạng compact. |
|
|
893
|
+
| `/profile <profile>` | Áp profile ngay và cập nhật lock. |
|
|
894
|
+
| `/profile auto` | Detect và áp profile recommend ngay. |
|
|
895
|
+
| `/profile setup` | Chọn profile + tech bằng option, không chat dài. |
|
|
896
|
+
| `/profile tech` | Xem tech stack và Context7 status hiện tại. |
|
|
897
|
+
| `/profile tech setup [profile]` | Chọn tech theo role; fullstack chọn FE/BE/DB. |
|
|
898
|
+
| `/profile tech apply ...` | Apply profile/tech bằng một lệnh deterministic. |
|
|
899
|
+
| `/memory-policy` | Xem memory policy. |
|
|
900
|
+
| `/task-preflight` | Check context trước task lớn/risk cao. |
|
|
901
|
+
| `/task-preflight compact` | Compact session có hướng dẫn. |
|
|
902
|
+
| `/piagent-usage` | Snapshot context/session. |
|
|
903
|
+
| `/session` | Pi native session stats/info. |
|
|
904
|
+
| `/compact` | Nén context. |
|
|
905
|
+
| `/mcp` / `/mcp tools` | Check MCP. |
|
|
906
|
+
| `/subagents-doctor` | Check subagent setup. |
|
|
907
|
+
| `/subagents-fleet` | Follow child sessions. |
|
|
908
|
+
| `/subagent-cost` | Check subagent token/cost. |
|
|
909
|
+
| `/discuss` | Làm rõ, không sửa. |
|
|
910
|
+
| `/plan` | Lập plan. |
|
|
911
|
+
| `/scout` | Scout/audit read-only. |
|
|
912
|
+
| `/fresh-scout` | Tự mở session mới rồi chạy `/scout`. |
|
|
913
|
+
| `/fresh-task` | Tự mở session mới rồi chạy `/task`. |
|
|
914
|
+
| `/fresh-be-to-fe` | Tự mở session mới rồi chạy `/be-to-fe`. |
|
|
915
|
+
| `/task` | Implement task. |
|
|
916
|
+
| `/be-to-fe` | BE read-only, FE implementation. |
|
|
917
|
+
| `/platform-improve` | Cải tiến platform. |
|
|
918
|
+
| `/review` | Review diff/source. |
|
|
919
|
+
| `/commit [message/scope]` | Commit local qua workflow có guard. |
|
|
920
|
+
| `/pr [title/request]` | Chuẩn bị PR, hỏi trước khi push/GitHub write. |
|
|
921
|
+
|
|
922
|
+
## 12. Troubleshooting
|
|
923
|
+
|
|
924
|
+
### Không thấy command platform
|
|
925
|
+
|
|
926
|
+
```bash
|
|
927
|
+
pi list --approve
|
|
928
|
+
piagent-install --stable --dry-run
|
|
929
|
+
piagent-install --stable
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
Mở lại Pi session sau khi install.
|
|
933
|
+
|
|
934
|
+
### `piagent-*` không có trên PATH
|
|
935
|
+
|
|
936
|
+
Cài lại terminal helper đúng release rồi kiểm tra `PATH`:
|
|
937
|
+
|
|
938
|
+
```bash
|
|
939
|
+
npm install -g --ignore-scripts github:Vt-mmm/piagent#v1.0.0
|
|
940
|
+
command -v piagent-install
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
Nếu đang làm việc từ source checkout, có thể dùng script trực tiếp:
|
|
944
|
+
|
|
945
|
+
```bash
|
|
946
|
+
bash /path/to/piagent/scripts/pi-session-stats.sh /path/to/project
|
|
947
|
+
bash /path/to/piagent/scripts/configure-mcp.sh --preset core --scope global --replace
|
|
948
|
+
bash /path/to/piagent/scripts/configure-subagents.sh --preset safe
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
### MCP không connect
|
|
952
|
+
|
|
953
|
+
```text
|
|
954
|
+
/mcp
|
|
955
|
+
/mcp setup
|
|
956
|
+
/mcp reconnect
|
|
957
|
+
/mcp tools
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
Kiểm config:
|
|
961
|
+
|
|
962
|
+
```bash
|
|
963
|
+
piagent-mcp --list
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
Kiểm env token mà không in giá trị secret:
|
|
967
|
+
|
|
968
|
+
```bash
|
|
969
|
+
for name in CONTEXT7_API_KEY GITHUB_PERSONAL_ACCESS_TOKEN FIGMA_ACCESS_TOKEN; do
|
|
970
|
+
test -n "${!name:-}" && echo "$name=set" || echo "$name=missing"
|
|
971
|
+
done
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
Không paste token vào chat hoặc commit config.
|
|
975
|
+
|
|
976
|
+
### Subagent không chạy
|
|
977
|
+
|
|
978
|
+
```text
|
|
979
|
+
/subagents-doctor
|
|
980
|
+
/subagents-models
|
|
981
|
+
/subagents-fleet
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
Re-apply config:
|
|
985
|
+
|
|
986
|
+
```bash
|
|
987
|
+
piagent-subagents --preset safe
|
|
988
|
+
```
|
|
989
|
+
|
|
990
|
+
Fallback:
|
|
991
|
+
|
|
992
|
+
```bash
|
|
993
|
+
bash /path/to/piagent/scripts/configure-subagents.sh --preset safe
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
### Context quá cao
|
|
997
|
+
|
|
998
|
+
```text
|
|
999
|
+
/piagent-usage
|
|
1000
|
+
/session
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
Nếu `contextUsage.percent > 75%`:
|
|
1004
|
+
|
|
1005
|
+
```text
|
|
1006
|
+
/compact
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
Hoặc mở session mới:
|
|
1010
|
+
|
|
1011
|
+
```bash
|
|
1012
|
+
pi --name "Deploy monitor"
|
|
1013
|
+
```
|
|
1014
|
+
|
|
1015
|
+
### Resume không đúng session
|
|
1016
|
+
|
|
1017
|
+
Lấy session id/file từ `/piagent-usage`, rồi:
|
|
1018
|
+
|
|
1019
|
+
```bash
|
|
1020
|
+
pi --session <session-id>
|
|
1021
|
+
pi --session /absolute/path/to/session.jsonl
|
|
1022
|
+
```
|
|
1023
|
+
|
|
1024
|
+
### Verify evidence không được nhận
|
|
1025
|
+
|
|
1026
|
+
Nguyên nhân thường gặp:
|
|
1027
|
+
|
|
1028
|
+
- agent ghi `piagent_verify_record` nhưng chưa chạy bash verify thật;
|
|
1029
|
+
- command string không exact-match `task.verifyCommands`;
|
|
1030
|
+
- verify chạy trước `task.createdAt`;
|
|
1031
|
+
- verify chạy ở cwd khác;
|
|
1032
|
+
- subagent chạy nhưng parent chưa thấy persisted ledger đúng cwd.
|
|
1033
|
+
|
|
1034
|
+
Fix:
|
|
1035
|
+
|
|
1036
|
+
```text
|
|
1037
|
+
Run the exact verify command from task.verifyCommands in the project cwd, then record verify evidence again.
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
## 13. Không commit
|
|
1041
|
+
|
|
1042
|
+
Không commit:
|
|
1043
|
+
|
|
1044
|
+
```text
|
|
1045
|
+
.env
|
|
1046
|
+
**/auth.json
|
|
1047
|
+
.pi/piagent-state/
|
|
1048
|
+
.pi/benchmarks/
|
|
1049
|
+
.pi/memory/local/
|
|
1050
|
+
.pi/memory/state.sqlite
|
|
1051
|
+
.pi/sessions/
|
|
1052
|
+
.pi/todos/
|
|
1053
|
+
.pi/auth.json
|
|
1054
|
+
token/API key/OAuth files
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
Commit được nếu không chứa secret và team muốn share:
|
|
1058
|
+
|
|
1059
|
+
```text
|
|
1060
|
+
AGENTS.md
|
|
1061
|
+
.mcp.json
|
|
1062
|
+
.pi/piagent-profile.json
|
|
1063
|
+
.pi/project-context.md
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
Memory shared (`.pi/memory/MEMORY.md`) chỉ commit nếu team explicit opt-in sau review/redaction.
|
|
1067
|
+
|
|
1068
|
+
## 14. Tài liệu chi tiết
|
|
1069
|
+
|
|
1070
|
+
- Quickstart: `docs/quickstart-vietnamese.md`
|
|
1071
|
+
- Command reference: `docs/command-reference-vietnamese.md`
|
|
1072
|
+
- Team onboarding: `docs/team-onboarding.md`
|
|
1073
|
+
- MCP and tools: `docs/mcp-and-tools.md`
|
|
1074
|
+
- Subagents: `docs/subagents-and-multiagent.md`
|
|
1075
|
+
- Usage observability: `docs/usage-observability.md`
|
|
1076
|
+
- Model options: `docs/model-options.md`
|
|
1077
|
+
- Memory policy: `docs/memory-policy.md`
|
|
1078
|
+
- Task contract: `docs/task-implementation-contract.md`
|
|
1079
|
+
- Runtime policy: `docs/runtime-policy-design.md`
|
|
1080
|
+
- Quality benchmark: `docs/quality-benchmark.md`
|