@zihanw/pi-forge 0.4.1 → 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 +41 -1
- package/README.md +11 -11
- package/README.zh-CN.md +3 -5
- package/SUBAGENT_ADAPTER_CONTRACT.md +3 -1
- package/dist/agent-profile.d.ts +18 -62
- package/dist/agent-profile.d.ts.map +1 -1
- package/dist/agent-profile.js +27 -249
- package/dist/agent-profile.js.map +1 -1
- 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 +0 -105
- package/dist/forge-config.d.ts.map +1 -1
- package/dist/forge-config.js +1 -313
- 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 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -81
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.d.ts +6 -5
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +43 -112
- package/dist/lifecycle.js.map +1 -1
- package/dist/loader.d.ts +5 -8
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +10 -467
- 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 +33 -104
- 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 +15 -14
- package/dist/profile-command.js.map +1 -1
- package/dist/profile-service.d.ts.map +1 -1
- package/dist/profile-service.js +23 -39
- 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/runtime/profile-runtime.d.ts +2 -2
- package/dist/runtime/profile-runtime.d.ts.map +1 -1
- package/dist/runtime/profile-runtime.js +13 -10
- package/dist/runtime/profile-runtime.js.map +1 -1
- package/dist/runtime/prompt-stack-runtime.d.ts +4 -3
- package/dist/runtime/prompt-stack-runtime.d.ts.map +1 -1
- package/dist/runtime/prompt-stack-runtime.js +42 -57
- 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/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 +143 -146
- 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 +40 -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 +1 -68
- 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 +0 -35
- 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 +32 -103
- 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 +1 -1
- package/docs/concepts/prompt-stacks.md +5 -5
- 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 +37 -5
- package/docs/development/scoped-global-profiles-stacks.md +1 -1
- package/docs/development/setup.md +6 -4
- package/docs/getting-started.md +5 -4
- package/docs/guides/custom-macros-and-slots.md +8 -7
- package/docs/guides/debugging.md +1 -1
- package/docs/guides/delegation.md +18 -22
- package/docs/guides/migrating-to-0.5.md +107 -0
- package/docs/guides/use-cases.md +7 -11
- package/docs/guides/web-editor.md +5 -9
- package/docs/reference/commands.md +4 -3
- package/docs/reference/configuration.md +17 -18
- package/docs/reference/features.md +34 -80
- 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 +1 -1
- package/docs/zh-CN/concepts/prompt-stacks.md +4 -4
- package/docs/zh-CN/getting-started.md +3 -2
- package/docs/zh-CN/guides/delegation.md +10 -12
- package/docs/zh-CN/guides/migrating-to-0.5.md +92 -0
- package/docs/zh-CN/guides/web-editor.md +4 -4
- package/docs/zh-CN/reference/commands.md +3 -2
- 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 -343
- 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 -154
- 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 -272
- 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 -5
- package/dist/subagent-command.d.ts.map +0 -1
- package/dist/subagent-command.js +0 -249
- 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 -125
- package/dist/subagent-profile-tool.js.map +0 -1
- package/dist/subagent-tool.d.ts +0 -77
- package/dist/subagent-tool.d.ts.map +0 -1
- package/dist/subagent-tool.js +0 -559
- 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
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# pi-forge 0.5.0 architecture plan (lean)
|
|
2
|
+
|
|
3
|
+
[Documentation](../README.md) · [Roadmap](../development/roadmap.md) · [Architecture rules](../development/architecture-rules.md)
|
|
4
|
+
|
|
5
|
+
Status: accepted lean 0.5.0 scope
|
|
6
|
+
|
|
7
|
+
Date: 2026-08-18
|
|
8
|
+
|
|
9
|
+
The long-term architecture goal is unchanged. The original six-phase target plan and Phase-0 evidence are archived in [0.5 full architecture proposal](archive/0.5-full-proposal/README.md). This page is the executable 0.5.0 scope; 0.5.x continues toward the full target.
|
|
10
|
+
|
|
11
|
+
## Goal
|
|
12
|
+
|
|
13
|
+
0.5.0 is a breaking cleanup release plus the minimum foundation for later work:
|
|
14
|
+
|
|
15
|
+
- deterministic immutable prompt compilation;
|
|
16
|
+
- prompt-stack schema v2;
|
|
17
|
+
- minimal repository/codec persistence seam;
|
|
18
|
+
- optional subagents behind a versioned host port;
|
|
19
|
+
- an explicit public package surface.
|
|
20
|
+
|
|
21
|
+
It is not a platformization release.
|
|
22
|
+
|
|
23
|
+
## Accepted 0.5.0 decisions
|
|
24
|
+
|
|
25
|
+
1. **SillyTavern is removed completely.** 0.4 is the last supported conversion path. Commands, importer, regex emulation, example, guide, and tests are deleted.
|
|
26
|
+
2. **Mutable variables are removed.** Turn/session stores, `setvar`/`setturnvar`/`setsessionvar`/clear/get variable macros, `variables` slot, and `pi-forge-variable-state` entries are removed. Static values become immutable `parameters` in schema v2.
|
|
27
|
+
3. **`forge-v1` replaces the macro implementation.** One parsed grammar with interpolation, a finite filter set, and `if`/`else` over documented environment predicates. No includes, loops, function calls, general expressions, or ambient access.
|
|
28
|
+
4. **The trusted extension port is retained and redesigned in this release.** `registerMacro` and `registerSlot` survive with a pure contract. The contract is specified in [Extension port contract](#extension-port-contract-050).
|
|
29
|
+
5. **Regex `display` and `both` are removed.** Valid effects become `outgoing` and `finalize`. `finalize` behavior is retained with explicit ownership in [Finalize regex ownership](#finalize-regex-ownership-050).
|
|
30
|
+
6. **Subagents move to an optional `pi-forge-subagents` package.** The main package removes the hard dependency on `@zihanw/pi-subagent-runtime`. The main package keeps `@zihanw/pi-forge/subagent` as a versioned host port with data-only event-bus messages. The `/subagent` entry owns a minimal Forge DTO host contract — wire messages, recursive validators, transport, and client/host lifecycle — plus a Forge-owned canonical fingerprint helper that stays byte-compatible with the runtime's `sha256:v1` canonical JSON. The 0.4 execution contract (the Forge host product types layered over the runtime's portable contract: request, preflight, plan, response, context, tool negotiation, and their validators) moves to the optional package with names unchanged; the optional package imports the runtime's portable leaves directly.
|
|
31
|
+
7. **The 0.5.0 host port has a minimal operation catalogue and mandatory lifecycle rules.** Operations are discovery, profile listing/snapshot, and prompt preparation. Correlation IDs, payload validation, timeouts, host generation, duplicate-host failure, disposal/`unavailable`, and listener cleanup are part of host port v1, not deferred.
|
|
32
|
+
8. **`ForgeWorkspace` is the minimal resource-state owner, and all stack/profile persistence goes through minimal repositories and codecs in 0.5.0.** Repositories own scoped discovery and mutation; codecs own parse/normalize/validate/serialize. Expected-fingerprint writes and guaranteed atomic replacement are 0.5.x work.
|
|
33
|
+
9. **Configuration ownership uses dedicated optional-package files.** Main package owns `webEditor.*` in `.pi/forge/config.json` and its global equivalent. The optional package owns `.pi/forge/subagents.json` and `~/.pi/forge/subagents.json`. Main pi-forge does not read, write, validate, or clean subagent configuration. Legacy `config.json.subagents` is read-only fallback material for the optional package, with warnings and no automatic migration.
|
|
34
|
+
10. **Web editor delegation UI is removed from the main package in 0.5.0.** The optional package ships config-only for delegation. A small standalone optional-package editor page is the 0.5.x path; a main-editor contribution port is not designed now.
|
|
35
|
+
11. **Pi session custom entries:** newly written stack/profile entries use a `schemaVersion` envelope. Unversioned 0.4 entries are decoded through legacy readers. `pi-forge-variable-state` is never restored or written; one bounded diagnostic is emitted per restoration.
|
|
36
|
+
12. **Public surfaces are exactly three intentional entry points:** package root default factory, package root named extension API (`registerMacro`, `registerSlot`, and their contract types), and `@zihanw/pi-forge/subagent`. All other root re-exports and `src/*` aliases are removed. `check-package` enforces this allowlist.
|
|
37
|
+
13. **Migration is a small utility plus release notes, not a framework.** A v1-to-v2 script converts mechanical `variables`/macro fields with explicit diagnostics; removed behavior is never silently approximated.
|
|
38
|
+
|
|
39
|
+
## Extension port contract (0.5.0)
|
|
40
|
+
|
|
41
|
+
The 0.5.0 extension contract is part of the breaking release. It is a trusted-extension port, not a security boundary.
|
|
42
|
+
|
|
43
|
+
- `PromptEnvironment` is a deep-frozen, JSON-compatible snapshot with three path roots:
|
|
44
|
+
- `runtime.*` — documented built-in runtime facts;
|
|
45
|
+
- `parameters.*` — immutable stack parameters;
|
|
46
|
+
- `extensions.*` — registered extension values.
|
|
47
|
+
- `registerMacro` registers a named, zero-argument pure value renderer:
|
|
48
|
+
- inputs: `{ env: PromptEnvironment; helpers: PromptRenderHelpers }`;
|
|
49
|
+
- declaration: `{ name, description?, source?, dependencies: string[] }`;
|
|
50
|
+
- returns a `string`; `throw` produces a compiler error diagnostic and no partial output;
|
|
51
|
+
- addressed in templates as `{{ extensions.<name> }}`.
|
|
52
|
+
- `registerSlot` keeps option-schema validation and is addressed by `kind: "slot"`:
|
|
53
|
+
- inputs: `{ item, options, env, helpers }`;
|
|
54
|
+
- same declaration, return, and error semantics as macros.
|
|
55
|
+
- Dependency declarations are authoritative for the analyzer. A renderer must only read declared paths; undeclared reads are contract violations, not enforced isolation.
|
|
56
|
+
- Output limits are enforced by the compiler: 100,000 characters per compiled template and 16,384 characters per extension macro/slot value.
|
|
57
|
+
- Registration identity is name-based and global within the Forge extension loader. Duplicate registration throws; unregistration returns a disposer. The workspace owns load/reload/dispose ordering and reuses the current trusted extension discovery directories.
|
|
58
|
+
- Preview, runtime, and subagent preparation use the same analyzer output. No consumer may parse template syntax independently.
|
|
59
|
+
|
|
60
|
+
## Finalize regex ownership (0.5.0)
|
|
61
|
+
|
|
62
|
+
`finalize` is retained, but is explicitly outside deterministic prompt compilation:
|
|
63
|
+
|
|
64
|
+
- **Owner:** the lifecycle/transcript adapter, not the compiler.
|
|
65
|
+
- **Order:** after the provider returns a finalized assistant message, before that message is stored in the transcript.
|
|
66
|
+
- **Constraints:** `stage: "compiled"`, `targets: ["messages"]`, and assistant roles only, as validated today.
|
|
67
|
+
- **Preview:** preview and runtime prompt compilation never apply `finalize`. Preview reports an informational diagnostic that finalize rules are not represented.
|
|
68
|
+
- **Restoration:** the original model output is not preserved. This remains a documented, user-enabled destructive transform carried over from 0.4.
|
|
69
|
+
- **Tests:** 0.5.0 adds characterization coverage for finalize ordering and non-application during preview.
|
|
70
|
+
|
|
71
|
+
## Minimal target state
|
|
72
|
+
|
|
73
|
+
```mermaid
|
|
74
|
+
flowchart LR
|
|
75
|
+
Adapters["Commands + lifecycle + web editor"] --> Workspace["ForgeWorkspace"]
|
|
76
|
+
Workspace --> Repos["Minimal repositories + codecs"]
|
|
77
|
+
Workspace --> Compiler["forge-v1 compiler"]
|
|
78
|
+
Compiler --> Extensions["Trusted extension port"]
|
|
79
|
+
Workspace -. "event-bus host port v1" .-> Optional["pi-forge-subagents"]
|
|
80
|
+
Optional --> Runtime["pi-subagent-runtime"]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The final layered target (core modules, full application services, complete host catalogue, fingerprint/atomic persistence) remains the archived full plan and is reached in 0.5.x.
|
|
84
|
+
|
|
85
|
+
## Implementation lanes
|
|
86
|
+
|
|
87
|
+
Only one lane is active at a time. Each lane ends with `npm run verify` green and committed.
|
|
88
|
+
|
|
89
|
+
### Lane 0: documentation convergence
|
|
90
|
+
|
|
91
|
+
Archive the full proposal, make this lean plan active, and simplify repository guidance and PR requirements.
|
|
92
|
+
|
|
93
|
+
### Lane 1a: removals only
|
|
94
|
+
|
|
95
|
+
- Remove SillyTavern code, tests, examples, and guides.
|
|
96
|
+
- Remove mutable variable stores, variable session entries, variable macros, and the `variables` slot.
|
|
97
|
+
- Remove regex `display`/`both` and make them validation errors.
|
|
98
|
+
- Keep static `stack.variables` working through the existing compiler until schema v2 lands in Lane 1b.
|
|
99
|
+
- Update only tests that cover removed behavior.
|
|
100
|
+
|
|
101
|
+
### Lane 1b: compiler, schema v2, and extension contract
|
|
102
|
+
|
|
103
|
+
- Implement `forge-v1` parse/analyze/render.
|
|
104
|
+
- Introduce frozen `PromptEnvironment` and make preview/runtime/subagent preparation share one compiler entry.
|
|
105
|
+
- Introduce schema v2 with immutable `parameters`.
|
|
106
|
+
- Implement the [extension port contract](#extension-port-contract-050).
|
|
107
|
+
- Retain `finalize` under the ownership rule above and add its characterization coverage here.
|
|
108
|
+
- Add compiler/schema/extension conformance coverage.
|
|
109
|
+
|
|
110
|
+
### Lane 1c: migration and documentation
|
|
111
|
+
|
|
112
|
+
- Add the small v1-to-v2 migration script with explicit diagnostics.
|
|
113
|
+
- Migrate examples and update English and Chinese user-facing compiler/schema/extension docs.
|
|
114
|
+
- Update changelog and migration notes for the Lane 1 breaks.
|
|
115
|
+
|
|
116
|
+
### Lane 1d: compiler/extension conformance
|
|
117
|
+
|
|
118
|
+
- Make custom slot extensions symmetric with macros: pure `{ item, options, env, helpers }` render context, declared `dependencies`, and the same 16,384-character output limit.
|
|
119
|
+
- Resolve declared extension dependencies when populating `env.extensions` for slot rendering.
|
|
120
|
+
- Introduce a reusable prompt dependency analysis plan (direct dependencies, transitive extension closure, slot dependencies, diagnostics) shared by runtime compilation, preview, and subagent preparation.
|
|
121
|
+
- Create one compilation context per provider-preparation cycle with a single runtime/timestamp snapshot, frozen base environment, and request-local extension cache shared between system and message compilation; this applies to the runtime lifecycle (`before_agent_start` + `context`), preview rendering, and subagent host preparation alike. Cache entries are keyed by name and frozen environment snapshot; `latestUserMessage` is the one captured field that can change between phases, and `setLatestUserMessage` invalidates the cache only when the value actually changes, so env-dependent macros observe the current value instead of a stale pre-phase snapshot. Tradeoff: when the value does change, the whole request-local cache is dropped, so a stateful/non-deterministic macro appearing in both phases may render different values per phase (system keeps the pre-invalidation value, messages get a fresh one); the two phases still share one explicit timestamp snapshot.
|
|
122
|
+
- Keep dependency analysis eager, but resolve extension values lazily during rendering so unreachable branches do not execute extensions.
|
|
123
|
+
- Support nested `{% if %}` blocks with a recursion-depth guard.
|
|
124
|
+
- Fix parser conformance issues such as empty-string comparisons and strict undefined handling.
|
|
125
|
+
- Clarify or document `maxChars` best-effort semantics and separate empty-system-prompt fallback from compile failure.
|
|
126
|
+
- Add focused conformance tests for all of the above.
|
|
127
|
+
|
|
128
|
+
### Lane 2a: minimal repositories and codecs
|
|
129
|
+
|
|
130
|
+
- Extract stack/profile codecs as the single parse/normalize/validate/serialize source: `src/codecs/prompt-stack.ts` and `src/codecs/agent-profile.ts` own parse/normalize/validate/serialize, and the loaders (and migration tooling) delegate to them; repositories (`src/repositories/`) are the only read/write/delete path for domain resources — reads (directory enumeration + file reads through the codecs) and mutations (scope/containment/symlink-checked writes and deletes) both live there, and `loader.ts`/`agent-profile.ts` only delegate.
|
|
131
|
+
- Extract scoped repositories as the only domain resource read/write/delete path, including scope and containment validation. Legacy stack migration is a documented byte-preserving exception: its raw IO lives in the repository (read/copy/delete for `.pi/prompt-stacks`), while canonicalization happens on every subsequent load through the codecs.
|
|
132
|
+
- Remove direct domain-resource writes from web host, commands, and profile service.
|
|
133
|
+
- Do not add expected-fingerprint conflicts or guaranteed atomic replacement yet; characterize current replacement behavior with tests.
|
|
134
|
+
|
|
135
|
+
### Lane 2b: ForgeWorkspace and host port v1
|
|
136
|
+
|
|
137
|
+
- Introduce `ForgeWorkspace` as the minimal snapshot owner over the Lane 2a repositories: one immutable scoped stack/profile snapshot plus active selection/provenance, owning host registration/generation/disposal.
|
|
138
|
+
- Publish `@zihanw/pi-forge/subagent` host port v1 over the Pi event bus with mandatory lifecycle rules and the three minimal operations (discovery, profile listing/snapshot, and prompt preparation). The port is transport-neutral (`ForgeHostTransport`), uses plain validated data messages, and never crosses live contexts or internal registries.
|
|
139
|
+
- Mandatory lifecycle semantics: clients subscribe before announcing/discovering and use bounded timeouts; duplicate live hosts fail with an explicit `host.duplicate` error; disposal sends `unavailable` and invalidates connections; all transient and persistent listeners are cleaned up. `request`/`reply` wire messages carry `hostId` + `generation`, so stale-generation and wrong-host requests are rejected server-side and mismatched replies are ignored client-side.
|
|
140
|
+
- Host-owned preparation: the client sends only a profile selector, task, prompt-compilation access facts (`level`/`network`/`allowProcess`) and backend facts (model/thinking/tool catalog); the workspace resolves the profile + stack from its snapshot and compiles the prompt itself, returning an immutable preparation artifact (system prompt, messages, effective tools, diagnostics, and profile snapshot). No execution/runtime material (access workspace model, limits, `resultProjection`/`parent`/`remoteEgressConsent`, or a base prompt) crosses the boundary. Each operation has a recursive, exact-field, JSON-compatible validator (plain objects only, enums enforced) at the wire boundary.
|
|
141
|
+
- `ForgeWorkspace` snapshots are genuinely immutable (deep-frozen clones), and the host port is wired into the real extension lifecycle (`pi.events` transport; reload on session start/tree/compact; dispose on session shutdown, before subagent teardown). The host can only be started after the first snapshot exists (`startHostPort` throws otherwise), so `host available` ⇒ `snapshotKnown`; `reload` honors project trust (untrusted workspaces expose global resources only). The base system prompt is host-owned and intentionally empty for delegated subagents — the prompt stack composes the system prompt, and the host rejects unknown request fields so no prompt-runtime material can be smuggled across the boundary.
|
|
142
|
+
- Cover timeout, duplicate-host failure, generation/stale-request rejection, disposal, listener cleanup, operation validators, immutability, and a real-factory integration discovery->list->prepare->dispose flow in tests.
|
|
143
|
+
|
|
144
|
+
### Lane 3: subagent extraction
|
|
145
|
+
|
|
146
|
+
- Create `pi-forge-subagents` by moving current subagent commands, tools, config parsing/writing, and execution code.
|
|
147
|
+
- Optional package depends only on documented host-port messages and owns the dedicated `subagents.json` files, with read-only legacy fallback.
|
|
148
|
+
- Remove main-package delegation UI and all subagent configuration reads/writes.
|
|
149
|
+
- Main package installs and passes verification without the subagent runtime.
|
|
150
|
+
- Optional package passes packed-install smoke tests.
|
|
151
|
+
|
|
152
|
+
### Lane 3.5: host-neutrality hardening
|
|
153
|
+
|
|
154
|
+
Emergent lane recorded after the fact; executed in three stages.
|
|
155
|
+
|
|
156
|
+
- Stage 1: make the prompt compiler host-neutral.
|
|
157
|
+
- Stage 2: make `ForgeWorkspace` the single resource-state owner.
|
|
158
|
+
- Stage 3: align subagent docs/config with the optional package and make the packed smoke portable. The optional package gains profile discovery, the `/forge-agent` command, legacy config fallback, and tool-description summary refresh.
|
|
159
|
+
|
|
160
|
+
### Lane 4: public surface and release
|
|
161
|
+
|
|
162
|
+
Lane 4a: Forge-native host contract (both packages).
|
|
163
|
+
|
|
164
|
+
- The main package drops the `@zihanw/pi-subagent-runtime` dependency entirely. (An earlier draft of this lane kept the runtime as the `/subagent` contract library; that contradicted decision 6 and the release gates and is removed.) `/subagent` owns the minimal Forge DTO host contract described in decision 6.
|
|
165
|
+
- Workspace prompt preparation becomes Forge-native: resolve profile and stack from the snapshot, compile through the shared compilation context, filter the client tool catalog through stack policy, and return the `prepare` DTO directly. The synthetic AgentRequest/preflight/prompt-runtime construction is removed.
|
|
166
|
+
- The 0.4 execution contract modules move to the optional package per decision 6; contract tests move with the code.
|
|
167
|
+
|
|
168
|
+
Lane 4b: main-package public-surface cut.
|
|
169
|
+
|
|
170
|
+
- Root exports reduce to the default factory plus `registerMacro`/`registerSlot` and their contract types; `/subagent` exports the host contract only; `src/*` aliases are removed.
|
|
171
|
+
- `check-package` flips from requiring legacy aliases to forbidding them and enforcing the three-entry allowlist; public-API tests assert exact export name sets; packed-install smoke assertions follow the trimmed surface.
|
|
172
|
+
|
|
173
|
+
Lane 4c: optional-package packed smoke.
|
|
174
|
+
|
|
175
|
+
- The optional package gains its own `check:packed`: pack both packages, install into a temporary consumer, load the extension, and run discover → listProfiles → prepare → dispose over a loopback `ForgeHostTransport` against a fixture workspace.
|
|
176
|
+
|
|
177
|
+
Lane 4d: documentation and changelog.
|
|
178
|
+
|
|
179
|
+
- Update English and Chinese user-facing docs for breaking changes: rewrite the public-API policy for the three surfaces, replace the subagent adapter contract reference with the host-port contract, complete the 0.5 migration guide (Lanes 2–4) in English and Chinese, and fix stale README references.
|
|
180
|
+
- Write changelog entries for Lanes 3.5 and 4 and one-page migration notes.
|
|
181
|
+
|
|
182
|
+
Lane 4e: release.
|
|
183
|
+
|
|
184
|
+
- Run main-only and main-plus-optional packed-install verification (`check:packed` smoke), version both packages 0.5.0, publish main then optional, smoke the published artifacts, and tag.
|
|
185
|
+
|
|
186
|
+
## Release gates
|
|
187
|
+
|
|
188
|
+
- `npm run verify` passes.
|
|
189
|
+
- All stack/profile persistence goes through minimal repositories and codecs.
|
|
190
|
+
- Runtime and preview compile through one `forge-v1` entry point.
|
|
191
|
+
- Host port v1 passes discovery, timeout, generation, duplicate-host, and disposal tests.
|
|
192
|
+
- `finalize` ordering and preview exclusion are characterized.
|
|
193
|
+
- Schema v2, extension contract, and migration notes are documented.
|
|
194
|
+
- Main package has no subagent runtime dependency and passes packed smoke tests alone.
|
|
195
|
+
- Optional package passes packed smoke tests through host port v1 and owns only its dedicated config files.
|
|
196
|
+
- No non-allowlisted root exports or `src/*` aliases remain.
|
|
197
|
+
- User-facing breaking changes are documented in English and Chinese.
|
|
198
|
+
|
|
199
|
+
## Deferred to 0.5.x
|
|
200
|
+
|
|
201
|
+
These items come from the archived full plan and are intentionally not part of 0.5.0:
|
|
202
|
+
|
|
203
|
+
- expected-fingerprint conflict writes and guaranteed atomic file replacement;
|
|
204
|
+
- physical `pi-forge-core` package and enforced module/package boundaries;
|
|
205
|
+
- automatic dependency-direction checking;
|
|
206
|
+
- full `PromptStackService` / `AgentProfileService` application facades;
|
|
207
|
+
- complete host RPC operation catalogue, progress events, and richer lifecycle features beyond host port v1;
|
|
208
|
+
- optional-package standalone delegation UI or a main-editor contribution port;
|
|
209
|
+
- full public-surface classification register and consumer audit repeat;
|
|
210
|
+
- rolling Pi compatibility matrix and scheduled latest-Pi probe;
|
|
211
|
+
- sandbox, staged writes, new prompt features, richer imports, and orchestration.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# 0.5 public-consumer audit
|
|
2
|
+
|
|
3
|
+
[Design index](README.md) · [0.5 migration inventory](0.5-inventory.md) · [0.5 decision drafts](0.5-phase0-decision-drafts.md)
|
|
4
|
+
|
|
5
|
+
Status: completed Phase 0 evidence; public-surface decision pending
|
|
6
|
+
|
|
7
|
+
Date: 2026-08-17
|
|
8
|
+
|
|
9
|
+
## Scope and method
|
|
10
|
+
|
|
11
|
+
This audit identifies known consumers of surfaces that Phase 6 may remove or
|
|
12
|
+
replace. It covers the repository, published npm metadata, the Pi package
|
|
13
|
+
directory, public web searches for exact import strings, and an unauthenticated
|
|
14
|
+
GitHub code-search attempt. It cannot prove that no private or unindexed
|
|
15
|
+
consumer exists.
|
|
16
|
+
|
|
17
|
+
## Findings
|
|
18
|
+
|
|
19
|
+
| Surface | Known consumer / evidence | Confidence | 0.5 implication |
|
|
20
|
+
|---|---|---|---|
|
|
21
|
+
| Default package entry | `pi.extensions` in the published manifest | High | Retain as main extension entry |
|
|
22
|
+
| `@zihanw/pi-forge/subagent` | Public-API packaged-import test; reference documentation | High | Retain only as the deliberate versioned host port |
|
|
23
|
+
| Root macro/slot registration | Custom-system-status example, user guide, and Pi package listing | High | Acknowledge a real documented integration path; publish a migration or replacement contract |
|
|
24
|
+
| Root profile/resource helper exports | Repository tests and root barrel only | Medium | No named external consumer found; do not preserve by default |
|
|
25
|
+
| `@zihanw/pi-forge/src/*` aliases | Compatibility documentation and package manifest | Medium | No named external consumer found; announce removal and retain no new alias |
|
|
26
|
+
| Root documentation pointers | Package `files` allowlist, root `PUBLIC_API.md`, root `SUBAGENT_ADAPTER_CONTRACT.md` | High | Decide whether to retain as offline redirect files |
|
|
27
|
+
| SillyTavern converter/command | Released docs, examples, and tests | High | User-facing migration obligation, but planned removal is explicit |
|
|
28
|
+
|
|
29
|
+
The local repository contains no package-style import other than its own
|
|
30
|
+
`@zihanw/pi-forge/subagent` public-surface test. It contains no downstream
|
|
31
|
+
repository or fixture that imports a `src/*` alias.
|
|
32
|
+
|
|
33
|
+
## Published-package observations
|
|
34
|
+
|
|
35
|
+
- npm reported `@zihanw/pi-forge` 0.4.1 as `latest` on 2026-08-17. Its manifest
|
|
36
|
+
contains the root and `/subagent` exports, the three `src/*` compatibility
|
|
37
|
+
patterns, and `@zihanw/pi-subagent-runtime` as a hard dependency.
|
|
38
|
+
- The same manifest identifies Pi SDK packages and `typebox` as wildcard peers.
|
|
39
|
+
- The Pi package directory is discoverable and documents `registerMacro` and
|
|
40
|
+
`registerSlot` as reusable-package APIs. At crawl time it displayed stale
|
|
41
|
+
0.3.2 package metadata, despite npm reporting 0.4.1. It is useful evidence of
|
|
42
|
+
discoverability, not an authoritative release or consumer record.
|
|
43
|
+
|
|
44
|
+
## Search results and limitations
|
|
45
|
+
|
|
46
|
+
- Exact public-web searches for `@zihanw/pi-forge`,
|
|
47
|
+
`@zihanw/pi-forge/subagent`, and `@zihanw/pi-forge/src/` found the package
|
|
48
|
+
listing and this repository's published material, but no independent source
|
|
49
|
+
import.
|
|
50
|
+
- Unauthenticated GitHub code search rejected the exact-import query with HTTP
|
|
51
|
+
401. A maintainer with appropriate access should repeat it, including private
|
|
52
|
+
organization repositories, before a release removes compatibility exports.
|
|
53
|
+
- npm does not provide a reliable reverse-dependency list for this extension;
|
|
54
|
+
download counts cannot identify source/API consumers.
|
|
55
|
+
|
|
56
|
+
## Required release follow-up
|
|
57
|
+
|
|
58
|
+
Before Phase 6, repeat the search with maintainer GitHub credentials, inspect
|
|
59
|
+
support/issues/discussions for named integrations, and add every discovered
|
|
60
|
+
consumer to the public-surface decision register. The absence of a discovered
|
|
61
|
+
consumer supports removal only under the 0.5 breaking-release policy; it is not
|
|
62
|
+
a claim that no consumer exists.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# 0.5.0 migration inventory
|
|
2
|
+
|
|
3
|
+
[Design index](README.md) · [0.5 architecture plan](architecture-0.5.md) · [Architecture rules](../../../development/architecture-rules.md)
|
|
4
|
+
|
|
5
|
+
Status: Phase 0 evidence; not an accepted architecture decision
|
|
6
|
+
|
|
7
|
+
Date: 2026-08-17
|
|
8
|
+
|
|
9
|
+
This inventory records the 0.4.1 surfaces that 0.5 must retain, migrate, remove,
|
|
10
|
+
or deliberately replace. It is a characterization aid, not a promise to preserve
|
|
11
|
+
every current behavior. The 0.5 plan remains authoritative, and a maintainer must
|
|
12
|
+
accept any new boundary or product decision before implementation.
|
|
13
|
+
|
|
14
|
+
## Snapshot and method
|
|
15
|
+
|
|
16
|
+
The inventory is based on tracked source, tests, the package manifest, and
|
|
17
|
+
documentation at commit `5b56096`. It lists in-repository consumers and
|
|
18
|
+
documented integration surfaces. It cannot establish unknown downstream npm
|
|
19
|
+
consumers; that check remains a Phase 6 release task.
|
|
20
|
+
|
|
21
|
+
| Area | Current evidence | 0.5 disposition |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| Prompt stacks | Schema v1 files, project/global catalogs, legacy project read path, compiler, macros, slots, regex, tool/skill policy | Keep as v2 compiler/resource work; remove mutable variables; audit finalized regex; retire legacy storage compatibility on the documented path |
|
|
24
|
+
| Agent profiles | Schema v1 files, project/global catalogs, model/thinking/stack preflight, apply, provenance, drift | Keep as a separate domain and service; introduce v2 only if storage changes |
|
|
25
|
+
| Runtime state | One `PiForgeRuntimeState` owns resources, lifecycle values, presentation/debug state, and variables | Replace with workspace-owned resource snapshot plus separate adapter state slices |
|
|
26
|
+
| Browser editor | Token-gated localhost HTTP server; host performs resource workflows and direct writes | Retain as an adapter; move resource mutation and validation into services/repositories |
|
|
27
|
+
| Subagents | Main extension registers commands/tools and directly depends on `@zihanw/pi-subagent-runtime` | Extract as optional package behind a versioned public host port |
|
|
28
|
+
| SillyTavern | Import command, converter, report, guide, example, tests | Remove completely; require conversion on 0.4 before upgrading |
|
|
29
|
+
| Package surface | Root exports, `/subagent`, and `src/*` compatibility patterns | Replace with explicit 0.5 entries; retain only intentional public ports |
|
|
30
|
+
|
|
31
|
+
## Public package and extension surfaces
|
|
32
|
+
|
|
33
|
+
### Package manifest
|
|
34
|
+
|
|
35
|
+
- Package: `@zihanw/pi-forge` 0.4.1; Pi entry: `dist/index.js`.
|
|
36
|
+
- Public exports: package root, `@zihanw/pi-forge/subagent`, examples, and broad
|
|
37
|
+
compiled `@zihanw/pi-forge/src/*` compatibility aliases. Browser client paths
|
|
38
|
+
are explicitly blocked.
|
|
39
|
+
- Pi SDK packages and `typebox` are optional wildcard peers. The repository's
|
|
40
|
+
development fixture is Pi 0.83.0; no minimum or tested Pi range is published.
|
|
41
|
+
- `@zihanw/pi-subagent-runtime@0.1.0-beta.2` is currently a hard dependency.
|
|
42
|
+
- `PUBLIC_API.md` and `SUBAGENT_ADAPTER_CONTRACT.md` are npm-published root
|
|
43
|
+
compatibility pointers to the authoritative reference documentation. Their
|
|
44
|
+
0.5 package-file and redirect status is not yet decided.
|
|
45
|
+
|
|
46
|
+
### Root exports grouped by intent
|
|
47
|
+
|
|
48
|
+
| Current surface | Evidence / consumer | 0.5 review action |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| Default Pi extension factory | `src/index.ts`; `pi.extensions` manifest | Keep as main package entry point |
|
|
51
|
+
| Resource identity/catalog/loader helpers | Root barrel and tests | Decide whether each is a stable domain export or internal |
|
|
52
|
+
| Macro/slot registration and Forge extension API | Root barrel; custom-system-status example and guide | Preserve only as an intentional trusted-extension port, compatible with immutable compilation |
|
|
53
|
+
| Profile repository/resolution/application APIs | Root barrel and profile tests | Replace experimental APIs with deliberate service/domain exports if external consumers exist |
|
|
54
|
+
| Subagent contract and host preparation helpers | Root compatibility re-exports and `/subagent` entry | Keep `/subagent`, but replace its current internal host-preparation surface with a versioned port |
|
|
55
|
+
| `src/*` aliases | Documentation and package checks | Remove in Phase 6 after consumer audit and migration notice |
|
|
56
|
+
|
|
57
|
+
The only in-repository package-style import is the public-API test of
|
|
58
|
+
`@zihanw/pi-forge/subagent`. Documentation identifies trusted macro/slot
|
|
59
|
+
extension authors as intended consumers. No external consumer audit is recorded.
|
|
60
|
+
|
|
61
|
+
### Phase-0 public-surface decision register
|
|
62
|
+
|
|
63
|
+
This is the required decision format for the final public-surface review. The
|
|
64
|
+
listed dispositions are provisional until consumer audit and maintainer review;
|
|
65
|
+
Phase 6 must execute this register rather than make API decisions while deleting
|
|
66
|
+
exports.
|
|
67
|
+
|
|
68
|
+
| 0.4 surface group | Candidate 0.5 disposition | Target entry point / migration | Known consumer | Decision status |
|
|
69
|
+
|---|---|---|---|---|
|
|
70
|
+
| Default extension factory | Stable | Package root default export | Pi package manifest | Provisional: retain |
|
|
71
|
+
| Macro/slot and trusted Forge extension registration | Stable or experimental | Deliberate main-package extension port | Custom-system-status example; documented trusted extension authors | Pending compiler-extension contract |
|
|
72
|
+
| Resource identity/catalog/loader helpers | Internal unless a named consumer requires a domain port | No `src/*` replacement by default | Root barrel and tests only | Pending consumer audit |
|
|
73
|
+
| Profile repository/resolution/application helpers | Experimental or internal | Deliberate service/domain entry only if justified | Root barrel and tests only | Pending service boundary and consumer audit |
|
|
74
|
+
| `/subagent` host contract | Versioned experimental host port | `@zihanw/pi-forge/subagent` | Public-API test; future optional extension | Pending host-discovery decision |
|
|
75
|
+
| Root re-exports of subagent names | Remove or retain only as one-release migration shim | Direct consumers to `/subagent` | 0.4 compatibility policy | Pending consumer audit and migration decision |
|
|
76
|
+
| `src/*` aliases | Remove | Intentional entries only | Compatibility documentation | Planned removal in Phase 6 |
|
|
77
|
+
| `PUBLIC_API.md` and `SUBAGENT_ADAPTER_CONTRACT.md` | Retain as package pointers or replace with package-local index | Decide published-file policy with the final entries | `files` allowlist and current documentation | Pending Phase 6 public-doc decision |
|
|
78
|
+
|
|
79
|
+
## Persisted resources and state
|
|
80
|
+
|
|
81
|
+
### Resource files
|
|
82
|
+
|
|
83
|
+
| Resource | Locations | Schema / current behavior | Migration concern |
|
|
84
|
+
|---|---|---|---|
|
|
85
|
+
| Prompt stack | Project `.pi/forge/prompt-stacks/*.json`; global `~/.pi/forge/prompt-stacks/*.json`; legacy project `.pi/prompt-stacks/*.json` read path | v1 `PromptStack`; scoped project-over-global resolution; loader normalizes and validates | Define v1→v2 codec, retained regex fields, `variables`→immutable `parameters`, conflict/backup behavior, and final legacy-path removal |
|
|
86
|
+
| Agent profile | Project `.pi/forge/agent-profiles/*.json`; global `~/.pi/forge/agent-profiles/*.json` | v1 `pi-forge.agent-profile`; model, thinking level, relative scoped stack reference, optional auto-activation | Preserve IDs/scoped references where possible; decide whether v2 is needed and document any rewrite |
|
|
87
|
+
| Main-package configuration | Project/global `.pi/forge/config.json` | `webEditor.port` | Main package owns the editor setting; keep it outside stack/profile repositories |
|
|
88
|
+
| Subagent configuration | Currently project/global `.pi/forge/config.json`, `subagents.*` | Defaults, per-profile authorization, backend/timeout, unattended invocation and summary flag | Open: optional package must own parsing, validation, writes, and migration; decide whether it remains a namespaced shared file or moves to a dedicated file |
|
|
89
|
+
| Trusted Forge extensions | Project/global `.pi/forge/extensions/*.{ts,js,mjs,cjs}` | Executable macro/slot registrations, loaded on trusted projects | Workspace owns registration lifecycle; compiler v2 must define the replacement extension contract |
|
|
90
|
+
| Payload captures | User-selected path, commonly `.pi/forge/payloads/last.json` | Redacted provider payload, potentially sensitive | Presentation/debug artifact, not workspace resource state |
|
|
91
|
+
|
|
92
|
+
### Pi session custom entries
|
|
93
|
+
|
|
94
|
+
| Entry type | Stored data | Current restoration | 0.5 requirement |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| `pi-forge-prompt-stack-state` | `activeStackId` | Latest branch entry selects scoped active stack | Version/restoration and v1 selector migration policy |
|
|
97
|
+
| `pi-forge-agent-profile-state` | Profile provenance or `null` | Latest branch entry drives drift status; does not reapply profile | Version/restoration policy and compatibility with profile schema changes |
|
|
98
|
+
| `pi-forge-variable-state` | Mutable session variables | Latest branch entry restores variables | Remove and provide an explicit ignored/diagnostic migration path; do not write a replacement |
|
|
99
|
+
|
|
100
|
+
These entry payloads have no explicit version today. This requires a state
|
|
101
|
+
decision and migration notes under the architecture rules.
|
|
102
|
+
|
|
103
|
+
## Runtime ownership and Pi coupling
|
|
104
|
+
|
|
105
|
+
`PiForgeRuntimeState` currently holds stacks, profiles, active selection,
|
|
106
|
+
profile provenance, compile inputs/variables, diagnostics, Forge-extension
|
|
107
|
+
registration metadata, payload capture, and browser-facing state. Its users span
|
|
108
|
+
the stack, profile, policy, web-editor, payload, lifecycle, and subagent paths.
|
|
109
|
+
|
|
110
|
+
| Pi coupling | Current owner / use | 0.5 target |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| Lifecycle | Session, resource-discovery, tree/compact/shutdown, input/turn, compilation/context and message events | Pi adapter translates events to workspace/services and owns adapter-only transient state |
|
|
113
|
+
| Compilation | `before_agent_start` and `context` provide live Pi context, clock, system options and messages | Normalize inputs once into immutable `PromptEnvironment`; preview and runtime share the compiler |
|
|
114
|
+
| Tool policy | Pi active-tool APIs plus input/turn reassertion and tool-call guard | `ToolPolicyPort`; preserve baseline reconciliation with other extensions |
|
|
115
|
+
| Profile application | Pi model/thinking setters plus active-stack mutation and rollback | Runtime-controller port with preflight and documented compensation semantics |
|
|
116
|
+
| Extension registrations | Forge loader mutates macro/slot registries | Workspace-coordinated trusted registration lifecycle, without core importing Pi adapters |
|
|
117
|
+
| Subagents | Main extension creates runtime/backends and reads shared state | Optional extension calls only the versioned Forge host capability |
|
|
118
|
+
|
|
119
|
+
## Commands, tools, and HTTP adapter surface
|
|
120
|
+
|
|
121
|
+
| Surface | Current operations | 0.5 disposition |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| `/preset` | List, status, use/disable, preview, validate, diagnostics, reload, UI, legacy migration, SillyTavern import | Keep ordinary stack operations as service calls; remove legacy migration command after documented migration and remove SillyTavern command |
|
|
124
|
+
| `/profile` | List, use, save, status, preview, validate, reload, forget | Keep as thin profile-service adapter |
|
|
125
|
+
| `/payload` and `/intercept` | Arm/display/save redacted next provider payload | Keep as separate debug/presentation slice; decide path-safety independently of domain resources |
|
|
126
|
+
| `/forge-agent` | Backends, dry plan, approved run | Move with optional subagent integration |
|
|
127
|
+
| `forge_subagent_profiles` and `forge_subagent` | Enabled-profile discovery and foreground delegation | Move with optional subagent integration |
|
|
128
|
+
| Local editor HTTP API | Stack/profile list/get/validate/create/save/delete/apply/reload/activate; resources; payload; delegation config | Retain token-gated localhost adapter; map typed service results to HTTP and remove workflow/persistence from web host |
|
|
129
|
+
|
|
130
|
+
The editor binds to `127.0.0.1`, uses a per-server random token, and accepts the
|
|
131
|
+
token in the query/header. Browser source remains under `src/web-editor/client/`;
|
|
132
|
+
generated embedded assets must not be hand edited.
|
|
133
|
+
|
|
134
|
+
## Current resource mutation locations
|
|
135
|
+
|
|
136
|
+
| Location | Current mutation | Phase 1 target |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `web-host.ts` | Stack/profile/config reads and writes, deletes, creation, import routing | Adapter invokes repositories/services only |
|
|
139
|
+
| `profile-service.ts` | Profile create/write/delete | Move filesystem behavior to profile repository and codec |
|
|
140
|
+
| `preset-command.ts` | SillyTavern converted stack/report writes | Remove with SillyTavern surface |
|
|
141
|
+
| `stack-migration.ts` | Legacy stack copy/delete | Retire after the documented pre-0.5 migration path |
|
|
142
|
+
| `forge-config.ts` | Configuration writes | Separately owned configuration concern unless explicitly redesigned |
|
|
143
|
+
| `payload-command.ts` | User-requested payload file write | Debug artifact, not a domain-resource repository |
|
|
144
|
+
|
|
145
|
+
Current resource mutation has path-containment and symlink checks in several
|
|
146
|
+
paths, but replacement writes are not uniformly atomic and stack mutations do
|
|
147
|
+
not uniformly carry expected fingerprints. Phase 1 must characterize these
|
|
148
|
+
behaviors before changing them.
|
|
149
|
+
|
|
150
|
+
## Tooling and verification surface
|
|
151
|
+
|
|
152
|
+
| Tooling | Current enforcement | 0.5 review action |
|
|
153
|
+
|---|---|---|
|
|
154
|
+
| `scripts/check-package.mjs` | Package tarball layout, wildcard Pi peers, `src/*` compatibility exports, blocked browser paths | Update with final explicit entry points and root compatibility-pointer policy in Phase 6 |
|
|
155
|
+
| `scripts/check-dist.mjs` | Generated `dist/` matches authored source | Update only alongside intentional source/package layout changes |
|
|
156
|
+
| `scripts/check-docs.mjs` | Local documentation-link validation | Keep links current as 0.5 guides, migration material, and redirects replace 0.4 documentation |
|
|
157
|
+
| `scripts/build-web-client.mjs` | Generated embedded browser script/style synchronization | Preserve; regenerate only from authored `src/web-editor/client/` changes |
|
|
158
|
+
| Public API and package tests | Root/subagent export compatibility and packed-entry behavior | Replace 0.4 compatibility assertions with the accepted public-surface register in Phase 6 |
|
|
159
|
+
|
|
160
|
+
`package.json` scripts, the browser suite, build/type checks, and packed-install
|
|
161
|
+
smoke tests are part of the release evidence. The final verification matrix must
|
|
162
|
+
test the documented Pi range with and without the optional subagent package.
|
|
163
|
+
|
|
164
|
+
## Documentation, examples, and characterization coverage
|
|
165
|
+
|
|
166
|
+
### Released documentation requiring a 0.5 review
|
|
167
|
+
|
|
168
|
+
- Prompt-stack schema, macro/slot, agent-profile, configuration, command,
|
|
169
|
+
debugging, delegation, web-editor, getting-started, public-API, and subagent
|
|
170
|
+
contract documentation.
|
|
171
|
+
- English and Chinese user guides. Chinese internal architecture documentation
|
|
172
|
+
is not required by the plan, but user-facing breaking changes are.
|
|
173
|
+
|
|
174
|
+
### Examples and tests requiring disposition
|
|
175
|
+
|
|
176
|
+
| Item | 0.5 action |
|
|
177
|
+
|---|---|
|
|
178
|
+
| Default, image-reader, reviewer, and validation prompt-stack examples | Revalidate or migrate against schema v2 |
|
|
179
|
+
| Custom system-status extension | Retain only if it conforms to the replacement template/slot extension port |
|
|
180
|
+
| SillyTavern example, importer fixtures/tests, and guide | Remove after final 0.4 conversion path is documented |
|
|
181
|
+
| Compiler, profile, catalog, policy, lifecycle, web-editor, and subagent tests | Preserve as characterization coverage until the responsible phase replaces them |
|
|
182
|
+
| Browser editor tests | Keep through adapter migration; regenerate client assets when authored client code changes |
|
|
183
|
+
|
|
184
|
+
## Phase-0 open work and exit evidence
|
|
185
|
+
|
|
186
|
+
1. Record maintainer acceptance or amendment status for the proposed 0.5 plan.
|
|
187
|
+
2. The [external-consumer audit](0.5-consumer-audit.md) is complete with an
|
|
188
|
+
explicit unauthenticated-search limitation. Repeat it with maintainer access
|
|
189
|
+
before Phase 6 removes exports or compatibility paths.
|
|
190
|
+
3. The [template-language spike](template-language-spike.md) is complete.
|
|
191
|
+
Accept its grammar, environment, extension-port, schema, and migration
|
|
192
|
+
decisions before Phase 3.
|
|
193
|
+
4. The [Pi host-discovery spike](host-discovery-spike.md) is complete.
|
|
194
|
+
Accept its event-bus host-port protocol, operation catalogue, versioning, and
|
|
195
|
+
lifecycle rules before Phase 5.
|
|
196
|
+
5. Establish a supported Pi version range and packed-install test matrix.
|
|
197
|
+
6. Decide Pi session custom-entry versioning and restoration semantics for
|
|
198
|
+
prompt-stack state, profile state, and removed variable state.
|
|
199
|
+
7. Decide main-package versus optional-subagent ownership and storage migration
|
|
200
|
+
for `webEditor.*` and `subagents.*` configuration.
|
|
201
|
+
8. Complete and accept the public-surface decision register before Phase 6.
|
|
202
|
+
9. Turn repository/reload, profile-application, finalized-regex,
|
|
203
|
+
migration-artifact, and physical-package questions into accepted decisions
|
|
204
|
+
before their affected implementation phases.
|
|
205
|
+
|
|
206
|
+
Phase 0 exits only when this removal/migration inventory and the resulting
|
|
207
|
+
decisions are reviewed. This inventory alone authorizes no implementation
|
|
208
|
+
boundary changes.
|