@piagent/platform 1.1.9 → 1.2.1

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +175 -1
  2. package/README.md +2 -2
  3. package/docs/command-reference-vietnamese.md +19 -5
  4. package/docs/distribution-standard.md +7 -7
  5. package/docs/mcp-and-tools.md +154 -2
  6. package/docs/model-options.md +10 -8
  7. package/docs/operator-manual-vietnamese.md +25 -13
  8. package/docs/publishing-for-teams.md +2 -0
  9. package/docs/quickstart-vietnamese.md +2 -2
  10. package/docs/release-install-policy.md +6 -6
  11. package/docs/security-threat-model.md +4 -3
  12. package/docs/team-onboarding.md +4 -4
  13. package/docs/usage-observability.md +29 -0
  14. package/docs/vercel-docs-site.md +34 -4
  15. package/docs-site/architecture.html +152 -0
  16. package/docs-site/assets/docs.css +1001 -0
  17. package/docs-site/assets/docs.js +84 -0
  18. package/docs-site/commands.html +203 -0
  19. package/docs-site/content/architecture.html +29 -0
  20. package/docs-site/content/commands.html +80 -0
  21. package/docs-site/content/index.html +80 -0
  22. package/docs-site/content/mcp-approval.html +133 -0
  23. package/docs-site/content/mcp-auth.html +76 -0
  24. package/docs-site/content/mcp-servers.html +111 -0
  25. package/docs-site/content/mcp.html +120 -0
  26. package/docs-site/content/permissions.html +54 -0
  27. package/docs-site/content/profiles.html +68 -0
  28. package/docs-site/content/quickstart.html +144 -0
  29. package/docs-site/content/runtime.html +45 -0
  30. package/docs-site/content/scope.html +71 -0
  31. package/docs-site/content/security.html +51 -0
  32. package/docs-site/content/team.html +23 -0
  33. package/docs-site/content/workflows.html +47 -0
  34. package/docs-site/index.html +131 -1534
  35. package/docs-site/mcp-approval.html +256 -0
  36. package/docs-site/mcp-auth.html +199 -0
  37. package/docs-site/mcp-servers.html +234 -0
  38. package/docs-site/mcp.html +243 -0
  39. package/docs-site/permissions.html +177 -0
  40. package/docs-site/profiles.html +191 -0
  41. package/docs-site/quickstart.html +267 -0
  42. package/docs-site/runtime.html +168 -0
  43. package/docs-site/scope.html +194 -0
  44. package/docs-site/security.html +174 -0
  45. package/docs-site/team.html +142 -0
  46. package/docs-site/workflows.html +170 -0
  47. package/package.json +4 -2
  48. package/packages/piagent-core/capabilities/capability-core.js +58 -5
  49. package/packages/piagent-core/capabilities/capability-sources.js +73 -12
  50. package/packages/piagent-core/extensions/document-intake.ts +5 -5
  51. package/packages/piagent-core/extensions/piagent-guard.ts +432 -2
  52. package/packages/piagent-core/extensions/policy-core.js +1586 -98
  53. package/packages/piagent-core/mcp/mcp-approval-store.js +216 -0
  54. package/packages/piagent-core/mcp/mcp-auth-readiness.js +225 -0
  55. package/packages/piagent-core/mcp/mcp-command-actions.js +400 -0
  56. package/packages/piagent-core/mcp/mcp-config-layers.js +466 -0
  57. package/packages/piagent-core/mcp/mcp-import-kinds.js +240 -0
  58. package/packages/piagent-core/mcp/mcp-server-catalog.js +150 -0
  59. package/packages/piagent-core/mcp/mcp-server-entry.js +293 -0
  60. package/packages/piagent-core/mcp/mcp-session-view.js +236 -0
  61. package/packages/piagent-core/mcp/mcp-tool-naming.js +90 -0
  62. package/packages/piagent-core/package.json +7 -3
  63. package/packages/piagent-core/prompts/model-options.md +8 -8
  64. package/scripts/build-docs-site.mjs +421 -0
  65. package/scripts/configure-model-scope.sh +21 -5
  66. package/scripts/configure-subagents.sh +18 -5
  67. package/scripts/init-project.sh +15 -8
  68. package/scripts/install-global.sh +5 -5
  69. package/scripts/mcp-manage.mjs +656 -0
  70. package/scripts/pi-model-catalog.sh +11 -1
  71. package/scripts/pi-session-stats.sh +27 -1
  72. package/scripts/pi-usage-history.mjs +567 -0
  73. package/scripts/piagent-cli.mjs +1 -1
  74. package/scripts/preview-docs-site.mjs +88 -0
  75. package/scripts/quality-benchmark.sh +37 -9
  76. package/scripts/setup.sh +23 -15
  77. package/scripts/team-doctor.sh +18 -2
  78. package/scripts/uninstall-global.sh +10 -4
  79. package/scripts/verify-local.sh +65 -19
  80. package/scripts/verify-release-identity.mjs +37 -2
  81. package/scripts/configure-mcp.sh +0 -349
@@ -1,6 +1,8 @@
1
1
  # Model selector and scope
2
2
 
3
- Pi Agent Platform không khóa vào một provider. OpenAI Codex và Claude/Anthropic đều là first-class option.
3
+ Pi Agent Platform không khóa vào một provider. Hai họ model dưới đây đều là first-class option: **model OpenAI Codex** (provider id `openai-codex`) và **model Claude của Anthropic** (provider id `anthropic`).
4
+
5
+ Lưu ý cách đọc: trong toàn bộ tài liệu này, "Codex" và "Claude" là **tên họ model** đứng sau các provider id ở trên. Chúng không phải tên CLI, và cũng không phải một agent nào khác — mọi thứ ở đây đều chạy trong Pi.
4
6
 
5
7
  Quan trọng: flow chính là user chọn model bằng native Pi selector, không phải hỏi agent recommend.
6
8
 
