@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.
Files changed (159) hide show
  1. package/.gitattributes +7 -0
  2. package/AGENTS.md +31 -0
  3. package/CHANGELOG.md +296 -0
  4. package/CODE_OF_CONDUCT.md +36 -0
  5. package/CONTRIBUTING.md +66 -0
  6. package/LICENSE +21 -0
  7. package/README.md +588 -0
  8. package/SECURITY.md +38 -0
  9. package/adapters/backend-api/profile.json +88 -0
  10. package/adapters/be-readonly-fe/profile.json +120 -0
  11. package/adapters/data/profile.json +88 -0
  12. package/adapters/devops/profile.json +92 -0
  13. package/adapters/docs/profile.json +74 -0
  14. package/adapters/fullstack/profile.json +94 -0
  15. package/adapters/generic/profile.json +95 -0
  16. package/adapters/mobile/profile.json +87 -0
  17. package/adapters/node-typescript/profile.json +76 -0
  18. package/adapters/python/profile.json +75 -0
  19. package/adapters/web-frontend/profile.json +101 -0
  20. package/catalog/capabilities.json +206 -0
  21. package/docs/architecture.md +64 -0
  22. package/docs/auto-delegation-policy.md +192 -0
  23. package/docs/capability-packs.md +234 -0
  24. package/docs/command-reference-vietnamese.md +484 -0
  25. package/docs/context-window-policy.md +85 -0
  26. package/docs/distribution-standard.md +229 -0
  27. package/docs/herdr-workflow.md +58 -0
  28. package/docs/mcp-and-tools.md +316 -0
  29. package/docs/memory-policy.md +164 -0
  30. package/docs/model-options.md +165 -0
  31. package/docs/oauth-providers.md +53 -0
  32. package/docs/operator-manual-vietnamese.md +1080 -0
  33. package/docs/package-architecture-notes.md +101 -0
  34. package/docs/project-adapters.md +174 -0
  35. package/docs/project-onboarding.md +135 -0
  36. package/docs/publishing-for-teams.md +64 -0
  37. package/docs/quality-benchmark.md +74 -0
  38. package/docs/quickstart-vietnamese.md +350 -0
  39. package/docs/release-install-policy.md +223 -0
  40. package/docs/runtime-harness-standard.md +118 -0
  41. package/docs/runtime-policy-design.md +132 -0
  42. package/docs/runtime-quality-baseline.md +257 -0
  43. package/docs/security-redaction-benchmark.md +56 -0
  44. package/docs/security-threat-model.md +66 -0
  45. package/docs/subagent-orchestration-capabilities.md +104 -0
  46. package/docs/subagents-and-multiagent.md +346 -0
  47. package/docs/task-implementation-contract.md +200 -0
  48. package/docs/team-onboarding.md +333 -0
  49. package/docs/usage-observability.md +130 -0
  50. package/docs/vercel-docs-site.md +115 -0
  51. package/docs/workflow-recipes.md +125 -0
  52. package/docs-site/assets/piagent-logo.svg +35 -0
  53. package/docs-site/favicon.svg +18 -0
  54. package/docs-site/index.html +1613 -0
  55. package/docs-site/vercel.json +24 -0
  56. package/evals/fixtures/action-proposal.invalid.json +34 -0
  57. package/evals/fixtures/action-proposal.valid.json +34 -0
  58. package/evals/fixtures/capability-pack.invalid.json +123 -0
  59. package/evals/fixtures/capability-pack.valid.json +123 -0
  60. package/evals/fixtures/capability-recipe.invalid.json +81 -0
  61. package/evals/fixtures/capability-recipe.valid.json +82 -0
  62. package/evals/fixtures/context-index.invalid.json +25 -0
  63. package/evals/fixtures/context-index.valid.json +25 -0
  64. package/evals/fixtures/eval-scenario.invalid.json +40 -0
  65. package/evals/fixtures/eval-scenario.valid.json +45 -0
  66. package/evals/fixtures/project-profile.invalid.json +88 -0
  67. package/evals/fixtures/project-profile.valid.json +95 -0
  68. package/evals/fixtures/task-contract.invalid.json +73 -0
  69. package/evals/fixtures/task-contract.valid.json +74 -0
  70. package/evals/golden/enforcement-decisions.json +329 -0
  71. package/evals/scenarios/capability-resolution.json +45 -0
  72. package/package.json +132 -0
  73. package/packages/piagent-core/README.md +147 -0
  74. package/packages/piagent-core/capabilities/capability-core.js +1023 -0
  75. package/packages/piagent-core/capabilities/capability-sources.js +265 -0
  76. package/packages/piagent-core/extensions/guard-io.js +45 -0
  77. package/packages/piagent-core/extensions/guard-shell-analysis.ts +558 -0
  78. package/packages/piagent-core/extensions/guard-types.ts +406 -0
  79. package/packages/piagent-core/extensions/piagent-guard.ts +5760 -0
  80. package/packages/piagent-core/extensions/policy-core.js +1070 -0
  81. package/packages/piagent-core/extensions/redaction-core.js +4 -0
  82. package/packages/piagent-core/extensions/runtime-evidence.js +215 -0
  83. package/packages/piagent-core/package.json +46 -0
  84. package/packages/piagent-core/policies/base-policy.json +249 -0
  85. package/packages/piagent-core/prompts/be-to-fe.md +82 -0
  86. package/packages/piagent-core/prompts/commit.md +27 -0
  87. package/packages/piagent-core/prompts/discuss.md +35 -0
  88. package/packages/piagent-core/prompts/memory-policy.md +52 -0
  89. package/packages/piagent-core/prompts/model-options.md +68 -0
  90. package/packages/piagent-core/prompts/onboard-project.md +147 -0
  91. package/packages/piagent-core/prompts/piagent-commands.md +68 -0
  92. package/packages/piagent-core/prompts/plan.md +35 -0
  93. package/packages/piagent-core/prompts/platform-improve.md +69 -0
  94. package/packages/piagent-core/prompts/pr.md +26 -0
  95. package/packages/piagent-core/prompts/review.md +38 -0
  96. package/packages/piagent-core/prompts/scout.md +50 -0
  97. package/packages/piagent-core/prompts/task.md +69 -0
  98. package/packages/piagent-core/security/sensitive-data.js +187 -0
  99. package/packages/piagent-core/skills/piagent-ops/SKILL.md +44 -0
  100. package/packages/piagent-core/skills/piagent-source-cache/SKILL.md +59 -0
  101. package/packages/piagent-core/skills/piagent-source-cache/checkout-source-repo.sh +144 -0
  102. package/packages/piagent-core/subagents/piagent-oracle.md +29 -0
  103. package/packages/piagent-core/subagents/piagent-planner.md +46 -0
  104. package/packages/piagent-core/subagents/piagent-reviewer.md +48 -0
  105. package/packages/piagent-core/subagents/piagent-scout.md +37 -0
  106. package/packages/piagent-core/subagents/piagent-worker.md +44 -0
  107. package/packs/engineering-base/pack.json +123 -0
  108. package/packs/engineering-base/recipes/bounded-change.json +82 -0
  109. package/packs/web-delivery/pack.json +72 -0
  110. package/packs/web-delivery/recipes/verified-web-change.json +57 -0
  111. package/schemas/action-proposal.schema.json +90 -0
  112. package/schemas/capability-pack.schema.json +190 -0
  113. package/schemas/capability-recipe.schema.json +72 -0
  114. package/schemas/context-index.schema.json +258 -0
  115. package/schemas/eval-scenario.schema.json +67 -0
  116. package/schemas/project-profile.schema.json +555 -0
  117. package/schemas/task-contract.schema.json +314 -0
  118. package/scripts/audit-runtime-host.sh +78 -0
  119. package/scripts/bootstrap-local.sh +25 -0
  120. package/scripts/capability-catalog.mjs +290 -0
  121. package/scripts/check-runtime-advisories.mjs +114 -0
  122. package/scripts/configure-mcp.sh +301 -0
  123. package/scripts/configure-model-scope.sh +143 -0
  124. package/scripts/configure-subagents.sh +241 -0
  125. package/scripts/import-agent-instructions.mjs +199 -0
  126. package/scripts/init-project.sh +369 -0
  127. package/scripts/install-global.sh +532 -0
  128. package/scripts/link-project.sh +25 -0
  129. package/scripts/migrate-project-state.mjs +176 -0
  130. package/scripts/pi-auto.sh +79 -0
  131. package/scripts/pi-model-catalog.sh +154 -0
  132. package/scripts/pi-session-stats.sh +135 -0
  133. package/scripts/piagent-cli.mjs +53 -0
  134. package/scripts/profile-doctor.sh +238 -0
  135. package/scripts/quality-benchmark.sh +185 -0
  136. package/scripts/redaction-benchmark.mjs +227 -0
  137. package/scripts/runtime-policy-smoke.sh +48 -0
  138. package/scripts/setup.sh +425 -0
  139. package/scripts/team-doctor.sh +461 -0
  140. package/scripts/verify-local.sh +540 -0
  141. package/scripts/verify-release-identity.mjs +85 -0
  142. package/scripts/verify-vercel-link.mjs +64 -0
  143. package/templates/global/mcp.json +9 -0
  144. package/templates/global/settings.json +37 -0
  145. package/templates/project/.mcp.json +9 -0
  146. package/templates/project/.pi/context-index.json +25 -0
  147. package/templates/project/.pi/gitignore.template +22 -0
  148. package/templates/project/.pi/mcp.json +9 -0
  149. package/templates/project/.pi/memory/MEMORY.md +11 -0
  150. package/templates/project/.pi/memory/memory_summary.md +9 -0
  151. package/templates/project/.pi/piagent-profile.json +107 -0
  152. package/templates/project/.pi/project-context.md +30 -0
  153. package/templates/project/.pi/settings.json +17 -0
  154. package/templates/project/.pi/task-contract.template.json +74 -0
  155. package/templates/project/.pi/tech-context/README.md +7 -0
  156. package/templates/project/.pi/tech-stack.json +10 -0
  157. package/templates/project/AGENTS.md +34 -0
  158. package/templates/project/REVIEW_GUIDELINES.md +23 -0
  159. package/types/pi-runtime-shims.d.ts +13 -0
