@zihanw/pi-forge 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +11 -11
  3. package/README.zh-CN.md +4 -6
  4. package/SUBAGENT_ADAPTER_CONTRACT.md +3 -1
  5. package/dist/agent-profile.d.ts +21 -42
  6. package/dist/agent-profile.d.ts.map +1 -1
  7. package/dist/agent-profile.js +82 -194
  8. package/dist/agent-profile.js.map +1 -1
  9. package/dist/catalog.d.ts +27 -0
  10. package/dist/catalog.d.ts.map +1 -0
  11. package/dist/catalog.js +59 -0
  12. package/dist/catalog.js.map +1 -0
  13. package/dist/codecs/agent-profile.d.ts +53 -0
  14. package/dist/codecs/agent-profile.d.ts.map +1 -0
  15. package/dist/codecs/agent-profile.js +176 -0
  16. package/dist/codecs/agent-profile.js.map +1 -0
  17. package/dist/codecs/index.d.ts +5 -0
  18. package/dist/codecs/index.d.ts.map +1 -0
  19. package/dist/codecs/index.js +3 -0
  20. package/dist/codecs/index.js.map +1 -0
  21. package/dist/codecs/prompt-stack.d.ts +18 -0
  22. package/dist/codecs/prompt-stack.d.ts.map +1 -0
  23. package/dist/codecs/prompt-stack.js +479 -0
  24. package/dist/codecs/prompt-stack.js.map +1 -0
  25. package/dist/compile-cycle.d.ts +18 -0
  26. package/dist/compile-cycle.d.ts.map +1 -0
  27. package/dist/compile-cycle.js +13 -0
  28. package/dist/compile-cycle.js.map +1 -0
  29. package/dist/compiler.d.ts +10 -4
  30. package/dist/compiler.d.ts.map +1 -1
  31. package/dist/compiler.js +53 -19
  32. package/dist/compiler.js.map +1 -1
  33. package/dist/extension-registry.d.ts.map +1 -1
  34. package/dist/extension-registry.js +5 -2
  35. package/dist/extension-registry.js.map +1 -1
  36. package/dist/forge-config.d.ts +2 -81
  37. package/dist/forge-config.d.ts.map +1 -1
  38. package/dist/forge-config.js +5 -280
  39. package/dist/forge-config.js.map +1 -1
  40. package/dist/forge-v1/analyzer.d.ts +3 -0
  41. package/dist/forge-v1/analyzer.d.ts.map +1 -0
  42. package/dist/forge-v1/analyzer.js +50 -0
  43. package/dist/forge-v1/analyzer.js.map +1 -0
  44. package/dist/forge-v1/index.d.ts +6 -0
  45. package/dist/forge-v1/index.d.ts.map +1 -0
  46. package/dist/forge-v1/index.js +13 -0
  47. package/dist/forge-v1/index.js.map +1 -0
  48. package/dist/forge-v1/parser.d.ts +3 -0
  49. package/dist/forge-v1/parser.d.ts.map +1 -0
  50. package/dist/forge-v1/parser.js +186 -0
  51. package/dist/forge-v1/parser.js.map +1 -0
  52. package/dist/forge-v1/renderer.d.ts +9 -0
  53. package/dist/forge-v1/renderer.d.ts.map +1 -0
  54. package/dist/forge-v1/renderer.js +181 -0
  55. package/dist/forge-v1/renderer.js.map +1 -0
  56. package/dist/forge-v1/types.d.ts +87 -0
  57. package/dist/forge-v1/types.d.ts.map +1 -0
  58. package/dist/forge-v1/types.js +4 -0
  59. package/dist/forge-v1/types.js.map +1 -0
  60. package/dist/index.d.ts +12 -9
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +49 -59
  63. package/dist/index.js.map +1 -1
  64. package/dist/lifecycle.d.ts +7 -5
  65. package/dist/lifecycle.d.ts.map +1 -1
  66. package/dist/lifecycle.js +44 -110
  67. package/dist/lifecycle.js.map +1 -1
  68. package/dist/loader.d.ts +16 -3
  69. package/dist/loader.d.ts.map +1 -1
  70. package/dist/loader.js +42 -440
  71. package/dist/loader.js.map +1 -1
  72. package/dist/macro-engine.d.ts +9 -14
  73. package/dist/macro-engine.d.ts.map +1 -1
  74. package/dist/macro-engine.js +5 -238
  75. package/dist/macro-engine.js.map +1 -1
  76. package/dist/payload-command.d.ts +6 -6
  77. package/dist/payload-command.d.ts.map +1 -1
  78. package/dist/payload-command.js.map +1 -1
  79. package/dist/payload-state.d.ts +16 -0
  80. package/dist/payload-state.d.ts.map +1 -0
  81. package/dist/payload-state.js +14 -0
  82. package/dist/payload-state.js.map +1 -0
  83. package/dist/preset-command.d.ts +4 -4
  84. package/dist/preset-command.d.ts.map +1 -1
  85. package/dist/preset-command.js +55 -98
  86. package/dist/preset-command.js.map +1 -1
  87. package/dist/preview.d.ts +4 -4
  88. package/dist/preview.d.ts.map +1 -1
  89. package/dist/preview.js +17 -8
  90. package/dist/preview.js.map +1 -1
  91. package/dist/profile-command.d.ts +2 -2
  92. package/dist/profile-command.d.ts.map +1 -1
  93. package/dist/profile-command.js +52 -26
  94. package/dist/profile-command.js.map +1 -1
  95. package/dist/profile-service.d.ts +5 -2
  96. package/dist/profile-service.d.ts.map +1 -1
  97. package/dist/profile-service.js +63 -42
  98. package/dist/profile-service.js.map +1 -1
  99. package/dist/prompt-analysis.d.ts +24 -0
  100. package/dist/prompt-analysis.d.ts.map +1 -0
  101. package/dist/prompt-analysis.js +84 -0
  102. package/dist/prompt-analysis.js.map +1 -0
  103. package/dist/prompt-runtime.d.ts +19 -0
  104. package/dist/prompt-runtime.d.ts.map +1 -0
  105. package/dist/prompt-runtime.js +30 -0
  106. package/dist/prompt-runtime.js.map +1 -0
  107. package/dist/regex.js +6 -12
  108. package/dist/regex.js.map +1 -1
  109. package/dist/render-helpers.d.ts +2 -10
  110. package/dist/render-helpers.d.ts.map +1 -1
  111. package/dist/render-helpers.js +3 -53
  112. package/dist/render-helpers.js.map +1 -1
  113. package/dist/repositories/agent-profile.d.ts +36 -0
  114. package/dist/repositories/agent-profile.d.ts.map +1 -0
  115. package/dist/repositories/agent-profile.js +153 -0
  116. package/dist/repositories/agent-profile.js.map +1 -0
  117. package/dist/repositories/index.d.ts +3 -0
  118. package/dist/repositories/index.d.ts.map +1 -0
  119. package/dist/repositories/index.js +3 -0
  120. package/dist/repositories/index.js.map +1 -0
  121. package/dist/repositories/prompt-stack.d.ts +57 -0
  122. package/dist/repositories/prompt-stack.d.ts.map +1 -0
  123. package/dist/repositories/prompt-stack.js +175 -0
  124. package/dist/repositories/prompt-stack.js.map +1 -0
  125. package/dist/resource-identity.d.ts +33 -0
  126. package/dist/resource-identity.d.ts.map +1 -0
  127. package/dist/resource-identity.js +56 -0
  128. package/dist/resource-identity.js.map +1 -0
  129. package/dist/runtime/profile-runtime.d.ts +2 -2
  130. package/dist/runtime/profile-runtime.d.ts.map +1 -1
  131. package/dist/runtime/profile-runtime.js +18 -10
  132. package/dist/runtime/profile-runtime.js.map +1 -1
  133. package/dist/runtime/prompt-stack-runtime.d.ts +5 -4
  134. package/dist/runtime/prompt-stack-runtime.d.ts.map +1 -1
  135. package/dist/runtime/prompt-stack-runtime.js +47 -52
  136. package/dist/runtime/prompt-stack-runtime.js.map +1 -1
  137. package/dist/runtime/tool-policy-runtime.d.ts +2 -2
  138. package/dist/runtime/tool-policy-runtime.d.ts.map +1 -1
  139. package/dist/runtime/tool-policy-runtime.js +3 -3
  140. package/dist/runtime/tool-policy-runtime.js.map +1 -1
  141. package/dist/session-adapter.d.ts +17 -0
  142. package/dist/session-adapter.d.ts.map +1 -0
  143. package/dist/session-adapter.js +57 -0
  144. package/dist/session-adapter.js.map +1 -0
  145. package/dist/slot-renderers.d.ts +16 -3
  146. package/dist/slot-renderers.d.ts.map +1 -1
  147. package/dist/slot-renderers.js +15 -63
  148. package/dist/slot-renderers.js.map +1 -1
  149. package/dist/stack-migration.d.ts +6 -0
  150. package/dist/stack-migration.d.ts.map +1 -1
  151. package/dist/stack-migration.js +49 -52
  152. package/dist/stack-migration.js.map +1 -1
  153. package/dist/storage.d.ts +10 -0
  154. package/dist/storage.d.ts.map +1 -1
  155. package/dist/storage.js +45 -10
  156. package/dist/storage.js.map +1 -1
  157. package/dist/subagent/fingerprints.d.ts +24 -0
  158. package/dist/subagent/fingerprints.d.ts.map +1 -0
  159. package/dist/subagent/fingerprints.js +81 -0
  160. package/dist/subagent/fingerprints.js.map +1 -0
  161. package/dist/subagent/host-port.d.ts +296 -0
  162. package/dist/subagent/host-port.d.ts.map +1 -0
  163. package/dist/subagent/host-port.js +560 -0
  164. package/dist/subagent/host-port.js.map +1 -0
  165. package/dist/subagent/index.d.ts +10 -10
  166. package/dist/subagent/index.d.ts.map +1 -1
  167. package/dist/subagent/index.js +9 -10
  168. package/dist/subagent/index.js.map +1 -1
  169. package/dist/subagent-host.d.ts +99 -18
  170. package/dist/subagent-host.d.ts.map +1 -1
  171. package/dist/subagent-host.js +185 -162
  172. package/dist/subagent-host.js.map +1 -1
  173. package/dist/template-render.d.ts +18 -0
  174. package/dist/template-render.d.ts.map +1 -0
  175. package/dist/template-render.js +232 -0
  176. package/dist/template-render.js.map +1 -0
  177. package/dist/types.d.ts +43 -27
  178. package/dist/types.d.ts.map +1 -1
  179. package/dist/types.js.map +1 -1
  180. package/dist/web-editor/client-script.generated.d.ts.map +1 -1
  181. package/dist/web-editor/client-script.generated.js +1 -1
  182. package/dist/web-editor/client-script.generated.js.map +1 -1
  183. package/dist/web-editor/client-styles.generated.d.ts.map +1 -1
  184. package/dist/web-editor/client-styles.generated.js +1 -1
  185. package/dist/web-editor/client-styles.generated.js.map +1 -1
  186. package/dist/web-editor/server.d.ts.map +1 -1
  187. package/dist/web-editor/server.js +32 -72
  188. package/dist/web-editor/server.js.map +1 -1
  189. package/dist/web-editor/styles.d.ts.map +1 -1
  190. package/dist/web-editor/styles.js +13 -0
  191. package/dist/web-editor/styles.js.map +1 -1
  192. package/dist/web-editor/types.d.ts +10 -37
  193. package/dist/web-editor/types.d.ts.map +1 -1
  194. package/dist/web-host.d.ts +4 -2
  195. package/dist/web-host.d.ts.map +1 -1
  196. package/dist/web-host.js +110 -138
  197. package/dist/web-host.js.map +1 -1
  198. package/dist/workspace.d.ts +74 -0
  199. package/dist/workspace.d.ts.map +1 -0
  200. package/dist/workspace.js +351 -0
  201. package/dist/workspace.js.map +1 -0
  202. package/docs/README.md +6 -4
  203. package/docs/concepts/agent-profiles.md +2 -2
  204. package/docs/concepts/prompt-stacks.md +12 -7
  205. package/docs/design/README.md +21 -3
  206. package/docs/design/architecture-0.5.md +211 -0
  207. package/docs/design/archive/0.5-full-proposal/0.5-consumer-audit.md +62 -0
  208. package/docs/design/archive/0.5-full-proposal/0.5-inventory.md +208 -0
  209. package/docs/design/archive/0.5-full-proposal/0.5-phase0-decision-drafts.md +237 -0
  210. package/docs/design/archive/0.5-full-proposal/README.md +12 -0
  211. package/docs/design/archive/0.5-full-proposal/architecture-0.5.md +423 -0
  212. package/docs/design/archive/0.5-full-proposal/host-discovery-spike.md +103 -0
  213. package/docs/design/archive/0.5-full-proposal/template-language-spike.md +156 -0
  214. package/docs/design/context-diff-plan.md +72 -0
  215. package/docs/design/decision-template.md +33 -0
  216. package/docs/design/roadmap-0.4-archive.md +1 -1
  217. package/docs/design/subagents/interface-design.md +1 -1
  218. package/docs/development/architecture-rules.md +148 -0
  219. package/docs/development/roadmap.md +39 -13
  220. package/docs/development/scoped-global-profiles-stacks.md +325 -0
  221. package/docs/development/setup.md +6 -4
  222. package/docs/getting-started.md +9 -6
  223. package/docs/guides/custom-macros-and-slots.md +8 -7
  224. package/docs/guides/debugging.md +1 -1
  225. package/docs/guides/delegation.md +25 -21
  226. package/docs/guides/migrating-to-0.5.md +107 -0
  227. package/docs/guides/use-cases.md +7 -11
  228. package/docs/guides/web-editor.md +7 -11
  229. package/docs/reference/commands.md +4 -3
  230. package/docs/reference/configuration.md +18 -17
  231. package/docs/reference/features.md +34 -79
  232. package/docs/reference/macros-and-slots.md +70 -49
  233. package/docs/reference/public-api.md +64 -17
  234. package/docs/reference/stack-schema.md +14 -9
  235. package/docs/reference/subagent-host-port.md +49 -0
  236. package/docs/zh-CN/README.md +3 -3
  237. package/docs/zh-CN/concepts/agent-profiles.md +4 -2
  238. package/docs/zh-CN/concepts/prompt-stacks.md +9 -7
  239. package/docs/zh-CN/getting-started.md +10 -7
  240. package/docs/zh-CN/guides/delegation.md +11 -13
  241. package/docs/zh-CN/guides/migrating-to-0.5.md +92 -0
  242. package/docs/zh-CN/guides/web-editor.md +7 -7
  243. package/docs/zh-CN/reference/commands.md +6 -3
  244. package/examples/custom-system-status-extension/README.md +3 -3
  245. package/examples/custom-system-status-extension/index.ts +2 -1
  246. package/examples/custom-system-status-extension/prompt-stack.json +4 -3
  247. package/examples/default-prompt-stack.json +9 -4
  248. package/examples/image-reader-prompt-stack.json +16 -26
  249. package/examples/reviewer-prompt-stack.json +13 -24
  250. package/package.json +101 -120
  251. package/dist/runtime/subagent-runtime.d.ts +0 -45
  252. package/dist/runtime/subagent-runtime.d.ts.map +0 -1
  253. package/dist/runtime/subagent-runtime.js +0 -335
  254. package/dist/runtime/subagent-runtime.js.map +0 -1
  255. package/dist/runtime-state.d.ts +0 -30
  256. package/dist/runtime-state.d.ts.map +0 -1
  257. package/dist/runtime-state.js +0 -17
  258. package/dist/runtime-state.js.map +0 -1
  259. package/dist/sillytavern-importer/items.d.ts +0 -3
  260. package/dist/sillytavern-importer/items.d.ts.map +0 -1
  261. package/dist/sillytavern-importer/items.js +0 -88
  262. package/dist/sillytavern-importer/items.js.map +0 -1
  263. package/dist/sillytavern-importer/macros.d.ts +0 -15
  264. package/dist/sillytavern-importer/macros.d.ts.map +0 -1
  265. package/dist/sillytavern-importer/macros.js +0 -141
  266. package/dist/sillytavern-importer/macros.js.map +0 -1
  267. package/dist/sillytavern-importer/prompt-order.d.ts +0 -6
  268. package/dist/sillytavern-importer/prompt-order.d.ts.map +0 -1
  269. package/dist/sillytavern-importer/prompt-order.js +0 -38
  270. package/dist/sillytavern-importer/prompt-order.js.map +0 -1
  271. package/dist/sillytavern-importer/regex.d.ts +0 -3
  272. package/dist/sillytavern-importer/regex.d.ts.map +0 -1
  273. package/dist/sillytavern-importer/regex.js +0 -275
  274. package/dist/sillytavern-importer/regex.js.map +0 -1
  275. package/dist/sillytavern-importer/report.d.ts +0 -21
  276. package/dist/sillytavern-importer/report.d.ts.map +0 -1
  277. package/dist/sillytavern-importer/report.js +0 -166
  278. package/dist/sillytavern-importer/report.js.map +0 -1
  279. package/dist/sillytavern-importer/types.d.ts +0 -106
  280. package/dist/sillytavern-importer/types.d.ts.map +0 -1
  281. package/dist/sillytavern-importer/types.js +0 -2
  282. package/dist/sillytavern-importer/types.js.map +0 -1
  283. package/dist/sillytavern-importer.d.ts +0 -5
  284. package/dist/sillytavern-importer.d.ts.map +0 -1
  285. package/dist/sillytavern-importer.js +0 -117
  286. package/dist/sillytavern-importer.js.map +0 -1
  287. package/dist/subagent/canonical.d.ts +0 -22
  288. package/dist/subagent/canonical.d.ts.map +0 -1
  289. package/dist/subagent/canonical.js +0 -24
  290. package/dist/subagent/canonical.js.map +0 -1
  291. package/dist/subagent/context.d.ts +0 -8
  292. package/dist/subagent/context.d.ts.map +0 -1
  293. package/dist/subagent/context.js +0 -125
  294. package/dist/subagent/context.js.map +0 -1
  295. package/dist/subagent/contract.d.ts +0 -10
  296. package/dist/subagent/contract.d.ts.map +0 -1
  297. package/dist/subagent/contract.js +0 -10
  298. package/dist/subagent/contract.js.map +0 -1
  299. package/dist/subagent/plan.d.ts +0 -18
  300. package/dist/subagent/plan.d.ts.map +0 -1
  301. package/dist/subagent/plan.js +0 -157
  302. package/dist/subagent/plan.js.map +0 -1
  303. package/dist/subagent/preflight.d.ts +0 -4
  304. package/dist/subagent/preflight.d.ts.map +0 -1
  305. package/dist/subagent/preflight.js +0 -108
  306. package/dist/subagent/preflight.js.map +0 -1
  307. package/dist/subagent/request.d.ts +0 -4
  308. package/dist/subagent/request.d.ts.map +0 -1
  309. package/dist/subagent/request.js +0 -122
  310. package/dist/subagent/request.js.map +0 -1
  311. package/dist/subagent/response.d.ts +0 -8
  312. package/dist/subagent/response.d.ts.map +0 -1
  313. package/dist/subagent/response.js +0 -155
  314. package/dist/subagent/response.js.map +0 -1
  315. package/dist/subagent/tools.d.ts +0 -4
  316. package/dist/subagent/tools.d.ts.map +0 -1
  317. package/dist/subagent/tools.js +0 -42
  318. package/dist/subagent/tools.js.map +0 -1
  319. package/dist/subagent/types.d.ts +0 -268
  320. package/dist/subagent/types.d.ts.map +0 -1
  321. package/dist/subagent/types.js +0 -3
  322. package/dist/subagent/types.js.map +0 -1
  323. package/dist/subagent/validation.d.ts +0 -35
  324. package/dist/subagent/validation.d.ts.map +0 -1
  325. package/dist/subagent/validation.js +0 -314
  326. package/dist/subagent/validation.js.map +0 -1
  327. package/dist/subagent-command.d.ts +0 -4
  328. package/dist/subagent-command.d.ts.map +0 -1
  329. package/dist/subagent-command.js +0 -246
  330. package/dist/subagent-command.js.map +0 -1
  331. package/dist/subagent-profile-tool.d.ts +0 -49
  332. package/dist/subagent-profile-tool.d.ts.map +0 -1
  333. package/dist/subagent-profile-tool.js +0 -124
  334. package/dist/subagent-profile-tool.js.map +0 -1
  335. package/dist/subagent-tool.d.ts +0 -53
  336. package/dist/subagent-tool.d.ts.map +0 -1
  337. package/dist/subagent-tool.js +0 -456
  338. package/dist/subagent-tool.js.map +0 -1
  339. package/docs/guides/sillytavern-import.md +0 -47
  340. package/docs/reference/subagent-adapter.md +0 -204
  341. package/examples/sillytavern-dm-writer-prompt-stack.json +0 -190
