@pikku/cli 0.12.100 → 0.12.103

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 (259) hide show
  1. package/console-app/assets/{abnfDiagram-VRR7QNED-Icjp9hnB.js → abnfDiagram-VRR7QNED-BLi9JHGg.js} +1 -1
  2. package/console-app/assets/{arc-BfGls--L.js → arc-B3b5uYlL.js} +1 -1
  3. package/console-app/assets/architecture-TIHT7OUA-BYeDayHv.js +1 -0
  4. package/console-app/assets/{architectureDiagram-ZJ3FMSHR-CpnsLBns.js → architectureDiagram-ZJ3FMSHR-Dkd8kxIa.js} +1 -1
  5. package/console-app/assets/{blockDiagram-677ZJIJ3-ByKRMGSr.js → blockDiagram-677ZJIJ3-DnH0nNlb.js} +1 -1
  6. package/console-app/assets/{c4Diagram-LMCZKHZV-CzJSbsUo.js → c4Diagram-LMCZKHZV-BlelCS5i.js} +1 -1
  7. package/console-app/assets/channel-CTa6nggO.js +1 -0
  8. package/console-app/assets/{chunk-32BRIVSS-D_tc4HCY.js → chunk-32BRIVSS-D7tMgtT1.js} +1 -1
  9. package/console-app/assets/{chunk-52WLFC77-wkQkuUXG.js → chunk-52WLFC77-CRepS35y.js} +1 -1
  10. package/console-app/assets/{chunk-C7G6YPKG-BFW3xG3R.js → chunk-C7G6YPKG-CUldlJz4.js} +1 -1
  11. package/console-app/assets/{chunk-EX3LRPZG-Car090Sw.js → chunk-EX3LRPZG-DODbrqEj.js} +1 -1
  12. package/console-app/assets/{chunk-FWX5IMBZ-c2ud9kQ-.js → chunk-FWX5IMBZ-nZa59wGD.js} +2 -2
  13. package/console-app/assets/{chunk-HOUHSVGY-RYmQka5R.js → chunk-HOUHSVGY-BaawVZCa.js} +1 -1
  14. package/console-app/assets/{chunk-ICXQ74PX-C-dqYC_9.js → chunk-ICXQ74PX-C86LrIRs.js} +1 -1
  15. package/console-app/assets/{chunk-MOJQB5TN-Cu3FUWwl.js → chunk-MOJQB5TN-ovUDQlyW.js} +1 -1
  16. package/console-app/assets/{chunk-OGEWGWER-Z7f1yArD.js → chunk-OGEWGWER-ByZKAcGu.js} +1 -1
  17. package/console-app/assets/{chunk-PUDLZKDR-Bp68DuRj.js → chunk-PUDLZKDR-DdeJN3wJ.js} +1 -1
  18. package/console-app/assets/{chunk-Q4XR5HBZ-CdKSYWZ4.js → chunk-Q4XR5HBZ-Blp5W9-b.js} +1 -1
  19. package/console-app/assets/{chunk-RYQCIY6F-9ISCAKm2.js → chunk-RYQCIY6F-DehwjyPp.js} +1 -1
  20. package/console-app/assets/{chunk-V7JOEXUC-2EOc1nQB.js → chunk-V7JOEXUC-Ca1xeVdo.js} +1 -1
  21. package/console-app/assets/chunk-VAUOI2AC-BCngaLxk.js +1 -0
  22. package/console-app/assets/{chunk-VR4S4FIN-BPvN0PUm.js → chunk-VR4S4FIN-Cj7ZlsLr.js} +1 -1
  23. package/console-app/assets/{chunk-WYO6CB5R-DOpurCTP.js → chunk-WYO6CB5R-CsdBQ1HS.js} +1 -1
  24. package/console-app/assets/chunk-XXDRQBXY-CGIlOoBU.js +1 -0
  25. package/console-app/assets/{chunk-ZGVPDNZ5-Bu2weVOL.js → chunk-ZGVPDNZ5-DMnFdLEO.js} +1 -1
  26. package/console-app/assets/classDiagram-OUVF2IWQ-Bwt1ZVOR.js +1 -0
  27. package/console-app/assets/classDiagram-v2-EOCWNBFH-Bwt1ZVOR.js +1 -0
  28. package/console-app/assets/{cose-bilkent-JH36ORCC-nau-QGCX.js → cose-bilkent-JH36ORCC-CiYBhiBv.js} +1 -1
  29. package/console-app/assets/{cynefin-VYW2F7L2-BBw-E7lg.js → cynefin-VYW2F7L2-BXuNC8qm.js} +1 -1
  30. package/console-app/assets/{cynefinDiagram-TSTJHNR4-BvnMvOvH.js → cynefinDiagram-TSTJHNR4-Ck53b-Nr.js} +1 -1
  31. package/console-app/assets/{dagre-VKFMJZFB-CHEqPR29.js → dagre-VKFMJZFB-C9hZCnOv.js} +1 -1
  32. package/console-app/assets/{diagram-FQU43EPY-JijKRWyb.js → diagram-FQU43EPY-DuEKSLPE.js} +1 -1
  33. package/console-app/assets/{diagram-G47NLZAW-G5UsB31f.js → diagram-G47NLZAW-B_yO-zKt.js} +1 -1
  34. package/console-app/assets/{diagram-NH7WQ7WH-BhuJ6fPu.js → diagram-NH7WQ7WH-CtKFjoB4.js} +1 -1
  35. package/console-app/assets/{diagram-OA4YK3LP-DaUF-8N4.js → diagram-OA4YK3LP-T9eIYXYs.js} +1 -1
  36. package/console-app/assets/{diagram-WEI45ONY-wLsJIhoM.js → diagram-WEI45ONY-BTgu-I69.js} +1 -1
  37. package/console-app/assets/{dist-fbBkbDNG.js → dist-DSVj7qxi.js} +1 -1
  38. package/console-app/assets/{ebnfDiagram-CCIWWBDH-BZCEa3Dz.js → ebnfDiagram-CCIWWBDH-BdyNRX2k.js} +1 -1
  39. package/console-app/assets/{erDiagram-Q63AITRT-4XoEUtEh.js → erDiagram-Q63AITRT-B0cr0nxe.js} +1 -1
  40. package/console-app/assets/eventmodeling-45OFAUF4-BeHdsPzc.js +1 -0
  41. package/console-app/assets/flowDiagram-23GEKE2U-6N6mIkfB.js +1 -0
  42. package/console-app/assets/{ganttDiagram-NO4QXBWP-BXU7pfq6.js → ganttDiagram-NO4QXBWP-Cr1R_nGh.js} +1 -1
  43. package/console-app/assets/{gitGraph-TEB2WS4Q-BdMAmvpU.js → gitGraph-TEB2WS4Q-zcmQoWd4.js} +1 -1
  44. package/console-app/assets/{gitGraphDiagram-IHSO6WYX-3Hn0zwZR.js → gitGraphDiagram-IHSO6WYX-CHB9Fnch.js} +1 -1
  45. package/console-app/assets/{index-Din2vBeb.js → index-BbIUXgNl.js} +150 -150
  46. package/console-app/assets/{index-BXMjqLQ5.css → index-C9U-Zyvx.css} +1 -1
  47. package/console-app/assets/{info-DKCQHKI2-Dc_oQkp5.js → info-DKCQHKI2-BGPZGp_E.js} +1 -1
  48. package/console-app/assets/{infoDiagram-FWYZ7A6U-B3v4xCUn.js → infoDiagram-FWYZ7A6U-Br_p6SR_.js} +1 -1
  49. package/console-app/assets/{ishikawaDiagram-FXEZZL3T-DzWq9Vtp.js → ishikawaDiagram-FXEZZL3T-Ma2d4IuN.js} +1 -1
  50. package/console-app/assets/{journeyDiagram-5HDEW3XC-C0buWi_a.js → journeyDiagram-5HDEW3XC-LdCblEX2.js} +1 -1
  51. package/console-app/assets/{kanban-definition-HUTT4EX6-DRAN9HhV.js → kanban-definition-HUTT4EX6-CRWetzV4.js} +1 -1
  52. package/console-app/assets/{line-UqgRNiAC.js → line-DrceqMYY.js} +1 -1
  53. package/console-app/assets/{linear-FTAGuk_3.js → linear-acWbtwAj.js} +1 -1
  54. package/console-app/assets/{mermaid-parser.core-DIHI27FL.js → mermaid-parser.core-n773Jf0G.js} +3 -3
  55. package/console-app/assets/{mermaid.core-D4q8kvcu.js → mermaid.core-DyTRkSqH.js} +3 -3
  56. package/console-app/assets/{mindmap-definition-LN4V7U3C-DN-_CNLb.js → mindmap-definition-LN4V7U3C-CBU-ehFU.js} +1 -1
  57. package/console-app/assets/{packet-7NZHBO7P-8a3PoQAb.js → packet-7NZHBO7P-DL_fgdX1.js} +1 -1
  58. package/console-app/assets/{pegDiagram-2B236MQR-Bh2MhzCN.js → pegDiagram-2B236MQR-CrFaAHHj.js} +1 -1
  59. package/console-app/assets/{pie-RZYD4A2V-Bi6zbJDl.js → pie-RZYD4A2V-STtzW8Tz.js} +1 -1
  60. package/console-app/assets/{pieDiagram-ENE6RG2P-D2Z0W5UU.js → pieDiagram-ENE6RG2P-DsUOr1Ud.js} +1 -1
  61. package/console-app/assets/{quadrantDiagram-ABIIQ3AL-DNOKka0p.js → quadrantDiagram-ABIIQ3AL-DmuSe_qW.js} +1 -1
  62. package/console-app/assets/{radar-I7S5WNFK-CAxa68Sg.js → radar-I7S5WNFK-L8w2lEOb.js} +1 -1
  63. package/console-app/assets/{railroad-3IZDKUUU-CZb1usP7.js → railroad-3IZDKUUU-CxqlE5vc.js} +1 -1
  64. package/console-app/assets/railroad-abnf-AHOZXSZD-CkJOR_Em.js +1 -0
  65. package/console-app/assets/railroad-ebnf-EBAXGLYW-BH_pRGgm.js +1 -0
  66. package/console-app/assets/railroad-peg-LSFZ7HO6-B50bKcii.js +1 -0
  67. package/console-app/assets/{railroadDiagram-RFXS5EU6-B1K2hbTD.js → railroadDiagram-RFXS5EU6-CJ8Lpbeo.js} +1 -1
  68. package/console-app/assets/{requirementDiagram-TGXJPOKE-K8wcOO0Q.js → requirementDiagram-TGXJPOKE-8OXQXUud.js} +1 -1
  69. package/console-app/assets/{sankeyDiagram-HTMAVEWB-WBPBkgNx.js → sankeyDiagram-HTMAVEWB-Bezd2CqZ.js} +1 -1
  70. package/console-app/assets/{sequenceDiagram-DBY2YBRQ-Dz80qZZv.js → sequenceDiagram-DBY2YBRQ-DHb5js3D.js} +1 -1
  71. package/console-app/assets/{src-CnJCXDL0.js → src-DfFamOl-.js} +1 -1
  72. package/console-app/assets/{stateDiagram-2N3HPSRC-DMur7lZf.js → stateDiagram-2N3HPSRC-UpyJm2mi.js} +1 -1
  73. package/console-app/assets/stateDiagram-v2-6OUMAXLB-C6gAfg82.js +1 -0
  74. package/console-app/assets/{swimlanes-5IMT3BWC-BlLdYcPU.js → swimlanes-5IMT3BWC-yUrV5f4O.js} +1 -1
  75. package/console-app/assets/swimlanesDiagram-G3AALYLV-Ch2_j5W5.js +8 -0
  76. package/console-app/assets/{timeline-definition-FHXFAJF6-CBOit0JY.js → timeline-definition-FHXFAJF6-B6w-rZeZ.js} +1 -1
  77. package/console-app/assets/{treeView-QDETBFTQ-DM1i1ast.js → treeView-QDETBFTQ-0k2QpnXc.js} +1 -1
  78. package/console-app/assets/{treemap-6X3UGDF4-ACrBEfY6.js → treemap-6X3UGDF4-ByCuDcGA.js} +1 -1
  79. package/console-app/assets/{vennDiagram-L72KCM5P-BmeFWb5N.js → vennDiagram-L72KCM5P-BH4374lw.js} +1 -1
  80. package/console-app/assets/{wardley-OPB4EBWU-BpIbeh58.js → wardley-OPB4EBWU-DNVwuJz6.js} +1 -1
  81. package/console-app/assets/{wardleyDiagram-EHGQE667-CxL7Mv7y.js → wardleyDiagram-EHGQE667-EXnQ6lkx.js} +1 -1
  82. package/console-app/assets/{xychartDiagram-FW5EYKEG-DkV75xT2.js → xychartDiagram-FW5EYKEG-rFh-UdgH.js} +1 -1
  83. package/console-app/index.html +10 -3
  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.d.ts +2 -1
  159. package/dist/.pikku/workflow/pikku-personas.gen.js +1 -1
  160. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +11 -18
  161. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
  162. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  163. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  164. package/dist/bin/pikku-bin.mjs +2 -2
  165. package/dist/src/cli.wiring.js +20 -11
  166. package/dist/src/deploy/analyzer/analyzer.js +44 -0
  167. package/dist/src/deploy/analyzer/manifest.d.ts +37 -0
  168. package/dist/src/fabric/functions/smoke.function.js +7 -4
  169. package/dist/src/fabric/functions/validate.function.js +3 -1
  170. package/dist/src/functions/commands/db-export.js +1 -1
  171. package/dist/src/functions/commands/db-shared.d.ts +0 -14
  172. package/dist/src/functions/commands/dev.d.ts +3 -0
  173. package/dist/src/functions/commands/dev.js +41 -2
  174. package/dist/src/functions/commands/knowledge-index.d.ts +3 -3
  175. package/dist/src/functions/commands/new-addon.js +6 -3
  176. package/dist/src/functions/commands/scenario-browser.d.ts +25 -2
  177. package/dist/src/functions/commands/scenario-browser.js +5 -1
  178. package/dist/src/functions/commands/scenario-formatter.d.ts +1 -1
  179. package/dist/src/functions/commands/scenario-ladder.d.ts +1 -1
  180. package/dist/src/functions/commands/scenario-ladder.js +1 -1
  181. package/dist/src/functions/commands/scenario-plan.d.ts +2 -1
  182. package/dist/src/functions/commands/scenario-plan.js +1 -1
  183. package/dist/src/functions/commands/scenario.d.ts +7 -1
  184. package/dist/src/functions/commands/scenario.js +28 -7
  185. package/dist/src/functions/commands/serve.d.ts +3 -0
  186. package/dist/src/functions/commands/serve.js +15 -1
  187. package/dist/src/functions/commands/{workspace-validate.d.ts → validate.d.ts} +18 -3
  188. package/dist/src/functions/commands/validate.js +9 -0
  189. package/dist/src/functions/db/local-db.d.ts +2 -1
  190. package/dist/src/functions/db/local-db.js +2 -2
  191. package/dist/src/functions/surface/collect-surface.d.ts +14 -0
  192. package/dist/src/functions/surface/collect-surface.js +215 -0
  193. package/dist/src/functions/validate/addon-package-checks.d.ts +26 -0
  194. package/dist/src/functions/validate/addon-package-checks.js +258 -0
  195. package/dist/src/functions/validate/persona-checks.d.ts +1 -1
  196. package/dist/src/functions/validate/persona-checks.js +1 -1
  197. package/dist/src/functions/validate/scenario-file-checks.js +33 -0
  198. package/dist/src/functions/validate/shared-checks.d.ts +1 -1
  199. package/dist/src/functions/validate/shared-checks.js +1 -1
  200. package/dist/src/functions/validate/type-identity-checks.d.ts +25 -0
  201. package/dist/src/functions/validate/type-identity-checks.js +218 -0
  202. package/dist/src/functions/validate/validate-registry.d.ts +52 -0
  203. package/dist/src/functions/validate/validate-registry.js +111 -0
  204. package/dist/src/functions/validate/validate.d.ts +47 -0
  205. package/dist/src/functions/validate/{workspace-validate.js → validate.js} +46 -12
  206. package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent-types.js +3 -2
  207. package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.js +5 -1
  208. package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.d.ts +1 -1
  209. package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.js +15 -2
  210. package/dist/src/functions/wirings/ai-agent/serialize-model-aliases.d.ts +5 -0
  211. package/dist/src/functions/wirings/ai-agent/serialize-model-aliases.js +12 -0
  212. package/dist/src/functions/wirings/ai-scorer/pikku-command-ai-scorer.d.ts +1 -0
  213. package/dist/src/functions/wirings/ai-scorer/pikku-command-ai-scorer.js +51 -0
  214. package/dist/src/functions/wirings/ai-scorer/serialize-scorer-names.d.ts +10 -0
  215. package/dist/src/functions/wirings/ai-scorer/serialize-scorer-names.js +17 -0
  216. package/dist/src/functions/wirings/auth/serialize-auth-gen.js +27 -10
  217. package/dist/src/functions/wirings/cli/serialize-channel-cli.js +9 -4
  218. package/dist/src/functions/wirings/console/serialize-console-functions.js +9 -56
  219. package/dist/src/functions/wirings/functions/serialize-function-types.js +7 -30
  220. package/dist/src/functions/wirings/middleware/serialize-middleware-imports.js +5 -1
  221. package/dist/src/functions/wirings/package/pikku-command-package.js +12 -1
  222. package/dist/src/functions/wirings/package/serialize-package.d.ts +1 -1
  223. package/dist/src/functions/wirings/package/serialize-package.js +5 -2
  224. package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +1 -6
  225. package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.js +30 -0
  226. package/dist/src/functions/wirings/scenarios/serialize-feature-meta.d.ts +1 -1
  227. package/dist/src/functions/wirings/scenarios/serialize-scenario-registration.js +6 -5
  228. package/dist/src/functions/wirings/workflow/serialize-personas.js +2 -5
  229. package/dist/src/functions/wirings/workflow/serialize-workflow-routes.js +12 -4
  230. package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +10 -17
  231. package/dist/src/functions/workflows/all.workflow.js +11 -1
  232. package/dist/src/server/bun-server-runner.js +3 -0
  233. package/dist/src/server/dev-server-runner.interface.d.ts +10 -0
  234. package/dist/src/server/node-server-runner.js +3 -0
  235. package/dist/src/services.js +1 -0
  236. package/dist/src/utils/meta-diff.d.ts +1 -1
  237. package/dist/src/utils/meta-diff.js +2 -0
  238. package/dist/src/utils/model-alias-override.d.ts +7 -0
  239. package/dist/src/utils/model-alias-override.js +33 -0
  240. package/dist/src/utils/pikku-cli-config.js +16 -0
  241. package/dist/tsconfig.tsbuildinfo +1 -1
  242. package/package.json +17 -17
  243. package/console-app/assets/architecture-TIHT7OUA-C8l7I5Lm.js +0 -1
  244. package/console-app/assets/channel-BgJ-Z0cx.js +0 -1
  245. package/console-app/assets/chunk-VAUOI2AC-DwKsbf70.js +0 -1
  246. package/console-app/assets/chunk-XXDRQBXY-RuYSFsQb.js +0 -1
  247. package/console-app/assets/classDiagram-OUVF2IWQ-ohoLCI8g.js +0 -1
  248. package/console-app/assets/classDiagram-v2-EOCWNBFH-ohoLCI8g.js +0 -1
  249. package/console-app/assets/eventmodeling-45OFAUF4-DZ7z4YJO.js +0 -1
  250. package/console-app/assets/flowDiagram-23GEKE2U-rd7-NwZT.js +0 -1
  251. package/console-app/assets/railroad-abnf-AHOZXSZD-DkQZciri.js +0 -1
  252. package/console-app/assets/railroad-ebnf-EBAXGLYW-CPBeASA9.js +0 -1
  253. package/console-app/assets/railroad-peg-LSFZ7HO6-CXEVIZ0g.js +0 -1
  254. package/console-app/assets/stateDiagram-v2-6OUMAXLB-BDgLCrot.js +0 -1
  255. package/console-app/assets/swimlanesDiagram-G3AALYLV-CZ5rQIcE.js +0 -8
  256. package/dist/.pikku/schemas/schemas/WorkspaceValidateOutput.schema.json +0 -1
  257. package/dist/src/functions/commands/workspace-validate.js +0 -9
  258. package/dist/src/functions/validate/workspace-validate.d.ts +0 -33
  259. /package/dist/.pikku/schemas/schemas/{WorkspaceValidateInput.schema.json → ValidateInput.schema.json} +0 -0
