@jadelclemens/pi-forge 0.0.0-stage → 0.6.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.
Files changed (440) hide show
  1. package/CHANGELOG.md +486 -0
  2. package/LICENSE +21 -0
  3. package/PUBLIC_API.md +5 -0
  4. package/README.md +204 -2
  5. package/README.zh-CN.md +128 -0
  6. package/SUBAGENT_ADAPTER_CONTRACT.md +7 -0
  7. package/dist/active-state.d.ts +148 -0
  8. package/dist/active-state.d.ts.map +1 -0
  9. package/dist/active-state.js +374 -0
  10. package/dist/active-state.js.map +1 -0
  11. package/dist/agent-profile.d.ts +51 -0
  12. package/dist/agent-profile.d.ts.map +1 -0
  13. package/dist/agent-profile.js +197 -0
  14. package/dist/agent-profile.js.map +1 -0
  15. package/dist/capabilities.d.ts +39 -0
  16. package/dist/capabilities.d.ts.map +1 -0
  17. package/dist/capabilities.js +160 -0
  18. package/dist/capabilities.js.map +1 -0
  19. package/dist/capability-anchors.d.ts +45 -0
  20. package/dist/capability-anchors.d.ts.map +1 -0
  21. package/dist/capability-anchors.js +263 -0
  22. package/dist/capability-anchors.js.map +1 -0
  23. package/dist/capability-command.d.ts +4 -0
  24. package/dist/capability-command.d.ts.map +1 -0
  25. package/dist/capability-command.js +164 -0
  26. package/dist/capability-command.js.map +1 -0
  27. package/dist/capability-events.d.ts +79 -0
  28. package/dist/capability-events.d.ts.map +1 -0
  29. package/dist/capability-events.js +478 -0
  30. package/dist/capability-events.js.map +1 -0
  31. package/dist/capability-projection.d.ts +22 -0
  32. package/dist/capability-projection.d.ts.map +1 -0
  33. package/dist/capability-projection.js +273 -0
  34. package/dist/capability-projection.js.map +1 -0
  35. package/dist/capability-protocol.d.ts +21 -0
  36. package/dist/capability-protocol.d.ts.map +1 -0
  37. package/dist/capability-protocol.js +15 -0
  38. package/dist/capability-protocol.js.map +1 -0
  39. package/dist/capability-state.d.ts +74 -0
  40. package/dist/capability-state.d.ts.map +1 -0
  41. package/dist/capability-state.js +43 -0
  42. package/dist/capability-state.js.map +1 -0
  43. package/dist/capability-tool.d.ts +11 -0
  44. package/dist/capability-tool.d.ts.map +1 -0
  45. package/dist/capability-tool.js +25 -0
  46. package/dist/capability-tool.js.map +1 -0
  47. package/dist/capability-web-host.d.ts +11 -0
  48. package/dist/capability-web-host.d.ts.map +1 -0
  49. package/dist/capability-web-host.js +105 -0
  50. package/dist/capability-web-host.js.map +1 -0
  51. package/dist/catalog.d.ts +27 -0
  52. package/dist/catalog.d.ts.map +1 -0
  53. package/dist/catalog.js +59 -0
  54. package/dist/catalog.js.map +1 -0
  55. package/dist/codecs/agent-profile.d.ts +53 -0
  56. package/dist/codecs/agent-profile.d.ts.map +1 -0
  57. package/dist/codecs/agent-profile.js +176 -0
  58. package/dist/codecs/agent-profile.js.map +1 -0
  59. package/dist/codecs/capability.d.ts +71 -0
  60. package/dist/codecs/capability.d.ts.map +1 -0
  61. package/dist/codecs/capability.js +363 -0
  62. package/dist/codecs/capability.js.map +1 -0
  63. package/dist/codecs/index.d.ts +5 -0
  64. package/dist/codecs/index.d.ts.map +1 -0
  65. package/dist/codecs/index.js +3 -0
  66. package/dist/codecs/index.js.map +1 -0
  67. package/dist/codecs/prompt-stack.d.ts +18 -0
  68. package/dist/codecs/prompt-stack.d.ts.map +1 -0
  69. package/dist/codecs/prompt-stack.js +623 -0
  70. package/dist/codecs/prompt-stack.js.map +1 -0
  71. package/dist/command-contribution/index.d.ts +21 -0
  72. package/dist/command-contribution/index.d.ts.map +1 -0
  73. package/dist/command-contribution/index.js +14 -0
  74. package/dist/command-contribution/index.js.map +1 -0
  75. package/dist/compile-cycle.d.ts +26 -0
  76. package/dist/compile-cycle.d.ts.map +1 -0
  77. package/dist/compile-cycle.js +16 -0
  78. package/dist/compile-cycle.js.map +1 -0
  79. package/dist/compiler.d.ts +22 -0
  80. package/dist/compiler.d.ts.map +1 -0
  81. package/dist/compiler.js +737 -0
  82. package/dist/compiler.js.map +1 -0
  83. package/dist/context-diff-history.d.ts +69 -0
  84. package/dist/context-diff-history.d.ts.map +1 -0
  85. package/dist/context-diff-history.js +107 -0
  86. package/dist/context-diff-history.js.map +1 -0
  87. package/dist/context-diff-snapshot.d.ts +19 -0
  88. package/dist/context-diff-snapshot.d.ts.map +1 -0
  89. package/dist/context-diff-snapshot.js +146 -0
  90. package/dist/context-diff-snapshot.js.map +1 -0
  91. package/dist/context-diff.d.ts +70 -0
  92. package/dist/context-diff.d.ts.map +1 -0
  93. package/dist/context-diff.js +259 -0
  94. package/dist/context-diff.js.map +1 -0
  95. package/dist/extension-registry.d.ts +25 -0
  96. package/dist/extension-registry.d.ts.map +1 -0
  97. package/dist/extension-registry.js +9 -0
  98. package/dist/extension-registry.js.map +1 -0
  99. package/dist/forge-command.d.ts +10 -0
  100. package/dist/forge-command.d.ts.map +1 -0
  101. package/dist/forge-command.js +106 -0
  102. package/dist/forge-command.js.map +1 -0
  103. package/dist/forge-config.d.ts +9 -0
  104. package/dist/forge-config.d.ts.map +1 -0
  105. package/dist/forge-config.js +15 -0
  106. package/dist/forge-config.js.map +1 -0
  107. package/dist/forge-extensions.d.ts +28 -0
  108. package/dist/forge-extensions.d.ts.map +1 -0
  109. package/dist/forge-extensions.js +198 -0
  110. package/dist/forge-extensions.js.map +1 -0
  111. package/dist/forge-v1/analyzer.d.ts +3 -0
  112. package/dist/forge-v1/analyzer.d.ts.map +1 -0
  113. package/dist/forge-v1/analyzer.js +50 -0
  114. package/dist/forge-v1/analyzer.js.map +1 -0
  115. package/dist/forge-v1/index.d.ts +6 -0
  116. package/dist/forge-v1/index.d.ts.map +1 -0
  117. package/dist/forge-v1/index.js +13 -0
  118. package/dist/forge-v1/index.js.map +1 -0
  119. package/dist/forge-v1/parser.d.ts +3 -0
  120. package/dist/forge-v1/parser.d.ts.map +1 -0
  121. package/dist/forge-v1/parser.js +186 -0
  122. package/dist/forge-v1/parser.js.map +1 -0
  123. package/dist/forge-v1/renderer.d.ts +9 -0
  124. package/dist/forge-v1/renderer.d.ts.map +1 -0
  125. package/dist/forge-v1/renderer.js +181 -0
  126. package/dist/forge-v1/renderer.js.map +1 -0
  127. package/dist/forge-v1/types.d.ts +87 -0
  128. package/dist/forge-v1/types.d.ts.map +1 -0
  129. package/dist/forge-v1/types.js +4 -0
  130. package/dist/forge-v1/types.js.map +1 -0
  131. package/dist/host-compatibility.d.ts +13 -0
  132. package/dist/host-compatibility.d.ts.map +1 -0
  133. package/dist/host-compatibility.js +41 -0
  134. package/dist/host-compatibility.js.map +1 -0
  135. package/dist/index.d.ts +15 -0
  136. package/dist/index.d.ts.map +1 -0
  137. package/dist/index.js +183 -0
  138. package/dist/index.js.map +1 -0
  139. package/dist/json-fingerprint.d.ts +11 -0
  140. package/dist/json-fingerprint.d.ts.map +1 -0
  141. package/dist/json-fingerprint.js +66 -0
  142. package/dist/json-fingerprint.js.map +1 -0
  143. package/dist/lifecycle.d.ts +46 -0
  144. package/dist/lifecycle.d.ts.map +1 -0
  145. package/dist/lifecycle.js +330 -0
  146. package/dist/lifecycle.js.map +1 -0
  147. package/dist/loader.d.ts +21 -0
  148. package/dist/loader.d.ts.map +1 -0
  149. package/dist/loader.js +58 -0
  150. package/dist/loader.js.map +1 -0
  151. package/dist/macro-engine.d.ts +18 -0
  152. package/dist/macro-engine.d.ts.map +1 -0
  153. package/dist/macro-engine.js +29 -0
  154. package/dist/macro-engine.js.map +1 -0
  155. package/dist/payload-capture.d.ts +31 -0
  156. package/dist/payload-capture.d.ts.map +1 -0
  157. package/dist/payload-capture.js +253 -0
  158. package/dist/payload-capture.js.map +1 -0
  159. package/dist/payload-command.d.ts +12 -0
  160. package/dist/payload-command.d.ts.map +1 -0
  161. package/dist/payload-command.js +197 -0
  162. package/dist/payload-command.js.map +1 -0
  163. package/dist/payload-state.d.ts +20 -0
  164. package/dist/payload-state.d.ts.map +1 -0
  165. package/dist/payload-state.js +20 -0
  166. package/dist/payload-state.js.map +1 -0
  167. package/dist/policy.d.ts +7 -0
  168. package/dist/policy.d.ts.map +1 -0
  169. package/dist/policy.js +41 -0
  170. package/dist/policy.js.map +1 -0
  171. package/dist/preset-command.d.ts +19 -0
  172. package/dist/preset-command.d.ts.map +1 -0
  173. package/dist/preset-command.js +261 -0
  174. package/dist/preset-command.js.map +1 -0
  175. package/dist/preview-inspection.d.ts +68 -0
  176. package/dist/preview-inspection.d.ts.map +1 -0
  177. package/dist/preview-inspection.js +293 -0
  178. package/dist/preview-inspection.js.map +1 -0
  179. package/dist/preview-text.d.ts +5 -0
  180. package/dist/preview-text.d.ts.map +1 -0
  181. package/dist/preview-text.js +27 -0
  182. package/dist/preview-text.js.map +1 -0
  183. package/dist/preview.d.ts +32 -0
  184. package/dist/preview.d.ts.map +1 -0
  185. package/dist/preview.js +272 -0
  186. package/dist/preview.js.map +1 -0
  187. package/dist/profile-command.d.ts +17 -0
  188. package/dist/profile-command.d.ts.map +1 -0
  189. package/dist/profile-command.js +385 -0
  190. package/dist/profile-command.js.map +1 -0
  191. package/dist/profile-service.d.ts +107 -0
  192. package/dist/profile-service.d.ts.map +1 -0
  193. package/dist/profile-service.js +248 -0
  194. package/dist/profile-service.js.map +1 -0
  195. package/dist/prompt-analysis.d.ts +24 -0
  196. package/dist/prompt-analysis.d.ts.map +1 -0
  197. package/dist/prompt-analysis.js +84 -0
  198. package/dist/prompt-analysis.js.map +1 -0
  199. package/dist/prompt-cache-warning.d.ts +23 -0
  200. package/dist/prompt-cache-warning.d.ts.map +1 -0
  201. package/dist/prompt-cache-warning.js +74 -0
  202. package/dist/prompt-cache-warning.js.map +1 -0
  203. package/dist/prompt-runtime.d.ts +19 -0
  204. package/dist/prompt-runtime.d.ts.map +1 -0
  205. package/dist/prompt-runtime.js +34 -0
  206. package/dist/prompt-runtime.js.map +1 -0
  207. package/dist/regex.d.ts +19 -0
  208. package/dist/regex.d.ts.map +1 -0
  209. package/dist/regex.js +507 -0
  210. package/dist/regex.js.map +1 -0
  211. package/dist/render-helpers.d.ts +38 -0
  212. package/dist/render-helpers.d.ts.map +1 -0
  213. package/dist/render-helpers.js +85 -0
  214. package/dist/render-helpers.js.map +1 -0
  215. package/dist/repositories/agent-profile.d.ts +36 -0
  216. package/dist/repositories/agent-profile.d.ts.map +1 -0
  217. package/dist/repositories/agent-profile.js +153 -0
  218. package/dist/repositories/agent-profile.js.map +1 -0
  219. package/dist/repositories/capability.d.ts +53 -0
  220. package/dist/repositories/capability.d.ts.map +1 -0
  221. package/dist/repositories/capability.js +294 -0
  222. package/dist/repositories/capability.js.map +1 -0
  223. package/dist/repositories/index.d.ts +3 -0
  224. package/dist/repositories/index.d.ts.map +1 -0
  225. package/dist/repositories/index.js +3 -0
  226. package/dist/repositories/index.js.map +1 -0
  227. package/dist/repositories/prompt-stack.d.ts +57 -0
  228. package/dist/repositories/prompt-stack.d.ts.map +1 -0
  229. package/dist/repositories/prompt-stack.js +175 -0
  230. package/dist/repositories/prompt-stack.js.map +1 -0
  231. package/dist/resource-identity.d.ts +33 -0
  232. package/dist/resource-identity.d.ts.map +1 -0
  233. package/dist/resource-identity.js +56 -0
  234. package/dist/resource-identity.js.map +1 -0
  235. package/dist/runtime/capability-runtime.d.ts +95 -0
  236. package/dist/runtime/capability-runtime.d.ts.map +1 -0
  237. package/dist/runtime/capability-runtime.js +991 -0
  238. package/dist/runtime/capability-runtime.js.map +1 -0
  239. package/dist/runtime/profile-runtime.d.ts +14 -0
  240. package/dist/runtime/profile-runtime.d.ts.map +1 -0
  241. package/dist/runtime/profile-runtime.js +56 -0
  242. package/dist/runtime/profile-runtime.js.map +1 -0
  243. package/dist/runtime/prompt-stack-runtime.d.ts +27 -0
  244. package/dist/runtime/prompt-stack-runtime.d.ts.map +1 -0
  245. package/dist/runtime/prompt-stack-runtime.js +149 -0
  246. package/dist/runtime/prompt-stack-runtime.js.map +1 -0
  247. package/dist/runtime/tool-policy-runtime.d.ts +25 -0
  248. package/dist/runtime/tool-policy-runtime.d.ts.map +1 -0
  249. package/dist/runtime/tool-policy-runtime.js +386 -0
  250. package/dist/runtime/tool-policy-runtime.js.map +1 -0
  251. package/dist/runtime/web-editor-runtime.d.ts +11 -0
  252. package/dist/runtime/web-editor-runtime.d.ts.map +1 -0
  253. package/dist/runtime/web-editor-runtime.js +141 -0
  254. package/dist/runtime/web-editor-runtime.js.map +1 -0
  255. package/dist/session-adapter.d.ts +30 -0
  256. package/dist/session-adapter.d.ts.map +1 -0
  257. package/dist/session-adapter.js +167 -0
  258. package/dist/session-adapter.js.map +1 -0
  259. package/dist/session-state.d.ts +23 -0
  260. package/dist/session-state.d.ts.map +1 -0
  261. package/dist/session-state.js +44 -0
  262. package/dist/session-state.js.map +1 -0
  263. package/dist/session-usage.d.ts +65 -0
  264. package/dist/session-usage.d.ts.map +1 -0
  265. package/dist/session-usage.js +134 -0
  266. package/dist/session-usage.js.map +1 -0
  267. package/dist/slot-renderers.d.ts +38 -0
  268. package/dist/slot-renderers.d.ts.map +1 -0
  269. package/dist/slot-renderers.js +285 -0
  270. package/dist/slot-renderers.js.map +1 -0
  271. package/dist/stack-migration.d.ts +35 -0
  272. package/dist/stack-migration.d.ts.map +1 -0
  273. package/dist/stack-migration.js +123 -0
  274. package/dist/stack-migration.js.map +1 -0
  275. package/dist/status-text.d.ts +6 -0
  276. package/dist/status-text.d.ts.map +1 -0
  277. package/dist/status-text.js +11 -0
  278. package/dist/status-text.js.map +1 -0
  279. package/dist/storage.d.ts +24 -0
  280. package/dist/storage.d.ts.map +1 -0
  281. package/dist/storage.js +94 -0
  282. package/dist/storage.js.map +1 -0
  283. package/dist/subagent/fingerprints.d.ts +12 -0
  284. package/dist/subagent/fingerprints.d.ts.map +1 -0
  285. package/dist/subagent/fingerprints.js +17 -0
  286. package/dist/subagent/fingerprints.js.map +1 -0
  287. package/dist/subagent/host-port.d.ts +296 -0
  288. package/dist/subagent/host-port.d.ts.map +1 -0
  289. package/dist/subagent/host-port.js +560 -0
  290. package/dist/subagent/host-port.js.map +1 -0
  291. package/dist/subagent/index.d.ts +16 -0
  292. package/dist/subagent/index.d.ts.map +1 -0
  293. package/dist/subagent/index.js +15 -0
  294. package/dist/subagent/index.js.map +1 -0
  295. package/dist/subagent-host.d.ts +125 -0
  296. package/dist/subagent-host.d.ts.map +1 -0
  297. package/dist/subagent-host.js +327 -0
  298. package/dist/subagent-host.js.map +1 -0
  299. package/dist/template-render.d.ts +18 -0
  300. package/dist/template-render.d.ts.map +1 -0
  301. package/dist/template-render.js +232 -0
  302. package/dist/template-render.js.map +1 -0
  303. package/dist/types.d.ts +213 -0
  304. package/dist/types.d.ts.map +1 -0
  305. package/dist/types.js +2 -0
  306. package/dist/types.js.map +1 -0
  307. package/dist/ui-contribution/contrib-port.d.ts +170 -0
  308. package/dist/ui-contribution/contrib-port.d.ts.map +1 -0
  309. package/dist/ui-contribution/contrib-port.js +640 -0
  310. package/dist/ui-contribution/contrib-port.js.map +1 -0
  311. package/dist/ui-contribution/index.d.ts +3 -0
  312. package/dist/ui-contribution/index.d.ts.map +1 -0
  313. package/dist/ui-contribution/index.js +2 -0
  314. package/dist/ui-contribution/index.js.map +1 -0
  315. package/dist/web-editor/client-script.d.ts +2 -0
  316. package/dist/web-editor/client-script.d.ts.map +1 -0
  317. package/dist/web-editor/client-script.generated.d.ts +2 -0
  318. package/dist/web-editor/client-script.generated.d.ts.map +1 -0
  319. package/dist/web-editor/client-script.generated.js +3 -0
  320. package/dist/web-editor/client-script.generated.js.map +1 -0
  321. package/dist/web-editor/client-script.js +2 -0
  322. package/dist/web-editor/client-script.js.map +1 -0
  323. package/dist/web-editor/client-styles.d.ts +2 -0
  324. package/dist/web-editor/client-styles.d.ts.map +1 -0
  325. package/dist/web-editor/client-styles.generated.d.ts +2 -0
  326. package/dist/web-editor/client-styles.generated.d.ts.map +1 -0
  327. package/dist/web-editor/client-styles.generated.js +3 -0
  328. package/dist/web-editor/client-styles.generated.js.map +1 -0
  329. package/dist/web-editor/client-styles.js +2 -0
  330. package/dist/web-editor/client-styles.js.map +1 -0
  331. package/dist/web-editor/contrib-service.d.ts +41 -0
  332. package/dist/web-editor/contrib-service.d.ts.map +1 -0
  333. package/dist/web-editor/contrib-service.js +174 -0
  334. package/dist/web-editor/contrib-service.js.map +1 -0
  335. package/dist/web-editor/index.d.ts +3 -0
  336. package/dist/web-editor/index.d.ts.map +1 -0
  337. package/dist/web-editor/index.js +2 -0
  338. package/dist/web-editor/index.js.map +1 -0
  339. package/dist/web-editor/line-diff.d.ts +28 -0
  340. package/dist/web-editor/line-diff.d.ts.map +1 -0
  341. package/dist/web-editor/line-diff.js +216 -0
  342. package/dist/web-editor/line-diff.js.map +1 -0
  343. package/dist/web-editor/page.d.ts +4 -0
  344. package/dist/web-editor/page.d.ts.map +1 -0
  345. package/dist/web-editor/page.js +26 -0
  346. package/dist/web-editor/page.js.map +1 -0
  347. package/dist/web-editor/schema-form.d.ts +63 -0
  348. package/dist/web-editor/schema-form.d.ts.map +1 -0
  349. package/dist/web-editor/schema-form.js +213 -0
  350. package/dist/web-editor/schema-form.js.map +1 -0
  351. package/dist/web-editor/server.d.ts +4 -0
  352. package/dist/web-editor/server.d.ts.map +1 -0
  353. package/dist/web-editor/server.js +637 -0
  354. package/dist/web-editor/server.js.map +1 -0
  355. package/dist/web-editor/styles.d.ts +2 -0
  356. package/dist/web-editor/styles.d.ts.map +1 -0
  357. package/dist/web-editor/styles.js +1744 -0
  358. package/dist/web-editor/styles.js.map +1 -0
  359. package/dist/web-editor/types.d.ts +304 -0
  360. package/dist/web-editor/types.d.ts.map +1 -0
  361. package/dist/web-editor/types.js +2 -0
  362. package/dist/web-editor/types.js.map +1 -0
  363. package/dist/web-host.d.ts +56 -0
  364. package/dist/web-host.d.ts.map +1 -0
  365. package/dist/web-host.js +750 -0
  366. package/dist/web-host.js.map +1 -0
  367. package/dist/workspace.d.ts +85 -0
  368. package/dist/workspace.d.ts.map +1 -0
  369. package/dist/workspace.js +409 -0
  370. package/dist/workspace.js.map +1 -0
  371. package/docs/README.md +49 -0
  372. package/docs/concepts/agent-profiles.md +62 -0
  373. package/docs/concepts/prompt-stacks.md +99 -0
  374. package/docs/design/0.5.1-plan.md +237 -0
  375. package/docs/design/README.md +37 -0
  376. package/docs/design/architecture-0.5.md +254 -0
  377. package/docs/design/archive/0.5-full-proposal/0.5-consumer-audit.md +62 -0
  378. package/docs/design/archive/0.5-full-proposal/0.5-inventory.md +208 -0
  379. package/docs/design/archive/0.5-full-proposal/0.5-phase0-decision-drafts.md +237 -0
  380. package/docs/design/archive/0.5-full-proposal/README.md +12 -0
  381. package/docs/design/archive/0.5-full-proposal/architecture-0.5.md +423 -0
  382. package/docs/design/archive/0.5-full-proposal/host-discovery-spike.md +103 -0
  383. package/docs/design/archive/0.5-full-proposal/template-language-spike.md +156 -0
  384. package/docs/design/archive/2026-09-12-system-update-design.md +229 -0
  385. package/docs/design/context-diff-plan.md +78 -0
  386. package/docs/design/decision-template.md +33 -0
  387. package/docs/design/pi-forge-system-update-design-notes.md +157 -0
  388. package/docs/design/roadmap-0.4-archive.md +216 -0
  389. package/docs/design/subagents/design-review.md +220 -0
  390. package/docs/design/subagents/interface-design.md +274 -0
  391. package/docs/design/subagents/sdk-spike-findings.md +117 -0
  392. package/docs/development/architecture-rules.md +148 -0
  393. package/docs/development/complexity-review.md +86 -0
  394. package/docs/development/release.md +59 -0
  395. package/docs/development/roadmap.md +117 -0
  396. package/docs/development/scoped-global-profiles-stacks.md +325 -0
  397. package/docs/development/setup.md +99 -0
  398. package/docs/getting-started.md +96 -0
  399. package/docs/guides/custom-macros-and-slots.md +69 -0
  400. package/docs/guides/debugging.md +39 -0
  401. package/docs/guides/delegation.md +105 -0
  402. package/docs/guides/migrating-to-0.5.md +136 -0
  403. package/docs/guides/pi-1-compatibility.md +160 -0
  404. package/docs/guides/use-cases.md +67 -0
  405. package/docs/guides/web-editor.md +161 -0
  406. package/docs/reference/active-state.md +77 -0
  407. package/docs/reference/capabilities.md +288 -0
  408. package/docs/reference/commands.md +89 -0
  409. package/docs/reference/configuration.md +70 -0
  410. package/docs/reference/features.md +305 -0
  411. package/docs/reference/macros-and-slots.md +103 -0
  412. package/docs/reference/provider-support.md +67 -0
  413. package/docs/reference/public-api.md +133 -0
  414. package/docs/reference/session-cache.md +112 -0
  415. package/docs/reference/stack-schema.md +243 -0
  416. package/docs/reference/subagent-host-port.md +57 -0
  417. package/docs/reference/ui-contribution-port.md +51 -0
  418. package/docs/zh-CN/README.md +41 -0
  419. package/docs/zh-CN/concepts/agent-profiles.md +48 -0
  420. package/docs/zh-CN/concepts/prompt-stacks.md +48 -0
  421. package/docs/zh-CN/getting-started.md +82 -0
  422. package/docs/zh-CN/guides/delegation.md +76 -0
  423. package/docs/zh-CN/guides/migrating-to-0.5.md +121 -0
  424. package/docs/zh-CN/guides/pi-1-compatibility.md +158 -0
  425. package/docs/zh-CN/guides/web-editor.md +134 -0
  426. package/docs/zh-CN/reference/capabilities.md +288 -0
  427. package/docs/zh-CN/reference/commands.md +89 -0
  428. package/docs/zh-CN/reference/provider-support.md +67 -0
  429. package/docs/zh-CN/reference/session-cache.md +112 -0
  430. package/examples/capabilities/review.json +12 -0
  431. package/examples/capabilities/write-tools.json +15 -0
  432. package/examples/custom-system-status-extension/index.ts +144 -0
  433. package/examples/custom-system-status-extension/prompt-stack.json +40 -0
  434. package/examples/default-prompt-stack.json +125 -0
  435. package/examples/fake-assistant-direct-output-prompt-stack.json +48 -0
  436. package/examples/hack-prompt-stack.json +118 -0
  437. package/examples/minimal-prompt-stack.json +40 -0
  438. package/examples/read-first-worker-prompt-stack.json +49 -0
  439. package/examples/validation-issues-prompt-stack.json +38 -0
  440. package/package.json +114 -4