@@ -5,7 +5,8 @@ interface ForgeRegistrationApi {
5
5
  name: string;
6
6
  source?: string;
7
7
  description?: string;
8
- render: () => string;
8
+ dependencies?: string[];
9
+ render: (ctx: { env: Record<string, unknown>; helpers: unknown }) => string;
9
10
  }): () => void;
10
11
  registerSlot(definition: {
11
12
  name: string;
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": 1,
2
+ "schemaVersion": 2,
3
3
  "type": "pi-forge.prompt-stack",
4
4
  "id": "custom-system-status",
5
5
  "name": "Custom System Status",
@@ -12,7 +12,7 @@
12
12
  "name": "CPU Load Macro",
13
13
  "enabled": true,
14
14
  "role": "system",
15
- "content": "Current rough CPU load: {{cpuLoad}}"
15
+ "content": "Current rough CPU load: {{ extensions.cpuLoad }}"
16
16
  },
17
17
  {
18
18
  "kind": "slot",
@@ -35,5 +35,6 @@
35
35
  "enabled": true,
36
36
  "slot": "chat-history"
37
37
  }
38
- ]
38
+ ],
39
+ "parameters": {}
39
40
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": 1,
2
+ "schemaVersion": 2,
3
3
  "type": "pi-forge.prompt-stack",