@@ -48,7 +50,7 @@ piagent-models --provider openai-codex
48
50
  piagent-models --provider anthropic
49
51
  ```
50
52
 
51
- Lưu ý: `--list-models` chỉ hiện model mà Pi xem là available với credential/provider hiện tại. Nếu chưa login Anthropic, Claude có thể chưa hiện dù model catalog local có metadata.
53
+ Lưu ý: `--list-models` chỉ hiện model mà Pi xem là available với credential/provider hiện tại. Nếu chưa login Anthropic, các model Claude có thể chưa hiện dù model catalog local có metadata.
52
54
 
53
55
  ## Thinking levels
54
56
 
@@ -70,7 +72,7 @@ pi --thinking medium
70
72
 
71
73
  Đừng giới hạn vào vài ví dụ. Sau `pi update --models`, kiểm tra catalog local bằng `piagent-models`. Ở release hiện tại, các family/presets chính cần nhớ:
72
74
 
73
- ### OpenAI Codex
75
+ ### Họ model OpenAI Codex
74
76
 
75
77
  | Model | Role gợi ý | Khi dùng |
76
78
  |---|---|---|
@@ -82,14 +84,14 @@ pi --thinking medium
82
84
  | `openai-codex/gpt-5.6-sol` | strategic/deep | architecture, large refactor, planning lớn |
83
85
  | `openai-codex/gpt-5.6-terra` | huge-context scout | đọc nhiều docs/source, tổng hợp repo lớn |
84
86
 
85
- ### Claude / Anthropic
87
+ ### Họ model Claude (Anthropic)
86
88
 
87
89
  | Model | Role gợi ý | Khi dùng |
88
90
  |---|---|---|
89
91
  | `anthropic/claude-haiku-4-5` | fast/cheap | hỏi nhanh, docs/scout nhẹ |
90
92
  | `anthropic/claude-sonnet-4-5` | balanced | task source bình thường |
91
93
  | `anthropic/claude-sonnet-4-6` | balanced/deep | source task lớn hơn, max-capable |
92
- | `anthropic/claude-sonnet-5` | balanced/hard default | Claude default mạnh cho implement |
94
+ | `anthropic/claude-sonnet-5` | balanced/hard default | model default mạnh cho implement |
93
95
  | `anthropic/claude-opus-4-5` | deep | review/refactor lớn |
94
96
  | `anthropic/claude-opus-4-6` | deep/max | architecture/reasoning nặng |
95
97
  | `anthropic/claude-opus-4-7` | deep/xhigh/max | high-risk/debug/architecture |
@@ -102,7 +104,7 @@ Pi catalog có thể có thêm dated variants như `*-2025xxxx`. Dùng alias lat
102
104
 
103
105
  Preset dưới đây là cách mình seed `enabledModels`, không phải giới hạn hard. User vẫn có thể mở `/model` để chọn bất kỳ model available nào trong provider catalog.
104
106
 
105
- | Preset | OpenAI Codex example | Claude/Anthropic example | Khi dùng |
107
+ | Preset | Model OpenAI Codex | Model Claude (Anthropic) | Khi dùng |
106
108
  |---|---|---|---|
107
109
  | Fast scout | `openai-codex/gpt-5.4-mini:low` | `anthropic/claude-haiku-4-5:low` | đọc nhanh, hỏi đáp, grep/scout nhẹ |
108
110
  | Balanced implement | `openai-codex/gpt-5.5:medium` | `anthropic/claude-sonnet-5:medium` | task source bình thường |
@@ -160,6 +162,6 @@ bash scripts/quality-benchmark.sh /path/to/project --record \
160
162
 
161
163
  So sánh tối thiểu:
162
164
 
163
- - Pi + Codex fast/balanced/deep;
164
- - Pi + Claude fast/balanced/deep;
165
+ - Pi + model Codex ở fast/balanced/deep;
166
+ - Pi + model Claude ở fast/balanced/deep;
165
167
  - any other approved setup nếu team muốn so sánh bằng số liệu.
@@ -18,12 +18,12 @@ Support matrix release hiện tại: macOS Apple Silicon + Bash và Linux x64 +
18
18
  ```bash
19
19
  node --version # >= 22.19.0
20
20
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
21
- npm install -g --ignore-scripts @piagent/platform@1.1.9
21
+ npm install -g --ignore-scripts @piagent/platform@1.2.1
22
22
  piagent-install --stable --dry-run
23
23
  piagent-install --stable
24
24
  ```
25
25
 
26
- Khi seed `.pi/settings.json` cho team/repo cần audit lặp lại, giữ package source dạng pinned tag như `git:github.com/Vt-mmm/piagent@v1.1.9`. Máy cá nhân có thể dùng `git:github.com/Vt-mmm/piagent` để theo latest.
26
+ Khi seed `.pi/settings.json` cho team/repo cần audit lặp lại, giữ package source dạng pinned tag như `git:github.com/Vt-mmm/piagent@v1.2.1`. Máy cá nhân có thể dùng `git:github.com/Vt-mmm/piagent` để theo latest.
27
27
 
28
28
  Nếu đang ở source checkout của platform, dùng helper theo channel để preview trước khi đổi:
29
29
 
@@ -99,7 +99,7 @@ install package once
99
99
 
100
100
  ```bash
101
101
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
102
- npm install -g --ignore-scripts @piagent/platform@1.1.9
102
+ npm install -g --ignore-scripts @piagent/platform@1.2.1
103
103
  piagent-install --stable --dry-run
104
104
  piagent-install --stable
105
105
  ```
@@ -154,7 +154,7 @@ Trong Pi:
154
154
  /login
155
155
  ```
156
156
 
157
- Chọn provider/account như OpenAI/Codex hoặc Anthropic/Claude. Credential nằm trong Pi user dir, không nằm trong repo và không được commit.
157
+ Chọn provider/account cho họ model muốn dùng: OpenAI (model Codex) hoặc Anthropic (model Claude). Credential nằm trong Pi user dir, không nằm trong repo và không được commit.
158
158
 
