@pikku/cli 0.12.100 → 0.12.102

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 (246) hide show
  1. package/console-app/assets/{abnfDiagram-VRR7QNED-Icjp9hnB.js → abnfDiagram-VRR7QNED-BneJZPuq.js} +1 -1
  2. package/console-app/assets/{arc-BfGls--L.js → arc-B6oXAx95.js} +1 -1
  3. package/console-app/assets/architecture-TIHT7OUA-BIpQbDwm.js +1 -0
  4. package/console-app/assets/{architectureDiagram-ZJ3FMSHR-CpnsLBns.js → architectureDiagram-ZJ3FMSHR-Dn6JKcGL.js} +1 -1
  5. package/console-app/assets/{blockDiagram-677ZJIJ3-ByKRMGSr.js → blockDiagram-677ZJIJ3-CQtakjN5.js} +1 -1
  6. package/console-app/assets/{c4Diagram-LMCZKHZV-CzJSbsUo.js → c4Diagram-LMCZKHZV-DRBlz-sO.js} +1 -1
  7. package/console-app/assets/channel-D9eZ2wja.js +1 -0
  8. package/console-app/assets/{chunk-32BRIVSS-D_tc4HCY.js → chunk-32BRIVSS-DIionvWe.js} +1 -1
  9. package/console-app/assets/{chunk-52WLFC77-wkQkuUXG.js → chunk-52WLFC77-DwrMMV53.js} +1 -1
  10. package/console-app/assets/{chunk-C7G6YPKG-BFW3xG3R.js → chunk-C7G6YPKG-C7_SHoee.js} +1 -1
  11. package/console-app/assets/{chunk-EX3LRPZG-Car090Sw.js → chunk-EX3LRPZG-Brqi3de0.js} +1 -1
  12. package/console-app/assets/{chunk-FWX5IMBZ-c2ud9kQ-.js → chunk-FWX5IMBZ-CGXYdLJv.js} +2 -2
  13. package/console-app/assets/{chunk-HOUHSVGY-RYmQka5R.js → chunk-HOUHSVGY-C-mHnXIa.js} +1 -1
  14. package/console-app/assets/{chunk-ICXQ74PX-C-dqYC_9.js → chunk-ICXQ74PX-x3psPzuY.js} +1 -1
  15. package/console-app/assets/{chunk-MOJQB5TN-Cu3FUWwl.js → chunk-MOJQB5TN-2uXUItkq.js} +1 -1
  16. package/console-app/assets/{chunk-OGEWGWER-Z7f1yArD.js → chunk-OGEWGWER-eXRvfFkE.js} +1 -1
  17. package/console-app/assets/{chunk-PUDLZKDR-Bp68DuRj.js → chunk-PUDLZKDR-CyN33Wwe.js} +1 -1
  18. package/console-app/assets/{chunk-Q4XR5HBZ-CdKSYWZ4.js → chunk-Q4XR5HBZ-uyzxeIyh.js} +1 -1
  19. package/console-app/assets/{chunk-RYQCIY6F-9ISCAKm2.js → chunk-RYQCIY6F-CB9wv1YB.js} +1 -1
  20. package/console-app/assets/{chunk-V7JOEXUC-2EOc1nQB.js → chunk-V7JOEXUC-DLMzjIkb.js} +1 -1
  21. package/console-app/assets/chunk-VAUOI2AC--YVrsYCZ.js +1 -0
  22. package/console-app/assets/{chunk-VR4S4FIN-BPvN0PUm.js → chunk-VR4S4FIN-DtBvdHYI.js} +1 -1
  23. package/console-app/assets/{chunk-WYO6CB5R-DOpurCTP.js → chunk-WYO6CB5R-B_EVxwHf.js} +1 -1
  24. package/console-app/assets/chunk-XXDRQBXY-By-5aH9h.js +1 -0
  25. package/console-app/assets/{chunk-ZGVPDNZ5-Bu2weVOL.js → chunk-ZGVPDNZ5-CGfMGxHR.js} +1 -1
  26. package/console-app/assets/classDiagram-OUVF2IWQ-Bg6U871E.js +1 -0
  27. package/console-app/assets/classDiagram-v2-EOCWNBFH-Bg6U871E.js +1 -0
  28. package/console-app/assets/{cose-bilkent-JH36ORCC-nau-QGCX.js → cose-bilkent-JH36ORCC-B_3kCkWC.js} +1 -1
  29. package/console-app/assets/{cynefin-VYW2F7L2-BBw-E7lg.js → cynefin-VYW2F7L2-Buqf60VA.js} +1 -1
  30. package/console-app/assets/{cynefinDiagram-TSTJHNR4-BvnMvOvH.js → cynefinDiagram-TSTJHNR4-DOjw2x6X.js} +1 -1
  31. package/console-app/assets/{dagre-VKFMJZFB-CHEqPR29.js → dagre-VKFMJZFB-CTZTYT0b.js} +1 -1
  32. package/console-app/assets/{diagram-FQU43EPY-JijKRWyb.js → diagram-FQU43EPY-BZh4LC_G.js} +1 -1
  33. package/console-app/assets/{diagram-G47NLZAW-G5UsB31f.js → diagram-G47NLZAW-DDHD69gC.js} +1 -1
  34. package/console-app/assets/{diagram-NH7WQ7WH-BhuJ6fPu.js → diagram-NH7WQ7WH-YnfI_N0A.js} +1 -1
  35. package/console-app/assets/{diagram-OA4YK3LP-DaUF-8N4.js → diagram-OA4YK3LP-ByfLxp7x.js} +1 -1
  36. package/console-app/assets/{diagram-WEI45ONY-wLsJIhoM.js → diagram-WEI45ONY-CghNIRYp.js} +1 -1
  37. package/console-app/assets/{dist-fbBkbDNG.js → dist-DCLZxlZv.js} +1 -1
  38. package/console-app/assets/{ebnfDiagram-CCIWWBDH-BZCEa3Dz.js → ebnfDiagram-CCIWWBDH-D5_G_ZqU.js} +1 -1
  39. package/console-app/assets/{erDiagram-Q63AITRT-4XoEUtEh.js → erDiagram-Q63AITRT-B5ZtoDJs.js} +1 -1
  40. package/console-app/assets/eventmodeling-45OFAUF4-eU2Q2DYK.js +1 -0
  41. package/console-app/assets/flowDiagram-23GEKE2U-CtRJ8nYJ.js +1 -0
  42. package/console-app/assets/{ganttDiagram-NO4QXBWP-BXU7pfq6.js → ganttDiagram-NO4QXBWP-R-TggPMB.js} +1 -1
  43. package/console-app/assets/{gitGraph-TEB2WS4Q-BdMAmvpU.js → gitGraph-TEB2WS4Q-Cjhl-pwb.js} +1 -1
  44. package/console-app/assets/{gitGraphDiagram-IHSO6WYX-3Hn0zwZR.js → gitGraphDiagram-IHSO6WYX-DnQe5wWr.js} +1 -1
  45. package/console-app/assets/{index-Din2vBeb.js → index-BZTTf18Y.js} +150 -150
  46. package/console-app/assets/{index-BXMjqLQ5.css → index-r763CZB4.css} +1 -1
  47. package/console-app/assets/{info-DKCQHKI2-Dc_oQkp5.js → info-DKCQHKI2-DlSWT4UP.js} +1 -1
  48. package/console-app/assets/{infoDiagram-FWYZ7A6U-B3v4xCUn.js → infoDiagram-FWYZ7A6U-xqpfzGnj.js} +1 -1
  49. package/console-app/assets/{ishikawaDiagram-FXEZZL3T-DzWq9Vtp.js → ishikawaDiagram-FXEZZL3T-M_pUeGWs.js} +1 -1
  50. package/console-app/assets/{journeyDiagram-5HDEW3XC-C0buWi_a.js → journeyDiagram-5HDEW3XC-Dm6FR2DD.js} +1 -1
  51. package/console-app/assets/{kanban-definition-HUTT4EX6-DRAN9HhV.js → kanban-definition-HUTT4EX6-CbhkDdQH.js} +1 -1
  52. package/console-app/assets/{line-UqgRNiAC.js → line-C98Z2IVv.js} +1 -1
  53. package/console-app/assets/{linear-FTAGuk_3.js → linear-fYIkDCbB.js} +1 -1
  54. package/console-app/assets/{mermaid-parser.core-DIHI27FL.js → mermaid-parser.core-Dkioi2z2.js} +3 -3
  55. package/console-app/assets/{mermaid.core-D4q8kvcu.js → mermaid.core-CeJcbw8_.js} +3 -3
  56. package/console-app/assets/{mindmap-definition-LN4V7U3C-DN-_CNLb.js → mindmap-definition-LN4V7U3C-DDitGESW.js} +1 -1
  57. package/console-app/assets/{packet-7NZHBO7P-8a3PoQAb.js → packet-7NZHBO7P-DWZKJ9Us.js} +1 -1
  58. package/console-app/assets/{pegDiagram-2B236MQR-Bh2MhzCN.js → pegDiagram-2B236MQR-CZGjPLXH.js} +1 -1
  59. package/console-app/assets/{pie-RZYD4A2V-Bi6zbJDl.js → pie-RZYD4A2V-DT4-E-uE.js} +1 -1
  60. package/console-app/assets/{pieDiagram-ENE6RG2P-D2Z0W5UU.js → pieDiagram-ENE6RG2P-bgr82Jyt.js} +1 -1
  61. package/console-app/assets/{quadrantDiagram-ABIIQ3AL-DNOKka0p.js → quadrantDiagram-ABIIQ3AL-Dcw3uNG0.js} +1 -1
  62. package/console-app/assets/{radar-I7S5WNFK-CAxa68Sg.js → radar-I7S5WNFK-CFAbRVFk.js} +1 -1
  63. package/console-app/assets/{railroad-3IZDKUUU-CZb1usP7.js → railroad-3IZDKUUU-CjkCoEjH.js} +1 -1
  64. package/console-app/assets/railroad-abnf-AHOZXSZD-BM21cj3I.js +1 -0
  65. package/console-app/assets/railroad-ebnf-EBAXGLYW-CDjo5TUI.js +1 -0
  66. package/console-app/assets/railroad-peg-LSFZ7HO6-CiKQmfgW.js +1 -0
  67. package/console-app/assets/{railroadDiagram-RFXS5EU6-B1K2hbTD.js → railroadDiagram-RFXS5EU6-BUoL0dsw.js} +1 -1
  68. package/console-app/assets/{requirementDiagram-TGXJPOKE-K8wcOO0Q.js → requirementDiagram-TGXJPOKE-C27qMKlr.js} +1 -1
  69. package/console-app/assets/{sankeyDiagram-HTMAVEWB-WBPBkgNx.js → sankeyDiagram-HTMAVEWB-BYEhrrY0.js} +1 -1
  70. package/console-app/assets/{sequenceDiagram-DBY2YBRQ-Dz80qZZv.js → sequenceDiagram-DBY2YBRQ-BCuL4Pl6.js} +1 -1
  71. package/console-app/assets/{src-CnJCXDL0.js → src-jNbD6Nj3.js} +1 -1
  72. package/console-app/assets/{stateDiagram-2N3HPSRC-DMur7lZf.js → stateDiagram-2N3HPSRC-C8Ywa3Ah.js} +1 -1
  73. package/console-app/assets/stateDiagram-v2-6OUMAXLB-BIGwMDyj.js +1 -0
  74. package/console-app/assets/{swimlanes-5IMT3BWC-BlLdYcPU.js → swimlanes-5IMT3BWC-C12iYfdp.js} +1 -1
  75. package/console-app/assets/swimlanesDiagram-G3AALYLV-BsoUfqN-.js +8 -0
  76. package/console-app/assets/{timeline-definition-FHXFAJF6-CBOit0JY.js → timeline-definition-FHXFAJF6-BFQotHp7.js} +1 -1
  77. package/console-app/assets/{treeView-QDETBFTQ-DM1i1ast.js → treeView-QDETBFTQ-CGbwDLTd.js} +1 -1
  78. package/console-app/assets/{treemap-6X3UGDF4-ACrBEfY6.js → treemap-6X3UGDF4-DxSGskiF.js} +1 -1
  79. package/console-app/assets/{vennDiagram-L72KCM5P-BmeFWb5N.js → vennDiagram-L72KCM5P-D4hlUYc9.js} +1 -1
  80. package/console-app/assets/{wardley-OPB4EBWU-BpIbeh58.js → wardley-OPB4EBWU-XlXl32Vn.js} +1 -1
  81. package/console-app/assets/{wardleyDiagram-EHGQE667-CxL7Mv7y.js → wardleyDiagram-EHGQE667-ttCeFzYx.js} +1 -1
  82. package/console-app/assets/{xychartDiagram-FW5EYKEG-DkV75xT2.js → xychartDiagram-FW5EYKEG-BMG4kbfv.js} +1 -1
  83. package/console-app/index.html +2 -2
  84. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +6 -2
  85. package/dist/.pikku/agent/pikku-agent-types.gen.js +3 -0
  86. package/dist/.pikku/agent/pikku-model-aliases.gen.d.ts +1 -0
  87. package/dist/.pikku/agent/pikku-model-aliases.gen.js +5 -0
  88. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
  89. package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
  90. package/dist/.pikku/cli/pikku-cli-channel.js +13 -8
  91. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
  92. package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
  93. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
  94. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
  95. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  96. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  97. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
  98. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +18 -12
  99. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  100. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  101. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  102. package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
  103. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  104. package/dist/.pikku/function/pikku-function-types.gen.d.ts +6 -25
  105. package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
  106. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  107. package/dist/.pikku/function/pikku-functions-meta.gen.json +51 -27
  108. package/dist/.pikku/function/pikku-functions.gen.js +3 -1
  109. package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
  110. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  111. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
  112. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
  113. package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +1 -1
  114. package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +1 -1
  115. package/dist/.pikku/pikku-bootstrap.gen.d.ts +2 -1
  116. package/dist/.pikku/pikku-bootstrap.gen.js +2 -1
  117. package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
  118. package/dist/.pikku/pikku-meta-service.gen.js +1 -1
  119. package/dist/.pikku/pikku-services.gen.d.ts +1 -1
  120. package/dist/.pikku/pikku-types.gen.d.ts +1 -1
  121. package/dist/.pikku/pikku-types.gen.js +1 -1
  122. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  123. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  124. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
  125. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  126. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  127. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
  128. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +2 -1
  129. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +1 -1
  130. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
  131. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +1 -1
  132. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
  133. package/dist/.pikku/scenarios/schemas/register.gen.d.ts +1 -1
  134. package/dist/.pikku/scenarios/schemas/register.gen.js +1 -1
  135. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  136. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  137. package/dist/.pikku/schemas/register.gen.js +7 -5
  138. package/dist/.pikku/schemas/schemas/DevInput.schema.json +1 -1
  139. package/dist/.pikku/schemas/schemas/PikkuAIScorerOutput.schema.json +1 -0
  140. package/dist/.pikku/schemas/schemas/ServeInput.schema.json +1 -1
  141. package/dist/.pikku/schemas/schemas/ValidateOutput.schema.json +1 -0
  142. package/dist/.pikku/scopes/pikku-personas.gen.js +1 -1
  143. package/dist/.pikku/scopes/pikku-roles.gen.d.ts +1 -1
  144. package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
  145. package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
  146. package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
  147. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
  148. package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
  149. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  150. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  151. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  152. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  153. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
  154. package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
  155. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  156. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  157. package/dist/.pikku/workflow/meta/allWorkflow.gen.json +8 -2
  158. package/dist/.pikku/workflow/pikku-personas.gen.js +1 -1
  159. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +9 -17
  160. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
  161. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  162. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  163. package/dist/bin/pikku-bin.mjs +2 -2
  164. package/dist/src/cli.wiring.js +20 -11
  165. package/dist/src/deploy/analyzer/analyzer.js +21 -0
  166. package/dist/src/deploy/analyzer/manifest.d.ts +18 -0
  167. package/dist/src/fabric/functions/smoke.function.js +7 -4
  168. package/dist/src/fabric/functions/validate.function.js +1 -1
  169. package/dist/src/functions/commands/db-export.js +1 -1
  170. package/dist/src/functions/commands/db-shared.d.ts +0 -14
  171. package/dist/src/functions/commands/dev.d.ts +3 -0
  172. package/dist/src/functions/commands/dev.js +41 -2
  173. package/dist/src/functions/commands/knowledge-index.d.ts +3 -3
  174. package/dist/src/functions/commands/new-addon.js +6 -3
  175. package/dist/src/functions/commands/scenario-browser.d.ts +24 -1
  176. package/dist/src/functions/commands/scenario-browser.js +5 -1
  177. package/dist/src/functions/commands/scenario.d.ts +6 -0
  178. package/dist/src/functions/commands/scenario.js +26 -5
  179. package/dist/src/functions/commands/serve.d.ts +3 -0
  180. package/dist/src/functions/commands/serve.js +15 -1
  181. package/dist/src/functions/commands/{workspace-validate.d.ts → validate.d.ts} +18 -3
  182. package/dist/src/functions/commands/validate.js +9 -0
  183. package/dist/src/functions/db/local-db.d.ts +2 -1
  184. package/dist/src/functions/db/local-db.js +2 -2
  185. package/dist/src/functions/validate/addon-package-checks.d.ts +26 -0
  186. package/dist/src/functions/validate/addon-package-checks.js +258 -0
  187. package/dist/src/functions/validate/persona-checks.d.ts +1 -1
  188. package/dist/src/functions/validate/persona-checks.js +1 -1
  189. package/dist/src/functions/validate/scenario-file-checks.js +33 -0
  190. package/dist/src/functions/validate/shared-checks.d.ts +1 -1
  191. package/dist/src/functions/validate/shared-checks.js +1 -1
  192. package/dist/src/functions/validate/validate-registry.d.ts +52 -0
  193. package/dist/src/functions/validate/validate-registry.js +100 -0
  194. package/dist/src/functions/validate/validate.d.ts +47 -0
  195. package/dist/src/functions/validate/{workspace-validate.js → validate.js} +46 -12
  196. package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent-types.js +3 -2
  197. package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.js +5 -1
  198. package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.d.ts +1 -1
  199. package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.js +15 -2
  200. package/dist/src/functions/wirings/ai-agent/serialize-model-aliases.d.ts +5 -0
  201. package/dist/src/functions/wirings/ai-agent/serialize-model-aliases.js +12 -0
  202. package/dist/src/functions/wirings/ai-scorer/pikku-command-ai-scorer.d.ts +1 -0
  203. package/dist/src/functions/wirings/ai-scorer/pikku-command-ai-scorer.js +51 -0
  204. package/dist/src/functions/wirings/ai-scorer/serialize-scorer-names.d.ts +10 -0
  205. package/dist/src/functions/wirings/ai-scorer/serialize-scorer-names.js +17 -0
  206. package/dist/src/functions/wirings/auth/serialize-auth-gen.js +27 -10
  207. package/dist/src/functions/wirings/cli/serialize-channel-cli.js +9 -4
  208. package/dist/src/functions/wirings/console/serialize-console-functions.js +9 -56
  209. package/dist/src/functions/wirings/functions/serialize-function-types.js +7 -30
  210. package/dist/src/functions/wirings/middleware/serialize-middleware-imports.js +5 -1
  211. package/dist/src/functions/wirings/package/pikku-command-package.js +12 -1
  212. package/dist/src/functions/wirings/package/serialize-package.d.ts +1 -1
  213. package/dist/src/functions/wirings/package/serialize-package.js +5 -2
  214. package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +1 -6
  215. package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.js +30 -0
  216. package/dist/src/functions/wirings/workflow/serialize-workflow-routes.js +12 -4
  217. package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +8 -16
  218. package/dist/src/functions/workflows/all.workflow.js +6 -1
  219. package/dist/src/server/bun-server-runner.js +3 -0
  220. package/dist/src/server/dev-server-runner.interface.d.ts +10 -0
  221. package/dist/src/server/node-server-runner.js +3 -0
  222. package/dist/src/services.js +1 -0
  223. package/dist/src/utils/meta-diff.d.ts +1 -1
  224. package/dist/src/utils/meta-diff.js +2 -0
  225. package/dist/src/utils/model-alias-override.d.ts +7 -0
  226. package/dist/src/utils/model-alias-override.js +33 -0
  227. package/dist/src/utils/pikku-cli-config.js +16 -0
  228. package/dist/tsconfig.tsbuildinfo +1 -1
  229. package/package.json +17 -17
  230. package/console-app/assets/architecture-TIHT7OUA-C8l7I5Lm.js +0 -1
  231. package/console-app/assets/channel-BgJ-Z0cx.js +0 -1
  232. package/console-app/assets/chunk-VAUOI2AC-DwKsbf70.js +0 -1
  233. package/console-app/assets/chunk-XXDRQBXY-RuYSFsQb.js +0 -1
  234. package/console-app/assets/classDiagram-OUVF2IWQ-ohoLCI8g.js +0 -1
  235. package/console-app/assets/classDiagram-v2-EOCWNBFH-ohoLCI8g.js +0 -1
  236. package/console-app/assets/eventmodeling-45OFAUF4-DZ7z4YJO.js +0 -1
  237. package/console-app/assets/flowDiagram-23GEKE2U-rd7-NwZT.js +0 -1
  238. package/console-app/assets/railroad-abnf-AHOZXSZD-DkQZciri.js +0 -1
  239. package/console-app/assets/railroad-ebnf-EBAXGLYW-CPBeASA9.js +0 -1
  240. package/console-app/assets/railroad-peg-LSFZ7HO6-CXEVIZ0g.js +0 -1
  241. package/console-app/assets/stateDiagram-v2-6OUMAXLB-BDgLCrot.js +0 -1
  242. package/console-app/assets/swimlanesDiagram-G3AALYLV-CZ5rQIcE.js +0 -8
  243. package/dist/.pikku/schemas/schemas/WorkspaceValidateOutput.schema.json +0 -1
  244. package/dist/src/functions/commands/workspace-validate.js +0 -9
  245. package/dist/src/functions/validate/workspace-validate.d.ts +0 -33
  246. /package/dist/.pikku/schemas/schemas/{WorkspaceValidateInput.schema.json → ValidateInput.schema.json} +0 -0