4
4
  "id": "default",
5
5
  "name": "Default Pi Prompt Mirror",
@@ -14,10 +14,14 @@
14
14
  "allowDuplicateChatHistory": false
15
15
  },
16
16
  "tools": {
17
- "allow": ["*"]
17
+ "allow": [
18
+ "*"
19
+ ]
18
20
  },
19
21
  "skills": {
20
- "allow": ["*"]
22
+ "allow": [
23
+ "*"
24
+ ]
21
25
  },
22
26
  "items": [
23
27
  {
@@ -116,5 +120,6 @@
116
120
  "enabled": true,
117
121
  "slot": "chat-history"
118
122
  }
119
- ]
123
+ ],
124
+ "parameters": {}
120
125
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": 1,
2
+ "schemaVersion": 2,
3
3
  "type": "pi-forge.prompt-stack",
4
4
  "id": "image-reader",
5
5
  "name": "Image Reader Subagent",
@@ -14,13 +14,11 @@
14
14
  "allowDuplicateChatHistory": false
15
15
  },
16
16
  "tools": {
17
- "deny": ["bash", "edit", "write"]
18
- },
19
- "variables": {
20
- "audience": "main agent",
21
- "report_mode": "image-reader",
22
- "detail_level": "exhaustive factual visual inventory",
23
- "safety_scope": "include safety-relevant visual content neutrally without giving instructions for harmful acts"
17
+ "deny": [
18
+ "bash",
19
+ "edit",
20
+ "write"
21
+ ]
24
22
  },