@@ -0,0 +1,26 @@
1
+ import type { ValidateFinding as Finding } from './persona-checks.js';
2
+ /**
3
+ * A package that publishes generated pikku output.
4
+ *
5
+ * The generated files carry relative imports to hand-written sources, so what
6
+ * the package ships and what it references have to agree — which is what the
7
+ * checks below are for.
8
+ *
9
+ * Having a `.pikku` directory is not enough on its own: an app's
10
+ * packages/functions has one too, and it is codegen output for that app rather
11
+ * than something anybody installs. The question is whether the package *ships*
12
+ * it, so the signal is a `files`/`exports` that carries it into the tarball.
13
+ * A private package is excluded for the same reason — nobody installs it, so
14
+ * its published file set is not a thing that can be wrong.
15
+ */
16
+ export declare function isAddonPackage(pkgDir: string): Promise<boolean>;
17
+ /**
18
+ * Every relative import in a shipped generated file must resolve to a file
19
+ * that is itself shipped.
20
+ *
21
+ * Stated as a property rather than as "the build script must copy types/",
22
+ * because the build script is not the only way to get this wrong and will not
23
+ * always be a `cp`. The generated files declare what they need; the check just
24
+ * holds the package to it.
25
+ */
26
+ export declare function runAddonPackageChecks(pkgDir: string): Promise<Finding[]>;
@@ -0,0 +1,258 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { readdir } from 'node:fs/promises';
3
+ import { dirname, join, relative, resolve, sep } from 'node:path';
4
+ import { readJsonSafe, readTextSafe } from './shared-checks.js';
5
+ /** Where the CLI writes generated output, both in source and once built. */
6
+ const GENERATED_DIRS = ['.pikku', join('dist', '.pikku')];
7
+ /** Roots that carry generated output into the tarball when listed in `files`. */
8
+ const SHIPPING_ROOTS = new Set(['dist', '.pikku']);
9
+ /**
10
+ * A package that publishes generated pikku output.
11
+ *
12
+ * The generated files carry relative imports to hand-written sources, so what
13
+ * the package ships and what it references have to agree — which is what the
14
+ * checks below are for.
15
+ *
16
+ * Having a `.pikku` directory is not enough on its own: an app's
17
+ * packages/functions has one too, and it is codegen output for that app rather
18
+ * than something anybody installs. The question is whether the package *ships*
19
+ * it, so the signal is a `files`/`exports` that carries it into the tarball.
20
+ * A private package is excluded for the same reason — nobody installs it, so
21
+ * its published file set is not a thing that can be wrong.
22
+ */
23
+ export async function isAddonPackage(pkgDir) {
24
+ const pkg = await readJsonSafe(join(pkgDir, 'package.json'));
25
+ if (!pkg || pkg.private)
26
+ return false;
27
+ if (!GENERATED_DIRS.some((dir) => existsSync(join(pkgDir, dir))))
28
+ return false;
29
+ const shipsViaFiles = (pkg.files ?? []).some((entry) => SHIPPING_ROOTS.has(entry.replace(/^\.\//, '').split('/')[0]));
30
+ return shipsViaFiles || JSON.stringify(pkg.exports ?? null).includes('.pikku');
31
+ }
32
+ async function walk(dir) {
33
+ const out = [];
34
+ let entries;
35
+ try {
36
+ entries = await readdir(dir, { withFileTypes: true });
37
+ }
38
+ catch {
39
+ return out;
40
+ }
41
+ for (const entry of entries) {
42
+ const path = join(dir, entry.name);
43
+ if (entry.isDirectory())
44
+ out.push(...(await walk(path)));
45
+ else
46
+ out.push(path);
47
+ }
48
+ return out;
49
+ }
50
+ const IMPORT_RE = /(?:^|[\s(};])(?:from|import|require)\s*\(?\s*['"]([^'"]+)['"]/g;
51
+ function relativeSpecifiers(source) {
52
+ const found = new Set();
53
+ for (const match of source.matchAll(IMPORT_RE)) {
54
+ const specifier = match[1];
55
+ if (specifier.startsWith('.'))
56
+ found.add(specifier);
57
+ }
58
+ return [...found];
59
+ }
60
+ /**
61
+ * The on-disk file a specifier names, under TypeScript's NodeNext rules.
62
+ *
63
+ * `./x.js` may be satisfied by `x.ts` or `x.d.ts`, and pikku's generated files
64
+ * import hand-written declarations as `./x.d.js` — the `.js` extension the
65
+ * compiler wants, on a file that only ever exists as `.d.ts`.
66
+ */
67
+ function resolveCandidates(specifier, fromDir) {
68
+ const base = resolve(fromDir, specifier);
69
+ if (base.endsWith('.d.js'))
70
+ return [base.slice(0, -5) + '.d.ts'];
71
+ if (base.endsWith('.js')) {
72
+ const stem = base.slice(0, -3);
73
+ return [base, stem + '.ts', stem + '.d.ts', stem + '.tsx'];
74
+ }
75
+ // `.mjs` and `.cjs` are scanned as generated files, so they are also imported
76
+ // as one, and each has its own TypeScript twin rather than sharing `.ts`.
77
+ if (base.endsWith('.mjs') || base.endsWith('.cjs')) {
78
+ const stem = base.slice(0, -4);
79
+ const kind = base.slice(-3, -2);
80
+ return [base, `${stem}.${kind}ts`, `${stem}.d.${kind}ts`];
81
+ }
82
+ if (/\.(ts|tsx|json)$/.test(base))
83
+ return [base];
84
+ return [
85
+ base + '.ts',
86
+ base + '.d.ts',
87
+ base + '.js',
88
+ join(base, 'index.ts'),
89
+ join(base, 'index.d.ts'),
90
+ join(base, 'index.js'),
91
+ ];
92
+ }
93
+ /**
94
+ * The directory a `files` entry is rooted at.
95
+ *
96
+ * `dist`, `dist/`, `dist/**` and `dist/*` all publish the same tree, so the
97
+ * root is what decides both whether a path ships and whether the entry has
98
+ * anything behind it. Anything more elaborate than a trailing wildcard is left
99
+ * to npm.
100
+ */
101
+ function packedRoot(entry) {
102
+ return entry
103
+ .replace(/^\.\//, '')
104
+ .replace(/\/\*+$/, '')
105
+ .replace(/\/$/, '');
106
+ }
107
+ /**
108
+ * Whether `files` carries this path into the published tarball.
109
+ *
110
+ * A package with no `files` publishes everything, so the question only has
111
+ * teeth when the field is present.
112
+ */
113
+ function isPacked(absPath, pkgDir, files) {
114
+ if (!files)
115
+ return true;
116
+ const rel = relative(pkgDir, absPath);
117
+ if (rel.startsWith('..'))
118
+ return false;
119
+ return files.some((entry) => {
120
+ const normalized = packedRoot(entry);
121
+ return rel === normalized || rel.startsWith(normalized + sep);
122
+ });
123
+ }
124
+ /**
125
+ * Every `./…` target reachable through an `exports` or `imports` map, paired
126
+ * with the entry-point name that leads to it.
127
+ *
128
+ * Both fields nest arbitrarily deep — a subpath holds a condition object, which
129
+ * may hold another — so the walk collects strings rather than assuming a shape.
130
+ * A `*` is left in place: the wildcard's own directory is what has to ship.
131
+ */
132
+ function entryPointTargets(map, name = '') {
133
+ if (typeof map === 'string') {
134
+ return map.startsWith('./') ? [{ name, target: map }] : [];
135
+ }
136
+ if (!map || typeof map !== 'object')
137
+ return [];
138
+ return Object.entries(map).flatMap(([key, value]) => entryPointTargets(value, name || key));
139
+ }
140
+ /**
141
+ * Every relative import in a shipped generated file must resolve to a file
142
+ * that is itself shipped.
143
+ *
144
+ * Stated as a property rather than as "the build script must copy types/",
145
+ * because the build script is not the only way to get this wrong and will not
146
+ * always be a `cp`. The generated files declare what they need; the check just
147
+ * holds the package to it.
148
+ */
149
+ export async function runAddonPackageChecks(pkgDir) {
150
+ const findings = [];
151
+ const pkg = await readJsonSafe(join(pkgDir, 'package.json'));
152
+ if (!pkg)
153
+ return findings;
154
+ // `files` is the package's own statement of what it publishes, so an entry
155
+ // with nothing behind it means the build has not run — and validating the
156
+ // published file set of a package that has not been built proves nothing.
157
+ const absent = (pkg.files ?? []).filter((entry) => !existsSync(join(pkgDir, packedRoot(entry))));
158
+ if (absent.length > 0) {
159
+ findings.push({
160
+ id: 'addon-not-built',
161
+ severity: 'info',
162
+ message: `${pkg.name ?? relative(dirname(pkgDir), pkgDir)} lists ${absent.join(', ')} in "files" with nothing on disk — packaging was not verified because the package is not built`,
163
+ path: join(pkgDir, absent[0]),
164
+ fixHint: 'Run the package build first, then validate. In CI, `build && pikku validate` is the order that checks what actually publishes.',
165
+ });
166
+ return findings;
167
+ }
168
+ // The entry points are the package's promise about what can be reached from
169
+ // outside it, and nothing inside dist/.pikku mentions them — so the import
170
+ // walk below cannot see a `#pikku` that still points at the source tree.
171
+ for (const { name, target } of [
172
+ ...entryPointTargets(pkg.imports),
173
+ ...entryPointTargets(pkg.exports),
174
+ ]) {
175
+ const withoutWildcard = target.slice(2).split('*')[0];
176
+ if (!isPacked(join(pkgDir, withoutWildcard), pkgDir, pkg.files)) {
177
+ findings.push({
178
+ id: 'addon-entry-point-not-packed',
179
+ severity: 'error',
180
+ message: `"${name}" resolves to ${target}, which "files" does not publish — the entry point exists here and not for anyone who installs ${pkg.name ?? 'this addon'}`,
181
+ path: join(pkgDir, withoutWildcard),
182
+ fixHint: `Point it at the built copy under dist, or add ${withoutWildcard.split('/')[0]} to "files".`,
183
+ });
184
+ continue;
185
+ }
186
+ // Shipping the directory is not the same as producing the file. A wildcard
187
+ // names a directory whose contents are the point, so only a concrete
188
+ // target can be held to existing.
189
+ if (!target.includes('*') && !existsSync(join(pkgDir, withoutWildcard))) {
190
+ findings.push({
191
+ id: 'addon-entry-point-missing',
192
+ severity: 'error',
193
+ message: `"${name}" resolves to ${target}, which does not exist — importing it fails for anyone who installs ${pkg.name ?? 'this addon'}`,
194
+ path: join(pkgDir, withoutWildcard),
195
+ fixHint: 'Point the entry point at a file the build produces, or drop it from "exports".',
196
+ });
197
+ }
198
+ }
199
+ // Both generated directories ship, and they are not the same check twice.
200
+ // `exports` maps `./.pikku/*` to the root one, making it a public entry
201
+ // point whose imports climb to `<pkg>/types`, while the copy under dist
202
+ // reaches `<pkg>/dist/types` — two roots, two ways to fall outside the
203
+ // tarball.
204
+ const generatedRoots = GENERATED_DIRS.map((dir) => join(pkgDir, dir)).filter((dir) => existsSync(dir) && isPacked(dir, pkgDir, pkg.files));
205
+ // One missing file is imported by every generated file that needs its types,
206
+ // so reporting per import turns a single packaging mistake into a page of
207
+ // findings. Group by what is actually wrong: the thing that is not shipped.
208
+ const unresolved = new Map();
209
+ const unpacked = new Map();
210
+ const shippedFiles = (await Promise.all(generatedRoots.map((root) => walk(root)))).flat();
211
+ for (const file of shippedFiles) {
212
+ if (!/\.(ts|tsx|js|mjs|cjs)$/.test(file))
213
+ continue;
214
+ const source = await readTextSafe(file);
215
+ if (!source)
216
+ continue;
217
+ for (const specifier of relativeSpecifiers(source)) {
218
+ const candidates = resolveCandidates(specifier, dirname(file));
219
+ const target = candidates.find((candidate) => existsSync(candidate));
220
+ if (!target) {
221
+ // Keyed by the file that is missing rather than by the specifier: the
222
+ // same absent file is spelled `../types/x` from one directory and
223
+ // `../../types/x` from another, and it is still one thing to fix.
224
+ const missing = candidates[0];
225
+ const seen = unresolved.get(missing) ?? { specifier, files: [] };
226
+ seen.files.push(file);
227
+ unresolved.set(missing, seen);
228
+ }
229
+ else if (!isPacked(target, pkgDir, pkg.files)) {
230
+ const seen = unpacked.get(target) ?? { target, files: [] };
231
+ seen.files.push(file);
232
+ unpacked.set(target, seen);
233
+ }
234
+ }
235
+ }
236
+ const alsoIn = (files) => files.length > 1
237
+ ? ` (and ${files.length - 1} other generated file${files.length > 2 ? 's' : ''})`
238
+ : '';
239
+ for (const [missing, { specifier, files }] of unresolved) {
240
+ findings.push({
241
+ id: 'addon-shipped-import-unresolved',
242
+ severity: 'error',
243
+ message: `${relative(pkgDir, missing)} is not in the package, but ${files.length} shipped generated file${files.length === 1 ? '' : 's'} import${files.length === 1 ? 's' : ''} it (as "${specifier}" from ${relative(pkgDir, files[0])}) — anything installing ${pkg.name ?? 'this addon'} typechecks against a module that is not there`,
244
+ path: missing,
245
+ fixHint: 'Ship the file it names. The generated output is copied into dist, so whatever it imports has to be copied too — e.g. `cp -r .pikku types dist/` rather than `cp -r .pikku dist/`.',
246
+ });
247
+ }
248
+ for (const { target, files } of unpacked.values()) {
249
+ findings.push({
250
+ id: 'addon-shipped-import-not-packed',
251
+ severity: 'error',
252
+ message: `${relative(pkgDir, files[0])} imports ${relative(pkgDir, target)}${alsoIn(files)}, which exists but is excluded by "files" — it resolves here and not for anyone who installs the package`,
253
+ path: target,
254
+ fixHint: `Add ${relative(pkgDir, target).split(sep)[0]} to "files" in package.json, or move the file under a path already listed there.`,
255
+ });
256
+ }
257
+ return findings;
258
+ }
@@ -15,7 +15,7 @@ export type PersonaCheckConfig = {
15
15
  /**
16
16
  * The people this project can run as, and whether it can run as them.
17
17
  *
18
- * Shared by `pikku workspace validate` and `pikku fabric validate` — the two
18
+ * Shared by `pikku validate` and `pikku fabric validate` — the two
19
19
  * validators are separate implementations, and a check that only one of them
20
20
  * makes is a check half the projects never see.
21
21
  *
@@ -100,7 +100,7 @@ const hasActorSignIn = async (sourceFiles) => {
100
100
  /**
101
101
  * The people this project can run as, and whether it can run as them.
102
102
  *
103
- * Shared by `pikku workspace validate` and `pikku fabric validate` — the two
103
+ * Shared by `pikku validate` and `pikku fabric validate` — the two
104
104
  * validators are separate implementations, and a check that only one of them
105
105
  * makes is a check half the projects never see.
106
106
  *
@@ -36,6 +36,16 @@ const SCENARIO_FILE = /\.(scenario|scenarios|steps)\.tsx?$/;
36
36
  */
37
37
  const VIRTUAL_USER_DECLARATIONS = ['definePersonas', 'runVirtualUser'];
38
38
  const VIRTUAL_USER_FILE = /\.(virtual-user|vu)\.tsx?$/;
39
+ /**
40
+ * The declarations that grade an agent, and where they live.
41
+ *
42
+ * A scorer is a test of the agent that is also shipped, which is exactly why it
43
+ * needs its own file rather than sitting beside the agent it grades: the two
44
+ * are edited for opposite reasons, and a rubric buried in an agent definition
45
+ * is one nobody reviews as a rubric.
46
+ */
47
+ const SCORER_DECLARATIONS = ['pikkuAIScorer', 'pikkuAIJudge'];
48
+ const SCORER_FILE = /\.scorers?\.tsx?$/;
39
49
  const isGenerated = (path) => path.includes('.gen.') || path.includes(`${'/'}.pikku${'/'}`);
40
50
  const listSourceFiles = async (dir) => {
41
51
  if (!existsSync(dir))
@@ -119,5 +129,28 @@ export const runScenarioFileChecks = async (root, srcDirectories) => {
119
129
  ].join('\n'),
120
130
  });
121
131
  }
132
+ for (const file of files) {
133
+ if (SCORER_FILE.test(file) || isGenerated(file))
134
+ continue;
135
+ const text = await readTextSafe(file);
136
+ if (!text)
137
+ continue;
138
+ const used = SCORER_DECLARATIONS.filter((name) => new RegExp(`\\b${name}\\s*\\(`).test(text));
139
+ if (used.length === 0)
140
+ continue;
141
+ const rel = relative(root, file);
142
+ findings.push({
143
+ id: 'scorer-declared-outside-scorer-file',
144
+ severity: 'error',
145
+ message: `${rel} declares ${used.join(', ')} — scorers and judges must live in a *.scorer.ts file, not mixed into application code`,
146
+ path: file,
147
+ fixHint: [
148
+ 'Move the declaration into a dedicated file, e.g.:',
149
+ ` ${rel.replace(/[^/\\]+$/, 'grading.scorer.ts')}`,
150
+ 'A scorer grades the agent it sits next to, and is edited for the',
151
+ 'opposite reason — keeping it separate is what keeps it reviewable.',
152
+ ].join('\n'),
153
+ });
154
+ }
122
155
  return findings;
123
156
  };
@@ -48,7 +48,7 @@ export declare function readTextSafe(path: string): Promise<string | null>;
48
48
  /**
49
49
  * Every check that is true of any pikku project, regardless of where it deploys.
50
50
  *
51
- * `pikku workspace validate` is exactly this; `pikku fabric validate` is this
51
+ * `pikku validate`'s app-project check is exactly this; `pikku fabric validate` is this
52
52
  * plus the deploy-shaped checks (themes, frontends, the Cloudflare adapter, the
53
53
  * .gitignore contract). Before this module the two were separate walks over the
54
54
  * same project that duplicated sixteen findings verbatim, and each carried
@@ -85,7 +85,7 @@ const REQUIRED_SCAFFOLD = [
85
85
  /**
86
86
  * Every check that is true of any pikku project, regardless of where it deploys.
87
87
  *
88
- * `pikku workspace validate` is exactly this; `pikku fabric validate` is this
88
+ * `pikku validate`'s app-project check is exactly this; `pikku fabric validate` is this
89
89
  * plus the deploy-shaped checks (themes, frontends, the Cloudflare adapter, the
90
90
  * .gitignore contract). Before this module the two were separate walks over the
91
91
  * same project that duplicated sixteen findings verbatim, and each carried
@@ -0,0 +1,25 @@
1
+ import type { ValidateFinding } from './persona-checks.js';
2
+ /**
3
+ * A linked dependency resolves its own imports from its own checkout, so it can
4
+ * hand the project types built against a different version of a shared package.
5
+ * The symptom is a typecheck that OOMs rather than one that fails, so nothing
6
+ * else in this validator would catch it.
7
+ *
8
+ * Runs against the workspace root only. The mismatch is a property of the
9
+ * install, not of any one package in it, so running per workspace package would
10
+ * report the same pair once per package.
11
+ */
12
+ export declare function runTypeIdentityChecks(root: string): Promise<ValidateFinding[]>;
13
+ /**
14
+ * Preflight for codegen. Runs BEFORE the typecheck, because the failure it
15
+ * explains kills the process rather than failing it: a V8 heap OOM aborts, so
16
+ * nothing printed after the fact is ever seen. By the time the user has a
17
+ * symptom, the only thing that can help them is already on screen above it.
18
+ *
19
+ * Warns rather than throws. A skewed linked dependency is a strong signal, not
20
+ * a certainty — plenty of them are harmless, and refusing to build on one would
21
+ * break working setups over a heuristic.
22
+ */
23
+ export declare function warnOnSplitTypeIdentity(rootDir: string, logger: {
24
+ warn: (message: string) => void;
25
+ }): Promise<void>;
@@ -0,0 +1,218 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { lstat, readdir, realpath } from 'node:fs/promises';
3
+ import { dirname, join, relative } from 'node:path';
4
+ import { ErrorCode } from '@pikku/inspector';
5
+ import { readJsonSafe } from './shared-checks.js';
6
+ /**
7
+ * Packages whose TYPE identity matters, not just their runtime identity.
8
+ *
9
+ * Two copies of one of these at different versions give TypeScript two
10
+ * unrelated declarations of the same interface, and every place they meet
11
+ * becomes a structural comparison of the full shape. Inside a generic inference
12
+ * chain that compounds: one project went from a 1.3GB/13s typecheck to an
13
+ * unbounded OOM (8GB and 12GB ceilings both died, 7.7M types, single
14
+ * assignability checks taking 8s) because one dependency's `dist` was symlinked
15
+ * into a sibling checkout that carried its own better-auth. It reads as "codegen
16
+ * is slow", never as a version problem, which is why it is worth a check.
17
+ *
18
+ * Distinct from the duplicate-copy check, which is two copies of the SAME
19
+ * version splitting module state at runtime. This is a compile-time blow-up and
20
+ * only fires when the versions differ.
21
+ */
22
+ const TYPE_IDENTITY_PKGS = [
23
+ 'better-auth',
24
+ '@better-auth/core',
25
+ '@pikku/core',
26
+ 'kysely',
27
+ 'zod',
28
+ ];
29
+ /**
30
+ * Installed version of `pkg` as seen FROM `fromDir`, walking parent
31
+ * node_modules the way node resolution does. Used to ask what a linked
32
+ * dependency resolves in its own checkout, which is not what the project
33
+ * resolves.
34
+ */
35
+ async function versionResolvedFrom(fromDir, pkg) {
36
+ let dir = fromDir;
37
+ for (;;) {
38
+ const j = await readJsonSafe(join(dir, 'node_modules', pkg, 'package.json'));
39
+ if (j?.version)
40
+ return j.version;
41
+ const parent = dirname(dir);
42
+ if (parent === dir)
43
+ return null;
44
+ dir = parent;
45
+ }
46
+ }
47
+ /**
48
+ * Where `pkg` resolves for the project itself. The root alone is not enough:
49
+ * an isolated/pnpm-style install (bun's default) links dependencies under the
50
+ * workspace package that declares them and leaves the root node_modules
51
+ * without them, so probing only the root silently finds nothing.
52
+ */
53
+ async function projectResolvedVersion(root, pkg) {
54
+ const bases = [root];
55
+ for (const group of ['packages', 'apps', 'backends']) {
56
+ const groupDir = join(root, group);
57
+ if (!existsSync(groupDir))
58
+ continue;
59
+ const entries = await readdir(groupDir, { withFileTypes: true }).catch(() => []);
60
+ for (const d of entries) {
61
+ if (d.isDirectory())
62
+ bases.push(join(groupDir, d.name));
63
+ }
64
+ }
65
+ for (const base of bases) {
66
+ const j = await readJsonSafe(join(base, 'node_modules', pkg, 'package.json'));
67
+ if (j?.version)
68
+ return { version: j.version, from: base };
69
+ }
70
+ return null;
71
+ }
72
+ /**
73
+ * Dependencies whose code physically lives outside the project: a `link:` or
74
+ * `portal:` dep, or a hand-made symlink into a sibling checkout. Only these can
75
+ * introduce a second version of a type-identity package, because a normal
76
+ * install dedupes through the lockfile.
77
+ *
78
+ * The symlink is often NOT the package directory but a build output inside it
79
+ * (`node_modules/@scope/pkg/dist -> ../../../other-repo/packages/pkg/dist`),
80
+ * which still moves type resolution to the other tree since TypeScript resolves
81
+ * symlinks to their realpath. So each candidate subdir is probed too.
82
+ *
83
+ * Only symlinks are resolved. `realpath` lstats every component of the path, so
84
+ * running it over every installed package costs 20x more on a hoisted install
85
+ * (1781 packages at the root) than on an isolated one (35) — and a path that
86
+ * traverses no symlink cannot leave the project anyway. `readdir` already hands
87
+ * back the entry type, so ruling a package out is free.
88
+ */
89
+ async function externalDependencyRoots(root) {
90
+ const found = new Map();
91
+ const nodeModules = join(root, 'node_modules');
92
+ if (!existsSync(nodeModules))
93
+ return found;
94
+ // Compare realpath against realpath: on macOS the temp/project path is often
95
+ // itself a symlink (/var -> /private/var), which would otherwise make every
96
+ // dependency look external.
97
+ const realRoot = await realpath(root).catch(() => root);
98
+ const topLevel = await readdir(nodeModules, { withFileTypes: true }).catch(() => []);
99
+ const pkgDirs = [];
100
+ for (const entry of topLevel) {
101
+ if (entry.name.startsWith('.'))
102
+ continue;
103
+ if (entry.name.startsWith('@')) {
104
+ const scoped = await readdir(join(nodeModules, entry.name), {
105
+ withFileTypes: true,
106
+ }).catch(() => []);
107
+ for (const inner of scoped) {
108
+ pkgDirs.push({
109
+ dir: join(nodeModules, entry.name, inner.name),
110
+ link: inner.isSymbolicLink(),
111
+ });
112
+ }
113
+ }
114
+ else {
115
+ pkgDirs.push({
116
+ dir: join(nodeModules, entry.name),
117
+ link: entry.isSymbolicLink(),
118
+ });
119
+ }
120
+ }
121
+ const linkTarget = async (path) => {
122
+ const stats = await lstat(path).catch(() => null);
123
+ if (!stats?.isSymbolicLink())
124
+ return null;
125
+ return realpath(path).catch(() => null);
126
+ };
127
+ const isExternal = (real) => relative(realRoot, real).startsWith('..');
128
+ for (const { dir: pkgDir, link } of pkgDirs) {
129
+ // A package linked to a path inside the project (bun's .bun store) is not
130
+ // external, but the build output *inside* that target still can be.
131
+ const target = link ? await realpath(pkgDir).catch(() => null) : null;
132
+ if (link && !target)
133
+ continue;
134
+ const candidates = [
135
+ target && isExternal(target) ? target : null,
136
+ await linkTarget(join(target ?? pkgDir, 'dist')),
137
+ ];
138
+ for (const real of candidates) {
139
+ if (!real || !isExternal(real))
140
+ continue;
141
+ const name = relative(nodeModules, pkgDir);
142
+ // `real` may point at a build output (…/pkg/dist); report the linked
143
+ // package's own root so the message names something a reader can act on.
144
+ let owner = real;
145
+ while (!existsSync(join(owner, 'package.json')) &&
146
+ dirname(owner) !== owner) {
147
+ owner = dirname(owner);
148
+ }
149
+ if (!found.has(name))
150
+ found.set(name, owner);
151
+ break;
152
+ }
153
+ }
154
+ return found;
155
+ }
156
+ /**
157
+ * A linked dependency resolves its own imports from its own checkout, so it can
158
+ * hand the project types built against a different version of a shared package.
159
+ * The symptom is a typecheck that OOMs rather than one that fails, so nothing
160
+ * else in this validator would catch it.
161
+ *
162
+ * Runs against the workspace root only. The mismatch is a property of the
163
+ * install, not of any one package in it, so running per workspace package would
164
+ * report the same pair once per package.
165
+ */
166
+ export async function runTypeIdentityChecks(root) {
167
+ const findings = [];
168
+ const external = await externalDependencyRoots(root);
169
+ if (external.size === 0)
170
+ return findings;
171
+ for (const pkg of TYPE_IDENTITY_PKGS) {
172
+ const local = await projectResolvedVersion(root, pkg);
173
+ if (!local)
174
+ continue;
175
+ const ours = local.version;
176
+ for (const [depName, depRoot] of external) {
177
+ const theirs = await versionResolvedFrom(depRoot, pkg);
178
+ if (!theirs || theirs === ours)
179
+ continue;
180
+ findings.push({
181
+ id: `split-type-identity-${depName.replace(/[@/]/g, '-')}-${pkg.replace(/[@/]/g, '-')}`,
182
+ severity: 'error',
183
+ message: `"${depName}" is linked to ${depRoot} and resolves ${pkg}@${theirs} there, while this project resolves ${pkg}@${ours} — two type identities for ${pkg}`,
184
+ path: join(root, 'node_modules', depName),
185
+ fixHint: [
186
+ `TypeScript treats the two ${pkg} declarations as unrelated types and structurally compares them wherever they meet, which can make a typecheck OOM instead of fail.`,
187
+ `Align the versions so both trees resolve one ${pkg}: either bump ${pkg} to ${theirs} here, or to ${ours} in ${depRoot}.`,
188
+ `If the link is no longer needed, remove it and reinstall so "${depName}" comes from the registry.`,
189
+ ].join('\n'),
190
+ });
191
+ }
192
+ }
193
+ return findings;
194
+ }
195
+ /**
196
+ * Preflight for codegen. Runs BEFORE the typecheck, because the failure it
197
+ * explains kills the process rather than failing it: a V8 heap OOM aborts, so
198
+ * nothing printed after the fact is ever seen. By the time the user has a
199
+ * symptom, the only thing that can help them is already on screen above it.
200
+ *
201
+ * Warns rather than throws. A skewed linked dependency is a strong signal, not
202
+ * a certainty — plenty of them are harmless, and refusing to build on one would
203
+ * break working setups over a heuristic.
204
+ */
205
+ export async function warnOnSplitTypeIdentity(rootDir, logger) {
206
+ if (process.env?.PIKKU_SKIP_TYPE_IDENTITY_CHECK)
207
+ return;
208
+ const findings = await runTypeIdentityChecks(rootDir).catch(() => []);
209
+ if (findings.length === 0)
210
+ return;
211
+ logger.warn(`[${ErrorCode.SPLIT_TYPE_IDENTITY}] ${findings.length === 1 ? 'A linked dependency resolves a shared package' : 'Linked dependencies resolve shared packages'} at a different version than this project:\n` +
212
+ findings.map((f) => ` ${f.message}`).join('\n') +
213
+ `\nTypeScript treats each pair as two unrelated types and structurally compares them\n` +
214
+ `wherever they meet, which inside a generic inference chain can exhaust the heap —\n` +
215
+ `codegen then dies of memory pressure instead of reporting an error.\n\n` +
216
+ `Fix: align the versions so both trees resolve one copy, or drop the link and\n` +
217
+ `reinstall. Set PIKKU_SKIP_TYPE_IDENTITY_CHECK=1 to silence this.`);
218
+ }
@@ -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>;