@piagent/platform 1.37.1 → 1.38.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.
- package/CHANGELOG.md +47 -0
- package/README.md +5 -3
- package/README.vi.md +2 -2
- package/catalog/capabilities.json +2 -2
- package/docs/command-reference-vietnamese.md +4 -3
- package/docs/distribution-standard.md +6 -6
- package/docs/en/maintainer-guide.md +8 -0
- package/docs/en/workspace-editor.md +222 -0
- package/docs/languages.json +13 -4
- package/docs/operator-manual-vietnamese.md +7 -7
- package/docs/publishing-for-teams.md +2 -0
- package/docs/release-install-policy.md +2 -2
- package/docs/research/ide-m0-spike.md +101 -0
- package/docs/team-onboarding.md +2 -2
- package/docs/vi/maintainer-guide.md +8 -0
- package/docs/vi/workspace-editor.md +217 -0
- package/docs-site/architecture.html +1 -1
- package/docs-site/benchmark.html +1 -1
- package/docs-site/commands.html +1 -1
- package/docs-site/content/en/index.html +4 -4
- package/docs-site/content/en/whats-new.html +17 -0
- package/docs-site/content/index.html +4 -4
- package/docs-site/content/whats-new.html +17 -0
- package/docs-site/context-engine.html +1 -1
- package/docs-site/ecosystem.html +1 -1
- package/docs-site/en/architecture.html +1 -1
- package/docs-site/en/benchmark.html +1 -1
- package/docs-site/en/commands.html +1 -1
- package/docs-site/en/context-engine.html +1 -1
- package/docs-site/en/ecosystem.html +1 -1
- package/docs-site/en/index.html +5 -5
- package/docs-site/en/mcp-approval.html +1 -1
- package/docs-site/en/mcp-auth.html +1 -1
- package/docs-site/en/mcp-servers.html +1 -1
- package/docs-site/en/mcp.html +1 -1
- package/docs-site/en/permissions.html +1 -1
- package/docs-site/en/profiles.html +1 -1
- package/docs-site/en/quickstart.html +1 -1
- package/docs-site/en/runtime.html +1 -1
- package/docs-site/en/scope.html +1 -1
- package/docs-site/en/security.html +1 -1
- package/docs-site/en/team.html +1 -1
- package/docs-site/en/whats-new.html +18 -1
- package/docs-site/en/windows.html +1 -1
- package/docs-site/en/workflows.html +1 -1
- package/docs-site/index.html +5 -5
- package/docs-site/mcp-approval.html +1 -1
- package/docs-site/mcp-auth.html +1 -1
- package/docs-site/mcp-servers.html +1 -1
- package/docs-site/mcp.html +1 -1
- package/docs-site/permissions.html +1 -1
- package/docs-site/profiles.html +1 -1
- package/docs-site/quickstart.html +1 -1
- package/docs-site/runtime.html +1 -1
- package/docs-site/scope.html +1 -1
- package/docs-site/security.html +1 -1
- package/docs-site/team.html +1 -1
- package/docs-site/whats-new.html +18 -1
- package/docs-site/windows.html +1 -1
- package/docs-site/workflows.html +1 -1
- package/evals/fixtures/piagent-webui/checkpoint-v1.invalid.json +21 -0
- package/evals/fixtures/piagent-webui/checkpoint-v1.valid.json +20 -0
- package/evals/fixtures/piagent-webui/terminal-v1.invalid.json +17 -0
- package/evals/fixtures/piagent-webui/terminal-v1.valid.json +16 -0
- package/evals/fixtures/piagent-webui/workspace-file-v1.invalid.json +24 -0
- package/evals/fixtures/piagent-webui/workspace-file-v1.valid.json +23 -0
- package/evals/fixtures/piagent-webui/workspace-paths-v1.invalid.json +24 -0
- package/evals/fixtures/piagent-webui/workspace-paths-v1.valid.json +24 -0
- package/evals/fixtures/piagent-webui/workspace-search-v1.invalid.json +26 -0
- package/evals/fixtures/piagent-webui/workspace-search-v1.valid.json +26 -0
- package/evals/fixtures/piagent-webui/workspace-tree-v1.invalid.json +28 -0
- package/evals/fixtures/piagent-webui/workspace-tree-v1.valid.json +27 -0
- package/evals/fixtures/piagent-webui/workspace-write-v1.invalid.json +19 -0
- package/evals/fixtures/piagent-webui/workspace-write-v1.valid.json +19 -0
- package/evals/long-task-soak-v1/README.md +17 -0
- package/evals/long-task-soak-v1/lib/session-loop.mjs +19 -3
- package/evals/long-task-soak-v1/scenarios/ide-editor-terminal.json +19 -0
- package/evals/long-task-soak-v1/surfaces/webui-gateway.mjs +17 -2
- package/evals/long-task-soak-v1/surfaces/workspace-actions.mjs +95 -0
- package/evals/private-holdout-v1/public-exposure.v2.json +2 -2
- package/package.json +7 -3
- package/packages/piagent-core/extensions/fallback-base-policy.ts +1 -1
- package/packages/piagent-core/extensions/guard-types.ts +3 -1
- package/packages/piagent-core/extensions/path-suggestions.ts +137 -0
- package/packages/piagent-core/extensions/piagent-guard.ts +85 -7
- package/packages/piagent-core/extensions/workspace-inspection.ts +145 -0
- package/packages/piagent-core/extensions/workspace-policy.d.ts +7 -0
- package/packages/piagent-core/extensions/workspace-policy.js +3 -0
- package/packages/piagent-core/extensions/workspace-search-index.mjs +8 -0
- package/packages/piagent-core/extensions/workspace-search.ts +74 -0
- package/packages/piagent-core/extensions/workspace-write.ts +116 -0
- package/packages/piagent-core/managed/background-process.mjs +9 -4
- package/packages/piagent-core/managed/boundary-package-proxy.mjs +21 -0
- package/packages/piagent-core/managed/boundary-queue.mjs +24 -0
- package/packages/piagent-core/managed/checkpoint-git.mjs +16 -0
- package/packages/piagent-core/managed/checkpoints.mjs +17 -64
- package/packages/piagent-core/managed/command-tools.mjs +6 -6
- package/packages/piagent-core/managed/continuation.mjs +3 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/backend-api/profile.json +88 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/be-readonly-fe/profile.json +130 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/data/profile.json +88 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/devops/profile.json +90 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/docs/profile.json +74 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/fullstack/profile.json +92 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/generic/profile.json +95 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/mobile/profile.json +86 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/node-typescript/profile.json +74 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/python/profile.json +75 -0
- package/packages/piagent-core/managed/dist/workspace/assets/adapters/web-frontend/profile.json +99 -0
- package/packages/piagent-core/managed/dist/workspace/assets/local-state-path-BrmghxEZ.js +284 -0
- package/packages/piagent-core/managed/dist/workspace/assets/packages/piagent-core/policies/base-policy.json +351 -0
- package/packages/piagent-core/managed/dist/workspace/manifest.json +65 -0
- package/packages/piagent-core/managed/dist/workspace/worker.mjs +7374 -0
- package/packages/piagent-core/managed/dist/workspace/workspace-search-index.mjs +1007 -0
- package/packages/piagent-core/managed/patch-snapshot.mjs +6 -8
- package/packages/piagent-core/managed/permission.mjs +29 -6
- package/packages/piagent-core/managed/repository-operation.mjs +2 -1
- package/packages/piagent-core/managed/review-snapshot-request.mjs +21 -0
- package/packages/piagent-core/managed/sandbox-diagnostic.mjs +2 -0
- package/packages/piagent-core/managed/session-mutation-observations.mjs +37 -0
- package/packages/piagent-core/managed/session.mjs +2 -2
- package/packages/piagent-core/managed/source-revert-requests.mjs +21 -0
- package/packages/piagent-core/managed/terminal-boundary.mjs +88 -0
- package/packages/piagent-core/managed/terminal-channel.mjs +66 -0
- package/packages/piagent-core/managed/terminal-runtime.mjs +64 -0
- package/packages/piagent-core/managed/terminal-seatbelt.mjs +48 -0
- package/packages/piagent-core/managed/terminal-worker.mjs +70 -0
- package/packages/piagent-core/managed/tool-boundary.mjs +45 -35
- package/packages/piagent-core/managed/tool-freshness.mjs +47 -0
- package/packages/piagent-core/managed/tool-worker.mjs +18 -3
- package/packages/piagent-core/managed/workspace-worker-pins.mjs +26 -0
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-core/policies/base-policy.json +2 -1
- package/packages/piagent-core/runtime/checkpoints/checkpoint-authority.ts +43 -0
- package/packages/piagent-core/runtime/checkpoints/checkpoint-refs.mjs +51 -0
- package/packages/piagent-core/runtime/checkpoints/checkpoint-store.mjs +179 -0
- package/packages/piagent-core/runtime/checkpoints/checkpoint-worker.ts +28 -0
- package/packages/piagent-core/runtime/checkpoints/git-adapter.mjs +36 -0
- package/packages/piagent-core/runtime/checkpoints/persistent-history.mjs +96 -0
- package/packages/piagent-core/runtime/checkpoints/personal-git.ts +272 -0
- package/packages/piagent-core/runtime/checkpoints/personal-runtime.ts +158 -0
- package/packages/piagent-core/runtime/checkpoints/prune.mjs +29 -0
- package/packages/piagent-core/runtime/checkpoints/restore-preview.mjs +46 -0
- package/packages/piagent-core/runtime/checkpoints/turn-checkpoints.mjs +167 -0
- package/packages/piagent-core/runtime/hooks/session-hooks.ts +19 -16
- package/packages/piagent-core/runtime/hooks/session-start-hook.ts +3 -0
- package/packages/piagent-core/runtime/hooks/tool-call-hook.ts +2 -2
- package/packages/piagent-core/runtime/inspection/diff-projection.ts +2 -1
- package/packages/piagent-core/runtime/inspection/managed-source-revert.ts +90 -0
- package/packages/piagent-core/runtime/inspection/review-state-projection.ts +19 -8
- package/packages/piagent-core/runtime/inspection/session-diff-projection.ts +47 -0
- package/packages/piagent-core/runtime/inspection/session-hunk-provenance.ts +56 -0
- package/packages/piagent-core/runtime/inspection/session-mutation-observer.ts +125 -0
- package/packages/piagent-core/runtime/inspection/source-action-contract.ts +123 -0
- package/packages/piagent-core/runtime/inspection/source-change-projection.ts +3 -9
- package/packages/piagent-core/runtime/inspection/source-mutation-projection.ts +3 -41
- package/packages/piagent-core/runtime/inspection/source-mutation-store.ts +6 -36
- package/packages/piagent-core/runtime/inspection/source-revert-projection.ts +36 -30
- package/packages/piagent-core/runtime/inspection/text-diff.ts +5 -4
- package/packages/piagent-core/runtime/inspection/workspace-worker.ts +79 -0
- package/packages/piagent-core/runtime/policy/source-index-transaction.ts +3 -10
- package/packages/piagent-core/runtime/policy/source-mutation-guard-binding.ts +27 -2
- package/packages/piagent-core/runtime/policy/source-mutation-guard.ts +42 -12
- package/packages/piagent-core/runtime/policy/source-worktree-transaction.ts +10 -5
- package/packages/piagent-core/runtime/policy/workspace-write-authority.ts +51 -0
- package/packages/piagent-core/runtime/process-owner.mjs +20 -0
- package/packages/piagent-core/runtime/process-tree-watch.mjs +46 -0
- package/packages/piagent-core/runtime/quality/model-mutation-proof.ts +8 -5
- package/packages/piagent-core/runtime/registration/permission-commands.ts +10 -2
- package/packages/piagent-core/runtime/registration/task-evidence-tools.ts +1 -1
- package/packages/piagent-core/runtime/session/workspace-member-edits.d.mts +7 -0
- package/packages/piagent-core/runtime/session/workspace-member-edits.mjs +41 -0
- package/packages/piagent-core/security/workspace-file-reader.ts +2 -1
- package/packages/piagent-webui/dist/client/assets/Alert-DXF8-XqE.js +1 -0
- package/packages/piagent-webui/dist/client/assets/Button-DZJosXQi.js +1 -0
- package/packages/piagent-webui/dist/client/assets/DialogTitle-CL-fzCnT.js +3 -0
- package/packages/piagent-webui/dist/client/assets/MarkdownMessage-k4tq1y8s.js +29 -0
- package/packages/piagent-webui/dist/client/assets/TerminalPanel-DvOPgrGI.js +2 -0
- package/packages/piagent-webui/dist/client/assets/TerminalView-B_a16moC.js +9 -0
- package/packages/piagent-webui/dist/client/assets/TerminalView-kHJ-D0s7.css +1 -0
- package/packages/piagent-webui/dist/client/assets/Typography-DMZL1kLS.js +1 -0
- package/packages/piagent-webui/dist/client/assets/WorkspaceCodeEditor-BCiYM9NA.js +2 -0
- package/packages/piagent-webui/dist/client/assets/WorkspaceExplorer-DttpQtpf.js +5 -0
- package/packages/piagent-webui/dist/client/assets/WorkspaceQuickOpen-fgXwQ46B.js +1 -0
- package/packages/piagent-webui/dist/client/assets/bootstrap-CedkNtRG.js +1 -0
- package/packages/piagent-webui/dist/client/assets/dist-B1M7IjfA.js +10 -0
- package/packages/piagent-webui/dist/client/assets/dist-BUYtGaUP.js +1 -0
- package/packages/piagent-webui/dist/client/assets/dist-C82AtDDT.js +6 -0
- package/packages/piagent-webui/dist/client/assets/dist-D9b8j6pJ.js +1 -0
- package/packages/piagent-webui/dist/client/assets/dist-DLfpWwLs.js +23 -0
- package/packages/piagent-webui/dist/client/assets/dist-DcEu_WYV.js +1 -0
- package/packages/piagent-webui/dist/client/assets/dist-_JsfplOG.js +9 -0
- package/packages/piagent-webui/dist/client/assets/dist-idN8f9Fc.js +1 -0
- package/packages/piagent-webui/dist/client/assets/dist-nvgpa2Us.js +1 -0
- package/packages/piagent-webui/dist/client/assets/index-BW8-BUMx.js +102 -0
- package/packages/piagent-webui/dist/client/assets/index-Brs_HjIo.css +1 -0
- package/packages/piagent-webui/dist/client/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/packages/piagent-webui/dist/client/assets/tab-close-HE0XxoJf.js +1 -0
- package/packages/piagent-webui/dist/client/assets/ui-preferences-DiddStu0.js +124 -0
- package/packages/piagent-webui/dist/client/assets/useTheme-_ESOj7MI.js +10 -0
- package/packages/piagent-webui/dist/client/assets/workspace-api-O7auv_td.js +1 -0
- package/packages/piagent-webui/dist/client/index.html +10 -2
- package/packages/piagent-webui/extension/same-session-bridge.ts +2 -3
- package/packages/piagent-webui/extension/source-revert-controller.ts +14 -208
- package/packages/piagent-webui/gateway/checkpoint-sessions.ts +99 -0
- package/packages/piagent-webui/gateway/checkpoint-store.ts +6 -0
- package/packages/piagent-webui/gateway/company-relay.ts +5 -0
- package/packages/piagent-webui/gateway/company-terminal-cache.ts +54 -0
- package/packages/piagent-webui/gateway/company-terminal-channel.ts +117 -0
- package/packages/piagent-webui/gateway/company-terminal-relay.ts +75 -0
- package/packages/piagent-webui/gateway/gateway-protocol-service.ts +12 -0
- package/packages/piagent-webui/gateway/gateway-service.ts +48 -4
- package/packages/piagent-webui/gateway/managed-gateway.mjs +30 -3
- package/packages/piagent-webui/gateway/managed-projection.ts +5 -3
- package/packages/piagent-webui/gateway/managed-source-revert-controller.ts +45 -0
- package/packages/piagent-webui/gateway/managed-source-revert-sessions.ts +74 -0
- package/packages/piagent-webui/gateway/managed-terminal-binding.ts +30 -0
- package/packages/piagent-webui/gateway/managed-terminal-processes.ts +74 -0
- package/packages/piagent-webui/gateway/managed-terminal-sessions.ts +9 -0
- package/packages/piagent-webui/gateway/path-suggestions.ts +1 -124
- package/packages/piagent-webui/gateway/personal-terminal-binding.ts +36 -0
- package/packages/piagent-webui/gateway/personal-terminal-diagnostic.mjs +16 -0
- package/packages/piagent-webui/gateway/personal-terminal-processes.ts +119 -0
- package/packages/piagent-webui/gateway/personal-terminal-sessions.ts +22 -0
- package/packages/piagent-webui/gateway/runtime-session-controls.ts +2 -1
- package/packages/piagent-webui/gateway/session-catalog.ts +3 -2
- package/packages/piagent-webui/gateway/session-command-controller.ts +4 -4
- package/packages/piagent-webui/gateway/session-inspection-registry.ts +29 -5
- package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +8 -8
- package/packages/piagent-webui/gateway/signed-session-journal.ts +77 -0
- package/packages/piagent-webui/gateway/source-revert-sessions.ts +74 -0
- package/packages/piagent-webui/gateway/source-revert-store.ts +47 -0
- package/packages/piagent-webui/gateway/terminal-command-ledger.ts +33 -0
- package/packages/piagent-webui/gateway/terminal-mentions.ts +29 -0
- package/packages/piagent-webui/gateway/terminal-output-buffer.ts +58 -0
- package/packages/piagent-webui/gateway/terminal-router.ts +12 -0
- package/packages/piagent-webui/gateway/terminal-sessions.ts +247 -0
- package/packages/piagent-webui/gateway/workspace-write-sessions.ts +69 -0
- package/packages/piagent-webui/gateway/workspace-write-store.ts +6 -0
- package/packages/piagent-webui/package.json +14 -2
- package/packages/piagent-webui/server/checkpoint-command.ts +30 -0
- package/packages/piagent-webui/server/checkpoint-controller.ts +87 -0
- package/packages/piagent-webui/server/checkpoint-routes.ts +38 -0
- package/packages/piagent-webui/server/control-command-digest.ts +5 -0
- package/packages/piagent-webui/server/core-inspection-provider.ts +16 -22
- package/packages/piagent-webui/server/gateway-websocket.ts +36 -8
- package/packages/piagent-webui/server/loopback-server.ts +9 -0
- package/packages/piagent-webui/server/read-model-provider.ts +3 -0
- package/packages/piagent-webui/server/read-only-router.ts +3 -0
- package/packages/piagent-webui/server/session-auth.ts +4 -1
- package/packages/piagent-webui/server/session-source-revert-routes.ts +54 -0
- package/packages/piagent-webui/server/source-projection-binding.ts +18 -0
- package/packages/piagent-webui/server/source-revert-controller.ts +225 -0
- package/packages/piagent-webui/server/terminal-command.ts +35 -0
- package/packages/piagent-webui/server/terminal-websocket-stream.ts +56 -0
- package/packages/piagent-webui/server/transcript-projection.ts +2 -1
- package/packages/piagent-webui/server/workspace-read-routes.ts +32 -0
- package/packages/piagent-webui/server/workspace-reader.ts +23 -0
- package/packages/piagent-webui/server/workspace-write-controller.ts +118 -0
- package/packages/piagent-webui/server/workspace-write-routes.ts +38 -0
- package/packages/piagent-webui/shared/terminal-message.ts +23 -0
- package/schemas/piagent-webui/catalog-v1.json +63 -0
- package/schemas/piagent-webui/checkpoint-v1.schema.json +466 -0
- package/schemas/piagent-webui/control-command-v1.schema.json +68 -3
- package/schemas/piagent-webui/diff-v1.schema.json +4 -0
- package/schemas/piagent-webui/gateway-protocol-v1.schema.json +123 -3
- package/schemas/piagent-webui/session-catalog-v1.schema.json +1 -1
- package/schemas/piagent-webui/session-command-v1.schema.json +1 -1
- package/schemas/piagent-webui/snapshot-v1.schema.json +2 -1
- package/schemas/piagent-webui/source-revert-v1.schema.json +22 -3
- package/schemas/piagent-webui/terminal-v1.schema.json +495 -0
- package/schemas/piagent-webui/workspace-file-v1.schema.json +79 -0
- package/schemas/piagent-webui/workspace-paths-v1.schema.json +71 -0
- package/schemas/piagent-webui/workspace-search-v1.schema.json +80 -0
- package/schemas/piagent-webui/workspace-tree-v1.schema.json +87 -0
- package/schemas/piagent-webui/workspace-write-v1.schema.json +276 -0
- package/schemas/project-profile.schema.json +8 -3
- package/scripts/company-terminal.mjs +16 -11
- package/scripts/pi-auto.sh +5 -1
- package/scripts/team-doctor.sh +8 -0
- package/packages/piagent-webui/dist/client/assets/MarkdownMessage-CfgyQQbW.js +0 -29
- package/packages/piagent-webui/dist/client/assets/index-HyzWKvDu.js +0 -234
- package/packages/piagent-webui/dist/client/assets/index-_0nGP2n3.css +0 -1
package/packages/piagent-core/managed/dist/workspace/assets/adapters/web-frontend/profile.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"projectId": "web-frontend",
|
|
4
|
+
"displayName": "Web Frontend Project",
|
|
5
|
+
"mode": "web-frontend",
|
|
6
|
+
"permissionProfile": "workspace-write",
|
|
7
|
+
"rootMarkers": [
|
|
8
|
+
"AGENTS.md",
|
|
9
|
+
"package.json"
|
|
10
|
+
],
|
|
11
|
+
"protectedPaths": [
|
|
12
|
+
".git/**",
|
|
13
|
+
"**/auth.json",
|
|
14
|
+
"**/.env",
|
|
15
|
+
"**/.env.*",
|
|
16
|
+
"**/node_modules/**",
|
|
17
|
+
"**/dist/**",
|
|
18
|
+
"**/.next/**"
|
|
19
|
+
],
|
|
20
|
+
"requiredContext": [
|
|
21
|
+
"AGENTS.md",
|
|
22
|
+
".pi/project-context.md",
|
|
23
|
+
"README.md",
|
|
24
|
+
"package.json"
|
|
25
|
+
],
|
|
26
|
+
"taskModes": {
|
|
27
|
+
"readOnly": {
|
|
28
|
+
"tools": [
|
|
29
|
+
"read",
|
|
30
|
+
"grep",
|
|
31
|
+
"find",
|
|
32
|
+
"ls"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"sourceWrite": {
|
|
36
|
+
"requiresPlan": true,
|
|
37
|
+
"requiresVerify": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"verifyCommands": {
|
|
41
|
+
"docsOnly": [
|
|
42
|
+
"test -s README.md"
|
|
43
|
+
],
|
|
44
|
+
"source": [
|
|
45
|
+
"node -e \"const s=require('./package.json').scripts||{}; const n=['type-check','typecheck','lint','test']; if(!n.some(k=>s[k])){console.error('No Node source verifier is configured');process.exit(2)}\" && npm run type-check --if-present && npm run typecheck --if-present && npm run lint --if-present && npm test --if-present"
|
|
46
|
+
],
|
|
47
|
+
"runtime": [
|
|
48
|
+
"node -e \"const s=require('./package.json').scripts||{}; if(!s['test:e2e']){console.error('No web frontend runtime verifier is configured');process.exit(2)}\" && npm run test:e2e"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"mcpCapabilities": [
|
|
52
|
+
"filesystem-readonly",
|
|
53
|
+
"filesystem-write",
|
|
54
|
+
"shell",
|
|
55
|
+
"github",
|
|
56
|
+
"browser",
|
|
57
|
+
"memory"
|
|
58
|
+
],
|
|
59
|
+
"capabilityPacks": [
|
|
60
|
+
{
|
|
61
|
+
"name": "web-delivery",
|
|
62
|
+
"version": "0.1.1"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"capabilityPolicy": {
|
|
66
|
+
"allowedOwners": [
|
|
67
|
+
"platform-maintainers"
|
|
68
|
+
],
|
|
69
|
+
"allowedLifecycles": [
|
|
70
|
+
"experimental"
|
|
71
|
+
],
|
|
72
|
+
"allowedFilesystemRead": [
|
|
73
|
+
"**/*"
|
|
74
|
+
],
|
|
75
|
+
"allowedFilesystemWrite": [
|
|
76
|
+
"**/*"
|
|
77
|
+
],
|
|
78
|
+
"allowedNetworkDomains": [],
|
|
79
|
+
"allowedExternalActions": []
|
|
80
|
+
},
|
|
81
|
+
"memory": {
|
|
82
|
+
"enabled": true,
|
|
83
|
+
"mode": "manual",
|
|
84
|
+
"scope": "project",
|
|
85
|
+
"summaryFile": ".pi/memory/memory_summary.md",
|
|
86
|
+
"handbookFile": ".pi/memory/MEMORY.md",
|
|
87
|
+
"localDir": ".pi/memory/local",
|
|
88
|
+
"readBeforeTask": true,
|
|
89
|
+
"writePolicy": "explicit-only",
|
|
90
|
+
"maxInjectedChars": 4000,
|
|
91
|
+
"externalPackages": []
|
|
92
|
+
},
|
|
93
|
+
"runtimePolicy": {
|
|
94
|
+
"execPolicy": "enforce",
|
|
95
|
+
"contextBudget": "enforce",
|
|
96
|
+
"toolRegistry": "advisory",
|
|
97
|
+
"finalGate": "enforce"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import "node:child_process";
|
|
5
|
+
//#region ../piagent-core/capabilities/project-profile.js
|
|
6
|
+
var ADAPTER_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
7
|
+
var ProjectProfileError = class extends Error {};
|
|
8
|
+
function adapterProfileFile(platformRoot, name) {
|
|
9
|
+
if (typeof name !== "string") return void 0;
|
|
10
|
+
const trimmed = name.trim();
|
|
11
|
+
if (!ADAPTER_NAME.test(trimmed)) return void 0;
|
|
12
|
+
const candidate = path.join(platformRoot, "adapters", trimmed, "profile.json");
|
|
13
|
+
return fs.existsSync(candidate) ? candidate : void 0;
|
|
14
|
+
}
|
|
15
|
+
function readJson(file) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
18
|
+
} catch {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a stored project profile document against the installed adapters.
|
|
24
|
+
* Returns the document to enforce, plus the adapter it came from when one was
|
|
25
|
+
* named. Any key the project states replaces the adapter's key whole — there is
|
|
26
|
+
* no per-entry merging of lists, because a half-merged protectedPaths is harder
|
|
27
|
+
* to reason about than a stated one.
|
|
28
|
+
*/
|
|
29
|
+
function resolveProjectProfileDocument(platformRoot, stored) {
|
|
30
|
+
if (!stored || typeof stored !== "object" || Array.isArray(stored)) return {
|
|
31
|
+
profile: stored,
|
|
32
|
+
base: void 0
|
|
33
|
+
};
|
|
34
|
+
if (stored.extends === void 0) return {
|
|
35
|
+
profile: stored,
|
|
36
|
+
base: void 0
|
|
37
|
+
};
|
|
38
|
+
const file = adapterProfileFile(platformRoot, stored.extends);
|
|
39
|
+
if (!file) throw new ProjectProfileError(`project profile extends "${String(stored.extends)}", which is not an adapter in the installed platform`);
|
|
40
|
+
const adapter = readJson(file);
|
|
41
|
+
if (!adapter) throw new ProjectProfileError(`adapter profile is unreadable: ${file}`);
|
|
42
|
+
const { extends: base, ...overrides } = stored;
|
|
43
|
+
return {
|
|
44
|
+
profile: {
|
|
45
|
+
...adapter,
|
|
46
|
+
...overrides
|
|
47
|
+
},
|
|
48
|
+
base
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../piagent-core/extensions/workspace-evidence-roots.js
|
|
53
|
+
var WORKSPACE_PRIVATE_STATE_PATTERNS = Object.freeze([
|
|
54
|
+
"**/.git/**",
|
|
55
|
+
"**/.hg/**",
|
|
56
|
+
"**/.svn/**",
|
|
57
|
+
"**/.pi/**",
|
|
58
|
+
"**/.aws/**",
|
|
59
|
+
"**/.azure/**",
|
|
60
|
+
"**/.docker/**",
|
|
61
|
+
"**/.gnupg/**",
|
|
62
|
+
"**/.kube/**",
|
|
63
|
+
"**/.ssh/**",
|
|
64
|
+
"**/.git-credentials",
|
|
65
|
+
"**/.netrc",
|
|
66
|
+
"**/.npmrc",
|
|
67
|
+
"**/.pypirc",
|
|
68
|
+
"**/.env",
|
|
69
|
+
"**/.env.*",
|
|
70
|
+
"**/auth.json",
|
|
71
|
+
"**/credential.json",
|
|
72
|
+
"**/credentials.json",
|
|
73
|
+
"**/secret.json",
|
|
74
|
+
"**/secrets.json",
|
|
75
|
+
"**/token.json",
|
|
76
|
+
"**/tokens.json"
|
|
77
|
+
]);
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region ../piagent-core/extensions/context-index-policy.js
|
|
80
|
+
var DEFAULT_CONTEXT_INDEX_PATH = ".pi/context-index.json";
|
|
81
|
+
var CONTEXT_ENGINE_STATE_PATTERN = ".pi/piagent-state/**";
|
|
82
|
+
var EXCLUDE_POLICY_VERSION = 2;
|
|
83
|
+
function stringArray(value) {
|
|
84
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item.trim().length > 0) : [];
|
|
85
|
+
}
|
|
86
|
+
function uniqueStrings(values) {
|
|
87
|
+
return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
88
|
+
}
|
|
89
|
+
function compareCodePoints(left, right) {
|
|
90
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
91
|
+
}
|
|
92
|
+
function normalizePattern(value) {
|
|
93
|
+
return String(value ?? "").trim().replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/+/g, "/");
|
|
94
|
+
}
|
|
95
|
+
function readJsonObject(file, label, { optional = false } = {}) {
|
|
96
|
+
if (!fs.existsSync(file)) {
|
|
97
|
+
if (optional) return void 0;
|
|
98
|
+
throw new Error(`${label} is missing at ${file}`);
|
|
99
|
+
}
|
|
100
|
+
let parsed;
|
|
101
|
+
try {
|
|
102
|
+
parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
103
|
+
} catch {
|
|
104
|
+
throw new Error(`${label} is not valid JSON: ${file}`);
|
|
105
|
+
}
|
|
106
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${label} must contain a JSON object: ${file}`);
|
|
107
|
+
return parsed;
|
|
108
|
+
}
|
|
109
|
+
function contextIndexStatePath(profile) {
|
|
110
|
+
const configured = profile?.contextIndex?.path;
|
|
111
|
+
return typeof configured === "string" && configured.trim() ? configured.trim() : DEFAULT_CONTEXT_INDEX_PATH;
|
|
112
|
+
}
|
|
113
|
+
function effectiveProtectedPaths(policy = {}, profile = {}) {
|
|
114
|
+
const policyProtectedPaths = stringArray(policy.protectedPaths);
|
|
115
|
+
const baseReadProtectedPaths = Array.isArray(policy.shellProtectedPaths) ? stringArray(policy.shellProtectedPaths) : policyProtectedPaths;
|
|
116
|
+
const profileProtectedPaths = stringArray(profile.protectedPaths);
|
|
117
|
+
const profileShellProtectedPaths = Array.isArray(profile.shellProtectedPaths) ? stringArray(profile.shellProtectedPaths) : profileProtectedPaths;
|
|
118
|
+
const readOnlyPaths = stringArray(profile.readOnlyPaths);
|
|
119
|
+
const contextIndexPath = contextIndexStatePath(profile);
|
|
120
|
+
return {
|
|
121
|
+
readProtectedPaths: uniqueStrings([
|
|
122
|
+
...WORKSPACE_PRIVATE_STATE_PATTERNS,
|
|
123
|
+
...baseReadProtectedPaths,
|
|
124
|
+
...profileProtectedPaths,
|
|
125
|
+
contextIndexPath
|
|
126
|
+
]),
|
|
127
|
+
writeProtectedPaths: uniqueStrings([
|
|
128
|
+
...WORKSPACE_PRIVATE_STATE_PATTERNS,
|
|
129
|
+
...policyProtectedPaths,
|
|
130
|
+
...profileProtectedPaths,
|
|
131
|
+
...readOnlyPaths,
|
|
132
|
+
contextIndexPath
|
|
133
|
+
]),
|
|
134
|
+
shellProtectedPaths: uniqueStrings([
|
|
135
|
+
...WORKSPACE_PRIVATE_STATE_PATTERNS,
|
|
136
|
+
...baseReadProtectedPaths,
|
|
137
|
+
...profileShellProtectedPaths,
|
|
138
|
+
...readOnlyPaths,
|
|
139
|
+
contextIndexPath
|
|
140
|
+
]),
|
|
141
|
+
readOnlyPaths: uniqueStrings(readOnlyPaths)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function normalizeContextIndexExcludePatterns(patterns) {
|
|
145
|
+
return uniqueStrings(stringArray(patterns).map(normalizePattern)).sort(compareCodePoints);
|
|
146
|
+
}
|
|
147
|
+
function contextIndexExcludePatterns(policy, profile) {
|
|
148
|
+
const effective = effectiveProtectedPaths(policy, profile);
|
|
149
|
+
return normalizeContextIndexExcludePatterns([
|
|
150
|
+
...effective.readProtectedPaths,
|
|
151
|
+
...effective.writeProtectedPaths,
|
|
152
|
+
...effective.shellProtectedPaths,
|
|
153
|
+
CONTEXT_ENGINE_STATE_PATTERN
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
function contextIndexExcludeDigest(patterns) {
|
|
157
|
+
return crypto.createHash("sha256").update(JSON.stringify({
|
|
158
|
+
version: EXCLUDE_POLICY_VERSION,
|
|
159
|
+
patterns: normalizeContextIndexExcludePatterns(patterns)
|
|
160
|
+
})).digest("hex");
|
|
161
|
+
}
|
|
162
|
+
function loadProjectContextIndexPolicy(platformRoot, projectPath, options = {}) {
|
|
163
|
+
const policy = readJsonObject(path.join(platformRoot, "packages", "piagent-core", "policies", "base-policy.json"), "Piagent base policy");
|
|
164
|
+
const explicitProfilePath = typeof options.profilePath === "string" && options.profilePath.trim() ? path.resolve(options.profilePath) : void 0;
|
|
165
|
+
const profilePath = explicitProfilePath ?? path.join(projectPath, ".pi", "piagent-profile.json");
|
|
166
|
+
const stored = readJsonObject(profilePath, "Piagent project profile", { optional: !explicitProfilePath });
|
|
167
|
+
const profile = stored ? resolveProjectProfileDocument(platformRoot, stored).profile : {};
|
|
168
|
+
return {
|
|
169
|
+
policy,
|
|
170
|
+
profile,
|
|
171
|
+
profilePath,
|
|
172
|
+
profileSource: explicitProfilePath ? "env" : stored ? "project" : "fallback",
|
|
173
|
+
excludePatterns: contextIndexExcludePatterns(policy, profile)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region ../piagent-core/extensions/policy-core.js
|
|
178
|
+
function escapeRegex(value) {
|
|
179
|
+
return value.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
180
|
+
}
|
|
181
|
+
function normalizePathCandidate(candidate) {
|
|
182
|
+
if (typeof candidate !== "string") return "";
|
|
183
|
+
const raw = candidate.trim().replace(/^['"]|['"]$/g, "");
|
|
184
|
+
if (/^\/+$/.test(raw)) return "/";
|
|
185
|
+
return raw.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/").replace(/\/$/, "");
|
|
186
|
+
}
|
|
187
|
+
function segmentMatches(patternSegment, candidateSegment) {
|
|
188
|
+
if (patternSegment === "*") return candidateSegment.length > 0;
|
|
189
|
+
return new RegExp(`^${escapeRegex(patternSegment).replace(/\*/g, "[^/]*")}$`).test(candidateSegment);
|
|
190
|
+
}
|
|
191
|
+
function globMatchesPath(pattern, candidate) {
|
|
192
|
+
const normalizedPattern = normalizePathCandidate(pattern);
|
|
193
|
+
const normalizedCandidate = normalizePathCandidate(candidate);
|
|
194
|
+
if (!normalizedPattern || !normalizedCandidate) return false;
|
|
195
|
+
const patternSegments = normalizedPattern.split("/").filter(Boolean);
|
|
196
|
+
const candidateSegments = normalizedCandidate.split("/").filter(Boolean);
|
|
197
|
+
function match(patternIndex, candidateIndex) {
|
|
198
|
+
if (patternIndex === patternSegments.length) return candidateIndex === candidateSegments.length;
|
|
199
|
+
const patternSegment = patternSegments[patternIndex];
|
|
200
|
+
if (patternSegment === "**") {
|
|
201
|
+
if (match(patternIndex + 1, candidateIndex)) return true;
|
|
202
|
+
for (let nextCandidate = candidateIndex; nextCandidate < candidateSegments.length; nextCandidate += 1) if (match(patternIndex + 1, nextCandidate + 1)) return true;
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (candidateIndex >= candidateSegments.length) return false;
|
|
206
|
+
if (!segmentMatches(patternSegment, candidateSegments[candidateIndex])) return false;
|
|
207
|
+
return match(patternIndex + 1, candidateIndex + 1);
|
|
208
|
+
}
|
|
209
|
+
return match(0, 0);
|
|
210
|
+
}
|
|
211
|
+
function matchesProtectedPath(candidate, patterns) {
|
|
212
|
+
const normalizedCandidate = normalizePathCandidate(candidate).toLocaleLowerCase("en-US");
|
|
213
|
+
if (!normalizedCandidate) return void 0;
|
|
214
|
+
return patterns.find((pattern) => {
|
|
215
|
+
const normalizedPattern = normalizePathCandidate(pattern).toLocaleLowerCase("en-US");
|
|
216
|
+
if (globMatchesPath(normalizedPattern, normalizedCandidate)) return true;
|
|
217
|
+
if (normalizedPattern.endsWith("/**")) return globMatchesPath(normalizedPattern.slice(0, -3), normalizedCandidate);
|
|
218
|
+
return false;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region ../piagent-core/extensions/local-state-path.js
|
|
223
|
+
function statePathError(label, reason) {
|
|
224
|
+
return /* @__PURE__ */ new Error(`${label} ${reason}`);
|
|
225
|
+
}
|
|
226
|
+
function resolveLocalStatePath(projectRoot, target, options = {}) {
|
|
227
|
+
const label = options.label ?? "Local state path";
|
|
228
|
+
const lexicalRoot = path.resolve(projectRoot);
|
|
229
|
+
const absoluteTarget = path.resolve(target);
|
|
230
|
+
const canonicalRoot = fs.realpathSync.native(lexicalRoot);
|
|
231
|
+
let relative = path.relative(lexicalRoot, absoluteTarget);
|
|
232
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) relative = path.relative(canonicalRoot, absoluteTarget);
|
|
233
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) throw statePathError(label, "must stay inside the project");
|
|
234
|
+
const segments = relative.split(path.sep).filter(Boolean);
|
|
235
|
+
let current = canonicalRoot;
|
|
236
|
+
for (let index = 0; index < segments.length; index += 1) {
|
|
237
|
+
current = path.join(current, segments[index]);
|
|
238
|
+
let stat;
|
|
239
|
+
try {
|
|
240
|
+
stat = fs.lstatSync(current);
|
|
241
|
+
} catch (error) {
|
|
242
|
+
if (error?.code === "ENOENT") return path.join(canonicalRoot, ...segments);
|
|
243
|
+
throw error;
|
|
244
|
+
}
|
|
245
|
+
if (stat.isSymbolicLink()) throw statePathError(label, `must not traverse a symbolic link (${segments.slice(0, index + 1).join("/")})`);
|
|
246
|
+
const final = index === segments.length - 1;
|
|
247
|
+
if (!final && !stat.isDirectory()) throw statePathError(label, `has a non-directory ancestor (${segments.slice(0, index + 1).join("/")})`);
|
|
248
|
+
if (final && options.kind === "directory" && !stat.isDirectory()) throw statePathError(label, "must be a directory");
|
|
249
|
+
if (final && options.kind === "file" && !stat.isFile()) throw statePathError(label, "must be a regular file");
|
|
250
|
+
}
|
|
251
|
+
return path.join(canonicalRoot, ...segments);
|
|
252
|
+
}
|
|
253
|
+
var STATE_ROOT_IGNORE = "# Piagent runtime state: local only, never committed.\n*\n";
|
|
254
|
+
function ensureStateRootIgnored(projectRoot) {
|
|
255
|
+
try {
|
|
256
|
+
const root = resolveLocalStatePath(projectRoot, path.join(projectRoot, ".pi", "piagent-state"), { label: "Piagent state root" });
|
|
257
|
+
fs.mkdirSync(root, {
|
|
258
|
+
recursive: true,
|
|
259
|
+
mode: 448
|
|
260
|
+
});
|
|
261
|
+
fs.writeFileSync(path.join(root, ".gitignore"), STATE_ROOT_IGNORE, {
|
|
262
|
+
flag: "wx",
|
|
263
|
+
mode: 384
|
|
264
|
+
});
|
|
265
|
+
} catch {}
|
|
266
|
+
}
|
|
267
|
+
function ensurePrivateStateDirectory(projectRoot, directory, label = "Local state directory") {
|
|
268
|
+
const target = resolveLocalStatePath(projectRoot, directory, { label });
|
|
269
|
+
fs.mkdirSync(target, {
|
|
270
|
+
recursive: true,
|
|
271
|
+
mode: 448
|
|
272
|
+
});
|
|
273
|
+
if (path.relative(path.join(fs.realpathSync.native(path.resolve(projectRoot)), ".pi", "piagent-state"), target).split(path.sep)[0] !== "..") ensureStateRootIgnored(projectRoot);
|
|
274
|
+
const verified = resolveLocalStatePath(projectRoot, directory, {
|
|
275
|
+
label,
|
|
276
|
+
kind: "directory"
|
|
277
|
+
});
|
|
278
|
+
try {
|
|
279
|
+
fs.chmodSync(verified, 448);
|
|
280
|
+
} catch {}
|
|
281
|
+
return verified;
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
export { effectiveProtectedPaths as a, contextIndexExcludeDigest as i, resolveLocalStatePath as n, loadProjectContextIndexPolicy as o, matchesProtectedPath as r, normalizeContextIndexExcludePatterns as s, ensurePrivateStateDirectory as t };
|