25
23
  "items": [
26
24
  {
@@ -29,7 +27,7 @@
29
27
  "name": "Image Reader Role",
30
28
  "enabled": true,
31
29
  "role": "system",
32
- "content": "{{setturnvar::active_preset::image-reader}}You are an image reader subagent. Your job is to inspect image inputs directly and produce a faithful visual report for the {{audience}}.\n\nUse this stack only when you can actually inspect the image. If no image is present, the image is inaccessible, or the current model cannot view images, say that directly and do not guess.\n\nPrimary objective: describe exactly what is visible in the image in detail. Treat the report as sensory evidence for another agent, not as advice, judgment, or creative writing."
30
+ "content": "You are an image reader subagent. Your job is to inspect image inputs directly and produce a faithful visual report for the {{ parameters.audience }}.\n\nUse this stack only when you can actually inspect the image. If no image is present, the image is inaccessible, or the current model cannot view images, say that directly and do not guess.\n\nPrimary objective: describe exactly what is visible in the image in detail. Treat the report as sensory evidence for another agent, not as advice, judgment, or creative writing."
33
31
  },
34
32
  {
35
33
  "kind": "block",
@@ -45,21 +43,7 @@
45
43
  "name": "Macro Context",
46
44
  "enabled": true,
47
45
  "role": "system",
48
- "content": "{{ifeq::report_mode::image-reader::Report mode is active: {{upper::{{report_mode}}}}.::Report mode is not image-reader; state this mismatch before proceeding.}}\n{{ifvar::safety_scope::Safety scope: {{safety_scope}}.}}\n{{iftools::read::If the user references an image file path and direct vision input is unavailable, you may inspect only file metadata or surrounding text with read tools; do not pretend metadata is image vision.}}\n{{ifslot::variables::Runtime variables are available below for auditability.}}"
49
- },
50
- {
51
- "kind": "slot",
52
- "id": "variables",
53
- "name": "Image Reader Variables",
54
- "enabled": true,
55
- "role": "system",
56
- "slot": "variables",
57
- "options": {
58
- "includeStatic": true,
59
- "includeSession": true,
60
- "includeTurn": true,
61
- "format": "plain"
62
- }
46
+ "content": "Report mode is active: {{ parameters.report_mode | upper }}.\nSafety scope: {{ parameters.safety_scope }}.\n{% if runtime.tool.read %}If the user references an image file path and direct vision input is unavailable, you may inspect only file metadata or surrounding text with read tools; do not pretend metadata is image vision.{% endif %}"
63
47
  },
64
48
  {
65
49
  "kind": "slot",
@@ -118,7 +102,13 @@
118
102
  "name": "Current Image Task",
119
103
  "enabled": true,
120
104
  "role": "user",
121
- "content": "<current_image_task>\n{{xml::{{lastUserMessage}}}}\n</current_image_task>\n\nProduce the image report now for the {{audience}}.\n\nRequired output:\n1. Access check: state whether you can directly inspect the image.\n2. One-sentence overview: summarize the scene plainly.\n3. Detailed inventory: list visible subjects, objects, setting, text, colors, layout, and relationships.\n4. Safety-relevant content: list visible hazards, injuries, weapons, explicit content, abuse indicators, hate symbols, or other potentially harmful content. Write \"None visible\" only if none are visible.\n5. Uncertainties: list anything important that is unclear, ambiguous, cropped, blurry, or inferred.\n6. Machine-readable summary: include one compact JSON object with keys \"canInspectImage\", \"overview\", \"visibleText\", \"safetyRelevantContent\", and \"uncertainties\". Use strings or arrays only; do not include markdown inside the JSON.\n\nRequest as JSON string for logging: {{json::{{lastUserMessage}}}}"
105
+ "content": "<current_image_task>\n{{ runtime.lastUserMessage | xml }}\n</current_image_task>\n\nProduce the image report now for the {{ parameters.audience }}.\n\nRequired output:\n1. Access check: state whether you can directly inspect the image.\n2. One-sentence overview: summarize the scene plainly.\n3. Detailed inventory: list visible subjects, objects, setting, text, colors, layout, and relationships.\n4. Safety-relevant content: list visible hazards, injuries, weapons, explicit content, abuse indicators, hate symbols, or other potentially harmful content. Write \"None visible\" only if none are visible.\n5. Uncertainties: list anything important that is unclear, ambiguous, cropped, blurry, or inferred.\n6. Machine-readable summary: include one compact JSON object with keys \"canInspectImage\", \"overview\", \"visibleText\", \"safetyRelevantContent\", and \"uncertainties\". Use strings or arrays only; do not include markdown inside the JSON.\n\nRequest as JSON string for logging: {{ runtime.lastUserMessage | json }}"
122
106
  }
123
- ]
107
+ ],
108
+ "parameters": {
109
+ "audience": "main agent",
110
+ "report_mode": "image-reader",
111
+ "detail_level": "exhaustive factual visual inventory",
112
+ "safety_scope": "include safety-relevant visual content neutrally without giving instructions for harmful acts"
113
+ }
124
114
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": 1,
2
+ "schemaVersion": 2,
3
3
  "type": "pi-forge.prompt-stack",
