@zihanw/pi-forge 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -1
- package/README.md +11 -11
- package/README.zh-CN.md +4 -6
- package/SUBAGENT_ADAPTER_CONTRACT.md +3 -1
- package/dist/agent-profile.d.ts +21 -42
- package/dist/agent-profile.d.ts.map +1 -1
- package/dist/agent-profile.js +82 -194
- package/dist/agent-profile.js.map +1 -1
- package/dist/catalog.d.ts +27 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +59 -0
- package/dist/catalog.js.map +1 -0
- package/dist/codecs/agent-profile.d.ts +53 -0
- package/dist/codecs/agent-profile.d.ts.map +1 -0
- package/dist/codecs/agent-profile.js +176 -0
- package/dist/codecs/agent-profile.js.map +1 -0
- package/dist/codecs/index.d.ts +5 -0
- package/dist/codecs/index.d.ts.map +1 -0
- package/dist/codecs/index.js +3 -0
- package/dist/codecs/index.js.map +1 -0
- package/dist/codecs/prompt-stack.d.ts +18 -0
- package/dist/codecs/prompt-stack.d.ts.map +1 -0
- package/dist/codecs/prompt-stack.js +479 -0
- package/dist/codecs/prompt-stack.js.map +1 -0
- package/dist/compile-cycle.d.ts +18 -0
- package/dist/compile-cycle.d.ts.map +1 -0
- package/dist/compile-cycle.js +13 -0
- package/dist/compile-cycle.js.map +1 -0
- package/dist/compiler.d.ts +10 -4
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +53 -19
- package/dist/compiler.js.map +1 -1
- package/dist/extension-registry.d.ts.map +1 -1
- package/dist/extension-registry.js +5 -2
- package/dist/extension-registry.js.map +1 -1
- package/dist/forge-config.d.ts +2 -81
- package/dist/forge-config.d.ts.map +1 -1
- package/dist/forge-config.js +5 -280
- package/dist/forge-config.js.map +1 -1
- package/dist/forge-v1/analyzer.d.ts +3 -0
- package/dist/forge-v1/analyzer.d.ts.map +1 -0
- package/dist/forge-v1/analyzer.js +50 -0
- package/dist/forge-v1/analyzer.js.map +1 -0
- package/dist/forge-v1/index.d.ts +6 -0
- package/dist/forge-v1/index.d.ts.map +1 -0
- package/dist/forge-v1/index.js +13 -0
- package/dist/forge-v1/index.js.map +1 -0
- package/dist/forge-v1/parser.d.ts +3 -0
- package/dist/forge-v1/parser.d.ts.map +1 -0
- package/dist/forge-v1/parser.js +186 -0
- package/dist/forge-v1/parser.js.map +1 -0
- package/dist/forge-v1/renderer.d.ts +9 -0
- package/dist/forge-v1/renderer.d.ts.map +1 -0
- package/dist/forge-v1/renderer.js +181 -0
- package/dist/forge-v1/renderer.js.map +1 -0
- package/dist/forge-v1/types.d.ts +87 -0
- package/dist/forge-v1/types.d.ts.map +1 -0
- package/dist/forge-v1/types.js +4 -0
- package/dist/forge-v1/types.js.map +1 -0
- package/dist/index.d.ts +12 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -59
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.d.ts +7 -5
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +44 -110
- package/dist/lifecycle.js.map +1 -1
- package/dist/loader.d.ts +16 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +42 -440
- package/dist/loader.js.map +1 -1
- package/dist/macro-engine.d.ts +9 -14
- package/dist/macro-engine.d.ts.map +1 -1
- package/dist/macro-engine.js +5 -238
- package/dist/macro-engine.js.map +1 -1
- package/dist/payload-command.d.ts +6 -6
- package/dist/payload-command.d.ts.map +1 -1
- package/dist/payload-command.js.map +1 -1
- package/dist/payload-state.d.ts +16 -0
- package/dist/payload-state.d.ts.map +1 -0
- package/dist/payload-state.js +14 -0
- package/dist/payload-state.js.map +1 -0
- package/dist/preset-command.d.ts +4 -4
- package/dist/preset-command.d.ts.map +1 -1
- package/dist/preset-command.js +55 -98
- package/dist/preset-command.js.map +1 -1
- package/dist/preview.d.ts +4 -4
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +17 -8
- package/dist/preview.js.map +1 -1
- package/dist/profile-command.d.ts +2 -2
- package/dist/profile-command.d.ts.map +1 -1
- package/dist/profile-command.js +52 -26
- package/dist/profile-command.js.map +1 -1
- package/dist/profile-service.d.ts +5 -2
- package/dist/profile-service.d.ts.map +1 -1
- package/dist/profile-service.js +63 -42
- package/dist/profile-service.js.map +1 -1
- package/dist/prompt-analysis.d.ts +24 -0
- package/dist/prompt-analysis.d.ts.map +1 -0
- package/dist/prompt-analysis.js +84 -0
- package/dist/prompt-analysis.js.map +1 -0
- package/dist/prompt-runtime.d.ts +19 -0
- package/dist/prompt-runtime.d.ts.map +1 -0
- package/dist/prompt-runtime.js +30 -0
- package/dist/prompt-runtime.js.map +1 -0
- package/dist/regex.js +6 -12
- package/dist/regex.js.map +1 -1
- package/dist/render-helpers.d.ts +2 -10
- package/dist/render-helpers.d.ts.map +1 -1
- package/dist/render-helpers.js +3 -53
- package/dist/render-helpers.js.map +1 -1
- package/dist/repositories/agent-profile.d.ts +36 -0
- package/dist/repositories/agent-profile.d.ts.map +1 -0
- package/dist/repositories/agent-profile.js +153 -0
- package/dist/repositories/agent-profile.js.map +1 -0
- package/dist/repositories/index.d.ts +3 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +3 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/prompt-stack.d.ts +57 -0
- package/dist/repositories/prompt-stack.d.ts.map +1 -0
- package/dist/repositories/prompt-stack.js +175 -0
- package/dist/repositories/prompt-stack.js.map +1 -0
- package/dist/resource-identity.d.ts +33 -0
- package/dist/resource-identity.d.ts.map +1 -0
- package/dist/resource-identity.js +56 -0
- package/dist/resource-identity.js.map +1 -0
- package/dist/runtime/profile-runtime.d.ts +2 -2
- package/dist/runtime/profile-runtime.d.ts.map +1 -1
- package/dist/runtime/profile-runtime.js +18 -10
- package/dist/runtime/profile-runtime.js.map +1 -1
- package/dist/runtime/prompt-stack-runtime.d.ts +5 -4
- package/dist/runtime/prompt-stack-runtime.d.ts.map +1 -1
- package/dist/runtime/prompt-stack-runtime.js +47 -52
- package/dist/runtime/prompt-stack-runtime.js.map +1 -1
- package/dist/runtime/tool-policy-runtime.d.ts +2 -2
- package/dist/runtime/tool-policy-runtime.d.ts.map +1 -1
- package/dist/runtime/tool-policy-runtime.js +3 -3
- package/dist/runtime/tool-policy-runtime.js.map +1 -1
- package/dist/session-adapter.d.ts +17 -0
- package/dist/session-adapter.d.ts.map +1 -0
- package/dist/session-adapter.js +57 -0
- package/dist/session-adapter.js.map +1 -0
- package/dist/slot-renderers.d.ts +16 -3
- package/dist/slot-renderers.d.ts.map +1 -1
- package/dist/slot-renderers.js +15 -63
- package/dist/slot-renderers.js.map +1 -1
- package/dist/stack-migration.d.ts +6 -0
- package/dist/stack-migration.d.ts.map +1 -1
- package/dist/stack-migration.js +49 -52
- package/dist/stack-migration.js.map +1 -1
- package/dist/storage.d.ts +10 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +45 -10
- package/dist/storage.js.map +1 -1
- package/dist/subagent/fingerprints.d.ts +24 -0
- package/dist/subagent/fingerprints.d.ts.map +1 -0
- package/dist/subagent/fingerprints.js +81 -0
- package/dist/subagent/fingerprints.js.map +1 -0
- package/dist/subagent/host-port.d.ts +296 -0
- package/dist/subagent/host-port.d.ts.map +1 -0
- package/dist/subagent/host-port.js +560 -0
- package/dist/subagent/host-port.js.map +1 -0
- package/dist/subagent/index.d.ts +10 -10
- package/dist/subagent/index.d.ts.map +1 -1
- package/dist/subagent/index.js +9 -10
- package/dist/subagent/index.js.map +1 -1
- package/dist/subagent-host.d.ts +99 -18
- package/dist/subagent-host.d.ts.map +1 -1
- package/dist/subagent-host.js +185 -162
- package/dist/subagent-host.js.map +1 -1
- package/dist/template-render.d.ts +18 -0
- package/dist/template-render.d.ts.map +1 -0
- package/dist/template-render.js +232 -0
- package/dist/template-render.js.map +1 -0
- package/dist/types.d.ts +43 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/web-editor/client-script.generated.d.ts.map +1 -1
- package/dist/web-editor/client-script.generated.js +1 -1
- package/dist/web-editor/client-script.generated.js.map +1 -1
- package/dist/web-editor/client-styles.generated.d.ts.map +1 -1
- package/dist/web-editor/client-styles.generated.js +1 -1
- package/dist/web-editor/client-styles.generated.js.map +1 -1
- package/dist/web-editor/server.d.ts.map +1 -1
- package/dist/web-editor/server.js +32 -72
- package/dist/web-editor/server.js.map +1 -1
- package/dist/web-editor/styles.d.ts.map +1 -1
- package/dist/web-editor/styles.js +13 -0
- package/dist/web-editor/styles.js.map +1 -1
- package/dist/web-editor/types.d.ts +10 -37
- package/dist/web-editor/types.d.ts.map +1 -1
- package/dist/web-host.d.ts +4 -2
- package/dist/web-host.d.ts.map +1 -1
- package/dist/web-host.js +110 -138
- package/dist/web-host.js.map +1 -1
- package/dist/workspace.d.ts +74 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +351 -0
- package/dist/workspace.js.map +1 -0
- package/docs/README.md +6 -4
- package/docs/concepts/agent-profiles.md +2 -2
- package/docs/concepts/prompt-stacks.md +12 -7
- package/docs/design/README.md +21 -3
- package/docs/design/architecture-0.5.md +211 -0
- package/docs/design/archive/0.5-full-proposal/0.5-consumer-audit.md +62 -0
- package/docs/design/archive/0.5-full-proposal/0.5-inventory.md +208 -0
- package/docs/design/archive/0.5-full-proposal/0.5-phase0-decision-drafts.md +237 -0
- package/docs/design/archive/0.5-full-proposal/README.md +12 -0
- package/docs/design/archive/0.5-full-proposal/architecture-0.5.md +423 -0
- package/docs/design/archive/0.5-full-proposal/host-discovery-spike.md +103 -0
- package/docs/design/archive/0.5-full-proposal/template-language-spike.md +156 -0
- package/docs/design/context-diff-plan.md +72 -0
- package/docs/design/decision-template.md +33 -0
- package/docs/design/roadmap-0.4-archive.md +1 -1
- package/docs/design/subagents/interface-design.md +1 -1
- package/docs/development/architecture-rules.md +148 -0
- package/docs/development/roadmap.md +39 -13
- package/docs/development/scoped-global-profiles-stacks.md +325 -0
- package/docs/development/setup.md +6 -4
- package/docs/getting-started.md +9 -6
- package/docs/guides/custom-macros-and-slots.md +8 -7
- package/docs/guides/debugging.md +1 -1
- package/docs/guides/delegation.md +25 -21
- package/docs/guides/migrating-to-0.5.md +107 -0
- package/docs/guides/use-cases.md +7 -11
- package/docs/guides/web-editor.md +7 -11
- package/docs/reference/commands.md +4 -3
- package/docs/reference/configuration.md +18 -17
- package/docs/reference/features.md +34 -79
- package/docs/reference/macros-and-slots.md +70 -49
- package/docs/reference/public-api.md +64 -17
- package/docs/reference/stack-schema.md +14 -9
- package/docs/reference/subagent-host-port.md +49 -0
- package/docs/zh-CN/README.md +3 -3
- package/docs/zh-CN/concepts/agent-profiles.md +4 -2
- package/docs/zh-CN/concepts/prompt-stacks.md +9 -7
- package/docs/zh-CN/getting-started.md +10 -7
- package/docs/zh-CN/guides/delegation.md +11 -13
- package/docs/zh-CN/guides/migrating-to-0.5.md +92 -0
- package/docs/zh-CN/guides/web-editor.md +7 -7
- package/docs/zh-CN/reference/commands.md +6 -3
- package/examples/custom-system-status-extension/README.md +3 -3
- package/examples/custom-system-status-extension/index.ts +2 -1
- package/examples/custom-system-status-extension/prompt-stack.json +4 -3
- package/examples/default-prompt-stack.json +9 -4
- package/examples/image-reader-prompt-stack.json +16 -26
- package/examples/reviewer-prompt-stack.json +13 -24
- package/package.json +101 -120
- package/dist/runtime/subagent-runtime.d.ts +0 -45
- package/dist/runtime/subagent-runtime.d.ts.map +0 -1
- package/dist/runtime/subagent-runtime.js +0 -335
- package/dist/runtime/subagent-runtime.js.map +0 -1
- package/dist/runtime-state.d.ts +0 -30
- package/dist/runtime-state.d.ts.map +0 -1
- package/dist/runtime-state.js +0 -17
- package/dist/runtime-state.js.map +0 -1
- package/dist/sillytavern-importer/items.d.ts +0 -3
- package/dist/sillytavern-importer/items.d.ts.map +0 -1
- package/dist/sillytavern-importer/items.js +0 -88
- package/dist/sillytavern-importer/items.js.map +0 -1
- package/dist/sillytavern-importer/macros.d.ts +0 -15
- package/dist/sillytavern-importer/macros.d.ts.map +0 -1
- package/dist/sillytavern-importer/macros.js +0 -141
- package/dist/sillytavern-importer/macros.js.map +0 -1
- package/dist/sillytavern-importer/prompt-order.d.ts +0 -6
- package/dist/sillytavern-importer/prompt-order.d.ts.map +0 -1
- package/dist/sillytavern-importer/prompt-order.js +0 -38
- package/dist/sillytavern-importer/prompt-order.js.map +0 -1
- package/dist/sillytavern-importer/regex.d.ts +0 -3
- package/dist/sillytavern-importer/regex.d.ts.map +0 -1
- package/dist/sillytavern-importer/regex.js +0 -275
- package/dist/sillytavern-importer/regex.js.map +0 -1
- package/dist/sillytavern-importer/report.d.ts +0 -21
- package/dist/sillytavern-importer/report.d.ts.map +0 -1
- package/dist/sillytavern-importer/report.js +0 -166
- package/dist/sillytavern-importer/report.js.map +0 -1
- package/dist/sillytavern-importer/types.d.ts +0 -106
- package/dist/sillytavern-importer/types.d.ts.map +0 -1
- package/dist/sillytavern-importer/types.js +0 -2
- package/dist/sillytavern-importer/types.js.map +0 -1
- package/dist/sillytavern-importer.d.ts +0 -5
- package/dist/sillytavern-importer.d.ts.map +0 -1
- package/dist/sillytavern-importer.js +0 -117
- package/dist/sillytavern-importer.js.map +0 -1
- package/dist/subagent/canonical.d.ts +0 -22
- package/dist/subagent/canonical.d.ts.map +0 -1
- package/dist/subagent/canonical.js +0 -24
- package/dist/subagent/canonical.js.map +0 -1
- package/dist/subagent/context.d.ts +0 -8
- package/dist/subagent/context.d.ts.map +0 -1
- package/dist/subagent/context.js +0 -125
- package/dist/subagent/context.js.map +0 -1
- package/dist/subagent/contract.d.ts +0 -10
- package/dist/subagent/contract.d.ts.map +0 -1
- package/dist/subagent/contract.js +0 -10
- package/dist/subagent/contract.js.map +0 -1
- package/dist/subagent/plan.d.ts +0 -18
- package/dist/subagent/plan.d.ts.map +0 -1
- package/dist/subagent/plan.js +0 -157
- package/dist/subagent/plan.js.map +0 -1
- package/dist/subagent/preflight.d.ts +0 -4
- package/dist/subagent/preflight.d.ts.map +0 -1
- package/dist/subagent/preflight.js +0 -108
- package/dist/subagent/preflight.js.map +0 -1
- package/dist/subagent/request.d.ts +0 -4
- package/dist/subagent/request.d.ts.map +0 -1
- package/dist/subagent/request.js +0 -122
- package/dist/subagent/request.js.map +0 -1
- package/dist/subagent/response.d.ts +0 -8
- package/dist/subagent/response.d.ts.map +0 -1
- package/dist/subagent/response.js +0 -155
- package/dist/subagent/response.js.map +0 -1
- package/dist/subagent/tools.d.ts +0 -4
- package/dist/subagent/tools.d.ts.map +0 -1
- package/dist/subagent/tools.js +0 -42
- package/dist/subagent/tools.js.map +0 -1
- package/dist/subagent/types.d.ts +0 -268
- package/dist/subagent/types.d.ts.map +0 -1
- package/dist/subagent/types.js +0 -3
- package/dist/subagent/types.js.map +0 -1
- package/dist/subagent/validation.d.ts +0 -35
- package/dist/subagent/validation.d.ts.map +0 -1
- package/dist/subagent/validation.js +0 -314
- package/dist/subagent/validation.js.map +0 -1
- package/dist/subagent-command.d.ts +0 -4
- package/dist/subagent-command.d.ts.map +0 -1
- package/dist/subagent-command.js +0 -246
- package/dist/subagent-command.js.map +0 -1
- package/dist/subagent-profile-tool.d.ts +0 -49
- package/dist/subagent-profile-tool.d.ts.map +0 -1
- package/dist/subagent-profile-tool.js +0 -124
- package/dist/subagent-profile-tool.js.map +0 -1
- package/dist/subagent-tool.d.ts +0 -53
- package/dist/subagent-tool.d.ts.map +0 -1
- package/dist/subagent-tool.js +0 -456
- package/dist/subagent-tool.js.map +0 -1
- package/docs/guides/sillytavern-import.md +0 -47
- package/docs/reference/subagent-adapter.md +0 -204
- package/examples/sillytavern-dm-writer-prompt-stack.json +0 -190
|
@@ -1,28 +1,75 @@
|
|
|
1
1
|
# Public API policy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Documentation](../README.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
pi-forge is pre-1.0. This document defines the intentional integration surfaces of the 0.5.0 line.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Package-root macro and slot registration APIs (`registerMacro`, `registerSlot`, their registry readers, render contexts, and declarative definition types) are supported for trusted reusable extensions.
|
|
9
|
-
- `ForgeExtensionApi` and related registration types are supported for trusted project-local forge extensions.
|
|
7
|
+
## The three intentional entry points
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
`check-package` enforces this allowlist; nothing else is importable from the package.
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
### 1. Package root: extension factory
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
```ts
|
|
14
|
+
import piForge from "@zihanw/pi-forge";
|
|
15
|
+
```
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
The default export is the Pi extension entry point declared by `pi.extensions`. Most users install the package and never import it directly.
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
### 2. Package root: trusted extension API
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
```ts
|
|
22
|
+
import { registerMacro, registerSlot } from "@zihanw/pi-forge";
|
|
23
|
+
import type {
|
|
24
|
+
ForgeExtensionApi,
|
|
25
|
+
ForgeExtensionRegister,
|
|
26
|
+
PromptEnvironment,
|
|
27
|
+
PromptEnvironmentValue,
|
|
28
|
+
PromptExtensionArgumentDefinition,
|
|
29
|
+
PromptExtensionOptionDefinition,
|
|
30
|
+
PromptExtensionOptionsSchema,
|
|
31
|
+
PromptExtensionOptionType,
|
|
32
|
+
PromptMacroDefinition,
|
|
33
|
+
PromptMacroRenderContext,
|
|
34
|
+
PromptMacroRenderer,
|
|
35
|
+
PromptRegistryEntry,
|
|
36
|
+
PromptRenderHelpers,
|
|
37
|
+
PromptSlotDefinition,
|
|
38
|
+
PromptSlotRenderContext,
|
|
39
|
+
PromptSlotRenderer,
|
|
40
|
+
} from "@zihanw/pi-forge";
|
|
41
|
+
```
|
|
27
42
|
|
|
28
|
-
|
|
43
|
+
Supported for trusted reusable and project-local extensions. The contract (pure renderers, declared dependencies, immutable `PromptEnvironment`, bounded output) is specified in the [0.5.0 architecture plan](../design/architecture-0.5.md#extension-port-contract-050) and the [custom macros and slots guide](../guides/custom-macros-and-slots.md).
|
|
44
|
+
|
|
45
|
+
### 3. `@zihanw/pi-forge/subagent`: versioned host port
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import {
|
|
49
|
+
ForgeHost, ForgeHostClient, ForgeHostPortError,
|
|
50
|
+
FORGE_HOST_CHANNEL, FORGE_HOST_PORT_VERSION, FORGE_HOST_PORT_OPERATIONS,
|
|
51
|
+
validateListProfilesRequest, validateListProfilesResponse,
|
|
52
|
+
validateResolveProfileRequest, validateResolveProfileResponse,
|
|
53
|
+
validatePrepareRequest, validatePrepareResponse,
|
|
54
|
+
canonicalSubagentJson, subagentFingerprint,
|
|
55
|
+
subagentSourceProfileFingerprint, subagentPromptStackFingerprint,
|
|
56
|
+
} from "@zihanw/pi-forge/subagent";
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The experimental host port over the Pi event bus: discovery, profile listing/snapshot, and host-owned prompt preparation with mandatory lifecycle semantics (correlation IDs, payload validation, bounded timeouts, host generation, duplicate-host failure, disposal/`unavailable`, listener cleanup). The wire DTOs and validators are self-contained Forge data contracts; the main package has no dependency on `@zihanw/pi-subagent-runtime`. The canonical `sha256:v1` fingerprint helpers are Forge-owned and byte-compatible with the runtime's canonical JSON.
|
|
60
|
+
|
|
61
|
+
The optional `@zihanw/pi-forge-subagents` package consumes this port and owns subagent execution and configuration.
|
|
62
|
+
|
|
63
|
+
## Compatibility policy
|
|
64
|
+
|
|
65
|
+
- **Stable** surfaces (root factory, macro/slot registration) preserve source compatibility within the documented release range unless a changelog entry announces a breaking release.
|
|
66
|
+
- **Experimental** surfaces (the `/subagent` host port) are typed, tested, and documented, but may change deliberately as integration experience exposes missing semantics.
|
|
67
|
+
- Everything not listed above is internal and may change without notice. In particular: no `src/*` subpath aliases exist, `./examples/*` is not an import surface (examples ship as browsable files), and removed 0.4 surfaces (the execution contract re-exports, loader/profile/catalog helpers) now live either nowhere or in `@zihanw/pi-forge-subagents`.
|
|
68
|
+
|
|
69
|
+
## Removed in 0.5.0
|
|
70
|
+
|
|
71
|
+
- All `@zihanw/pi-forge/src/*` compatibility aliases and the `./examples/*` subpath export.
|
|
72
|
+
- Root re-exports of loader, agent-profile, profile-service, catalog, resource-identity, render-helper values, the `forge-v1` engine, and registry readers.
|
|
73
|
+
- Root and `/subagent` re-exports of the 0.4 execution contract (`AgentRequest`, `createAgentExecutionPlan`, `validateAgentRequest`, `negotiateSubagentTools`, `resolveSubagentHostProfile`, `prepareSubagentHostPlan`, and friends). The execution contract now belongs to `@zihanw/pi-forge-subagents`.
|
|
74
|
+
|
|
75
|
+
See the [0.5 migration guide](../guides/migrating-to-0.5.md) for the complete breaking-change list.
|
|
@@ -6,7 +6,7 @@ Use [the default Pi mirror](../../examples/default-prompt-stack.json) as the com
|
|
|
6
6
|
|
|
7
7
|
## Top-level shape
|
|
8
8
|
|
|
9
|
-
A stack has a unique `id`, schema/type identity, optional display metadata and auto-activation, a system `mode`, ordered `items`, and optional defaults, variables, context, resource policy, regex, and source metadata.
|
|
9
|
+
A stack has a unique `id`, schema/type identity, optional display metadata and auto-activation, a system `mode`, ordered `items`, and optional defaults, parameters (schema v2) or legacy variables, context, resource policy, regex, and source metadata.
|
|
10
10
|
|
|
11
11
|
Unknown/advanced metadata is preserved by raw editing, but behavior-changing fields are shape-checked and invalid values are not silently normalized into active behavior.
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ Block:
|
|
|
21
21
|
"name": "Readable label",
|
|
22
22
|
"enabled": true,
|
|
23
23
|
"role": "system",
|
|
24
|
-
"content": "Your text here. Use {{
|
|
24
|
+
"content": "Your text here. Use {{ parameters.role }} / {{ runtime.lastUserMessage }} for dynamic content."
|
|
25
25
|
}
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -65,7 +65,7 @@ Item IDs must be unique. Unsupported slots and missing required custom registrat
|
|
|
65
65
|
}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
- Set `includeLastUserMessage: false` when a later block reinserts `{{lastUserMessage}}`.
|
|
68
|
+
- Set `includeLastUserMessage: false` when a later block reinserts `{{ runtime.lastUserMessage }}`.
|
|
69
69
|
- `stripAssistantThinking` removes prior thinking blocks but preserves visible assistant text, tool calls, and results. It does not change the live loop or stored transcript.
|
|
70
70
|
- `includeSummaries: false` excludes branch/compaction summaries.
|
|
71
71
|
- `roles` keeps only selected roles.
|
|
@@ -76,7 +76,7 @@ When filtering would separate a tool call from its result, pi-forge removes dang
|
|
|
76
76
|
|
|
77
77
|
## Structured slots
|
|
78
78
|
|
|
79
|
-
`tools`, `tool-guidelines`, `skills`, `project-context
|
|
79
|
+
`tools`, `tool-guidelines`, `skills`, and `project-context` support `"format": "plain"`; the default is XML-style structure. Date slots support `includeTime: true`.
|
|
80
80
|
|
|
81
81
|
See [macros and slots](macros-and-slots.md) for names and options.
|
|
82
82
|
|
|
@@ -101,13 +101,14 @@ Tool policy changes Pi's active tool list, is reasserted before input/turns, and
|
|
|
101
101
|
|
|
102
102
|
Skill policy filters only pi-forge-rendered skill slots. It does not disable explicit invocation and is not a capability boundary. `append`/`prepend` may retain Pi's unfiltered base skill text, so validation warns.
|
|
103
103
|
|
|
104
|
-
##
|
|
104
|
+
## Parameters and schema v2
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
Schema v2 stacks store immutable static values in `parameters` (JSON-compatible):
|
|
107
107
|
|
|
108
108
|
```json
|
|
109
109
|
{
|
|
110
|
-
"
|
|
110
|
+
"schemaVersion": 2,
|
|
111
|
+
"parameters": {
|
|
111
112
|
"char": "Konata",
|
|
112
113
|
"user": "User",
|
|
113
114
|
"style": { "tone": "concise" }
|
|
@@ -115,7 +116,11 @@ Top-level static variables are JSON values:
|
|
|
115
116
|
}
|
|
116
117
|
```
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
Parameters resolve through `{{ parameters.<name> }}` templates and are available
|
|
120
|
+
to trusted custom macros/slots. Unversioned and v1 stacks continue to read the
|
|
121
|
+
legacy `variables` field (string values) and support bare `{{name}}` fallback.
|
|
122
|
+
A stack must not mix `parameters` and `variables` across schema versions. See
|
|
123
|
+
[macro reference](macros-and-slots.md).
|
|
119
124
|
|
|
120
125
|
## Regex transforms
|
|
121
126
|
|
|
@@ -164,4 +169,4 @@ Outgoing rules change future model input. To destructively change a completed as
|
|
|
164
169
|
|
|
165
170
|
> `finalize` runs at `message_end`, after raw output may have streamed. It replaces the stored assistant message, so the original output is not preserved.
|
|
166
171
|
|
|
167
|
-
`effect: "
|
|
172
|
+
`effect: "outgoing"` and `"finalize"` are the only valid effects; `"display"` and `"both"` are rejected during validation. Runtime diagnostics report match and changed-segment counts.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Subagent host port contract
|
|
2
|
+
|
|
3
|
+
[Documentation](../README.md)
|
|
4
|
+
|
|
5
|
+
Status: experimental, versioned (`FORGE_HOST_PORT_VERSION = 1`). The `/subagent` entry point is the main package's only subagent surface: a transport-neutral host port over data-only messages. Subagent execution, approval, and configuration live in the optional [`@zihanw/pi-forge-subagents`](https://github.com/MacroSony/pi-forge-subagents) package, which consumes this port and never imports main-package internals.
|
|
6
|
+
|
|
7
|
+
## Ownership boundary
|
|
8
|
+
|
|
9
|
+
- **Main package owns:** prompt-stack/agent-profile storage and validation (repositories + codecs), the immutable `ForgeWorkspace` snapshot, profile/stack resolution, host-owned prompt compilation, and tool filtering through stack policy.
|
|
10
|
+
- **Optional package owns:** delegation authorization (`subagents.json`), the execution contract (request, preflight, plan, response, validators), backend preflight and sealing via `@zihanw/pi-subagent-runtime`, approval UX, and execution.
|
|
11
|
+
- **Never crosses the port:** live contexts, internal registries, execution/runtime material (access workspace model, limits, `resultProjection`, `parent`, `remoteEgressConsent`, a base system prompt). The client sends only a profile selector, the task, prompt-compilation access facts (`level`/`network`/`allowProcess`), and backend facts (model, thinking level, tool catalog).
|
|
12
|
+
|
|
13
|
+
## Transport and lifecycle
|
|
14
|
+
|
|
15
|
+
`ForgeHostTransport` is a minimal `{ emit(channel, data), on(channel, handler) }` interface; the production wiring is `pi.events`. Wire messages are plain JSON-compatible data validated recursively (exact nested fields, typed enums, plain objects only, unknown fields rejected) at both boundaries.
|
|
16
|
+
|
|
17
|
+
Mandatory lifecycle rules:
|
|
18
|
+
|
|
19
|
+
1. Clients subscribe before announcing or discovering, and use bounded timeouts.
|
|
20
|
+
2. A duplicate live host fails explicitly (`host.duplicate`).
|
|
21
|
+
3. `request`/`reply` messages carry `hostId` + `generation`; stale-generation and wrong-host requests are rejected server-side, mismatched replies ignored client-side.
|
|
22
|
+
4. Disposal sends `unavailable` and invalidates connections; all transient and persistent listeners are cleaned up.
|
|
23
|
+
5. The host can only start after the first workspace snapshot exists, so an advertised host implies a loaded workspace. Reload honors project trust: untrusted workspaces expose global resources only.
|
|
24
|
+
|
|
25
|
+
## Operations
|
|
26
|
+
|
|
27
|
+
### Discovery
|
|
28
|
+
|
|
29
|
+
`ForgeHostClient.discover()` / `ForgeHostSession` in the optional package announce on `FORGE_HOST_CHANNEL` and wait for `available` with capabilities.
|
|
30
|
+
|
|
31
|
+
### `listProfiles`
|
|
32
|
+
|
|
33
|
+
Request: `{}`. Response: `{ profiles: ForgeProfileSummary[] }` — each with `profileId`, `scope`, optional `name`/`description`/`autoActivate`, `model`, `thinkingLevel`, `promptStack`, `usable`, and load diagnostics. Read-only; no resolution side effects.
|
|
34
|
+
|
|
35
|
+
### `resolveProfile`
|
|
36
|
+
|
|
37
|
+
Request: `{ profile: string }` — a scoped selector (`reviewer`, `project:reviewer`, `global:reviewer`). Response: `{ snapshot }` — the immutable host-owned profile snapshot artifact: resolved profile and prompt stack JSON, prompt dependency list, and `sha256:v1` content fingerprints (`profileFingerprint`, `promptStackFingerprint`) computed with Forge-owned canonical helpers byte-compatible with the runtime's canonical JSON. The optional package re-validates and re-fingerprints the snapshot before binding it into execution plans.
|
|
38
|
+
|
|
39
|
+
### `prepare`
|
|
40
|
+
|
|
41
|
+
Request: `{ profile, task: { text }, access: ForgePromptAccessFacts, backend: ForgeBackendFacts }`. The workspace resolves the profile and stack from its snapshot, filters the client tool catalog through stack tool policy and the access facts, and compiles through the same compilation context as runtime and preview. Response: `{ profileId, model, thinkingLevel, systemPrompt, messages, effectiveToolIds, effectiveToolNames, diagnostics, profileSnapshot, preparedAt }`. `messages` ends with the protected delegated task (`protectedTask: true`, `source: "delegated-task"`); stack-compiled messages carry `source: "prompt-stack"`. The base system prompt is host-owned and intentionally empty for delegated subagents — the prompt stack composes the system prompt.
|
|
42
|
+
|
|
43
|
+
## Fingerprints
|
|
44
|
+
|
|
45
|
+
`canonicalSubagentJson`, `subagentFingerprint`, `subagentSourceProfileFingerprint`, `subagentPromptStackFingerprint`, and `SUBAGENT_FINGERPRINT_PREFIX` are Forge-owned and vendored in the main package; golden vectors pin byte compatibility with the runtime's canonical serialization. Conversation and execution fingerprints are never host-computed — they are issued by `@zihanw/pi-subagent-runtime` during plan sealing in the optional package.
|
|
46
|
+
|
|
47
|
+
## Errors
|
|
48
|
+
|
|
49
|
+
`ForgeHostPortError` carries `code: "timeout" | "duplicate" | "unavailable" | "protocol" | "invalid"`. Operation-level failures return `{ ok: false, error }` results rather than throwing across the bus.
|
package/docs/zh-CN/README.md
CHANGED
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
## 指南
|
|
12
12
|
|
|
13
13
|
- [Web 编辑器](guides/web-editor.md)
|
|
14
|
+
- [迁移到 0.5](guides/migrating-to-0.5.md)
|
|
14
15
|
- [实验性前台 delegation](guides/delegation.md):启用前请先阅读安全边界。
|
|
15
16
|
- [Prompt stack 使用场景(英文)](../guides/use-cases.md)
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
自定义 macros/slots 和调试的完整说明目前以英文版为准:
|
|
18
19
|
|
|
19
|
-
- [SillyTavern import](../guides/sillytavern-import.md)
|
|
20
20
|
- [Custom macros and slots](../guides/custom-macros-and-slots.md)
|
|
21
21
|
- [Prompt and payload debugging](../guides/debugging.md)
|
|
22
22
|
|
|
@@ -27,7 +27,7 @@ SillyTavern 导入、自定义 macros/slots 和调试的完整说明目前以英
|
|
|
27
27
|
- [Macros 与 slots(英文)](../reference/macros-and-slots.md)
|
|
28
28
|
- [配置(英文)](../reference/configuration.md)
|
|
29
29
|
- [Public API(英文)](../reference/public-api.md)
|
|
30
|
-
- [实验性 subagent
|
|
30
|
+
- [实验性 subagent host port(英文)](../reference/subagent-host-port.md)
|
|
31
31
|
|
|
32
32
|
## 开发与设计
|
|
33
33
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[中文文档](../README.md) · [English](../../concepts/agent-profiles.md)
|
|
4
4
|
|
|
5
|
-
Agent profile
|
|
5
|
+
Agent profile 是项目级或用户全局、带 schema version 的预设,只引用一个精确模型、思考等级和 prompt stack。项目 profile 位于 `.pi/forge/agent-profiles/`,全局 profile 位于 `~/.pi/forge/agent-profiles/`。命令接受 `reviewer`、`project:reviewer` 和 `global:reviewer`;未限定 ID 优先解析项目 profile,项目 profile 会遮蔽同 ID 全局 profile。
|
|
6
6
|
|
|
7
7
|
```json
|
|
8
8
|
{
|
|
@@ -23,6 +23,8 @@ Agent profile 是项目级、带 schema version 的预设,只引用一个精
|
|
|
23
23
|
|
|
24
24
|
`promptStack` 可以是 `null`。Profile v1 不保存生成参数、工具、skills、backend 或 runner policy;不支持字段会直接报错。工具/skill 策略只属于引用的 stack。
|
|
25
25
|
|
|
26
|
+
`promptStack` 引用相对 profile 自身 scope 解析:项目 profile 用裸 ID 引用项目 stack,也可用 `global:<id>` 显式引用全局 stack;全局 profile 只能引用全局 stack,`project:<id>` 会被拒绝。
|
|
27
|
+
|
|
26
28
|
## 应用
|
|
27
29
|
|
|
28
30
|
```text
|
|
@@ -41,4 +43,4 @@ Agent profile 是项目级、带 schema version 的预设,只引用一个精
|
|
|
41
43
|
|
|
42
44
|
`/profile status` 会把 profile 源定义变化和当前模型/思考等级/stack drift 分开显示。Provenance 只用于 branch 状态报告;reload、resume、tree navigation 和 compaction 不会重新应用 profile。
|
|
43
45
|
|
|
44
|
-
普通 profile 默认不能委派。Delegation
|
|
46
|
+
普通 profile 默认不能委派。Delegation 授权由可选包 `@zihanw/pi-forge-subagents` 通过专用文件持有:可信项目 `.pi/forge/subagents.json` 只授权 `project:<id>`,用户全局 `~/.pi/forge/subagents.json` 只授权 `global:<id>`,并可按 profile 覆盖 backend/timeout;同 ID 的全局和项目 profile 永不互相继承授权。主包不读取任何 subagent 配置,删除 profile 也不会改动 `subagents.json`。启用前见[前台 delegation](../guides/delegation.md)。
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[中文文档](../README.md) · [English](../../concepts/prompt-stacks.md)
|
|
4
4
|
|
|
5
|
-
Prompt stack 是一份有序、声明式的 prompt 与策略描述,由固定 **block** 和动态 **slot** 组成。
|
|
5
|
+
Prompt stack 是一份有序、声明式的 prompt 与策略描述,由固定 **block** 和动态 **slot** 组成。Stack 可以放在项目 `.pi/forge/prompt-stacks/`,也可以放在用户全局 `~/.pi/forge/prompt-stacks/`。命令接受 `reviewer`、`project:reviewer` 和 `global:reviewer`;未限定 ID 优先解析项目 stack,项目 stack 会遮蔽同 ID 全局 stack。重复 ID 只在同一 scope 内算错误。
|
|
6
6
|
|
|
7
7
|
## 编译模型
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ Prompt stack 是一份有序、声明式的 prompt 与策略描述,由固定 *
|
|
|
11
11
|
1. 按 JSON 顺序排列启用的 block/slot。
|
|
12
12
|
2. 构建 system 内容,并使用 `replace`、`append` 或 `prepend` 模式。
|
|
13
13
|
3. 在可移动 `chat-history` 周围插入 user/assistant 消息。
|
|
14
|
-
4.
|
|
14
|
+
4. 用 forge-v1 编译 `runtime.*` / `parameters.*` / `extensions.*` 模板。
|
|
15
15
|
5. 对 Pi 执行工具策略,并过滤 pi-forge 渲染的 skills。
|
|
16
16
|
6. 应用 history/compiled outgoing regex。
|
|
17
17
|
7. 可选地在消息完成后应用破坏性的 finalize regex。
|
|
@@ -21,7 +21,7 @@ Prompt stack 是一份有序、声明式的 prompt 与策略描述,由固定 *
|
|
|
21
21
|
1. 长期 system 规则。
|
|
22
22
|
2. 工具和项目上下文。
|
|
23
23
|
3. `includeLastUserMessage: false` 的 `chat-history`。
|
|
24
|
-
4. 包含 `{{lastUserMessage}}` 的最终 user block。
|
|
24
|
+
4. 包含 `{{ runtime.lastUserMessage }}` 的最终 user block。
|
|
25
25
|
|
|
26
26
|
这样既保留旧上下文,又只在最后明确出现一次当前请求。History 还可以过滤 summary/role、去掉旧工具消息、移除 assistant thinking,并限制消息数或字符数。
|
|
27
27
|
|
|
@@ -29,12 +29,14 @@ Prompt stack 是一份有序、声明式的 prompt 与策略描述,由固定 *
|
|
|
29
29
|
|
|
30
30
|
工具 `allow`/`deny` 会修改 Pi active tools,并在 tool call 时再次检查。Skill policy 只过滤 pi-forge 渲染给模型的列表;它不能阻止明确调用,也不是安全边界。若必须控制模型可见 skill 列表,请使用 `replace`,因为 Pi 的基础 prompt 可能已经在 `append`/`prepend` 内容之前列出 skills。
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## Scope 与自动启用
|
|
33
33
|
|
|
34
|
-
- `default.json
|
|
34
|
+
- 只有显式设置 `"autoActivate": true` 的 stack 参与自动启用;文件名(包括 `default.json`)没有特殊作用。
|
|
35
|
+
- 项目 stack 优先于全局 stack;项目 scope 存在候选时,即使项目候选无效或冲突也会 fail closed,不会回退到全局 stack。
|
|
36
|
+
- 同 ID 项目 stack 会遮蔽全局 stack,包括无效 shadow 或显式 opt-out。
|
|
35
37
|
- `/preset use none` 会记录 session branch 的 opt-out。
|
|
36
|
-
- Active stack
|
|
38
|
+
- Active stack 选择会跟随 Pi session tree branch。
|
|
37
39
|
- 恢复的 branch 状态优先于新 session 自动启用。
|
|
38
40
|
- 自动启用的 agent profile 优先于独立 stack autoload。
|
|
39
41
|
|
|
40
|
-
完整字段见英文 [stack schema](../../reference/stack-schema.md)
|
|
42
|
+
完整字段见英文 [stack schema](../../reference/stack-schema.md)(schema v2 使用 `parameters`),模板语法见[参考](../../reference/macros-and-slots.md)。
|
|
@@ -10,7 +10,7 @@ pi-forge 需要 Node.js 22.19 或更高版本,并作为 Pi extension 运行:
|
|
|
10
10
|
pi install npm:@zihanw/pi-forge
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
安装或更新后请重启 Pi。Pi host 会提供运行时 SDK;精确 package
|
|
13
|
+
安装或更新后请重启 Pi。Pi host 会提供运行时 SDK;精确 package 版本只用于可复现的开发测试。用户全局 stack/profile 始终可以浏览;项目 stack、profile 和 config 只在 Pi 信任项目后加载和写入。
|
|
14
14
|
|
|
15
15
|
## 第一个 stack
|
|
16
16
|
|
|
@@ -28,7 +28,7 @@ cp examples/default-prompt-stack.json .pi/forge/prompt-stacks/default.json
|
|
|
28
28
|
/preset use default
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
示例中的 `default.json` 带 `"autoActivate": true`,因此没有恢复的 session 选择或明确 opt-out 时会自动启用。设置 `"autoActivate": false` 可以关闭此行为;文件名本身没有特殊作用。
|
|
32
32
|
|
|
33
33
|
## 编辑和检查
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ cp examples/default-prompt-stack.json .pi/forge/prompt-stacks/default.json
|
|
|
36
36
|
/preset ui
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
编辑器运行在带 token 的本地 `127.0.0.1` URL,支持结构化/原始 JSON 编辑、排序、校验、完整预览、策略、regex、导入导出、fork 和 profile
|
|
39
|
+
编辑器运行在带 token 的本地 `127.0.0.1` URL,支持结构化/原始 JSON 编辑、排序、校验、完整预览、策略、regex、导入导出、fork 和 profile 管理。工具栏的 scope 下拉(默认 `project`)决定新建、fork 和导入 stack 写入项目 `.pi/forge/prompt-stacks` 还是用户全局 `~/.pi/forge/prompt-stacks`。
|
|
40
40
|
|
|
41
41
|
命令行也可以检查:
|
|
42
42
|
|
|
@@ -56,7 +56,7 @@ cp examples/default-prompt-stack.json .pi/forge/prompt-stacks/default.json
|
|
|
56
56
|
/profile use reviewer
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Profile
|
|
59
|
+
Profile 默认保存在 `.pi/forge/agent-profiles/*.json`。`/profile save global:reviewer` 会写入用户全局 `~/.pi/forge/agent-profiles`。应用是经过 preflight 的一次性操作;之后的手动设置不会被自动覆盖。
|
|
60
60
|
|
|
61
61
|
## 存储与迁移
|
|
62
62
|
|
|
@@ -64,12 +64,15 @@ Profile 保存在 `.pi/forge/agent-profiles/*.json`。应用是经过 preflight
|
|
|
64
64
|
|---|---|
|
|
65
65
|
| `.pi/forge/prompt-stacks/` | 项目 prompt stacks |
|
|
66
66
|
| `.pi/forge/agent-profiles/` | 项目 agent profiles |
|
|
67
|
-
| `.pi/forge/config.json` |
|
|
67
|
+
| `.pi/forge/config.json` | 项目配置(`webEditor.*`) |
|
|
68
68
|
| `.pi/forge/extensions/` | 可信项目 macro/slot 代码 |
|
|
69
|
-
| `~/.pi/forge/
|
|
69
|
+
| `~/.pi/forge/prompt-stacks/` | 用户全局 prompt stacks |
|
|
70
|
+
| `~/.pi/forge/agent-profiles/` | 用户全局 agent profiles |
|
|
71
|
+
| `~/.pi/forge/config.json` | 用户默认配置(`webEditor.*`) |
|
|
72
|
+
| `.pi/forge/subagents.json` / `~/.pi/forge/subagents.json` | 由可选包 `@zihanw/pi-forge-subagents` 持有的 delegation 授权配置 |
|
|
70
73
|
| `~/.pi/forge/extensions/` | 可信用户 macro/slot 代码 |
|
|
71
74
|
|
|
72
|
-
旧的 `.pi/prompt-stacks/*.json`
|
|
75
|
+
旧的 `.pi/prompt-stacks/*.json` 仍可读取;命令创建的 stack 会写到 `.pi/forge/prompt-stacks`,使用 Web 编辑器的 `global` scope 下拉可创建到用户全局 `~/.pi/forge/prompt-stacks`。安全迁移方式:
|
|
73
76
|
|
|
74
77
|
```text
|
|
75
78
|
/preset migrate-stacks --dry-run
|
|
@@ -4,28 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
> **实验性:** 此 API 和 backend 可能独立于稳定的 prompt stack/profile 功能发生变化。
|
|
6
6
|
|
|
7
|
-
pi-forge 可以把明确授权的 agent profile 作为独立、干净、一次性的 Pi 进程执行。它在前台运行,并向父对话返回有界报告。
|
|
7
|
+
可选包 `@zihanw/pi-forge-subagents` 可以把明确授权的 agent profile 作为独立、干净、一次性的 Pi 进程执行。它在前台运行,并向父对话返回有界报告。
|
|
8
8
|
|
|
9
9
|
## 启用 profile
|
|
10
10
|
|
|
11
|
-
Profile 默认不能委派。请在可信项目的 `.pi/forge/
|
|
11
|
+
Profile 默认不能委派。请在可信项目的 `.pi/forge/subagents.json` 中逐个启用项目 profile,在用户全局 `~/.pi/forge/subagents.json` 中逐个启用全局 profile;`.pi/forge/config.json.subagents` 仅作为只读兼容来源:
|
|
12
12
|
|
|
13
13
|
```json
|
|
14
14
|
{
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"timeoutMs": 300000
|
|
22
|
-
}
|
|
15
|
+
"backend": "pi-subprocess-readonly",
|
|
16
|
+
"timeoutMs": 60000,
|
|
17
|
+
"profiles": {
|
|
18
|
+
"reviewer": {
|
|
19
|
+
"enabled": true,
|
|
20
|
+
"timeoutMs": 300000
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
```
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
授权跟随 profile scope:项目 `subagents.json` 的 `profiles.<id>` 只授权 `project:<id>`,全局 `subagents.json` 的 `profiles.<id>` 只授权 `global:<id>`。同 ID 的全局和项目 profile 不会互相继承 enable/backend/timeout。未启用或未列出的 ID 不会被 discovery 返回,即使猜中 ID 也会被拒绝。
|
|
29
27
|
|
|
30
28
|
## Plan 与运行
|
|
31
29
|
|
|
@@ -35,7 +33,7 @@ Profile 授权只允许出现在项目配置,因为 profile 本身也是项目
|
|
|
35
33
|
/forge-agent run reviewer 检查这个 API 设计。
|
|
36
34
|
```
|
|
37
35
|
|
|
38
|
-
`plan` 会解析 profile/stack、编译并校验不可变的实际 provider-bound 计划,然后在不联系 provider 的情况下丢弃。
|
|
36
|
+
`plan` 会解析 profile/stack、编译并校验不可变的实际 provider-bound 计划,然后在不联系 provider 的情况下丢弃。Profile selector 在所有入口使用同一语法:`reviewer`(项目优先)、`project:reviewer` 或 `global:reviewer`。同 ID 冲突时,项目 profile 保持简写 selector,全局 profile 仍通过 `global:<id>` 调用。
|
|
39
37
|
|
|
40
38
|
父模型使用无数据外发的 `forge_subagent_profiles` 做 discovery,再用 `forge_subagent` 执行。限制严格的父 stack 必须允许这两个工具名。
|
|
41
39
|
|
|
@@ -55,7 +53,7 @@ Profile 授权只允许出现在项目配置,因为 profile 本身也是项目
|
|
|
55
53
|
}
|
|
56
54
|
```
|
|
57
55
|
|
|
58
|
-
它只影响 `forge_subagent`;`/forge-agent run` 仍需要交互审批。格式错误或不可信项目会 fail closed。请把此
|
|
56
|
+
它只影响 `forge_subagent`;`/forge-agent run` 仍需要交互审批。格式错误或不可信项目会 fail closed。请把此 `subagents.json` 当作授权文件:除非所有可调用父 agent 都可以无需再次询问就把编译 prompt 和可读文件发给 provider,否则不要启用或提交此设置。
|
|
59
57
|
|
|
60
58
|
## Child 边界
|
|
61
59
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# 迁移到 pi-forge 0.5
|
|
2
|
+
|
|
3
|
+
[中文文档](../README.md) · [English](../../guides/migrating-to-0.5.md)
|
|
4
|
+
|
|
5
|
+
0.5.0 是一个破坏性的清理版本。本页是全部变更的迁移说明。
|
|
6
|
+
|
|
7
|
+
## 被移除的内容
|
|
8
|
+
|
|
9
|
+
- SillyTavern 导入器(`/preset import-silly`)及其报告、指南、示例和测试。升级前请先用 pi-forge 0.4 转换 SillyTavern preset。
|
|
10
|
+
- 可变 turn/session 变量、变量修改 macro、`pi-forge-variable-state` session 条目和 `variables` slot。
|
|
11
|
+
- 正则的 `display` 与 `both` 效果;保留 `outgoing` 和 `finalize`。
|
|
12
|
+
- 主包中的 subagent 执行功能(移至可选包,见下文 Lane 3/4)。
|
|
13
|
+
|
|
14
|
+
## 模板语法变更
|
|
15
|
+
|
|
16
|
+
Prompt 文本现在使用封闭的 `forge-v1` 语法编译。
|
|
17
|
+
|
|
18
|
+
| 0.4 写法 | 0.5 forge-v1 |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `{{name}}`(静态) | `{{ parameters.name }}` |
|
|
21
|
+
| `{{lastUserMessage}}` | `{{ runtime.lastUserMessage }}` |
|
|
22
|
+
| `{{date}}` / `{{time}}` / `{{cwd}}` | `{{ runtime.date }}` / `{{ runtime.time }}` / `{{ runtime.cwd }}` |
|
|
23
|
+
| `{{tools}}` | `{{ runtime.selectedToolsText }}` |
|
|
24
|
+
| `{{upper::x}}` | `{{ x \| upper }}` |
|
|
25
|
+
| `{{iftools::bash::A::B}}` | `{% if runtime.tool.bash %}A{% else %}B{% endif %}` |
|
|
26
|
+
| 自定义 `{{myMacro}}` | `{{ extensions.myMacro }}` |
|
|
27
|
+
|
|
28
|
+
未知路径、未知 filter、解析错误、循环和输出超限都是编译错误;失败的块会被省略,而不是把原始模板文本重新注入。
|
|
29
|
+
|
|
30
|
+
## Schema v2
|
|
31
|
+
|
|
32
|
+
Schema v2 的 stack 把不可变静态值存入 `parameters`(JSON 兼容),取代旧的纯字符串 `variables` 字段:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"schemaVersion": 2,
|
|
37
|
+
"parameters": { "char": "Konata" }
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
未标注版本 / v1 的 stack 仍通过旧的 `variables` 读取器加载。
|
|
42
|
+
|
|
43
|
+
## 运行迁移工具
|
|
44
|
+
|
|
45
|
+
一个以诊断为先的机械脚本可转换已保存的 stack 文件:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
node scripts/migrate-stack-v2.mjs .pi/forge/prompt-stacks/default.json --dry-run
|
|
49
|
+
node scripts/migrate-stack-v2.mjs .pi/forge/prompt-stacks/default.json --write
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
它会把 `variables` 改名为 `parameters`、映射 runtime/parameter 路径并转换简单的 filter 管道。无法机械转换的写法会被报告;只有不存在这类写法时才会写入文件。仍含旧 `variables` 字段的 schema v2 文件不会被改动,仅给出警告。
|
|
53
|
+
|
|
54
|
+
## Lane 2:带 scope 的全局 profile 与 prompt stack
|
|
55
|
+
|
|
56
|
+
- 用户全局资源现在位于 `~/.pi/forge/prompt-stacks` 和 `~/.pi/forge/agent-profiles`,与项目存储并存。Profile 和 stack 选择器支持显式 scope:`project:<id>`、`global:<id>`,裸 ID 优先解析项目资源。
|
|
57
|
+
- 同 ID 的项目资源会遮蔽对应的全局资源;全局 stack 不能引用项目资源(反之亦然)——引用在被引用资源的 scope 内解析。
|
|
58
|
+
- 未信任的项目一律拒绝:只加载全局资源,所有变更路由被拒绝,并且当 session 可能仍活跃时 `session_shutdown` 不再销毁已信任的工作区(空闲工作区一小时后被清扫;host 独立停止)。
|
|
59
|
+
- Web 编辑器新增 scope 下拉,可向任一存储创建 stack/profile,并通过显式 `global:<id>` 路由执行全局变更。
|
|
60
|
+
|
|
61
|
+
## Lane 3:subagent 包拆分
|
|
62
|
+
|
|
63
|
+
Subagent 执行功能从主包移入可选包 `@zihanw/pi-forge-subagents`(要求 `@zihanw/pi-forge@^0.5.0`)。如需保留前台 delegation,请单独安装该包。
|
|
64
|
+
|
|
65
|
+
- **命令:** `/subagents` 和 `/subagent-run` 已从主包移除。可选包注册 `/forge-agent backends|plan|run`。
|
|
66
|
+
- **模型工具:** `forge_subagent_profiles` 和 `forge_subagent` 由可选包注册。
|
|
67
|
+
- **配置:** `subagents.*` 从 `.pi/forge/config.json` 移入专用的 `.pi/forge/subagents.json`(可信项目)和 `~/.pi/forge/subagents.json`(用户默认)。可选包会把旧的 `config.json.subagents` 段落作为只读回退读取并发出警告;它永远不会写入旧位置。把配置值复制到 `subagents.json` 即可消除警告。
|
|
68
|
+
- **Web 编辑器:** delegation 卡片已从主编辑器移除;请直接编辑 `subagents.json`。
|
|
69
|
+
- **架构:** 主包的 prompt 编译器不再携带 subagent 假设,`ForgeWorkspace` 是资源状态和编译上下文的唯一持有者。
|
|
70
|
+
|
|
71
|
+
## Lane 4:Forge 原生 host 契约与公开 surface
|
|
72
|
+
|
|
73
|
+
- 主包不再依赖 `@zihanw/pi-subagent-runtime`,也不再导出 0.4 执行契约。该契约(`AgentRequest`、`createAgentExecutionPlan`、`validateAgentRequest`、`negotiateSubagentTools`、preflight/plan/response 校验器等)现在位于 `@zihanw/pi-forge-subagents` 内部,供其自身 runtime 接线使用;两个包都不把它作为第三方可用的公开 surface。
|
|
74
|
+
- `@zihanw/pi-forge/subagent` 现在只导出带版本的 host port:wire DTO 与校验器、`ForgeHostTransport`、`ForgeHost`/`ForgeHostClient`、生命周期常量,以及 Forge 持有的规范指纹辅助函数。`resolveSubagentHostProfile` / `prepareSubagentHostPlan` 已被 host port 的 `resolveProfile` 和 `prepare` 操作取代。
|
|
75
|
+
- 包根只导出默认扩展工厂、`registerMacro`/`registerSlot` 及其契约类型。其余根导出(loader、agent-profile、profile-service、catalog、resource-identity、render-helper 值、`forge-v1` 引擎、registry 读取器)已全部移除。
|
|
76
|
+
- 所有 `@zihanw/pi-forge/src/*` 子路径别名和 `./examples/*` 导出均已移除;`check-package` 会拒绝它们。
|
|
77
|
+
|
|
78
|
+
### 导入迁移表
|
|
79
|
+
|
|
80
|
+
| 0.4 导入 | 0.5 替代 |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `@zihanw/pi-forge`(默认导出、`registerMacro`、`registerSlot`) | 不变 |
|
|
83
|
+
| `@zihanw/pi-forge/subagent` host-port 名称(`ForgeHost*`、校验器、指纹) | 不变 |
|
|
84
|
+
| `@zihanw/pi-forge/subagent` 执行契约(`AgentRequest`、`createAgentExecutionPlan` 等) | 已内置于 `@zihanw/pi-forge-subagents`;无公开替代 |
|
|
85
|
+
| `@zihanw/pi-forge/subagent` 的 `resolveSubagentHostProfile` / `prepareSubagentHostPlan` | 通过 `ForgeHostClient` 使用 host-port 操作 |
|
|
86
|
+
| `@zihanw/pi-forge/src/*` 别名 | 已移除;无替代(内部实现) |
|
|
87
|
+
| 根部的 loader/profile/catalog/engine 再导出 | 已移除;无替代(内部实现) |
|
|
88
|
+
|
|
89
|
+
## 兼容性说明
|
|
90
|
+
|
|
91
|
+
- Host port 的 wire 结构在 `FORGE_HOST_PORT_VERSION = 1` 内只做增量扩展;未知操作会以普通的 `{ ok: false, error }` 结果拒绝(`"Unknown Forge host operation: …"`),而不是抛出异常。可选包必须把任何操作失败视为该请求的终态。
|
|
92
|
+
- 主包内置的指纹辅助函数由黄金向量锁定,与 `@zihanw/pi-subagent-runtime` 的规范序列化保持字节兼容;计划封存(plan sealing)仍只发生在可选包中。
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
`/preset ui restart` 会替换 server,`/preset ui stop` 会关闭它。
|
|
12
12
|
|
|
13
|
-
编辑器绑定在带 session token 的可用 `127.0.0.1`
|
|
13
|
+
编辑器绑定在带 session token 的可用 `127.0.0.1` 端口;多个项目可以同时运行。读取、预览和 payload 检查在合适范围内可用;写入要求 Pi 信任项目,并且文件被限制在 pi-forge 的 stack/profile 存储内。可以在 `.pi/forge/config.json` 中设置偏好端口:
|
|
14
14
|
|
|
15
15
|
```json
|
|
16
16
|
{
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
- 拖拽排序、启用/禁用、校验和完整编译预览;
|
|
30
30
|
- 工具/skill 搜索、精确名称 chips 和通配符策略;
|
|
31
31
|
- variables、context 和 regex 规则;
|
|
32
|
-
- 原生 pi-forge
|
|
32
|
+
- 原生 pi-forge JSON 导入;
|
|
33
33
|
- 导出、fork、删除和 payload 捕获。
|
|
34
34
|
|
|
35
|
-
已有 ID 在编辑时不可修改;需要新 ID 时使用 **Fork**,避免破坏 profile
|
|
35
|
+
已有 ID 在编辑时不可修改;需要新 ID 时使用 **Fork**,避免破坏 profile 引用和当前选择。工具栏的 scope 下拉(默认 `project`)决定新建、导入和 fork 的写入位置:选择 `global` 写入用户全局 `~/.pi/forge/prompt-stacks`,选择 `project` 写入项目 `.pi/forge/prompt-stacks`。列表会为全局 stack 显示 `global` badge;保存和删除通过 `global:<id>` 路由精确作用于全局文件。保存、导入、fork 和删除后会重新加载当前 Pi session。
|
|
36
36
|
|
|
37
37
|
## Agent profile 工作区
|
|
38
38
|
|
|
39
|
-
列表显示 profile ID、名称、模型、思考等级、stack、校验状态、auto-activation
|
|
39
|
+
列表显示 profile ID、名称、模型、思考等级、stack、校验状态、auto-activation 和 last-applied provenance。每个 profile 都带 `project` / `global` scope badge;同 ID 的 shadow 对会显示 `shadows global:<id>` 或 `shadowed by project:<id>`。
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
可信项目通过 **New profile** 旁的 scope 下拉(默认 `project`)选择目标 scope:选择 `global` 写入用户全局 `~/.pi/forge/agent-profiles`,选择 `project` 写入项目 `.pi/forge/agent-profiles`。全局 profile 可通过显式 `global:<id>` 路由编辑、校验、保存、一次性应用和删除;未限定路由始终只作用于项目资源。编辑全局 profile 时,stack 下拉只显示全局 stack。Model 选项来自 Pi registry,thinking 选项反映模型支持,stack 选项来自同一个 repository。编辑器会拒绝同 scope 内第二个 auto-activation profile。
|
|
42
42
|
|
|
43
|
-
Delegation
|
|
43
|
+
## Delegation
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Delegation 配置不在主编辑器中。可选包 `@zihanw/pi-forge-subagents` 持有专用的 `.pi/forge/subagents.json` 和 `~/.pi/forge/subagents.json` 文件。启用 profile 前请阅读[前台 delegation](delegation.md)。
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[中文文档](../README.md) · [English](../../reference/commands.md)
|
|
4
4
|
|
|
5
|
+
方括号参数可选。写项目文件的命令要求项目已被信任。未限定的 `<id>` 使用项目优先的有效查找;需要精确选择时使用 `project:<id>` 或 `global:<id>`。
|
|
6
|
+
|
|
5
7
|
## Prompt stack
|
|
6
8
|
|
|
7
9
|
| 命令 | 行为 |
|
|
@@ -21,7 +23,6 @@
|
|
|
21
23
|
| 命令 | 行为 |
|
|
22
24
|
|---|---|
|
|
23
25
|
| `/preset migrate-stacks [--dry-run] [--overwrite] [--delete-legacy]` | 把旧 stack 复制到 `.pi/forge/prompt-stacks` |
|
|
24
|
-
| `/preset import-silly <path> [character_id] [--dry-run] [--overwrite]` | 转换 SillyTavern preset 并生成报告 |
|
|
25
26
|
|
|
26
27
|
覆盖或删除之前请先使用 `--dry-run`。
|
|
27
28
|
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
|---|---|
|
|
32
33
|
| `/profile list` | 列出 profile 和解析诊断 |
|
|
33
34
|
| `/profile use <id>` | preflight 并一次性应用 |
|
|
34
|
-
| `/profile save <id> [--overwrite]` | 捕获当前模型、thinking 和 stack |
|
|
35
|
+
| `/profile save <id\|global:id> [--overwrite]` | 捕获当前模型、thinking 和 stack;`global:<id>` 写入用户全局目录 |
|
|
35
36
|
| `/profile status` | 比较当前 runtime 和 last-applied provenance |
|
|
36
37
|
| `/profile preview <id>` | 不应用地解析模型/auth/thinking/stack/tools |
|
|
37
38
|
| `/profile validate [id]` | 校验一个或全部 profile |
|
|
@@ -40,13 +41,15 @@
|
|
|
40
41
|
|
|
41
42
|
## 实验性 delegation
|
|
42
43
|
|
|
44
|
+
以下命令由可选包 `@zihanw/pi-forge-subagents` 提供。
|
|
45
|
+
|
|
43
46
|
| 命令 | 行为 |
|
|
44
47
|
|---|---|
|
|
45
48
|
| `/forge-agent backends` | 列出 backend、capabilities 和默认值 |
|
|
46
49
|
| `/forge-agent plan <profile> [--backend <id>] <task>` | 准备、显示并丢弃计划,不联系 provider |
|
|
47
50
|
| `/forge-agent run <profile> [--backend <id>] <task>` | 审批并执行前台只读任务 |
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
只接受匹配 scope 明确授权的 profile:项目 `subagents.json` 授权 `project:<id>`,全局 `subagents.json` 授权 `global:<id>`;也可使用 `.pi/forge/config.json.subagents` 作为只读兼容来源。模型工具为 `forge_subagent_profiles` 和 `forge_subagent`。见[安全说明](../guides/delegation.md)。
|
|
50
53
|
|
|
51
54
|
## Payload
|
|
52
55
|
|
|
@@ -4,7 +4,7 @@ This example shows how trusted pi-forge extension modules can register a custom
|
|
|
4
4
|
|
|
5
5
|
It registers:
|
|
6
6
|
|
|
7
|
-
- `{{cpuLoad}}` macro: one-line CPU load summary.
|
|
7
|
+
- `{{ extensions.cpuLoad }}` macro: one-line CPU load summary.
|
|
8
8
|
- `machine-status` slot: CPU load, OS load average, memory, and uptime snapshot.
|
|
9
9
|
|
|
10
10
|
The renderers are synchronous, so this example uses Node's OS load average and memory APIs. It is a rough machine-load signal, not an async sampled CPU-utilization profiler.
|
|
@@ -53,12 +53,12 @@ Each module exports a default function or named `register` function:
|
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
55
|
export default function register(api) {
|
|
56
|
-
api.registerMacro({ name: "cpuLoad", render: () => "..." });
|
|
56
|
+
api.registerMacro({ name: "cpuLoad", dependencies: [], render: ({ env, helpers }) => "..." });
|
|
57
57
|
api.registerSlot({ name: "machine-status", render: () => "..." });
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
pi-forge passes the registration API into the function, tracks unregister callbacks, and unregisters previous definitions before reloading the folder. If the extension is not loaded, the stack can still be read, but `machine-status` will validate as an unsupported slot and `{{cpuLoad}}` will remain an unresolved
|
|
61
|
+
pi-forge passes the registration API into the function, tracks unregister callbacks, and unregisters previous definitions before reloading the folder. If the extension is not loaded, the stack can still be read, but `machine-status` will validate as an unsupported slot and `{{ extensions.cpuLoad }}` will remain an unresolved extension path.
|
|
62
62
|
|
|
63
63
|
Only use this folder for trusted code. These modules execute with normal local code permissions after the project is trusted.
|
|
64
64
|
|