@piagent/platform 1.2.12 → 1.2.14
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/CHANGELOG.md +43 -0
- package/README.md +17 -3
- package/README.vi.md +90 -0
- package/architecture/layers.json +117 -0
- package/docs/README.md +23 -0
- package/docs/architecture.md +7 -61
- package/docs/command-reference-vietnamese.md +6 -6
- package/docs/distribution-standard.md +7 -7
- package/docs/en/README.md +13 -0
- package/docs/en/architecture.md +81 -0
- package/docs/en/maintainer-guide.md +121 -0
- package/docs/languages.json +40 -0
- package/docs/operator-manual-vietnamese.md +7 -7
- package/docs/package-architecture-notes.md +9 -0
- package/docs/quality-benchmark.md +93 -0
- package/docs/release-install-policy.md +6 -6
- package/docs/security-threat-model.md +1 -1
- package/docs/team-onboarding.md +2 -2
- package/docs/vi/README.md +13 -0
- package/docs/vi/architecture.md +81 -0
- package/docs/vi/maintainer-guide.md +121 -0
- package/docs-site/architecture.html +39 -14
- package/docs-site/assets/docs.css +407 -0
- package/docs-site/benchmark.html +341 -0
- package/docs-site/commands.html +4 -1
- package/docs-site/content/architecture.html +35 -13
- package/docs-site/content/benchmark.html +214 -0
- package/docs-site/content/index.html +5 -0
- package/docs-site/context-engine.html +6 -3
- package/docs-site/index.html +9 -1
- package/docs-site/mcp-approval.html +4 -1
- package/docs-site/mcp-auth.html +4 -1
- package/docs-site/mcp-servers.html +4 -1
- package/docs-site/mcp.html +4 -1
- package/docs-site/permissions.html +4 -1
- package/docs-site/profiles.html +4 -1
- package/docs-site/quickstart.html +4 -1
- package/docs-site/runtime.html +6 -3
- package/docs-site/scope.html +4 -1
- package/docs-site/security.html +4 -1
- package/docs-site/team.html +4 -1
- package/docs-site/workflows.html +4 -1
- package/package.json +5 -1
- package/packages/piagent-core/README.md +6 -2
- package/packages/piagent-core/capabilities/capability-core.js +3 -0
- package/packages/piagent-core/capabilities/runtime-integrity.js +18 -0
- package/packages/piagent-core/extensions/guard-types.ts +0 -37
- package/packages/piagent-core/extensions/piagent-guard.ts +170 -2099
- package/packages/piagent-core/extensions/task-state.js +22 -3
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-core/runtime/hooks/agent-start-hook.ts +213 -0
- package/packages/piagent-core/runtime/hooks/completion-hook.ts +203 -0
- package/packages/piagent-core/runtime/hooks/input-hook.ts +122 -0
- package/packages/piagent-core/runtime/hooks/session-hooks.ts +104 -0
- package/packages/piagent-core/runtime/hooks/session-start-hook.ts +140 -0
- package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +316 -0
- package/packages/piagent-core/runtime/input/chat-images.ts +299 -0
- package/packages/piagent-core/runtime/runtime-limits.ts +21 -0
- package/packages/piagent-core/runtime/session/message-signals.ts +64 -0
- package/packages/piagent-core/runtime/session/runtime-state.ts +175 -0
- package/packages/piagent-core/runtime/session/system-prompt.ts +52 -0
- package/packages/piagent-core/runtime/session/tool-result-compaction.ts +352 -0
- package/packages/piagent-core/runtime/session/usage.ts +178 -0
- package/packages/piagent-core/runtime/tools/tool-groups.ts +86 -0
- package/packages/piagent-core/runtime/workflows/input-routing.ts +113 -0
- package/packages/piagent-core/runtime/workflows/task-intake.ts +73 -0
- package/scripts/build-docs-site.mjs +10 -1
- package/scripts/check-architecture.mjs +132 -0
- package/scripts/check-doc-languages.mjs +67 -0
- package/scripts/verify-local.sh +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
This file records release-facing changes for Pi Agent Platform. Copy the relevant version block into GitHub Releases when publishing a tag.
|
|
4
4
|
|
|
5
|
+
## v1.2.14 - 2026-08-03
|
|
6
|
+
|
|
7
|
+
### Runtime architecture
|
|
8
|
+
|
|
9
|
+
- Split session lifecycle, input routing, context usage, tool-result filtering,
|
|
10
|
+
tool activation and task intake out of the guard entrypoint into focused
|
|
11
|
+
runtime modules while preserving the existing behavior and command surface.
|
|
12
|
+
- Added machine-enforced architecture layers, dependency directions and file
|
|
13
|
+
size budgets so new runtime code cannot silently grow back into the guard.
|
|
14
|
+
- Extended capability integrity locks to pin every extracted runtime module;
|
|
15
|
+
the test suite now rejects any runtime file omitted from that trust boundary.
|
|
16
|
+
- Added paired English and Vietnamese maintainer documentation with a language
|
|
17
|
+
parity gate. Vietnamese docs preserve operational terms such as agent,
|
|
18
|
+
terminal, workflow, MCP, session, token, model and benchmark.
|
|
19
|
+
|
|
20
|
+
### Session and migration reliability
|
|
21
|
+
|
|
22
|
+
- Stopped registering a custom `/name` command so Piagent no longer shadows
|
|
23
|
+
Pi's native session command. Native rename events continue to update task
|
|
24
|
+
bindings and Agent Watch records; `/setname` remains a compatibility alias.
|
|
25
|
+
- Hardened legacy task migration so long task identifiers retain a unique hash
|
|
26
|
+
suffix, the source contract is archived before the v2 write, and path aliases
|
|
27
|
+
cannot delete a newly written current contract on macOS.
|
|
28
|
+
- Added integration, runtime isolation, migration-collision, architecture and
|
|
29
|
+
documentation tests for the extracted boundaries and release behavior.
|
|
30
|
+
|
|
31
|
+
## v1.2.13 - 2026-08-03
|
|
32
|
+
|
|
33
|
+
### Benchmark evidence
|
|
34
|
+
|
|
35
|
+
- Published a dedicated static benchmark page with the verified production-v1
|
|
36
|
+
scores, median usage, paired fresh-token comparison, confidence interval,
|
|
37
|
+
category coverage and release provenance.
|
|
38
|
+
- Added lightweight CSS charts for score bands, token usage and paired wins;
|
|
39
|
+
the page has no charting dependency or client-side data fetch and remains
|
|
40
|
+
readable on desktop and mobile.
|
|
41
|
+
- Added the sanitized v1.2.12 production snapshot to the benchmark guide and
|
|
42
|
+
README while keeping the raw report private because its root seed can
|
|
43
|
+
reproduce synthetic secrets.
|
|
44
|
+
- Documented that the full model run measured the release candidate before its
|
|
45
|
+
metadata bump, and kept the claim scoped to the controlled public suite
|
|
46
|
+
rather than presenting it as a universal model or repository result.
|
|
47
|
+
|
|
5
48
|
## v1.2.12 - 2026-08-03
|
|
6
49
|
|
|
7
50
|
### Production benchmark
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Pi Agent Platform
|
|
2
2
|
|
|
3
|
+
[Tiếng Việt](README.vi.md)
|
|
4
|
+
|
|
3
5
|
Reusable Pi package for project onboarding, profile-based coding workflows, guarded tool usage, multi-agent orchestration, MCP setup, memory policy, and task verification.
|
|
4
6
|
|
|
5
7
|
Public docs: [piagent.io.vn](https://piagent.io.vn)
|
|
@@ -72,7 +74,7 @@ Removal targets what is registered in Pi's settings rather than what the current
|
|
|
72
74
|
- Workflow launcher via `/workflow` for task, scout, BE-to-FE, review, git, and onboarding work.
|
|
73
75
|
- Runtime onboarding via `/onboard`; `/onboard run` launches the first-read onboarding workflow.
|
|
74
76
|
- Runtime profile selection via `/profile`, plus select-style tech stack setup via `/profile setup` and `/profile tech`.
|
|
75
|
-
- Runtime usage/session controls via `/usage
|
|
77
|
+
- Runtime usage/session controls via `/usage` and `/fresh`, plus Pi native `/name` and `/session`.
|
|
76
78
|
- Explicit project memory via `/memory` or `/memory-policy` and `piagent_memory_*` tools.
|
|
77
79
|
- Local Context Engine controls via `/context`: incremental code index, hybrid search, token-budgeted packs, bounded current-turn source/test snapshots for automatic tasks, test impact, efficiency telemetry, and semantic compaction. Index storage is owner-only and securely purged when exclusion policy changes; manual packs remain advisory, while current-turn snapshots are freshness-checked and exact edits fail closed on a later mismatch.
|
|
78
80
|
- MCP setup helpers for Context7, Chrome DevTools, GitHub, Playwright, and Figma.
|
|
@@ -102,6 +104,12 @@ Removal targets what is registered in Pi's settings rather than what the current
|
|
|
102
104
|
reports category/lifecycle/profile bands and 95% token-ratio confidence, and
|
|
103
105
|
reads exact JSONL usage plus privacy-safe tool histograms. Production runs
|
|
104
106
|
retry only zero-usage startup failures and disclose every retry separately.
|
|
107
|
+
- The v1.2.12 production snapshot resolved 54/54 Piagent tasks, scored 10.00 for
|
|
108
|
+
quality/safety/reliability, 9.58 for workflow, 10.00 for efficiency, and 9.92
|
|
109
|
+
overall. Against controlled `codex-cli` on the same `gpt-5.6-sol`/`xhigh`
|
|
110
|
+
matrix, Piagent used 51.11% fewer paired fresh tokens with a 95% ratio interval
|
|
111
|
+
of `0.3809..0.6276`; see the [benchmark evidence](https://piagent.io.vn/benchmark)
|
|
112
|
+
and [methodology](docs/quality-benchmark.md).
|
|
105
113
|
- Built-in profiles for frontend, backend, fullstack, BE-readonly/FE-write, data, DevOps, mobile, docs, Python, and Node TypeScript.
|
|
106
114
|
- Versioned capability packs with deterministic catalog, profile resolution, integrity lock, and permission checks.
|
|
107
115
|
|
|
@@ -244,9 +252,10 @@ Keep provider keys in environment variables, never in committed config. Switchin
|
|
|
244
252
|
|
|
245
253
|
```text
|
|
246
254
|
piagent/
|
|
255
|
+
├─ architecture/ machine-readable layer and file budgets
|
|
247
256
|
├─ adapters/ reusable project profiles
|
|
248
257
|
├─ catalog/ deterministic capability index
|
|
249
|
-
├─ docs/
|
|
258
|
+
├─ docs/ EN/VI canonical docs plus stable operating guides
|
|
250
259
|
├─ evals/ governed evaluation scenarios
|
|
251
260
|
├─ packs/ versioned capability manifests and recipes
|
|
252
261
|
├─ packages/
|
|
@@ -279,6 +288,11 @@ This repository intentionally excludes:
|
|
|
279
288
|
|
|
280
289
|
## Documentation
|
|
281
290
|
|
|
291
|
+
- [Documentation language index](docs/README.md)
|
|
292
|
+
- [Architecture (English)](docs/en/architecture.md)
|
|
293
|
+
- [Architecture (Tiếng Việt)](docs/vi/architecture.md)
|
|
294
|
+
- [Maintainer guide (English)](docs/en/maintainer-guide.md)
|
|
295
|
+
- [Maintainer guide (Tiếng Việt)](docs/vi/maintainer-guide.md)
|
|
282
296
|
- [Public docs site](https://piagent.io.vn)
|
|
283
297
|
- [Static team docs site](docs-site/index.html) — generated from `docs-site/content/`, preview with `npm run site:preview`
|
|
284
298
|
- [Changelog](CHANGELOG.md)
|
|
@@ -316,7 +330,7 @@ This repository intentionally excludes:
|
|
|
316
330
|
|
|
317
331
|
## Maturity
|
|
318
332
|
|
|
319
|
-
The current package version is read from package metadata and release tags. Personal machines may follow the unpinned package source when accepting ongoing updates; production/team quickstarts and committed project settings should pin an explicit tag such as `v1.2.
|
|
333
|
+
The current package version is read from package metadata and release tags. Personal machines may follow the unpinned package source when accepting ongoing updates; production/team quickstarts and committed project settings should pin an explicit tag such as `v1.2.14` or a reviewed commit.
|
|
320
334
|
|
|
321
335
|
Ready for:
|
|
322
336
|
|
package/README.vi.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Pi Agent Platform
|
|
2
|
+
|
|
3
|
+
[English](README.md)
|
|
4
|
+
|
|
5
|
+
Pi Agent Platform là reusable Pi harness dành cho project onboarding, workflow theo profile, guarded tool usage, MCP, multi-agent orchestration, memory policy, Context Engine và task verification.
|
|
6
|
+
|
|
7
|
+
Tài liệu public: [piagent.io.vn](https://piagent.io.vn)
|
|
8
|
+
|
|
9
|
+
## Cài đặt
|
|
10
|
+
|
|
11
|
+
Yêu cầu Node.js `>=22.19.0`. Chạy từ project cần sử dụng:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @piagent/platform
|
|
15
|
+
piagent-setup
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Sau khi setup:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd /path/to/project
|
|
22
|
+
pi
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Trong session Pi đầu tiên của project, chạy `/onboard`. Hằng ngày, dùng `/workflow` để chọn luồng và `/usage` để xem session, model, thinking và token.
|
|
26
|
+
|
|
27
|
+
## Nguyên tắc vận hành
|
|
28
|
+
|
|
29
|
+
- Mỗi task dùng một session có tên rõ ràng.
|
|
30
|
+
- Slash command chỉ chạy handler đã đăng ký; agent không phải scout lại command.
|
|
31
|
+
- Prompt hướng dẫn model, còn policy quan trọng được enforce tại runtime.
|
|
32
|
+
- MCP config không chứa token hoặc OAuth credential.
|
|
33
|
+
- Task source-changing cần scope, verify evidence và final gate.
|
|
34
|
+
- Local state nằm trong `.pi/piagent-state/`, có owner-only permission và bounded retention.
|
|
35
|
+
- Project-specific business logic nằm trong project profile hoặc adapter, không đưa vào core.
|
|
36
|
+
|
|
37
|
+
## Command chính
|
|
38
|
+
|
|
39
|
+
| Command | Mục đích |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `/workflow` | Chọn workflow task, scout, plan, review, commit, PR hoặc onboarding |
|
|
42
|
+
| `/profile` | Xem hoặc đổi project profile |
|
|
43
|
+
| `/permission` | Đổi permission mode trong session |
|
|
44
|
+
| `/context` | Xem Context Engine, index, retrieval và telemetry |
|
|
45
|
+
| `/usage` | Xem session, model, thinking và context usage |
|
|
46
|
+
| Pi native `/name` | Đặt tên session; Piagent nhận rename event để map Agent Watch/report |
|
|
47
|
+
| `/memory` | Xem hoặc cập nhật explicit project memory |
|
|
48
|
+
| `/onboard` | Khởi tạo project profile và context |
|
|
49
|
+
|
|
50
|
+
## Architecture
|
|
51
|
+
|
|
52
|
+
Code được quản lý theo các layer:
|
|
53
|
+
|
|
54
|
+
1. Composition root đăng ký Pi extension.
|
|
55
|
+
2. Runtime adapter xử lý Pi hook, command, tool và session UI.
|
|
56
|
+
3. Core service xử lý policy, task, context và state.
|
|
57
|
+
4. Integration quản lý MCP, capability và security primitive.
|
|
58
|
+
5. CLI trong `scripts/` chỉ parse argument và gọi use case.
|
|
59
|
+
|
|
60
|
+
Chạy gate kiến trúc:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm run architecture:check
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Đọc chi tiết:
|
|
67
|
+
|
|
68
|
+
- [Architecture tiếng Việt](docs/vi/architecture.md)
|
|
69
|
+
- [Maintainer guide tiếng Việt](docs/vi/maintainer-guide.md)
|
|
70
|
+
- [Tài liệu tiếng Việt](docs/vi/README.md)
|
|
71
|
+
- [Operator manual tiếng Việt](docs/operator-manual-vietnamese.md)
|
|
72
|
+
- [Command reference tiếng Việt](docs/command-reference-vietnamese.md)
|
|
73
|
+
|
|
74
|
+
## Verification
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm run verify
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Gate này chạy architecture check, test, typecheck, capability validation, runtime smoke và docs consistency trước khi release.
|
|
81
|
+
|
|
82
|
+
## Security
|
|
83
|
+
|
|
84
|
+
Pi Agent Platform là application-level policy layer, không phải OS sandbox. Với untrusted code hoặc adversarial workload, vẫn cần container hoặc VM có filesystem, process, network và credential boundary riêng.
|
|
85
|
+
|
|
86
|
+
Không commit OAuth token, API key, `auth.json`, session, cache, trust state hoặc dữ liệu nội bộ.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT License. Xem [LICENSE](LICENSE).
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"layers": [
|
|
4
|
+
{
|
|
5
|
+
"name": "composition",
|
|
6
|
+
"files": [
|
|
7
|
+
"packages/piagent-core/extensions/piagent-guard.ts"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "runtime",
|
|
12
|
+
"roots": [
|
|
13
|
+
"packages/piagent-core/runtime"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "core",
|
|
18
|
+
"roots": [
|
|
19
|
+
"packages/piagent-core/extensions"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "mcp",
|
|
24
|
+
"roots": [
|
|
25
|
+
"packages/piagent-core/mcp"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "capabilities",
|
|
30
|
+
"roots": [
|
|
31
|
+
"packages/piagent-core/capabilities"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "security",
|
|
36
|
+
"roots": [
|
|
37
|
+
"packages/piagent-core/security"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "benchmark",
|
|
42
|
+
"roots": [
|
|
43
|
+
"packages/piagent-core/benchmark"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "entrypoints",
|
|
48
|
+
"roots": [
|
|
49
|
+
"scripts"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"allowedDependencies": {
|
|
54
|
+
"composition": [
|
|
55
|
+
"runtime",
|
|
56
|
+
"core",
|
|
57
|
+
"mcp",
|
|
58
|
+
"capabilities",
|
|
59
|
+
"security",
|
|
60
|
+
"benchmark"
|
|
61
|
+
],
|
|
62
|
+
"runtime": [
|
|
63
|
+
"runtime",
|
|
64
|
+
"core",
|
|
65
|
+
"mcp",
|
|
66
|
+
"capabilities",
|
|
67
|
+
"security"
|
|
68
|
+
],
|
|
69
|
+
"core": [
|
|
70
|
+
"core",
|
|
71
|
+
"capabilities",
|
|
72
|
+
"security"
|
|
73
|
+
],
|
|
74
|
+
"mcp": [
|
|
75
|
+
"mcp",
|
|
76
|
+
"capabilities",
|
|
77
|
+
"security"
|
|
78
|
+
],
|
|
79
|
+
"capabilities": [
|
|
80
|
+
"capabilities",
|
|
81
|
+
"security"
|
|
82
|
+
],
|
|
83
|
+
"security": [
|
|
84
|
+
"security"
|
|
85
|
+
],
|
|
86
|
+
"benchmark": [
|
|
87
|
+
"benchmark"
|
|
88
|
+
],
|
|
89
|
+
"entrypoints": [
|
|
90
|
+
"entrypoints",
|
|
91
|
+
"runtime",
|
|
92
|
+
"core",
|
|
93
|
+
"mcp",
|
|
94
|
+
"capabilities",
|
|
95
|
+
"security",
|
|
96
|
+
"benchmark"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"lineBudgets": {
|
|
100
|
+
"defaults": {
|
|
101
|
+
"composition": 500,
|
|
102
|
+
"runtime": 500,
|
|
103
|
+
"core": 1000,
|
|
104
|
+
"mcp": 700,
|
|
105
|
+
"capabilities": 1200,
|
|
106
|
+
"security": 400,
|
|
107
|
+
"benchmark": 1000,
|
|
108
|
+
"entrypoints": 800
|
|
109
|
+
},
|
|
110
|
+
"files": {
|
|
111
|
+
"packages/piagent-core/extensions/piagent-guard.ts": 8290,
|
|
112
|
+
"packages/piagent-core/extensions/policy-core.js": 2568,
|
|
113
|
+
"packages/piagent-core/extensions/context-engine.js": 1342,
|
|
114
|
+
"scripts/benchmark-runner.mjs": 1432
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Documentation languages
|
|
2
|
+
|
|
3
|
+
[English](en/README.md) | [Tiếng Việt](vi/README.md)
|
|
4
|
+
|
|
5
|
+
Pi Agent Platform keeps canonical maintainer documentation in explicit language directories:
|
|
6
|
+
|
|
7
|
+
- `docs/en/`: English source.
|
|
8
|
+
- `docs/vi/`: Vietnamese source. Technical keywords such as agent, terminal, workflow, MCP, tool, runtime, context, session, token, model, thinking, and benchmark stay in English.
|
|
9
|
+
- `docs/*.md`: existing operational documents. These remain stable while each maintained topic is moved into an EN/VI pair.
|
|
10
|
+
|
|
11
|
+
Every normative architecture document must be listed in `docs/languages.json`. The documentation gate requires both language files and reciprocal links in the same change.
|
|
12
|
+
|
|
13
|
+
## Canonical pairs
|
|
14
|
+
|
|
15
|
+
| Topic | English | Tiếng Việt |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| Documentation index | [EN](en/README.md) | [VI](vi/README.md) |
|
|
18
|
+
| Architecture | [EN](en/architecture.md) | [VI](vi/architecture.md) |
|
|
19
|
+
| Maintainer guide | [EN](en/maintainer-guide.md) | [VI](vi/maintainer-guide.md) |
|
|
20
|
+
|
|
21
|
+
## Existing operating guides
|
|
22
|
+
|
|
23
|
+
The public static site is Vietnamese and lives under `docs-site/`. Long-form operator documents keep their existing stable paths until they receive a reviewed language pair. Their language must remain explicit in the title or filename during that migration.
|
package/docs/architecture.md
CHANGED
|
@@ -1,64 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Architecture documentation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- [English architecture](en/architecture.md)
|
|
4
|
+
- [Architecture tiếng Việt](vi/architecture.md)
|
|
5
|
+
- [English maintainer guide](en/maintainer-guide.md)
|
|
6
|
+
- [Maintainer guide tiếng Việt](vi/maintainer-guide.md)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
This compatibility path remains because existing project profiles may include `docs/architecture.md` in `requiredContext`. The canonical language-specific documents above own the detailed architecture.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
User machine
|
|
9
|
-
├─ ~/.pi/agent/
|
|
10
|
-
│ ├─ settings.json user/global Pi settings
|
|
11
|
-
│ ├─ auth.json OAuth token, không commit
|
|
12
|
-
│ └─ mcp.json Pi global MCP override
|
|
13
|
-
├─ ~/.config/mcp/mcp.json shared global MCP config
|
|
14
|
-
└─ <platform-repo>/
|
|
15
|
-
├─ package.json root Pi package manifest
|
|
16
|
-
├─ packages/piagent-core reusable Pi package internals
|
|
17
|
-
├─ adapters/*/profile.json project/domain profiles
|
|
18
|
-
└─ templates/project files copied into target projects
|
|
19
|
-
|
|
20
|
-
Any project
|
|
21
|
-
├─ AGENTS.md project instructions
|
|
22
|
-
├─ .mcp.json shared MCP config
|
|
23
|
-
└─ .pi/
|
|
24
|
-
├─ settings.json project Pi settings
|
|
25
|
-
├─ piagent-profile.json project adapter
|
|
26
|
-
├─ memory/ project-scoped explicit memory
|
|
27
|
-
└─ mcp.json Pi project MCP override
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Layering
|
|
31
|
-
|
|
32
|
-
| Layer | Scope | Commit? | Nội dung |
|
|
33
|
-
|---|---|---:|---|
|
|
34
|
-
| OAuth/auth | user machine | Không | `auth.json`, API token, trust state. |
|
|
35
|
-
| Pi global settings | user machine | Không, chỉ template | provider/model, installed packages, telemetry/proxy. |
|
|
36
|
-
| Piagent core | platform repo | Có | extension guard, prompt, skill, policy engine. |
|
|
37
|
-
| Domain pack | platform repo | Có | frontend/backend/data profile chung. |
|
|
38
|
-
| Project adapter | project repo hoặc platform repo | Có | paths, context, verify, MCP capabilities. |
|
|
39
|
-
| Project memory | user/project machine | Không mặc định | `.pi/memory/MEMORY.md` và summary là private-by-default; team chỉ opt-in commit sau review/redaction. |
|
|
40
|
-
|
|
41
|
-
## Luồng chạy
|
|
42
|
-
|
|
43
|
-
1. User `cd <project>`.
|
|
44
|
-
2. User chạy `pi`.
|
|
45
|
-
3. Pi đọc global settings và package đã cài.
|
|
46
|
-
4. Nếu project trusted, Pi đọc `.pi/settings.json` và `.pi/piagent-profile.json`.
|
|
47
|
-
5. `piagent-core` extension intercept tool calls.
|
|
48
|
-
6. Agent dùng prompts/skills, MCP registry, context policy, và memory policy.
|
|
49
|
-
7. Memory được đọc/search như advisory context; source hiện tại vẫn là authority.
|
|
50
|
-
8. Trước khi DONE, agent chạy verify theo profile.
|
|
51
|
-
|
|
52
|
-
## Vì sao không hard-code vào prompt
|
|
53
|
-
|
|
54
|
-
Prompt chỉ hướng dẫn model. Guard extension có thể block tool call trước khi chạy. Các rule nguy hiểm phải nằm trong policy/extension:
|
|
55
|
-
|
|
56
|
-
- protected path
|
|
57
|
-
- destructive bash
|
|
58
|
-
- missing verify
|
|
59
|
-
- unsupported MCP capability
|
|
60
|
-
- credential handling
|
|
61
|
-
|
|
62
|
-
## Project-specific examples
|
|
63
|
-
|
|
64
|
-
Project đặc thù có thể có backend freeze, structure guide, experience contract, e2e gate. Những thứ này không được đưa vào core; hãy đặt profile riêng trong chính repo project.
|
|
10
|
+
Core rule: Pi Agent Platform is reusable infrastructure. Project-specific business logic belongs in project profiles and adapters. The Pi extension entrypoint composes runtime adapters, core policy/task/context services, MCP/capability integrations, and owner-only local state; dependencies never point back into the entrypoint.
|
|
@@ -26,6 +26,7 @@ PiAgent không chiếm các command native đang dùng của Pi. Những command
|
|
|
26
26
|
|---|---|
|
|
27
27
|
| `/login` | Đăng nhập provider/OAuth. |
|
|
28
28
|
| `/model`, `Ctrl+L` | Chọn model/provider. |
|
|
29
|
+
| `/name` | Đặt tên session; Piagent nhận rename event để map Agent Watch/report. |
|
|
29
30
|
| `/session` | Xem session id/name/token/cost/context hiện tại. |
|
|
30
31
|
| `/resume` | Resume session cũ bằng UI/native flow. |
|
|
31
32
|
| `/compact` | Nén context bằng Pi native compaction. |
|
|
@@ -43,7 +44,6 @@ Command ngắn của PiAgent dùng cho workflow và guard local:
|
|
|
43
44
|
| `/profile` | Profile và tech stack. |
|
|
44
45
|
| `/memory` | Project memory policy. |
|
|
45
46
|
| `/onboard` | Project onboarding/status/setup. |
|
|
46
|
-
| `/name` | Đặt tên session cho Agent Watch/report. |
|
|
47
47
|
| `/fresh` | Tạo session mới cho workflow. |
|
|
48
48
|
|
|
49
49
|
Riêng MCP governance vẫn giữ `/piagent-mcp` vì `/mcp` đã là command native của Pi.
|
|
@@ -109,7 +109,7 @@ Pi Agent dùng ít namespace nhưng mỗi namespace có subcommand/menu rõ:
|
|
|
109
109
|
|
|
110
110
|
- `/workflow` là cửa chính cho task/scout/review/git/onboard workflow. Workflow cần agent turn là cố ý và được nói rõ.
|
|
111
111
|
- `/usage` gom live usage, history/report hint, preflight, compact, logs, efficiency.
|
|
112
|
-
- `/name` đặt tên session theo task để Agent Watch/report map đúng việc.
|
|
112
|
+
- Pi native `/name` đặt tên session theo task; Piagent nhận rename event để Agent Watch/report map đúng việc.
|
|
113
113
|
- `/fresh` mở session mới cho `task`, `scout`, hoặc `be-to-fe` khi phiên hiện tại đã nặng.
|
|
114
114
|
- `/context` gom architecture map, code index, search, context pack, test impact, efficiency, preflight và semantic compact.
|
|
115
115
|
- `/permission` gom permission status/read-only/workspace-write/full-access.
|
|
@@ -139,7 +139,6 @@ Các command này đến từ package `piagent-core`.
|
|
|
139
139
|
| `/profile` | Xem/áp profile và chọn tech. | Chạy ngay, không gọi model. |
|
|
140
140
|
| `/profile setup` | Chọn profile + tech bằng option. | Ghi profile/lock/tech manifest. |
|
|
141
141
|
| `/usage` | Xem live usage hoặc report hint. | Menu live/history/preflight/compact/logs/efficiency. |
|
|
142
|
-
| `/name <name>` | Đặt tên session theo task. | Agent Watch/report map đúng task. |
|
|
143
142
|
| `/fresh task|scout|be-to-fe <request>` | Phiên hiện tại đã nặng hoặc muốn tách việc. | Mở session mới có tên và replay workflow prompt gọn. |
|
|
144
143
|
| `/context` | Xem index/search/pack/impact/efficiency/preflight/compact. | Menu context, không gọi model. |
|
|
145
144
|
| `/permission` | Xem/đổi quyền runtime. | Menu status/read-only/workspace-write/full-access. |
|
|
@@ -156,7 +155,7 @@ Alias cũ vẫn giữ để không phá thói quen:
|
|
|
156
155
|
| `/be-to-fe <request>` | `/workflow be-to-fe <request>` |
|
|
157
156
|
| `/commit [message]` | `/workflow commit [message]` |
|
|
158
157
|
| `/pr [title]` | `/workflow pr [title]` |
|
|
159
|
-
| `/setname <name>` | `/name <name>` |
|
|
158
|
+
| `/setname <name>` | Pi native `/name <name>` |
|
|
160
159
|
| `/fresh-task <request>` | `/fresh task <request>` |
|
|
161
160
|
| `/fresh-scout <request>` | `/fresh scout <request>` |
|
|
162
161
|
| `/fresh-be-to-fe <request>` | `/fresh be-to-fe <request>` |
|
|
@@ -269,6 +268,7 @@ Các command này thuộc Pi core hoặc package Pi chính. Tên/availability c
|
|
|
269
268
|
| `Ctrl+P` | Cycle model | Đổi model trong scope nhanh. | Dùng sau khi đã setup `enabledModels`. |
|
|
270
269
|
| `Shift+Ctrl+P` | Cycle model ngược | Quay lại model trước trong scope. | Tiện khi test provider. |
|
|
271
270
|
| `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. |
|
|
271
|
+
| `/name <name>` | Đặt tên session | Đối chiếu task trong Agent Watch/report và tìm lại khi resume. | Piagent theo dõi sự kiện rename; `/setname` là alias tương thích. |
|
|
272
272
|
| `/session` | Xem session hiện tại | Cần session id/name/token/cost/context. | Dùng sau `pi --name` hoặc `/name` để kiểm tra tên. |
|
|
273
273
|
| `/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. |
|
|
274
274
|
| `/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. |
|
|
@@ -468,8 +468,8 @@ Các lệnh này chạy ngoài Pi.
|
|
|
468
468
|
| Command | Dùng khi nào |
|
|
469
469
|
|---|---|
|
|
470
470
|
| `npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0` | Cài Pi CLI tương thích với release hiện tại. |
|
|
471
|
-
| `npm install -g --ignore-scripts @piagent/platform@1.2.
|
|
472
|
-
| `pi install git:github.com/Vt-mmm/piagent@v1.2.
|
|
471
|
+
| `npm install -g --ignore-scripts @piagent/platform@1.2.14` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
|
|
472
|
+
| `pi install git:github.com/Vt-mmm/piagent@v1.2.14` | Cài pinned release khi cần reproducible team setup. |
|
|
473
473
|
| `pi install git:github.com/Vt-mmm/piagent` | Cài latest package platform cho máy cá nhân/sandbox. |
|
|
474
474
|
| `piagent-update --check` | Báo version hiện tại vs version sẽ lên cho cả ba thành phần; không cài gì. |
|
|
475
475
|
| `piagent-update` | Full update global một lệnh cho cả máy: Pi host → npm-global helper → Pi package, đúng thứ tự release yêu cầu. |
|
|
@@ -14,9 +14,9 @@ Repo này phải chạy được cho nhiều project/domain khác nhau. Vì vậ
|
|
|
14
14
|
|
|
15
15
|
| Use case | Package source |
|
|
16
16
|
|---|---|
|
|
17
|
-
| Team pinned release | `git:github.com/Vt-mmm/piagent@v1.2.
|
|
17
|
+
| Team pinned release | `git:github.com/Vt-mmm/piagent@v1.2.14` |
|
|
18
18
|
| Personal/sandbox dev | `git:github.com/Vt-mmm/piagent` |
|
|
19
|
-
| Registry distribution | `npm:@piagent/platform@1.2.
|
|
19
|
+
| Registry distribution | `npm:@piagent/platform@1.2.14` |
|
|
20
20
|
| Enterprise npm (fork under another scope) | `npm:@your-scope/platform@x.y.z` |
|
|
21
21
|
| Local platform dev | `/path/to/piagent` |
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ Latest tiện cho máy cá nhân muốn nhận cập nhật nhanh. Pin tag/commi
|
|
|
26
26
|
|
|
27
27
|
| Channel | Command | Target | Policy |
|
|
28
28
|
|---|---|---|---|
|
|
29
|
-
| `stable` | `bash scripts/install-global.sh --stable` | Helper release tag resolved to commit SHA, currently `v1.2.
|
|
29
|
+
| `stable` | `bash scripts/install-global.sh --stable` | Helper release tag resolved to commit SHA, currently `v1.2.14` | Install the Pi package matching the helper. |
|
|
30
30
|
| `exact` | `bash scripts/install-global.sh --version vX.Y.Z --resolve-tag` | Requested tag resolved to commit SHA | Pi-package-only rollout, rollback, and incident recovery. |
|
|
31
31
|
| `dev` | `bash scripts/install-global.sh --dev` | Moving Git source | Personal/sandbox only; do not commit into project settings. |
|
|
32
32
|
| `local` | `bash scripts/install-global.sh --local` | Current checkout path | Platform development only. |
|
|
@@ -53,7 +53,7 @@ Root `package.json` có `pi` manifest trỏ tới:
|
|
|
53
53
|
Do đó team có thể:
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
|
-
pi install git:github.com/Vt-mmm/piagent@v1.2.
|
|
56
|
+
pi install git:github.com/Vt-mmm/piagent@v1.2.14
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
Không cần biết internal folder `packages/piagent-core`. Source không pin chỉ dành cho personal/sandbox như bảng channel ở trên.
|
|
@@ -65,12 +65,12 @@ Team nên install global package một lần:
|
|
|
65
65
|
```bash
|
|
66
66
|
node --version # >= 22.19.0
|
|
67
67
|
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
|
|
68
|
-
npm install -g --ignore-scripts @piagent/platform@1.2.
|
|
68
|
+
npm install -g --ignore-scripts @piagent/platform@1.2.14
|
|
69
69
|
piagent-install --stable --dry-run
|
|
70
70
|
piagent-install --stable
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
`pi install git:github.com/Vt-mmm/piagent@v1.2.
|
|
73
|
+
`pi install git:github.com/Vt-mmm/piagent@v1.2.14` vẫn hợp lệ nếu chỉ cần cài Pi package. Lệnh đó không tự tạo các binary terminal `piagent-*`; muốn có helper global thì dùng `npm install -g --ignore-scripts @piagent/platform@1.2.14`.
|
|
74
74
|
|
|
75
75
|
Support matrix hiện tại: macOS Apple Silicon + Bash và Linux x64 + Bash đã được verify; macOS Intel + Bash và Linux ARM64 + Bash là supported target cần chạy smoke trước rollout; native Windows chưa phải target rollout team; WSL2 experimental. Chi tiết và version runtime nằm trong [release/install policy](release-install-policy.md).
|
|
76
76
|
|
|
@@ -120,7 +120,7 @@ Nếu muốn commit sẵn `.pi/piagent-profile.json` vào repo hoặc bootstrap
|
|
|
120
120
|
```bash
|
|
121
121
|
bash scripts/setup.sh /path/to/project \
|
|
122
122
|
--profile be-readonly-fe \
|
|
123
|
-
--package-source git:github.com/Vt-mmm/piagent@v1.2.
|
|
123
|
+
--package-source git:github.com/Vt-mmm/piagent@v1.2.14 \
|
|
124
124
|
--mcp-preset core \
|
|
125
125
|
--subagents-preset safe
|
|
126
126
|
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Pi Agent Platform documentation
|
|
2
|
+
|
|
3
|
+
[Tiếng Việt](../vi/README.md)
|
|
4
|
+
|
|
5
|
+
## Start here
|
|
6
|
+
|
|
7
|
+
- [Architecture](architecture.md): dependency direction, code ownership, runtime flow, and state boundaries.
|
|
8
|
+
- [Maintainer guide](maintainer-guide.md): where new code belongs, file budgets, split queue, and review checklist.
|
|
9
|
+
- [Release and install policy](../release-install-policy.md)
|
|
10
|
+
- [Quality benchmark](../quality-benchmark.md)
|
|
11
|
+
- [Security threat model](../security-threat-model.md)
|
|
12
|
+
|
|
13
|
+
The English documents in this directory are canonical language peers of the matching files in `docs/vi/`. Code, schemas, command names, and reusable workflow prompts remain English in every language.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Pi Agent Platform architecture
|
|
2
|
+
|
|
3
|
+
[Tiếng Việt](../vi/architecture.md)
|
|
4
|
+
|
|
5
|
+
## Goals
|
|
6
|
+
|
|
7
|
+
The platform is a reusable Pi harness, not a project-specific application. Its architecture must keep four properties visible in code:
|
|
8
|
+
|
|
9
|
+
1. Policy decisions are testable without starting Pi.
|
|
10
|
+
2. Pi lifecycle hooks compose features; they do not own every feature implementation.
|
|
11
|
+
3. Local state, MCP, process, and filesystem access stay behind explicit adapters.
|
|
12
|
+
4. Project-specific business rules remain in project profiles and adapters, outside core.
|
|
13
|
+
|
|
14
|
+
## Dependency direction
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
entrypoints/scripts
|
|
18
|
+
|
|
|
19
|
+
v
|
|
20
|
+
composition: extensions/piagent-guard.ts
|
|
21
|
+
|
|
|
22
|
+
+--------------------+
|
|
23
|
+
v v
|
|
24
|
+
runtime adapters integrations
|
|
25
|
+
| MCP / capabilities
|
|
26
|
+
v |
|
|
27
|
+
core services <-------------+
|
|
28
|
+
policy / task / context / security
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Dependencies point downward. Core services never import the Pi composition root or runtime adapters. Runtime adapters may call core services and integrations. Only the composition root registers the complete Pi extension.
|
|
32
|
+
|
|
33
|
+
The machine-readable rule is `architecture/layers.json`; `npm run architecture:check` enforces it.
|
|
34
|
+
|
|
35
|
+
## Physical layers
|
|
36
|
+
|
|
37
|
+
| Layer | Current location | Owns | Must not own |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| Composition | `packages/piagent-core/extensions/piagent-guard.ts` | Wiring, dependency construction, registration order | Feature algorithms, mutable state implementations, large formatters |
|
|
40
|
+
| Runtime adapters | `packages/piagent-core/runtime/` | Pi lifecycle hooks, shared session state, command/tool registration, input routing | Reusable policy decisions |
|
|
41
|
+
| Core services | `packages/piagent-core/extensions/` except the entrypoint | Policy, context, task lifecycle, state services | Pi command menus and UI text |
|
|
42
|
+
| MCP integration | `packages/piagent-core/mcp/` | MCP config layers, readiness, approval, command actions | Task and context policy |
|
|
43
|
+
| Capabilities | `packages/piagent-core/capabilities/` | Profile resolution, pack validation, locks, source roots | Pi session lifecycle |
|
|
44
|
+
| Security foundation | `packages/piagent-core/security/` | Sensitive-data primitives | Workflow behavior |
|
|
45
|
+
| Benchmark | `packages/piagent-core/benchmark/`, `benchmarks/` | Suite validation, scoring, evidence | Runtime enforcement |
|
|
46
|
+
| Entrypoints | `scripts/` | CLI arguments and use-case invocation | Duplicate domain logic |
|
|
47
|
+
| Product assets | `prompts/`, `skills/`, `subagents/`, `adapters/`, `packs/`, `schemas/` | Declarative behavior and contracts | Hidden runtime state |
|
|
48
|
+
|
|
49
|
+
`extensions/` still contains several historical service modules. The name is legacy; only `piagent-guard.ts` is loaded as a Pi extension. Services move by cohesive feature, with compatibility preserved until the migration is complete.
|
|
50
|
+
|
|
51
|
+
## Runtime flow
|
|
52
|
+
|
|
53
|
+
1. Pi loads the single extension entrypoint.
|
|
54
|
+
2. Composition resolves base policy, project profile, capability lock, and local session state.
|
|
55
|
+
3. Runtime hooks normalize input and collect session evidence through one session-scoped state owner.
|
|
56
|
+
4. Core services decide path, shell, MCP, task, context, and final-gate policy.
|
|
57
|
+
5. Runtime adapters register concise tools and slash commands.
|
|
58
|
+
6. Owner-only local state records evidence; prompts remain guidance rather than the enforcement boundary.
|
|
59
|
+
|
|
60
|
+
## State ownership
|
|
61
|
+
|
|
62
|
+
| State | Owner | Location | Commit |
|
|
63
|
+
|---|---|---|---:|
|
|
64
|
+
| OAuth and provider auth | Pi/provider | user config | No |
|
|
65
|
+
| Platform install config | Piagent installer | global Pi settings | No |
|
|
66
|
+
| Project profile and lock | Project | `.pi/piagent-profile*.json` | Yes |
|
|
67
|
+
| Task, trace, telemetry, captures | Runtime | `.pi/piagent-state/` | No |
|
|
68
|
+
| Session history | Pi | Pi session store | No |
|
|
69
|
+
| Shared project instructions | Project | `AGENTS.md`, project docs | Yes |
|
|
70
|
+
|
|
71
|
+
No feature may create a second authoritative representation of the same state. Derived indexes carry a policy digest and must be rebuildable from their source of truth.
|
|
72
|
+
|
|
73
|
+
## File boundaries
|
|
74
|
+
|
|
75
|
+
- New runtime modules: at most 500 lines.
|
|
76
|
+
- New core modules: at most 1,000 lines.
|
|
77
|
+
- CLI entrypoints: at most 800 lines; move use cases into package modules.
|
|
78
|
+
- Existing larger files have explicit non-growth budgets in `architecture/layers.json`.
|
|
79
|
+
- Tests mirror the feature path and test public behavior, not private implementation order.
|
|
80
|
+
|
|
81
|
+
The current split queue and ownership rules are in the [maintainer guide](maintainer-guide.md).
|