4
4
  "id": "reviewer",
5
5
  "name": "Focused Code Reviewer",
@@ -14,12 +14,10 @@
14
14
  "allowDuplicateChatHistory": false
15
15
  },
16
16
  "tools": {
17
- "deny": ["edit", "write"]
18
- },
19
- "variables": {
20
- "review_focus": "correctness, regressions, security, maintainability, and missing tests",
21
- "review_style": "findings first, ordered by severity",
22
- "max_findings": "8"
17
+ "deny": [
18
+ "edit",
19
+ "write"
20
+ ]
23
21
  },
24
22
  "items": [
25
23
  {
@@ -28,7 +26,7 @@
28
26
  "name": "Reviewer Role",
29
27
  "enabled": true,
30
28
  "role": "system",
31
- "content": "You are a senior code reviewer operating inside pi. Review the user's target with a skeptical engineering lens. Prioritize {{review_focus}}.\n\nRules:\n- Do not edit files or write patches unless the user explicitly asks for implementation.\n- You may inspect files and run safe read-only commands when needed.\n- Treat previous conversation as context, not as the target unless the latest user message says so.\n- Prefer concrete file/line references when available.\n- If there are no substantive issues, say that clearly and mention residual risks or test gaps."
29
+ "content": "You are a senior code reviewer operating inside pi. Review the user's target with a skeptical engineering lens. Prioritize {{ parameters.review_focus }}.\n\nRules:\n- Do not edit files or write patches unless the user explicitly asks for implementation.\n- You may inspect files and run safe read-only commands when needed.\n- Treat previous conversation as context, not as the target unless the latest user message says so.\n- Prefer concrete file/line references when available.\n- If there are no substantive issues, say that clearly and mention residual risks or test gaps."
32
30
  },
33
31
  {
34
32
  "kind": "slot",
@@ -58,20 +56,6 @@
58
56
  "role": "system",
59
57
  "slot": "date-cwd"
60
58
  },
61
- {
62
- "kind": "slot",
63
- "id": "variables",
64
- "name": "Review Variables",
65
- "enabled": true,
66
- "role": "system",
67
- "slot": "variables",
68
- "options": {
69
- "includeStatic": true,
70
- "includeSession": true,
71
- "includeTurn": false,
72
- "format": "plain"
73
- }
74
- },
75
59
  {
76
60
  "kind": "block",
77
61
  "id": "history-open",
@@ -109,7 +93,12 @@
109
93
  "name": "Current Review Target",
110
94
  "enabled": true,
111
95
  "role": "user",
112
- "content": "<review_target>\n{{lastUserMessage}}\n</review_target>\n\nReview this target now. Lead with findings, ordered by severity. Limit yourself to the most important {{max_findings}} findings unless the target asks for exhaustive review. Use this format:\n\nFindings:\n- [severity] file:line - issue, impact, and suggested fix.\n\nOpen questions:\n- List only questions that materially affect the review.\n\nIf no findings are present, write \"No blocking findings\" and then summarize remaining test or operational risk."
96
+ "content": "<review_target>\n{{ runtime.lastUserMessage }}\n</review_target>\n\nReview this target now. Lead with findings, ordered by severity. Limit yourself to the most important {{ parameters.max_findings }} findings unless the target asks for exhaustive review. Use this format:\n\nFindings:\n- [severity] file:line - issue, impact, and suggested fix.\n\nOpen questions:\n- List only questions that materially affect the review.\n\nIf no findings are present, write \"No blocking findings\" and then summarize remaining test or operational risk."
113
97
  }
114
- ]
98
+ ],
99
+ "parameters": {
100
+ "review_focus": "correctness, regressions, security, maintainability, and missing tests",
101
+ "review_style": "findings first, ordered by severity",
102
+ "max_findings": "8"
103
+ }
115
104
  }
