@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,484 @@
|
|
|
1
|
+
# Command reference tiếng Việt
|
|
2
|
+
|
|
3
|
+
> Nếu cần flow đầy đủ theo thứ tự dùng thật, đọc `docs/operator-manual-vietnamese.md`. File này chỉ là bảng tra cứu command.
|
|
4
|
+
|
|
5
|
+
File này là bảng tra cứu command chính cho Pi Agent Platform. Mục tiêu là khi anh/team mở Herdr, `cd` vào project, chạy `pi`, thì biết rõ lệnh nào dùng cho việc gì.
|
|
6
|
+
|
|
7
|
+
## Cách đọc command
|
|
8
|
+
|
|
9
|
+
Có 4 loại command khác nhau:
|
|
10
|
+
|
|
11
|
+
| Loại | Gõ ở đâu | Ví dụ | Ý nghĩa |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| Terminal command | Terminal đã có Bash | `piagent-mcp --preset core` | Cài, kiểm tra, hoặc cấu hình máy/project từ bên ngoài Pi. macOS Apple Silicon và Linux x64 đã verify; macOS Intel/Linux ARM64 cần smoke trước rollout; native Windows chưa là target team; WSL2 experimental. |
|
|
14
|
+
| Pi slash command | Bên trong Pi TUI | `/onboard-project` | Gọi workflow/prompt/package command trong Pi session hiện tại. |
|
|
15
|
+
| Pi hotkey | Bên trong Pi TUI | `Ctrl+L` | Mở UI nhanh, thường dùng cho model/session. |
|
|
16
|
+
| Tool syntax | Bên trong Pi, khi cần chính xác | `subagent({ action: "status" })` | Gọi đúng tool/action, dùng khi slash command hoặc natural prompt chưa đủ rõ. |
|
|
17
|
+
|
|
18
|
+
Nếu không chắc một slash command có sẵn chưa, mở Pi và gõ `/` để xem danh sách command của session hiện tại. Command có thể khác nhau theo package đã install, provider đã login, và project trust.
|
|
19
|
+
|
|
20
|
+
## Flow hằng ngày ngắn nhất
|
|
21
|
+
|
|
22
|
+
Lần đầu trên một project:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd /path/to/project
|
|
26
|
+
pi
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Trong Pi:
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
/login
|
|
33
|
+
/model
|
|
34
|
+
/piagent-commands
|
|
35
|
+
/onboard-project
|
|
36
|
+
/context-index
|
|
37
|
+
/memory-policy
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Các lần sau:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
cd /path/to/project
|
|
44
|
+
pi
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Trong Pi:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
/task Implement <task cụ thể>.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Nếu chỉ scout/audit read-only:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
/scout Scout payment FE mapping vs BE. Do not edit source.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Nếu session đang nặng hoặc Pi báo context overflow, dùng fresh workflow:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
/fresh-scout <read-only request>
|
|
63
|
+
/fresh-task <implementation request>
|
|
64
|
+
/fresh-be-to-fe <BE-readonly/FE request>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Nếu task còn mơ hồ:
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
/discuss <ý tưởng hoặc yêu cầu thô>
|
|
71
|
+
/plan <goal cần bóc tách>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Nguyên tắc command/UX
|
|
75
|
+
|
|
76
|
+
Pi Agent dùng ít namespace nhưng mỗi namespace có subcommand rõ:
|
|
77
|
+
|
|
78
|
+
- `/profile` là namespace duy nhất cho profile và tech stack; không dùng `/profiles` hoặc `/profile-tech` riêng.
|
|
79
|
+
- Status command như `/profile`, `/permission-status`, `/context-index`, `/piagent-orchestration` phải ngắn và không gọi model follow-up.
|
|
80
|
+
- Khi user cần chọn, ưu tiên select option. Khi UI select không khả dụng, trả về exact apply command để chạy ngay.
|
|
81
|
+
- Long list chỉ hiện khi gõ `list`, `options`, hoặc `/piagent-commands <topic>`.
|
|
82
|
+
- Hành động rủi ro như stage rộng, push, PR write, deploy, publish, thay đổi database hoặc external-provider write vẫn cần xác nhận người vận hành.
|
|
83
|
+
|
|
84
|
+
## Command của platform mình
|
|
85
|
+
|
|
86
|
+
Các command này đến từ package `piagent-core`.
|
|
87
|
+
|
|
88
|
+
| Command | Dịch nghĩa | Dùng khi nào | Kết quả mong đợi |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `/piagent-commands` | Bảng hướng dẫn command | Khi không nhớ command hoặc muốn giải thích cho team mới. | Agent tóm tắt command theo đúng ngữ cảnh project. |
|
|
91
|
+
| `/permission-status` | Xem quyền runtime | Khi muốn biết session đang là read-only, workspace-write, hay full-access. | Hiện active permission profile và guard boundary còn giữ. |
|
|
92
|
+
| `/read-only` | Chuyển session sang read-only | Khi chỉ muốn scout/audit/review, không sửa source. | Shell/write/unknown tool bị chặn trước execution. |
|
|
93
|
+
| `/workspace-write` | Chuyển session sang write chuẩn | Khi quay về mode implement bình thường. | Guard trở về profile implementation mặc định. |
|
|
94
|
+
| `/full-access` | Bật trusted full-access | Khi repo đã trusted và muốn agent có quyền workspace rộng hơn. | Tool/scope autonomy được nới trong session; protected paths/redaction/human gates vẫn bật. |
|
|
95
|
+
| `/full-access <task>` | Bật full-access rồi chạy task | Khi muốn một lệnh vừa cấp quyền vừa giao việc. | Session chuyển sang `trusted-full-access`, phần `<task>` được gửi tiếp cho agent. |
|
|
96
|
+
| `/onboard-project` | Đọc project lần đầu | Lần đầu gắn repo vào Pi, sau `/login` và `/model`. | Tạo/cập nhật `.pi/piagent-profile.json`, `.pi/project-context.md`, `.pi/context-index.json`, `.pi/memory/*`. |
|
|
97
|
+
| `/context-index` | Xem bản đồ context | Khi muốn biết context index đã generate chưa mà không burn token. | Hiện node/edge/citation/warning ngắn, không gọi model follow-up. |
|
|
98
|
+
| `/context-index search <keyword>` | Tìm trong bản đồ context | Khi cần điểm vào module/tech/risk trước khi scout rộng. | Trả các node khớp keyword; vẫn phải đọc file được cite trước khi sửa. |
|
|
99
|
+
| `/profile` | Xem profile ngắn | Khi muốn biết mode hiện tại mà không burn token. | Hiện status ngắn, không gọi model follow-up. |
|
|
100
|
+
| `/profile list` | Xem profile có sẵn | Khi chưa nhớ tên profile. | Hiện list compact. |
|
|
101
|
+
| `/profile <profile>` | Áp profile ngay | Khi đã biết profile muốn dùng. | Ghi `.pi/piagent-profile.json` và lock ngay, không hỏi vòng. |
|
|
102
|
+
| `/profile auto` | Áp profile recommend | Khi muốn auto-detect và apply luôn. | Detect profile rồi ghi profile/lock ngay. |
|
|
103
|
+
| `/profile setup` | Chọn profile + tech bằng option | Khi onboarding hoặc muốn đổi profile/stack mà không chat dài. | Mở select profile, rồi select tech theo role; fallback là card ngắn + lệnh apply chính xác nếu UI select chưa có. |
|
|
104
|
+
| `/profile setup fullstack` | Chọn tech cho fullstack | Khi đã biết profile là fullstack. | Chọn frontend, backend, database rồi ghi `.pi/tech-stack.json` và `.pi/tech-context/*` placeholder. |
|
|
105
|
+
| `/profile fe`, `/profile be`, `/profile full`, `/profile be-fe` | Alias ngắn | Khi muốn gõ nhanh. | Map sang `web-frontend`, `backend-api`, `fullstack`, `be-readonly-fe`. |
|
|
106
|
+
| `/profile tech` | Xem tech stack hiện tại | Khi muốn biết profile đã gắn tech nào và Context7 đã record chưa. | Hiện manifest + pending Context7 ngắn, không gọi model follow-up. |
|
|
107
|
+
| `/profile tech setup [profile]` | Wizard chọn tech | Khi muốn chọn tech theo role bằng UI select. | FE profile chọn FE + DB; BE profile chọn BE + DB; fullstack chọn FE + BE + DB. |
|
|
108
|
+
| `/profile tech options [profile]` | Xem option tech | Khi UI select không có hoặc muốn lấy lệnh apply. | Hiện option theo role và lệnh mẫu `/profile tech apply ...`. |
|
|
109
|
+
| `/profile tech apply fullstack frontend=nextjs backend=nestjs database=prisma` | Apply trực tiếp | Khi team muốn một lệnh deterministic, không chat dài. | Ghi profile, lock, tech manifest, Context7 placeholders. |
|
|
110
|
+
| `/profile tech refresh` | Xem Context7 cần record | Sau khi chọn tech stack. | Hiện các query Context7 cần đọc và record bằng tool runtime. |
|
|
111
|
+
| `/memory-policy` | Kiểm tra memory | Khi muốn biết Pi đang nhớ gì, hoặc muốn lưu memory explicit. | Hiện chính sách memory và file `.pi/memory/*`. |
|
|
112
|
+
| `/piagent-orchestration` | Xem policy solo/subagent | Khi muốn biết task sẽ chạy solo-first, lens nào, Field Guide nào. | Hiện status compact, không gọi model follow-up. |
|
|
113
|
+
| `/model-options` | Giải thích model | Khi chưa rõ chọn provider model nào, thinking nào. | Giải thích selector, scope, thinking, benchmark rule. |
|
|
114
|
+
| `/task-preflight` | Kiểm context trước task | Trước task lớn/risk cao hoặc khi session đã dài. | Báo nên chạy trực tiếp, compact, hay fresh session. |
|
|
115
|
+
| `/task-preflight compact` | Compact có hướng dẫn | Khi context 70%+ hoặc trước task dài tiếp theo. | Pi compact session, giữ quyết định/open blockers/verify cần thiết. |
|
|
116
|
+
| `/piagent-usage` | Snapshot token/context | Khi muốn biết session đang ăn context/token như nào. | Hiện session file, model, live context, lệnh lấy exact stats. |
|
|
117
|
+
| `/platform-improve` | Cải tiến platform/workflow | Khi cần cập nhật setup, prompt, MCP, model scope, memory, runtime policy, docs, hoặc subagent workflow. | Có implementation matrix, source changes, docs, và verify. |
|
|
118
|
+
| `/be-to-fe` | Map BE spec sang FE | Khi BE là source-of-truth/read-only, chỉ implement FE. | Scout BE read-only, map contract, implement FE, verify FE. |
|
|
119
|
+
| `/scout` | Scout/audit read-only | Khi cần evidence matrix trước khi chốt task, đặc biệt payment/auth/data/BE contract. | Không sửa source; trả context manifest, verify, gaps, risks. |
|
|
120
|
+
| `/fresh-scout` | Scout trong session mới | Khi task scout lớn hoặc session hiện tại nặng. | Tự mở session mới và chạy `/scout` với request ngắn. |
|
|
121
|
+
| `/fresh-task` | Task trong session mới | Khi implementation mới không nên kéo context cũ. | Tự mở session mới và chạy `/task`. |
|
|
122
|
+
| `/fresh-be-to-fe` | BE→FE trong session mới | Khi mapping BE/FE lớn hoặc session hiện tại đã phình. | Tự mở session mới và chạy `/be-to-fe`. |
|
|
123
|
+
| `/task` | Implement task chuẩn | Khi requirement đã rõ. | Có task contract, context manifest, verify, trace, gate. |
|
|
124
|
+
| `/commit [message/scope]` | Commit local có guard | Khi diff đã review và muốn tạo commit gọn. | Stage file rõ ràng, chạy verify phù hợp, commit local; không push. |
|
|
125
|
+
| `/pr [title/request]` | Chuẩn bị pull request | Khi branch đã commit xong và muốn mở PR. | Check status/branch/remote, verify, hỏi xác nhận trước push hoặc tạo/cập nhật PR. |
|
|
126
|
+
| `/plan` | Lập kế hoạch | Khi cần bóc task trước khi sửa. | Plan có scope, file target, verify, risk. |
|
|
127
|
+
| `/discuss` | Trao đổi/làm rõ | Khi chưa nên sửa code. | Giải thích option/tradeoff, không tự implement. |
|
|
128
|
+
| `/review` | Review current diff/source | Khi cần audit read-only trước final/merge. | Findings theo severity, file/area, required fix. |
|
|
129
|
+
|
|
130
|
+
Git flow của Pi cố ý không dùng namespace `/git-*`. Daily flow là nói tự nhiên hoặc dùng lệnh ngắn:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
/commit docs: update onboarding notes
|
|
134
|
+
/pr Add guarded git workflow
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`/commit` chỉ tạo local commit. `/pr` có thể cần `git push` và GitHub write action, nên guard vẫn bắt agent xác nhận rõ branch/title/scope trước khi đẩy hoặc tạo PR. Các lệnh stage rộng như `git add .`, `git add -A`, `git add --all`, `git add -- .`, `git add :/` cũng bị đưa qua confirmation để tránh gom nhầm file riêng tư hoặc unrelated diff.
|
|
138
|
+
|
|
139
|
+
## Image/screenshot input
|
|
140
|
+
|
|
141
|
+
| Tình huống | Cách dùng | Kết quả |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| Chat box trả ra local path ảnh | `/scout Check screenshot /var/folders/.../screenshot.png` | Platform attach ảnh và rewrite path thành `[image1]`. |
|
|
144
|
+
| Nhiều ảnh trong cùng prompt | Dán tối đa 4 path ảnh | Prompt có `[image1]`, `[image2]`, ... |
|
|
145
|
+
| Ảnh quá lớn | Dùng Pi `read` tool trên file ảnh hoặc resize ảnh trước | Tránh nhồi ảnh quá lớn vào chat input. |
|
|
146
|
+
|
|
147
|
+
Định dạng hỗ trợ: `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp`. Giới hạn mặc định: 4 ảnh/input, 8 MB/ảnh.
|
|
148
|
+
|
|
149
|
+
Profile name nên biết:
|
|
150
|
+
|
|
151
|
+
| Profile | Dùng khi nào |
|
|
152
|
+
|---|---|
|
|
153
|
+
| `generic` | Repo chưa rõ cấu trúc. |
|
|
154
|
+
| `web-frontend` | Chỉ FE. |
|
|
155
|
+
| `backend-api` | Chỉ BE/API. |
|
|
156
|
+
| `be-readonly-fe` | BE đọc-only, FE là nơi sửa. |
|
|
157
|
+
| `fullstack` | FE và BE đều có thể sửa nếu task cho phép. |
|
|
158
|
+
| `node-typescript` | Tooling/lib Node TypeScript. |
|
|
159
|
+
| `python` | Python app/lib. |
|
|
160
|
+
| `data` | ETL, dbt, data pipeline, notebook. |
|
|
161
|
+
| `devops` | Docker, Terraform, K8s, CI/CD. |
|
|
162
|
+
| `mobile` | React Native/Flutter. |
|
|
163
|
+
| `docs` | Docs/manual/portal. |
|
|
164
|
+
|
|
165
|
+
Tech stack option theo profile:
|
|
166
|
+
|
|
167
|
+
| Profile | Role bắt buộc chọn | Ví dụ |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| `web-frontend` | Frontend + database optional | `frontend=nextjs database=none` |
|
|
170
|
+
| `backend-api` | Backend + database optional | `backend=nestjs database=prisma` |
|
|
171
|
+
| `fullstack` | Frontend + backend + database optional | `frontend=nextjs backend=nestjs database=prisma` |
|
|
172
|
+
| `be-readonly-fe` | Frontend + backend + database optional | `frontend=react-vite backend=fastapi database=postgres` |
|
|
173
|
+
| `mobile` | Mobile | `mobile=react-native` |
|
|
174
|
+
| `devops` | DevOps | `devops=docker` |
|
|
175
|
+
| `data` | Data + database optional | `data=dbt database=postgres` |
|
|
176
|
+
| `docs` | Docs | `docs=mintlify` |
|
|
177
|
+
|
|
178
|
+
Sau khi chọn tech, platform tạo `.pi/tech-stack.json` và các file `.pi/tech-context/<tech>.json`. `/onboard-project` sẽ đưa các pointer này vào `.pi/context-index.json`. File context chỉ nên chứa tóm tắt ngắn/citation từ Context7, không lưu nguyên văn docs dài, token, session, hoặc secret.
|
|
179
|
+
|
|
180
|
+
## Command native của Pi
|
|
181
|
+
|
|
182
|
+
Các command này thuộc Pi core hoặc package Pi chính. Tên/availability có thể phụ thuộc version Pi.
|
|
183
|
+
|
|
184
|
+
| Command/hotkey | Dịch nghĩa | Dùng khi nào | Ghi chú |
|
|
185
|
+
|---|---|---|---|
|
|
186
|
+
| `/login` | Đăng nhập provider | Lần đầu dùng OpenAI/Codex hoặc Anthropic/Claude. | OAuth/session lưu local trong Pi, không commit repo. |
|
|
187
|
+
| `/model` | Chọn model | Muốn chọn OpenAI provider bằng native selector. | Đây là flow chính, không phải hỏi agent tự chọn thay. |
|
|
188
|
+
| `Ctrl+L` | Mở model selector | Đổi model nhanh. | Tương đương UI selector của Pi. |
|
|
189
|
+
| `/scoped-models` | Chỉnh danh sách model cycle | Muốn `Ctrl+P` chỉ xoay quanh vài model hay dùng. | Global setup seed sẵn provider model families. |
|
|
190
|
+
| `Ctrl+P` | Cycle model | Đổi model trong scope nhanh. | Dùng sau khi đã setup `enabledModels`. |
|
|
191
|
+
| `Shift+Ctrl+P` | Cycle model ngược | Quay lại model trước trong scope. | Tiện khi test provider. |
|
|
192
|
+
| `Shift+Tab` | Đổi thinking level | Chọn effort như `medium`, `high`, `xhigh`, `max` nếu model hỗ trợ. | Model không hỗ trợ level nào thì Pi có thể clamp. |
|
|
193
|
+
| `/session` | Xem session hiện tại | Cần session id/name/token/cost/context. | Dùng cùng `/piagent-usage`. |
|
|
194
|
+
| `/resume` | Resume session | Khi tắt nhầm Pi hoặc muốn nối lại work cũ. | Dựa vào session list/id/name của Pi. |
|
|
195
|
+
| `/compact` | Nén context | Khi context usage cao trước task dài. | Chỉ dùng khi cần; đọc lại context quan trọng sau compact. |
|
|
196
|
+
| `/mcp` | Xem MCP | Kiểm tra server/tool MCP trong Pi. | Cần `pi-mcp-adapter` hoặc MCP config tương ứng. |
|
|
197
|
+
| `/mcp setup` | Setup/refresh MCP | Khi MCP chưa nhận config. | Tùy adapter/version. |
|
|
198
|
+
| `/mcp tools` | List MCP tools | Muốn biết server expose tool nào. | Dùng trước khi bảo agent gọi tool ngoài. |
|
|
199
|
+
| `/mcp reconnect` | Kết nối lại MCP | Khi server lỗi, token mới, hoặc config đổi. | Không thay thế việc export secret env. |
|
|
200
|
+
| `/mcp-auth figma` | OAuth Figma MCP | Khi dùng Figma remote MCP. | Có thể khác theo Figma/Pi MCP package version. |
|
|
201
|
+
|
|
202
|
+
## Command subagent
|
|
203
|
+
|
|
204
|
+
Các command này đến từ package `pi-subagents`. Tên hơi “package terminology”, nên bảng dưới dịch ra nghĩa thực tế.
|
|
205
|
+
|
|
206
|
+
Quan trọng: daily flow không bắt anh phải nhớ các lệnh này. Các workflow `/task`, `/be-to-fe`, `/platform-improve`, `/plan`, `/review` dùng solo-first orchestration: parent agent lập task tree/review lenses trước, rồi chỉ spawn subagent khi task có phần việc độc lập và đáng token. Slash command dưới đây dùng khi anh muốn ép orchestration cụ thể hoặc debug.
|
|
207
|
+
|
|
208
|
+
| Command | Dịch nghĩa dễ hiểu | Dùng khi nào | Kết quả mong đợi |
|
|
209
|
+
|---|---|---|---|
|
|
210
|
+
| `/subagents-doctor` | Health check subagent | Khi mới setup, sau update, hoặc subagent không chạy. | Kiểm tra package, config, agent files, runtime readiness. |
|
|
211
|
+
| `/subagents-models` | Bản đồ model của subagent | Khi muốn biết mỗi agent đang inherit model nào hoặc override gì. | Hiện model/thinking/routing đang áp dụng cho subagents. |
|
|
212
|
+
| `/subagents` | Catalog/admin agents | Khi muốn xem agent nào có sẵn. | List builtin + piagent agents, có thể inspect metadata. |
|
|
213
|
+
| `/subagents-fleet` | Dashboard đội agent đang chạy | Khi có background/parallel subagents. | Hiện active/done runs, id, status, transcript/result nếu hỗ trợ. |
|
|
214
|
+
| `/subagent-cost` | Chi phí/token subagents | Khi muốn biết parent + child agents tiêu hao ra sao. | Hiện usage/cost theo runs nếu package/provider expose stats. |
|
|
215
|
+
| `/subagents-watchdog` | Giám sát run bị treo | Khi background agents có nguy cơ stuck/timeout. | Theo dõi/nhắc trạng thái tùy package. |
|
|
216
|
+
| `/subagents-watchdog recommend-model` | Gợi ý model watchdog | Khi muốn watchdog dùng model mạnh bổ sung với model chính. | Trả gợi ý model/thinking hiện tại. |
|
|
217
|
+
| `/subagents-watchdog on` | Bật watchdog | Khi muốn adversarial review ở cuối turn cho session/project. | Watchdog review repo edits ở `agent_end`; có thể tốn thêm token. |
|
|
218
|
+
| `/subagents-profiles` | List profiles | Khi team có nhiều provider/quota profile. | Hiện profiles trong `~/.pi/agent/profile/pi-subagents/`. |
|
|
219
|
+
| `/subagents-refresh-provider-models <provider>` | Refresh model catalog | Khi model registry/provider thay đổi. | Probe/cache catalog provider. |
|
|
220
|
+
| `/subagents-generate-profiles <provider>` | Sinh quota/quality profiles | Khi muốn profile model theo quota/chất lượng. | Tạo profile cho provider. |
|
|
221
|
+
| `/subagents-check-profile <name>` | Check profile | Khi profile/model có thể stale. | Re-check model availability/auth. |
|
|
222
|
+
| `/run <agent> "<task>"` | Chạy 1 subagent | Khi cần 1 scout/reviewer/planner riêng context. | Child session chạy task rồi trả summary về parent. |
|
|
223
|
+
| `/run <agent> "<task>" --bg` | Chạy background | Khi muốn agent chạy nền rồi mình xem sau. | Dùng `/subagents-fleet` để follow. |
|
|
224
|
+
| `/run <agent> "<task>" --fork` | Chạy từ forked session | Khi child cần inherited conversation/context branch. | Fork thật từ parent leaf; dùng fresh nếu không cần history. |
|
|
225
|
+
| `/parallel ...` | Chạy nhiều agent song song | Khi các việc độc lập, nhất là read-only review/scout/test analysis. | Parent đợi hoặc gom kết quả tùy flow. |
|
|
226
|
+
| `/chain ...` | Chạy tuần tự | Khi output agent trước là input agent sau. | Dùng `{previous}` để truyền summary trước đó. |
|
|
227
|
+
| `/run-chain <name>` | Chạy chain đã lưu | Khi có workflow lặp lại. | Package chạy recipe chain đã định nghĩa. |
|
|
228
|
+
| `/parallel-review` | Review song song | Khi cần nhiều reviewer theo góc nhìn độc lập. | Có thể thêm `autofix` nếu đã cho phép sửa. |
|
|
229
|
+
| `/review-loop` | Worker/reviewer/fix loop | Khi muốn review đến khi sạch hoặc hết vòng. | Nên set max rounds, thường dùng tối đa 3 vòng. |
|
|
230
|
+
| `/parallel-research` | Research song song | Khi cần external evidence + local scout. | Builtin `researcher` cần `pi-web-access`. |
|
|
231
|
+
| `/parallel-context-build` | Build context handoff | Khi task lớn cần `context.md`/meta-prompt trước planning. | Dùng `context-builder` agents. |
|
|
232
|
+
| `/parallel-handoff-plan` | Research + context + plan | Khi muốn handoff plan đầy đủ cho implementation. | Tốt cho architecture hoặc platform change lớn. |
|
|
233
|
+
| `/gather-context-and-clarify` | Scout rồi hỏi đúng câu | Khi requirement chưa rõ nhưng cần đọc trước. | Trả clarification questions có evidence. |
|
|
234
|
+
| `/parallel-cleanup` | Cleanup review sau implement | Khi muốn rà cleanup đáng làm. | Có thể thêm `autofix`. |
|
|
235
|
+
|
|
236
|
+
Glossary:
|
|
237
|
+
|
|
238
|
+
| Từ | Nghĩa trong repo mình |
|
|
239
|
+
|---|---|
|
|
240
|
+
| `doctor` | Kiểm tra sức khỏe/setup, không sửa logic task. |
|
|
241
|
+
| `models` | Cho biết model/thinking từng subagent sẽ dùng. |
|
|
242
|
+
| `fleet` | “Đội” child sessions đang chạy hoặc vừa chạy xong. |
|
|
243
|
+
| `scout` | Agent đọc/map code read-only. |
|
|
244
|
+
| `planner` | Agent lập plan và verify gate, không sửa code. |
|
|
245
|
+
| `worker` | Agent sửa code theo plan. |
|
|
246
|
+
| `reviewer` | Agent review diff/test/scope. |
|
|
247
|
+
| `oracle` | Agent phản biện/risk challenge. |
|
|
248
|
+
| `researcher` | Builtin agent nghiên cứu web/docs có nguồn; cần `pi-web-access`. |
|
|
249
|
+
| `context-builder` | Builtin agent tạo context/meta-prompt handoff cho task lớn. |
|
|
250
|
+
| `chain` | Làm A rồi dùng kết quả A để làm B. |
|
|
251
|
+
| `parallel` | Làm nhiều nhánh độc lập cùng lúc. |
|
|
252
|
+
| `bg` | Background run, không block parent ngay. |
|
|
253
|
+
| `fork` | Child bắt đầu từ nhánh session hiện tại thay vì context fresh. |
|
|
254
|
+
| `watchdog` | Opt-in adversarial reviewer ở cuối turn; không phải `reviewer` subagent. |
|
|
255
|
+
| `worktree` | Checkout riêng cho parallel writers để tránh đè file nhau. |
|
|
256
|
+
|
|
257
|
+
Piagent subagents:
|
|
258
|
+
|
|
259
|
+
| Agent | Khi dùng | Write policy |
|
|
260
|
+
|---|---|---|
|
|
261
|
+
| `piagent-scout` | Map repo/module/spec trước khi sửa. | Read-only. |
|
|
262
|
+
| `piagent-planner` | Lập implementation plan. | Read-only. |
|
|
263
|
+
| `piagent-worker` | Implement task đã rõ/đã approve. | Có thể write trong scope. |
|
|
264
|
+
| `piagent-reviewer` | Review diff, verify coverage, scope drift. | Review-first. |
|
|
265
|
+
| `piagent-oracle` | Challenge architecture/risk. | Read-only. |
|
|
266
|
+
|
|
267
|
+
## Exact subagent control syntax
|
|
268
|
+
|
|
269
|
+
Dùng khi muốn chính xác hơn slash command:
|
|
270
|
+
|
|
271
|
+
```text
|
|
272
|
+
subagent({ agent: "piagent-scout", task: "Map the auth flow. Read-only.", context: "fresh" })
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Status:
|
|
276
|
+
|
|
277
|
+
```text
|
|
278
|
+
subagent({ action: "status" })
|
|
279
|
+
subagent({ action: "status", id: "<run-id>", view: "transcript" })
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Điều khiển run:
|
|
283
|
+
|
|
284
|
+
```text
|
|
285
|
+
subagent({ action: "steer", id: "<run-id>", message: "Focus only on tests." })
|
|
286
|
+
subagent({ action: "stop", id: "<run-id>" })
|
|
287
|
+
subagent({ action: "resume", id: "<run-id>", message: "Continue after this clarification." })
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Rule thực tế: dùng slash/natural prompt cho hầu hết task; dùng tool syntax khi cần debug run id hoặc steer/stop chính xác.
|
|
291
|
+
|
|
292
|
+
Một số option hữu ích:
|
|
293
|
+
|
|
294
|
+
```text
|
|
295
|
+
/run reviewer[model=anthropic/claude-sonnet-5:high] "Review this diff"
|
|
296
|
+
/run scout[output=context.md,outputMode=file-only] "Map auth flow"
|
|
297
|
+
/chain scout[output=context.md,as=context] "Scan" -> planner[reads=context.md] "Plan from {outputs.context}"
|
|
298
|
+
subagent({ action: "status", view: "fleet" })
|
|
299
|
+
subagent({ action: "status", id: "<run-id>", view: "transcript", lines: 120 })
|
|
300
|
+
subagent({ action: "grant-spawn-budget", additional: 10 })
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
`outputMode=file-only` hữu ích khi child tạo report dài: parent chỉ nhận đường dẫn file, không bị nhồi full report vào context.
|
|
304
|
+
|
|
305
|
+
## Khi nào nên spawn subagent
|
|
306
|
+
|
|
307
|
+
Theo provider docs, subagent tốt nhất cho việc độc lập và bounded:
|
|
308
|
+
|
|
309
|
+
- codebase exploration;
|
|
310
|
+
- map contract/API/schema;
|
|
311
|
+
- đọc docs/spec dài rồi tóm tắt;
|
|
312
|
+
- review correctness/security/tests/scope drift theo nhiều góc nhìn;
|
|
313
|
+
- chạy/test analysis không cần sửa cùng file;
|
|
314
|
+
- compress context trước khi parent/worker implement.
|
|
315
|
+
|
|
316
|
+
Không nên spawn bừa khi:
|
|
317
|
+
|
|
318
|
+
- task nhỏ, một file, verify đơn giản;
|
|
319
|
+
- nhiều writer cùng sửa chung vùng source;
|
|
320
|
+
- requirement chưa rõ;
|
|
321
|
+
- cần quyết định product/architecture từ user;
|
|
322
|
+
- repo đang dirty mà chưa hiểu thay đổi của ai.
|
|
323
|
+
|
|
324
|
+
Default của platform là an toàn:
|
|
325
|
+
|
|
326
|
+
- `maxSubagentDepth: 1`: parent spawn child, child không fan-out tiếp.
|
|
327
|
+
- `parallel.concurrency: 3`: không mở quá nhiều child cùng lúc.
|
|
328
|
+
- `asyncByDefault: false`: không tự chạy background nếu anh không yêu cầu.
|
|
329
|
+
- Một `piagent-worker` tại một thời điểm; parallel chủ yếu dùng cho scout/reviewer.
|
|
330
|
+
|
|
331
|
+
Nếu anh không gọi gì thêm, `/task` vẫn chạy solo-first và chỉ tự dùng subagent theo `docs/auto-delegation-policy.md` khi có scout/planning/review độc lập đáng làm.
|
|
332
|
+
|
|
333
|
+
## Prompt mẫu cho bài toán thật
|
|
334
|
+
|
|
335
|
+
### Platform/package improvement
|
|
336
|
+
|
|
337
|
+
```text
|
|
338
|
+
/platform-improve Improve onboarding, model scope, MCP setup, and verification docs for team usage. Keep workflows public, project-agnostic, and verifiable.
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Khi muốn tách rõ agents:
|
|
342
|
+
|
|
343
|
+
```text
|
|
344
|
+
Use piagent-scout to map current platform docs/scripts read-only.
|
|
345
|
+
Use piagent-scout to inspect relevant external source context read-only when the user provides it.
|
|
346
|
+
Then use piagent-planner to produce an implementation plan.
|
|
347
|
+
Only after plan is clear, use piagent-worker for implementation.
|
|
348
|
+
Use piagent-reviewer before final.
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### BE spec lên FE, không sửa BE
|
|
352
|
+
|
|
353
|
+
```text
|
|
354
|
+
/profile be-readonly-fe
|
|
355
|
+
/be-to-fe Implement FE support for <endpoint/spec>. Scout backend read-only, map contract, then edit frontend only.
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Nếu muốn parallel read-only:
|
|
359
|
+
|
|
360
|
+
```text
|
|
361
|
+
Run parallel piagent-scout agents: one maps backend contract read-only, one maps frontend route/state usage. Wait for both, then plan FE implementation.
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Review trước khi ship
|
|
365
|
+
|
|
366
|
+
```text
|
|
367
|
+
/review current diff
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Hoặc chia reviewer:
|
|
371
|
+
|
|
372
|
+
```text
|
|
373
|
+
/parallel piagent-reviewer "Review correctness and edge cases" -> piagent-reviewer "Review tests and verification gaps" -> piagent-reviewer "Review scope drift and protected paths"
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Terminal commands
|
|
377
|
+
|
|
378
|
+
Các lệnh này chạy ngoài Pi.
|
|
379
|
+
|
|
380
|
+
| Command | Dùng khi nào |
|
|
381
|
+
|---|---|
|
|
382
|
+
| `npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.81.1` | Cài Pi CLI tương thích với release hiện tại. |
|
|
383
|
+
| `npm install -g --ignore-scripts github:Vt-mmm/piagent#v1.0.0` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
|
|
384
|
+
| `pi install git:github.com/Vt-mmm/piagent@v1.0.0` | Cài pinned release khi cần reproducible team setup. |
|
|
385
|
+
| `pi install git:github.com/Vt-mmm/piagent` | Cài latest package platform cho máy cá nhân/sandbox. |
|
|
386
|
+
| 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, npm-global helper và Pi package. v1.0.0 yêu cầu Pi `0.81.1`. |
|
|
387
|
+
| Cài exact Pi host ghi trong release cũ, rồi helper `vPREVIOUS` và `piagent-install --stable` | Full rollback; đánh giá dependency risk của host cũ trước khi hạ version. |
|
|
388
|
+
| `piagent-install --stable --dry-run` | Preview Pi package matching với helper hiện tại; stable resolve tag → commit SHA. |
|
|
389
|
+
| `piagent-install --stable` | Cài Pi package matching với helper hiện tại bằng resolved commit SHA. |
|
|
390
|
+
| `piagent-install --version vX.Y.Z --resolve-tag` | Chỉ đổi Pi package; npm-global helper giữ nguyên version. |
|
|
391
|
+
| `piagent-install --version vX.Y.Z` | Chỉ đổi Pi package theo exact tag literal khi cần giữ behavior cũ. |
|
|
392
|
+
| `piagent-install --dev` | Theo moving source cho máy cá nhân/sandbox; không commit vào `.pi/settings.json`. |
|
|
393
|
+
| `pi update --extensions` | Refresh package đã cài; với pinned tag/commit, muốn nâng version thì chạy lại install bằng ref mới. |
|
|
394
|
+
| `pi list --approve` | Xem package Pi đã install. |
|
|
395
|
+
| `piagent-auto` | Mở Pi với project trust `--approve` cho lần chạy hiện tại; guard vẫn bật. |
|
|
396
|
+
| `piagent-auto --read-only -p "<task>"` | Auto-run scout/read-only; guard chặn shell/write/unknown tool. |
|
|
397
|
+
| `piagent-auto --full-access -p "<task>"` | Trusted automation style; không tắt protected paths/redaction/human gates. |
|
|
398
|
+
| `pi` rồi `/full-access <task>` | Một lệnh trong Pi để bật full-access cho session và giao task. |
|
|
399
|
+
| `pi --list-models` | Xem model Pi thấy được theo credentials hiện tại. |
|
|
400
|
+
| `piagent-install --with-mcp --with-subagents` | Cài global package + MCP + subagent baseline từ package bin. |
|
|
401
|
+
| `piagent-setup <project> --profile auto` | Setup đầy đủ cho một project khi muốn preseed bằng bin. |
|
|
402
|
+
| `piagent-init <project> --profile generic` | Init project files tối thiểu. |
|
|
403
|
+
| `piagent-models` | Xem catalog model seeded bởi platform. |
|
|
404
|
+
| `piagent-model-scope --preset full` | Re-apply full provider model scope. |
|
|
405
|
+
| `piagent-mcp --preset core --scope global --replace` | Apply the governed MCP core baseline: Context7, Chrome DevTools, GitHub. |
|
|
406
|
+
| `piagent-mcp --preset popular --scope global --replace` | Apply the governed MCP popular baseline: core + Playwright + Figma remote. |
|
|
407
|
+
| `piagent-mcp --list` | List MCP presets. |
|
|
408
|
+
| `piagent-subagents --preset safe` | Re-apply subagent safe config. |
|
|
409
|
+
| `pi install npm:pi-web-access@0.13.0` | Optional: cấp web/search/fetch tools cho builtin `researcher`. |
|
|
410
|
+
| `piagent-setup <project> --with-web-access` | Setup project + optional web access cho research subagents. |
|
|
411
|
+
| `piagent-usage /path/to/project` | Lấy exact session usage từ terminal khác. |
|
|
412
|
+
| `piagent-doctor /path/to/project --strict-share` | Kiểm tra project có share/open-source được không. |
|
|
413
|
+
| `piagent-benchmark ...` | Ghi quality benchmark bằng package bin. |
|
|
414
|
+
| `bash scripts/verify-local.sh` | Verify repo platform trước khi commit/tag. |
|
|
415
|
+
| `bash scripts/verify-local.sh --offline` | Verify trong CI/máy sạch, bỏ qua local Pi model catalog. |
|
|
416
|
+
| `bash scripts/setup.sh <project> ...` | Preseed setup project; không bắt buộc cho daily flow. |
|
|
417
|
+
| `bash scripts/quality-benchmark.sh ...` | Ghi quality benchmark theo scenario thật. |
|
|
418
|
+
|
|
419
|
+
Trong output `piagent-install`, `currentRelease` là version của terminal helper đang chạy, không phải lời xác nhận rằng npm-global helper vừa được update. Checklist đầy đủ nằm tại [release/install policy](release-install-policy.md).
|
|
420
|
+
|
|
421
|
+
Khi đang develop chính repo `piagent`, có thể dùng npm scripts tương ứng:
|
|
422
|
+
|
|
423
|
+
| Command | Tương đương |
|
|
424
|
+
|---|---|
|
|
425
|
+
| `npm run verify` | `bash scripts/verify-local.sh` |
|
|
426
|
+
| `npm run setup -- <project>` | `bash scripts/setup.sh <project>` |
|
|
427
|
+
| `npm run install-global` | `bash scripts/install-global.sh` |
|
|
428
|
+
| `npm run init-project -- <project>` | `bash scripts/init-project.sh <project>` |
|
|
429
|
+
| `npm run doctor -- <project> --strict-share` | `bash scripts/team-doctor.sh <project> --strict-share` |
|
|
430
|
+
| `npm run benchmark -- ...` | `bash scripts/quality-benchmark.sh ...` |
|
|
431
|
+
| `npm run usage -- <project>` | `bash scripts/pi-session-stats.sh <project>` |
|
|
432
|
+
| `npm run models` | `bash scripts/pi-model-catalog.sh` |
|
|
433
|
+
| `npm run model-scope -- --preset full` | `bash scripts/configure-model-scope.sh --preset full` |
|
|
434
|
+
| `npm run mcp -- --preset core --scope global --replace` | `bash scripts/configure-mcp.sh --preset core --scope global --replace` |
|
|
435
|
+
| `npm run subagents -- --preset safe` | `bash scripts/configure-subagents.sh --preset safe` |
|
|
436
|
+
|
|
437
|
+
## MCP command quick map
|
|
438
|
+
|
|
439
|
+
| Muốn làm gì | Gõ |
|
|
440
|
+
|---|---|
|
|
441
|
+
| Kiểm tra MCP trong Pi | `/mcp` |
|
|
442
|
+
| Xem tool MCP | `/mcp tools` |
|
|
443
|
+
| Reconnect sau khi đổi config/env | `/mcp reconnect` |
|
|
444
|
+
| Apply global Context7/Chrome/GitHub baseline | `piagent-mcp --preset core --scope global --replace` |
|
|
445
|
+
| Apply Figma/Playwright baseline | `piagent-mcp --preset popular --scope global --replace` |
|
|
446
|
+
| Xem preset | `piagent-mcp --list` |
|
|
447
|
+
|
|
448
|
+
Secret phải để trong env, không commit:
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
export CONTEXT7_API_KEY=ctx7sk_...
|
|
452
|
+
export GITHUB_PERSONAL_ACCESS_TOKEN=<github-token>
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## Token/context command quick map
|
|
456
|
+
|
|
457
|
+
| Câu hỏi | Lệnh |
|
|
458
|
+
|---|---|
|
|
459
|
+
| Session này đang dùng model gì? | `/session` hoặc `/piagent-usage` |
|
|
460
|
+
| Context window đang còn bao nhiêu? | `/piagent-usage` |
|
|
461
|
+
| Exact token/cost từ terminal khác? | `piagent-usage /path/to/project` |
|
|
462
|
+
| Subagents tốn bao nhiêu? | `/subagent-cost` |
|
|
463
|
+
| Có nên compact chưa? | Xem `contextUsage.percent`; trên 75% mới cân nhắc `/compact`. |
|
|
464
|
+
|
|
465
|
+
Không claim tiết kiệm token/cost nếu chưa có số liệu cùng scenario. Dùng benchmark script để ghi lại.
|
|
466
|
+
|
|
467
|
+
## Source rule cho subagent/custom agent
|
|
468
|
+
|
|
469
|
+
Mental model chuẩn:
|
|
470
|
+
|
|
471
|
+
1. Parent Pi là coordinator: giữ requirement, quyết định, final output.
|
|
472
|
+
2. Subagent là child session: có context riêng, có thể dùng model/tool riêng hoặc inherit parent.
|
|
473
|
+
3. Child trả summary/result về parent; parent không nên bị nhồi toàn bộ log trung gian.
|
|
474
|
+
4. Dùng read-only subagents trước: scout, docs research, review, test-gap analysis.
|
|
475
|
+
5. Writer song song chỉ dùng khi có worktree isolation và write set không overlap.
|
|
476
|
+
6. Agent custom tốt phải có role hẹp, tool surface rõ, output contract rõ.
|
|
477
|
+
|
|
478
|
+
Đây là lý do platform mình có `piagent-scout`, `piagent-planner`, `piagent-worker`, `piagent-reviewer`, `piagent-oracle` thay vì một agent tổng quát làm tất cả.
|
|
479
|
+
|
|
480
|
+
## Tài liệu chính
|
|
481
|
+
|
|
482
|
+
- Pi usage docs: https://pi.dev/docs/latest/usage
|
|
483
|
+
- Pi packages: https://pi.dev/packages
|
|
484
|
+
- pi-subagents package: https://pi.dev/packages/pi-subagents
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Context-window policy
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Không nhồi toàn bộ repo vào context. Agent phải load đúng lớp context theo task.
|
|
6
|
+
|
|
7
|
+
Lần đầu gắn project vào platform, chạy `/onboard-project` sau login/model selection để tạo `.pi/project-context.md` và `.pi/context-index.json`. Các task sau dùng context index như bản đồ nhỏ để tìm đúng vùng cần đọc, rồi vẫn verify bằng files task-specific hiện tại.
|
|
8
|
+
|
|
9
|
+
## Context order
|
|
10
|
+
|
|
11
|
+
1. `AGENTS.md` gần project nhất.
|
|
12
|
+
2. Project profile: `.pi/piagent-profile.json`.
|
|
13
|
+
3. Project context index: `.pi/context-index.json` nếu tồn tại và không stale.
|
|
14
|
+
4. Project context snapshot: `.pi/project-context.md`.
|
|
15
|
+
5. Memory summary nếu profile bật memory và task liên quan: `.pi/memory/memory_summary.md`.
|
|
16
|
+
6. Required context từ profile.
|
|
17
|
+
7. Task-specific files.
|
|
18
|
+
8. Related tests/docs.
|
|
19
|
+
9. External docs only khi cần và ưu tiên official docs.
|
|
20
|
+
|
|
21
|
+
Trước khi ghi context manifest hoặc dự định đưa file lớn vào prompt, dùng:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
piagent_context_preflight
|
|
25
|
+
piagent_context_budget
|
|
26
|
+
piagent_context_index_status
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Trước task lớn/risk cao trong Pi TUI:
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
/task-preflight
|
|
33
|
+
/task-preflight compact
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Nếu recommendation là `fresh-session`, dùng `/fresh-task`, `/fresh-scout`, hoặc `/fresh-be-to-fe` thay vì tiếp tục nhồi context vào session hiện tại.
|
|
37
|
+
|
|
38
|
+
## Context manifest
|
|
39
|
+
|
|
40
|
+
Mỗi task nên có manifest ngắn:
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
Context manifest
|
|
44
|
+
- profile: .pi/piagent-profile.json
|
|
45
|
+
- index: .pi/context-index.json (advisory map)
|
|
46
|
+
- snapshot: .pi/project-context.md
|
|
47
|
+
- memory: .pi/memory/memory_summary.md (if relevant)
|
|
48
|
+
- required: AGENTS.md
|
|
49
|
+
- required: docs/architecture.md
|
|
50
|
+
- task files: src/...
|
|
51
|
+
- verify: npm test
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Compaction default
|
|
55
|
+
|
|
56
|
+
Pi settings template dùng:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"compaction": {
|
|
61
|
+
"enabled": true,
|
|
62
|
+
"reserveTokens": 16384,
|
|
63
|
+
"keepRecentTokens": 20000
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Rule
|
|
69
|
+
|
|
70
|
+
- Nếu task là read-only, không mở write-capable prompt.
|
|
71
|
+
- Nếu task là source-write, phải biết verify command trước khi sửa.
|
|
72
|
+
- Không paste full mandatory-flow boilerplate vào task hằng ngày; platform prompts/tools đã chứa flow đó.
|
|
73
|
+
- Nếu context vượt budget, tạo summary theo module thay vì nhồi full files.
|
|
74
|
+
- Dùng `/context-index` hoặc `piagent_context_index_search` để tìm điểm vào repo, nhưng không dùng index thay thế việc đọc source thật.
|
|
75
|
+
- Không raw-read hoặc raw-edit `.pi/context-index.json` trong task thường ngày. Runtime coi index là advisory state, sanitize khi đọc qua tool/command, và ghi qua `/onboard-project` hoặc `piagent_context_index_record`.
|
|
76
|
+
- File context vượt hard cap phải được summarize hoặc đọc targeted slices, không inject full.
|
|
77
|
+
- Nếu input quá dài thật, lưu intake vào file project/local gitignored rồi reference file; không dán toàn bộ spec vào một turn.
|
|
78
|
+
- Nếu input chứa local screenshot/image path, để input guard attach thành `[image1]` thay vì đọc ảnh như text context. Ảnh lớn hơn giới hạn chat nên dùng Pi `read` để resize.
|
|
79
|
+
- Memory chỉ là hint. Phải verify bằng source hiện tại trước khi sửa code.
|
|
80
|
+
- Context index cũng chỉ là hint. Nó có node/edge/citation để giảm scout lại, không phải security boundary hoặc source of truth.
|
|
81
|
+
|
|
82
|
+
## Nguồn
|
|
83
|
+
|
|
84
|
+
- Pi compaction: https://pi.dev/docs/latest/compaction
|
|
85
|
+
- Pi settings: https://pi.dev/docs/latest/settings
|