@@ -0,0 +1,52 @@
1
+ import type { ValidateFinding as Finding } from './persona-checks.js';
2
+ export type ValidateTarget = {
3
+ /** Absolute directory the check runs against. */
4
+ dir: string;
5
+ /** How the target is named in output — repo-relative, or "." for the root. */
6
+ label: string;
7
+ };
8
+ /**
9
+ * A check plus the condition under which it means anything.
10
+ *
11
+ * `pikku validate` runs every check whose precondition holds, wherever it
12
+ * holds. It deliberately does not detect a project *kind* and then dispatch:
13
+ * the repos that motivated this are several kinds at once — the addons
14
+ * monorepo is a workspace containing 217 publishable addons — and any
15
+ * single-kind guess is wrong for them. Preconditions compose where a mode
16
+ * would have had to pick.
17
+ */
18
+ export type ValidateCheck = {
19
+ id: string;
20
+ /** What this check is for, shown when reporting what ran. */
21
+ subject: string;
22
+ applies: (target: ValidateTarget) => Promise<boolean>;
23
+ run: (target: ValidateTarget) => Promise<Finding[]>;
24
+ };
25
+ /**
26
+ * Every directory under `root` that holds a package.json.
27
+ *
28
+ * Walking beats reading the `workspaces` globs: the field is an array in one
29
+ * repo and `{ packages: [...] }` in the next, spells the same layout as
30
+ * `packages/**` or as six explicit globs, and a package that is real but
31
+ * unlisted is exactly the kind of thing worth validating. Over-collecting is
32
+ * harmless here because the preconditions decide what actually runs.
33
+ */
34
+ export declare function discoverTargets(root: string, maxDepth?: number): Promise<ValidateTarget[]>;
35
+ export declare const CHECKS: ValidateCheck[];
36
+ export type ValidationPlan = Array<{
37
+ check: ValidateCheck;
38
+ target: ValidateTarget;
39
+ }>;
40
+ export declare function planValidation(root: string): Promise<ValidationPlan>;
41
+ export type ValidateReport = {
42
+ ok: boolean;
43
+ root: string;
44
+ /** What ran, so a clean result can say what it actually looked at. */
45
+ ran: Array<{
46
+ checkId: string;
47
+ subject: string;
48
+ target: string;
49
+ }>;
50
+ findings: Finding[];
51
+ };
52
+ export declare function runValidate(root: string): Promise<ValidateReport>;
@@ -0,0 +1,100 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { readdir } from 'node:fs/promises';
3
+ import { join, relative } from 'node:path';
4
+ import { isAddonPackage, runAddonPackageChecks, } from './addon-package-checks.js';
5
+ import { runSharedProjectChecks } from './shared-checks.js';
6
+ /** A hand-written `types/application-types.d.ts` beside package.json. */
7
+ const ADDON_MARKER = join('types', 'application-types.d.ts');
8
+ const SKIP_DIRS = new Set([
9
+ 'node_modules',
10
+ '.git',
11
+ 'dist',
12
+ 'build',
13
+ '.pikku',
14
+ '.pikku-runtime',
15
+ 'coverage',
16
+ '.next',
17
+ '.yarn',
18
+ ]);
19
+ /**
20
+ * Every directory under `root` that holds a package.json.
21
+ *
22
+ * Walking beats reading the `workspaces` globs: the field is an array in one
23
+ * repo and `{ packages: [...] }` in the next, spells the same layout as
24
+ * `packages/**` or as six explicit globs, and a package that is real but
25
+ * unlisted is exactly the kind of thing worth validating. Over-collecting is
26
+ * harmless here because the preconditions decide what actually runs.
27
+ */
28
+ export async function discoverTargets(root, maxDepth = 5) {
29
+ const targets = [];
30
+ const visit = async (dir, depth) => {
31
+ if (existsSync(join(dir, 'package.json'))) {
32
+ targets.push({ dir, label: relative(root, dir) || '.' });
33
+ }
34
+ if (depth >= maxDepth)
35
+ return;
36
+ let entries;
37
+ try {
38
+ entries = await readdir(dir, { withFileTypes: true });
39
+ }
40
+ catch {
41
+ return;
42
+ }
43
+ for (const entry of entries) {
44
+ if (!entry.isDirectory())
45
+ continue;
46
+ if (entry.name.startsWith('.') || SKIP_DIRS.has(entry.name))
47
+ continue;
48
+ await visit(join(dir, entry.name), depth + 1);
49
+ }
50
+ };
51
+ await visit(root, 0);
52
+ return targets;
53
+ }
54
+ export const CHECKS = [
55
+ {
56
+ id: 'app-project',
57
+ subject: 'app project',
58
+ // An addon also carries a pikku.config.json, and running the app-shaped
59
+ // checks against one reports every app convention it has no reason to
60
+ // follow — starting with a packages/functions/ it will never have.
61
+ applies: async ({ dir }) => existsSync(join(dir, 'pikku.config.json')) &&
62
+ !existsSync(join(dir, ADDON_MARKER)),
63
+ run: async ({ dir }) => (await runSharedProjectChecks(dir)).findings,
64
+ },
65
+ {
66
+ id: 'addon-package',
67
+ subject: 'addon',
68
+ applies: async ({ dir }) => isAddonPackage(dir),
69
+ run: async ({ dir }) => runAddonPackageChecks(dir),
70
+ },
71
+ ];
72
+ export async function planValidation(root) {
73
+ const plan = [];
74
+ for (const target of await discoverTargets(root)) {
75
+ for (const check of CHECKS) {
76
+ if (await check.applies(target))
77
+ plan.push({ check, target });
78
+ }
79
+ }
80
+ return plan;
81
+ }
82
+ export async function runValidate(root) {
83
+ const plan = await planValidation(root);
84
+ const findings = [];
85
+ const ran = [];
86
+ for (const { check, target } of plan) {
87
+ findings.push(...(await check.run(target)));
88
+ ran.push({
89
+ checkId: check.id,
90
+ subject: check.subject,
91
+ target: target.label,
92
+ });
93
+ }
94
+ return {
95
+ ok: !findings.some((f) => f.severity === 'error'),
96
+ root,
97
+ ran,
98
+ findings,
99
+ };
100
+ }
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ export { readJsonSafe, readTextSafe } from './shared-checks.js';
3
+ export declare const FindingSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ severity: z.ZodEnum<{
6
+ warn: "warn";
7
+ error: "error";
8
+ info: "info";
9
+ }>;
10
+ message: z.ZodString;
11
+ path: z.ZodString;
12
+ fixHint: z.ZodString;
13
+ }, z.core.$strip>;
14
+ export type Finding = z.infer<typeof FindingSchema>;
15
+ export declare const ValidateInput: z.ZodObject<{}, z.core.$strip>;
16
+ export declare const ValidateOutput: z.ZodObject<{
17
+ ok: z.ZodBoolean;
18
+ root: z.ZodString;
19
+ ran: z.ZodArray<z.ZodObject<{
20
+ checkId: z.ZodString;
21
+ subject: z.ZodString;
22
+ target: z.ZodString;
23
+ }, z.core.$strip>>;
24
+ findings: z.ZodArray<z.ZodObject<{
25
+ id: z.ZodString;
26
+ severity: z.ZodEnum<{
27
+ warn: "warn";
28
+ error: "error";
29
+ info: "info";
30
+ }>;
31
+ message: z.ZodString;
32
+ path: z.ZodString;
33
+ fixHint: z.ZodString;
34
+ }, z.core.$strip>>;
35
+ }, z.core.$strip>;
36
+ /**
37
+ * The workspace root, or failing that the package the caller is standing in.
38
+ *
39
+ * A standalone publishable addon has no `workspaces` anywhere above it, and
40
+ * running from its `src/` would otherwise validate `src/` — a directory with no
41
+ * package.json, where every check's precondition is false and the run reports
42
+ * that nothing applied. The addon author is exactly who the addon checks are
43
+ * for, so the nearest package.json is the answer when no workspace claims it.
44
+ */
45
+ export declare function findProjectRoot(startDir: string): Promise<string>;
46
+ export declare function runProjectValidate(startDir?: string): Promise<z.infer<typeof ValidateOutput>>;
47
+ export declare const renderValidate: (_s: unknown, { ok, root, ran, findings }: z.infer<typeof ValidateOutput>) => void;
@@ -3,7 +3,7 @@ import { readFile } from 'node:fs/promises';
3
3
  import { dirname, join } from 'node:path';
