@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,192 @@
|
|
|
1
|
+
# Solo-first orchestration policy
|
|
2
|
+
|
|
3
|
+
Mục tiêu: user không phải nhớ `/run`, `/parallel`, `/chain` cho workflow hằng ngày, nhưng platform cũng không tự biến mọi task thành swarm tốn token. Khi anh gõ `/task`, `/be-to-fe`, `/platform-improve`, `/plan`, hoặc `/review`, parent agent đọc `piagent_orchestration_policy`, giữ mặc định **solo-first**, rồi chỉ dùng subagents nếu việc đó giúp giảm nhiễu context, tăng tốc read-heavy work, hoặc tăng chất lượng review.
|
|
4
|
+
|
|
5
|
+
Kiểm tra policy hiện tại trong Pi:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
/piagent-orchestration
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Slash command này chỉ hiện status compact, không gửi follow-up cho model.
|
|
12
|
+
|
|
13
|
+
## Kết luận thực tế
|
|
14
|
+
|
|
15
|
+
Subagent không nên hiểu là “luôn tự sinh khi task lớn”. Hành vi đúng là:
|
|
16
|
+
|
|
17
|
+
1. Parent agent đánh giá task có phần việc độc lập không.
|
|
18
|
+
2. Nếu có và `pi-subagents`/subagent tool khả dụng, parent có thể tự spawn subagent.
|
|
19
|
+
3. Nếu không có tool/package, parent tiếp tục single-agent và ghi rõ `Subagents: unavailable/not used`.
|
|
20
|
+
4. User vẫn có thể gọi command trực tiếp khi muốn ép orchestration cụ thể.
|
|
21
|
+
5. Parallel read-only có thể dùng cho scout/review; parallel writers không phải default và cần approval + isolation.
|
|
22
|
+
|
|
23
|
+
Nếu bundled skill `pi-subagents` có trong skill list của parent, parent nên dùng skill đó cho orchestration patterns thay vì tự đoán syntax. Skill này là parent-only; child subagents không nhận nó.
|
|
24
|
+
|
|
25
|
+
## Policy mặc định
|
|
26
|
+
|
|
27
|
+
| Setting | Default |
|
|
28
|
+
|---|---|
|
|
29
|
+
| Mode | `solo-first` |
|
|
30
|
+
| Max concurrent subagents | `2` |
|
|
31
|
+
| Review lenses | `correctness`, `tests`, `scope` |
|
|
32
|
+
| Field Guide | `.pi/memory/MEMORY.md`, advisory, explicit-write only |
|
|
33
|
+
| Writer policy | Một writer cho một write set. |
|
|
34
|
+
|
|
35
|
+
Model role guidance:
|
|
36
|
+
|
|
37
|
+
- planner: model mạnh nhất hợp lý cho decomposition, architecture, risk, acceptance criteria;
|
|
38
|
+
- worker: model nhanh/ổn định cho bounded implementation đã có plan;
|
|
39
|
+
- reviewer: model/thinking decorrelated với worker khi review quan trọng;
|
|
40
|
+
- watchdog/oracle: model mạnh chỉ cho final risk/security/release/high-impact.
|
|
41
|
+
|
|
42
|
+
## Khi nào parent nên tự spawn
|
|
43
|
+
|
|
44
|
+
Parent nên tự spawn subagents khi có ít nhất một điều kiện:
|
|
45
|
+
|
|
46
|
+
- cần scout nhiều vùng source độc lập;
|
|
47
|
+
- cần map BE contract read-only trong khi FE implementation là write target;
|
|
48
|
+
- cần đọc external source docs/repo và repo hiện tại song song;
|
|
49
|
+
- cần external research có nguồn dẫn, và `pi-web-access`/web tools đang available;
|
|
50
|
+
- cần tạo context handoff trước task lớn (`context-builder`);
|
|
51
|
+
- cần review nhiều góc độc lập: correctness, tests, security, scope drift;
|
|
52
|
+
- task có từ 3 touchpoint trở lên;
|
|
53
|
+
- task medium/high-risk nhưng có phần audit read-only trước khi edit;
|
|
54
|
+
- context có nguy cơ phình to nếu parent tự đọc toàn bộ log/spec/source.
|
|
55
|
+
|
|
56
|
+
## Khi nào không nên tự spawn
|
|
57
|
+
|
|
58
|
+
Không spawn nếu:
|
|
59
|
+
|
|
60
|
+
- task nhỏ, một file, verify đơn giản;
|
|
61
|
+
- requirement chưa rõ và cần hỏi user trước;
|
|
62
|
+
- chỉ có một write target nhỏ;
|
|
63
|
+
- subagent tool/package chưa available;
|
|
64
|
+
- repo dirty hoặc write set có nguy cơ overlap mà chưa phân tách được;
|
|
65
|
+
- task high-risk cần human gate trước khi edit;
|
|
66
|
+
- muốn spawn nhiều writer song song nhưng không có worktree isolation/approval.
|
|
67
|
+
|
|
68
|
+
## Default agent mapping
|
|
69
|
+
|
|
70
|
+
| Need | Agent | Mode |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| Map unfamiliar repo/module/spec | `piagent-scout` | read-only |
|
|
73
|
+
| Build implementation plan | `piagent-planner` | read-only |
|
|
74
|
+
| Implement approved bounded change | `piagent-worker` | single writer |
|
|
75
|
+
| Review current diff | `piagent-reviewer` | review-first |
|
|
76
|
+
| Challenge architecture/risk | `piagent-oracle` | read-only |
|
|
77
|
+
| External docs/web research | builtin `researcher` | read-only; requires web tools |
|
|
78
|
+
| Large context handoff | builtin `context-builder` or `piagent-scout` | writes handoff artifact only |
|
|
79
|
+
|
|
80
|
+
Default rule: parallel read-only is OK; parallel writers are not default.
|
|
81
|
+
|
|
82
|
+
## Workflow policy
|
|
83
|
+
|
|
84
|
+
### `/task`
|
|
85
|
+
|
|
86
|
+
Parent should:
|
|
87
|
+
|
|
88
|
+
1. load piagent context/profile/memory/project context;
|
|
89
|
+
2. load `piagent_orchestration_policy`;
|
|
90
|
+
3. create a compact task tree/workPlan and review lenses in `piagent_task_start`;
|
|
91
|
+
4. decide whether subagents are useful enough to justify extra token cost;
|
|
92
|
+
5. if useful, spawn bounded read-only scout/planner/reviewer before or after implementation;
|
|
93
|
+
6. keep implementation single-writer unless user explicitly approves otherwise;
|
|
94
|
+
7. summarize subagent outputs into task contract/context manifest/final response.
|
|
95
|
+
|
|
96
|
+
### `/be-to-fe`
|
|
97
|
+
|
|
98
|
+
Recommended auto-delegation:
|
|
99
|
+
|
|
100
|
+
- `piagent-scout`: map backend contract read-only;
|
|
101
|
+
- `piagent-scout`: map frontend touchpoints read-only;
|
|
102
|
+
- `piagent-planner`: produce FE implementation plan;
|
|
103
|
+
- parent or `piagent-worker`: implement FE only;
|
|
104
|
+
- `piagent-reviewer`: review diff and verify coverage.
|
|
105
|
+
|
|
106
|
+
### `/platform-improve`
|
|
107
|
+
|
|
108
|
+
Recommended auto-delegation:
|
|
109
|
+
|
|
110
|
+
- `piagent-scout`: inspect current platform source/docs;
|
|
111
|
+
- builtin `researcher`: inspect official docs/web evidence when `pi-web-access` is installed;
|
|
112
|
+
- builtin `context-builder`: create handoff context/meta-prompt for large platform changes;
|
|
113
|
+
- `piagent-scout`: inspect official docs/external source repo targeted evidence;
|
|
114
|
+
- `piagent-planner`: produce implementation matrix;
|
|
115
|
+
- parent or `piagent-worker`: implement bounded changes;
|
|
116
|
+
- `piagent-reviewer`: review docs/runtime behavior.
|
|
117
|
+
|
|
118
|
+
### `/review`
|
|
119
|
+
|
|
120
|
+
Recommended auto-delegation:
|
|
121
|
+
|
|
122
|
+
- select explicit review lenses first;
|
|
123
|
+
- optional parallel `piagent-reviewer` for correctness;
|
|
124
|
+
- optional parallel `piagent-reviewer` for tests/verification;
|
|
125
|
+
- optional parallel `piagent-reviewer` for scope/protected-path drift;
|
|
126
|
+
- optional `piagent-oracle` for architecture/high-risk concerns.
|
|
127
|
+
|
|
128
|
+
If the user explicitly asks for a review loop, use `/review-loop` or an equivalent parent-controlled loop with max rounds. Do not blindly apply all reviewer suggestions.
|
|
129
|
+
|
|
130
|
+
## Prompt examples parent may use internally
|
|
131
|
+
|
|
132
|
+
Single scout:
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
Use piagent-scout to map the target module read-only. Return files, ownership, invariants, and likely change points only.
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Parallel scout:
|
|
139
|
+
|
|
140
|
+
```text
|
|
141
|
+
Run parallel piagent-scout agents: one maps backend contract read-only, one maps frontend touchpoints read-only. Wait for both and summarize the contract-to-FE map.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Parallel review:
|
|
145
|
+
|
|
146
|
+
```text
|
|
147
|
+
Run parallel piagent-reviewer agents for correctness, tests/verification, and scope/protected-path drift. Wait for all and summarize findings by severity.
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Tool syntax fallback:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
subagent({ agent: "piagent-scout", task: "Map target area read-only. Return concise findings.", context: "fresh" })
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Reporting requirement
|
|
157
|
+
|
|
158
|
+
Final response should include one line:
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
Subagents: <not used / unavailable / used: piagent-scout, piagent-reviewer>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
If not used, give the reason briefly:
|
|
165
|
+
|
|
166
|
+
- `task was tiny`;
|
|
167
|
+
- `requirements unresolved`;
|
|
168
|
+
- `subagent tool unavailable`;
|
|
169
|
+
- `write set overlap risk`;
|
|
170
|
+
- `human gate required first`.
|
|
171
|
+
|
|
172
|
+
## Token rule
|
|
173
|
+
|
|
174
|
+
Subagents can reduce parent context pollution, but total token usage can increase because each child does its own model/tool work. Use them for parallelizable read-heavy work and review quality, not as a blanket token-saving switch.
|
|
175
|
+
|
|
176
|
+
## Package shortcuts worth using
|
|
177
|
+
|
|
178
|
+
| Shortcut | Use when |
|
|
179
|
+
|---|---|
|
|
180
|
+
| `/parallel-review` | Need distinct review angles; add `autofix` only when user permits fixes. |
|
|
181
|
+
| `/review-loop` | Need worker/reviewer/fix loop until clean or capped. |
|
|
182
|
+
| `/parallel-research` | Need external evidence + local code context. |
|
|
183
|
+
| `/parallel-context-build` | Need context/meta-prompt handoff before a large plan. |
|
|
184
|
+
| `/parallel-handoff-plan` | Need research + context-builder + implementation handoff. |
|
|
185
|
+
| `/gather-context-and-clarify` | Need scout/research first, then ask only meaningful questions. |
|
|
186
|
+
| `/parallel-cleanup` | Need post-implementation cleanup review. |
|
|
187
|
+
|
|
188
|
+
See `docs/subagent-orchestration-capabilities.md`.
|
|
189
|
+
|
|
190
|
+
## Official docs
|
|
191
|
+
|
|
192
|
+
- Pi pi-subagents package: https://pi.dev/packages/pi-subagents
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Capability packs
|
|
2
|
+
|
|
3
|
+
## Tổng quan
|
|
4
|
+
|
|
5
|
+
Capability pack là đơn vị khai báo tài nguyên dùng chung của Pi Agent Platform. Pack không thực thi code từ manifest. Manifest chỉ mô tả:
|
|
6
|
+
|
|
7
|
+
- danh tính, phiên bản, owner và lifecycle;
|
|
8
|
+
- artifact được cung cấp;
|
|
9
|
+
- dependency phiên bản chính xác;
|
|
10
|
+
- capability, path, network và external action cần thiết;
|
|
11
|
+
- profile activation;
|
|
12
|
+
- eval scenario bắt buộc.
|
|
13
|
+
|
|
14
|
+
Core package chịu trách nhiệm validate, resolve và tạo bằng chứng integrity. Project profile luôn là nguồn cấp quyền cuối cùng.
|
|
15
|
+
|
|
16
|
+
## Thành phần
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
packs/<name>/
|
|
20
|
+
├─ pack.json
|
|
21
|
+
└─ recipes/
|
|
22
|
+
└─ <recipe>.json
|
|
23
|
+
|
|
24
|
+
catalog/
|
|
25
|
+
└─ capabilities.json
|
|
26
|
+
|
|
27
|
+
.pi/
|
|
28
|
+
├─ piagent-profile.json
|
|
29
|
+
└─ piagent-profile.lock.json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Thành phần | Vai trò |
|
|
33
|
+
|---|---|
|
|
34
|
+
| `pack.json` | Manifest có schema, owner, version, artifact, dependency và permission. |
|
|
35
|
+
| Capability recipe | Step graph khai báo mode, dependency, timeout, retry, output và gate. |
|
|
36
|
+
| Catalog | Index deterministic của toàn bộ pack và artifact digest. |
|
|
37
|
+
| Project profile | Chọn pack và cấp quyền owner/lifecycle/network/action. |
|
|
38
|
+
| Profile lock | Kết quả resolve có profile digest, pack digest và effective permissions. |
|
|
39
|
+
|
|
40
|
+
## Lệnh vận hành
|
|
41
|
+
|
|
42
|
+
Kiểm tra catalog hiện tại:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
piagent-capabilities catalog --check
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Tạo lại catalog sau thay đổi được phê duyệt:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
piagent-capabilities catalog --write
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Resolve profile ra stdout:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
piagent-capabilities resolve \
|
|
58
|
+
--profile adapters/generic/profile.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Tạo lock bên cạnh profile project:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
piagent-capabilities resolve \
|
|
65
|
+
--profile /path/to/project/.pi/piagent-profile.json \
|
|
66
|
+
--output /path/to/project/.pi/piagent-profile.lock.json \
|
|
67
|
+
--package-source npm:@your-scope/platform@x.y.z
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Cập nhật profile và lock theo đường fail-closed:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
piagent-capabilities apply-profile \
|
|
74
|
+
--profile adapters/generic/profile.json \
|
|
75
|
+
--target /path/to/project/.pi/piagent-profile.json \
|
|
76
|
+
--package-source git:github.com/Vt-mmm/piagent@vX.Y.Z \
|
|
77
|
+
--force
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Kiểm tra profile và lock:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
piagent-capabilities doctor \
|
|
84
|
+
--profile /path/to/project/.pi/piagent-profile.json \
|
|
85
|
+
--lock /path/to/project/.pi/piagent-profile.lock.json \
|
|
86
|
+
--package-source npm:@your-scope/platform@x.y.z
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Kiểm tra external action proposal dạng dry-run:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
piagent-capabilities validate-action --file proposal.json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`scripts/init-project.sh` tự tạo `piagent-profile.lock.json` sau khi áp dụng profile.
|
|
96
|
+
|
|
97
|
+
## Profile selection
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"capabilityPacks": [
|
|
102
|
+
{
|
|
103
|
+
"name": "engineering-base",
|
|
104
|
+
"version": "0.1.1"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"capabilityPolicy": {
|
|
108
|
+
"allowedOwners": [
|
|
109
|
+
"platform-maintainers"
|
|
110
|
+
],
|
|
111
|
+
"allowedLifecycles": [
|
|
112
|
+
"experimental"
|
|
113
|
+
],
|
|
114
|
+
"allowedFilesystemRead": [
|
|
115
|
+
"**/*"
|
|
116
|
+
],
|
|
117
|
+
"allowedFilesystemWrite": [
|
|
118
|
+
"**/*"
|
|
119
|
+
],
|
|
120
|
+
"allowedNetworkDomains": [],
|
|
121
|
+
"allowedExternalActions": []
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Pack không thể cấp thêm quyền cho chính nó:
|
|
127
|
+
|
|
128
|
+
- capability phải có trong `mcpCapabilities` của profile;
|
|
129
|
+
- owner và lifecycle phải được profile cho phép;
|
|
130
|
+
- filesystem read/write scope phải exact-match grant tương ứng của profile;
|
|
131
|
+
- built-in path-like tool và tool có định danh `fs`/`filesystem` bị giới hạn theo filesystem scope đã resolve; đường dẫn thoát khỏi repository hoặc đi qua symlink bị từ chối. Tool khác tiếp tục qua tool registry. Base-policy protected path luôn có ưu tiên deny cao hơn; shell command vẫn chịu shell protected-path và exec-policy gate;
|
|
132
|
+
- network domain phải exact-match allowlist;
|
|
133
|
+
- external action phải exact-match allowlist;
|
|
134
|
+
- task contract và runtime policy vẫn có thể thu hẹp thêm quyền.
|
|
135
|
+
|
|
136
|
+
## Security properties
|
|
137
|
+
|
|
138
|
+
### Input boundary
|
|
139
|
+
|
|
140
|
+
- Chỉ nhận JSON với field đã khai báo.
|
|
141
|
+
- Reject key nguy hiểm và nesting trên 32 cấp.
|
|
142
|
+
- Giới hạn manifest 256 KiB và artifact 2 MiB.
|
|
143
|
+
- Artifact path phải là đường dẫn tương đối trong repository.
|
|
144
|
+
- Reject absolute path, parent traversal, backslash và symlink.
|
|
145
|
+
- Protected-path matching không phân biệt hoa/thường; runtime canonicalize đường dẫn hiện hữu để chặn alias hoặc symlink trỏ vào vùng được bảo vệ.
|
|
146
|
+
|
|
147
|
+
### Integrity
|
|
148
|
+
|
|
149
|
+
- Manifest và artifact dùng SHA-256 digest.
|
|
150
|
+
- Catalog và lock dùng canonical key order.
|
|
151
|
+
- Artifact ID là duy nhất trên toàn catalog để liên kết recipe không mơ hồ.
|
|
152
|
+
- Không có timestamp trong generated contract.
|
|
153
|
+
- Doctor phát hiện catalog hoặc lock stale.
|
|
154
|
+
- Generated output dùng temporary file cùng thư mục, `fsync`, rồi atomic rename.
|
|
155
|
+
- Lock gắn với declared package-source identifier, package version, catalog và digest của các runtime enforcement file đang cài. Đây là integrity binding của runtime quan sát được, không phải chứng minh nguồn gốc cryptographic của package archive.
|
|
156
|
+
- Optional runtime package được cài bằng exact version; installer đối chiếu registry integrity với digest đã phê duyệt trước khi cài.
|
|
157
|
+
- Khi cập nhật profile, lock được ghi trước; nếu profile không thể ghi thì lock được rollback. Process interruption tạo trạng thái mismatch fail-closed thay vì áp dụng profile thiếu lock.
|
|
158
|
+
|
|
159
|
+
### Permission boundary
|
|
160
|
+
|
|
161
|
+
- Resolver chỉ chấp nhận permission là tập con của profile grant.
|
|
162
|
+
- Lock ghi lại `protectedPaths`, `shellProtectedPaths`, `readOnlyPaths` và filesystem scope do pack yêu cầu.
|
|
163
|
+
- Network và external action mặc định rỗng.
|
|
164
|
+
- Action proposal bắt buộc `riskLane=high-risk`, `dryRun=true`, `containsSecrets=false`.
|
|
165
|
+
- Proposal dùng canonical UTC timestamp, chưa hết hạn, có hiệu lực tối đa 24 giờ và không chứa raw payload hay credential.
|
|
166
|
+
- `validate-action` chỉ kiểm tra contract, thời hạn và secret indicator; không authorize action, không đối chiếu requested permission với profile/lock và không đọc artifact để xác minh digest/size.
|
|
167
|
+
- External action vẫn cần human confirmation và executor riêng trước khi có side effect.
|
|
168
|
+
|
|
169
|
+
## Lifecycle
|
|
170
|
+
|
|
171
|
+
| Trạng thái | Ý nghĩa |
|
|
172
|
+
|---|---|
|
|
173
|
+
| `experimental` | Đang pilot, profile phải opt-in rõ. |
|
|
174
|
+
| `stable` | Contract và eval đã đủ cho use case công bố. |
|
|
175
|
+
| `deprecated` | Vẫn resolve được khi profile cho phép, nhưng cần kế hoạch thay thế. |
|
|
176
|
+
|
|
177
|
+
Điều kiện promote lên `stable`:
|
|
178
|
+
|
|
179
|
+
1. Schema và doctor pass.
|
|
180
|
+
2. Không có dependency cycle hoặc permission không được cấp.
|
|
181
|
+
3. Eval scenario bắt buộc pass trên project pilot.
|
|
182
|
+
4. Security review không còn Critical/High.
|
|
183
|
+
5. Artifact contract và compatibility note đã được duyệt.
|
|
184
|
+
|
|
185
|
+
## Thêm capability pack
|
|
186
|
+
|
|
187
|
+
1. Tạo `packs/<name>/pack.json` theo `schemas/capability-pack.schema.json`.
|
|
188
|
+
2. Khai owner, exact version, lifecycle và permission tối thiểu.
|
|
189
|
+
3. Khai artifact ID duy nhất, artifact path hiện hữu; không dùng symlink.
|
|
190
|
+
4. Thêm recipe/eval nếu pack có workflow hoặc invariant riêng.
|
|
191
|
+
5. Chạy `npm test` và `npm run capabilities:catalog`.
|
|
192
|
+
6. Chạy `npm run verify` trước handoff.
|
|
193
|
+
|
|
194
|
+
## Capability source (pack ngoài platform)
|
|
195
|
+
|
|
196
|
+
Project dùng được pack không thuộc repo này mà không cần fork. Khai trong `.pi/piagent-profile.json`:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"capabilitySources": [
|
|
201
|
+
{ "name": "team", "path": ".pi/packs" },
|
|
202
|
+
{ "name": "acme", "source": "npm:@acme/piagent-packs@1.2.3" }
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Mỗi entry khai đúng một trong hai:
|
|
208
|
+
|
|
209
|
+
- `path` — thư mục nằm trong project. Không cần network, không cần publish.
|
|
210
|
+
- `source` — npm hoặc git ở version/tag/commit chính xác. Range (`^1.2.3`, `latest`, `main`) bị từ chối vì lock mất ý nghĩa nếu code đổi mà lock không đổi.
|
|
211
|
+
|
|
212
|
+
Thư mục nguồn phải chứa `packs/`, nằm trong project, và không chứa symlink.
|
|
213
|
+
|
|
214
|
+
### Vendor
|
|
215
|
+
|
|
216
|
+
`source` được fetch bằng một lệnh riêng, chạy có chủ đích:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
piagent-capabilities vendor --profile .pi/piagent-profile.json
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Lệnh này ghi vào `.pi/capability-vendor/<name>/` và in digest để review trước khi commit. Đây là chỗ duy nhất chạm network. Resolve và guard chỉ đọc thứ đã có trên đĩa, nên pack không đổi được giữa lúc review và lúc chạy. Nguồn khai mà chưa vendor thì resolve fail — không im lặng chạy với ít pack hơn profile yêu cầu.
|
|
223
|
+
|
|
224
|
+
### Vẫn deny by default
|
|
225
|
+
|
|
226
|
+
Khai source không cấp quyền gì. Pack ngoài vẫn phải qua `capabilityPolicy` như pack nội bộ: owner lạ bị từ chối chứ không phải cảnh báo, và `allowedOwners` phải liệt kê owner đó trước. Lock ghi cả `origin` và `source` của từng pack, nên pack đổi nguồn là thay thế chứ không phải update.
|
|
227
|
+
|
|
228
|
+
## Giới hạn hiện tại
|
|
229
|
+
|
|
230
|
+
- Catalog là local file, chưa có remote discovery service. Catalog chỉ chứa pack của platform; pack ngoài xuất hiện trong lock của project.
|
|
231
|
+
- Lock là preflight và integrity contract; runtime guard xác minh lại trước mỗi tool call đối với profile hiện hành. `PIAGENT_PROFILE` trusted override và legacy profile chưa khai `capabilityPacks` nằm ngoài lock gate; khi lock lỗi chỉ nhóm recovery/read-only tool giới hạn được phép hoạt động.
|
|
232
|
+
- Eval scenario mới có schema và validation; execution matrix được triển khai ở phase tiếp theo.
|
|
233
|
+
- Recipe binding nội bộ và eval scenario ID được kiểm tra trong exact dependency graph; capability binding vẫn do runtime tool registry giải quyết.
|
|
234
|
+
- External action proposal chỉ được validate; authorization, artifact byte verification và executor có credential không nằm trong phạm vi này.
|