@zihanw/pi-forge 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. package/CHANGELOG.md +79 -1
  2. package/README.md +12 -11
  3. package/README.zh-CN.md +3 -5
  4. package/SUBAGENT_ADAPTER_CONTRACT.md +3 -1
  5. package/dist/agent-profile.d.ts +18 -62
  6. package/dist/agent-profile.d.ts.map +1 -1
  7. package/dist/agent-profile.js +27 -249
  8. package/dist/agent-profile.js.map +1 -1
  9. package/dist/codecs/agent-profile.d.ts +53 -0
  10. package/dist/codecs/agent-profile.d.ts.map +1 -0
  11. package/dist/codecs/agent-profile.js +176 -0
  12. package/dist/codecs/agent-profile.js.map +1 -0
  13. package/dist/codecs/index.d.ts +5 -0
  14. package/dist/codecs/index.d.ts.map +1 -0
  15. package/dist/codecs/index.js +3 -0
  16. package/dist/codecs/index.js.map +1 -0
  17. package/dist/codecs/prompt-stack.d.ts +18 -0
  18. package/dist/codecs/prompt-stack.d.ts.map +1 -0
  19. package/dist/codecs/prompt-stack.js +479 -0
  20. package/dist/codecs/prompt-stack.js.map +1 -0
  21. package/dist/compile-cycle.d.ts +18 -0
  22. package/dist/compile-cycle.d.ts.map +1 -0
  23. package/dist/compile-cycle.js +13 -0
  24. package/dist/compile-cycle.js.map +1 -0
  25. package/dist/compiler.d.ts +10 -4
  26. package/dist/compiler.d.ts.map +1 -1
  27. package/dist/compiler.js +53 -19
  28. package/dist/compiler.js.map +1 -1
  29. package/dist/context-diff-history.d.ts +61 -0
  30. package/dist/context-diff-history.d.ts.map +1 -0
  31. package/dist/context-diff-history.js +84 -0
  32. package/dist/context-diff-history.js.map +1 -0
  33. package/dist/context-diff-snapshot.d.ts +19 -0
  34. package/dist/context-diff-snapshot.d.ts.map +1 -0
  35. package/dist/context-diff-snapshot.js +146 -0
  36. package/dist/context-diff-snapshot.js.map +1 -0
  37. package/dist/context-diff.d.ts +70 -0
  38. package/dist/context-diff.d.ts.map +1 -0
  39. package/dist/context-diff.js +259 -0
  40. package/dist/context-diff.js.map +1 -0
  41. package/dist/extension-registry.d.ts.map +1 -1
  42. package/dist/extension-registry.js +5 -2
  43. package/dist/extension-registry.js.map +1 -1
  44. package/dist/forge-config.d.ts +0 -105
  45. package/dist/forge-config.d.ts.map +1 -1
  46. package/dist/forge-config.js +1 -313
  47. package/dist/forge-config.js.map +1 -1
  48. package/dist/forge-v1/analyzer.d.ts +3 -0
  49. package/dist/forge-v1/analyzer.d.ts.map +1 -0
  50. package/dist/forge-v1/analyzer.js +50 -0
  51. package/dist/forge-v1/analyzer.js.map +1 -0
  52. package/dist/forge-v1/index.d.ts +6 -0
  53. package/dist/forge-v1/index.d.ts.map +1 -0
  54. package/dist/forge-v1/index.js +13 -0
  55. package/dist/forge-v1/index.js.map +1 -0
  56. package/dist/forge-v1/parser.d.ts +3 -0
  57. package/dist/forge-v1/parser.d.ts.map +1 -0
  58. package/dist/forge-v1/parser.js +186 -0
  59. package/dist/forge-v1/parser.js.map +1 -0
  60. package/dist/forge-v1/renderer.d.ts +9 -0
  61. package/dist/forge-v1/renderer.d.ts.map +1 -0
  62. package/dist/forge-v1/renderer.js +181 -0
  63. package/dist/forge-v1/renderer.js.map +1 -0
  64. package/dist/forge-v1/types.d.ts +87 -0
  65. package/dist/forge-v1/types.d.ts.map +1 -0
  66. package/dist/forge-v1/types.js +4 -0
  67. package/dist/forge-v1/types.js.map +1 -0
  68. package/dist/index.d.ts +12 -12
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +54 -83
  71. package/dist/index.js.map +1 -1
  72. package/dist/lifecycle.d.ts +8 -5
  73. package/dist/lifecycle.d.ts.map +1 -1
  74. package/dist/lifecycle.js +45 -112
  75. package/dist/lifecycle.js.map +1 -1
  76. package/dist/loader.d.ts +5 -8
  77. package/dist/loader.d.ts.map +1 -1
  78. package/dist/loader.js +10 -467
  79. package/dist/loader.js.map +1 -1
  80. package/dist/macro-engine.d.ts +9 -14
  81. package/dist/macro-engine.d.ts.map +1 -1
  82. package/dist/macro-engine.js +5 -238
  83. package/dist/macro-engine.js.map +1 -1
  84. package/dist/payload-capture.d.ts +10 -0
  85. package/dist/payload-capture.d.ts.map +1 -1
  86. package/dist/payload-capture.js +39 -9
  87. package/dist/payload-capture.js.map +1 -1
  88. package/dist/payload-command.d.ts +8 -6
  89. package/dist/payload-command.d.ts.map +1 -1
  90. package/dist/payload-command.js +36 -6
  91. package/dist/payload-command.js.map +1 -1
  92. package/dist/payload-state.d.ts +19 -0
  93. package/dist/payload-state.d.ts.map +1 -0
  94. package/dist/payload-state.js +19 -0
  95. package/dist/payload-state.js.map +1 -0
  96. package/dist/preset-command.d.ts +4 -4
  97. package/dist/preset-command.d.ts.map +1 -1
  98. package/dist/preset-command.js +33 -104
  99. package/dist/preset-command.js.map +1 -1
  100. package/dist/preview.d.ts +4 -4
  101. package/dist/preview.d.ts.map +1 -1
  102. package/dist/preview.js +34 -11
  103. package/dist/preview.js.map +1 -1
  104. package/dist/profile-command.d.ts +2 -2
  105. package/dist/profile-command.d.ts.map +1 -1
  106. package/dist/profile-command.js +15 -14
  107. package/dist/profile-command.js.map +1 -1
  108. package/dist/profile-service.d.ts.map +1 -1
  109. package/dist/profile-service.js +23 -39
  110. package/dist/profile-service.js.map +1 -1
  111. package/dist/prompt-analysis.d.ts +24 -0
  112. package/dist/prompt-analysis.d.ts.map +1 -0
  113. package/dist/prompt-analysis.js +84 -0
  114. package/dist/prompt-analysis.js.map +1 -0
  115. package/dist/prompt-runtime.d.ts +19 -0
  116. package/dist/prompt-runtime.d.ts.map +1 -0
  117. package/dist/prompt-runtime.js +30 -0
  118. package/dist/prompt-runtime.js.map +1 -0
  119. package/dist/regex.js +6 -12
  120. package/dist/regex.js.map +1 -1
  121. package/dist/render-helpers.d.ts +2 -10
  122. package/dist/render-helpers.d.ts.map +1 -1
  123. package/dist/render-helpers.js +3 -53
  124. package/dist/render-helpers.js.map +1 -1
  125. package/dist/repositories/agent-profile.d.ts +36 -0
  126. package/dist/repositories/agent-profile.d.ts.map +1 -0
  127. package/dist/repositories/agent-profile.js +153 -0
  128. package/dist/repositories/agent-profile.js.map +1 -0
  129. package/dist/repositories/index.d.ts +3 -0
  130. package/dist/repositories/index.d.ts.map +1 -0
  131. package/dist/repositories/index.js +3 -0
  132. package/dist/repositories/index.js.map +1 -0
  133. package/dist/repositories/prompt-stack.d.ts +57 -0
  134. package/dist/repositories/prompt-stack.d.ts.map +1 -0
  135. package/dist/repositories/prompt-stack.js +175 -0
  136. package/dist/repositories/prompt-stack.js.map +1 -0
  137. package/dist/runtime/profile-runtime.d.ts +2 -2
  138. package/dist/runtime/profile-runtime.d.ts.map +1 -1
  139. package/dist/runtime/profile-runtime.js +13 -10
  140. package/dist/runtime/profile-runtime.js.map +1 -1
  141. package/dist/runtime/prompt-stack-runtime.d.ts +4 -3
  142. package/dist/runtime/prompt-stack-runtime.d.ts.map +1 -1
  143. package/dist/runtime/prompt-stack-runtime.js +42 -57
  144. package/dist/runtime/prompt-stack-runtime.js.map +1 -1
  145. package/dist/runtime/tool-policy-runtime.d.ts +2 -2
  146. package/dist/runtime/tool-policy-runtime.d.ts.map +1 -1
  147. package/dist/runtime/tool-policy-runtime.js +16 -6
  148. package/dist/runtime/tool-policy-runtime.js.map +1 -1
  149. package/dist/runtime/web-editor-runtime.d.ts +2 -1
  150. package/dist/runtime/web-editor-runtime.d.ts.map +1 -1
  151. package/dist/runtime/web-editor-runtime.js +8 -3
  152. package/dist/runtime/web-editor-runtime.js.map +1 -1
  153. package/dist/session-adapter.d.ts +17 -0
  154. package/dist/session-adapter.d.ts.map +1 -0
  155. package/dist/session-adapter.js +57 -0
  156. package/dist/session-adapter.js.map +1 -0
  157. package/dist/slot-renderers.d.ts +16 -3
  158. package/dist/slot-renderers.d.ts.map +1 -1
  159. package/dist/slot-renderers.js +15 -63
  160. package/dist/slot-renderers.js.map +1 -1
  161. package/dist/stack-migration.d.ts +6 -0
  162. package/dist/stack-migration.d.ts.map +1 -1
  163. package/dist/stack-migration.js +49 -52
  164. package/dist/stack-migration.js.map +1 -1
  165. package/dist/subagent/fingerprints.d.ts +24 -0
  166. package/dist/subagent/fingerprints.d.ts.map +1 -0
  167. package/dist/subagent/fingerprints.js +81 -0
  168. package/dist/subagent/fingerprints.js.map +1 -0
  169. package/dist/subagent/host-port.d.ts +296 -0
  170. package/dist/subagent/host-port.d.ts.map +1 -0
  171. package/dist/subagent/host-port.js +560 -0
  172. package/dist/subagent/host-port.js.map +1 -0
  173. package/dist/subagent/index.d.ts +10 -10
  174. package/dist/subagent/index.d.ts.map +1 -1
  175. package/dist/subagent/index.js +9 -10
  176. package/dist/subagent/index.js.map +1 -1
  177. package/dist/subagent-host.d.ts +99 -18
  178. package/dist/subagent-host.d.ts.map +1 -1
  179. package/dist/subagent-host.js +143 -146
  180. package/dist/subagent-host.js.map +1 -1
  181. package/dist/template-render.d.ts +18 -0
  182. package/dist/template-render.d.ts.map +1 -0
  183. package/dist/template-render.js +232 -0
  184. package/dist/template-render.js.map +1 -0
  185. package/dist/types.d.ts +40 -27
  186. package/dist/types.d.ts.map +1 -1
  187. package/dist/types.js.map +1 -1
  188. package/dist/ui-contribution/contrib-port.d.ts +170 -0
  189. package/dist/ui-contribution/contrib-port.d.ts.map +1 -0
  190. package/dist/ui-contribution/contrib-port.js +640 -0
  191. package/dist/ui-contribution/contrib-port.js.map +1 -0
  192. package/dist/ui-contribution/index.d.ts +3 -0
  193. package/dist/ui-contribution/index.d.ts.map +1 -0
  194. package/dist/ui-contribution/index.js +2 -0
  195. package/dist/ui-contribution/index.js.map +1 -0
  196. package/dist/web-editor/client-script.generated.d.ts.map +1 -1
  197. package/dist/web-editor/client-script.generated.js +1 -1
  198. package/dist/web-editor/client-script.generated.js.map +1 -1
  199. package/dist/web-editor/client-styles.generated.d.ts.map +1 -1
  200. package/dist/web-editor/client-styles.generated.js +1 -1
  201. package/dist/web-editor/client-styles.generated.js.map +1 -1
  202. package/dist/web-editor/contrib-service.d.ts +41 -0
  203. package/dist/web-editor/contrib-service.d.ts.map +1 -0
  204. package/dist/web-editor/contrib-service.js +174 -0
  205. package/dist/web-editor/contrib-service.js.map +1 -0
  206. package/dist/web-editor/line-diff.d.ts +28 -0
  207. package/dist/web-editor/line-diff.d.ts.map +1 -0
  208. package/dist/web-editor/line-diff.js +216 -0
  209. package/dist/web-editor/line-diff.js.map +1 -0
  210. package/dist/web-editor/schema-form.d.ts +63 -0
  211. package/dist/web-editor/schema-form.d.ts.map +1 -0
  212. package/dist/web-editor/schema-form.js +213 -0
  213. package/dist/web-editor/schema-form.js.map +1 -0
  214. package/dist/web-editor/server.d.ts.map +1 -1
  215. package/dist/web-editor/server.js +72 -74
  216. package/dist/web-editor/server.js.map +1 -1
  217. package/dist/web-editor/styles.d.ts.map +1 -1
  218. package/dist/web-editor/styles.js +201 -21
  219. package/dist/web-editor/styles.js.map +1 -1
  220. package/dist/web-editor/types.d.ts +12 -35
  221. package/dist/web-editor/types.d.ts.map +1 -1
  222. package/dist/web-host.d.ts +6 -2
  223. package/dist/web-host.d.ts.map +1 -1
  224. package/dist/web-host.js +33 -103
  225. package/dist/web-host.js.map +1 -1
  226. package/dist/workspace.d.ts +74 -0
  227. package/dist/workspace.d.ts.map +1 -0
  228. package/dist/workspace.js +351 -0
  229. package/dist/workspace.js.map +1 -0
  230. package/docs/README.md +7 -4
  231. package/docs/concepts/agent-profiles.md +1 -1
  232. package/docs/concepts/prompt-stacks.md +5 -5
  233. package/docs/design/0.5.1-plan.md +237 -0
  234. package/docs/design/README.md +21 -3
  235. package/docs/design/architecture-0.5.md +222 -0
  236. package/docs/design/archive/0.5-full-proposal/0.5-consumer-audit.md +62 -0
  237. package/docs/design/archive/0.5-full-proposal/0.5-inventory.md +208 -0
  238. package/docs/design/archive/0.5-full-proposal/0.5-phase0-decision-drafts.md +237 -0
  239. package/docs/design/archive/0.5-full-proposal/README.md +12 -0
  240. package/docs/design/archive/0.5-full-proposal/architecture-0.5.md +423 -0
  241. package/docs/design/archive/0.5-full-proposal/host-discovery-spike.md +103 -0
  242. package/docs/design/archive/0.5-full-proposal/template-language-spike.md +156 -0
  243. package/docs/design/context-diff-plan.md +78 -0
  244. package/docs/design/decision-template.md +33 -0
  245. package/docs/design/roadmap-0.4-archive.md +1 -1
  246. package/docs/design/subagents/interface-design.md +1 -1
  247. package/docs/development/architecture-rules.md +148 -0
  248. package/docs/development/release.md +7 -1
  249. package/docs/development/roadmap.md +37 -5
  250. package/docs/development/scoped-global-profiles-stacks.md +1 -1
  251. package/docs/development/setup.md +6 -4
  252. package/docs/getting-started.md +5 -4
  253. package/docs/guides/custom-macros-and-slots.md +8 -7
  254. package/docs/guides/debugging.md +1 -1
  255. package/docs/guides/delegation.md +18 -22
  256. package/docs/guides/migrating-to-0.5.md +107 -0
  257. package/docs/guides/use-cases.md +7 -11
  258. package/docs/guides/web-editor.md +6 -10
  259. package/docs/reference/commands.md +4 -3
  260. package/docs/reference/configuration.md +17 -18
  261. package/docs/reference/features.md +34 -80
  262. package/docs/reference/macros-and-slots.md +70 -49
  263. package/docs/reference/public-api.md +76 -17
  264. package/docs/reference/stack-schema.md +15 -10
  265. package/docs/reference/subagent-host-port.md +49 -0
  266. package/docs/reference/ui-contribution-port.md +51 -0
  267. package/docs/zh-CN/README.md +3 -3
  268. package/docs/zh-CN/concepts/agent-profiles.md +1 -1
  269. package/docs/zh-CN/concepts/prompt-stacks.md +5 -5
  270. package/docs/zh-CN/getting-started.md +3 -2
  271. package/docs/zh-CN/guides/delegation.md +10 -12
  272. package/docs/zh-CN/guides/migrating-to-0.5.md +92 -0
  273. package/docs/zh-CN/guides/web-editor.md +4 -4
  274. package/docs/zh-CN/reference/commands.md +3 -2
  275. package/examples/custom-system-status-extension/README.md +3 -3
  276. package/examples/custom-system-status-extension/index.ts +2 -1
  277. package/examples/custom-system-status-extension/prompt-stack.json +4 -3
  278. package/examples/default-prompt-stack.json +9 -4
  279. package/examples/image-reader-prompt-stack.json +16 -26
  280. package/examples/reviewer-prompt-stack.json +13 -24
  281. package/package.json +106 -120
  282. package/dist/runtime/subagent-runtime.d.ts +0 -45
  283. package/dist/runtime/subagent-runtime.d.ts.map +0 -1
  284. package/dist/runtime/subagent-runtime.js +0 -343
  285. package/dist/runtime/subagent-runtime.js.map +0 -1
  286. package/dist/runtime-state.d.ts +0 -30
  287. package/dist/runtime-state.d.ts.map +0 -1
  288. package/dist/runtime-state.js +0 -17
  289. package/dist/runtime-state.js.map +0 -1
  290. package/dist/sillytavern-importer/items.d.ts +0 -3
  291. package/dist/sillytavern-importer/items.d.ts.map +0 -1
  292. package/dist/sillytavern-importer/items.js +0 -88
  293. package/dist/sillytavern-importer/items.js.map +0 -1
  294. package/dist/sillytavern-importer/macros.d.ts +0 -15
  295. package/dist/sillytavern-importer/macros.d.ts.map +0 -1
  296. package/dist/sillytavern-importer/macros.js +0 -141
  297. package/dist/sillytavern-importer/macros.js.map +0 -1
  298. package/dist/sillytavern-importer/prompt-order.d.ts +0 -6
  299. package/dist/sillytavern-importer/prompt-order.d.ts.map +0 -1
  300. package/dist/sillytavern-importer/prompt-order.js +0 -38
  301. package/dist/sillytavern-importer/prompt-order.js.map +0 -1
  302. package/dist/sillytavern-importer/regex.d.ts +0 -3
  303. package/dist/sillytavern-importer/regex.d.ts.map +0 -1
  304. package/dist/sillytavern-importer/regex.js +0 -275
  305. package/dist/sillytavern-importer/regex.js.map +0 -1
  306. package/dist/sillytavern-importer/report.d.ts +0 -21
  307. package/dist/sillytavern-importer/report.d.ts.map +0 -1
  308. package/dist/sillytavern-importer/report.js +0 -166
  309. package/dist/sillytavern-importer/report.js.map +0 -1
  310. package/dist/sillytavern-importer/types.d.ts +0 -106
  311. package/dist/sillytavern-importer/types.d.ts.map +0 -1
  312. package/dist/sillytavern-importer/types.js +0 -2
  313. package/dist/sillytavern-importer/types.js.map +0 -1
  314. package/dist/sillytavern-importer.d.ts +0 -5
  315. package/dist/sillytavern-importer.d.ts.map +0 -1
  316. package/dist/sillytavern-importer.js +0 -117
  317. package/dist/sillytavern-importer.js.map +0 -1
  318. package/dist/subagent/canonical.d.ts +0 -22
  319. package/dist/subagent/canonical.d.ts.map +0 -1
  320. package/dist/subagent/canonical.js +0 -24
  321. package/dist/subagent/canonical.js.map +0 -1
  322. package/dist/subagent/context.d.ts +0 -8
  323. package/dist/subagent/context.d.ts.map +0 -1
  324. package/dist/subagent/context.js +0 -125
  325. package/dist/subagent/context.js.map +0 -1
  326. package/dist/subagent/contract.d.ts +0 -10
  327. package/dist/subagent/contract.d.ts.map +0 -1
  328. package/dist/subagent/contract.js +0 -10
  329. package/dist/subagent/contract.js.map +0 -1
  330. package/dist/subagent/plan.d.ts +0 -18
  331. package/dist/subagent/plan.d.ts.map +0 -1
  332. package/dist/subagent/plan.js +0 -157
  333. package/dist/subagent/plan.js.map +0 -1
  334. package/dist/subagent/preflight.d.ts +0 -4
  335. package/dist/subagent/preflight.d.ts.map +0 -1
  336. package/dist/subagent/preflight.js +0 -108
  337. package/dist/subagent/preflight.js.map +0 -1
  338. package/dist/subagent/request.d.ts +0 -4
  339. package/dist/subagent/request.d.ts.map +0 -1
  340. package/dist/subagent/request.js +0 -154
  341. package/dist/subagent/request.js.map +0 -1
  342. package/dist/subagent/response.d.ts +0 -8
  343. package/dist/subagent/response.d.ts.map +0 -1
  344. package/dist/subagent/response.js +0 -155
  345. package/dist/subagent/response.js.map +0 -1
  346. package/dist/subagent/tools.d.ts +0 -4
  347. package/dist/subagent/tools.d.ts.map +0 -1
  348. package/dist/subagent/tools.js +0 -42
  349. package/dist/subagent/tools.js.map +0 -1
  350. package/dist/subagent/types.d.ts +0 -272
  351. package/dist/subagent/types.d.ts.map +0 -1
  352. package/dist/subagent/types.js +0 -3
  353. package/dist/subagent/types.js.map +0 -1
  354. package/dist/subagent/validation.d.ts +0 -35
  355. package/dist/subagent/validation.d.ts.map +0 -1
  356. package/dist/subagent/validation.js +0 -314
  357. package/dist/subagent/validation.js.map +0 -1
  358. package/dist/subagent-command.d.ts +0 -5
  359. package/dist/subagent-command.d.ts.map +0 -1
  360. package/dist/subagent-command.js +0 -249
  361. package/dist/subagent-command.js.map +0 -1
  362. package/dist/subagent-profile-tool.d.ts +0 -49
  363. package/dist/subagent-profile-tool.d.ts.map +0 -1
  364. package/dist/subagent-profile-tool.js +0 -125
  365. package/dist/subagent-profile-tool.js.map +0 -1
  366. package/dist/subagent-tool.d.ts +0 -77
  367. package/dist/subagent-tool.d.ts.map +0 -1
  368. package/dist/subagent-tool.js +0 -559
  369. package/dist/subagent-tool.js.map +0 -1
  370. package/docs/guides/sillytavern-import.md +0 -47
  371. package/docs/reference/subagent-adapter.md +0 -204
  372. package/examples/sillytavern-dm-writer-prompt-stack.json +0 -190