package/package.json CHANGED
@@ -1,122 +1,103 @@
1
1
  {
2
- "name": "@zihanw/pi-forge",
3
- "version": "0.4.0",
4
- "description": "Pi extension for prompt stacks, one-shot agent profiles, policy, import, and debugging.",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/MacroSony/pi-forge.git"
8
- },
9
- "type": "module",
10
- "exports": {
11
- ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js",
14
- "default": "./dist/index.js"
15
- },
16
- "./subagent": {
17
- "types": "./dist/subagent/index.d.ts",
18
- "import": "./dist/subagent/index.js",
19
- "default": "./dist/subagent/index.js"
20
- },
21
- "./src/*.ts": {
22
- "types": "./dist/*.d.ts",
23
- "import": "./dist/*.js",
24
- "default": "./dist/*.js"
25
- },
26
- "./src/*.js": {
27
- "types": "./dist/*.d.ts",
28
- "import": "./dist/*.js",
29
- "default": "./dist/*.js"
30
- },
31
- "./src/*": {
32
- "types": "./dist/*.d.ts",
33
- "import": "./dist/*.js",
34
- "default": "./dist/*.js"
35
- },
36
- "./src/web-editor/client/*": null,
37
- "./examples/*": "./examples/*"
38
- },
39
- "keywords": [
40
- "pi-package",
41
- "pi-extension",
42
- "prompt-stack",
43
- "agent-profile"
44
- ],
45
- "license": "MIT",
46
- "engines": {
47
- "node": ">=22.19.0"
48
- },
49
- "pi": {
50
- "extensions": [
51
- "./dist/index.js"
52
- ]
53
- },
54
- "peerDependencies": {
55
- "@earendil-works/pi-agent-core": "*",
56
- "@earendil-works/pi-ai": "*",
57
- "@earendil-works/pi-coding-agent": "*",
58
- "@earendil-works/pi-tui": "*",
59
- "typebox": "*"
60
- },
61
- "peerDependenciesMeta": {
62
- "@earendil-works/pi-agent-core": {
63
- "optional": true
64
- },
65
- "@earendil-works/pi-ai": {
66
- "optional": true
67
- },
68
- "@earendil-works/pi-coding-agent": {
69
- "optional": true
70
- },
71
- "@earendil-works/pi-tui": {
72
- "optional": true
73
- },
74
- "typebox": {
75
- "optional": true
76
- }
77
- },
78
- "dependencies": {
79
- "@zihanw/pi-subagent-runtime": "0.1.0-beta.2"
80
- },
81
- "devDependencies": {
82
- "@earendil-works/pi-agent-core": "0.83.0",
83
- "@earendil-works/pi-ai": "0.83.0",
84
- "@earendil-works/pi-coding-agent": "0.83.0",
85
- "@earendil-works/pi-tui": "0.83.0",
86
- "@types/node": "22.20.1",
87
- "@vitejs/plugin-vue": "6.0.8",
88
- "playwright-core": "1.61.1",
89
- "typebox": "1.3.7",
90
- "typescript": "6.0.3",
91
- "vite": "8.1.5",
92
- "vue": "3.5.40",
93
- "vue-tsc": "3.3.8"
94
- },
95
- "scripts": {
96
- "build": "npm run build:client && tsc -p tsconfig.build.json",
97
- "build:client": "node scripts/build-web-client.mjs",
98
- "check:client": "node scripts/build-web-client.mjs --check",
99
- "check:docs": "node scripts/check-docs.mjs",
100
- "check:dist": "node scripts/check-dist.mjs",
101
- "check:package": "node scripts/check-package.mjs",
102
- "prepack": "npm run build",
103
- "typecheck": "tsc --noEmit && vue-tsc --noEmit -p tsconfig.web.json",
104
- "test": "node --test tests/*.test.ts",
105
- "test:browser": "node --test tests-browser/*.test.ts",
106
- "verify": "npm test && npm run test:browser && npm run typecheck && npm run check:client && npm run check:docs && npm run check:dist && npm run check:package"
107
- },
108
- "files": [
109
- "dist/",
110
- "docs/",
111
- "examples/",
112
- "README.md",
113
- "README.zh-CN.md",
114
- "CHANGELOG.md",
115
- "SUBAGENT_ADAPTER_CONTRACT.md",
116
- "PUBLIC_API.md",
117
- "LICENSE*"
118
- ],
119
- "publishConfig": {
120
- "access": "public"
121
- }
2
+ "name": "@zihanw/pi-forge",
3
+ "version": "0.5.0",
4
+ "description": "Pi extension for prompt stacks, one-shot agent profiles, policy, import, and debugging.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/MacroSony/pi-forge.git"
8
+ },
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "./subagent": {
17
+ "types": "./dist/subagent/index.d.ts",
18
+ "import": "./dist/subagent/index.js",
19
+ "default": "./dist/subagent/index.js"
20
+ }
21
+ },
22
+ "keywords": [
23
+ "pi-package",
24
+ "pi-extension",
25
+ "prompt-stack",
26
+ "agent-profile"
27
+ ],
28
+ "license": "MIT",
29
+ "engines": {
30
+ "node": ">=22.19.0"
31
+ },
32
+ "pi": {
33
+ "extensions": [
34
+ "./dist/index.js"
35
+ ]
36
+ },
37
+ "peerDependencies": {
38
+ "@earendil-works/pi-agent-core": "*",
39
+ "@earendil-works/pi-ai": "*",
40
+ "@earendil-works/pi-coding-agent": "*",
41
+ "@earendil-works/pi-tui": "*",
42
+ "typebox": "*"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "@earendil-works/pi-agent-core": {
46
+ "optional": true
47
+ },
48
+ "@earendil-works/pi-ai": {
49
+ "optional": true
50
+ },
51
+ "@earendil-works/pi-coding-agent": {
52
+ "optional": true
53
+ },
54
+ "@earendil-works/pi-tui": {
55
+ "optional": true
56
+ },
57
+ "typebox": {
58
+ "optional": true
59
+ }
60
+ },
61
+ "devDependencies": {
62
+ "@earendil-works/pi-agent-core": "0.84.2",
63
+ "@earendil-works/pi-ai": "0.84.2",
64
+ "@earendil-works/pi-coding-agent": "0.84.2",
65
+ "@earendil-works/pi-tui": "0.84.2",
66
+ "@types/node": "22.20.1",
67
+ "@vitejs/plugin-vue": "6.0.8",
68
+ "playwright-core": "1.61.1",
69
+ "typebox": "1.3.7",
70
+ "typescript": "6.0.3",
71
+ "vite": "8.1.5",
72
+ "vue": "3.5.40",
73
+ "vue-tsc": "3.3.8"
74
+ },
75
+ "scripts": {
76
+ "build": "npm run build:client && tsc -p tsconfig.build.json",
77
+ "build:client": "node scripts/build-web-client.mjs",
78
+ "check:client": "node scripts/build-web-client.mjs --check",
79
+ "check:docs": "node scripts/check-docs.mjs",
80
+ "check:dist": "node scripts/check-dist.mjs",
81
+ "check:package": "node scripts/check-package.mjs",
82
+ "prepack": "npm run build",
83
+ "typecheck": "tsc --noEmit && vue-tsc --noEmit -p tsconfig.web.json",
84
+ "test": "node --test tests/*.test.ts",
85
+ "test:browser": "node --test --test-concurrency=1 tests-browser/*.test.ts",
86
+ "verify": "npm test && npm run test:browser && npm run typecheck && npm run check:client && npm run check:docs && npm run check:dist && npm run check:package && npm run check:packed",
87
+ "check:packed": "node scripts/check-packed-install.mjs"
88
+ },
89
+ "files": [
90
+ "dist/",
91
+ "docs/",
92
+ "examples/",
93
+ "README.md",
94
+ "README.zh-CN.md",
95
+ "CHANGELOG.md",
96
+ "SUBAGENT_ADAPTER_CONTRACT.md",
97
+ "PUBLIC_API.md",
98
+ "LICENSE*"
99
+ ],
100
+ "publishConfig": {
101
+ "access": "public"
102
+ }
122
103
  }