159
159
  Browser login của OpenAI có hai chỗ trông như treo. Cả hai là lỗi Pi host, không phải platform, và còn nguyên ở `0.82.0` lẫn `0.82.1`.
160
160
 
@@ -281,7 +281,7 @@ Không phải daily default. Dùng khi muốn tạo sẵn `.pi` files cho projec
281
281
  bash /path/to/piagent/scripts/setup.sh /path/to/project \
282
282
  --project-only \
283
283
  --profile auto \
284
- --package-source git:github.com/Vt-mmm/piagent@v1.1.9 \
284
+ --package-source git:github.com/Vt-mmm/piagent@v1.2.1 \
285
285
  --mcp-preset core \
286
286
  --subagents-preset safe
287
287
  ```
@@ -298,7 +298,7 @@ Khi command không có trên PATH, dùng script trực tiếp:
298
298
 
299
299
  ```bash
300
300
  bash /path/to/piagent/scripts/init-project.sh /path/to/project --profile auto
301
- bash /path/to/piagent/scripts/configure-mcp.sh --preset core --scope global --replace
301
+ node /path/to/piagent/scripts/mcp-manage.mjs --preset core --scope global --replace
302
302
  bash /path/to/piagent/scripts/configure-subagents.sh --preset safe
303
303
  ```
304
304
 
@@ -514,6 +514,16 @@ bash /path/to/piagent/scripts/pi-session-stats.sh \
514
514
  /Users/<user>/.pi/agent/sessions/<project-key>/<session>.jsonl
515
515
  ```
516
516
 
517
+ Để xem tổng usage lịch sử trên máy, kể cả session đã end:
518
+
519
+ ```bash
520
+ piagent-usage --history /path/to/project --days 7
521
+ piagent-usage --history --all-projects --days 7 --csv
522
+ piagent-usage --history --all-projects --since 2026-07-20 --until 2026-07-26 --json
523
+ ```
524
+
525
+ History mode đọc trực tiếp `~/.pi/agent/sessions/**/*.jsonl`. Mặc định có tính cả subagent session files vì đó là usage thật của máy; thêm `--no-subagents` nếu chỉ muốn parent/main sessions.
526
+
517
527
  ### Cách đọc số
518
528
 
519
529
  | Field | Ý nghĩa |
@@ -654,7 +664,7 @@ piagent-mcp --list
654
664
  Fallback:
655
665
 
656
666
  ```bash
657
- bash /path/to/piagent/scripts/configure-mcp.sh --preset core --scope global --replace
667
+ node /path/to/piagent/scripts/mcp-manage.mjs --preset core --scope global --replace
658
668
  ```
659
669
 
660
670
  ### Cấu hình project
@@ -666,7 +676,7 @@ piagent-mcp --preset design --scope project --project /path/to/project
666
676
  Fallback:
667
677
 
668
678
  ```bash
669
- bash /path/to/piagent/scripts/configure-mcp.sh \
679
+ node /path/to/piagent/scripts/mcp-manage.mjs \
670
680
  --preset design \
671
681
  --scope project \
672
682
  --project /path/to/project
@@ -854,8 +864,8 @@ Watchdog là optional adversarial reviewer ở cuối turn, không bật mặc
854
864
 
855
865
  | Command | Dùng để |
856
866
  |---|---|
857
- | `npm install -g --ignore-scripts @piagent/platform@1.1.9` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
858
- | `pi install git:github.com/Vt-mmm/piagent@v1.1.9` | Install pinned release cho reproducible team setup. |
867
+ | `npm install -g --ignore-scripts @piagent/platform@1.2.1` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
868
+ | `pi install git:github.com/Vt-mmm/piagent@v1.2.1` | Install pinned release cho reproducible team setup. |
859
869
  | `pi install git:github.com/Vt-mmm/piagent` | Install latest platform package cho máy cá nhân/sandbox. |
860
870
  | Cài exact Pi host của release, rồi `npm install -g --ignore-scripts @piagent/platform@X.Y.Z` và `piagent-install --stable` | Full update: đồng bộ host, terminal helper và Pi package. Mỗi release pin một Pi host chính xác; lấy đúng version của release đang cài trong [release/install policy](release-install-policy.md). |
861
871
  | Cài exact Pi host ghi trong release cũ, rồi helper `vPREVIOUS` và `piagent-install --stable` | Full rollback; đánh giá lại dependency findings của host cũ trước khi hạ version. |
@@ -880,7 +890,9 @@ Watchdog là optional adversarial reviewer ở cuối turn, không bật mặc
880
890
  | `pi --fork <id-or-file>` | Fork session cũ sang session mới. |
881
891
  | `pi --name "<name>"` | Đặt tên session. |
882
892
  | `pi --tools read,grep,find,ls -p "Review src"` | Read-only one-shot. |
883
- | `piagent-usage /path/to/project` | Exact token/cost stats. |
893
+ | `piagent-usage /path/to/project` | Exact token/cost stats của session mới nhất. |
894
+ | `piagent-usage --history /path/to/project --days 7` | Tổng usage lịch sử của project. |
895
+ | `piagent-usage --history --all-projects --days 7 --csv` | CSV report cuối tuần toàn máy. |
884
896
  | `piagent-mcp --preset core --scope global --replace` | Setup or update the governed MCP baseline. |
885
897
  | `piagent-subagents --preset safe` | Setup subagents baseline. |
886
898
  | `bash scripts/verify-local.sh` | Verify platform repo. |
@@ -952,7 +964,7 @@ Mở lại Pi session sau khi install.
952
964
  Cài lại terminal helper đúng release rồi kiểm tra `PATH`:
953
965
 
954
966
  ```bash
955
- npm install -g --ignore-scripts @piagent/platform@1.1.9
967
+ npm install -g --ignore-scripts @piagent/platform@1.2.1
956
968
  command -v piagent-install
