@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
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { createResourceCatalog } from "./catalog.js";
|
|
2
|
+
import { hasAgentProfileErrors } from "./agent-profile.js";
|
|
3
|
+
import { readAgentProfilesScoped, readGlobalAgentProfiles } from "./repositories/agent-profile.js";
|
|
4
|
+
import { readGlobalPromptStacks, readPromptStacksScoped } from "./repositories/prompt-stack.js";
|
|
5
|
+
import { chooseDefaultStack, isDisabledPromptStackId } from "./loader.js";
|
|
6
|
+
import { formatResourceKey, parseResourceSelector } from "./resource-identity.js";
|
|
7
|
+
import { createForgeExtensionState, reloadForgeExtensions, unloadForgeExtensions } from "./forge-extensions.js";
|
|
8
|
+
import { validateListProfilesRequest, validatePrepareRequest, validatePrepareResponse, validateResolveProfileRequest, validateResolveProfileResponse, ForgeHost, } from "./subagent/host-port.js";
|
|
9
|
+
import { currentSubagentPromptRegistrationCatalog, prepareForgeDelegation, resolveSubagentHostProfile, } from "./subagent-host.js";
|
|
10
|
+
/**
|
|
11
|
+
* Single owner of the Forge resource graph.
|
|
12
|
+
*
|
|
13
|
+
* Owns one coherent, deep-frozen snapshot containing stacks, profiles, active
|
|
14
|
+
* selection, profile provenance, and extension lifecycle state. All readers
|
|
15
|
+
* (commands, web UI, lifecycle, tool policy, preview, host port) consume
|
|
16
|
+
* `snapshot()` instead of separate mutable bags.
|
|
17
|
+
*/
|
|
18
|
+
export class ForgeWorkspace {
|
|
19
|
+
extensionState = createForgeExtensionState();
|
|
20
|
+
current;
|
|
21
|
+
host;
|
|
22
|
+
get snapshotKnown() {
|
|
23
|
+
return this.current !== undefined;
|
|
24
|
+
}
|
|
25
|
+
reload(cwd, options = {}) {
|
|
26
|
+
const trusted = options.trusted !== false;
|
|
27
|
+
const stacks = trusted ? readPromptStacksScoped(cwd) : readGlobalPromptStacks();
|
|
28
|
+
if (this.extensionDiagnostics.length > 0) {
|
|
29
|
+
for (const loaded of stacks)
|
|
30
|
+
loaded.diagnostics.unshift(...this.extensionDiagnostics);
|
|
31
|
+
}
|
|
32
|
+
const profiles = trusted ? readAgentProfilesScoped(cwd) : readGlobalAgentProfiles();
|
|
33
|
+
const active = this.resolveActive(stacks, options);
|
|
34
|
+
const activeStackId = active ? formatResourceKey(active.key) : (options.activeStackId != null && isDisabledPromptStackId(options.activeStackId) ? "none" : null);
|
|
35
|
+
const snapshot = {
|
|
36
|
+
cwd,
|
|
37
|
+
stacks,
|
|
38
|
+
profiles,
|
|
39
|
+
activeStackId,
|
|
40
|
+
active,
|
|
41
|
+
lastAppliedProfile: options.lastAppliedProfile ?? this.current?.lastAppliedProfile,
|
|
42
|
+
extensionDiagnostics: this.extensionDiagnostics,
|
|
43
|
+
extensionPaths: this.extensionPaths,
|
|
44
|
+
capturedAt: new Date().toISOString(),
|
|
45
|
+
};
|
|
46
|
+
this.current = deepFreeze(structuredClone(snapshot));
|
|
47
|
+
return this.current;
|
|
48
|
+
}
|
|
49
|
+
reloadProfiles(cwd, trusted = true) {
|
|
50
|
+
if (!this.current)
|
|
51
|
+
throw new Error("ForgeWorkspace has not been reloaded.");
|
|
52
|
+
const profiles = trusted ? readAgentProfilesScoped(cwd) : readGlobalAgentProfiles();
|
|
53
|
+
return this.publish({
|
|
54
|
+
...this.current,
|
|
55
|
+
profiles,
|
|
56
|
+
capturedAt: new Date().toISOString(),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async loadExtensions(cwd) {
|
|
60
|
+
const result = await reloadForgeExtensions(cwd, this.extensionState);
|
|
61
|
+
this.extensionDiagnostics = result.diagnostics;
|
|
62
|
+
this.extensionPaths = result.loadedPaths;
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
disposeExtensions() {
|
|
66
|
+
const diagnostics = unloadForgeExtensions(this.extensionState);
|
|
67
|
+
this.extensionDiagnostics = diagnostics;
|
|
68
|
+
this.extensionPaths = [];
|
|
69
|
+
return diagnostics;
|
|
70
|
+
}
|
|
71
|
+
setActiveStack(id) {
|
|
72
|
+
if (!this.current)
|
|
73
|
+
return false;
|
|
74
|
+
if (!id || isDisabledPromptStackId(id)) {
|
|
75
|
+
this.publish({
|
|
76
|
+
...this.current,
|
|
77
|
+
activeStackId: "none",
|
|
78
|
+
active: undefined,
|
|
79
|
+
capturedAt: new Date().toISOString(),
|
|
80
|
+
});
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
const parsed = parseResourceSelector(id);
|
|
84
|
+
if (!parsed.ok)
|
|
85
|
+
return false;
|
|
86
|
+
const found = createResourceCatalog([...this.current.stacks]).resolveSelector(parsed.selector);
|
|
87
|
+
if (!found)
|
|
88
|
+
return false;
|
|
89
|
+
this.publish({
|
|
90
|
+
...this.current,
|
|
91
|
+
activeStackId: formatResourceKey(found.key),
|
|
92
|
+
active: found,
|
|
93
|
+
capturedAt: new Date().toISOString(),
|
|
94
|
+
});
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
setLastAppliedProfile(profile) {
|
|
98
|
+
if (!this.current)
|
|
99
|
+
throw new Error("ForgeWorkspace has not been reloaded.");
|
|
100
|
+
this.publish({
|
|
101
|
+
...this.current,
|
|
102
|
+
lastAppliedProfile: profile,
|
|
103
|
+
capturedAt: new Date().toISOString(),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// Read/write view used by profile-service's AgentProfileApplicationState.
|
|
107
|
+
get active() {
|
|
108
|
+
return this.current?.active;
|
|
109
|
+
}
|
|
110
|
+
set active(value) {
|
|
111
|
+
if (!value) {
|
|
112
|
+
this.setActiveStack(undefined);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!this.current)
|
|
116
|
+
throw new Error("ForgeWorkspace has not been reloaded.");
|
|
117
|
+
this.publish({
|
|
118
|
+
...this.current,
|
|
119
|
+
activeStackId: formatResourceKey(value.key),
|
|
120
|
+
active: value,
|
|
121
|
+
capturedAt: new Date().toISOString(),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
get lastAppliedProfile() {
|
|
125
|
+
return this.current?.lastAppliedProfile;
|
|
126
|
+
}
|
|
127
|
+
set lastAppliedProfile(value) {
|
|
128
|
+
this.setLastAppliedProfile(value);
|
|
129
|
+
}
|
|
130
|
+
snapshot() {
|
|
131
|
+
if (!this.current)
|
|
132
|
+
throw new Error("ForgeWorkspace has not been reloaded.");
|
|
133
|
+
return this.current;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Register the host port for the current snapshot. Idempotent: the host is
|
|
137
|
+
* only started once the first snapshot exists, so `available` never implies
|
|
138
|
+
* an unloaded workspace. On reload the live host is kept (its generation
|
|
139
|
+
* only changes via dispose).
|
|
140
|
+
*/
|
|
141
|
+
startHostPort(transport) {
|
|
142
|
+
if (!this.current)
|
|
143
|
+
throw new Error("ForgeWorkspace must be reloaded before starting the host port.");
|
|
144
|
+
if (this.host?.isLive)
|
|
145
|
+
return this.host;
|
|
146
|
+
const host = new ForgeHost(transport, {
|
|
147
|
+
capabilities: ["listProfiles", "resolveProfile", "prepare"],
|
|
148
|
+
handle: (operation, payload) => this.operate(operation, payload),
|
|
149
|
+
});
|
|
150
|
+
this.host = host;
|
|
151
|
+
host.start();
|
|
152
|
+
return host;
|
|
153
|
+
}
|
|
154
|
+
/** Invoke the minimal-operation surface against the current snapshot. */
|
|
155
|
+
operate(operation, payload) {
|
|
156
|
+
if (operation === "listProfiles")
|
|
157
|
+
return this.listProfiles(payload);
|
|
158
|
+
if (operation === "resolveProfile")
|
|
159
|
+
return this.resolveProfile(payload);
|
|
160
|
+
if (operation === "prepare")
|
|
161
|
+
return this.prepare(payload);
|
|
162
|
+
return { ok: false, error: `Unknown Forge host operation: ${operation}` };
|
|
163
|
+
}
|
|
164
|
+
listProfiles(payload) {
|
|
165
|
+
const validated = validateListProfilesRequest(payload);
|
|
166
|
+
if (!validated.ok)
|
|
167
|
+
return { ok: false, error: validated.error };
|
|
168
|
+
try {
|
|
169
|
+
const snapshot = this.snapshot();
|
|
170
|
+
return {
|
|
171
|
+
ok: true,
|
|
172
|
+
data: {
|
|
173
|
+
profiles: snapshot.profiles.map((loaded) => stripUndefined({
|
|
174
|
+
profileId: loaded.profile.id,
|
|
175
|
+
scope: loaded.scope,
|
|
176
|
+
name: loaded.profile.name,
|
|
177
|
+
description: loaded.profile.description,
|
|
178
|
+
autoActivate: loaded.profile.autoActivate,
|
|
179
|
+
model: { provider: loaded.profile.model.provider, id: loaded.profile.model.id },
|
|
180
|
+
thinkingLevel: loaded.profile.thinkingLevel,
|
|
181
|
+
promptStack: loaded.profile.promptStack,
|
|
182
|
+
usable: !hasAgentProfileErrors(loaded.diagnostics),
|
|
183
|
+
diagnostics: loaded.diagnostics,
|
|
184
|
+
})),
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
return { ok: false, error: `listProfiles failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
resolveProfile(payload) {
|
|
193
|
+
const validated = validateResolveProfileRequest(payload);
|
|
194
|
+
if (!validated.ok)
|
|
195
|
+
return { ok: false, error: validated.error };
|
|
196
|
+
const request = validated.data;
|
|
197
|
+
try {
|
|
198
|
+
const snapshot = this.resolveProfilePlan(request.profile);
|
|
199
|
+
const response = { snapshot };
|
|
200
|
+
const responseValidated = validateResolveProfileResponse(stripUndefined(response));
|
|
201
|
+
if (!responseValidated.ok)
|
|
202
|
+
return { ok: false, error: responseValidated.error };
|
|
203
|
+
return { ok: true, data: stripUndefined(response) };
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
return { ok: false, error: `resolveProfile failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/** Host-owned profile resolution returns the immutable profile snapshot artifact. */
|
|
210
|
+
resolveProfilePlan(profile) {
|
|
211
|
+
const snapshot = this.snapshot();
|
|
212
|
+
const parsed = parseResourceSelector(profile);
|
|
213
|
+
if (!parsed.ok)
|
|
214
|
+
throw new Error(`Invalid profile selector ${profile}: ${parsed.error}`);
|
|
215
|
+
const loaded = createResourceCatalog([...snapshot.profiles]).resolveSelector(parsed.selector);
|
|
216
|
+
if (!loaded)
|
|
217
|
+
throw new Error(`Unknown profile: ${profile}`);
|
|
218
|
+
if (hasAgentProfileErrors(loaded.diagnostics))
|
|
219
|
+
throw new Error(`Profile ${profile} failed loading validation.`);
|
|
220
|
+
const resolved = resolveSubagentHostProfile(loaded, {
|
|
221
|
+
promptStacks: snapshot.stacks,
|
|
222
|
+
registrations: currentSubagentPromptRegistrationCatalog(),
|
|
223
|
+
});
|
|
224
|
+
if (!resolved.snapshot)
|
|
225
|
+
throw new Error(`Profile ${profile} could not be resolved.`);
|
|
226
|
+
return resolved.snapshot;
|
|
227
|
+
}
|
|
228
|
+
prepare(payload) {
|
|
229
|
+
const validated = validatePrepareRequest(payload);
|
|
230
|
+
if (!validated.ok)
|
|
231
|
+
return { ok: false, error: validated.error };
|
|
232
|
+
const request = validated.data;
|
|
233
|
+
let response;
|
|
234
|
+
try {
|
|
235
|
+
response = stripUndefined(this.preparePlan(request));
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
return { ok: false, error: `Prepare failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
239
|
+
}
|
|
240
|
+
const responseValidated = validatePrepareResponse(response);
|
|
241
|
+
if (!responseValidated.ok)
|
|
242
|
+
return { ok: false, error: responseValidated.error };
|
|
243
|
+
return { ok: true, data: response };
|
|
244
|
+
}
|
|
245
|
+
/** Host owns profile/stack resolution and prompt compilation. */
|
|
246
|
+
preparePlan(request) {
|
|
247
|
+
const snapshot = this.snapshot();
|
|
248
|
+
const parsed = parseResourceSelector(request.profile);
|
|
249
|
+
if (!parsed.ok)
|
|
250
|
+
throw new Error(`Invalid profile selector ${request.profile}: ${parsed.error}`);
|
|
251
|
+
const loaded = createResourceCatalog([...snapshot.profiles]).resolveSelector(parsed.selector);
|
|
252
|
+
if (!loaded)
|
|
253
|
+
throw new Error(`Unknown profile: ${request.profile}`);
|
|
254
|
+
if (hasAgentProfileErrors(loaded.diagnostics))
|
|
255
|
+
throw new Error(`Profile ${request.profile} failed loading validation.`);
|
|
256
|
+
const resolved = resolveSubagentHostProfile(loaded, {
|
|
257
|
+
promptStacks: snapshot.stacks,
|
|
258
|
+
registrations: currentSubagentPromptRegistrationCatalog(),
|
|
259
|
+
});
|
|
260
|
+
if (!resolved.snapshot)
|
|
261
|
+
throw new Error(`Profile ${request.profile} could not be resolved for preparation.`);
|
|
262
|
+
const prepared = prepareForgeDelegation({
|
|
263
|
+
snapshot: resolved.snapshot,
|
|
264
|
+
task: request.task,
|
|
265
|
+
access: request.access,
|
|
266
|
+
backend: request.backend,
|
|
267
|
+
cwd: snapshot.cwd,
|
|
268
|
+
});
|
|
269
|
+
return {
|
|
270
|
+
profileId: request.profile,
|
|
271
|
+
model: { ...request.backend.model },
|
|
272
|
+
thinkingLevel: request.backend.thinkingLevel,
|
|
273
|
+
systemPrompt: prepared.systemPrompt,
|
|
274
|
+
messages: prepared.messages,
|
|
275
|
+
effectiveToolIds: prepared.effectiveToolIds,
|
|
276
|
+
effectiveToolNames: prepared.effectiveToolNames,
|
|
277
|
+
diagnostics: prepared.diagnostics,
|
|
278
|
+
profileSnapshot: resolved.snapshot,
|
|
279
|
+
preparedAt: prepared.preparedAt,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
dispose() {
|
|
283
|
+
this.disposeExtensions();
|
|
284
|
+
if (this.host?.isLive)
|
|
285
|
+
this.host.stop();
|
|
286
|
+
this.host = undefined;
|
|
287
|
+
this.current = undefined;
|
|
288
|
+
}
|
|
289
|
+
resolveActive(stacks, options) {
|
|
290
|
+
if (options.suppressAutoActivate && options.activeStackId == null)
|
|
291
|
+
return undefined;
|
|
292
|
+
if (options.activeStackId != null) {
|
|
293
|
+
if (isDisabledPromptStackId(options.activeStackId))
|
|
294
|
+
return undefined;
|
|
295
|
+
const parsed = parseResourceSelector(options.activeStackId);
|
|
296
|
+
if (parsed.ok) {
|
|
297
|
+
const found = createResourceCatalog([...stacks]).resolveSelector(parsed.selector);
|
|
298
|
+
if (found)
|
|
299
|
+
return found;
|
|
300
|
+
}
|
|
301
|
+
// Persisted selection no longer resolves; fall back to the default stack
|
|
302
|
+
// rather than silently starting with no active stack.
|
|
303
|
+
return chooseDefaultStack([...stacks]);
|
|
304
|
+
}
|
|
305
|
+
return chooseDefaultStack([...stacks]);
|
|
306
|
+
}
|
|
307
|
+
publish(next) {
|
|
308
|
+
this.current = deepFreeze(structuredClone(next));
|
|
309
|
+
return this.current;
|
|
310
|
+
}
|
|
311
|
+
get extensionDiagnostics() {
|
|
312
|
+
return this.extensionDiagnosticsValue;
|
|
313
|
+
}
|
|
314
|
+
set extensionDiagnostics(value) {
|
|
315
|
+
this.extensionDiagnosticsValue = value;
|
|
316
|
+
}
|
|
317
|
+
get extensionPaths() {
|
|
318
|
+
return this.extensionPathsValue;
|
|
319
|
+
}
|
|
320
|
+
set extensionPaths(value) {
|
|
321
|
+
this.extensionPathsValue = value;
|
|
322
|
+
}
|
|
323
|
+
extensionDiagnosticsValue = [];
|
|
324
|
+
extensionPathsValue = [];
|
|
325
|
+
}
|
|
326
|
+
function stripUndefined(value) {
|
|
327
|
+
if (Array.isArray(value))
|
|
328
|
+
return value.map(stripUndefined);
|
|
329
|
+
if (value && typeof value === "object") {
|
|
330
|
+
const result = {};
|
|
331
|
+
for (const [key, item] of Object.entries(value)) {
|
|
332
|
+
if (item === undefined)
|
|
333
|
+
continue;
|
|
334
|
+
result[key] = stripUndefined(item);
|
|
335
|
+
}
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
return value;
|
|
339
|
+
}
|
|
340
|
+
function deepFreeze(value) {
|
|
341
|
+
const freeze = (current) => {
|
|
342
|
+
if (current === null || typeof current !== "object")
|
|
343
|
+
return;
|
|
344
|
+
for (const key of Object.keys(current))
|
|
345
|
+
freeze(current[key]);
|
|
346
|
+
Object.freeze(current);
|
|
347
|
+
};
|
|
348
|
+
freeze(value);
|
|
349
|
+
return value;
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[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,CAAC,EAAE,CAAC;YACjD,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAS;YACjC,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,UAAU,CAAI,KAAQ;IAC9B,MAAM,MAAM,GAAG,CAAC,OAAgB,EAAQ,EAAE;QACzC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO;QAC5D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,MAAM,CAAE,OAAmC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1F,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/docs/README.md
CHANGED
|
@@ -14,8 +14,8 @@ Use this page as the documentation map. Each subject has one authoritative home;
|
|
|
14
14
|
|
|
15
15
|
- [Web editor](guides/web-editor.md)
|
|
16
16
|
- [Prompt-stack patterns and examples](guides/use-cases.md)
|
|
17
|
+
- [Migrating to 0.5](guides/migrating-to-0.5.md)
|
|
17
18
|
- [Foreground delegation](guides/delegation.md) — experimental; read the security boundary before enabling it.
|
|
18
|
-
- [SillyTavern import](guides/sillytavern-import.md)
|
|
19
19
|
- [Custom macros and slots](guides/custom-macros-and-slots.md)
|
|
20
20
|
- [Prompt and payload debugging](guides/debugging.md)
|
|
21
21
|
|
|
@@ -27,15 +27,17 @@ Use this page as the documentation map. Each subject has one authoritative home;
|
|
|
27
27
|
- [Configuration](reference/configuration.md)
|
|
28
28
|
- [Implemented feature inventory](reference/features.md)
|
|
29
29
|
- [Public API policy](reference/public-api.md)
|
|
30
|
-
- [Experimental subagent
|
|
30
|
+
- [Experimental subagent host port contract](reference/subagent-host-port.md)
|
|
31
31
|
|
|
32
32
|
## Development
|
|
33
33
|
|
|
34
34
|
- [Development setup and verification](development/setup.md)
|
|
35
|
+
- [Architecture and development rules](development/architecture-rules.md)
|
|
36
|
+
- [0.5 architecture plan](design/architecture-0.5.md)
|
|
35
37
|
- [Release process](development/release.md)
|
|
36
38
|
- [Roadmap](development/roadmap.md)
|
|
37
39
|
- [Complexity review](development/complexity-review.md)
|
|
38
40
|
|
|
39
|
-
##
|
|
41
|
+
## Architecture and design
|
|
40
42
|
|
|
41
|
-
[
|
|
43
|
+
[Architecture and design](design/README.md) contains the active 0.5 plan plus historical decisions and investigations. Current released behavior remains documented in the guides and reference pages above.
|
|
@@ -6,7 +6,7 @@ An agent profile is a project-local, schema-versioned preset that references one
|
|
|
6
6
|
|
|
7
7
|
## Schema
|
|
8
8
|
|
|
9
|
-
Profiles live in `.pi/forge/agent-profiles/*.json
|
|
9
|
+
Profiles live in `.pi/forge/agent-profiles/*.json` (project scope) or `~/.pi/forge/agent-profiles/*.json` (global scope). Commands accept `reviewer`, `project:reviewer`, and `global:reviewer`; a project profile shadows a same-ID global profile for unqualified lookups. A profile's `promptStack` reference resolves relative to the profile's own scope: a project profile may reference its own project stack by bare ID or a global stack as `global:<id>`; a global profile may only reference global stacks.
|
|
10
10
|
|
|
11
11
|
```json
|
|
12
12
|
{
|
|
@@ -55,6 +55,6 @@ Provenance is branch-scoped status metadata, not ownership. Reload, resume, tree
|
|
|
55
55
|
|
|
56
56
|
## Delegation is separate
|
|
57
57
|
|
|
58
|
-
Ordinary profiles cannot be delegated by default.
|
|
58
|
+
Ordinary profiles cannot be delegated by default. Delegation authorization is owned by the optional `@zihanw/pi-forge-subagents` package in dedicated files: the trusted project's `.pi/forge/subagents.json` authorizes `project:<id>` profiles and the user-global `~/.pi/forge/subagents.json` authorizes `global:<id>` profiles, with per-profile backend/timeout overrides. The main package reads no subagent configuration, and deleting a profile does not touch `subagents.json`.
|
|
59
59
|
|
|
60
60
|
Read the [experimental delegation guide](../guides/delegation.md) before enabling it.
|
|
@@ -33,7 +33,7 @@ A slot renders current Pi data at that position:
|
|
|
33
33
|
}
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Slots cover conversation history, tools, tool guidance, skills, project context, appended system text,
|
|
36
|
+
Slots cover conversation history, tools, tool guidance, skills, project context, appended system text, model, date, and working directory. See [macros and slots](../reference/macros-and-slots.md).
|
|
37
37
|
|
|
38
38
|
## Compilation order
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ For each new user turn, pi-forge:
|
|
|
42
42
|
1. Orders enabled blocks and slots exactly as written.
|
|
43
43
|
2. Builds `system` content and applies the stack's `replace`, `append`, or `prepend` mode.
|
|
44
44
|
3. Inserts synthetic user/assistant messages around the movable `chat-history` slot.
|
|
45
|
-
4.
|
|
45
|
+
4. Compiles forge-v1 templates over `runtime.*`, `parameters.*`, and `extensions.*`.
|
|
46
46
|
5. Applies the stack's tool policy to Pi and filters skills rendered by pi-forge.
|
|
47
47
|
6. Applies outgoing history/compiled regex rules.
|
|
48
48
|
7. Optionally applies destructive finalize rules when an assistant message completes.
|
|
@@ -64,7 +64,7 @@ Use `replace` when the model-visible skill list must be controlled. With `append
|
|
|
64
64
|
1. Long-lived system rules.
|
|
65
65
|
2. Runtime tools and project context.
|
|
66
66
|
3. Chat history with `includeLastUserMessage: false`.
|
|
67
|
-
4. A final user block containing `{{lastUserMessage}}`.
|
|
67
|
+
4. A final user block containing `{{ runtime.lastUserMessage }}`.
|
|
68
68
|
|
|
69
69
|
This preserves prior context while presenting the current request once, in an explicit final position. History can also filter summaries and roles, drop previous tool traffic, strip assistant thinking, and limit recent messages or characters. pi-forge repairs dangling tool-call/result pairs after filtering.
|
|
70
70
|
|
|
@@ -74,17 +74,22 @@ Stacks may use either `allow` or `deny` patterns for each resource. Tool policy
|
|
|
74
74
|
|
|
75
75
|
External tool additions are preserved in the baseline restored when a restrictive stack is disabled. See the exact behavior in [stack policy reference](../reference/stack-schema.md#tool-and-skill-policy).
|
|
76
76
|
|
|
77
|
+
## Scopes and shadowing
|
|
78
|
+
|
|
79
|
+
Stacks may live in the user-global `~/.pi/forge/prompt-stacks/` or the project `.pi/forge/prompt-stacks/`. A project stack shadows a same-ID global stack for unqualified commands. Selectors are `reviewer`, `project:reviewer`, or `global:reviewer`. Duplicate IDs are errors only within one scope.
|
|
80
|
+
|
|
77
81
|
## Activation and session behavior
|
|
78
82
|
|
|
79
|
-
- `
|
|
80
|
-
-
|
|
83
|
+
- A stack may set `autoActivate: true`; conflicting auto-activation in one scope is invalid and fails closed.
|
|
84
|
+
- `default.json` has no special filename role anymore; missing `autoActivate` yields a migration warning.
|
|
81
85
|
- `/preset use none` records an explicit session opt-out.
|
|
82
|
-
- Active stack
|
|
86
|
+
- Active stack selection follows Pi's session-tree branch.
|
|
83
87
|
- Restored branch state takes precedence over fresh-session auto-activation.
|
|
88
|
+
- Project auto-activation candidates take precedence over global ones; an invalid or ambiguous project candidate never falls back to a global stack.
|
|
84
89
|
- An auto-activated agent profile takes precedence over standalone stack autoload.
|
|
85
90
|
|
|
86
91
|
## Extensions and transforms
|
|
87
92
|
|
|
88
|
-
|
|
93
|
+
Immutable `parameters` support forge-v1 interpolation and pure filters; tool/slot conditionals use `runtime.tool.*` / `runtime.slot.*` booleans. Trusted JavaScript/TypeScript registration modules can add macros and slots without putting executable code in stack JSON. Deterministic regex rules can transform model-bound prompt text or, with an explicit warning, replace finalized assistant transcript text.
|
|
89
94
|
|
|
90
95
|
See [custom macros and slots](../guides/custom-macros-and-slots.md), [macro reference](../reference/macros-and-slots.md), and [regex schema](../reference/stack-schema.md#regex-transforms).
|
package/docs/design/README.md
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Architecture and design
|
|
2
2
|
|
|
3
3
|
[Documentation](../README.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The active plan defines the executable forward-looking work. Archived documents preserve the long-term target, decisions, reviews, spikes, and implementation history; they are not the authoritative description of current user behavior. Use the [guides](../README.md#guides) and [reference](../README.md#reference) for released behavior.
|
|
6
|
+
|
|
7
|
+
## Active 0.5.0 plan
|
|
8
|
+
|
|
9
|
+
- [Lean 0.5.0 architecture plan](architecture-0.5.md) — executable breaking-cleanup scope, accepted decisions, implementation lanes, and release gates.
|
|
10
|
+
- [Architecture and development rules](../development/architecture-rules.md) — dependency direction and ownership rules for the full target.
|
|
11
|
+
- [Architecture decision template](decision-template.md) — structure for future boundary/product decisions.
|
|
12
|
+
|
|
13
|
+
## Archived 0.5 full proposal
|
|
14
|
+
|
|
15
|
+
The original six-phase target remains the long-term goal and is preserved here:
|
|
16
|
+
|
|
17
|
+
- [Full proposal index](archive/0.5-full-proposal/README.md)
|
|
18
|
+
- [Full 0.5 architecture plan](archive/0.5-full-proposal/architecture-0.5.md)
|
|
19
|
+
- [Migration inventory](archive/0.5-full-proposal/0.5-inventory.md)
|
|
20
|
+
- [Public-consumer audit](archive/0.5-full-proposal/0.5-consumer-audit.md)
|
|
21
|
+
- [Phase-0 decision drafts](archive/0.5-full-proposal/0.5-phase0-decision-drafts.md)
|
|
22
|
+
- [Template-language spike](archive/0.5-full-proposal/template-language-spike.md)
|
|
23
|
+
- [Pi host-discovery spike](archive/0.5-full-proposal/host-discovery-spike.md)
|
|
6
24
|
|
|
7
25
|
## Subagent design history
|
|
8
26
|
|
|
@@ -14,4 +32,4 @@ These documents preserve decisions, reviews, spikes, and implementation history.
|
|
|
14
32
|
|
|
15
33
|
- [0.4 roadmap and implementation log](roadmap-0.4-archive.md)
|
|
16
34
|
|
|
17
|
-
The
|
|
35
|
+
The 0.5 host boundary is in the [subagent host port contract](../reference/subagent-host-port.md); accepted work ordering is in the [roadmap](../development/roadmap.md).
|