@@ -1,45 +0,0 @@
1
- import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import { type PiSubprocessBackendOptions, type PiSubprocessRunReport } from "@zihanw/pi-subagent-runtime/backends/subprocess";
3
- import { type PiRpcBackendOptions } from "@zihanw/pi-subagent-runtime/backends/rpc";
4
- import type { PiForgeRuntimeState } from "../runtime-state.ts";
5
- import { type AgentExecutionPlan, type AgentRequest, type AgentResponse, type BackendPreflightAccepted, type SubagentBackendDescriptor, type SubagentDiagnostic } from "../subagent/contract.ts";
6
- export interface ForgeSubagentPreparedRun {
7
- request: AgentRequest;
8
- preflight: BackendPreflightAccepted;
9
- plan: AgentExecutionPlan;
10
- diagnostics: SubagentDiagnostic[];
11
- }
12
- export type ForgeSubagentPreparationResult = {
13
- ok: true;
14
- prepared: ForgeSubagentPreparedRun;
15
- } | {
16
- ok: false;
17
- diagnostics: SubagentDiagnostic[];
18
- };
19
- /** Host-facing execution update; phases match the runtime's run events. */
20
- export interface SubagentBackendExecutionUpdate {
21
- phase: "starting" | "message" | "tool-result" | "finishing";
22
- message: string;
23
- details?: unknown;
24
- }
25
- export interface ForgeSubagentRuntime {
26
- /** Registered backend IDs, known without an extension context. */
27
- backendIds(): string[];
28
- descriptors(ctx: ExtensionContext): SubagentBackendDescriptor[];
29
- prepare(profileId: string, task: string, ctx: ExtensionContext, run?: {
30
- backendId?: string;
31
- timeoutMs?: number;
32
- }): Promise<ForgeSubagentPreparationResult>;
33
- discard(prepared: ForgeSubagentPreparedRun): Promise<void>;
34
- execute(prepared: ForgeSubagentPreparedRun, ctx: ExtensionContext, signal?: AbortSignal, onUpdate?: (update: SubagentBackendExecutionUpdate) => void): Promise<AgentResponse>;
35
- takeReport?(runId: string): PiSubprocessRunReport | undefined;
36
- dispose(): Promise<void>;
37
- }
38
- export interface ForgeSubagentRuntimeOptions {
39
- /** Backend that executes prepared runs; defaults to the subprocess backend. */
40
- backendId?: string;
41
- subprocess?: Omit<PiSubprocessBackendOptions, "modelRegistry" | "cwd">;
42
- rpc?: Omit<PiRpcBackendOptions, "modelRegistry" | "cwd">;
43
- }
44
- export declare function createForgeSubagentRuntime(state: PiForgeRuntimeState, options?: ForgeSubagentRuntimeOptions): ForgeSubagentRuntime;
45
- //# sourceMappingURL=subagent-runtime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subagent-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/subagent-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,iCAAiC,CAAC;AAWvF,OAAO,EAGN,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAEN,KAAK,mBAAmB,EACxB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ/D,OAAO,EAKN,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EAGvB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,WAAW,wBAAwB;IACxC,OAAO,EAAE,YAAY,CAAC;IACtB,SAAS,EAAE,wBAAwB,CAAC;IACpC,IAAI,EAAE,kBAAkB,CAAC;IACzB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAED,MAAM,MAAM,8BAA8B,GACvC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,wBAAwB,CAAA;CAAE,GAChD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,WAAW,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAAC;AAEpD,2EAA2E;AAC3E,MAAM,WAAW,8BAA8B;IAC9C,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACpC,kEAAkE;IAClE,UAAU,IAAI,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,GAAG,EAAE,gBAAgB,GAAG,yBAAyB,EAAE,CAAC;IAChE,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC3J,OAAO,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,OAAO,CAAC,QAAQ,EAAE,wBAAwB,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,8BAA8B,KAAK,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9K,UAAU,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAAC;IAC9D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAOD,MAAM,WAAW,2BAA2B;IAC3C,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,IAAI,CAAC,0BAA0B,EAAE,eAAe,GAAG,KAAK,CAAC,CAAC;IACvE,GAAG,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,GAAG,KAAK,CAAC,CAAC;CACzD;AAeD,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,2BAAgC,GACvC,oBAAoB,CA4MtB"}