@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,101 @@
|
|
|
1
|
+
# Package architecture notes
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Pi Agent Platform được đóng gói như một reusable Pi package để dùng cho nhiều project mà không kéo theo rule nghiệp vụ của một repo cụ thể.
|
|
6
|
+
|
|
7
|
+
## Package shape
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
packages/piagent-core/
|
|
11
|
+
├─ capabilities/
|
|
12
|
+
│ └─ capability-core.js
|
|
13
|
+
├─ extensions/
|
|
14
|
+
│ ├─ piagent-guard.ts ← extension entry point
|
|
15
|
+
│ ├─ guard-shell-analysis.ts
|
|
16
|
+
│ ├─ guard-types.ts
|
|
17
|
+
│ ├─ guard-io.js
|
|
18
|
+
│ ├─ policy-core.js
|
|
19
|
+
│ ├─ redaction-core.js
|
|
20
|
+
│ └─ runtime-evidence.js
|
|
21
|
+
├─ prompts/
|
|
22
|
+
├─ skills/
|
|
23
|
+
├─ subagents/
|
|
24
|
+
├─ policies/
|
|
25
|
+
└─ package.json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Root `package.json` expose:
|
|
29
|
+
|
|
30
|
+
- `pi.extensions`
|
|
31
|
+
- `pi.skills`
|
|
32
|
+
- `pi.prompts`
|
|
33
|
+
- `pi.subagents.agents`
|
|
34
|
+
|
|
35
|
+
`pi.extensions` names `piagent-guard.ts` explicitly instead of globbing the
|
|
36
|
+
directory. Pi loads every path the field matches and calls its default export as
|
|
37
|
+
an extension factory, so a glob would sweep in the modules the guard imports —
|
|
38
|
+
they export helpers, not a factory, and would fail to load. Anything added to
|
|
39
|
+
`extensions/` is a library module until it is named in the manifest.
|
|
40
|
+
|
|
41
|
+
Root CLI additionally exposes `piagent-capabilities` for catalog validation, profile resolution, lock verification, and dry-run action proposal validation.
|
|
42
|
+
|
|
43
|
+
## Design decisions
|
|
44
|
+
|
|
45
|
+
### 1. Prompts stay short
|
|
46
|
+
|
|
47
|
+
Workflow prompts define phase, required tools, output contract, and verification. Project-specific detail lives in `.pi/piagent-profile.json`, `.pi/project-context.md`, memory, and required context files.
|
|
48
|
+
|
|
49
|
+
### 2. Profile is the project adapter
|
|
50
|
+
|
|
51
|
+
Profiles hold protected paths, required context, verify commands, MCP capabilities, and hard gates. This keeps the core package reusable across frontend, backend, fullstack, data, DevOps, mobile, and docs projects.
|
|
52
|
+
|
|
53
|
+
### 3. Runtime state is local and auditable
|
|
54
|
+
|
|
55
|
+
Task state is stored under `.pi/piagent-state/` and also mirrored into Pi session custom entries when possible. This gives a file-based audit trail without requiring a database.
|
|
56
|
+
|
|
57
|
+
### 4. Source cache is read-only shared state
|
|
58
|
+
|
|
59
|
+
`piagent-source-cache` stores user-provided external repositories in a stable local cache. Agents read targeted files from the cache and never edit it directly.
|
|
60
|
+
|
|
61
|
+
### 5. Review guidance is project-local
|
|
62
|
+
|
|
63
|
+
`templates/project/REVIEW_GUIDELINES.md` gives each project a place to define review rules without changing the package.
|
|
64
|
+
|
|
65
|
+
### 6. Tool policy belongs in runtime
|
|
66
|
+
|
|
67
|
+
Prompt instructions are not enough for safety. The extension layer provides exec policy, tool policy, protected path checks, context budget checks, and final gates.
|
|
68
|
+
|
|
69
|
+
### 7. Benchmarking is scenario-based
|
|
70
|
+
|
|
71
|
+
Token/cost/quality improvements must be measured on repeatable project scenarios, not assumed from setup shape.
|
|
72
|
+
|
|
73
|
+
### 8. Capability selection is deterministic
|
|
74
|
+
|
|
75
|
+
Capability packs declare exact dependencies, owners, lifecycle, artifacts, permissions, activation, and eval identifiers. Project profiles grant the allowed boundary. Resolver output is stored in `piagent-profile.lock.json` with profile, pack, and artifact digests.
|
|
76
|
+
|
|
77
|
+
Manifest data never executes code. Invalid paths, symbolic links, dependency cycles, stale locks, and permission expansion fail validation.
|
|
78
|
+
|
|
79
|
+
## Adopted capabilities
|
|
80
|
+
|
|
81
|
+
| Capability | Implementation |
|
|
82
|
+
|---|---|
|
|
83
|
+
| Project onboarding | `/onboard-project` + `piagent_project_onboarding_record` |
|
|
84
|
+
| Project context index | `/context-index` + `piagent_context_index_*` |
|
|
85
|
+
| Profile switching | `/profile` + `piagent_profile_options` / `piagent_profile_apply` |
|
|
86
|
+
| Explicit memory | `/memory-policy` + `piagent_memory_*` |
|
|
87
|
+
| Task lifecycle | `/task` + task/context/verify/trace tools |
|
|
88
|
+
| Platform workflow | `/platform-improve` |
|
|
89
|
+
| Backend-readonly to frontend | `/be-to-fe` |
|
|
90
|
+
| Source cache | `piagent-source-cache` + `piagent_source_checkout` |
|
|
91
|
+
| Subagent roles | `piagent-scout`, `piagent-planner`, `piagent-worker`, `piagent-reviewer`, `piagent-oracle` |
|
|
92
|
+
| Quality benchmark | `scripts/quality-benchmark.sh` |
|
|
93
|
+
| Capability catalog | `packs/*/pack.json` + `catalog/capabilities.json` |
|
|
94
|
+
| Capability resolver | `capability-core.js` + `piagent-capabilities` |
|
|
95
|
+
|
|
96
|
+
## Deferred capabilities
|
|
97
|
+
|
|
98
|
+
- Hard final assistant hook if Pi exposes a stable extension hook.
|
|
99
|
+
- Project-specific worktree policy for parallel writer agents.
|
|
100
|
+
- Optional stronger sandbox layer for strict enterprise environments.
|
|
101
|
+
- Rich TUI dashboard for long-running usage and benchmark summaries.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Project adapters
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Adapter mô tả project cho Pi core. Core không biết domain/project cụ thể trừ khi profile khai báo.
|
|
6
|
+
|
|
7
|
+
## Profile schema hiện tại
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"schemaVersion": 1,
|
|
12
|
+
"projectId": "my-project",
|
|
13
|
+
"displayName": "My Project",
|
|
14
|
+
"mode": "web-frontend",
|
|
15
|
+
"permissionProfile": "workspace-write",
|
|
16
|
+
"rootMarkers": ["AGENTS.md", "package.json"],
|
|
17
|
+
"protectedPaths": [".git/**", "**/auth.json"],
|
|
18
|
+
"shellProtectedPaths": [".git/**", "**/auth.json"],
|
|
19
|
+
"readOnlyPaths": ["backend/**"],
|
|
20
|
+
"requiredContext": ["AGENTS.md", "docs/architecture.md"],
|
|
21
|
+
"taskModes": {
|
|
22
|
+
"readOnly": { "tools": ["read", "grep", "find", "ls"] },
|
|
23
|
+
"sourceWrite": { "requiresPlan": true, "requiresVerify": true }
|
|
24
|
+
},
|
|
25
|
+
"verifyCommands": {
|
|
26
|
+
"docsOnly": ["test -s README.md"],
|
|
27
|
+
"source": ["npm test"]
|
|
28
|
+
},
|
|
29
|
+
"mcpCapabilities": [
|
|
30
|
+
"filesystem-readonly",
|
|
31
|
+
"filesystem-write",
|
|
32
|
+
"shell",
|
|
33
|
+
"github",
|
|
34
|
+
"memory"
|
|
35
|
+
],
|
|
36
|
+
"techStack": {
|
|
37
|
+
"provider": "context7",
|
|
38
|
+
"manifest": ".pi/tech-stack.json",
|
|
39
|
+
"contextDir": ".pi/tech-context",
|
|
40
|
+
"roles": {
|
|
41
|
+
"frontend": ["nextjs"],
|
|
42
|
+
"backend": ["nestjs"],
|
|
43
|
+
"database": ["prisma"]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"contextIndex": {
|
|
47
|
+
"enabled": true,
|
|
48
|
+
"path": ".pi/context-index.json",
|
|
49
|
+
"writePolicy": "onboarding-record",
|
|
50
|
+
"requireCitations": true,
|
|
51
|
+
"maxNodes": 120,
|
|
52
|
+
"maxEdges": 240,
|
|
53
|
+
"includeTechStack": true,
|
|
54
|
+
"includeMemoryPointers": true
|
|
55
|
+
},
|
|
56
|
+
"runtimePolicy": {
|
|
57
|
+
"execPolicy": "enforce",
|
|
58
|
+
"contextBudget": "enforce",
|
|
59
|
+
"toolRegistry": "advisory",
|
|
60
|
+
"finalGate": "enforce"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Path policy fields have distinct meanings:
|
|
66
|
+
|
|
67
|
+
- `protectedPaths`: block read/write path-tool access and protect these paths from shell parsing when `shellProtectedPaths` is omitted.
|
|
68
|
+
- `readOnlyPaths`: allow `read`/`grep`/`find`/`ls`, but block `write`/`edit` and shell access.
|
|
69
|
+
- `shellProtectedPaths`: block shell access only. Do not rely on this field to block write/edit; `profile-doctor` and `team-doctor` warn when a path is present only here.
|
|
70
|
+
|
|
71
|
+
## Built-in adapters
|
|
72
|
+
|
|
73
|
+
| Profile | Dùng cho | Verify mặc định |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `generic` | Repo chưa có chuẩn riêng | README check hoặc message yêu cầu cấu hình verify |
|
|
76
|
+
| `web-frontend` | Next/React/Vite frontend | type-check, lint, test, e2e nếu project khai báo |
|
|
77
|
+
| `backend-api` | Node/Java/Python API | npm/maven/gradle/pytest tùy marker |
|
|
78
|
+
| `be-readonly-fe` | BE là source of truth nhưng chỉ scout/read-only; FE là write target | FE type-check/lint/test/e2e theo layout phổ biến |
|
|
79
|
+
| `fullstack` | Repo có FE + BE/monorepo | type-check, lint, test, e2e nếu có |
|
|
80
|
+
| `node-typescript` | Node/TS library/tooling | npm type-check/lint/test nếu có |
|
|
81
|
+
| `python` | Python app/library | `uv run pytest` |
|
|
82
|
+
| `data` | ETL/dbt/DVC/notebook/data pipeline | pytest hoặc dbt compile nếu có |
|
|
83
|
+
| `devops` | Docker/Terraform/K8s/GitHub Actions | diff check, compose/terraform validate nếu tool có |
|
|
84
|
+
| `mobile` | React Native/Flutter | npm test / flutter test nếu tool có |
|
|
85
|
+
| `docs` | Docs portal/manual | markdown diff check + test nếu project có |
|
|
86
|
+
|
|
87
|
+
## Runtime profile selection
|
|
88
|
+
|
|
89
|
+
Default UX không bắt buộc chạy bash để set profile. Sau global install, vào project chạy:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
/onboard-project
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Nếu chưa có `.pi/piagent-profile.json`, onboarding nên dùng select-style setup: chọn profile trước, rồi chọn tech theo role. Native command là:
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
/profile setup
|
|
99
|
+
/profile tech setup fullstack
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Nếu Pi host chưa expose select UI, command trả về card compact và lệnh deterministic, ví dụ:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
/profile tech apply fullstack frontend=nextjs backend=nestjs database=prisma
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Kết quả ghi:
|
|
109
|
+
|
|
110
|
+
- `.pi/piagent-profile.json`;
|
|
111
|
+
- `.pi/piagent-profile.lock.json`;
|
|
112
|
+
- `.pi/tech-stack.json`;
|
|
113
|
+
- `.pi/tech-context/<tech>.json` placeholder.
|
|
114
|
+
|
|
115
|
+
Sau khi agent đọc Context7 cho tech tương ứng, chỉ record snapshot ngắn bằng `piagent_profile_tech_context_record`; không lưu nguyên văn docs dài.
|
|
116
|
+
|
|
117
|
+
`/onboard-project` cũng tạo `.pi/context-index.json`. Đây là advisory node/edge/citation map cho profile, tech, verify command, docs, risk và memory pointer; không dùng thay thế source hiện tại hoặc guard policy.
|
|
118
|
+
|
|
119
|
+
Đổi profile sau này:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
/profile list
|
|
123
|
+
/profile be-readonly-fe
|
|
124
|
+
/profile tech setup
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Auto detect trong shell script
|
|
128
|
+
|
|
129
|
+
`scripts/init-project.sh` và `scripts/setup.sh` vẫn hỗ trợ `--profile auto` cho case preseed/CI. Logic detect dựa trên marker:
|
|
130
|
+
|
|
131
|
+
- mobile: `pubspec.yaml`, hoặc `android/` + `ios/`;
|
|
132
|
+
- fullstack: package frontend + backend marker cùng tồn tại;
|
|
133
|
+
- frontend: Next/React/Vite/Vue/Svelte/Astro marker;
|
|
134
|
+
- backend: Nest/Express/Fastify/Hono/Prisma, Java Maven/Gradle, hoặc FastAPI/Flask/Django;
|
|
135
|
+
- data: dbt/DVC/notebooks/data marker;
|
|
136
|
+
- python: `pyproject.toml`;
|
|
137
|
+
- node-typescript: `package.json` + `tsconfig.json`;
|
|
138
|
+
- devops: Docker/compose/Terraform/K8s/Helm/GitHub Actions;
|
|
139
|
+
- docs: docs portal markers;
|
|
140
|
+
- fallback: `generic`.
|
|
141
|
+
|
|
142
|
+
Auto detect là bootstrap convenience, không phải policy cuối cùng. Sau init, `.pi/piagent-profile.json` là source of truth của project.
|
|
143
|
+
|
|
144
|
+
Mọi built-in adapter đều đưa `.pi/project-context.md` vào `requiredContext`. File này được tạo dạng placeholder khi init project, rồi được model thay bằng snapshot thật sau `/onboard-project`.
|
|
145
|
+
|
|
146
|
+
## Khi nào cần custom profile
|
|
147
|
+
|
|
148
|
+
Custom profile khi project có ít nhất một điểm sau:
|
|
149
|
+
|
|
150
|
+
- verify command riêng;
|
|
151
|
+
- protected path riêng;
|
|
152
|
+
- context bắt buộc riêng;
|
|
153
|
+
- tool/MCP capability riêng;
|
|
154
|
+
- runtime policy riêng;
|
|
155
|
+
- rule domain hoặc compliance riêng.
|
|
156
|
+
|
|
157
|
+
Không sửa core extension chỉ để phục vụ một repo. Sửa `.pi/piagent-profile.json` của repo đó trước.
|
|
158
|
+
|
|
159
|
+
## Adapter BE readonly → FE write
|
|
160
|
+
|
|
161
|
+
Dùng `adapters/be-readonly-fe/profile.json` khi task pattern là:
|
|
162
|
+
|
|
163
|
+
- đọc BE controller/DTO/schema/test để map contract;
|
|
164
|
+
- không được sửa backend;
|
|
165
|
+
- chỉ implement frontend;
|
|
166
|
+
- nếu BE thiếu/gãy contract thì report gap.
|
|
167
|
+
|
|
168
|
+
Không để `auto` tự chọn adapter này vì BE read-only là policy decision, không phải marker kỹ thuật.
|
|
169
|
+
|
|
170
|
+
## Project-specific profiles
|
|
171
|
+
|
|
172
|
+
Project-specific profiles should live in the target project repository, not in this public core repo.
|
|
173
|
+
|
|
174
|
+
Use `examples/private/` locally if a maintainer needs private examples; that path is ignored by git.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Project onboarding snapshot
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Lần đầu gắn một project vào Pi Agent Platform, không nên nhảy thẳng vào `/task`.
|
|
6
|
+
|
|
7
|
+
Luồng chuẩn là:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
cd /path/to/project
|
|
11
|
+
pi
|
|
12
|
+
/login
|
|
13
|
+
<select provider/model>
|
|
14
|
+
/onboard-project
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Sau khi `/onboard-project` chạy xong, project có file:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
.pi/piagent-profile.json
|
|
21
|
+
.pi/piagent-profile.lock.json
|
|
22
|
+
.pi/tech-stack.json
|
|
23
|
+
.pi/tech-context/*.json
|
|
24
|
+
.pi/project-context.md
|
|
25
|
+
.pi/context-index.json
|
|
26
|
+
.pi/memory/memory_summary.md
|
|
27
|
+
.pi/memory/MEMORY.md
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`/onboard-project` là nơi profile và tech stack được chọn. Ưu tiên select-style flow:
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
/profile setup
|
|
34
|
+
/profile tech setup fullstack
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Nếu Pi host chưa có native select, command trả card compact và lệnh deterministic, ví dụ `/profile tech apply fullstack frontend=nextjs backend=nestjs database=prisma`. Không dùng model để giải thích dài từng lựa chọn trong daily UX.
|
|
38
|
+
|
|
39
|
+
`.pi/project-context.md` là context snapshot để task sau không phải scout lại toàn bộ repo từ đầu.
|
|
40
|
+
|
|
41
|
+
`.pi/context-index.json` là compact advisory index dạng node/edge/citation cho profile, tech stack, verify command, docs, risk, memory pointer và task handoff đã được duyệt. Nó giúp agent tìm đúng điểm vào repo nhanh hơn, nhưng không phải source of truth hoặc security boundary.
|
|
42
|
+
|
|
43
|
+
Context index là Pi runtime state. Không đọc/ghi raw file này trong workflow thường ngày; dùng `/context-index`, `piagent_context_index_status`, `piagent_context_index_search`, `/onboard-project` hoặc `piagent_context_index_record` để runtime có thể kiểm soát path và sanitize dữ liệu advisory trước khi đưa vào model.
|
|
44
|
+
|
|
45
|
+
Memory markdown là local/private mặc định và bị ignore bởi `.pi/.gitignore`. Chỉ commit memory nếu team quyết định opt-in sau khi review/redact.
|
|
46
|
+
|
|
47
|
+
`.pi/memory/` là durable memory thủ công để giữ preference/decision/lesson ổn định giữa các session. Nó không thay thế snapshot hoặc source hiện tại.
|
|
48
|
+
|
|
49
|
+
## Vì sao không để bash làm bước này
|
|
50
|
+
|
|
51
|
+
Bash setup chỉ biết tạo template và detect marker. Nó không có model reasoning, không biết project purpose, module ownership, domain rule, hay risk boundary.
|
|
52
|
+
|
|
53
|
+
`/onboard-project` phải chạy sau login/model selection để chính model sẽ dùng cho task đọc qua project, chọn/gợi ý profile, và tạo snapshot.
|
|
54
|
+
|
|
55
|
+
## Profile selection
|
|
56
|
+
|
|
57
|
+
Xem hoặc đổi profile trong Pi:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
/profile list
|
|
61
|
+
/profile setup
|
|
62
|
+
/profile tech setup
|
|
63
|
+
/profile fullstack
|
|
64
|
+
/profile be-readonly-fe
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Khác biệt quan trọng:
|
|
68
|
+
|
|
69
|
+
- `fullstack`: FE và BE đều có thể được sửa nếu task cho phép.
|
|
70
|
+
- `be-readonly-fe`: BE chỉ scout/read-only; FE là write target.
|
|
71
|
+
- `web-frontend`: chỉ FE.
|
|
72
|
+
- `backend-api`: chỉ BE.
|
|
73
|
+
- `generic`: baseline an toàn khi chưa rõ repo.
|
|
74
|
+
|
|
75
|
+
## Phạm vi model cần đọc
|
|
76
|
+
|
|
77
|
+
Không đọc toàn bộ source. Đọc theo lớp:
|
|
78
|
+
|
|
79
|
+
1. `.pi/piagent-profile.json`
|
|
80
|
+
2. `AGENTS.md`
|
|
81
|
+
3. `.pi/project-context.md` hiện tại
|
|
82
|
+
4. `.pi/context-index.json` nếu đã được generate
|
|
83
|
+
5. `.pi/memory/memory_summary.md` nếu đã có và liên quan
|
|
84
|
+
6. `README.md`
|
|
85
|
+
7. package/build/runtime config
|
|
86
|
+
8. docs/architecture/spec nếu có
|
|
87
|
+
9. source directory map
|
|
88
|
+
10. test/verify command definitions
|
|
89
|
+
11. API/schema/migration markers nếu có
|
|
90
|
+
|
|
91
|
+
Mục tiêu là hiểu cấu trúc và policy, không nhồi full repo vào context.
|
|
92
|
+
|
|
93
|
+
## Artifact bắt buộc
|
|
94
|
+
|
|
95
|
+
`.pi/project-context.md` nên có:
|
|
96
|
+
|
|
97
|
+
- project purpose;
|
|
98
|
+
- stack/runtime/package manager;
|
|
99
|
+
- repository map;
|
|
100
|
+
- source-of-truth docs;
|
|
101
|
+
- domain/architecture notes;
|
|
102
|
+
- verification matrix;
|
|
103
|
+
- protected/high-risk areas;
|
|
104
|
+
- MCP/tool policy;
|
|
105
|
+
- memory policy;
|
|
106
|
+
- update triggers.
|
|
107
|
+
|
|
108
|
+
`piagent_project_onboarding_record` sẽ tự ghi thêm `.pi/context-index.json` khi tool có sẵn. Nếu cần kiểm tra nhanh, dùng:
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
/context-index
|
|
112
|
+
/context-index search <keyword>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Khi nào regenerate
|
|
116
|
+
|
|
117
|
+
Chạy lại:
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
/onboard-project
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
khi có thay đổi lớn:
|
|
124
|
+
|
|
125
|
+
- source layout đổi;
|
|
126
|
+
- framework/runtime đổi;
|
|
127
|
+
- verify command đổi;
|
|
128
|
+
- API/schema/migration/auth/provider policy đổi;
|
|
129
|
+
- project ownership hoặc domain rule đổi.
|
|
130
|
+
|
|
131
|
+
## Relationship với `/task`
|
|
132
|
+
|
|
133
|
+
`/task` sẽ yêu cầu đọc `.pi/project-context.md`. Nếu file còn trạng thái `Generated: not yet`, agent phải dừng và yêu cầu chạy `/onboard-project` trước.
|
|
134
|
+
|
|
135
|
+
Đây là điểm khác với CLI thuần: context bootstrap trở thành một bước có artifact có thể review và tái dùng. `.pi/project-context.md` và `.pi/context-index.json` có thể commit cho team sau khi review; memory markdown thì private-by-default.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Publish cho team dùng
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Team khác có thể cài cùng một Pi platform mà không lấy secret của maintainer.
|
|
6
|
+
|
|
7
|
+
## Cách phát hành
|
|
8
|
+
|
|
9
|
+
### Git repo
|
|
10
|
+
|
|
11
|
+
Dùng tag hoặc reviewed commit cho team/repo cần reproducible lock:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pi install git:github.com/Vt-mmm/piagent@vX.Y.Z
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Pin tag hoặc commit cho `.pi/settings.json` đã commit vào project. Luồng cài host, terminal helper, Pi package, update và rollback canonical nằm tại [release/install policy](release-install-policy.md).
|
|
18
|
+
|
|
19
|
+
Moving latest chỉ dành cho máy cá nhân hoặc sandbox chấp nhận thay đổi không đồng bộ:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pi install git:github.com/Vt-mmm/piagent
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### npm private package
|
|
26
|
+
|
|
27
|
+
Dùng khi muốn version/publish chuẩn:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pi install npm:@your-scope/platform@x.y.z
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Local path
|
|
34
|
+
|
|
35
|
+
Dùng khi dev platform trên một máy, không commit source này vào project team:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pi install /path/to/piagent
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Versioning
|
|
42
|
+
|
|
43
|
+
- `0.1.x`: local/internal pilot.
|
|
44
|
+
- `0.2.x`: có guard ổn định và docs team.
|
|
45
|
+
- `1.0.0`: đủ security review, MCP registry, adapter schema versioned.
|
|
46
|
+
|
|
47
|
+
## Không publish
|
|
48
|
+
|
|
49
|
+
- `auth.json`
|
|
50
|
+
- `.env`
|
|
51
|
+
- session files
|
|
52
|
+
- private token
|
|
53
|
+
- project data dump
|
|
54
|
+
|
|
55
|
+
## Team onboarding
|
|
56
|
+
|
|
57
|
+
1. Install exact Pi host version declared by the target release.
|
|
58
|
+
2. Install the pinned terminal helper and matching Pi package.
|
|
59
|
+
3. Login OAuth provider.
|
|
60
|
+
4. Run `pi` in the target project.
|
|
61
|
+
5. Run `/onboard-project`.
|
|
62
|
+
6. Choose/apply a profile inside Pi.
|
|
63
|
+
|
|
64
|
+
Chi tiết: `docs/team-onboarding.md` và `docs/distribution-standard.md`.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Quality benchmark guide
|
|
2
|
+
|
|
3
|
+
## Vì sao cần benchmark
|
|
4
|
+
|
|
5
|
+
Không nên claim tiết kiệm token/cost hoặc tăng chất lượng nếu chưa có số liệu theo cùng scenario. Token giảm khi:
|
|
6
|
+
|
|
7
|
+
- project context đã được onboard;
|
|
8
|
+
- profile giới hạn đúng scope;
|
|
9
|
+
- memory explicit giảm scout lặp;
|
|
10
|
+
- source cache giúp đọc targeted;
|
|
11
|
+
- task gate bắt verify/trace;
|
|
12
|
+
- tool policy chặn vòng lặp sai.
|
|
13
|
+
|
|
14
|
+
Benchmark là bằng chứng để chọn agent surface, model, profile, và workflow preset cho từng loại task.
|
|
15
|
+
|
|
16
|
+
## Ba scenario mặc định
|
|
17
|
+
|
|
18
|
+
Khởi tạo:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bash scripts/quality-benchmark.sh /path/to/project --init
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Script tạo:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
.pi/benchmarks/quality-scenarios.md
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Scenario mặc định:
|
|
31
|
+
|
|
32
|
+
1. `read-only-scout`
|
|
33
|
+
2. `bounded-source-fix`
|
|
34
|
+
3. `be-readonly-to-fe`
|
|
35
|
+
|
|
36
|
+
## Ghi một lần chạy
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bash scripts/quality-benchmark.sh /path/to/project --record \
|
|
40
|
+
--scenario read-only-scout \
|
|
41
|
+
--surface pi \
|
|
42
|
+
--result pass \
|
|
43
|
+
--tokens 8200 \
|
|
44
|
+
--duration 540 \
|
|
45
|
+
--notes "good plan, no edits"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Output:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
.pi/benchmarks/quality-runs.jsonl
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Tiêu chí so sánh
|
|
55
|
+
|
|
56
|
+
| Metric | Ý nghĩa |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `result` | `pass`, `fail`, hoặc `partial` theo verify và acceptance criteria. |
|
|
59
|
+
| `surface` | Agent surface/workflow/model preset được dùng cho run. |
|
|
60
|
+
| `tokens` | Tổng token do runtime/provider báo. |
|
|
61
|
+
| `cost` | Cost nếu provider báo được. |
|
|
62
|
+
| `durationSeconds` | Thời gian wall-clock. |
|
|
63
|
+
| `notes` | Số lần sửa lại, missing context, wrong file, verify failure, hoặc quality observation. |
|
|
64
|
+
|
|
65
|
+
## Quy tắc claim
|
|
66
|
+
|
|
67
|
+
Chỉ claim một setup tốt hơn khi:
|
|
68
|
+
|
|
69
|
+
- cùng task/spec;
|
|
70
|
+
- cùng repo state;
|
|
71
|
+
- cùng verify command;
|
|
72
|
+
- ít nhất 3 lần chạy hoặc 3 scenario khác nhau;
|
|
73
|
+
- pass rate không thấp hơn setup hiện tại;
|
|
74
|
+
- token/cost giảm mà không tăng manual rework.
|