@@ -0,0 +1,305 @@
1
+ # Implemented feature inventory
2
+
3
+ This file tracks the currently implemented feature surface for agent profiles, the prompt-stack runtime, static stack variables, web editor, storage migration, payload inspector, and regex MVP.
4
+
5
+ ## Package and Runtime
6
+
7
+ - Pi package manifest with compiled `dist/index.js` exposed through `package.json` `pi.extensions`.
8
+ - Public npm package configuration for `@zihanw/pi-forge`.
9
+ - Compiled npm runtime containing JavaScript, declarations, documentation, and examples without physical `src/` files; repository source remains available for clone-based development.
10
+ - Tarball verification rejects physical `src/` entries and requires the root and subagent compiled entry points.
11
+ - The web editor's HTML page shell and static styles are maintained separately from its browser behavior modules.
12
+ - Strict typed web-editor client modules bundled into one self-contained browser script at build time, with generated-client consistency verification.
13
+ - Supported Node.js baseline is 22.19+. In published 0.5.7, peer metadata required `>=0.87.0 <0.88.0`. Forge 0.5.8 expanded supported peers to `>=0.87.0 <0.88.0 || 0.99.0 || 0.99.1 || 0.99.2 || >=1.0.0 <1.1.0`; Forge 0.5.13 expands them to `>=0.87.0 <0.88.0 || 0.99.0 || 0.99.1 || 0.99.2 || >=1.0.0 <1.7.0` (development SDK pinned to 1.6.0 with `typebox@1.3.27`, minimum 0.87.0 unchanged). All five packages remain host-provided optional peers. Exact repository versions are reproducible development/test fixtures rather than runtime constraints. See [Pi 1.0 compatibility guide](../guides/pi-1-compatibility.md).
14
+ - Project trust check before loading prompt stacks.
15
+ - Footer status showing the active prompt stack.
16
+
17
+ ## Agent Profiles
18
+
19
+ - Strict schema-versioned project profiles from `.pi/forge/agent-profiles/*.json`.
20
+ - Profile v1 stores an exact provider/model reference, thinking level, and prompt-stack ID or `null`, with optional name, description, and fresh-session auto-activation metadata.
21
+ - Unsupported fields are errors so unimplemented generation, tool, skill, or runner settings cannot become inert configuration.
22
+ - Tool policy and model-visible skill filtering remain owned by the referenced prompt stack rather than duplicated in profiles.
23
+ - Pure profile resolution checks model existence, configured authentication, thinking-level clamping, prompt-stack validity, and unmatched tool allow patterns before application.
24
+ - `/profile use <id>` applies model, thinking level, and prompt stack once after complete preflight; later manual runtime changes are preserved.
25
+ - At most one profile may set `autoActivate: true`; it applies once for a fresh session and takes precedence over standalone prompt-stack autoload, while restored branch state takes precedence over both.
26
+ - Invalid or ambiguous profile auto-activation fails closed without applying a fallback stack or a partial profile. With no auto-activation profile, existing prompt-stack autoload remains the compatibility fallback.
27
+ - Failed application performs best-effort rollback and never records successful provenance.
28
+ - `/profile save <id> [--overwrite]` captures current runtime fields without tools, secrets, history, or provenance, preserving existing name/description metadata.
29
+ - `/profile preview <id>` reports resolved changes, prompt-stack tool policy, effective tools, and diagnostics without mutation.
30
+ - `/profile status` compares the current runtime with the last-applied resolved snapshot and reports source-definition changes separately.
31
+ - Last-applied provenance is branch-scoped session metadata used only for drift reporting; reload, resume, tree navigation, and compaction never reapply a profile.
32
+ - `/profile reload` reloads definitions without applying them, and `/profile forget` clears provenance without changing runtime state.
33
+ - Project trust gates profile loading, application, and writes.
34
+ - Shared typed profile services own capture, protected write/update/delete, application/rollback, immutable preview data, provenance changes, and runtime-drift calculation so command, web-editor, and adapter consumers do not duplicate behavior.
35
+
36
+ ## Subagent Host Port
37
+
38
+ - Experimental versioned `@zihanw/pi-forge/subagent` entry point: the minimal Forge DTO host contract (wire messages, recursive exact-field validators, transport-neutral `ForgeHostTransport`, `ForgeHost`/`ForgeHostClient` lifecycle) plus Forge-owned canonical `sha256:v1` fingerprint helpers byte-compatible with the runtime's canonical JSON.
39
+ - Mandatory lifecycle semantics: bounded discovery timeouts, explicit duplicate-host failure, `hostId`+`generation`-bound request/reply with stale/foreign rejection, disposal with `unavailable` and full listener cleanup. The host starts only after the first workspace snapshot exists, so an advertised host implies a loaded workspace; reload honors project trust (untrusted workspaces expose global resources only).
40
+ - Three minimal operations: `listProfiles` (loaded profile summaries with diagnostics), `resolveProfile` (immutable host-owned profile snapshot artifact with content fingerprints), and `prepare` (host-owned prompt compilation).
41
+ - Host-owned preparation: the client sends only a profile selector, the task text, prompt-compilation access facts (`level`/`network`/`allowProcess`), and backend facts (model, thinking level, tool catalog). The workspace resolves the profile and stack from its snapshot, filters the tool catalog through stack policy and access facts, and compiles through the same compilation context as runtime and preview. Responses return the system prompt, messages ending with the protected delegated task, effective tool IDs/names, diagnostics, the profile snapshot, and `preparedAt`.
42
+ - The port never exposes live contexts, internal registries, or execution/runtime material (access workspace model, limits, `resultProjection`, `parent`, `remoteEgressConsent`, base system prompt). The delegated-task base system prompt is host-owned and intentionally empty; the prompt stack composes the system prompt.
43
+ - Backend-independent host profile resolution produces path-free declarative snapshots and does not consult the parent model registry or authentication state.
44
+ - Host dependency scanning detects custom macro and slot references, records registration source identities, and fails resolution when required registrations are missing.
45
+ - Execution ownership (delegation authorization in `subagents.json`, the 0.4 execution contract, backend preflight/plan sealing via `@zihanw/pi-subagent-runtime`, approval UX, `forge_subagent`/`forge_subagent_profiles`, and `/forge-agent`) lives in the optional `@zihanw/pi-forge-subagents` package, which consumes this port and never imports main-package internals. See the [subagent host port contract](subagent-host-port.md).
46
+
47
+ ## Prompt Stack Loading and Storage
48
+
49
+ - File-backed prompt stacks from `.pi/forge/prompt-stacks/*.json`.
50
+ - Legacy `.pi/prompt-stacks/*.json` stacks remain readable and editable for compatibility.
51
+ - Same-named files in `.pi/forge/prompt-stacks` shadow legacy stack files.
52
+ - New stacks, imports, and forks write to `.pi/forge/prompt-stacks`.
53
+ - Trusted global and project-local macro/slot registration modules load from `~/.pi/forge/extensions` and `.pi/forge/extensions` before stack validation and reload on `/preset reload`.
54
+ - Trusted registration ownership is disposed during runtime shutdown, and supported ESM/CommonJS extension entry formats reload with fresh module code.
55
+ - `/preset migrate-stacks [--dry-run] [--overwrite] [--delete-legacy]` copies legacy stacks into the forge storage location.
56
+ - `default.json` auto-activation unless `autoActivate` is `false`.
57
+ - Branch-aware persisted active stack restore from session entries.
58
+ - Persisted `/preset use none` / `disable` opt-out.
59
+ - Invalid stacks with error diagnostics are skipped by automatic selection.
60
+ - Raw stack fields are shape-checked before recovery normalization, including behavior-changing booleans/enums, defaults, context, variables, and item fields.
61
+ - Stack validation for duplicate item IDs, duplicate stack IDs, unsupported slots, missing chat-history slots, and ignored items.
62
+ - Stack validation for tool and skill policy shape.
63
+
64
+ ## Prompt Compilation
65
+
66
+ - `replace`, `append`, and `prepend` system prompt modes.
67
+ - Empty replacement system prompt fallback to Pi's base system prompt.
68
+ - Enabled item ordering preserved during compilation.
69
+ - Movable `chat-history` slot in message layout.
70
+ - Optional omission of latest user message from chat history.
71
+ - Optional stripping of prior assistant thinking blocks from inserted chat history while preserving visible text, tool calls, and tool results.
72
+ - Chat history can filter summaries/roles, drop prior tool history, and cap recent history by message count or approximate characters with dangling tool calls/results repaired after filtering.
73
+ - Duplicate chat-history warning unless explicitly allowed.
74
+ - Synthetic `user`, `assistant`, and hidden `custom` messages.
75
+ - Optional consecutive-role merge (`context.mergeConsecutiveRoles`/`mergeSeparator`): runs of consecutive stack-authored `user`/`assistant` items compile into a single message; chat-history output and custom-role items are hard boundaries, and merging runs after compiled-stage regex.
76
+ - Validation warning when an enabled `system` item appears after non-system items (cross-channel item position has no effect on compilation).
77
+ - Context rewrite limited to the first provider request of each user-submitted turn.
78
+ - Tool policy filters Pi's active tool list while the stack is active and restores the previous active tools when the stack no longer applies.
79
+ - Tool policy restores its pre-policy baseline during extension shutdown so Pi reload/session replacement cannot carry a restricted built-in tool set into the replacement runtime.
80
+ - Startup tool enforcement waits until extension `session_start` configuration is complete, reasserts before user input and turns, and blocks disallowed model tool calls at execution time.
81
+ - Skill policy filters skills rendered by pi-forge `skills` slots.
82
+ - Outgoing regex transforms can run after `chat-history` insertion and after final prompt compilation.
83
+ - Per-rule `frequency: "request"` re-runs an outgoing message rule on every tool-result follow-up request over Pi's full natural context; the default `"turn"` keeps first-request-only behavior.
84
+ - `finalize` rules whose `roles` explicitly include `"toolResult"` also rewrite stored tool-result messages at completion time (destructive, documented); rules without `roles` stay assistant-only.
85
+ - Finalize regex transforms can rewrite completed assistant messages at `message_end`.
86
+
87
+ ## Regex Transforms
88
+
89
+ - Top-level `regex.schemaVersion` and ordered `regex.rules` stack config.
90
+ - Deterministic JavaScript `RegExp` replacements only; no embedded JavaScript, DOM access, browser automation, or CSS/HTML decoration runtime.
91
+ - `stage: "history"` transforms messages inserted by the `chat-history` slot.
92
+ - `stage: "compiled"` transforms the final compiled system prompt and/or message text before provider serialization.
93
+ - `effect: "outgoing"` is active for model-bound prompt text.
94
+ - `effect: "finalize"` is active for completed assistant messages at `stage: "compiled"` / `targets: ["messages"]`.
95
+ - `effect: "finalize"` is destructive: it replaces the finalized assistant message in Pi's stored transcript, so the original model output is not preserved.
96
+ - `effect: "outgoing"` and `"finalize"` are the only valid effects; `"display"` and `"both"` are rejected during validation.
97
+ - Streaming display is not transformed; raw text may be visible until the final message replacement happens.
98
+ - Message transforms support role filters, `maxMessages`, `maxChars`, `minDepth`, `maxDepth`, and `trimStrings`. `$0` is supported as a full-match alias for `$&` in replacements.
99
+ - Compiled-stage transforms support `targets: ["system"]`, `["messages"]`, or both.
100
+ - Supported regex flags are `g`, `i`, `m`, `s`, and `u`, with duplicate/unsupported flags rejected during validation.
101
+ - Runtime diagnostics report regex match counts and changed text segment counts.
102
+
103
+ ## Runtime Slots
104
+
105
+ - `chat-history`
106
+ - `tools`
107
+ - `tool-guidelines`
108
+ - `skills`
109
+ - `project-context`
110
+ - `append-system-prompt`
111
+ - `date`
112
+ - `cwd`
113
+ - `date-cwd`
114
+ - `active-model`
115
+ - `pi-docs`
116
+ - `date` and `date-cwd` slots can include `Current time: HH:MM:SS` with `includeTime: true`.
117
+ - Runtime slots are registered through the same `registerSlot` definition interface used by trusted custom slots.
118
+ - Trusted `~/.pi/forge/extensions` / `.pi/forge/extensions` modules and reusable Pi packages can register additional runtime slots through `registerSlot`, with declarative option schemas and shared render helpers.
119
+
120
+ ## Tool and Skill Policy
121
+
122
+ - Stack-level `tools.allow` / `tools.deny` policy.
123
+ - Stack-level `skills.allow` / `skills.deny` policy.
124
+ - Policy entries support exact names and `*` wildcards.
125
+ - Each resource uses either `allow` or `deny`; non-empty mixed lists are validation errors.
126
+ - Tool policy is enforced with `pi.setActiveTools()` and restored when prompt stacks are disabled or switched to an unrestricted stack.
127
+ - Tool policy preserves later extension tool additions in the restorable baseline while keeping them filtered from an active restrictive stack.
128
+ - A `tool_call` guard blocks tools outside the active stack policy even if another extension later changes Pi's active tool list.
129
+ - Rendered `tools` slots, template paths such as `{{ runtime.selectedToolsText }}`, and `tool-guidelines` respect stack tool policy.
130
+ - Rendered `skills` slots respect stack skill policy and continue to hide skills marked `disableModelInvocation`.
131
+ - Skill policy controls model-visible skill listings rendered by pi-forge; it does not disable explicit skill invocation and is not a security boundary.
132
+ - Validation warns when skill policy is used with `append` or `prepend` mode because Pi's base prompt may already include unfiltered skills.
133
+
134
+ ## Macros (forge-v1)
135
+
136
+ - Prompt text is compiled with the closed `forge-v1` template engine (parse → analyze → render).
137
+ - Runtime facts resolve through `{{ runtime.* }}` (cwd, date, time, lastUserMessage, selectedToolsText, activeModel, tool/slot booleans).
138
+ - Static values resolve through `{{ parameters.* }}`; schema v2 stores them in `parameters` while v1 stacks read legacy `variables`.
139
+ - Custom macros resolve through `{{ extensions.<name> }}` and are registered via the pure `registerMacro` extension port with declared dependencies and bounded output.
140
+ - Filters: `trim`, `upper`, `lower`, `json`, `xml`, composed with `|` pipelines.
141
+ - Conditionals: `{% if path %}...{% else %}...{% endif %}` with `==` / `!=` string comparisons over template paths.
142
+ - Undefined paths, unknown filters, parse errors, cycles, and output-limit breaches are compile errors; a failing block is omitted rather than re-injected.
143
+ - Legacy v1 stacks keep a bare-name compatibility fallback (`{{name}}`, `{{lastUserMessage}}`, `{{date}}`, ...) that maps to the corresponding parameter/runtime path.
144
+ - `getRegisteredMacros()` and `getRegisteredSlots()` expose active definitions for inspection.
145
+
146
+ ## Parameters
147
+
148
+ - Schema v2 stacks store immutable JSON-compatible values in top-level `parameters`.
149
+ - Schema v1 / unversioned stacks read the legacy string-only `variables` field and support bare `{{name}}` fallback.
150
+ - Parameters resolve through `{{ parameters.<name> }}` and are available to trusted custom macros/slots through the frozen environment.
151
+ - Mutable turn/session stores, variable mutation macros, session variable entries, and the `variables` slot are removed in 0.5.0.
152
+
153
+ ## Commands
154
+
155
+ - `/profile list`
156
+ - `/profile use <id>`
157
+ - `/profile save <id> [--overwrite]`
158
+ - `/profile status`
159
+ - `/profile preview <id>`
160
+ - `/profile validate [id]`
161
+ - `/profile reload`
162
+ - `/profile forget`
163
+ - `/forge-agent backends` (optional `@zihanw/pi-forge-subagents` package)
164
+ - `/forge-agent plan <profile> <task>` (optional package)
165
+ - `/forge-agent run <profile> <task>` (optional package)
166
+ - `/preset list`
167
+ - `/preset status`
168
+ - `/preset use <id|none>`
169
+ - `/preset preview [id]`
170
+ - `/preset validate [id]`
171
+ - `/preset diagnostics`
172
+ - `/preset reload`
173
+ - `/preset ui [stop|restart]`
174
+ - `/preset migrate-stacks [--dry-run] [--overwrite] [--delete-legacy]`
175
+ - `/capability add <text>`
176
+ - `/capability list`
177
+ - `/capability bindings`
178
+ - `/capability enable <[scope:]id>`
179
+ - `/capability enable-bound <id>`
180
+ - `/capability disable <activation-or-capability-id>`
181
+ - `/capability status`
182
+ - `/capability reset`
183
+ - `/capability help`
184
+ - `/intercept`
185
+ - `/payload next [save=<path>]`
186
+
187
+ ## Debugging and Tests
188
+
189
+ - `/intercept` displays the next provider payload with redaction/truncation for secrets and large data.
190
+ - `/payload next save=<path>` displays and saves the next redacted/truncated provider payload with char/token-ish size estimates.
191
+ - Payload redaction preserves known token limits, accounting counters, budgets, and tokenizer names while retaining credential-shaped token redaction.
192
+ - The web editor can arm, poll, clear, and inspect the next redacted provider payload in a full-screen collapsible JSON inspector.
193
+ - Runtime compile diagnostics are visible through a footer status and `/preset diagnostics`.
194
+ - `/preset ui` starts a token-protected localhost web editor for stack management.
195
+ - Node built-in tests cover agent-profile resolution/application/provenance, compiler, loader, regex, and the command/event harness.
196
+ - Tests cover regex validation, history-stage transforms, compiled-stage transforms, finalize transforms, replacement syntax, trim strings, depth limits, role/message/char limits, and preservation of non-text message parts.
197
+ - Tests cover subagent host resolution, custom dependency detection, effect-aware tool negotiation, golden canonical fingerprint vectors, and malformed host-port wire values. Execution-contract matrices (access/required-limit/terminal-status, context budgeting, protected media tasks) moved to the optional package's contract tests.
198
+ - A real headless-Chrome smoke test covers editor load, dirty state, metadata editing, policy and regex editing, validation, save, disk persistence, export, import, and browser-console errors.
199
+ - TypeScript strict typecheck passes.
200
+ - Package dry-run verifies published tarball contents.
201
+
202
+ ## Web Stack Editor
203
+
204
+ - `/preset ui`, `/preset ui restart`, and `/preset ui stop`.
205
+ - Local editor server bound to an available `127.0.0.1` port by default with a random URL token.
206
+ - Preferred editor port can be configured through `.pi/forge/config.json` using `webEditor.port`; if it is unavailable, pi-forge falls back to an available port.
207
+ - Existing same-project editor servers are reclaimed after extension reinitialization from session navigation/new-session flows, so `/preset ui` reuses the current URL instead of opening a second port.
208
+ - Resource inventory and preview remain usable when a reclaimed editor host is refreshed from lifecycle contexts that do not expose command-only prompt APIs.
209
+ - Stack list with active/error/warning indicators.
210
+ - Collapsible prompt-stack sidebar.
211
+ - Preset properties from the resource header, with peer Stack, Regex, Policy, Bindings and Advanced editing tabs; the separate Preview/Draft diff/Run diff dock stays alongside the editor.
212
+ - Light/dark theme toggle, button icons, and tooltips for common actions.
213
+ - English/中文 interface switch (`webEditor.locale`: `"en"`, `"zh-CN"`, or `"auto"` following the browser language); contributed settings tabs remain provider-authored and are not translated.
214
+ - Unsaved-change badge in the top bar.
215
+ - Create a new prompt stack from the browser, including when no stack files exist yet; new stacks start from the default Pi prompt mirror layout.
216
+ - View immutable stack ID and edit name, mode, `autoActivate`, description, and existing stack file content; use Fork to create a new ID.
217
+ - Edit stack `context` options from a structured dialog.
218
+ - Edit stack static `variables` from a structured table.
219
+ - Edit stack `regex.rules`, including order, stage, effect, targets, roles, limits, depth, trim strings, pattern, flags, replacement, and runtime warnings.
220
+ - Policy editor lists registered tools and loaded skills, hides exact selected names from the available list, and supports removable selected-pattern chips plus filter/autocomplete input.
221
+ - Reorder items by drag-and-drop.
222
+ - Add block and slot stack items directly.
223
+ - Delete stack items.
224
+ - Toggle item enabled state from the item list.
225
+ - Inline item validation badges when diagnostics point at a specific item.
226
+ - Edit block content in a full-height text editor area.
227
+ - Edit slot kind, role, slot type, and common slot options through form controls.
228
+ - Fall back to raw JSON editing for advanced slot options.
229
+ - View, copy, and apply raw stack JSON as a recovery path for advanced stack-level fields.
230
+ - Validate and inspect edited stack JSON before saving.
231
+ - Full-screen structured preview inspector with collapsible system/message sections, char/token estimates, and copy controls.
232
+ - Arm and inspect the next provider payload from the web editor; captures triggered by `/payload next` are also available to the browser while the editor is open.
233
+ - Provider payload inspector shows top-level JSON sections, redacted full text, char/token estimates, and copy controls.
234
+ - Save existing stack JSON and immediately reload pi-forge stack data.
235
+ - Save rejects attempts to change an existing stack ID before writing or changing active selection.
236
+ - Keyboard shortcuts for new stack, save, validate, preview, and closing dialogs/inspectors.
237
+ - Import native pi-forge stack JSON into `.pi/forge/prompt-stacks`.
238
+ - Export the current edited stack JSON from the browser, with clipboard fallback when download is unavailable.
239
+ - Fork the current stack into a new stack file, with optional activation.
240
+ - Delete stack files, disabling prompt-stack replacement if the deleted stack was active.
241
+ - Built-in Web writes cover Presets, Profiles, Capabilities, and trusted Forge configuration, with trust and path guardrails for save/import/fork/delete operations.
242
+ - Top-level navigation between prompt stacks and project agent profiles; stack drafts, selection, and active state survive surface switches.
243
+ - Profile list shows ID, name, model/thinking/stack targets, validation state, and `autoActivate` and last-applied badges.
244
+ - Profile create, edit, validate, save, one-shot apply, and delete reuse the shared resolver, transactional application service, and guarded repository; save rejects a second auto-activation profile and on-disk conflicts.
245
+ - Profile form populates provider/model choices from the model registry and stack choices from the shared stack repository, and shows resolution diagnostics for missing models, authentication, unsupported thinking levels, invalid stacks, and unmatched tool policy.
246
+ - A runtime/provenance card distinguishes current runtime, last-applied provenance, source-definition state, and per-field runtime drift after external model, thinking-level, or stack changes.
247
+ - The main web editor no longer ships a delegation card; delegation configuration is owned by the optional `@zihanw/pi-forge-subagents` package through `.pi/forge/subagents.json`.
248
+ - Smoke tests cover editor server token checks, bundled page/script markers, save, payload arm/capture/clear, create/fork, native JSON import, collision handling, delete, and stop behavior.
249
+
250
+ ## Capabilities and System Updates
251
+
252
+ - Upstream host requirement: Minimum supported Pi version is 0.87.0 (published 0.5.7 declared `>=0.87.0 <0.88.0`; 0.5.13 supports `>=0.87.0 <0.88.0 || 0.99.0 || 0.99.1 || 0.99.2 || >=1.0.0 <1.7.0`; dev SDK updated to 1.6.0 with `typebox@1.3.27`; no dual 0.86 runtime support claim). See [Pi 1.0 compatibility](../guides/pi-1-compatibility.md).
253
+ - File-backed capability definitions stored in `.pi/forge/capabilities/<id>.json` (project scope) and `~/.pi/forge/capabilities/<id>.json` (global scope) with schema `schemaVersion: 1`, `type: "pi-forge.capability"`.
254
+ - Literal text content (up to 100,000 characters) without macro, template, or script evaluation.
255
+ - Tool modification patches supporting `add` and `remove` arrays (tool IDs ≤ 128 characters, no whitespace/controls/wildcards, up to 256 tools per array). Capabilities support `add` and `remove` ONLY; candidate `only`/allowlist is not implemented.
256
+ - Fail-closed project-over-global shadowing for bare IDs; invalid local definitions fail closed with diagnostics and never fall back to global definitions.
257
+ - Scoped selectors (`project:<id>` and `global:<id>`) for targeting exact definitions.
258
+ - Local execution with zero inference cost: `/capability` commands and Web activity panel actions update internal session state and tool policy without invoking model inference or consuming API tokens.
259
+ - Unified `context_with_system` lifecycle: whole compiler, base prompt replacement, and capability projection pipeline moved to `context_with_system` without an internal two-phase split.
260
+ - Canonical session projection via `buildSessionProjection`: runtime, preview, and anchor locator helpers reflect turn-level `context_edit` omissions, replacements, and `sourceEntry` tracking without mutating raw session JSONL history on disk.
261
+ - Leading System prompt preservation: SDK incoming leading System message always remains first; Forge prefix plain metadata delivery anchors are inserted immediately after it.
262
+ - Settlement lifecycle and continuations: `agent_end` acts as an anchor commit boundary after tool batches or turns; compile cycle and busy fence reset only on `agent_settled` so `agent_before_settle` continuations preserve compiled Preset inputs.
263
+ - Immediate executable tool policy synchronization (`setActiveTools`) paired with next-model-request prompt text and section declaration delivery. Running tool batches are not killed mid-flight.
264
+ - Top-level Preset policy precedence: capability additions cannot enable tools denied by the active Preset (`tools.deny`); tool removals win globally across all active capabilities.
265
+ - Tool baseline recovery: restores session tools to a pristine baseline upon capability disable, adopting a conservative baseline when a session has no recorded baseline.
266
+ - Delivery via plain `custom` session entries carrying cursor-only metadata (`pi-forge-capability-delivery` with `{ schemaVersion: 1, throughEventId }`), replacing transcript `sendMessage` steering and `custom_message` carriers.
267
+ - Pre-compilation ordinal materialization into ephemeral in-memory markers at exact session positions matching canonical projection order.
268
+ - Request-only projection to native `SystemMessage.sections` (`forge-capability-<id>`) when supported by the provider, or fallback attributed user timeline updates (`[pi-forge capability update]`).
269
+ - Compaction input characterization: metadata delivery anchors and request-only rule text do not enter summarizer inputs while dialogue history is preserved.
270
+ - Breaking pre-release rename: no legacy aliases or readers are provided for the former instruction-mode schema, directories, or continuing capability state. Convert development configuration and start a new session; old JSONL and summaries are not rewritten.
271
+ - Provider-managed prompt cache warning: prompt caching and tool transport are downstream provider-managed; no guarantee of zero KV cache invalidation or exact cache hits.
272
+
273
+ ## Preset Capability Bindings
274
+
275
+ - Declarative `capabilities` binding list in the Preset schema.
276
+ - Qualified capability references (`project:<id>`, `global:<id>`), unique binding IDs (≤ 128 characters), and opt-in `modelCallable: boolean` (defaults to `false`).
277
+ - Finite overrides: either content replacement (`content`) or paragraph append (`appendContent` with two newlines), and independent whole-array replacement for `tools.add` and/or `tools.remove`.
278
+ - Source-effective preview via the shared server resolver (`resolveCapabilityBindings`).
279
+ - Stale-save guard using `sourceRevision` checking against raw file bytes, rejecting concurrent or external edits (409 Conflict) whenever bindings are present or modified.
280
+ - Same-Preset reload preserves immutable active snapshots; switching Presets retires old bound activations while retaining manual/unbound rules.
281
+ - Revocation behavior: disabling `modelCallable` does not retroactively erase active snapshots; human CLI or Web deactivation is the recovery path.
282
+
283
+ ## Agent Capability Controls
284
+
285
+ - Model-callable tool `forge_capability` registered when an active Preset includes bound capabilities.
286
+ - Fixed parameter schema: `{ action: "list" | "status" | "enable" | "disable", id?: string }` (ID ≤ 128 characters).
287
+ - Re-verifies project trust, active Preset existence, binding existence, `modelCallable: true`, and current tool policy on every call.
288
+ - Strict actor ownership: agent can only activate authorized bindings; agent `disable` can only stop its own agent-owned activations; agent cannot stop human rules, reset capabilities, add arbitrary prompt text, or remove `forge_capability`.
289
+ - Repeated use is idempotent and does not take over ownership from user to agent.
290
+ - Fences against disposed runtimes, restoring sessions, and cross-session re-entry.
291
+
292
+ ## Web Editor Capabilities and Session Activity
293
+
294
+ - Top-level **Capabilities** surface for project and global capability CRUD with validation diagnostics.
295
+ - Capability writes and deletions require `sourceRevision` checking against raw file bytes; 409 Conflict on stale views preserves user drafts.
296
+ - Capability saves never activate definitions into the active session.
297
+ - Dedicated peer **Capability bindings** tab in the Preset editor with binding configuration, `modelCallable` toggle, finite overrides, and live source vs effective preview.
298
+ - Global **Session capabilities** summary opens the non-modal **Current session** workspace, pairing controls with the active saved Preset/session projection and showing active capabilities, actor attribution (`user`/`agent`), collapsible frozen snapshots, tool deltas, effective tools, delivery status (`none`/`pending`/`prepared`), and presentation mode.
299
+ - Human activation picker with available capabilities (`GET /api/capability-state/available`) categorized into Library capabilities (unbound) and Current preset (bound).
300
+ - Explicit pre-activation preview displaying label, ID, badge, fingerprint, tool diff, problem banner, and full literal content.
301
+ - Bodyguard activation (`POST /api/capability-state/enable`) requiring session guard (`sessionId`, `leafId`, `revision`) and source fingerprint validation, rejecting stale or modified sources (409 Conflict) without automatic retry or inference.
302
+ - Read-only resource discovery and Preview never mutate tool policies, commit session events, or mark pending capabilities as prepared.
303
+ - Quiet state polling (every 3 seconds while visible, and on focus) with zero inference; catalog discovery occurs on workspace entry, explicit refresh and mutation follow-up, not each status poll.
304
+
305
+ The [Read-first Worker example](capabilities.md#read-first-worker) demonstrates default reading tools plus a model-authorized `bash`/`edit` capability. It is a tool-selection pattern, not a sandbox.
@@ -0,0 +1,103 @@
1
+ # Forge-v1 templates and runtime slots
2
+
3
+ [Documentation](../README.md)
4
+
5
+ Prompt text is compiled with the `forge-v1` engine: one closed grammar with no
6
+ includes, loops, function calls, or arbitrary expressions. Preview, runtime,
7
+ and subagent preparation use the same engine entry.
8
+
9
+ ## Template interpolation
10
+
11
+ | Syntax | Value |
12
+ |---|---|
13
+ | `{{ runtime.cwd }}` | Current working directory |
14
+ | `{{ runtime.date }}` | Current date as `YYYY-MM-DD` |
15
+ | `{{ runtime.time }}` | Current time as `HH:MM:SS` |
16
+ | `{{ runtime.lastUserMessage }}` | Latest user message |
17
+ | `{{ runtime.selectedToolsText }}` | Comma-separated effective tool names |
18
+ | `{{ runtime.activeModel }}` | Current `provider/model` |
19
+ | `{{ parameters.<name> }}` | Static stack parameter |
20
+ | `{{ extensions.<name> }}` | Registered custom macro value |
21
+
22
+ Legacy v1 stacks keep a compatibility fallback: bare `{{name}}` resolves to a
23
+ static parameter, `{{lastUserMessage}}`/`{{date}}`/`{{time}}`/`{{cwd}}` resolve
24
+ to the matching `runtime.*` value, and registered custom macros resolve by
25
+ name. New v2 stacks use the explicit `parameters.*` / `runtime.*` paths.
26
+
27
+ ## Filters
28
+
29
+ Nested pipelines are supported; filters are pure and versioned.
30
+
31
+ | Filter | Result |
32
+ |---|---|
33
+ | `{{ value \| trim }}` | Trim surrounding whitespace |
34
+ | `{{ value \| upper }}` | Uppercase |
35
+ | `{{ value \| lower }}` | Lowercase |
36
+ | `{{ value \| json }}` | JSON string literal |
37
+ | `{{ value \| xml }}` | XML-escaped |
38
+
39
+ ## Conditionals
40
+
41
+ ```text
42
+ {% if runtime.tool.read %}read is available{% else %}read is unavailable{% endif %}
43
+ {% if parameters.mode == "image-reader" %}image reader{% endif %}
44
+ {% if runtime.tool.bash != null %}bash visible{% endif %}
45
+ ```
46
+
47
+ - `{% if path %}` selects the branch when the path exists and is truthy.
48
+ - `==` / `!=` compare against a quoted string, including empty strings.
49
+ - Nested `{% if %}` blocks are supported.
50
+ - An undefined output path is a strict compile error (no raw fallback); the
51
+ legacy `defaults.unresolvedMacroPolicy` is ignored.
52
+ - `runtime.tool.<name>` and `runtime.slot.<name>` booleans power tool/slot
53
+ conditionals without function calls.
54
+
55
+ When a block fails to parse, analyze, or render, pi-forge emits an error
56
+ diagnostic and omits that block rather than re-injecting raw template text.
57
+
58
+ ## Built-in slots
59
+
60
+ | Slot | Rendered content |
61
+ |---|---|
62
+ | `chat-history` | Current conversation, with filtering and limits |
63
+ | `tools` | Effective tools and descriptions/snippets |
64
+ | `tool-guidelines` | Tool-use guidance |
65
+ | `skills` | Model-visible loaded Pi skills |
66
+ | `project-context` | Trusted project instructions/context |
67
+ | `append-system-prompt` | Pi's appended system prompt text |
68
+ | `date` | Current date, optionally time |
69
+ | `cwd` | Working directory |
70
+ | `date-cwd` | Date and working directory, optionally time |
71
+ | `active-model` | Selected provider/model |
72
+ | `pi-docs` | Pi documentation guidance |
73
+
74
+ Structured slots (`tools`, `tool-guidelines`, `skills`, `project-context`)
75
+ default to XML-style wrappers and support `"format": "plain"`.
76
+
77
+ ## Trusted custom definitions
78
+
79
+ Trusted global/project modules register macros (addressed as
80
+ `{{ extensions.<name> }}`) and slots through the pure extension port:
81
+
82
+ ```ts
83
+ api.registerMacro({
84
+ name: "ticketId",
85
+ description: "Current ticket id.",
86
+ dependencies: ["parameters.ticket.id"],
87
+ render: ({ env, helpers }) => String(env.parameters["ticket.id"]),
88
+ });
89
+
90
+ api.registerSlot({
91
+ name: "ticket-context",
92
+ description: "Render ticket context.",
93
+ dependencies: ["parameters.ticket.id"],
94
+ options: { heading: { type: "string", default: "Ticket context" } },
95
+ render: ({ item, options, env, helpers }) => "...",
96
+ });
97
+ ```
98
+
99
+ Custom slots receive the same pure `{ item, options, env, helpers }` context and
100
+ declared-dependency resolution as macros, and their output is held to the same
101
+ 16,384-character extension limit.
102
+
103
+ See [custom macros and slots](../guides/custom-macros-and-slots.md).
@@ -0,0 +1,67 @@
1
+ # Provider support for mid-conversation updates (Pi 0.87.1 snapshot)
2
+
3
+ [Documentation](../README.md) · [中文](../zh-CN/reference/provider-support.md)
4
+
5
+ This page records how Pi 0.87.1 sends mid-conversation system updates and tool changes for each API, and which models in the Pi model catalog were flagged for them. It explains why a [capability](capabilities.md#delivery-models-native-vs-fallback) may arrive as a native system update on one model and as a labeled user message on another.
6
+
7
+ > **Snapshot status:** Pi 0.87.1 (`@earendil-works/pi-ai` 0.87.1), local model catalog last checked 2026-09-21 to 2026-09-25, recorded 2026-09-26. Pi fetches the model catalog remotely and caches it in `~/.pi/agent/models-store.json`, so flags can change without a Pi upgrade. Run `/capability status` to see which path the current model uses before relying on this table.
8
+
9
+ ## How the choice is made
10
+
11
+ Pi and Forge both read the current model's `compat` flags on every request:
12
+
13
+ | Flag | Effect when `true` | Effect when absent or `false` |
14
+ |---|---|---|
15
+ | `supportsMidConvoSystemMessages` | Later system messages stay at their position in the conversation. Forge sends instruction text as native system sections. | Pi folds all system messages into the leading system prompt and sends the current tool list at request level. Forge sends instruction text as a labeled `[pi-forge capability update]` user message. |
16
+ | `supportsMidConvoToolChanges` (Anthropic Messages) | Tool additions and removals are sent as `tool_addition` / `tool_removal` blocks inside the system update. | The whole current tool list is sent at request level. |
17
+ | `supportsAdditionalTools` / `supportsToolSearch` (OpenAI Responses, Codex, Azure) | New tools are loaded in place (`additional_tools`, or a client-side tool search call and output). | The whole current tool list is sent at request level. |
18
+ | `supportsMidConvoToolAdditions` (OpenAI Completions) | New tools are loaded in place by a system message that carries `tools`. | The whole current tool list is sent at request level. |
19
+
20
+ Tool flags only apply when `supportsMidConvoSystemMessages` is also enabled. The provider name, the authentication method, and auth extensions do not decide the path. The same model can be flagged differently under different providers.
21
+
22
+ ## Behavior by API
23
+
24
+ | API | Instruction text | Tool changes |
25
+ |---|---|---|
26
+ | `anthropic-messages` | With the flag: a `role: "system"` message. Pi holds it until just before the next assistant message, so it never separates a `tool_use` from its `tool_result`; an update recorded before a user message is sent after it. | With `supportsMidConvoToolChanges` and at least one initial tool. **Pi 1.0.1+:** the request-level list stays fixed (initial tools plus a reserved deferred placeholder); later tools are defined by value inside `tool_addition` blocks (a same-name redefinition replaces the earlier definition) and withdrawn by `tool_removal`. **Pi 1.0.0 and earlier:** later tools are appended to the request-level list with `defer_loading`, the list only grows, and a same-name redefinition falls back to the full list. Otherwise (including a session that starts with no active tools, such as `tools.initial: []`): the current list at request level. |
27
+ | `openai-responses`, `openai-codex-responses`, `azure-openai-responses` | With the flag: a `developer` message (reasoning models that accept the developer role) or a `system` message, at its position. | Additions load in place while retained history contains only additions. Any removal or same-name redeclaration anywhere in retained history switches that and subsequent requests to the full current list at request level while that history remains. |
28
+ | `openai-completions` | With the flag: a `developer` or `system` message at its position. | Additions load in place with `supportsMidConvoToolAdditions`; removals and redeclarations switch to the full current list. |
29
+ | `mistral-conversations` | With the flag: a `system` message at its position. | Always the full current list at request level. |
30
+ | Google Generative AI / Vertex | Always folded into `systemInstruction`; no mid-conversation path. | Full current list. |
31
+ | Bedrock Converse | Always folded into the request-level system prompt. | Full current tool configuration. |
32
+ | `pi-messages` | Passes the context to its backend unchanged; behavior depends on that backend. | Backend-defined. |
33
+
34
+ Updates are rendered as `Updated system prompt section "<name>": ...` or `Removed system prompt section "<name>".`. [Tool-only capabilities](capabilities.md#delivery-models-native-vs-fallback) send no text update.
35
+
36
+ ## Flagged models in the 2026-09 catalog
37
+
38
+ Only models with `supportsMidConvoSystemMessages: true` are listed.
39
+
40
+ | Provider | Models | Tool changes |
41
+ |---|---|---|
42
+ | `anthropic` | `claude-fable-5`, `claude-fable-5-1`, `claude-opus-4-8`, `claude-opus-5`, `claude-opus-5-5` | Native additions and removals |
43
+ | `openai-codex` | `gpt-5.6-luna`, `gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-6-astra`, `gpt-6-luna`, `gpt-6-sol` | Additions in place (`additional_tools`) |
44
+ | `openai-codex` | `gpt-5.5` | Additions in place via tool search |
45
+ | `opencode` | `gpt-5.4`, `gpt-5.4-mini`, `gpt-5.4-pro`, `gpt-5.5`, `gpt-5.6-luna`, `gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-6-astra` | Additions in place (`additional_tools`) |
46
+ | `opencode` | `claude-fable-5`, `claude-fable-5-1`, `claude-opus-4-8`, `claude-opus-5` | Text only; any tool change sends the full list |
47
+ | `opencode`, `opencode-go` | `kimi-k3` | Additions in place |
48
+ | `opencode-go` | `gpt-5.6-luna` | Additions in place (`additional_tools`) |
49
+ | `deepseek` | `deepseek-v4-pro` | Text only; any tool change sends the full list |
50
+
51
+ Not flagged in the same catalog, among others: `anthropic/claude-sonnet-5`, `claude-sonnet-4-5`, `claude-sonnet-4-6`, `claude-opus-4-5` to `claude-opus-4-7`, `claude-haiku-4-5`; `openai-codex/gpt-5.3-codex-spark`; `deepseek/deepseek-flash`; every `google` and `kimi-coding` model.
52
+
53
+ ## Observed cache behavior
54
+
55
+ These are single-session observations, not guarantees. Cache reuse is decided by the provider.
56
+
57
+ - **`anthropic/claude-opus-5-5`, native path (OAuth through an auth extension):** adding, removing, and re-adding tools, including a capability the model enabled itself, kept the full cached prefix on all 18 follow-up requests. Requests with lower hit rates were writing new content, such as new tool definitions or large file reads, not losing earlier cache.
58
+ - **`anthropic/claude-sonnet-5`, fallback path:** the request after a tool change read nothing from cache, because Pi rewrote the leading system prompt and tool list. The model also questioned the labeled user update before using the new tool.
59
+ - **OpenAI Responses / Codex:** in earlier tests, a removal switched to the full tool list and cache reads dropped to zero; requests with only additions kept the prefix.
60
+
61
+ To preserve cacheable prefixes where possible, prefer a flagged model with native tool changes; cache hits are not guaranteed. On OpenAI Responses/Completions transports, any removal, including disabling a Capability that removes tools, makes later session requests send the full current tool list because removal detection scans the transcript. Re-enabling tools does not restore incremental delivery while that history remains. Anthropic's native `tool_removal` path is unaffected by this fallback.
62
+
63
+ ## Checking your own setup
64
+
65
+ 1. Run `/capability status`. It reports `native system sections` or `attributed user updates` for the current model.
66
+ 2. To see the flags directly, look up the model under its provider in `~/.pi/agent/models-store.json` and read its `compat` object.
67
+ 3. Use `/forge payload next` to capture the actual next request if you need to confirm the wire format.
@@ -0,0 +1,133 @@
1
+ # Public API policy
2
+
3
+ [Documentation](../README.md)
4
+
5
+ pi-forge is pre-1.0. This document defines the intentional integration surfaces of the 0.5 development line.
6
+
7
+ ## The five intentional entry points
8
+
9
+ `check-package` enforces this allowlist; nothing else is importable from the package.
10
+
11
+ ### 1. Package root: extension factory
12
+
13
+ ```ts
14
+ import piForge from "@zihanw/pi-forge";
15
+ ```
16
+
17
+ The default export is the Pi extension entry point declared by `pi.extensions`. Most users install the package and never import it directly.
18
+
19
+ ### 2. Package root: trusted extension API
20
+
21
+ ```ts
22
+ import { registerMacro, registerSlot } from "@zihanw/pi-forge";
23
+ import type {
24
+ ForgeExtensionApi,
25
+ ForgeExtensionRegister,
26
+ PromptEnvironment,
27
+ PromptEnvironmentValue,
28
+ PromptExtensionArgumentDefinition,
29
+ PromptExtensionOptionDefinition,
30
+ PromptExtensionOptionsSchema,
31
+ PromptExtensionOptionType,
32
+ PromptMacroDefinition,
33
+ PromptMacroRenderContext,
34
+ PromptMacroRenderer,
35
+ PromptRegistryEntry,
36
+ PromptRenderHelpers,
37
+ PromptSlotDefinition,
38
+ PromptSlotRenderContext,
39
+ PromptSlotRenderer,
40
+ } from "@zihanw/pi-forge";
41
+ ```
42
+
43
+ Supported for trusted reusable and project-local extensions. The contract (pure renderers, declared dependencies, immutable `PromptEnvironment`, bounded output) is specified in the [0.5.0 architecture plan](../design/architecture-0.5.md#extension-port-contract-050) and the [custom macros and slots guide](../guides/custom-macros-and-slots.md).
44
+
45
+ ### 3. `@zihanw/pi-forge/subagent`: versioned host port
46
+
47
+ ```ts
48
+ import {
49
+ ForgeHost, ForgeHostClient, ForgeHostPortError,
50
+ FORGE_HOST_CHANNEL, FORGE_HOST_PORT_VERSION, FORGE_HOST_PORT_OPERATIONS,
51
+ validateListProfilesRequest, validateListProfilesResponse,
52
+ validateResolveProfileRequest, validateResolveProfileResponse,
53
+ validatePrepareRequest, validatePrepareResponse,
54
+ canonicalSubagentJson, subagentFingerprint,
55
+ subagentSourceProfileFingerprint, subagentPromptStackFingerprint,
56
+ } from "@zihanw/pi-forge/subagent";
57
+ ```
58
+
59
+ The experimental host port over the Pi event bus: discovery, profile listing/snapshot, and host-owned prompt preparation with mandatory lifecycle semantics (correlation IDs, payload validation, bounded timeouts, host generation, duplicate-host failure, disposal/`unavailable`, listener cleanup). The wire DTOs and validators are self-contained Forge data contracts; the main package has no dependency on `@zihanw/pi-subagent-runtime`. The canonical `sha256:v1` fingerprint helpers are Forge-owned and byte-compatible with the runtime's canonical JSON.
60
+
61
+ The optional `@zihanw/pi-forge-subagents` package consumes this port and owns subagent execution and configuration.
62
+
63
+ #### Experimental nested-usage contract exports
64
+
65
+ The entry point also exports helper constants, validators, and types for tools and subagents reporting inner model usage under `toolResult.details[FORGE_NESTED_USAGE_KEY]`:
66
+
67
+ ```ts
68
+ import {
69
+ FORGE_NESTED_USAGE_KEY,
70
+ parseForgeNestedUsage,
71
+ type ForgeNestedUsage,
72
+ } from "@zihanw/pi-forge/subagent";
73
+ ```
74
+
75
+ - `FORGE_NESTED_USAGE_KEY`: constant string key (`"forgeNestedUsage"`).
76
+ - `parseForgeNestedUsage(value: unknown): ForgeNestedUsage | undefined`: strict schema parser that returns typed usage or `undefined` for malformed objects.
77
+ - `type ForgeNestedUsage`: typed schemaVersion 1 contract (`schemaVersion`, `requests`, `input`, `output`, optional `cacheRead` and `cacheWrite`).
78
+
79
+ See the [session cache usage reference](session-cache.md) for full contract rules, ingestion boundaries, and hit-rate aggregation semantics.
80
+
81
+ ### 4. `@zihanw/pi-forge/ui-contribution`: versioned settings port
82
+
83
+ ```ts
84
+ import {
85
+ UiContributionProvider,
86
+ UiContributionClient,
87
+ UI_CONTRIBUTION_PORT_VERSION,
88
+ } from "@zihanw/pi-forge/ui-contribution";
89
+ ```
90
+
91
+ The experimental generic Settings integration surface. Optional packages contribute recursively validated, JSON-compatible schemas and values over the Pi event bus; pi-forge owns only the renderer and web proxy. Providers own validation and persistence, may resolve operations asynchronously, and receive an abort signal tied to provider generation so stale requests can stop before side effects. The full contract is documented in the [UI contribution port reference](ui-contribution-port.md).
92
+
93
+ ### 5. `@zihanw/pi-forge/command-contribution`: Forge child-command contribution
94
+
95
+ ```ts
96
+ import {
97
+ FORGE_COMMAND_DISCOVERY_EVENT,
98
+ contributeForgeCommand,
99
+ } from "@zihanw/pi-forge/command-contribution";
100
+ import type {
101
+ ForgeCommandContribution,
102
+ ForgeCommandDiscovery,
103
+ ForgeCommandEvents,
104
+ } from "@zihanw/pi-forge/command-contribution";
105
+ ```
106
+
107
+ This is a local, synchronous discovery surface for contributing one child command below the main `/forge` root. A contribution supplies callback metadata (`name`, `description`, `handler`, and optional argument completions); `contributeForgeCommand` returns an explicit unsubscribe function. Discovery is an in-process callback exchange, not an RPC, authorization boundary, execution sandbox, singleton registry, or persistent format. The main package owns the sole `/forge` root. Reserved names are rejected and duplicate child contributors fail closed rather than being selected arbitrarily.
108
+
109
+ The optional subagent package can use this surface for `/forge subagent plan`, while its backend policy remains separate: `/forge-agent run` retains mandatory human approval and a selected backend may write; model-callable `forge_subagent` unattended authorization is a different path.
110
+
111
+ Forge 0.5.5 provides this main-package subpath. The optional package remains an independent unfinished release and must raise its Forge dependency floor to `^0.5.5` before consuming it as a paired release; this documentation does not claim optional-package publication or compatibility with an older main package.
112
+
113
+ ## Event bus contracts (no import entry point)
114
+
115
+ Optional cosmetic consumers integrate over the Pi event bus instead of importing the package:
116
+
117
+ - Active-state snapshot/change uses `@zihanw/pi-forge/active-state/v1` and `@zihanw/pi-forge/active-state/request/v1`. See the [active-state bus contract](active-state.md).
118
+
119
+ These channels carry only plain JSON scalars. They are not `@zihanw/pi-forge` import surfaces and consumers must not depend on package internals.
120
+
121
+ ## Compatibility policy
122
+
123
+ - **Stable** surfaces (root factory, macro/slot registration) preserve source compatibility within the documented release range unless a changelog entry announces a breaking release.
124
+ - **Experimental** surfaces (the `/subagent`, `/ui-contribution`, and `/command-contribution` ports) are typed and documented, but may change deliberately as integration experience exposes missing semantics. Forge 0.5.5 provides the command-contribution surface; optional consumers remain pending their independent version/floor bump and release.
125
+ - Everything not listed above is internal and may change without notice. In particular: no `src/*` subpath aliases exist, `./examples/*` is not an import surface (examples ship as browsable files), and removed 0.4 surfaces (the execution contract re-exports, loader/profile/catalog helpers) now live either nowhere or in `@zihanw/pi-forge-subagents`.
126
+
127
+ ## Removed in 0.5.0
128
+
129
+ - All `@zihanw/pi-forge/src/*` compatibility aliases and the `./examples/*` subpath export.
130
+ - Root re-exports of loader, agent-profile, profile-service, catalog, resource-identity, render-helper values, the `forge-v1` engine, and registry readers.
131
+ - Root and `/subagent` re-exports of the 0.4 execution contract (`AgentRequest`, `createAgentExecutionPlan`, `validateAgentRequest`, `negotiateSubagentTools`, `resolveSubagentHostProfile`, `prepareSubagentHostPlan`, and friends). The execution contract now belongs to `@zihanw/pi-forge-subagents`.
132
+
133
+ See the [0.5 migration guide](../guides/migrating-to-0.5.md) for the complete breaking-change list.