package/CHANGELOG.md CHANGED
@@ -6,7 +6,85 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
  In 0.x development, breaking changes may occur in minor releases and will be explicitly noted.
8
8
 
9
- ## [Unreleased]
9
+ ## [0.5.1] - 2026-08-23
10
+
11
+ ### Added
12
+
13
+ - **Cross-platform release CI.** The complete verification surface, including
14
+ the real-browser editor suite and packed-install smoke, now runs on GitHub's
15
+ macOS and Windows hosted runners in addition to Linux. Generated TypeScript
16
+ output and repository text files are pinned to LF so tracked `dist/` checks
17
+ remain deterministic across operating systems.
18
+ - **UI contribution framework (Lane 1).** Optional packages can now contribute schema-driven configuration pages to the web editor without shipping any UI code into the main package:
19
+ - New versioned `@zihanw/pi-forge/ui-contribution` entry point: a generic RPC contract over the Pi event bus (`UI_CONTRIBUTION_PORT_VERSION = 1`, with its own version counter separate from the `/subagent` host port) exposing exactly two operations — `listContributions` and `writeValues` — over discover/available/request/reply/unavailable channels. Wire messages carry `hostId` + `generation` binding, version negotiation (`minVersion`/`maxVersion`), bounded discovery timeouts, explicit duplicate-provider failure, and recursive JSON-compatibility validators. All payloads are plain data: no functions, components, or live contexts cross the bus. See the [UI contribution port contract](docs/reference/ui-contribution-port.md).
20
+ - Web server routes: `GET /api/contrib` returns discovered tab descriptors at page load, and `PUT /api/contrib/<tabId>` proxies submitted values to the contributing package over the bus. The forge side is fully generic and knows nothing about subagents; it never owns the schema, validation, or persistence of contributed tabs (the provider writes its own config files), and with no provider discovered there is no contributed tab and zero cost.
21
+ - Contribution discovery tolerates provider churn across sessions: providers that appear after startup surface their tabs, departed providers are cleared, and service stop cancels pending discovery.
22
+ - Data-driven stack-tab registry replaces the stack editor's hardcoded `"policy" | "regex" | "stack"` tab union. Built-in tabs keep their existing hosts (including the legacy imperative items workspace as an ordinary tab), while contributed configuration renders through a self-contained host on a separate top-level **Settings** surface.
23
+ - Generic schema-form renderer: a self-contained Vue component bridged via the vue-host mechanism, covering deliberately restricted v1 field types — boolean, number, enum, string, plus a record/table shape for keyed per-entry lists. Record identities may use live catalog-backed `keyOptions`, while validation and persistence remain provider-owned. No imperative code was added to `legacy-editor.ts`.
24
+ - **Context diff — per-turn prompt observability (Lane 2).** Consecutive real provider requests are diffed automatically so KV-cache reuse is observable:
25
+ - Host-neutral pure engine (`src/context-diff.ts`): `TurnSnapshot`/`TurnDiff` shapes, block classification (`same`/`added`/`removed`/`modified`) aligned by stable content-derived keys with positional fallback, and a prefix-walk cache-boundary algorithm that walks matching block hashes and trims the char-level common prefix inside the first mismatched block — no Myers diff. Token figures are chars/4 approximations: relative deltas are accurate, and absolute boundary claims are labeled approx in the UI.
26
+ - Automatic per-turn capture: every provider request enters a rolling history of the last 20 turns (not just manually armed captures), and each new snapshot is auto-diffed against the previous turn. Block hashes cover role and serialized wire-relevant fields, and request-level sections (tool definitions and similar) participate as blocks so wire changes break the cache boundary faithfully.
27
+ - `GET /api/context-diff` serves the latest snapshot, the previous-turn diff, and summary rollups (added/removed/net tokens, prefix tokens and ratio).
28
+ - Preview/diff dock: the preview modal is promoted into a wider right-side panel with three focused views — **Preview** (the live compiled draft), **Draft diff** (the unsaved draft against the saved stack), and **Run diff** (the latest captured provider turn against its predecessor). Diff views hide unchanged blocks by default, show modified blocks in Before/After columns, keep run/cache metadata collapsed until requested, and offer **Focus/Split** controls to use the full editor width without permanently crowding stack editing. The panel is a self-contained Vue component riding Lane 1's data-driven registry; no imperative code was added to `legacy-editor.ts`.
29
+
30
+ ### Fixed
31
+
32
+ - Preview/Draft/Run diffs now render git-style unified or split line views with old/new line numbers, inline changed spans, and changes-only/three-line/all-line context controls. Chars/4 figures are labeled strictly as estimates. Each captured provider request is correlated with its completed assistant message, so Run metadata shows Pi's actual input/output/cache-read/cache-write usage and a provider-reported cache-hit rate when cache reporting has been observed; otherwise it says the rate is not reported instead of presenting a synthetic zero.
33
+
34
+ - Schema-driven record settings can now provide catalog-backed `keyOptions`, rendered as a duplicate-safe selector instead of a free-text identity field. UI-contribution handlers may resolve asynchronously, allowing optional packages to refresh host-owned catalogs before returning a schema or validating a write; stale replies are suppressed if that provider generation stops while the handler is pending.
35
+
36
+ - Selective stack tool allow lists now select from Pi's complete registered tool catalog, so built-in inactive tools such as `grep`, `find`, and `ls` can be activated by a stack and are restored to their prior inactive state when the policy is removed. Allow lists containing `*` remain on the active baseline and do not expand to every inactive tool. The web editor now states the active-vs-registered distinction explicitly.
37
+ - The docked Compiled preview now consumes the editor's current in-memory stack draft, refreshes from actual draft-change notifications, aborts superseded requests, and no longer silently previews the saved disk version while unsaved edits are visible.
38
+ - Plugin configuration no longer mounts inside the stack Preview dock. Contributed pages now live on an independent top-level **Settings** surface, so switching between Stack Preview and Subagent Settings cannot unmount or constrain the settings form.
39
+ - Preview now owns a dedicated DOM mount instead of sharing the legacy stack-tab panel, so saving or selecting another stack cannot leave an active-but-empty dock. Draft changes immediately invalidate visible compiled output, Preview and Run requests both reject superseded responses, and browser tests cover save/selection plus controlled delayed-response races.
40
+ - Settings autosaves are serialized per contribution host and replay the newest full form snapshot after an in-flight write, preventing a slow older PUT from overwriting a newer edit while the UI reports `Saved`. Drafts and save status are retained independently per Settings page during rapid tab switches, while a forge-owned monotonic provider-session key forces clean forms to remount with fresh schema and values after fast provider churn. PUT results are bound to the provider session that received them, so a delayed old-session success retries the preserved draft instead of overwriting the new session. Duplicate contribution IDs are ignored after the first descriptor and Settings button IDs cannot collide with built-in stack tabs.
41
+ - Compiled draft diffs align messages with stable source keys rather than positional `message-<index>` IDs, avoiding cascades of false modifications after insertions. Split Preview and top-level Settings collapse to usable single-column layouts on narrow screens without document-level horizontal overflow.
42
+ - The stack editor now keeps the Project/Global selector attached to **New stack** instead of stretching it across a full row, leaves only primary actions in the toolbar, moves infrequent capture/import/export/delete actions into **More**, and compacts the status, metadata, tab, sidebar, and item-list chrome so editing and Preview/Diff receive substantially more viewport space.
43
+ - The profile editor now keeps the canonical `global:<id>` selector visible in list, summary, edit heading, and save status. Profile JSON continues to store a bare schema ID and same-scope prompt-stack references relatively; their global identity is carried by storage scope and is no longer visually lost in the editor.
44
+ - Context-diff fidelity (architecture review F1–F3/F6 and re-review R1–R4): block hashes are computed from the faithful redacted serialization rather than the lossy capture projection, preserving provider field order for request-level blocks; blocks align by stable unique keys so insertions before existing messages classify correctly; token rounding is conservative and consistent so per-block chips cannot contradict summary totals; and the empty Diff view reflects automatic per-turn capture instead of instructing manual arming.
45
+ - UI-contribution hardening (F4/F5/F7): a partial-patch `writeValues` success no longer clobbers cached descriptor values with stale data; contribution lifecycle handles late-surfacing and departed providers and cancels pending discovery on stop; malformed or oversized `/api/contrib` request bodies return 400/413 instead of surfacing raw validator failures.
46
+
47
+ ## [0.5.0] - 2026-08-21
48
+
49
+ ### Planning
50
+
51
+ - Replaced the proposed six-phase 0.5.0 plan with the accepted [lean 0.5.0 architecture plan](docs/design/architecture-0.5.md). The original full proposal and Phase-0 evidence are archived under [docs/design/archive/0.5-full-proposal/](docs/design/archive/0.5-full-proposal/README.md) and remain the long-term target.
52
+ - Accepted lean 0.5.0 decisions: complete SillyTavern removal; mutable-variable removal; `forge-v1` with a redesigned pure trusted-extension port; regex `display`/`both` removal while `finalize` is retained under lifecycle-adapter ownership; minimal repositories/codecs with fingerprint and atomic writes deferred; minimal `ForgeWorkspace`; versioned `/subagent` host port with mandatory lifecycle semantics; optional `pi-forge-subagents` package without main-package delegation UI and with dedicated `subagents.json` files; explicit root default, root named extension API, and `/subagent` surfaces.
53
+
54
+ ### Removed
55
+
56
+ - SillyTavern importer, `/preset import-silly`, its reports, guide, example, and tests are removed. 0.4 is the last supported conversion path.
57
+ - Mutable turn/session variable stores, `pi-forge-variable-state` session entries, set/get/clear variable macros, and the `variables` slot are removed. Static reusable values now live on stack `parameters` in schema v2 or legacy `variables` in v1.
58
+ - Regex `display` and `both` effects are removed and rejected as validation errors; only `outgoing` and `finalize` remain.
59
+ - **Breaking (Lane 4b): legacy package surfaces.** All `@zihanw/pi-forge/src/*` compatibility aliases and the `./examples/*` subpath export are removed. The package root now exports exactly the default Pi extension factory plus `registerMacro`/`registerSlot` and their contract types (`PromptEnvironment`, `PromptRenderHelpers`, macro/slot definition and renderer types, option-schema types, and the trusted project extension API types). `@zihanw/pi-forge/subagent` is the only other entry point. `check-package` enforces the allowlist and forbids legacy aliases.
60
+
61
+ ### Changed
62
+
63
+ - Prompt compilation uses the `forge-v1` parse/analyze/render engine with a frozen `PromptEnvironment` (`runtime.*`, `parameters.*`, `extensions.*`). Preview, runtime, and subagent preparation share the same compiler entry.
64
+ - `registerMacro` and `registerSlot` move to a pure-contract extension port with immutable `env`, declared dependencies, bounded output, and strict undefined-path errors.
65
+ - Prompt-stack schema v2 introduces immutable `parameters`; unversioned/v1 stacks continue to read through the legacy `variables` field.
66
+ - `finalize` regex remains lifecycle-owned and is excluded from preview, which now reports an informational diagnostic.
67
+ - Legacy 0.4 nested macro syntax (for example `{{upper::x}}`, `{{json::...}}`, `{{iftools::...}}`) is no longer executed by the compiler and must migrate to forge-v1 syntax.
68
+ - Compiler/extension conformance (Lane 1d): custom slots share the pure `{ item, options, env, helpers }` contract with declared `dependencies` and the 16,384-character output limit; `env.extensions` is resolved for slots; a shared dependency analysis and one compilation context keep preview/runtime/subagent consistent; extension values resolve lazily per active branch; nested `{% if %}` and empty-string comparisons are supported.
69
+ - Subagent extraction (Lane 3): the `forge_subagent`/`/forge-agent` execution surface, the web-editor delegation UI, and all subagent configuration reads/writes are removed from the main package and move to the optional `@zihanw/pi-forge-subagents` package, which discovers the active host through the versioned `/subagent` port and owns its own `subagents.json`. Packed-install smoke tests cover main-only and main-plus-optional installs (`check:packed`).
70
+ - Host-neutralization (Lane 3.5): the prompt compiler's rendering and preflight contract is fully host-neutral (capability-driven, no subagent-specific branches), `ForgeWorkspace` is the single owner of resource state and compilation contexts (no second loader/registry path), and subagent documentation/configuration alignment was completed for the optional package split. The packed-install smoke was made portable across checkouts.
71
+ - Forge-native host contract (Lane 4a): the main package no longer depends on `@zihanw/pi-subagent-runtime` at all. `@zihanw/pi-forge/subagent` is now exactly the minimal Forge DTO host contract — host-port wire messages, recursive validators, transport, client/host lifecycle, and Forge-owned canonical fingerprint helpers (byte-compatible with the runtime's `sha256:v1` canonical JSON, pinned by golden vectors). The 0.4 execution contract (request, preflight, plan, response, context budgeting, tool negotiation, and validators) moves to `@zihanw/pi-forge-subagents` with names unchanged, importing portable leaves from the runtime directly. Host-owned preparation no longer synthesizes runtime request/preflight/prompt-runtime artifacts: the workspace resolves the profile and stack from its snapshot, filters the client tool catalog through stack policy, and compiles through the shared compilation context directly. **Breaking:** the package root no longer re-exports subagent contract or host-resolution names (the `/subagent` entry point is the only subagent surface); client-side snapshot validation keeps structural and fingerprint checks while deep profile schema validation remains host-owned.
72
+ - Minimum repositories and codecs (Lane 2a): prompt-stack and agent-profile parse/normalize/validate/serialize are centralized in `src/codecs/`, and reads, writes, and deletes all go through scoped repositories (`src/repositories/`) with containment and symlink checks; the loaders and profile service delegate to the repositories, so domain resources are never read or written directly at the adapter layer. Replacement semantics are unchanged and characterized by tests (no fingerprint conflict or atomic replace yet). Legacy stack migration is a documented byte-preserving exception whose raw IO lives inside the repository.
73
+ - ForgeWorkspace and host port v1 (Lane 2b): a minimal `ForgeWorkspace` snapshot owner (genuinely immutable, deep-frozen snapshots) over the repositories/codecs, plus a versioned `@zihanw/pi-forge/subagent` host-port protocol over the Pi event bus with the three minimal operations (discovery, profile listing, prepare). Mandatory lifecycle semantics are enforced and covered by tests: bounded timeouts, explicit duplicate-host failure, `hostId`+`generation`-bound request/reply so stale/foreign requests are rejected, disposal/`unavailable`, listener cleanup, host-owned prompt preparation (client sends only profile selector + task + backend facts), and recursive JSON-compatible operation validators. The host is wired into the real extension lifecycle via `pi.events` (host can only start after the first snapshot exists, so availability implies a loaded workspace; `reload` honors project trust; disposal runs before subagent teardown; the base system prompt is host-owned and empty for delegated subagents), with integration tests that discover, list, prepare, and observe disposal through the published `/subagent` surface — including that the host is not advertised before any session start. Operation validators are strict and recursive: exact nested field sets, typed enums, plain-object-only JSON compatibility, and unknown-field rejection — so `allowProcess` is the only process fact and no runtime access/limit/execution material crosses.
74
+
75
+ - Documentation and migration notes (Lane 4d): the [public API policy](docs/reference/public-api.md) was rewritten for the three intentional entry points; the 0.4 subagent adapter contract reference was replaced by the [subagent host port contract](docs/reference/subagent-host-port.md); the [0.5 migration guide](docs/guides/migrating-to-0.5.md) now covers Lanes 1–4 with a [zh-CN translation](docs/zh-CN/guides/migrating-to-0.5.md); README, setup, getting-started, web-editor, features, and configuration docs were aligned with the optional-package split (EN + zh-CN).
76
+
77
+ - Strengthened the `/subagent` host-port DTO types (code-review follow-up, no wire-behavior change): `ForgeResolveProfileResponse.snapshot`, `ForgePrepareResponse.messages`/`diagnostics`/`profileSnapshot` are no longer `unknown`. New exported types: `ForgeProfileSnapshot`, `ForgeWireAgentProfile`, `ForgeWirePromptStack`, `ForgeDelegationMessage`, `ForgeDelegationDiagnostic`, `ForgePromptDependency`/`ForgePromptDependencyKind`, `ForgeListProfilesResponse`, `ForgeHostWireMessage`, and a generic `ValidationResult<T>`; the recursive validators now return typed data. Runtime validation is byte-compatible with 0.5.0.
78
+
79
+ ### Fixed
80
+
81
+ - Profile auto-activation now honors project-over-global shadowing: a global `autoActivate` profile whose ID exists in project scope no longer activates, matching `chooseAutoActivateStack` semantics (0.5.x review A1). Regression test covers explicit opt-out and implicit shadowing.
82
+ - The fresh-session startup branch now evaluates auto-activation requests with the same shadow-aware candidacy (A1 follow-up, found by dogfooding): a global `autoActivate` profile shadowed by a same-ID project profile no longer triggers the spurious "multiple agent profiles request auto-activation" error, and the auto-activate stack fallback is no longer skipped in that state.
83
+ - Extension macro/slot names may no longer contain `.` — forge-v1 uses dots as path separators, so dotted names were registerable but unreachable (0.5.x review A2). Regression test pins the rejection.
84
+ - Static prompt analysis now reports macro dependency cycles as `recursion` diagnostics instead of silently stopping traversal (0.5.x review A5). Regression test pins a single deduplicated diagnostic per cycle.
85
+ - Dev/test Pi SDK pins aligned across both repositories at `0.84.2` (0.5.x review A4); the optional package no longer mixes `0.83.0`/`0.84.2` instances in its tree.
86
+
87
+ - Web editor polish (code-review follow-up): the theme toggle moved from the legacy stacks topbar into the shared surface navigation, so it stays visible and functional on the Agent profiles surface; theme state now lives in a shared `theme.ts` module consumed by both the Vue shell and the legacy bridge. Policy editor rows no longer repeat the column labels on wide layouts (labels return when the grid stacks on narrow screens). Item/main action buttons no longer wrap their own text mid-label, and the item toolbar wraps whole buttons instead of clipping.
10
88
 
11
89
  ## [0.4.1] - 2026-08-17
12
90
 
package/README.md CHANGED
@@ -14,10 +14,10 @@ Think of it as a character sheet and workbench for your AI agent.
14
14
  - Switch between coding, reviewing, writing, roleplay, and translation modes with one command.
15
15
  - Save and apply complete model/thinking/stack profiles.
16
16
  - Enforce per-stack tool policy and filter model-visible skills.
17
- - Use static, turn, and session variables with nested template macros.
17
+ - Use immutable stack `parameters` with the deterministic forge-v1 template engine.
18
18
  - Apply deterministic regex transforms to outgoing prompts or finalized assistant messages.
19
- - Import SillyTavern presets and inspect the migration report.
20
19
  - Edit stacks and profiles in a local browser UI and inspect the exact provider payload.
20
+ - Inspect prompt changes in the Preview dock: **Preview** compiles the live draft, **Draft diff** compares unsaved edits with disk, and **Run diff** compares recent provider turns. Git-style unified/split views include old/new line numbers, inline highlights, and changes-only/three-line/all-line context. Run metadata keeps chars/4 estimates separate from Pi's provider-reported prompt/cache usage and real cache-hit rate.
21
21
  - Run an explicitly enabled profile as an experimental, approval-gated foreground subagent.
22
22
 
23
23
  ## Install
@@ -58,7 +58,7 @@ Restart Pi or run:
58
58
  /preset ui
59
59
  ```
60
60
 
61
- The local editor can create, fork, validate, preview, import, export, and delete prompt stacks. Its **Agent profiles** view manages one-shot model/thinking/stack presets and experimental delegation settings. Writes require a trusted project.
61
+ The local editor can create, fork, validate, preview, import, export, and delete prompt stacks. Its **Agent profiles** view manages one-shot model/thinking/stack presets. Writes require a trusted project. When `@zihanw/pi-forge-subagents` is installed, its schema-driven editor appears on the separate top-level **Settings** surface and persists to the optional package's `subagents.json` files.
62
62
 
63
63
  ### 3. Save a profile
64
64
 
@@ -78,9 +78,9 @@ A prompt stack is an ordered JSON document containing:
78
78
  | Item | Purpose |
79
79
  |---|---|
80
80
  | **Block** | Static `system`, `user`, `assistant`, or hidden `custom` text |
81
- | **Slot** | Runtime content such as tools, skills, project context, variables, date/cwd, or chat history |
81
+ | **Slot** | Runtime content such as tools, skills, project context, date/cwd, or chat history |
82
82
 
83
- Stacks can `replace`, `append`, or `prepend` Pi's base system prompt. During compilation, pi-forge expands macros, inserts conversation content, enforces tool policy, filters its skill listing, and applies enabled regex rules.
83
+ Stacks can `replace`, `append`, or `prepend` Pi's base system prompt. During compilation, pi-forge compiles forge-v1 templates over `runtime.*` / `parameters.*` / `extensions.*`, inserts conversation content, enforces tool policy, filters its skill listing, and applies enabled regex rules.
84
84
 
85
85
  Agent profiles are project-local references to an exact provider/model, thinking level, and prompt stack. They intentionally do not duplicate tool or skill policy—the referenced stack remains the source of truth.
86
86
 
@@ -88,7 +88,6 @@ Start with these examples:
88
88
 
89
89
  - [Default Pi mirror](examples/default-prompt-stack.json) keeps normal Pi behavior while making its sections movable.
90
90
  - [Focused reviewer](examples/reviewer-prompt-stack.json) creates a read-only review layout with an explicit latest-user target.
91
- - [SillyTavern DM writer](examples/sillytavern-dm-writer-prompt-stack.json) demonstrates characters, variables, history placement, and regex cleanup.
92
91
  - [Custom system-status extension](examples/custom-system-status-extension/README.md) registers a trusted macro and slot.
93
92
 
94
93
  ## Common commands
@@ -111,9 +110,9 @@ See the [complete command reference](docs/reference/commands.md).
111
110
 
112
111
  ## Experimental foreground delegation
113
112
 
114
- pi-forge can run an explicitly enabled profile as a clean, foreground Pi subprocess. The model can discover eligible profiles with `forge_subagent_profiles` and invoke one with `forge_subagent`; humans use `/forge-agent plan` and `/forge-agent run`.
113
+ The optional `@zihanw/pi-forge-subagents` package provides foreground delegation on top of pi-forge's `/subagent` host port. The model can discover eligible profiles with `forge_subagent_profiles` and invoke one with `forge_subagent`; humans use `/forge-agent plan` and `/forge-agent run`.
115
114
 
116
- This feature is **experimental** and profiles are not delegatable by default. Enable each profile in the trusted project's `.pi/forge/config.json` or its web-editor delegation card. Interactive execution presents an immutable plan for approval unless the project explicitly authorizes unattended model invocation.
115
+ This feature is **experimental** and profiles are not delegatable by default. Enable each profile in the trusted project's `.pi/forge/subagents.json` (or the optional package's read-only legacy fallback in `.pi/forge/config.json.subagents`). Interactive execution presents an immutable plan for approval unless the project explicitly authorizes unattended model invocation.
117
116
 
118
117
  > **Security boundary:** The current backends are shared-user processes, not operating-system sandboxes. “Read-only” describes the model-visible tool policy. The child retains the invoking user's OS read permissions, and readable content may be sent to the selected provider and retained in Pi's session data. Timeout and cancellation are best effort, and `/tree` cannot undo provider requests, billing, or external effects.
119
118
 
@@ -124,11 +123,11 @@ Read [foreground delegation and its safety model](docs/guides/delegation.md) bef
124
123
  ### Learn
125
124
 
126
125
  - [Getting started](docs/getting-started.md)
126
+ - [Migrating to 0.5](docs/guides/migrating-to-0.5.md)
127
127
  - [Prompt-stack concepts](docs/concepts/prompt-stacks.md)
128
128
  - [Agent-profile concepts](docs/concepts/agent-profiles.md)
129
129
  - [Web editor](docs/guides/web-editor.md)
130
130
  - [Prompt-stack patterns and examples](docs/guides/use-cases.md)
131
- - [SillyTavern import](docs/guides/sillytavern-import.md)
132
131
  - [Custom macros and slots](docs/guides/custom-macros-and-slots.md)
133
132
  - [Prompt and payload debugging](docs/guides/debugging.md)
134
133
 
@@ -139,14 +138,16 @@ Read [foreground delegation and its safety model](docs/guides/delegation.md) bef
139
138
  - [Macros and slots](docs/reference/macros-and-slots.md)
140
139
  - [Configuration](docs/reference/configuration.md)
141
140
  - [Public API policy](docs/reference/public-api.md)
142
- - [Experimental subagent adapter](docs/reference/subagent-adapter.md)
141
+ - [Experimental subagent host port](docs/reference/subagent-host-port.md)
143
142
 
144
143
  ### Develop and design
145
144
 
146
145
  - [Development setup](docs/development/setup.md)
146
+ - [Architecture and development rules](docs/development/architecture-rules.md)
147
+ - [0.5 architecture plan](docs/design/architecture-0.5.md)
147
148
  - [Release process](docs/development/release.md)
148
149
  - [Roadmap](docs/development/roadmap.md)
149
- - [Historical design archive](docs/design/README.md)
150
+ - [Architecture and design index](docs/design/README.md)
150
151
 
151
152
  Chinese user documentation starts at [docs/zh-CN/README.md](docs/zh-CN/README.md).
152
153
 
package/README.zh-CN.md CHANGED
@@ -16,7 +16,6 @@
16
16
  - 按栈严格限制工具,并过滤模型可见的 skills。
17
17
  - 使用静态、轮次和会话变量,以及支持嵌套的模板宏。
18
18
  - 对发给模型的 prompt 或最终 assistant 消息执行确定性 regex 转换。
19
- - 导入 SillyTavern 预设并检查迁移报告。
20
19
  - 在本地 Web 编辑器中管理 stack/profile,并检查实际 provider payload。
21
20
  - 用明确启用的 profile 运行实验性、需要审批的前台 subagent。
22
21
 
@@ -58,7 +57,7 @@ cp examples/default-prompt-stack.json .pi/forge/prompt-stacks/default.json
58
57
  /preset ui
59
58
  ```
60
59
 
61
- 本地编辑器可以新建、fork、校验、预览、导入、导出和删除 prompt stack,并可在新建/fork/导入时明确选择写入项目或用户全局存储。切换到 **Agent profiles** 可以浏览项目与全局 profile、编辑和删除全局 profile(通过显式 `global:<id>` 路由),并管理实验性 delegation 配置。写入操作要求项目已被信任。
60
+ 本地编辑器可以新建、fork、校验、预览、导入、导出和删除 prompt stack,并可在新建/fork/导入时明确选择写入项目或用户全局存储。Preview dock 提供带旧/新行号和行内高亮的 unified/split diff,可只看变化行或保留三行/全部上下文;Run diff 会把 chars/4 估算与 Pi 返回的真实 prompt/cache usage、cache hit rate 明确分开。切换到 **Agent profiles** 可以浏览项目与全局 profile、编辑和删除全局 profile(通过显式 `global:<id>` 路由)。写入操作要求项目已被信任。Delegation 配置由可选包 `@zihanw/pi-forge-subagents` 的 `subagents.json` 文件管理,不在编辑器中。
62
61
 
63
62
  ### 3. 保存 profile
64
63
 
@@ -88,7 +87,6 @@ Agent profile 是项目级或用户全局预设,引用精确 provider/model、
88
87
 
89
88
  - [默认 Pi mirror](examples/default-prompt-stack.json):保留 Pi 默认行为,同时让所有区域都可移动。
90
89
  - [专注代码审查](examples/reviewer-prompt-stack.json):只读工具策略、背景历史和明确的最新用户目标。
91
- - [SillyTavern DM writer](examples/sillytavern-dm-writer-prompt-stack.json):角色、变量、历史布局和 regex 清理。
92
90
  - [自定义 system-status extension](examples/custom-system-status-extension/README.md):注册可信 macro 和 slot。
93
91
 
94
92
  ## 常用命令
@@ -111,9 +109,9 @@ Agent profile 是项目级或用户全局预设,引用精确 provider/model、
111
109
 
112
110
  ## 实验性前台 delegation
113
111
 
114
- pi-forge 可以把明确授权的 profile 作为干净、前台运行的 Pi 子进程。模型通过 `forge_subagent_profiles` 发现可用 profile,再用 `forge_subagent` 调用;用户可以使用 `/forge-agent plan` 和 `/forge-agent run`。
112
+ 可选包 `@zihanw/pi-forge-subagents` 在 pi-forge 的 `/subagent` host port 之上提供前台 delegation。模型通过 `forge_subagent_profiles` 发现可用 profile,再用 `forge_subagent` 调用;用户可以使用 `/forge-agent plan` 和 `/forge-agent run`。
115
113
 
116
- 此功能仍是**实验性功能**,profile 默认不能委派。请在可信项目的 `.pi/forge/config.json`(授权 `project:<id>`)或用户全局 `~/.pi/forge/config.json`(授权 `global:<id>`)中逐个启用,也可以使用 Web 编辑器 delegation 卡片。除非项目明确授权无人值守的模型调用,否则执行前会显示与不可变计划绑定的审批界面。
114
+ 此功能仍是**实验性功能**,profile 默认不能委派。请在可信项目的 `.pi/forge/subagents.json`(或可选包只读兼容的 `.pi/forge/config.json.subagents`)中逐个启用。除非项目明确授权无人值守的模型调用,否则执行前会显示与不可变计划绑定的审批界面。
117
115
 
118
116
  > **安全边界:** 当前 backend 是 shared-user 进程,不是操作系统沙箱。“只读”只描述模型可见工具策略。Child 仍有启动用户的 OS 读取权限;可读内容可能发送给所选 provider,并保留在 Pi session 数据中。Timeout 和取消仅为 best effort,`/tree` 不能撤销 provider 请求、计费或外部影响。
119
117
 
@@ -1,5 +1,7 @@
1
1
  # Subagent adapter contract
2
2
 
3
- The authoritative experimental contract moved to [`docs/reference/subagent-adapter.md`](docs/reference/subagent-adapter.md).
3
+ The authoritative experimental contract moved to [`docs/reference/subagent-host-port.md`](docs/reference/subagent-host-port.md).
4
+
5
+ The 0.4 execution contract (request, preflight, plan, response, validators) moved to the optional `@zihanw/pi-forge-subagents` package in 0.5.0; the main package keeps only the versioned host port.
4
6
 
5
7
  This compatibility pointer remains at the published root path so existing links continue to work.
@@ -2,39 +2,24 @@ import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
2
2
  import { type Model } from "@earendil-works/pi-ai";
3
3
  import { type ResourceScope } from "./resource-identity.ts";
4
4
  import type { LoadedPromptStack } from "./types.ts";
5
- export declare const AGENT_PROFILE_TYPE: "pi-forge.agent-profile";
6
- export declare const AGENT_PROFILE_THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
7
- export interface AgentProfileModelReference {
8
- provider: string;
9
- id: string;
10
- }
11
- export interface AgentProfile {
12
- schemaVersion: 1;
13
- type: typeof AGENT_PROFILE_TYPE;
14
- id: string;
15
- name?: string;
16
- description?: string;
17
- autoActivate?: boolean;
18
- model: AgentProfileModelReference;
19
- thinkingLevel: ThinkingLevel;
20
- promptStack: string | null;
21
- }
22
- export type AgentProfileDiagnosticLevel = "error" | "warning" | "info";
23
- export interface AgentProfileDiagnostic {
24
- level: AgentProfileDiagnosticLevel;
25
- message: string;
26
- field?: string;
27
- }
28
- export interface LoadedAgentProfile {
29
- profile: AgentProfile;
30
- filePath: string;
31
- scope: "global" | "project";
32
- key: {
33
- scope: "global" | "project";
34
- id: string;
35
- };
36
- diagnostics: AgentProfileDiagnostic[];
37
- }
5
+ import { type AgentProfile, type AgentProfileDiagnostic, type AgentProfileModelReference, type LoadedAgentProfile } from "./codecs/agent-profile.ts";
6
+ export { AGENT_PROFILE_TYPE, AGENT_PROFILE_THINKING_LEVELS, validateAgentProfile, validateAgentProfilePromptStackScope } from "./codecs/agent-profile.ts";
7
+ export type { AgentProfile, AgentProfileDiagnostic, AgentProfileDiagnosticLevel, AgentProfileModelReference, LoadedAgentProfile } from "./codecs/agent-profile.ts";
8
+ export declare function loadAgentProfileFile(filePath: string, scope?: "global" | "project"): LoadedAgentProfile;
9
+ export { agentProfilePath, agentProfilesDir } from "./storage.ts";
10
+ export declare function isValidAgentProfileId(id: string): boolean;
11
+ export declare function loadAgentProfiles(cwd: string): LoadedAgentProfile[];
12
+ export declare function loadAgentProfilesScoped(cwd: string, globalDir?: string): LoadedAgentProfile[];
13
+ export declare function loadGlobalAgentProfiles(globalDir?: string): LoadedAgentProfile[];
14
+ export declare function chooseAutoActivateAgentProfile(profiles: readonly LoadedAgentProfile[]): LoadedAgentProfile | undefined;
15
+ export declare function hasAutoActivateAgentProfile(profiles: readonly LoadedAgentProfile[]): boolean;
16
+ export declare function resolveAgentProfile(loaded: LoadedAgentProfile, resources: AgentProfileResolutionResources): ResolvedAgentProfile;
17
+ export declare function isUsableAgentProfile(loaded: LoadedAgentProfile): boolean;
18
+ export declare function isResolvedAgentProfileUsable(resolved: ResolvedAgentProfile): boolean;
19
+ export declare function hasAgentProfileErrors(diagnostics: readonly AgentProfileDiagnostic[]): boolean;
20
+ export declare function renderAgentProfileDiagnostics(diagnostics: readonly AgentProfileDiagnostic[]): string;
21
+ export declare function agentProfileFingerprint(profile: AgentProfile): string;
22
+ export declare function isAgentProfileProvenance(value: unknown): value is AgentProfileProvenance;
38
23
  export interface AgentProfileResolutionResources {
39
24
  models: readonly Model<any>[];
40
25
  availableModels?: readonly Model<any>[];
@@ -62,33 +47,4 @@ export interface AgentProfileProvenance {
62
47
  appliedAt: string;
63
48
  snapshot: AgentProfileRuntimeSnapshot;
64
49
  }
65
- export { agentProfilePath, agentProfilesDir } from "./storage.ts";
66
- export declare function isValidAgentProfileId(id: string): boolean;
67
- export declare function loadAgentProfiles(cwd: string): LoadedAgentProfile[];
68
- /**
69
- * Load both global and project profiles. Global definitions are user-owned
70
- * and always load; project definitions load from the trusted project dirs.
71
- * The caller decides whether project trust applies before calling.
72
- */
73
- export declare function loadAgentProfilesScoped(cwd: string, globalDir?: string): LoadedAgentProfile[];
74
- /** Load only the user-owned global profiles, used by untrusted projects. */
75
- export declare function loadGlobalAgentProfiles(globalDir?: string): LoadedAgentProfile[];
76
- export declare function chooseAutoActivateAgentProfile(profiles: readonly LoadedAgentProfile[]): LoadedAgentProfile | undefined;
77
- export declare function hasAutoActivateAgentProfile(profiles: readonly LoadedAgentProfile[]): boolean;
78
- export declare function loadAgentProfileFile(filePath: string, scope?: "global" | "project"): LoadedAgentProfile;
79
- export declare function validateAgentProfile(profile: AgentProfile): AgentProfileDiagnostic[];
80
- /**
81
- * Validate the profile's stored `promptStack` selector against the profile's
82
- * own scope. Bare references stay scope-relative; only global profiles are
83
- * prohibited from referencing project stacks explicitly. Used by write paths
84
- * so edited JSON cannot persist a scope-unsafe dependency.
85
- */
86
- export declare function validateAgentProfilePromptStackScope(profile: AgentProfile, scope: ResourceScope): AgentProfileDiagnostic[];
87
- export declare function resolveAgentProfile(loaded: LoadedAgentProfile, resources: AgentProfileResolutionResources): ResolvedAgentProfile;
88
- export declare function isUsableAgentProfile(loaded: LoadedAgentProfile): boolean;
89
- export declare function isResolvedAgentProfileUsable(resolved: ResolvedAgentProfile): boolean;
90
- export declare function hasAgentProfileErrors(diagnostics: readonly AgentProfileDiagnostic[]): boolean;
91
- export declare function renderAgentProfileDiagnostics(diagnostics: readonly AgentProfileDiagnostic[]): string;
92
- export declare function agentProfileFingerprint(profile: AgentProfile): string;
93
- export declare function isAgentProfileProvenance(value: unknown): value is AgentProfileProvenance;
94
50
  //# sourceMappingURL=agent-profile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-profile.d.ts","sourceRoot":"","sources":["../src/agent-profile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAsB,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAgF,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE1I,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,kBAAkB,EAAG,wBAAiC,CAAC;AAEpE,eAAO,MAAM,6BAA6B,sEAA0G,CAAC;AAMrJ,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,YAAY;IAC5B,aAAa,EAAE,CAAC,CAAC;IACjB,IAAI,EAAE,OAAO,kBAAkB,CAAC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,0BAA0B,CAAC;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,M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