957
969
  ```
958
970
 
@@ -960,7 +972,7 @@ Nếu đang làm việc từ source checkout, có thể dùng script trực ti
960
972
 
961
973
  ```bash
962
974
  bash /path/to/piagent/scripts/pi-session-stats.sh /path/to/project
963
- bash /path/to/piagent/scripts/configure-mcp.sh --preset core --scope global --replace
975
+ node /path/to/piagent/scripts/mcp-manage.mjs --preset core --scope global --replace
964
976
  bash /path/to/piagent/scripts/configure-subagents.sh --preset safe
965
977
  ```
966
978
 
@@ -52,6 +52,8 @@ pi install /path/to/piagent
52
52
  - `1.1.7`: update global không còn chặn project đang chạy — lock chỉ block khi grant thật sự đổi, và profile dạng `extends` nhận policy từ platform đang cài thay vì giữ bản copy lúc onboard.
53
53
  - `1.1.8`: Pi báo ngay ở đầu session khi có release mới, kèm lệnh chạy update.
54
54
  - `1.1.9`: notice update hiện đúng trên bản cài bằng `pi install git:` — bản cài nhận diện theo vị trí thư mục, không theo `.git`.
55
+ - `1.2.0`: `piagent-mcp` quản lý server đầy đủ, server do repo mang theo phải được duyệt mới dùng được, và `/piagent-mcp` là command trong session chứ không phải nhờ model chạy bash.
56
+ - `1.2.1`: approval gate thật sự phủ direct tool và server đến qua `imports` — hai đường vòng mà bản `1.2.0` để hở; kèm một loạt fix về containment khi vendor, độ sâu shell guard, và credential trong URL.
55
57
 
56
58
  ## Không publish
57
59
 
@@ -50,14 +50,14 @@ Xong. Từ đây project nào cũng chỉ cần `cd` vào rồi gõ `pi`.
50
50
 
51
51
  Rollout team pin từng bước, update, rollback, và channel `--dev` cho máy cá nhân: [release-install-policy.md](release-install-policy.md).
52
52
 
53
- ## Bước 2 — login OAuth OpenAI Codex/ChatGPT hoặc Claude/Anthropic
53
+ ## Bước 2 — login OAuth provider model (OpenAI/ChatGPT hoặc Anthropic)
54
54
 
55
55
  ```bash
56
56
  pi
57
57
  /login
58
58
  ```
59
59
 
60
- Chọn provider OpenAI/Codex/ChatGPT hoặc Anthropic/Claude trong danh sách Pi. Token được lưu local trong Pi agent dir, không nằm trong repo.
60
+ Chọn provider cho họ model muốn dùng trong danh sách Pi: OpenAI/ChatGPT cho model Codex, hoặc Anthropic cho model Claude. Token được lưu local trong Pi agent dir, không nằm trong repo.
61
61
 
62
62
  ## Bước 3 — chọn model và chạy project onboarding
63
63
 
@@ -10,7 +10,7 @@ This file is the canonical install, update, rollback, and release checklist. Oth
10
10
 
11
11
  All supported environments require Node.js `>=22.19.0` and Pi Coding Agent `0.82.0`. The Pi host is installed as a Node CLI; Pi Agent Platform still defines its own release matrix because the terminal helpers and shell policy rely on Bash/POSIX behavior.
12
12
 
13
- | Surface | Status for v1.1.9 | Rollout guidance |
13
+ | Surface | Status for v1.2.1 | Rollout guidance |
14
14
  |---|---|---|
15
15
  | macOS Apple Silicon (`darwin/arm64`) + Bash | Verified for this release. | Safe default for team rollout after normal project smoke tests. |
16
16
  | Linux x64 + Bash | Verified in GitHub Actions. | Safe default for CI/server usage after normal project smoke tests. |
@@ -33,7 +33,7 @@ These three components are versioned independently. A full install, update, or r
33
33
 
34
34
  | Channel | Source shape | Mutability | Use when |
35
35
  |---|---|---:|---|
36
- | `stable` | `git:github.com/Vt-mmm/piagent@<resolved-commit-sha>` from `v1.1.9` | Fixed after resolution | Default for team rollout. |
36
+ | `stable` | `git:github.com/Vt-mmm/piagent@<resolved-commit-sha>` from `v1.2.1` | Fixed after resolution | Default for team rollout. |
37
37
  | `exact` | Tag, reviewed commit, or a tag resolved with `--resolve-tag` | Fixed when using a commit SHA | Pi-package-only roll forward, rollback, or reproduction. |
38
38
  | `dev` | `git:github.com/Vt-mmm/piagent` | Moving | Personal machine or sandbox only. |
39
39
  | `local` | `/path/to/piagent` | Local workspace | Platform development and dry-run validation. |
@@ -53,7 +53,7 @@ Use this flow when the team needs both terminal commands and the Pi package:
53
53
  ```bash
54
54
  node --version # >= 22.19.0
55
55
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
56
- npm install -g --ignore-scripts @piagent/platform@1.1.9
56
+ npm install -g --ignore-scripts @piagent/platform@1.2.1
57
57
  piagent-install --stable --dry-run
58
58
  piagent-install --stable
59
59
  ```
@@ -61,8 +61,8 @@ piagent-install --stable
61
61
  The stable preview and apply output includes:
62
62
 
63
63
  ```text
64
- currentRelease: v1.1.9 (helper package version)
65
- tag: v1.1.9
64
+ currentRelease: v1.2.1 (helper package version)
65
+ tag: v1.2.1
66
66
  resolvedCommit: <40-char-sha>
67
67
  source: git:github.com/Vt-mmm/piagent@<40-char-sha>
68
68
  ```
@@ -79,7 +79,7 @@ bash scripts/install-global.sh --stable
79
79
  Use this only when terminal commands are not needed:
80
80
 
81
81
  ```bash