@@ -0,0 +1,314 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/Vt-mmm/piagent/schemas/task-contract.schema.json",
4
+ "title": "Pi Agent Task Implementation Contract",
5
+ "type": "object",
6
+ "required": [
7
+ "taskId",
8
+ "summary",
9
+ "riskLane",
10
+ "expectedOutput",
11
+ "acceptanceCriteria",
12
+ "scope",
13
+ "outOfScope",
14
+ "protectedPaths",
15
+ "requiredContext",
16
+ "contextManifest",
17
+ "memoryCitations",
18
+ "verifyCommands",
19
+ "changedFiles",
20
+ "verifyEvidence",
21
+ "trace"
22
+ ],
23
+ "properties": {
24
+ "taskId": {
25
+ "type": "string",
26
+ "minLength": 1
27
+ },
28
+ "summary": {
29
+ "type": "string",
30
+ "minLength": 10
31
+ },
32
+ "riskLane": {
33
+ "enum": [
34
+ "tiny",
35
+ "normal",
36
+ "high-risk"
37
+ ]
38
+ },
39
+ "expectedOutput": {
40
+ "type": "string",
41
+ "minLength": 10
42
+ },
43
+ "acceptanceCriteria": {
44
+ "type": "array",
45
+ "items": {
46
+ "type": "string",
47
+ "minLength": 1
48
+ },
49
+ "minItems": 1
50
+ },
51
+ "scope": {
52
+ "type": "array",
53
+ "items": {
54
+ "type": "string",
55
+ "minLength": 1
56
+ },
57
+ "minItems": 1
58
+ },
59
+ "outOfScope": {
60
+ "type": "array",
61
+ "items": {
62
+ "type": "string",
63
+ "minLength": 1
64
+ }
65
+ },
66
+ "protectedPaths": {
67
+ "type": "array",
68
+ "items": {
69
+ "type": "string",
70
+ "minLength": 1
71
+ }
72
+ },
73
+ "requiredContext": {
74
+ "type": "array",
75
+ "items": {
76
+ "type": "string",
77
+ "minLength": 1
78
+ }
79
+ },
80
+ "contextManifest": {
81
+ "type": "array",
82
+ "items": {
83
+ "type": "object",
84
+ "required": [
85
+ "path",
86
+ "reason"
87
+ ],
88
+ "properties": {
89
+ "path": {
90
+ "type": "string"
91
+ },
92
+ "reason": {
93
+ "type": "string"
94
+ }
95
+ },
96
+ "additionalProperties": true
97
+ }
98
+ },
99
+ "memoryCitations": {
100
+ "type": "array",
101
+ "items": {
102
+ "type": "object",
103
+ "required": [
104
+ "path",
105
+ "reason"
106
+ ],
107
+ "properties": {
108
+ "path": {
109
+ "type": "string",
110
+ "minLength": 1
111
+ },
112
+ "reason": {
113
+ "type": "string",
114
+ "minLength": 1
115
+ }
116
+ },
117
+ "additionalProperties": false
118
+ }
119
+ },
120
+ "mcpCapabilities": {
121
+ "type": "array",
122
+ "items": {
123
+ "type": "string"
124
+ }
125
+ },
126
+ "verifyCommands": {
127
+ "type": "array",
128
+ "items": {
129
+ "type": "string",
130
+ "minLength": 1
131
+ }
132
+ },
133
+ "workPlan": {
134
+ "type": "array",
135
+ "description": "Optional solo-first task tree for parent/subagent coordination.",
136
+ "maxItems": 12,
137
+ "items": {
138
+ "type": "object",
139
+ "required": [
140
+ "id",
141
+ "title",
142
+ "role",
143
+ "mode",
144
+ "status"
145
+ ],
146
+ "properties": {
147
+ "id": {
148
+ "type": "string",
149
+ "minLength": 1,
150
+ "maxLength": 40
151
+ },
152
+ "title": {
153
+ "type": "string",
154
+ "minLength": 1,
155
+ "maxLength": 160
156
+ },
157
+ "role": {
158
+ "enum": [
159
+ "parent",
160
+ "piagent-scout",
161
+ "piagent-planner",
162
+ "piagent-worker",
163
+ "piagent-reviewer",
164
+ "piagent-oracle"
165
+ ]
166
+ },
167
+ "mode": {
168
+ "enum": [
169
+ "read-only",
170
+ "single-writer",
171
+ "review"
172
+ ]
173
+ },
174
+ "status": {
175
+ "enum": [
176
+ "pending",
177
+ "in-progress",
178
+ "done",
179
+ "skipped"
180
+ ]
181
+ },
182
+ "dependsOn": {
183
+ "type": "array",
184
+ "items": {
185
+ "type": "string",
186
+ "minLength": 1,
187
+ "maxLength": 40
188
+ }
189
+ }
190
+ },
191
+ "additionalProperties": false
192
+ }
193
+ },
194
+ "reviewLenses": {
195
+ "type": "array",
196
+ "description": "Explicit review lenses for the task, used instead of blanket swarm review.",
197
+ "uniqueItems": true,
198
+ "items": {
199
+ "enum": [
200
+ "correctness",
201
+ "tests",
202
+ "scope",
203
+ "security",
204
+ "docs",
205
+ "release",
206
+ "package"
207
+ ]
208
+ }
209
+ },
210
+ "orchestration": {
211
+ "type": "object",
212
+ "description": "Resolved solo-first orchestration policy captured when the task starts.",
213
+ "properties": {
214
+ "mode": {
215
+ "enum": [
216
+ "solo-first",
217
+ "bounded-subagents",
218
+ "parallel-readonly"
219
+ ]
220
+ },
221
+ "subagents": {
222
+ "enum": [
223
+ "not-used",
224
+ "optional",
225
+ "used"
226
+ ]
227
+ },
228
+ "reason": {
229
+ "type": "string",
230
+ "minLength": 1
231
+ },
232
+ "fieldGuidePath": {
233
+ "type": "string",
234
+ "minLength": 1
235
+ },
236
+ "modelRoles": {
237
+ "type": "object",
238
+ "properties": {
239
+ "planner": { "type": "string" },
240
+ "worker": { "type": "string" },
241
+ "reviewer": { "type": "string" },
242
+ "watchdog": { "type": "string" }
243
+ },
244
+ "additionalProperties": false
245
+ }
246
+ },
247
+ "additionalProperties": false
248
+ },
249
+ "changedFiles": {
250
+ "type": "array",
251
+ "items": {
252
+ "type": "string"
253
+ }
254
+ },
255
+ "verifyEvidence": {
256
+ "type": "array",
257
+ "items": {
258
+ "type": "object",
259
+ "required": [
260
+ "command",
261
+ "exitCode",
262
+ "summary"
263
+ ],
264
+ "properties": {
265
+ "command": {
266
+ "type": "string"
267
+ },
268
+ "exitCode": {
269
+ "type": "integer"
270
+ },
271
+ "summary": {
272
+ "type": "string"
273
+ },
274
+ "observed": {
275
+ "type": "boolean",
276
+ "description": "True only when the verify command was matched against an observed bash tool_result after task start."
277
+ },
278
+ "observedAt": {
279
+ "type": "string",
280
+ "description": "Timestamp of the matching bash tool_result observation."
281
+ },
282
+ "isError": {
283
+ "type": "boolean",
284
+ "description": "Observed Pi tool_result isError flag."
285
+ },
286
+ "matchedProfileCommand": {
287
+ "type": "boolean",
288
+ "description": "True only when the observed verify command exactly matches one of task.verifyCommands."
289
+ }
290
+ },
291
+ "additionalProperties": true
292
+ }
293
+ },
294
+ "trace": {
295
+ "type": "object",
296
+ "required": [
297
+ "outcome"
298
+ ],
299
+ "properties": {
300
+ "outcome": {
301
+ "enum": [
302
+ "pending",
303
+ "completed",
304
+ "blocked",
305
+ "partial",
306
+ "failed"
307
+ ]
308
+ }
309
+ },
310
+ "additionalProperties": true
311
+ }
312
+ },
313
+ "additionalProperties": true
314
+ }
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
+
6
+ if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
7
+ echo "Usage: scripts/audit-runtime-host.sh"
8
+ echo "Audit the exact Pi host and pinned optional add-ons used by the installer; requires registry access."
9
+ exit 0
10
+ fi
11
+ if [[ $# -gt 0 ]]; then
12
+ echo "Unknown argument: $1" >&2
13
+ exit 2
14
+ fi
15
+
16
+ require_exact_peer() {
17
+ local name="$1"
18
+ local value
19
+ value="$(node -e 'const fs=require("node:fs"); const p=JSON.parse(fs.readFileSync(process.argv[1], "utf8")); process.stdout.write(p.peerDependencies?.[process.argv[2]] ?? "");' "$ROOT/package.json" "$name")"
20
+ if [[ ! "$value" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then
21
+ echo "FAIL: peer dependency $name must use an exact version." >&2
22
+ exit 1
23
+ fi
24
+ printf '%s' "$value"
25
+ }
26
+
27
+ PI_CODING_VERSION="$(require_exact_peer "@earendil-works/pi-coding-agent")"
28
+ PI_AI_VERSION="$(require_exact_peer "@earendil-works/pi-ai")"
29
+ TYPEBOX_VERSION="$(require_exact_peer "typebox")"
30
+ PI_MCP_ADAPTER_VERSION="2.11.0"
31
+ PI_SUBAGENTS_VERSION="0.35.1"
32
+ PI_WEB_ACCESS_VERSION="0.13.0"
33
+
34
+ if [[ "$PI_CODING_VERSION" != "$PI_AI_VERSION" ]]; then
35
+ echo "FAIL: Pi Coding Agent and Pi AI host versions must match." >&2
36
+ exit 1
37
+ fi
38
+
39
+ AUDIT_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/piagent-runtime-audit.XXXXXX")"
40
+ cleanup() {
41
+ node --input-type=module - "$AUDIT_ROOT" <<'NODE'
42
+ import fs from "node:fs";
43
+ import os from "node:os";
44
+ import path from "node:path";
45
+
46
+ const target = path.resolve(process.argv[2]);
47
+ const tempRoot = fs.realpathSync(os.tmpdir());
48
+ const targetParent = fs.realpathSync(path.dirname(target));
49
+ if (targetParent !== tempRoot || !/^piagent-runtime-audit\.[A-Za-z0-9]+$/.test(path.basename(target))) {
50
+ throw new Error(`refusing to remove unexpected audit directory: ${target}`);
51
+ }
52
+ fs.rmSync(target, { recursive: true, force: true });
53
+ NODE
54
+ }
55
+ trap cleanup EXIT
56
+
57
+ node --input-type=module - "$AUDIT_ROOT/package.json" <<'NODE'
58
+ import fs from "node:fs";
59
+ const target = process.argv[2];
60
+ fs.writeFileSync(target, `${JSON.stringify({ name: "piagent-runtime-audit", version: "0.0.0", private: true }, null, 2)}\n`);
61
+ NODE
62
+
63
+ echo "Auditing Pi host ${PI_CODING_VERSION} and pinned add-ons at severity high and above..."
64
+ (
65
+ cd "$AUDIT_ROOT"
66
+ npm install --package-lock-only --ignore-scripts --no-audit --no-fund \
67
+ "@earendil-works/pi-coding-agent@${PI_CODING_VERSION}" \
68
+ "@earendil-works/pi-ai@${PI_AI_VERSION}" \
69
+ "typebox@${TYPEBOX_VERSION}" \
70
+ "pi-mcp-adapter@${PI_MCP_ADAPTER_VERSION}" \
71
+ "pi-subagents@${PI_SUBAGENTS_VERSION}" \
72
+ "pi-web-access@${PI_WEB_ACCESS_VERSION}" >/dev/null
73
+ # npm audit exits non-zero when it finds anything, so its status says nothing
74
+ # about whether the finding is one this project has accepted. The policy check
75
+ # decides that, and its exit status is the one that counts.
76
+ npm audit --json > audit.json || true
77
+ node "$ROOT/scripts/check-runtime-advisories.mjs" < audit.json
78
+ )
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ PLATFORM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
+ PI_AGENT_DIR="${PI_CODING_AGENT_DIR:-"${HOME}/.pi/agent"}"
6
+ MCP_CONFIG_DIR="${XDG_CONFIG_HOME:-"${HOME}/.config"}/mcp"
7
+
8
+ mkdir -p "$PI_AGENT_DIR/extensions" "$PI_AGENT_DIR/prompts" "$PI_AGENT_DIR/skills"
9
+ mkdir -p "$MCP_CONFIG_DIR"
10
+
11
+ echo "Pi Agent Platform"
12
+ echo "platform: $PLATFORM_ROOT"
13
+ echo "pi agent dir: $PI_AGENT_DIR"
14
+ echo
15
+ echo "Run these commands when ready:"
16
+ echo
17
+ echo " bash \"$PLATFORM_ROOT/scripts/install-global.sh\" --package-source \"$PLATFORM_ROOT\" --with-mcp --mcp-preset core --with-herdr"
18
+ echo " pi"
19
+ echo " /login"
20
+ echo
21
+ echo "Then link a project:"
22
+ echo
23
+ echo " bash \"$PLATFORM_ROOT/scripts/init-project.sh\" /path/to/project --profile generic --package-source git:github.com/Vt-mmm/piagent@vX.Y.Z"
24
+ echo " cd /path/to/project"
25
+ echo " pi"