4
4
  import { z } from 'zod';
5
5
  import { added, changed, dim, removed } from '../../fabric/lib/output.js';
6
- import { runSharedProjectChecks } from './shared-checks.js';
6
+ import { runValidate } from './validate-registry.js';
7
7
  export { readJsonSafe, readTextSafe } from './shared-checks.js';
8
8
  export const FindingSchema = z.object({
9
9
  id: z.string(),
@@ -12,16 +12,32 @@ export const FindingSchema = z.object({
12
12
  path: z.string(),
13
13
  fixHint: z.string(),
14
14
  });
15
- export const WorkspaceValidateInput = z.object({});
16
- export const WorkspaceValidateOutput = z.object({
15
+ export const ValidateInput = z.object({});
16
+ export const ValidateOutput = z.object({
17
17
  ok: z.boolean(),
18
18
  root: z.string(),
19
+ ran: z.array(z.object({
20
+ checkId: z.string(),
21
+ subject: z.string(),
22
+ target: z.string(),
23
+ })),
19
24
  findings: z.array(FindingSchema),
20
25
  });
26
+ /**
27
+ * The workspace root, or failing that the package the caller is standing in.
28
+ *
29
+ * A standalone publishable addon has no `workspaces` anywhere above it, and
30
+ * running from its `src/` would otherwise validate `src/` — a directory with no
31
+ * package.json, where every check's precondition is false and the run reports
32
+ * that nothing applied. The addon author is exactly who the addon checks are
33
+ * for, so the nearest package.json is the answer when no workspace claims it.
34
+ */
21
35
  export async function findProjectRoot(startDir) {
22
36
  let dir = startDir;
37
+ let nearestPackage;
23
38
  while (true) {
24
39
  if (existsSync(join(dir, 'package.json'))) {
40
+ nearestPackage ??= dir;
25
41
  try {
26
42
  const pkg = JSON.parse(await readFile(join(dir, 'package.json'), 'utf8'));
27
43
  if (pkg.workspaces)
@@ -33,19 +49,37 @@ export async function findProjectRoot(startDir) {
33
49
  }
34
50
  const parent = dirname(dir);
35
51
  if (parent === dir)
36
- return startDir;
52
+ return nearestPackage ?? startDir;
37
53
  dir = parent;
38
54
  }
39
55
  }
40
- export async function runWorkspaceValidate(startDir = process.cwd()) {
56
+ export async function runProjectValidate(startDir = process.cwd()) {
41
57
  const root = await findProjectRoot(startDir);
42
- const { findings } = await runSharedProjectChecks(root);
43
- const ok = !findings.some((f) => f.severity === 'error');
44
- return { ok, root, findings };
58
+ return runValidate(root);
45
59
  }
46
- export const renderWorkspaceValidate = (_s, { ok, root, findings }) => {
60
+ /** "2 addons, 1 app project" what the run actually looked at. */
61
+ function describeRan(ran) {
62
+ const bySubject = new Map();
63
+ for (const entry of ran) {
64
+ bySubject.set(entry.subject, (bySubject.get(entry.subject) ?? 0) + 1);
65
+ }
66
+ return [...bySubject]
67
+ .map(([subject, count]) => `${count} ${subject}${count === 1 ? '' : 's'}`)
68
+ .join(', ');
69
+ }
70
+ export const renderValidate = (_s, { ok, root, ran, findings }) => {
71
+ // A green tick for a run that checked nothing is the one outcome worth
72
+ // guarding against: auto-detection that finds nothing looks identical to
73
+ // auto-detection that found everything and liked it.
74
+ if (ran.length === 0) {
75
+ console.log(changed('⚠') +
76
+ ' ' +
77
+ 'Nothing to validate here — no app project and no publishable addon found');
78
+ console.log(` ${dim('fix:')} Run from a directory with a pikku.config.json, or from a package that publishes generated pikku output.`);
79
+ return;
80
+ }
47
81
  if (findings.length === 0) {
48
- console.log(added('✓ All checks passed — workspace is Pikku-compatible'));
82
+ console.log(added(`✓ All checks passed — checked ${describeRan(ran)}`));
49
83
  return;
50
84
  }
51
85
  const relPath = (p) => p.startsWith(root + '/') || p.startsWith(root + '\\')
@@ -76,9 +110,9 @@ export const renderWorkspaceValidate = (_s, { ok, root, findings }) => {
76
110
  counts.push(dim(`${infos.length} info${infos.length !== 1 ? 's' : ''}`));
77
111
  }
78
112
  console.log('─'.repeat(40));
79
- console.log(counts.join(' '));
113
+ console.log(`${counts.join(' ')} ${dim(`across ${describeRan(ran)}`)}`);
80
114
  if (ok) {
81
115
  console.log();
82
- console.log(added('✓') + ' ' + dim('no errors — workspace is structurally sound'));
116
+ console.log(added('✓') + ' ' + dim('no errors'));
83
117
  }
84
118
  };
@@ -5,11 +5,12 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
5
5
  import { serializeAIAgentTypes } from './serialize-ai-agent-types.js';
6
6
  export const pikkuAIAgentTypes = pikkuSessionlessFunc({
7
7
  func: async ({ logger, config }) => {
8
- const { agentTypesFile, functionTypesFile, agentMapDeclarationFile, scopesFile, packageMappings, } = config;
8
+ const { agentTypesFile, functionTypesFile, agentMapDeclarationFile, scorerNamesDeclarationFile, scopesFile, packageMappings, } = config;
9
9
  const functionTypesImportPath = getFileImportRelativePath(agentTypesFile, functionTypesFile, packageMappings);
10
10
  const agentMapImportPath = getFileImportRelativePath(agentTypesFile, agentMapDeclarationFile, packageMappings);
11
11
  const scopesImportPath = getFileImportRelativePath(agentTypesFile, scopesFile, packageMappings);
12
- const content = serializeAIAgentTypes(functionTypesImportPath, agentMapImportPath, scopesImportPath);
12
+ const scorerNamesImportPath = getFileImportRelativePath(agentTypesFile, scorerNamesDeclarationFile, packageMappings);
13
+ const content = serializeAIAgentTypes(functionTypesImportPath, agentMapImportPath, scopesImportPath, scorerNamesImportPath);
13
14
  await writeFileInDir(logger, agentTypesFile, content);
14
15
  },
15
16
  middleware: [
@@ -4,11 +4,15 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
4
4
  import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
5
5
  import { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
6
6
  import { serializeAgentMap } from './serialize-agent-map.js';
7
+ import { serializeModelAliases } from './serialize-model-aliases.js';
7
8
  export const pikkuAIAgent = pikkuSessionlessFunc({
8
9
  func: async ({ logger, config, getInspectorState }) => {
9
10
  const { agents, functions } = await getInspectorState();
10
- const { agentWiringsFile, agentWiringMetaFile, agentWiringMetaJsonFile, agentMapDeclarationFile, packageMappings, schema, addonName, } = config;
11
+ const { agentWiringsFile, agentWiringMetaFile, agentWiringMetaJsonFile, agentMapDeclarationFile, modelAliasesFile, packageMappings, schema, addonName, models, } = config;
11
12
  const agentFiles = agents.files;
13
+ // Written even with no agents: the image/speech/embedding runner methods
14
+ // take a model too.
15
+ await writeFileInDir(logger, modelAliasesFile, serializeModelAliases(models, addonName ?? null));
12
16
  if (agentFiles.size === 0 || Object.keys(agents.agentsMeta).length === 0) {
13
17
  // Still need to generate an empty agent map for the types import
14
18
  await writeFileInDir(logger, agentMapDeclarationFile, `export type AgentMap = {}\n`);
@@ -1 +1 @@
1
- export declare const serializeAIAgentTypes: (functionTypesImportPath: string, agentMapImportPath: string, scopesImportPath: string) => string;
1
+ export declare const serializeAIAgentTypes: (functionTypesImportPath: string, agentMapImportPath: string, scopesImportPath: string, scorerNamesImportPath: string) => string;
@@ -1,4 +1,4 @@
1
- export const serializeAIAgentTypes = (functionTypesImportPath, agentMapImportPath, scopesImportPath) => {
1
+ export const serializeAIAgentTypes = (functionTypesImportPath, agentMapImportPath, scopesImportPath, scorerNamesImportPath) => {
2
2
  return `import {
3
3
  CoreAIAgent,
4
4
  PikkuAIMiddlewareHooks,
@@ -9,16 +9,21 @@ import {
9
9
  agentResume as coreAgentResume,
10
10
  agentApprove as coreAgentApprove,
11
11
  } from '@pikku/core/ai-agent'
12
+ import {
13
+ pikkuAIScorer as corePikkuAIScorer,
14
+ pikkuAIJudge as corePikkuAIJudge,
15
+ } from '@pikku/core/ai-scorer'
12
16
  import type { PikkuPermission, PikkuMiddleware, Services, PikkuFunctionConfig } from '${functionTypesImportPath}'
13
17
  import type { StandardSchemaV1 } from '@standard-schema/spec'
14
18
  import type { AIAgentMemoryConfig, AIAgentInput } from '@pikku/core/ai-agent'
15
19
  import type { AgentMap } from '${agentMapImportPath}'
16
20
  import type { ScopeId } from '${scopesImportPath}'
21
+ import type { ScorerName } from '${scorerNamesImportPath}'
17
22
 
18
23
  type AIAgentConfig<
19
24
  InputSchema extends StandardSchemaV1 | undefined = undefined,
20
25
  OutputSchema extends StandardSchemaV1 | undefined = undefined
21
- > = Omit<CoreAIAgent<PikkuPermission, PikkuMiddleware, ScopeId>, 'tools' | 'agents' | 'workflows' | 'memory' | 'input' | 'output'> & {
26
+ > = Omit<CoreAIAgent<PikkuPermission, PikkuMiddleware, ScopeId, ScorerName>, 'tools' | 'agents' | 'workflows' | 'memory' | 'input' | 'output'> & {
22
27
  input?: InputSchema
23
28
  output?: OutputSchema
24
29
  memory?: Omit<AIAgentMemoryConfig, 'workingMemory'> & { workingMemory?: StandardSchemaV1 }
@@ -36,6 +41,14 @@ export const pikkuAIAgent = <
36
41
  return agent
37
42
  }
38
43
 
44
+ export const pikkuAIScorer = (
45
+ config: Parameters<typeof corePikkuAIScorer<Services>>[0]
46
+ ) => corePikkuAIScorer<Services>(config)
47
+
48
+ export const pikkuAIJudge = (
49
+ config: Parameters<typeof corePikkuAIJudge<Services>>[0]
50
+ ) => corePikkuAIJudge<Services>(config)
51
+
39
52
  export const pikkuAIMiddleware = <
40
53
  State extends Record<string, unknown> = Record<string, unknown>,
41
54
  RequiredServices extends Services = Services,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Bakes the `models` alias table into pikku state. Generated rather than read
3
+ * at runtime: a deployed unit never sees pikku.config.json.
4
+ */
5
+ export declare const serializeModelAliases: (models: Record<string, string> | undefined, addonName: string | null) => string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Bakes the `models` alias table into pikku state. Generated rather than read
3
+ * at runtime: a deployed unit never sees pikku.config.json.
4
+ */
5
+ export const serializeModelAliases = (models, addonName) => {
6
+ const packageArg = addonName ? `'${addonName}'` : 'null';
7
+ const table = JSON.stringify(models ?? {}, null, 2);
8
+ return `import { pikkuState } from '@pikku/core/ecosystem'
9
+
10
+ pikkuState(${packageArg}, 'agent', 'modelAliases', ${table})
11
+ `;
12
+ };
@@ -0,0 +1 @@
1
+ export declare const pikkuAIScorer: import("#pikku").PikkuFunctionConfig<void, boolean | undefined, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, boolean | undefined, "rpc" | "session", import("#pikku").WiredServices, unknown> | import("#pikku").PikkuFunction<void, boolean | undefined, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
@@ -0,0 +1,51 @@
1
+ import { pikkuSessionlessFunc } from '#pikku';
2
+ import { writeFileInDir } from '../../../utils/file-writer.js';
3
+ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
4
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
5
+ import { serializeScorerNames } from './serialize-scorer-names.js';
6
+ export const pikkuAIScorer = pikkuSessionlessFunc({
7
+ func: async ({ logger, config, getInspectorState }) => {
8
+ const { scorers } = await getInspectorState();
9
+ const { scorerWiringsFile, scorerWiringMetaFile, scorerWiringMetaJsonFile, scorerNamesDeclarationFile, packageMappings, schema, addonName, } = config;
10
+ const scorerFiles = scorers.files;
11
+ // Written even when empty: the agent types file imports ScorerName
12
+ // unconditionally, so a project with no scorers still has to typecheck.
13
+ await writeFileInDir(logger, scorerNamesDeclarationFile, serializeScorerNames(scorers.scorersMeta));
14
+ if (scorerFiles.size === 0 ||
15
+ Object.keys(scorers.scorersMeta).length === 0) {
16
+ return undefined;
17
+ }
18
+ const lines = [];
19
+ lines.push(`import { addAIScorer } from '@pikku/core/ai-scorer'`);
20
+ // Ahead of the registrations: addAIScorer refuses a scorer whose metadata
21
+ // has not landed yet.
22
+ lines.push(`import '${getFileImportRelativePath(scorerWiringsFile, scorerWiringMetaFile, packageMappings)}'`);
23
+ const sortedScorers = Array.from(scorerFiles.entries()).sort((a, b) => a[0].localeCompare(b[0]));
24
+ for (const [, { path, exportedName }] of sortedScorers) {
25
+ const importPath = getFileImportRelativePath(scorerWiringsFile, path, packageMappings);
26
+ lines.push(`import { ${exportedName} } from '${importPath}'`);
27
+ }
28
+ lines.push('');
29
+ const packageArg = addonName ? `, '${addonName}'` : '';
30
+ for (const [scorerName, { exportedName }] of sortedScorers) {
31
+ lines.push(`addAIScorer('${scorerName}', ${exportedName}${packageArg})`);
32
+ }
33
+ await writeFileInDir(logger, scorerWiringsFile, lines.join('\n'));
34
+ await writeFileInDir(logger, scorerWiringMetaJsonFile, JSON.stringify({ scorersMeta: scorers.scorersMeta }, null, 2));
35
+ const jsonImportPath = getFileImportRelativePath(scorerWiringMetaFile, scorerWiringMetaJsonFile, packageMappings);
36
+ const importStatement = schema?.supportsImportAttributes
37
+ ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
38
+ : `import metaData from '${jsonImportPath}'`;
39
+ await writeFileInDir(logger, scorerWiringMetaFile, `import { pikkuState } from '@pikku/core/ecosystem'
40
+ import type { ScorerMeta } from '@pikku/core/ai-scorer'
41
+ ${importStatement}
42
+ pikkuState(${addonName ? `'${addonName}'` : 'null'}, 'agent', 'scorersMeta', metaData.scorersMeta as ScorerMeta)`);
43
+ return true;
44
+ },
45
+ middleware: [
46
+ logCommandInfoAndTime({
47
+ commandStart: 'Finding AI scorers',
48
+ commandEnd: 'Found AI scorers',
49
+ }),
50
+ ],
51
+ });
@@ -0,0 +1,10 @@
1
+ import type { ScorerMeta } from '@pikku/core/ai-scorer';
2
+ /**
3
+ * The names an agent may ask to be graded by.
4
+ *
5
+ * Emitted even when there are none — the agent types file imports it
6
+ * unconditionally, so a project with no scorers still has to typecheck. `never`
7
+ * is what makes `scorers: ['typo']` a type error there rather than a silent
8
+ * no-op at runtime.
9
+ */
10
+ export declare const serializeScorerNames: (scorersMeta: ScorerMeta) => string;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The names an agent may ask to be graded by.
3
+ *
4
+ * Emitted even when there are none — the agent types file imports it
5
+ * unconditionally, so a project with no scorers still has to typecheck. `never`
6
+ * is what makes `scorers: ['typo']` a type error there rather than a silent
7
+ * no-op at runtime.
8
+ */
9
+ export const serializeScorerNames = (scorersMeta) => {
10
+ const names = Object.keys(scorersMeta).sort();
11
+ return `/**
12
+ * The AI scorers declared in this project.
13
+ */
14
+
15
+ export type ScorerName = ${names.length === 0 ? 'never' : names.map((name) => `'${name}'`).join(' | ')}
16
+ `;
17
+ };
@@ -36,10 +36,12 @@ function variableSchemaName(name, field) {
36
36
  // External consoles (served from another origin) cannot carry the session
37
37
  // cookie, so they authenticate with 'Authorization: Bearer <PIKKU_CONSOLE_TOKEN>'.
38
38
  // The expected token resolves through the secrets service per request and the
39
- // middleware is a no-op while the secret is unset. Emitted into the same
40
- // addHTTPMiddleware('*') call as the session middleware: the inspector keys
41
- // route-middleware groups by pattern, so a second '*' registration from another
42
- // file would silently displace this one in deployed units.
39
+ // middleware is a no-op while the secret is unset. Emitted alongside the session
40
+ // middleware in one addGlobalMiddleware call. This used to be an
41
+ // addHTTPMiddleware('*') call and had to be a single one, because the inspector
42
+ // keys route-middleware groups by pattern and a second '*' registration would
43
+ // silently displace it; global middleware is an append-only list, so that
44
+ // hazard is gone.
43
45
  //
44
46
  // The session carries the two scope roots the console addon gates itself on.
45
47
  // Without them this token authenticates but authorizes nothing: `wireAddon`
@@ -157,7 +159,7 @@ export const serializeAuthGen = (definition, providers, authFile, typesDeclarati
157
159
  '// AUTO-GENERATED by pikku CLI — do not edit',
158
160
  '',
159
161
  emitStatefulSession
160
- ? `import { pikkuSessionlessFunc, wireHTTPRoutes, addHTTPMiddleware } from '${pikkuTypesImportPath}'`
162
+ ? `import { pikkuSessionlessFunc, wireHTTPRoutes } from '${pikkuTypesImportPath}'\nimport { addGlobalMiddleware } from '@pikku/core/middleware'`
161
163
  : `import { pikkuSessionlessFunc, wireHTTPRoutes } from '${pikkuTypesImportPath}'`,
162
164
  emitStatefulSession
163
165
  ? `import { createAuthHandler, betterAuthSession } from '@pikku/better-auth'`
@@ -183,10 +185,10 @@ export const serializeAuthGen = (definition, providers, authFile, typesDeclarati
183
185
  // Stateful: betterAuthSession calls services.auth(), so it stays here with
184
186
  // the auth.wiring import.
185
187
  if (includeConsoleToken) {
186
- wiring.push(`addHTTPMiddleware('*', [`, ` betterAuthSession(),`, ...consoleTokenMiddlewareLines(), `])`, '');
188
+ wiring.push(`addGlobalMiddleware([`, ` betterAuthSession(),`, ...consoleTokenMiddlewareLines(), `])`, '');
187
189
  }
188
190
  else {
189
- wiring.push(`addHTTPMiddleware('*', [betterAuthSession()])`, '');
191
+ wiring.push(`addGlobalMiddleware([betterAuthSession()])`, '');
190
192
  }
191
193
  }
192
194
  // `pikku` tag marks these as scaffold plumbing (not user-authored wiring) so
@@ -208,10 +210,25 @@ export const serializeAuthGen = (definition, providers, authFile, typesDeclarati
208
210
  if (stateless) {
209
211
  // Stateless session middleware in its own file — imports neither auth.wiring
210
212
  // nor the better-auth server, so every unit's bootstrap stays lean.
213
+ // Global, not `addHTTPMiddleware('*')`.
214
+ //
215
+ // Both entries resolve a session from whatever request the call arrived on;
216
+ // neither is an HTTP routing concern. Registered as HTTP middleware they ran
217
+ // for HTTP wirings alone, so an MCP tool fronting a session-requiring
218
+ // function could only answer 'Authentication required' however the caller
219
+ // authenticated — the cookie was sent and never looked at.
220
+ //
221
+ // Wirings that carry no request are unaffected: every one of these opens
222
+ // with `if (!http?.request) return`, so queue, scheduler and CLI invocations
223
+ // pass straight through as before.
224
+ //
225
+ // This also retires the displacement hazard that kept both entries in one
226
+ // call — global middleware is a list rather than a map keyed by route
227
+ // pattern, so a second registration appends instead of overwriting.
211
228
  const middleware = [
212
229
  '// AUTO-GENERATED by pikku CLI — do not edit',
213
230
  '',
214
- `import { addHTTPMiddleware } from '${pikkuTypesImportPath}'`,
231
+ `import { addGlobalMiddleware } from '@pikku/core/middleware'`,
215
232
  `import { betterAuthStatelessSession } from '@pikku/better-auth'`,
216
233
  ...(includeConsoleToken
217
234
  ? [`import { authBearer } from '@pikku/core/middleware'`]
@@ -219,12 +236,12 @@ export const serializeAuthGen = (definition, providers, authFile, typesDeclarati
219
236
  '',
220
237
  ...(includeConsoleToken
221
238
  ? [
222
- `addHTTPMiddleware('*', [`,
239
+ `addGlobalMiddleware([`,
223
240
  ` betterAuthStatelessSession(),`,
224
241
  ...consoleTokenMiddlewareLines(),
225
242
  `])`,
226
243
  ]
227
- : [`addHTTPMiddleware('*', [betterAuthStatelessSession()])`]),
244
+ : [`addGlobalMiddleware([betterAuthStatelessSession()])`]),
228
245
  '',
229
246
  ];
230
247
  output.middleware = middleware.join('\n');
@@ -61,7 +61,7 @@ import { wireChannel } from '${channelTypesPath}'
61
61
  import { pikkuMiddleware${hasAddonFuncs ? ', ref' : ''}, pikkuSessionlessFunc } from '${functionTypesPath}'
62
62
  import { generateCommandHelp } from '@pikku/core/cli'
63
63
  import { handleRawCLI, type RawCLIFrame } from '@pikku/core/cli/channel'
64
- import { pikkuState } from '@pikku/core/ecosystem'
64
+ import { pikkuState, getSingletonServices, getCreateWireServices } from '@pikku/core/ecosystem'
65
65
  ${imports}
66
66
 
67
67
  // Middleware to close the channel after CLI command completes
@@ -108,12 +108,17 @@ export const cliHelp = pikkuSessionlessFunc<{ args?: string[] }, { help: string
108
108
  */
109
109
  export const cliRaw = pikkuSessionlessFunc<{ args: string[] }, RawCLIFrame>({
110
110
  auth: false,
111
- func: async (services, data: { args: string[] }, { channel, session }) => {
111
+ func: async (_services, data: { args: string[] }, { channel, session }) => {
112
112
  const { help, result, error, exitCode, commandId } = await handleRawCLI({
113
113
  programName: '${programName}',
114
114
  args: data.args,
115
- singletonServices: services as any,
116
- createWireServices: pikkuState(null, 'package', 'factories')?.createWireServices,
115
+ // The singletons, not this function's own view of them: a function body
116
+ // is handed \`secrets\` as a throwing accessor, and passing that down
117
+ // would strip every command run on this channel of a service its
118
+ // middleware is entitled to. Each command is stripped again by its own
119
+ // runner, so nothing gains access it would not have over HTTP.
120
+ singletonServices: getSingletonServices() as any,
121
+ createWireServices: getCreateWireServices(),
117
122
  // The connection authenticated during its upgrade — commands run as it.
118
123
  session,
119
124
  // The socket the command arrived on, so \`channel.remote(...)\` inside a