82
- pi install git:github.com/Vt-mmm/piagent@v1.1.9
82
+ pi install git:github.com/Vt-mmm/piagent@v1.2.1
83
83
  ```
84
84
 
85
85
  Direct `pi install` does not create `piagent-*` commands on `PATH`.
@@ -21,7 +21,7 @@ This document covers the packaged guard, project profiles, capability locks, ins
21
21
  - The operator, operating-system account, Pi host, and explicitly trusted project repository are trusted to execute code.
22
22
  - Project-local Pi resources are loaded only after Pi project trust or an explicit operator override.
23
23
  - A human remains available to approve destructive and external-provider actions.
24
- - Supported release verification covers macOS Apple Silicon + Bash, Linux x64 + Bash, Node.js `>=22.19.0`, and the exact Pi host version declared by the release. macOS Intel + Bash and Linux ARM64 + Bash are supported targets that need local smoke verification before broad rollout. Native Windows is not a team-rollout target for v1.1.9, and WSL2 is experimental/unverified.
24
+ - Supported release verification covers macOS Apple Silicon + Bash, Linux x64 + Bash, Node.js `>=22.19.0`, and the exact Pi host version declared by the release. macOS Intel + Bash and Linux ARM64 + Bash are supported targets that need local smoke verification before broad rollout. Native Windows is not a team-rollout target for v1.2.1, and WSL2 is experimental/unverified.
25
25
  - Registry, GitHub, model-provider, MCP-provider, and Vercel controls are external dependencies. Their account security and platform guarantees are not replaced by this repository.
26
26
 
27
27
  ## Threat actors and failure modes
@@ -40,12 +40,13 @@ The final category is outside the containment capability of the Piagent guard. I
40
40
  | Vector | Current control | Residual risk |
41
41
  |---|---|---|
42
42
  | Direct or nested path-like tool input | Bounded recursive input inspection, protected-path precedence, repository boundary checks, filesystem capability scopes, and read-only profile paths | A new carrier or field name must be classified before it can be treated as controlled. Unknown/ambiguous tools fail closed where policy requires confirmation. |
43
+ | Shell glob reaching a protected file | Glob candidates are read from the same expanded, resolved word list as every other check and matched against examples of each protected pattern, so a pattern assembled by an expansion (`{cat,.env*}`, `cat $({echo,.env*})`, `{bash,} -c 'cat .env*'`, `echo .env* | xargs cat`) is seen. This is the only check that can answer for a pattern at all, since `.env*` matches no protected literal. Whether a word is matched against filenames is decided per character, so a quoted metacharacter names a file instead (`{".env*",x}`). A redirection is read by the rule the shell uses — it opens its target only where that target expands to exactly one word, and is refused as an ambiguous redirect otherwise (`> "{.env,}"{,}`, `> {.env,other}`), while a word that can still disappear, an unset variable or a pattern under `nullglob`, leaves the count unknowable and keeps every candidate | Matching is against generated examples of each protected pattern, not against the filesystem, so a protected pattern whose examples do not represent every real name it covers can leave a matching file unnamed. Bounded expansion refuses rather than enumerates when a glob is too broad to expand. |
43
44
  | Encoding, case variation, traversal, or symbolic-link alias | Single percent decode, case-insensitive protected matching, canonical resolution for existing paths, traversal/repository escape rejection | Filesystem races and code executing outside observed tool paths require an OS boundary. |
44
- | Shell glob, brace, redirection, wrapper, assignment, or command composition | Static Bash operand/action analysis with bounded expansion and regression cases; protected input is denied and external mutation is confirmation-gated | Runtime-generated interpreter payloads cannot be fully understood by static parsing. Sensitive output redaction is a backstop, not containment. |
45
+ | Shell glob, brace, redirection, wrapper, assignment, or command composition | Static Bash operand/action analysis with bounded expansion and regression cases; protected input is denied and external mutation is confirmation-gated. A path the analysis cannot resolve — literal text concatenated with a substitution, as in `.en$(echo v)` — is refused rather than matched on its literal half | Runtime-generated interpreter payloads cannot be fully understood by static parsing. Sensitive output redaction is a backstop, not containment. |
45
46
  | Secret returned in tool output | Shared contextual redaction across guarded text/results and synthetic recall benchmark | High-entropy, novel secret formats, or transformed output such as base64-encoded content can evade pattern-based redaction. Never intentionally print real secrets. |
46
47
  | Malicious project profile or relaxed capability lock | Trust-aware profile loading, deterministic lock digest, base-policy/source integrity, protected self-state, and fail-closed verification | An already trusted malicious repository can execute code through mechanisms outside the guard. |
47
48
  | External GitHub/HTTP/MCP/provider mutation | Direct and proxied action classification plus explicit operator confirmation, including guarded shell carriers | Provider semantics and new tool schemas can change; new integrations require policy and regression review. |
48
- | Destructive local action | Exec-policy classification and explicit confirmation; protected paths remain denied in every permission profile | Confirmation is not isolation. A trusted process outside the observed tool path retains OS authority. |
49
+ | Destructive local action | Exec-policy classification and explicit confirmation; protected paths remain denied in every permission profile. A target written as a command substitution is evaluated only where its body is one plain command with literal operands and a format this renderer reproduces exactly, and confirmed otherwise — a separator, a nested substitution, a redirection, a variable, quoting, an escape, a `printf` option, or a `printf` conversion whose result this does not reproduce (`*`, `%q`, `%b`, the numeric conversions, `%%`) all make the body unreadable here. A constant width or precision and format reuse are reproduced, so a target built from those is refused rather than confirmed, and the rendered output is read as a path candidate as well as the format's literal text and its arguments — a name assembled across a conversion (`.e%.1sv nv` is `.env`) appears in none of the pieces. Brace expansion, ranges included, is performed once per segment before anything reads it, so the rules, the legacy patterns, the nested-interpreter scan, the pipeline producers and the destructive checks all see the word list the shell would build rather than the text as typed; the expansion produces a token stream, so a command and its arguments assembled from one brace word (`{cat,.env}`) are read as both; quoting is tracked per character, so a word holding a quoted group beside an expanding one (`"{.env,}"{,}`) expands exactly as far as the shell expands it — and a target that is nothing but an unresolved parameter expansion is confirmed rather than permitted, since it can hold any value including root. The same holds for reads: a word that is only an unresolved parameter expansion is confirmed wherever the command opens files (`cat ${HOME:+.env}`), including across a pipe into an `xargs` that opens them (`echo $F \| xargs cat`), while a command substitution in that position is left to the nested scan that classifies the command inside it, and two expansions with nothing between them count as a name being assembled just as literal text beside one does. Brace expansion, parameter expansion and command substitution are performed once per segment, in the order a shell performs them, and every reader takes that one word list — so a name assembled by an expansion (`r$(printf %s m) -rf /`, `xa$(printf %s rgs)`, `$(printf %s ba)$(echo -n sh) -c '...'`) is the command it becomes rather than the text it was typed as. A name that still cannot be resolved is treated as an unknown command rather than a known-harmless one: it is enough to bring the destructive checks, the interpreter scan and the file-operand net into play, since `${X:+r}m -rf /` and `${X:+cat} ${X:+.env}` are those commands whenever the variable is set. Differential cases are generated rather than enumerated, over the cross product the defects live in — expansion form, position in the command, and reader — with each spelling placed in the command name, the operand, a flag's argument, a redirection target, a pipeline producer, an `xargs` consumer and an interpreter payload; the corpus fails if any generated spelling produced no word list, so a batch that dies early cannot pass as coverage, and it asserts in both directions so a check that answers for everything fails too | Confirmation is not isolation. A trusted process outside the observed tool path retains OS authority. A target produced by any other command is knowable only at run time, so it is gated by confirmation rather than refused. |
49
50
  | Forged verification result | Observed Bash result ledger, command hash, task-start ordering, exit-code and verify-command matching | Compromise of the trusted Pi/process environment is outside this evidence model. |
50
51
  | Mutable or substituted release source | Exact team tags, stable tag-to-commit resolution, release-commit binding in tag CI, annotated-tag requirement, add-on integrity checks, and documented tag ruleset requirement | Bootstrap helper installation still relies on GitHub tag immutability; repository administrators must prevent tag update/deletion. Signed provenance remains future work. |
51
52
  | Dependency or package-content compromise | `--ignore-scripts` bootstrap installs, root and exact runtime dependency audits, immutable Action SHAs, package allowlist, artifact tests, CodeQL, Dependabot, secret scanning, and push protection | Audits are point-in-time and lower-severity/upstream findings remain. Review alerts and refresh pins continuously. |
@@ -9,7 +9,7 @@ Một thành viên mới không cần biết local path của maintainer. Luồn
9
9
  ```bash
