@jadelclemens/pi-forge 0.0.0-stage → 0.6.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 (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,144 @@
1
+ import { cpus, freemem, loadavg, totalmem, uptime } from "node:os";
2
+
3
+ interface ForgeRegistrationApi {
4
+ registerMacro(definition: {
5
+ name: string;
6
+ source?: string;
7
+ description?: string;
8
+ dependencies?: string[];
9
+ render: (ctx: { env: Record<string, unknown>; helpers: unknown }) => string;
10
+ }): () => void;
11
+ registerSlot(definition: {
12
+ name: string;
13
+ source?: string;
14
+ description?: string;
15
+ dependencies?: string[];
16
+ options?: Record<string, unknown>;
17
+ render: (ctx: {
18
+ options: Record<string, unknown>;
19
+ helpers: {
20
+ escapeXml(value: string): string;
21
+ plainBullet(label: string, value: string): string;
22
+ };
23
+ }) => string;
24
+ }): () => void;
25
+ }
26
+
27
+ export interface SystemStatusSnapshot {
28
+ logicalCores: number;
29
+ cpuModel: string;
30
+ load1: number;
31
+ load5: number;
32
+ load15: number;
33
+ normalizedLoad1: number;
34
+ freeMemoryMb: number;
35
+ totalMemoryMb: number;
36
+ usedMemoryPercent: number;
37
+ uptimeSeconds: number;
38
+ }
39
+
40
+ export default function registerSystemStatus(
41
+ api: ForgeRegistrationApi,
42
+ sampleSystemStatus: () => SystemStatusSnapshot = readSystemStatus,
43
+ ): void {
44
+ api.registerMacro({
45
+ name: "cpuLoad",
46
+ source: "pi-forge-example-system-status",
47
+ description: "Machine CPU load sampled when the prompt is compiled.",
48
+ dependencies: [],
49
+ // Renderers run during prompt compilation. Read a fresh snapshot for each render.
50
+ render: () => formatCpuLoad(Object.freeze(sampleSystemStatus())),
51
+ });
52
+
53
+ api.registerSlot({
54
+ name: "machine-status",
55
+ source: "pi-forge-example-system-status",
56
+ description: "Machine CPU, memory, and uptime sampled when the prompt is compiled.",
57
+ dependencies: [],
58
+ options: {
59
+ format: { type: "enum", values: ["plain", "xml"], default: "plain" },
60
+ heading: { type: "string", default: "Machine status" },
61
+ includeMemory: { type: "boolean", default: true },
62
+ includeUptime: { type: "boolean", default: true },
63
+ },
64
+ render: (ctx) => {
65
+ // Do not capture this at registration time: sample when the slot is rendered.
66
+ const snapshot = Object.freeze(sampleSystemStatus());
67
+ const includeMemory = ctx.options.includeMemory !== false;
68
+ const includeUptime = ctx.options.includeUptime !== false;
69
+ const heading = typeof ctx.options.heading === "string" && ctx.options.heading.trim()
70
+ ? ctx.options.heading.trim()
71
+ : "Machine status";
72
+
73
+ if (ctx.options.format === "xml") {
74
+ const lines = [
75
+ "<machine_status>",
76
+ ` <cpu logical_cores=\"${snapshot.logicalCores}\" normalized_load_1m=\"${snapshot.normalizedLoad1.toFixed(3)}\" model=\"${ctx.helpers.escapeXml(snapshot.cpuModel)}\">${ctx.helpers.escapeXml(formatCpuLoad(snapshot))}</cpu>`,
77
+ ` <load_average one_minute=\"${snapshot.load1.toFixed(2)}\" five_minutes=\"${snapshot.load5.toFixed(2)}\" fifteen_minutes=\"${snapshot.load15.toFixed(2)}\" />`,
78
+ ];
79
+ if (includeMemory) {
80
+ lines.push(` <memory used_percent=\"${snapshot.usedMemoryPercent.toFixed(1)}\" free_mb=\"${snapshot.freeMemoryMb}\" total_mb=\"${snapshot.totalMemoryMb}\" />`);
81
+ }
82
+ if (includeUptime) {
83
+ lines.push(` <uptime>${ctx.helpers.escapeXml(formatDuration(snapshot.uptimeSeconds))}</uptime>`);
84
+ }
85
+ lines.push("</machine_status>");
86
+ return lines.join("\n");
87
+ }
88
+
89
+ const lines = [
90
+ `${heading}:`,
91
+ ctx.helpers.plainBullet("CPU", `${snapshot.logicalCores} logical cores, ${snapshot.cpuModel}`),
92
+ ctx.helpers.plainBullet("CPU load", formatCpuLoad(snapshot)),
93
+ ctx.helpers.plainBullet("Load average", `${snapshot.load1.toFixed(2)} / ${snapshot.load5.toFixed(2)} / ${snapshot.load15.toFixed(2)} (1m/5m/15m)`),
94
+ ];
95
+ if (includeMemory) {
96
+ lines.push(ctx.helpers.plainBullet("Memory", `${snapshot.usedMemoryPercent.toFixed(1)}% used (${snapshot.freeMemoryMb} MB free / ${snapshot.totalMemoryMb} MB total)`));
97
+ }
98
+ if (includeUptime) {
99
+ lines.push(ctx.helpers.plainBullet("Uptime", formatDuration(snapshot.uptimeSeconds)));
100
+ }
101
+ return lines.join("\n");
102
+ },
103
+ });
104
+ }
105
+
106
+ function readSystemStatus(): SystemStatusSnapshot {
107
+ const cores = cpus();
108
+ const logicalCores = Math.max(cores.length, 1);
109
+ const [load1 = 0, load5 = 0, load15 = 0] = loadavg();
110
+ const free = freemem();
111
+ const total = totalmem();
112
+ const freeMemoryMb = Math.round(free / 1024 / 1024);
113
+ const totalMemoryMb = Math.round(total / 1024 / 1024);
114
+ const usedMemoryPercent = total > 0 ? ((total - free) / total) * 100 : 0;
115
+
116
+ return {
117
+ logicalCores,
118
+ cpuModel: cores[0]?.model ?? "unknown",
119
+ load1,
120
+ load5,
121
+ load15,
122
+ normalizedLoad1: load1 / logicalCores,
123
+ freeMemoryMb,
124
+ totalMemoryMb,
125
+ usedMemoryPercent,
126
+ uptimeSeconds: uptime(),
127
+ };
128
+ }
129
+
130
+ function formatCpuLoad(snapshot: SystemStatusSnapshot): string {
131
+ const normalizedPercent = snapshot.normalizedLoad1 * 100;
132
+ return `${normalizedPercent.toFixed(1)}% normalized (${snapshot.load1.toFixed(2)} 1m load / ${snapshot.logicalCores} logical cores)`;
133
+ }
134
+
135
+ function formatDuration(seconds: number): string {
136
+ const days = Math.floor(seconds / 86_400);
137
+ const hours = Math.floor((seconds % 86_400) / 3_600);
138
+ const minutes = Math.floor((seconds % 3_600) / 60);
139
+ const parts: string[] = [];
140
+ if (days > 0) parts.push(`${days}d`);
141
+ if (hours > 0 || parts.length > 0) parts.push(`${hours}h`);
142
+ parts.push(`${minutes}m`);
143
+ return parts.join(" ");
144
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "type": "pi-forge.prompt-stack",
4
+ "id": "custom-system-status",
5
+ "name": "Custom System Status",
6
+ "description": "Example stack that uses a trusted custom macro and custom slot registered from .pi/forge/extensions/system-status.ts.",
7
+ "mode": "append",
8
+ "items": [
9
+ {
10
+ "kind": "block",
11
+ "id": "cpu-load-macro",
12
+ "name": "CPU Load Macro",
13
+ "enabled": true,
14
+ "role": "system",
15
+ "content": "Current rough CPU load: {{ extensions.cpuLoad }}"
16
+ },
17
+ {
18
+ "kind": "slot",
19
+ "id": "machine-status",
20
+ "name": "Machine Status Slot",
21
+ "enabled": true,
22
+ "role": "system",
23
+ "slot": "machine-status",
24
+ "options": {
25
+ "format": "plain",
26
+ "heading": "Runtime machine snapshot",
27
+ "includeMemory": true,
28
+ "includeUptime": true
29
+ }
30
+ },
31
+ {
32
+ "kind": "slot",
33
+ "id": "chat-history",
34
+ "name": "Chat History",
35
+ "enabled": true,
36
+ "slot": "chat-history"
37
+ }
38
+ ],
39
+ "parameters": {}
40
+ }
@@ -0,0 +1,125 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "type": "pi-forge.prompt-stack",
4
+ "id": "default",
5
+ "name": "Default Pi Prompt Mirror",
6
+ "description": "Recreates Pi's built-in prompt layout with pi-forge slots, exposing tools, guidelines, docs, append-system-prompt, project context, skills, date/cwd, and chat history as movable pieces.",
7
+ "autoActivate": true,
8
+ "mode": "replace",
9
+ "defaults": {
10
+ "syntheticMessagesVisible": false,
11
+ "unresolvedMacroPolicy": "warn"
12
+ },
13
+ "context": {
14
+ "allowDuplicateChatHistory": false
15
+ },
16
+ "tools": {
17
+ "allow": [
18
+ "*"
19
+ ]
20
+ },
21
+ "skills": {
22
+ "allow": [
23
+ "*"
24
+ ]
25
+ },
26
+ "items": [
27
+ {
28
+ "kind": "block",
29
+ "id": "main-role",
30
+ "name": "Pi Default Role",
31
+ "enabled": true,
32
+ "role": "system",
33
+ "source": {
34
+ "package": "@earendil-works/pi-coding-agent",
35
+ "file": "dist/core/system-prompt.js"
36
+ },
37
+ "content": "You are a coding assistant running inside pi, a coding agent harness. Help users inspect files, run commands, and modify code."
38
+ },
39
+ {
40
+ "kind": "slot",
41
+ "id": "tools",
42
+ "name": "Available Tools",
43
+ "enabled": true,
44
+ "role": "system",
45
+ "slot": "tools",
46
+ "options": {
47
+ "format": "plain",
48
+ "onlyWithSnippets": true
49
+ }
50
+ },
51
+ {
52
+ "kind": "block",
53
+ "id": "custom-tools-note",
54
+ "name": "Custom Tools Note",
55
+ "enabled": true,
56
+ "role": "system",
57
+ "content": "Additional tools may be available."
58
+ },
59
+ {
60
+ "kind": "slot",
61
+ "id": "tool-guidelines",
62
+ "name": "Guidelines",
63
+ "enabled": true,
64
+ "role": "system",
65
+ "slot": "tool-guidelines",
66
+ "options": {
67
+ "format": "plain",
68
+ "heading": "Guidelines:",
69
+ "includePiDefaultGuidelines": true,
70
+ "piStyle": true
71
+ }
72
+ },
73
+ {
74
+ "kind": "slot",
75
+ "id": "pi-docs",
76
+ "name": "Pi Documentation Guidance",
77
+ "enabled": true,
78
+ "role": "system",
79
+ "slot": "pi-docs"
80
+ },
81
+ {
82
+ "kind": "slot",
83
+ "id": "append-system-prompt",
84
+ "name": "User Append System Prompt",
85
+ "enabled": true,
86
+ "role": "system",
87
+ "slot": "append-system-prompt"
88
+ },
89
+ {
90
+ "kind": "slot",
91
+ "id": "project-context",
92
+ "name": "Project Context",
93
+ "enabled": true,
94
+ "role": "system",
95
+ "slot": "project-context"
96
+ },
97
+ {
98
+ "kind": "slot",
99
+ "id": "skills",
100
+ "name": "Available Skills",
101
+ "enabled": true,
102
+ "role": "system",
103
+ "slot": "skills",
104
+ "options": {
105
+ "requireReadTool": true
106
+ }
107
+ },
108
+ {
109
+ "kind": "slot",
110
+ "id": "date-cwd",
111
+ "name": "Date and Working Directory",
112
+ "enabled": true,
113
+ "role": "system",
114
+ "slot": "date-cwd"
115
+ },
116
+ {
117
+ "kind": "slot",
118
+ "id": "chat-history",
119
+ "name": "Chat History",
120
+ "enabled": true,
121
+ "slot": "chat-history"
122
+ }
123
+ ],
124
+ "parameters": {}
125
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "type": "pi-forge.prompt-stack",
4
+ "id": "fake-assistant-direct-output",
5
+ "name": "Fake Assistant: Direct Output",
6
+ "description": "Model-specific experiment: append an ordinary assistant text message after chat history to suggest that tagged reasoning has already finished. Compatibility varies by model, provider, and endpoint; verify with an A/B run before use.",
7
+ "autoActivate": false,
8
+ "mode": "replace",
9
+ "defaults": {
10
+ "syntheticMessagesVisible": false,
11
+ "unresolvedMacroPolicy": "warn"
12
+ },
13
+ "context": {
14
+ "allowDuplicateChatHistory": false,
15
+ "mergeConsecutiveRoles": false
16
+ },
17
+ "tools": {
18
+ "deny": [
19
+ "*"
20
+ ]
21
+ },
22
+ "items": [
23
+ {
24
+ "kind": "block",
25
+ "id": "direct-answer-role",
26
+ "name": "Direct Answer Role",
27
+ "enabled": true,
28
+ "role": "system",
29
+ "content": "You are a concise assistant. Answer the user's latest request directly and include only the requested result."
30
+ },
31
+ {
32
+ "kind": "slot",
33
+ "id": "chat-history",
34
+ "name": "Chat History",
35
+ "enabled": true,
36
+ "slot": "chat-history"
37
+ },
38
+ {
39
+ "kind": "block",
40
+ "id": "fake-completed-thinking",
41
+ "name": "Fake Completed Thinking",
42
+ "enabled": true,
43
+ "role": "assistant",
44
+ "content": "<think>思考已完成,直接输出结果。</think>"
45
+ }
46
+ ],
47
+ "parameters": {}
48
+ }
@@ -0,0 +1,118 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "type": "pi-forge.prompt-stack",
4
+ "id": "regex-hack",
5
+ "name": "Regex Hack Pack",
6
+ "description": "Default layout plus outgoing-history regex rules: ANSI escapes are removed and illustrative sk-/ghp_ token shapes are redacted. This is a non-exhaustive demo, not a general secret scanner.",
7
+ "autoActivate": false,
8
+ "mode": "replace",
9
+ "defaults": {
10
+ "syntheticMessagesVisible": false,
11
+ "unresolvedMacroPolicy": "warn"
12
+ },
13
+ "context": {
14
+ "allowDuplicateChatHistory": false
15
+ },
16
+ "tools": {
17
+ "allow": [
18
+ "*"
19
+ ]
20
+ },
21
+ "items": [
22
+ {
23
+ "kind": "block",
24
+ "id": "main-role",
25
+ "name": "Pi Default Role",
26
+ "enabled": true,
27
+ "role": "system",
28
+ "content": "You are a coding assistant running inside pi, a coding agent harness. Help users inspect files, run commands, and modify code."
29
+ },
30
+ {
31
+ "kind": "slot",
32
+ "id": "tools",
33
+ "name": "Available Tools",
34
+ "enabled": true,
35
+ "role": "system",
36
+ "slot": "tools",
37
+ "options": {
38
+ "format": "plain",
39
+ "onlyWithSnippets": true
40
+ }
41
+ },
42
+ {
43
+ "kind": "slot",
44
+ "id": "project-context",
45
+ "name": "Project Context",
46
+ "enabled": true,
47
+ "role": "system",
48
+ "slot": "project-context"
49
+ },
50
+ {
51
+ "kind": "slot",
52
+ "id": "date-cwd",
53
+ "name": "Date and Working Directory",
54
+ "enabled": true,
55
+ "role": "system",
56
+ "slot": "date-cwd"
57
+ },
58
+ {
59
+ "kind": "slot",
60
+ "id": "chat-history",
61
+ "name": "Chat History",
62
+ "enabled": true,
63
+ "slot": "chat-history",
64
+ "options": {
65
+ "stripAssistantThinking": false
66
+ }
67
+ }
68
+ ],
69
+ "regex": {
70
+ "schemaVersion": 1,
71
+ "rules": [
72
+ {
73
+ "id": "strip-ansi-escapes",
74
+ "name": "ANSI terminal escape codes removed from outgoing history",
75
+ "enabled": true,
76
+ "stage": "history",
77
+ "targets": [
78
+ "messages"
79
+ ],
80
+ "pattern": "\\x1B\\[[0-?]*[ -/]*[@-~]",
81
+ "flags": "g",
82
+ "replace": ""
83
+ },
84
+ {
85
+ "id": "redact-api-keys-outgoing",
86
+ "name": "Illustrative sk-/ghp_ token shapes redacted on every provider request",
87
+ "enabled": true,
88
+ "stage": "history",
89
+ "effect": "outgoing",
90
+ "frequency": "request",
91
+ "targets": [
92
+ "messages"
93
+ ],
94
+ "pattern": "\\b(sk-[A-Za-z0-9_-]{12,}|ghp_[A-Za-z0-9]{20,})\\b",
95
+ "flags": "g",
96
+ "replace": "[REDACTED]"
97
+ },
98
+ {
99
+ "id": "redact-api-keys-finalize",
100
+ "name": "Illustrative sk-/ghp_ token shapes scrubbed from the stored transcript",
101
+ "enabled": true,
102
+ "stage": "compiled",
103
+ "effect": "finalize",
104
+ "targets": [
105
+ "messages"
106
+ ],
107
+ "roles": [
108
+ "assistant",
109
+ "toolResult"
110
+ ],
111
+ "pattern": "\\b(sk-[A-Za-z0-9_-]{12,}|ghp_[A-Za-z0-9]{20,})\\b",
112
+ "flags": "g",
113
+ "replace": "[REDACTED]"
114
+ }
115
+ ]
116
+ },
117
+ "parameters": {}
118
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "type": "pi-forge.prompt-stack",
4
+ "id": "minimal",
5
+ "name": "Minimal Worker",
6
+ "description": "Minimal Pi approximation of the DeepSeek Harness Minimal shape: the exact one-line persona, chat history, and only Pi's stock bash plus edit. It does not replicate DSH's persistent shell, editor tool, PTY, sandbox, or deployment semantics.",
7
+ "autoActivate": false,
8
+ "mode": "replace",
9
+ "defaults": {
10
+ "syntheticMessagesVisible": false,
11
+ "unresolvedMacroPolicy": "warn"
12
+ },
13
+ "tools": {
14
+ "allow": [
15
+ "bash",
16
+ "edit"
17
+ ]
18
+ },
19
+ "items": [
20
+ {
21
+ "kind": "block",
22
+ "id": "worker-role",
23
+ "name": "Worker Role",
24
+ "enabled": true,
25
+ "role": "system",
26
+ "content": "You are a helpful software engineer assistant."
27
+ },
28
+ {
29
+ "kind": "slot",
30
+ "id": "chat-history",
31
+ "name": "Chat History",
32
+ "enabled": true,
33
+ "slot": "chat-history",
34
+ "options": {
35
+ "includeSummaries": false
36
+ }
37
+ }
38
+ ],
39
+ "parameters": {}
40
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "type": "pi-forge.prompt-stack",
4
+ "id": "read-first-worker",
5
+ "name": "Read-first Worker",
6
+ "autoActivate": false,
7
+ "mode": "replace",
8
+ "tools": {
9
+ "allow": [
10
+ "read",
11
+ "ls",
12
+ "forge_capability",
13
+ "bash",
14
+ "edit"
15
+ ],
16
+ "initial": [
17
+ "read",
18
+ "ls",
19
+ "forge_capability"
20
+ ]
21
+ },
22
+ "capabilities": [
23
+ {
24
+ "id": "write-tools",
25
+ "ref": "project:write-tools",
26
+ "modelCallable": true
27
+ }
28
+ ],
29
+ "items": [
30
+ {
31
+ "kind": "block",
32
+ "id": "worker-role",
33
+ "name": "Worker Role",
34
+ "enabled": true,
35
+ "role": "system",
36
+ "content": "You are a helpful software engineer assistant. Discover paths with ls then read. When the task needs shell commands or edits, use forge_capability with the enable action for the write-tools binding, then use its disable action when finished."
37
+ },
38
+ {
39
+ "kind": "slot",
40
+ "id": "chat-history",
41
+ "name": "Chat History",
42
+ "enabled": true,
43
+ "slot": "chat-history",
44
+ "options": {
45
+ "includeSummaries": false
46
+ }
47
+ }
48
+ ]
49
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "type": "pi-forge.prompt-stack",
4
+ "id": "validation-issues",
5
+ "name": "Validation Issues Sample",
6
+ "description": "Deliberately invalid sample for testing /preset validate validation-issues.",
7
+ "autoActivate": false,
8
+ "mode": "replace",
9
+ "items": [
10
+ {
11
+ "kind": "block",
12
+ "id": "duplicate-id",
13
+ "enabled": true,
14
+ "role": "system",
15
+ "content": "This block is valid, but its id is duplicated below."
16
+ },
17
+ {
18
+ "kind": "block",
19
+ "id": "duplicate-id",
20
+ "enabled": true,
21
+ "role": "user",
22
+ "content": "This block intentionally duplicates the previous item id."
23
+ },
24
+ {
25
+ "kind": "slot",
26
+ "id": "unsupported-slot",
27
+ "enabled": true,
28
+ "role": "user",
29
+ "slot": "not-a-real-slot"
30
+ },
31
+ {
32
+ "kind": "block",
33
+ "id": "missing-role",
34
+ "enabled": true,
35
+ "content": "This enabled non-system block has no role and should be ignored."
36
+ }
37
+ ]
38
+ }