10
10
  node --version # >= 22.19.0
11
11
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
12
- npm install -g --ignore-scripts @piagent/platform@1.1.9
12
+ npm install -g --ignore-scripts @piagent/platform@1.2.1
13
13
  piagent-install --stable
14
14
  cd /path/to/project
15
15
  pi
@@ -42,7 +42,7 @@ Mặc định team dùng stable helper:
42
42
  ```bash
43
43
  node --version # >= 22.19.0
44
44
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.82.0
45
- npm install -g --ignore-scripts @piagent/platform@1.1.9
45
+ npm install -g --ignore-scripts @piagent/platform@1.2.1
46
46
  piagent-install --stable --dry-run
47
47
  piagent-install --stable
48
48
  ```
@@ -70,7 +70,7 @@ piagent-update --check
70
70
  piagent-update --project /path/to/project
71
71
  ```
72
72
 
73
- `--check` chỉ báo version, không đụng gì. Lên đúng một bản cụ thể thì `piagent-update --version 1.1.9`.
73
+ `--check` chỉ báo version, không đụng gì. Lên đúng một bản cụ thể thì `piagent-update --version 1.2.1`.
74
74
 
75
75
  Không cần ai nhớ đi kiểm tra: khi có release mới, Pi tự báo ngay ở dòng notice lúc mở session, kèm luôn lệnh chạy.
76
76
 
@@ -129,7 +129,7 @@ Nếu browser login của OpenAI trông như treo, xem [login provider](operator
129
129
 
130
130
  ## Bước 3 — chọn model và onboard project
131
131
 
132
- Sau login, chọn provider/model intended cho project understanding bằng native Pi selector. OpenAI Codex và Claude/Anthropic đều là supported option.
132
+ Sau login, chọn provider/model intended cho project understanding bằng native Pi selector. Cả hai họ model đều là supported option: model OpenAI Codex và model Anthropic Claude.
133
133
 
134
134
  ```text
135
135
  /model # hoặc Ctrl+L
@@ -88,6 +88,35 @@ Ví dụ output:
88
88
  }
89
89
  ```
90
90
 
91
+ ## Usage lịch sử / report tuần
92
+
93
+ `piagent-usage /path/to/project` chỉ trả exact stats của session mới nhất. Để xem tổng usage đã lưu trên máy, kể cả session đã end hoặc subagent runs:
94
+
95
+ ```bash
96
+ piagent-usage --history /path/to/project
97
+ piagent-usage --history /path/to/project --days 7
98
+ piagent-usage --history --all-projects --days 7 --csv
99
+ piagent-usage --history --all-projects --since 2026-07-20 --until 2026-07-26 --json
100
+ ```
101
+
102
+ History mode đọc trực tiếp `~/.pi/agent/sessions/**/*.jsonl`, cộng usage từ từng assistant message:
103
+
104
+ - `input`, `output`, `cacheRead`, `cacheWrite`, `reasoning`, `totalTokens`;
105
+ - `cost.total`;
106
+ - số user messages, assistant messages, tool calls, tool results;
107
+ - breakdown theo project và top sessions.
108
+
109
+ Mặc định history mode **bao gồm subagent session files** vì đó là usage thật của máy. Dùng `--no-subagents` khi chỉ muốn parent/main sessions.
110
+
111
+ Format hỗ trợ:
112
+
113
+ | Format | Lệnh |
114
+ |---|---|
115
+ | Human table | `piagent-usage --history <project>` |
116
+ | JSON | `piagent-usage --history <project> --json` |
117
+ | CSV | `piagent-usage --history <project> --csv` |
118
+ | Markdown | `piagent-usage --history <project> --markdown` |
119
+
91
120
  ## Cách đọc số
92
121
 
93
122
  | Field | Ý nghĩa |
@@ -19,6 +19,30 @@ Lý do:
19
19
 
20
20
  Tách repository chỉ nên dùng khi docs cần domain, quyền truy cập, hoặc lịch phát hành riêng.
21
21
 
22
+ ## Cấu trúc site
23
+
24
+ Site là nhiều trang tĩnh, mỗi topic một trang, sinh ra từ một shell dùng chung:
25
+
26
+ ```text
27
+ docs-site/
28
+ content/<slug>.html # nội dung riêng của từng trang, không có header/sidebar/footer
29
+ assets/docs.css # style dùng chung
30
+ assets/docs.js # sidebar filter, TOC, active-section, copy button
31
+ <slug>.html # output đã generate, được commit
32
+ vercel.json
33
+ scripts/build-docs-site.mjs
34
+ ```
35
+
36
+ Sidebar chia theo bốn nhóm — Get started, Build, MCP, Operate. Thứ tự nhóm và thứ tự trang nằm trong hằng `NAV` của `scripts/build-docs-site.mjs`; đó cũng là thứ tự của link prev/next ở cuối mỗi trang. Thêm một trang = thêm `docs-site/content/<slug>.html` + một entry trong `NAV`, rồi build lại.
37
+
38
+ ```bash
39
+ npm run site:build
40
+ ```
41
+
42
+ Output HTML được commit, vì Vercel serve file tĩnh và không có build step. `npm run verify` chạy `build-docs-site.mjs --check`, fail khi output đã commit không còn khớp source — cùng cách `catalog/capabilities.json` đang dùng. Không sửa tay `docs-site/<slug>.html`; sửa fragment trong `content/` hoặc sửa shell trong script.
43
+
44
+ Version badge xuất hiện trên mọi trang, nên `npm run release:identity` kiểm tra tất cả `docs-site/*.html` chứ không riêng `index.html`.
45
+
22
46
  ## Production promotion policy
23
47
 
24
48
  Production docs không được advertise một release tag chưa tồn tại.
@@ -96,16 +120,22 @@ curl -I https://www.piagent.io.vn/
96
120
  curl -sSL https://piagent.io.vn/ | grep 'vX.Y.Z docs'
97
121
  ```
98
122
 
99
- Xác nhận thêm favicon/logo, GitHub/Facebook links, install commands, sidebar anchors và mobile layout.
123
+ Xác nhận thêm favicon/logo, GitHub/Facebook links, install commands, sidebar anchors và mobile layout. Vì site giờ là nhiều trang, kiểm tra thêm clean URL và asset dùng chung:
124
+
125
+ ```bash
126
+ curl -o /dev/null -s -w '%{http_code}\n' https://piagent.io.vn/mcp
127
+ curl -o /dev/null -s -w '%{http_code}\n' https://piagent.io.vn/assets/docs.css
128
+ ```
100
129
 
101
130
  ## Local preview
102
131
 
103
132
  ```bash
104
- cd docs-site
105
- python3 -m http.server 4173
133
+ npm run site:preview
106
134
  ```
107
135
 
108
- Mở `http://localhost:4173`.
136
+ Mở `http://localhost:4321`. Đổi port bằng `npm run site:preview -- --port 4173`.
137
+
138
+ Dùng script này thay vì một static server bất kỳ: `vercel.json` bật `cleanUrls`, nên link nội bộ trỏ tới `/quickstart` chứ không phải `/quickstart.html`. `python3 -m http.server` trả 404 cho tất cả các link đó và preview thành vô dụng để kiểm tra navigation. Script bind loopback và resolve extensionless path đúng như production.
109
139
 
110
140
  ## Security notes
111
141
 
@@ -0,0 +1,152 @@
1
+ <!doctype html>
2
+ <html lang="vi">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Kiến trúc repo · Pi Agent Platform Docs</title>
7
+ <meta name="description" content="Repo này không nhét business logic vào core. Core chỉ giữ policy, prompts, guard, skills và scripts dùng lại được." />
8
+ <meta name="theme-color" content="#050505" />
9
+ <link rel="canonical" href="https://piagent.io.vn/architecture" />
10
+ <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
11
+ <meta property="og:title" content="Kiến trúc repo · Pi Agent Platform Docs" />
12
+ <meta property="og:description" content="Repo này không nhét business logic vào core. Core chỉ giữ policy, prompts, guard, skills và scripts dùng lại được." />
13
+ <meta property="og:url" content="https://piagent.io.vn/architecture" />
14
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
15
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
16
+ <link
17
+ href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap"
18
+ rel="stylesheet"
19
+ />
20
+ <link rel="stylesheet" href="/assets/docs.css" />
21
+ <script src="/assets/docs.js" defer></script>
22
+ </head>
23
+ <body>
24
+ <header class="topbar">
25
+ <a class="brand" href="/" aria-label="Pi Agent Platform">
26
+ <span class="brand-mark"><img src="/assets/piagent-logo.svg" alt="" /></span>
27
+ <span>Pi Agent Platform</span>
28
+ </a>
29
+ <div class="top-actions">
30
+ <span class="pill"><span class="pill-dot"></span>v1.2.1 docs</span>
31
+ <a class="button social" href="https://github.com/Vt-mmm/piagent" target="_blank" rel="noopener noreferrer" aria-label="Mở GitHub repository">
32
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
33
+ <path d="M7 17 17 7M9 7h8v8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
34
+ </svg>
35
+ GitHub
36
+ </a>
37
+ <button class="button mobile-menu" type="button" data-menu>Lộ trình</button>
38
+ <a class="button" href="/commands">Commands</a>
39
+ </div>
40
+ </header>
41
+
42
+ <div class="layout with-toc">
43
+ <aside class="sidebar" data-sidebar>
44
+ <div class="sidebar-search" aria-label="Tìm trong tài liệu">
45
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
46
+ <path d="M10.8 18.1a7.3 7.3 0 1 1 0-14.6 7.3 7.3 0 0 1 0 14.6Zm5.3-1.7 4.4 4.4" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
47
+ </svg>
48
+ <input type="search" placeholder="Tìm trang" data-filter />
49
+ </div>
50
+
51
+ <nav aria-label="Tài liệu">
52
+ <div class="nav-group">
53
+ <p class="nav-title">Get started</p>
54
+ <a class="nav-link" href="/">Overview</a>
55
+ <a class="nav-link" href="/quickstart">Quickstart</a>
56
+ <a class="nav-link" href="/scope">Phạm vi platform</a>
57
+ </div>
58
+ <div class="nav-group">
59
+ <p class="nav-title">Build</p>
60
+ <a class="nav-link" href="/profiles">Project profile</a>
61
+ <a class="nav-link" href="/permissions">Permission modes</a>
62
+ <a class="nav-link" href="/commands">Command catalog</a>
63
+ <a class="nav-link" href="/workflows">Workflows</a>
64
+ </div>
65
+ <div class="nav-group">
66
+ <p class="nav-title">MCP</p>
67
+ <a class="nav-link" href="/mcp">MCP overview</a>
68
+ <a class="nav-link" href="/mcp-servers">Quản lý server</a>
69
+ <a class="nav-link" href="/mcp-auth">Auth và readiness</a>
70
+ <a class="nav-link" href="/mcp-approval">Approval gate</a>
71
+ </div>
72
+ <div class="nav-group">
73
+ <p class="nav-title">Operate</p>
74
+ <a class="nav-link" href="/security">Security model</a>
75
+ <a class="nav-link current" href="/architecture" aria-current="page">Architecture</a>
76
+ <a class="nav-link" href="/runtime">Runtime tools</a>
77
+ <a class="nav-link" href="/team">Team usage</a>
78
+ </div>
79
+ </nav>
80
+ </aside>
81
+
82
+ <main>
83
+ <div class="content-shell" data-article>
84
+ <nav class="breadcrumb" aria-label="Breadcrumb">
85
+ <a href="/">Docs</a>
86
+ <span aria-hidden="true">/</span>
87
+ <span>Operate</span>
88
+ <span aria-hidden="true">/</span>
89
+ <span>Architecture</span>
90
+ </nav>
91
+ <div class="page-head">
92
+ <h1>Kiến trúc repo</h1>
93
+ <p>Repo này không nhét business logic vào core. Core chỉ giữ policy, prompts, guard, skills và scripts dùng lại được.</p>
94
+ </div>
95
+ <section class="section">
96
+
97
+ <div class="grid cols-3">
98
+ <article class="card">
99
+ <h3 id="core-package">Core package</h3>
100
+ <p><span class="inline-code">packages/piagent-core</span> chứa extension guard, prompts, skills và subagent roles.</p>
101
+ </article>
102
+ <article class="card">
103
+ <h3 id="adapters">Adapters</h3>
104
+ <p><span class="inline-code">adapters/</span> chứa profile dùng lại: frontend, backend, fullstack, data, devops, docs.</p>
105
+ </article>
106
+ <article class="card">
107
+ <h3 id="capability-packs">Capability packs</h3>
108
+ <p><span class="inline-code">packs/</span> gom policy, lifecycle, recipes và eval scenarios theo manifest có lock.</p>
109
+ </article>
110
+ <article class="card">
111
+ <h3 id="policies">Policies</h3>
112
+ <p>Base policy định nghĩa protected paths, command rules, permission modes và human-action gates.</p>
113
+ </article>
114
+ <article class="card">
115
+ <h3 id="scripts">Scripts</h3>
116
+ <p>Setup, doctor, model scope, MCP, subagents, benchmark và trusted-run wrapper đều có CLI riêng.</p>
117
+ </article>
118
+ <article class="card">
119
+ <h3 id="docs">Docs</h3>
120
+ <p><span class="inline-code">docs/</span> giữ manual dài. <span class="inline-code">docs-site/</span> là trang HTML gọn cho team.</p>
121
+ </article>
122
+ </div>
123
+ </section>
124
+ <nav class="pager" aria-label="Trang kế tiếp">
125
+ <a class="pager-prev" href="/security">
126
+ <span class="pager-label">Trước</span>
127
+ <span class="pager-title">Security model</span>
128
+ </a>
129
+ <a class="pager-next" href="/runtime">
130
+ <span class="pager-label">Tiếp</span>
131
+ <span class="pager-title">Runtime tools</span>
132
+ </a>
133
+ </nav>
134
+
135
+ <footer class="footer">
136
+ <p>Pi Agent Platform docs · static HTML · governed agent workflow</p>
137
+ <div class="footer-links" aria-label="External links">
138
+ <a href="https://piagent.io.vn" target="_blank" rel="noopener noreferrer">piagent.io.vn</a>
139
+ <a href="https://github.com/Vt-mmm/piagent" target="_blank" rel="noopener noreferrer">GitHub repository</a>
140
+ <a href="https://www.facebook.com/vinhtam0544/" target="_blank" rel="noopener noreferrer">Facebook profile</a>
141
+ </div>
142
+ </footer>
143
+ </div>
144
+ </main>
145
+
146
+ <aside class="toc" aria-label="Mục lục trang">
147
+ <p class="toc-title">Trên trang này</p>
148
+ <nav data-toc></nav>
149
+ </aside>
150
+ </div>
151
+ </body>
152
+ </html>