@powerhousedao/ph-cli 6.2.3 → 6.3.0-dev.10

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 (193) hide show
  1. package/README.md +21 -0
  2. package/dist/build-CD_KQkCH.mjs +4 -0
  3. package/dist/build-DDG00Wbj.mjs +3067 -0
  4. package/dist/build-DDG00Wbj.mjs.map +1 -0
  5. package/dist/check-B8oqVMg7.mjs +65 -0
  6. package/dist/check-B8oqVMg7.mjs.map +1 -0
  7. package/dist/check-CpzjVXHj.mjs +4 -0
  8. package/dist/check-Weu9n8OQ.mjs +81 -0
  9. package/dist/check-Weu9n8OQ.mjs.map +1 -0
  10. package/dist/classic-args-mH_DVsgC.mjs +48 -0
  11. package/dist/classic-args-mH_DVsgC.mjs.map +1 -0
  12. package/dist/classic-warnings-BR0S6lr5.mjs +179 -0
  13. package/dist/classic-warnings-BR0S6lr5.mjs.map +1 -0
  14. package/dist/{cli-connect-override-b4kKqgOZ.mjs → cli-connect-override-D22yFWlC.mjs} +6 -29
  15. package/dist/cli-connect-override-D22yFWlC.mjs.map +1 -0
  16. package/dist/cli.mjs +46 -1341
  17. package/dist/cli.mjs.map +1 -1
  18. package/dist/compound-DKi56SSx-CXQHhS6t.mjs +2911 -0
  19. package/dist/compound-DKi56SSx-CXQHhS6t.mjs.map +1 -0
  20. package/dist/connect-build-Bd6sSVwp.mjs +322 -0
  21. package/dist/connect-build-Bd6sSVwp.mjs.map +1 -0
  22. package/dist/{connect-config-_kiSMsbG.mjs → connect-config-CVU4xhti.mjs} +5 -5
  23. package/dist/{connect-config-_kiSMsbG.mjs.map → connect-config-CVU4xhti.mjs.map} +1 -1
  24. package/dist/connect-preview-CdFvlANO.mjs +49 -0
  25. package/dist/connect-preview-CdFvlANO.mjs.map +1 -0
  26. package/dist/connect-studio-BnfhpIv8.mjs +97 -0
  27. package/dist/connect-studio-BnfhpIv8.mjs.map +1 -0
  28. package/dist/{connect-studio-f3K1qPWd.mjs → connect-studio-D58ByAAn.mjs} +3 -3
  29. package/dist/definitions-worker.d.mts +98 -0
  30. package/dist/definitions-worker.d.mts.map +1 -0
  31. package/dist/definitions-worker.mjs +28 -0
  32. package/dist/definitions-worker.mjs.map +1 -0
  33. package/dist/dist-DXcB8fAF.mjs +542 -0
  34. package/dist/dist-DXcB8fAF.mjs.map +1 -0
  35. package/dist/evidence-CavwC5YV.mjs +134 -0
  36. package/dist/evidence-CavwC5YV.mjs.map +1 -0
  37. package/dist/explain-8OEXF2Dy.mjs +230 -0
  38. package/dist/explain-8OEXF2Dy.mjs.map +1 -0
  39. package/dist/export-DqbcbFU5.mjs +42 -0
  40. package/dist/export-DqbcbFU5.mjs.map +1 -0
  41. package/dist/external-M25AgDIE.d.mts +4277 -0
  42. package/dist/external-M25AgDIE.d.mts.map +1 -0
  43. package/dist/files-D6_euBBn.mjs +457 -0
  44. package/dist/files-D6_euBBn.mjs.map +1 -0
  45. package/dist/{generate-all-CIwP-3aa.mjs → generate-all-0YOnlZM0.mjs} +10 -5
  46. package/dist/generate-all-0YOnlZM0.mjs.map +1 -0
  47. package/dist/generate-app-hm6CJ_4O.mjs +72 -0
  48. package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
  49. package/dist/generate-desktop-shell-BovoRsR6.mjs +372 -0
  50. package/dist/generate-desktop-shell-BovoRsR6.mjs.map +1 -0
  51. package/dist/generate-document-model-BiD6ovXc.mjs +118 -0
  52. package/dist/generate-document-model-BiD6ovXc.mjs.map +1 -0
  53. package/dist/generate-editor-DBj_Pxwa.mjs +64 -0
  54. package/dist/generate-editor-DBj_Pxwa.mjs.map +1 -0
  55. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  56. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  57. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  58. package/dist/generate-migration-file-yK8uA70U.mjs +20 -0
  59. package/dist/generate-migration-file-yK8uA70U.mjs.map +1 -0
  60. package/dist/{generate-piece-QTt-ddt2.mjs → generate-piece-5Nyr2UZj.mjs} +18 -10
  61. package/dist/generate-piece-5Nyr2UZj.mjs.map +1 -0
  62. package/dist/{generate-piece-action-C5WTHsqu.mjs → generate-piece-action-DqR8BcoO.mjs} +10 -7
  63. package/dist/generate-piece-action-DqR8BcoO.mjs.map +1 -0
  64. package/dist/{generate-piece-trigger-DR10CPOG.mjs → generate-piece-trigger-CZaDD-cc.mjs} +8 -7
  65. package/dist/generate-piece-trigger-CZaDD-cc.mjs.map +1 -0
  66. package/dist/{generate-processor-DBtTkgo5.mjs → generate-processor-BVjOsfjJ.mjs} +20 -9
  67. package/dist/generate-processor-BVjOsfjJ.mjs.map +1 -0
  68. package/dist/generate-subgraph-DJZCr0Tk.mjs +86 -0
  69. package/dist/generate-subgraph-DJZCr0Tk.mjs.map +1 -0
  70. package/dist/get-version-ByaMbjqz.mjs +11 -0
  71. package/dist/get-version-ByaMbjqz.mjs.map +1 -0
  72. package/dist/index-H3AYe65i.d.mts +193 -0
  73. package/dist/index-H3AYe65i.d.mts.map +1 -0
  74. package/dist/{init-CIEMyAug.mjs → init-Ltg4cJzm.mjs} +29 -17
  75. package/dist/init-Ltg4cJzm.mjs.map +1 -0
  76. package/dist/inspect-CulIpVsF.mjs +52 -0
  77. package/dist/inspect-CulIpVsF.mjs.map +1 -0
  78. package/dist/{inspect-BpCB0TPo.mjs → inspect-zWJnBDMJ.mjs} +4 -4
  79. package/dist/{inspect-BpCB0TPo.mjs.map → inspect-zWJnBDMJ.mjs.map} +1 -1
  80. package/dist/install-added-dependencies-DnZFR3aE.mjs +18 -0
  81. package/dist/install-added-dependencies-DnZFR3aE.mjs.map +1 -0
  82. package/dist/keyframes-bFo9iDhT.mjs +201 -0
  83. package/dist/keyframes-bFo9iDhT.mjs.map +1 -0
  84. package/dist/mcp-VRTEA0Ib.mjs +263 -0
  85. package/dist/mcp-VRTEA0Ib.mjs.map +1 -0
  86. package/dist/migrate-BGFxHRgP.mjs +209 -0
  87. package/dist/migrate-BGFxHRgP.mjs.map +1 -0
  88. package/dist/migrate-document-models-CFNqYAgo.mjs +489 -0
  89. package/dist/migrate-document-models-CFNqYAgo.mjs.map +1 -0
  90. package/dist/migrate-subgraphs-BG-4KEzt.mjs +4 -0
  91. package/dist/migrate-subgraphs-CIksXwT7.mjs +710 -0
  92. package/dist/migrate-subgraphs-CIksXwT7.mjs.map +1 -0
  93. package/dist/module-dir-1avCXsBi.mjs +17 -0
  94. package/dist/module-dir-1avCXsBi.mjs.map +1 -0
  95. package/dist/npm-args-g1Tgel4s.mjs +78 -0
  96. package/dist/npm-args-g1Tgel4s.mjs.map +1 -0
  97. package/dist/offered-routes-imports-CQInWI6y.mjs +4 -0
  98. package/dist/offered-routes-imports-CalXK9dh.mjs +96 -0
  99. package/dist/offered-routes-imports-CalXK9dh.mjs.map +1 -0
  100. package/dist/ph-cli-commands-CcMT6rdd.mjs +4 -0
  101. package/dist/ph-cli-commands-Dy4vWwUm.mjs +1821 -0
  102. package/dist/ph-cli-commands-Dy4vWwUm.mjs.map +1 -0
  103. package/dist/render-3M3DwFzO.mjs +4 -0
  104. package/dist/render-SVfj3m8A.mjs +77 -0
  105. package/dist/render-SVfj3m8A.mjs.map +1 -0
  106. package/dist/run--de_-WAz.mjs +112 -0
  107. package/dist/run--de_-WAz.mjs.map +1 -0
  108. package/dist/run-LRGy7zGo.mjs +4 -0
  109. package/dist/run-sugar-DpznOP1e.mjs +56 -0
  110. package/dist/run-sugar-DpznOP1e.mjs.map +1 -0
  111. package/dist/runners/connect.d.mts +17 -0
  112. package/dist/runners/connect.d.mts.map +1 -0
  113. package/dist/runners/connect.mjs +83 -0
  114. package/dist/runners/connect.mjs.map +1 -0
  115. package/dist/runners/switchboard.d.mts +24 -0
  116. package/dist/runners/switchboard.d.mts.map +1 -0
  117. package/dist/runners/switchboard.mjs +178 -0
  118. package/dist/runners/switchboard.mjs.map +1 -0
  119. package/dist/schemas-DzgKfQIx.mjs +6024 -0
  120. package/dist/schemas-DzgKfQIx.mjs.map +1 -0
  121. package/dist/scripts/emit-runner-schemas.ts +24 -0
  122. package/dist/scripts/generate-commands-docs.ts +19 -0
  123. package/dist/scripts/manage-environment +0 -0
  124. package/dist/scripts/setup.sh +0 -0
  125. package/dist/subgraph-gate-BJ2PWXVY.mjs +26 -0
  126. package/dist/subgraph-gate-BJ2PWXVY.mjs.map +1 -0
  127. package/dist/subgraph-gate-j9ywj6KA.mjs +4 -0
  128. package/dist/subgraphs-7OYWwP-C.mjs +134 -0
  129. package/dist/subgraphs-7OYWwP-C.mjs.map +1 -0
  130. package/dist/{switchboard-migrate-7JQZM7-5.mjs → switchboard-migrate-BqSdKJ7u.mjs} +4 -5
  131. package/dist/switchboard-migrate-BqSdKJ7u.mjs.map +1 -0
  132. package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
  133. package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
  134. package/dist/{switchboard-reset-Ctegiqdm.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
  135. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  136. package/dist/sync-connect-routes-BtAsFPXN.mjs +4 -0
  137. package/dist/sync-connect-routes-t0Slg-P6.mjs +25 -0
  138. package/dist/sync-connect-routes-t0Slg-P6.mjs.map +1 -0
  139. package/dist/{utils-CvmDmCVd.mjs → utils-9KyRM0mf.mjs} +6 -34
  140. package/dist/{utils-CvmDmCVd.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
  141. package/dist/utils-TO9lB8Xs.mjs +4 -0
  142. package/dist/verify-D4V5VLnG.mjs +71 -0
  143. package/dist/verify-D4V5VLnG.mjs.map +1 -0
  144. package/dist/vetra-CVNZ46pK.mjs +352 -0
  145. package/dist/vetra-CVNZ46pK.mjs.map +1 -0
  146. package/dist/vetra-host-ChTpJiBJ.mjs +79 -0
  147. package/dist/vetra-host-ChTpJiBJ.mjs.map +1 -0
  148. package/dist/vetra-instance-CzhYIjxL.mjs +201 -0
  149. package/dist/vetra-instance-CzhYIjxL.mjs.map +1 -0
  150. package/dist/vetra-launch-qi10Unax.mjs +237 -0
  151. package/dist/vetra-launch-qi10Unax.mjs.map +1 -0
  152. package/dist/vetra-switchboard-BrkozIm7.mjs +4 -0
  153. package/dist/vetra-switchboard-tzdc14KA.mjs +230 -0
  154. package/dist/vetra-switchboard-tzdc14KA.mjs.map +1 -0
  155. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
  156. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  157. package/package.json +41 -15
  158. package/dist/build-CTvPQFMi.mjs +0 -4
  159. package/dist/build-sO3PcZxl.mjs +0 -166
  160. package/dist/build-sO3PcZxl.mjs.map +0 -1
  161. package/dist/cli-connect-override-b4kKqgOZ.mjs.map +0 -1
  162. package/dist/connect-build-BMaR9w4G.mjs +0 -153
  163. package/dist/connect-build-BMaR9w4G.mjs.map +0 -1
  164. package/dist/connect-preview-CzDqR-JN.mjs +0 -32
  165. package/dist/connect-preview-CzDqR-JN.mjs.map +0 -1
  166. package/dist/connect-studio-_-O1-oef.mjs +0 -36
  167. package/dist/connect-studio-_-O1-oef.mjs.map +0 -1
  168. package/dist/generate-all-CIwP-3aa.mjs.map +0 -1
  169. package/dist/generate-app-BTs1u-9l.mjs +0 -50
  170. package/dist/generate-app-BTs1u-9l.mjs.map +0 -1
  171. package/dist/generate-document-model-DhDQ_06X.mjs +0 -44
  172. package/dist/generate-document-model-DhDQ_06X.mjs.map +0 -1
  173. package/dist/generate-editor-CW7Do69u.mjs +0 -50
  174. package/dist/generate-editor-CW7Do69u.mjs.map +0 -1
  175. package/dist/generate-piece-QTt-ddt2.mjs.map +0 -1
  176. package/dist/generate-piece-action-C5WTHsqu.mjs.map +0 -1
  177. package/dist/generate-piece-trigger-DR10CPOG.mjs.map +0 -1
  178. package/dist/generate-processor-DBtTkgo5.mjs.map +0 -1
  179. package/dist/generate-subgraph-Dm27O59o.mjs +0 -42
  180. package/dist/generate-subgraph-Dm27O59o.mjs.map +0 -1
  181. package/dist/init-CIEMyAug.mjs.map +0 -1
  182. package/dist/install-added-dependencies-DVSbzler.mjs +0 -33
  183. package/dist/install-added-dependencies-DVSbzler.mjs.map +0 -1
  184. package/dist/migrate-B6QBYDNX.mjs +0 -83
  185. package/dist/migrate-B6QBYDNX.mjs.map +0 -1
  186. package/dist/switchboard-CgVB4U76.mjs +0 -87
  187. package/dist/switchboard-CgVB4U76.mjs.map +0 -1
  188. package/dist/switchboard-migrate-7JQZM7-5.mjs.map +0 -1
  189. package/dist/switchboard-nHCI3pha.mjs +0 -4
  190. package/dist/switchboard-reset-Ctegiqdm.mjs.map +0 -1
  191. package/dist/utils-C3c5YG6v.mjs +0 -4
  192. package/dist/vetra-s8gWslse.mjs +0 -627
  193. package/dist/vetra-s8gWslse.mjs.map +0 -1
@@ -0,0 +1,1821 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="41e7c60a-521a-5e9a-b35c-453ca4a658f6")}catch(e){}}();
3
+ import { n as skipInstallArgs } from "./install-added-dependencies-DnZFR3aE.mjs";
4
+ import { boolean, command, extendType, flag, multioption, number, oneOf, option, optional, positional, restPositionals, string, subcommands } from "cmd-ts";
5
+ import { AGENTS, accessTokenArgs, buildArgs, connectBuildArgs, connectConfigArgs, connectPreviewArgs, connectStudioArgs, debugArgs, hostCheckArgs, hostExportArgs, initArgs, inspectArgs, installArgs, keyframesArgs, listArgs, loginArgs, mcpArgs, migrateArgs, modelCheckArgs, modelInspectArgs, publishArgs, registryLoginArgs, switchboardArgs, uninstallArgs, unpublishArgs, vetraArgs } from "@powerhousedao/shared/clis/args";
6
+ import { DEFAULT_EXPIRY_SECONDS } from "@powerhousedao/shared/clis/constants";
7
+ import fs from "node:fs";
8
+ import path from "node:path";
9
+ import { PROCESSOR_APPS } from "@powerhousedao/shared/processors";
10
+ import { execSync } from "child_process";
11
+ import { execSync as execSync$1 } from "node:child_process";
12
+ import { createInterface } from "node:readline/promises";
13
+ //#region src/commands/access-token.ts
14
+ const accessToken = command({
15
+ name: "access-token",
16
+ description: `
17
+ The access-token command generates a bearer token for API authentication. This token
18
+ can be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).
19
+
20
+ This command:
21
+ 1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential
22
+ 2. Creates a JWT bearer token with configurable expiration
23
+ 3. Outputs the token to stdout (info to stderr) for easy piping
24
+
25
+ Prerequisites:
26
+ You must have a cryptographic identity. Run 'ph login' first to:
27
+ - Generate a keypair (stored in .ph/.keypair.json)
28
+ - Optionally link your Ethereum address (stored in .ph/.renown.json)
29
+
30
+ Token Details:
31
+ The generated token is a JWT (JSON Web Token) containing:
32
+ - Issuer (iss): Your CLI's DID (did:key:...)
33
+ - Subject (sub): Your CLI's DID
34
+ - Credential Subject: Chain ID, network ID, and address (if authenticated)
35
+ - Expiration (exp): Based on --expiry option
36
+ - Audience (aud): If --audience is specified
37
+
38
+ Output:
39
+ - Token information (DID, address, expiry) is printed to stderr
40
+ - The token itself is printed to stdout for easy piping/copying
41
+
42
+ This allows you to use the command in scripts:
43
+ TOKEN=$(ph access-token)
44
+ curl -H "Authorization: Bearer $TOKEN" http://localhost:4001/graphql
45
+
46
+ Usage with APIs:
47
+ Generate token and use with curl
48
+ TOKEN=$(ph access-token --expiry 1d)
49
+ curl -X POST http://localhost:4001/graphql \\
50
+ -H "Content-Type: application/json" \\
51
+ -H "Authorization: Bearer $TOKEN" \\
52
+ -d '{"query": "{ drives { id name } }"}'
53
+
54
+ Export as environment variable
55
+ export PH_ACCESS_TOKEN=$(ph access-token)
56
+
57
+ Notes:
58
+ - Tokens are self-signed using your CLI's private key
59
+ - No network request is made; tokens are generated locally
60
+ - The recipient API must trust your CLI's DID to accept the token
61
+ - For reactor-api, ensure AUTH_ENABLED=true to require authentication
62
+ `,
63
+ args: accessTokenArgs,
64
+ handler: async (args) => {
65
+ if (args.debug) console.log(args);
66
+ const { generateAccessToken, parseExpiry, formatExpiry } = await import("@renown/sdk/node");
67
+ const { getRenown } = await import("./auth-CNhbN5UM.mjs");
68
+ const renown = await getRenown();
69
+ let expiresIn = DEFAULT_EXPIRY_SECONDS;
70
+ if (args.expiry) expiresIn = parseExpiry(args.expiry);
71
+ const result = await generateAccessToken(renown, {
72
+ expiresIn,
73
+ aud: args.audience
74
+ });
75
+ console.error(`CLI DID: ${result.did}`);
76
+ console.error(`ETH Address: ${result.address}`);
77
+ console.error(`Token expires in: ${formatExpiry(expiresIn)}`);
78
+ console.error("");
79
+ console.log(result.token);
80
+ process.exit(0);
81
+ }
82
+ });
83
+ //#endregion
84
+ //#region src/commands/build.ts
85
+ const build$1 = command({
86
+ name: "build",
87
+ description: `
88
+ Build a Powerhouse package for publishing: a browser bundle and a node bundle of its
89
+ document models, scalars, editors, subgraphs and processors, type declarations, and its
90
+ stylesheet.
91
+
92
+ Pieces under pieces/ are built too, each into its own self-contained module under
93
+ dist/node/pieces/<name>, with a descriptor.json and package.json written beside it and
94
+ the piece listed in dist/powerhouse.manifest.json. A piece takes the package's version: an
95
+ entry in pieces/index.ts that declares version fails the build. A package that ships only
96
+ pieces is an ordinary package: it carries the same boilerplate, and every step above runs
97
+ for it too.
98
+
99
+ tsc runs first. If it reports type errors the build asks whether to go ahead, and stops
100
+ where it can't ask. --ignore-type-errors builds without asking; a package built that way
101
+ can load and still fail at runtime, so don't publish it.`,
102
+ args: buildArgs,
103
+ handler: async (args) => {
104
+ if (args.debug) console.log(args);
105
+ try {
106
+ const { runBuild } = await import("./build-CD_KQkCH.mjs");
107
+ await runBuild(args, {
108
+ checkDefinitions: true,
109
+ ownsProcess: true
110
+ });
111
+ } catch (error) {
112
+ console.error(args.debug || !(error instanceof Error) ? error : error.message);
113
+ process.exit(1);
114
+ }
115
+ }
116
+ });
117
+ //#endregion
118
+ //#region src/commands/connect.ts
119
+ const studio = command({
120
+ name: "studio",
121
+ description: `The studio command starts the Connect Studio, a development environment for building
122
+ and testing Powerhouse applications. It provides a visual interface for working with
123
+ your project.
124
+
125
+ This command:
126
+ 1. Starts a local Connect Studio server
127
+ 2. Provides a web interface for development
128
+ 3. Allows you to interact with your project components
129
+ 4. Supports various configuration options for customization
130
+ `,
131
+ args: connectStudioArgs,
132
+ handler: async (args) => {
133
+ if (args.debug) console.log(args);
134
+ const { runConnectStudio } = await import("./connect-studio-D58ByAAn.mjs");
135
+ await runConnectStudio(args, void 0, void 0, { reloadOnConfigChange: true });
136
+ }
137
+ });
138
+ const build = command({
139
+ name: "build",
140
+ description: `The Connect build command creates a production build with the project's local and
141
+ external packages included.
142
+
143
+ Runtime-config overrides (all combinable — last wins on collision):
144
+ ph connect build Build with the current source config.
145
+ ph connect build <key> <value> Build with a positional override applied (e.g. ph connect build connect.renown.url https://renown.staging).
146
+ ph connect build --<field> <value> Build with a per-field flag override (e.g. --renown-url https://renown.staging).
147
+ ph connect build --json '{"app":{"workflowsEnabled":true}}'
148
+ Build with a bulk override. The payload is the connect.* block
149
+ without the "connect" wrapper; unknown keys are rejected.
150
+
151
+ Build has no read mode; passing only <key> without <value> errors out (use \`ph connect config <key>\` to read).
152
+ `,
153
+ args: connectBuildArgs,
154
+ handler: async (args) => {
155
+ if (args.debug) console.log(args);
156
+ const { runConnectBuild } = await import("./connect-build-Bd6sSVwp.mjs");
157
+ await runConnectBuild(args);
158
+ process.exit(0);
159
+ }
160
+ });
161
+ const preview = command({
162
+ name: "preview",
163
+ description: `The Connect preview command previews a built Connect project.
164
+ NOTE: You must run \`ph connect build\` first
165
+ `,
166
+ args: connectPreviewArgs,
167
+ handler: async (args) => {
168
+ if (args.debug) console.log(args);
169
+ const { runConnectPreview } = await import("./connect-preview-CdFvlANO.mjs");
170
+ await runConnectPreview(args);
171
+ }
172
+ });
173
+ const config = command({
174
+ name: "config",
175
+ description: `Read or update Connect's runtime configuration (powerhouse.config.json).
176
+
177
+ Modes (mutually exclusive — positional, --get, --json, and field flags cannot be combined):
178
+ ph connect config List the effective connect.* block (defaults < source).
179
+ ph connect config <key> Get the value at the dotted path (e.g. ph connect config connect.renown.url).
180
+ ph connect config --get <dotted.path> Same as positional <key> (kept for backward compat).
181
+ ph connect config <key> <value> Set a single field and dual-write to source + dist (positional).
182
+ ph connect config --<field> <value> Set a single field via per-field flag (e.g. --renown-url https://renown.id).
183
+ ph connect config --json '{"renown":{"url":"…"}}'
184
+ Bulk-set multiple fields and dual-write. The payload is the connect.*
185
+ block without the "connect" wrapper; unknown keys are rejected.
186
+
187
+ Writes go to:
188
+ - <project>/powerhouse.config.json (source — picked up by the next build)
189
+ - <dist-dir>/powerhouse.config.json (if it exists — the currently-served SPA picks it up on refresh)
190
+ `,
191
+ args: connectConfigArgs,
192
+ handler: async (args) => {
193
+ const { runConnectConfig } = await import("./connect-config-CVU4xhti.mjs");
194
+ await runConnectConfig(args);
195
+ }
196
+ });
197
+ const connect = subcommands({
198
+ name: "connect",
199
+ description: `Powerhouse Connect commands. Use with \`studio\`, \`build\`, \`preview\`, or \`config\`. Defaults to \`studio\` if not specified.`,
200
+ cmds: {
201
+ studio,
202
+ build,
203
+ preview,
204
+ config
205
+ }
206
+ });
207
+ //#endregion
208
+ //#region src/commands/generate-all.ts
209
+ const generateAllCmd = command({
210
+ name: "all",
211
+ description: "Re-generate all modules in the current project",
212
+ args: { extract: flag({
213
+ long: "extract",
214
+ short: "x",
215
+ description: "Instead of generating code, write a spec for every module into specs/ (one-shot migration to documents-as-source-of-truth)"
216
+ }) },
217
+ handler: async (args) => {
218
+ const { startGenerateAll } = await import("./generate-all-0YOnlZM0.mjs");
219
+ await startGenerateAll(args, process.cwd());
220
+ process.exit(0);
221
+ }
222
+ });
223
+ //#endregion
224
+ //#region src/utils/fs-args.ts
225
+ const ExistingPath = extendType(string, {
226
+ displayName: "path",
227
+ description: "An existing path",
228
+ from(str) {
229
+ const resolved = path.resolve(str);
230
+ if (!fs.existsSync(resolved)) return Promise.reject(/* @__PURE__ */ new Error("Path doesn't exist"));
231
+ return Promise.resolve(resolved);
232
+ }
233
+ });
234
+ extendType(ExistingPath, {
235
+ displayName: "dir",
236
+ description: "A path to a directory or a file within a directory",
237
+ from(resolved) {
238
+ return Promise.resolve(fs.statSync(resolved).isDirectory() ? resolved : path.dirname(resolved));
239
+ }
240
+ });
241
+ /** An existing file. */
242
+ const File = extendType(ExistingPath, {
243
+ displayName: "file",
244
+ description: "A file in the file system",
245
+ from(resolved) {
246
+ if (!fs.statSync(resolved).isFile()) return Promise.reject(/* @__PURE__ */ new Error("Provided path is not a file"));
247
+ return Promise.resolve(resolved);
248
+ }
249
+ });
250
+ /** A module's directory name or path, resolved by the command against the project. */
251
+ const ModuleDir = extendType(string, {
252
+ displayName: "dir",
253
+ description: "A module's directory name or path",
254
+ from: (dir) => Promise.resolve(dir)
255
+ });
256
+ //#endregion
257
+ //#region src/utils/comma-separated.ts
258
+ /** Splits comma-separated values so `-t "a,b"` means the same as `-t a -t b`
259
+ * instead of yielding the single value `"a,b"`, which matches nothing. */
260
+ function splitCommaSeparated(values) {
261
+ return values.flatMap((value) => value.split(",")).map((value) => value.trim()).filter((value) => value.length > 0);
262
+ }
263
+ /** `multioption` type accepting repeated and/or comma-separated values. */
264
+ const CommaSeparatedStrings = { from: (values) => Promise.resolve(splitCommaSeparated(values)) };
265
+ //#endregion
266
+ //#region src/commands/generate-app.ts
267
+ const generateAppCmd = command({
268
+ name: "app",
269
+ description: "Generate a drive app",
270
+ args: {
271
+ name: option({
272
+ type: optional(string),
273
+ long: "name",
274
+ short: "n",
275
+ description: "The name of the drive app to generate"
276
+ }),
277
+ allowedDocumentTypes: multioption({
278
+ type: optional(CommaSeparatedStrings),
279
+ long: "document-types",
280
+ short: "t",
281
+ description: "The document types allowed by the new app (repeatable or comma-separated)"
282
+ }),
283
+ document: option({
284
+ type: optional(File),
285
+ long: "document",
286
+ short: "d",
287
+ description: "Path to a powerhouse/app spec file (.phd or .json) to drive codegen"
288
+ }),
289
+ dir: option({
290
+ type: optional(ModuleDir),
291
+ long: "dir",
292
+ description: "Name of the directory of an existing app to re-generate (my-app or editors/my-app)"
293
+ }),
294
+ disableDragAndDrop: flag({
295
+ type: boolean,
296
+ long: "disable-drag-and-drop",
297
+ description: "Do not allow drag and drop in this drive app.",
298
+ defaultValue: () => false,
299
+ defaultValueIsSerializable: true
300
+ }),
301
+ all: flag({
302
+ long: "all",
303
+ short: "a",
304
+ description: "Re-generate all existing apps in the current project"
305
+ }),
306
+ extract: flag({
307
+ long: "extract",
308
+ short: "x",
309
+ description: "Write a powerhouse/app spec for each existing drive app into specs/apps/"
310
+ }),
311
+ ...debugArgs
312
+ },
313
+ handler: async (args) => {
314
+ const { startGenerateApp } = await import("./generate-app-hm6CJ_4O.mjs");
315
+ await startGenerateApp(args, process.cwd());
316
+ process.exit(0);
317
+ }
318
+ });
319
+ //#endregion
320
+ //#region src/commands/generate-connect-routes.ts
321
+ const generateConnectRoutesCmd = command({
322
+ name: "connect-routes",
323
+ description: "Generate .ph/connect-routes.gen.ts, the route tree hosts/connect/routes/ type-checks against, and fail if a route the package offers imports @powerhousedao/connect",
324
+ args: { ...debugArgs },
325
+ handler: async () => {
326
+ const { syncProjectConnectRoutes } = await import("./sync-connect-routes-BtAsFPXN.mjs");
327
+ const { checkOfferedRoutesImports } = await import("./offered-routes-imports-CQInWI6y.mjs");
328
+ await syncProjectConnectRoutes(process.cwd());
329
+ await checkOfferedRoutesImports(process.cwd());
330
+ }
331
+ });
332
+ //#endregion
333
+ //#region src/commands/generate-desktop-shell.ts
334
+ const generateDesktopShellCmd = command({
335
+ name: "desktop-shell",
336
+ description: "Scaffold a builder-owned desktop identity (hosts/desktop/app.json + icon). `ph run desktop dev|build` then projects it into a native Tauri shell — no Rust.",
337
+ args: {
338
+ name: option({
339
+ type: optional(string),
340
+ long: "name",
341
+ short: "n",
342
+ description: "Product name (window title + macOS app name). Default: the project's package name."
343
+ }),
344
+ identifier: option({
345
+ type: optional(string),
346
+ long: "identifier",
347
+ short: "i",
348
+ description: "Reverse-DNS app identifier, e.g. com.acme.app. Default: inc.powerhouse.desktop.<project>."
349
+ }),
350
+ force: flag({
351
+ long: "force",
352
+ short: "f",
353
+ description: "Overwrite an existing app.json (protects edits by default)."
354
+ }),
355
+ ...debugArgs
356
+ },
357
+ handler: async (args) => {
358
+ const { startGenerateDesktopShell } = await import("./generate-desktop-shell-BovoRsR6.mjs");
359
+ startGenerateDesktopShell(args, process.cwd());
360
+ process.exit(0);
361
+ }
362
+ });
363
+ //#endregion
364
+ //#region src/commands/generate-document-model.ts
365
+ const generateDocumentModelCmd = command({
366
+ name: "document-model",
367
+ aliases: ["doc"],
368
+ description: "Generate a document model",
369
+ args: {
370
+ document: option({
371
+ type: optional(File),
372
+ long: "document",
373
+ short: "d",
374
+ description: "Path to a document model spec (.phd or .json) to generate from"
375
+ }),
376
+ dir: option({
377
+ type: optional(ModuleDir),
378
+ long: "dir",
379
+ description: "Name of the directory of an existing document model to re-generate (my-document-model or document-models/my-document-model)"
380
+ }),
381
+ all: flag({
382
+ long: "all",
383
+ short: "a",
384
+ description: "Re-generate all existing document models in the current project"
385
+ }),
386
+ extract: flag({
387
+ long: "extract",
388
+ short: "x",
389
+ description: "Write a powerhouse/document-model spec for each existing document model into specs/document-models/"
390
+ }),
391
+ /** @experimental Code-first scaffolding is being tested in production. */
392
+ name: option({
393
+ type: optional(string),
394
+ long: "name",
395
+ short: "n",
396
+ description: "Experimental. Create a code-first document model with this name, with its editor"
397
+ }),
398
+ /** @experimental Chooses code-first authoring for the model --name creates. */
399
+ codeFirst: flag({
400
+ long: "code-first",
401
+ description: "Experimental. With --name, create the model code-first. Existing models of both styles are discovered without it; ph migrate --document-model converts a schema-first one"
402
+ }),
403
+ ...debugArgs
404
+ },
405
+ handler: async (args) => {
406
+ const { startGenerateDocumentModel } = await import("./generate-document-model-BiD6ovXc.mjs");
407
+ await startGenerateDocumentModel(args, process.cwd());
408
+ process.exit(0);
409
+ }
410
+ });
411
+ //#endregion
412
+ //#region src/commands/generate-editor.ts
413
+ const generateEditorCmd = command({
414
+ name: "editor",
415
+ description: "Generate a document editor",
416
+ args: {
417
+ name: option({
418
+ type: optional(string),
419
+ long: "name",
420
+ short: "n",
421
+ description: "The name of the document editor to generate"
422
+ }),
423
+ documentType: option({
424
+ type: optional(string),
425
+ long: "document-type",
426
+ short: "t",
427
+ description: "The document type for the new editor"
428
+ }),
429
+ document: option({
430
+ type: optional(File),
431
+ long: "document",
432
+ short: "d",
433
+ description: "Path to a powerhouse/document-editor spec file (.phd or .json) to drive codegen"
434
+ }),
435
+ dir: option({
436
+ type: optional(ModuleDir),
437
+ long: "dir",
438
+ description: "Name of the directory of an existing editor to re-generate (my-editor or editors/my-editor)"
439
+ }),
440
+ all: flag({
441
+ long: "all",
442
+ short: "a",
443
+ description: "Re-generate all existing editors in the current project"
444
+ }),
445
+ extract: flag({
446
+ long: "extract",
447
+ short: "x",
448
+ description: "Write a powerhouse/document-editor spec for each existing editor into specs/editors/"
449
+ }),
450
+ ...debugArgs
451
+ },
452
+ handler: async (args) => {
453
+ const { startGenerateEditor } = await import("./generate-editor-DBj_Pxwa.mjs");
454
+ await startGenerateEditor(args, process.cwd());
455
+ process.exit(0);
456
+ }
457
+ });
458
+ //#endregion
459
+ //#region src/commands/generate-hosts.ts
460
+ const generateHostsCmd = command({
461
+ name: "hosts",
462
+ description: "Generate hosts/<name>/outputs.js + outputs.d.ts (typed $output token trees) for every host whose runner declares outputs, and refresh hosts/types.d.ts. Rerun after changing a producer's runner or declared drives: a stale outputs.js fails the load.",
463
+ args: {},
464
+ handler: async () => {
465
+ const { startGenerateHosts } = await import("./generate-hosts-RWj7WPHZ.mjs");
466
+ const ok = await startGenerateHosts(process.cwd());
467
+ process.exit(ok ? 0 : 1);
468
+ }
469
+ });
470
+ //#endregion
471
+ //#region src/commands/generate-migration-file.ts
472
+ const generateMigrationFileCmd = command({
473
+ name: "migration-file",
474
+ description: "Generate a migration file",
475
+ args: {
476
+ migrationFile: option({
477
+ type: string,
478
+ long: "path",
479
+ short: "p",
480
+ description: "Path to the migration file"
481
+ }),
482
+ schemaFile: option({
483
+ type: optional(string),
484
+ long: "schema-file",
485
+ description: "Path to the output file. Defaults to './schema.ts'"
486
+ }),
487
+ ...skipInstallArgs,
488
+ ...debugArgs
489
+ },
490
+ handler: async (args) => {
491
+ const { startGenerateMigrationFile } = await import("./generate-migration-file-yK8uA70U.mjs");
492
+ await startGenerateMigrationFile(args, process.cwd());
493
+ process.exit(0);
494
+ }
495
+ });
496
+ //#endregion
497
+ //#region src/commands/generate-piece-action.ts
498
+ const generatePieceActionCmd = command({
499
+ name: "piece-action",
500
+ description: "Generate an action inside an existing piece",
501
+ args: {
502
+ namePositional: positional({
503
+ type: optional(string),
504
+ displayName: "name",
505
+ description: "The name of the action, e.g. get-record"
506
+ }),
507
+ name: option({
508
+ type: optional(string),
509
+ long: "name",
510
+ short: "n",
511
+ description: "The name of the action to generate"
512
+ }),
513
+ piece: option({
514
+ type: optional(string),
515
+ long: "piece",
516
+ short: "p",
517
+ description: "The piece directory under pieces/ to add the action to. Optional when the project ships exactly one piece."
518
+ }),
519
+ requireReactor: option({
520
+ type: optional(oneOf(["read", "write"])),
521
+ long: "require-reactor",
522
+ description: "Declare reactor access for the action: read, or write (which includes read). The action then gets context.reactor"
523
+ }),
524
+ defaultTimeoutSeconds: option({
525
+ type: optional(number),
526
+ long: "default-timeout-seconds",
527
+ description: "Write defaultTimeoutSeconds: the step timeout used when the workflow sets none"
528
+ }),
529
+ defaultMaxAttempts: option({
530
+ type: optional(number),
531
+ long: "default-max-attempts",
532
+ description: "Write defaultRetry: { maxAttempts }: the attempts (1 is no retry) used when the workflow sets no retry"
533
+ }),
534
+ ...skipInstallArgs,
535
+ ...debugArgs
536
+ },
537
+ handler: async (args) => {
538
+ const { startGeneratePieceAction } = await import("./generate-piece-action-DqR8BcoO.mjs");
539
+ await startGeneratePieceAction(args, process.cwd());
540
+ process.exit(0);
541
+ }
542
+ });
543
+ //#endregion
544
+ //#region src/commands/generate-piece-trigger.ts
545
+ const generatePieceTriggerCmd = command({
546
+ name: "piece-trigger",
547
+ description: "Generate a trigger inside an existing piece",
548
+ args: {
549
+ namePositional: positional({
550
+ type: optional(string),
551
+ displayName: "name",
552
+ description: "The name of the trigger, e.g. new-record"
553
+ }),
554
+ name: option({
555
+ type: optional(string),
556
+ long: "name",
557
+ short: "n",
558
+ description: "The name of the trigger to generate"
559
+ }),
560
+ piece: option({
561
+ type: optional(string),
562
+ long: "piece",
563
+ short: "p",
564
+ description: "The piece directory under pieces/ to add the trigger to. Optional when the project ships exactly one piece."
565
+ }),
566
+ strategy: option({
567
+ type: oneOf(["polling", "webhook"]),
568
+ long: "strategy",
569
+ description: "How the trigger fires: polled on a schedule, or delivered to a webhook",
570
+ defaultValue: () => "polling",
571
+ defaultValueIsSerializable: true
572
+ }),
573
+ requireReactor: option({
574
+ type: optional(oneOf(["read", "write"])),
575
+ long: "require-reactor",
576
+ description: "Declare reactor access for the trigger: read, or write (which includes read). Its hooks then get context.reactor"
577
+ }),
578
+ ...skipInstallArgs,
579
+ ...debugArgs
580
+ },
581
+ handler: async (args) => {
582
+ const { startGeneratePieceTrigger } = await import("./generate-piece-trigger-CZaDD-cc.mjs");
583
+ await startGeneratePieceTrigger(args, process.cwd());
584
+ process.exit(0);
585
+ }
586
+ });
587
+ //#endregion
588
+ //#region src/commands/generate-piece.ts
589
+ const generatePieceCmd = command({
590
+ name: "piece",
591
+ description: "Generate a piece: a connector whose actions and triggers a workflow can call",
592
+ args: {
593
+ namePositional: positional({
594
+ type: optional(string),
595
+ displayName: "name",
596
+ description: "The name of the piece to generate. Its directory is the kebab-case of this."
597
+ }),
598
+ name: option({
599
+ type: optional(string),
600
+ long: "name",
601
+ short: "n",
602
+ description: "The name of the piece to generate"
603
+ }),
604
+ id: option({
605
+ type: optional(string),
606
+ long: "id",
607
+ description: "The piece id, the pieceName a workflow step holds, e.g. @acme/piece-crm. Defaults to one derived from the package name."
608
+ }),
609
+ auth: option({
610
+ type: oneOf([
611
+ "none",
612
+ "secret",
613
+ "custom"
614
+ ]),
615
+ long: "auth",
616
+ description: "The kind of connection the piece asks for",
617
+ defaultValue: () => "custom",
618
+ defaultValueIsSerializable: true
619
+ }),
620
+ description: option({
621
+ type: optional(string),
622
+ long: "description",
623
+ description: "One line describing what the piece connects to"
624
+ }),
625
+ dir: option({
626
+ type: optional(ModuleDir),
627
+ long: "dir",
628
+ description: "Name of the directory of an existing piece to re-register (my-piece or pieces/my-piece)"
629
+ }),
630
+ all: flag({
631
+ long: "all",
632
+ short: "a",
633
+ description: "Re-register every piece in pieces/: refresh the pieces list and the manifest, and prune what is gone"
634
+ }),
635
+ ...skipInstallArgs,
636
+ ...debugArgs
637
+ },
638
+ handler: async (args) => {
639
+ const { startGeneratePiece } = await import("./generate-piece-5Nyr2UZj.mjs");
640
+ await startGeneratePiece(args, process.cwd());
641
+ process.exit(0);
642
+ }
643
+ });
644
+ //#endregion
645
+ //#region src/commands/generate.ts
646
+ /** Exported for tests. */
647
+ const generateCmds = {
648
+ all: generateAllCmd,
649
+ "document-model": generateDocumentModelCmd,
650
+ editor: generateEditorCmd,
651
+ app: generateAppCmd,
652
+ processor: command({
653
+ name: "processor",
654
+ description: "Generate a processor",
655
+ args: {
656
+ name: option({
657
+ type: optional(string),
658
+ long: "name",
659
+ short: "n",
660
+ description: "The name of the processor to generate"
661
+ }),
662
+ type: option({
663
+ type: oneOf(["analytics", "relationalDb"]),
664
+ long: "type",
665
+ description: "The type of processor to generate",
666
+ defaultValue: () => "analytics",
667
+ defaultValueIsSerializable: true
668
+ }),
669
+ documentTypes: multioption({
670
+ type: CommaSeparatedStrings,
671
+ long: "document-types",
672
+ short: "t",
673
+ description: "The document types the processor will run on (repeatable or comma-separated)",
674
+ defaultValue: () => [],
675
+ defaultValueIsSerializable: true
676
+ }),
677
+ apps: multioption({
678
+ long: "apps",
679
+ type: { from(rawProcessorApps) {
680
+ const processorApps = splitCommaSeparated(rawProcessorApps);
681
+ if (processorApps.length === 0) throw new Error(`No arguments provided for processor apps. Must be "connect" and/or "switchboard"`);
682
+ if (processorApps.length > 2) throw new Error(`Too many arguments provided for processor apps. Must be "connect" and/or "switchboard"`);
683
+ const allowed = new Set(PROCESSOR_APPS);
684
+ if (!processorApps.every((p) => allowed.has(p))) throw new Error(`Processor apps can only be "connect" and/or "switchboard".`);
685
+ return Promise.resolve(processorApps);
686
+ } },
687
+ description: "Whether the processor will run in switchboard (nodejs), connect (browser), or both",
688
+ defaultValue: () => ["switchboard", "connect"],
689
+ defaultValueIsSerializable: true
690
+ }),
691
+ document: option({
692
+ type: optional(File),
693
+ long: "document",
694
+ short: "d",
695
+ description: "Path to a powerhouse/processor spec file (.phd or .json) to drive codegen"
696
+ }),
697
+ dir: option({
698
+ type: optional(ModuleDir),
699
+ long: "dir",
700
+ description: "Name of the directory of an existing processor to re-generate (my-processor or processors/my-processor)"
701
+ }),
702
+ all: flag({
703
+ long: "all",
704
+ short: "a",
705
+ description: "Re-generate all existing processors in the current project"
706
+ }),
707
+ extract: flag({
708
+ long: "extract",
709
+ short: "x",
710
+ description: "Write a powerhouse/processor spec for each existing processor into specs/processors/"
711
+ }),
712
+ ...skipInstallArgs,
713
+ ...debugArgs
714
+ },
715
+ handler: async (args) => {
716
+ const { startGenerateProcessor } = await import("./generate-processor-BVjOsfjJ.mjs");
717
+ await startGenerateProcessor(args, process.cwd());
718
+ process.exit(0);
719
+ }
720
+ }),
721
+ subgraph: command({
722
+ name: "subgraph",
723
+ description: "Generate a subgraph",
724
+ args: {
725
+ name: option({
726
+ type: optional(string),
727
+ long: "name",
728
+ short: "n",
729
+ description: "The name of the subgraph to generate"
730
+ }),
731
+ document: option({
732
+ type: optional(File),
733
+ long: "document",
734
+ short: "d",
735
+ description: "Path to a powerhouse/subgraph spec file (.phd or .json) to drive codegen"
736
+ }),
737
+ dir: option({
738
+ type: optional(ModuleDir),
739
+ long: "dir",
740
+ description: "Name of the directory of an existing subgraph to re-generate (my-subgraph or subgraphs/my-subgraph)"
741
+ }),
742
+ all: flag({
743
+ long: "all",
744
+ short: "a",
745
+ description: "Re-generate all existing subgraphs in the current project"
746
+ }),
747
+ extract: flag({
748
+ long: "extract",
749
+ short: "x",
750
+ description: "Write a powerhouse/subgraph spec for each existing subgraph into specs/subgraphs/"
751
+ }),
752
+ /** @experimental */
753
+ codeFirst: flag({
754
+ long: "code-first",
755
+ description: "Experimental. With --name or --document, create a new subgraph code-first. Existing subgraphs keep their own style; ph migrate --subgraph converts one"
756
+ }),
757
+ ...skipInstallArgs,
758
+ ...debugArgs
759
+ },
760
+ handler: async (args) => {
761
+ const { startGenerateSubgraph } = await import("./generate-subgraph-DJZCr0Tk.mjs");
762
+ await startGenerateSubgraph(args, process.cwd());
763
+ process.exit(0);
764
+ }
765
+ }),
766
+ piece: generatePieceCmd,
767
+ "piece-action": generatePieceActionCmd,
768
+ "piece-trigger": generatePieceTriggerCmd,
769
+ "migration-file": generateMigrationFileCmd,
770
+ "connect-routes": generateConnectRoutesCmd,
771
+ "desktop-shell": generateDesktopShellCmd,
772
+ hosts: generateHostsCmd
773
+ };
774
+ const generate = subcommands({
775
+ name: "generate",
776
+ description: `The generate command creates code for Powerhouse modules. It helps you create new code from scratch, or to re-generate existing code in your project.`,
777
+ cmds: generateCmds
778
+ });
779
+ //#endregion
780
+ //#region src/commands/host.ts
781
+ const check = command({
782
+ name: "check",
783
+ description: "Check a host the way `ph run` would, without starting it: every load, validation, resolution and boot issue, grouped by host file. Exits 1 on any issue. `--env <file>` checks against that file alone.",
784
+ args: hostCheckArgs,
785
+ handler: async (args) => {
786
+ const { runHostCheck } = await import("./check-B8oqVMg7.mjs");
787
+ const { output, exitCode } = await runHostCheck(args);
788
+ console.log(output);
789
+ process.exitCode = exitCode;
790
+ }
791
+ });
792
+ const exportCmd = command({
793
+ name: "export",
794
+ description: "Print a host as declared, with every member a compound names, as JSON (tokens unresolved). `--out` writes it to a file instead.",
795
+ args: hostExportArgs,
796
+ handler: async (args) => {
797
+ const { runHostExport } = await import("./export-DqbcbFU5.mjs");
798
+ const { stdout, stderr, exitCode } = await runHostExport(args);
799
+ if (stdout !== void 0) process.stdout.write(stdout);
800
+ if (stderr !== void 0) process.stderr.write(stderr);
801
+ process.exitCode = exitCode;
802
+ }
803
+ });
804
+ const host = subcommands({
805
+ name: "host",
806
+ description: "Inspect the project's hosts/: `check`, `export`.",
807
+ cmds: {
808
+ check,
809
+ export: exportCmd
810
+ }
811
+ });
812
+ //#endregion
813
+ //#region src/commands/init.ts
814
+ const init = command({
815
+ name: "init",
816
+ description: "Initialize a new project",
817
+ args: initArgs,
818
+ handler: async (args) => {
819
+ if (args.debug) console.log({ args });
820
+ const { startInit } = await import("./init-Ltg4cJzm.mjs");
821
+ await startInit(args);
822
+ process.exit(0);
823
+ }
824
+ });
825
+ //#endregion
826
+ //#region src/commands/inspect.ts
827
+ const inspect = command({
828
+ name: "inspect",
829
+ description: `
830
+ The inspect command examines and provides detailed information about a Powerhouse package.
831
+ It helps you understand the structure, dependencies, and configuration of packages in
832
+ your project.
833
+
834
+ This command:
835
+ 1. Analyzes the specified package
836
+ 2. Retrieves detailed information about its structure and configuration
837
+ 3. Displays package metadata, dependencies, and other relevant information
838
+ 4. Helps troubleshoot package-related issues`,
839
+ aliases: ["is"],
840
+ args: inspectArgs,
841
+ handler: async (args) => {
842
+ if (args.debug) console.log(args);
843
+ const { startInspect } = await import("./inspect-zWJnBDMJ.mjs");
844
+ startInspect(args);
845
+ process.exit(0);
846
+ }
847
+ });
848
+ //#endregion
849
+ //#region src/commands/install.ts
850
+ const MANIFEST_TIMEOUT_MS = 1e4;
851
+ async function fetchExternalDependencies(registryUrl, dependency) {
852
+ const base = registryUrl.endsWith("/") ? registryUrl : `${registryUrl}/`;
853
+ const spec = dependency.version ? `${dependency.name}@${dependency.version}` : dependency.name;
854
+ try {
855
+ const response = await fetch(`${base}-/cdn/${spec}/powerhouse.manifest.json`, { signal: AbortSignal.timeout(MANIFEST_TIMEOUT_MS) });
856
+ if (!response.ok) return [];
857
+ const external = (await response.json()).externalDependencies;
858
+ return typeof external === "object" && external !== null ? Object.keys(external).sort() : [];
859
+ } catch {
860
+ return [];
861
+ }
862
+ }
863
+ async function warnAboutExternalDependencies(registryUrl, dependencies) {
864
+ const found = await Promise.all(dependencies.map((dependency) => fetchExternalDependencies(registryUrl, dependency)));
865
+ for (const [i, dependency] of dependencies.entries()) {
866
+ const external = found[i];
867
+ if (external.length === 0) continue;
868
+ console.warn(`⚠ ${dependency.name}: its subgraphs and processors need packages with native addons or WebAssembly modules (${external.join(", ")}) and only run when the package is installed locally: ph install --local ${dependency.name}\n Its pieces work either way.`);
869
+ }
870
+ }
871
+ const install = command({
872
+ name: "install",
873
+ aliases: ["add", "i"],
874
+ description: `
875
+ The install command adds Powerhouse dependencies to your project.
876
+
877
+ By default it only registers the package in powerhouse.config.json with
878
+ provider "registry" — Connect will load it from the registry CDN at runtime.
879
+
880
+ With --local, the package is also installed into node_modules and marked
881
+ as provider "local" — it will be bundled into ph connect build so the
882
+ preview works without the registry being reachable.
883
+
884
+ Resolution order for the registry URL:
885
+ --registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default
886
+ `,
887
+ args: installArgs,
888
+ handler: async (args) => {
889
+ if (args.debug) console.log(args);
890
+ const { getPowerhouseProjectInfo, makeDependenciesWithVersions } = await import("@powerhousedao/shared/clis");
891
+ const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
892
+ if (!projectPath) throw new Error(`Could not find project path to install from.`);
893
+ const { resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
894
+ const registryUrl = resolveRegistryUrl({
895
+ registry: args.registry,
896
+ projectPath
897
+ });
898
+ if (args.debug) console.log(">>> registryUrl", registryUrl);
899
+ const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies, registryUrl);
900
+ if (args.debug) {
901
+ console.log(">>> parsedDependencies", dependenciesWithVersions);
902
+ console.log("\n>>> projectInfo", {
903
+ localProjectPath,
904
+ globalProjectPath,
905
+ packageManager,
906
+ isGlobal
907
+ });
908
+ }
909
+ if (args.local) {
910
+ if (dependenciesWithVersions.length === 0) throw new Error("--local requires at least one package name (e.g. ph install --local @scope/pkg)");
911
+ try {
912
+ const specs = dependenciesWithVersions.map((d) => d.version ? `${d.name}@${d.version}` : d.name);
913
+ const scopes = /* @__PURE__ */ new Set();
914
+ for (const dep of dependenciesWithVersions) if (dep.name.startsWith("@")) {
915
+ const scope = dep.name.split("/")[0];
916
+ scopes.add(scope);
917
+ }
918
+ const scopeRegistryArgs = Array.from(scopes).map((scope) => `--${scope}:registry=${registryUrl}`);
919
+ const minReleaseAgeArgs = packageManager === "pnpm" ? ["--config.minimum-release-age=0"] : [];
920
+ const allowBuildArgs = packageManager === "pnpm" && args.allowBuild.length > 0 ? [`--allow-build=${args.allowBuild.join(",")}`] : [];
921
+ const { resolveCommand } = await import("package-manager-detector");
922
+ const resolved = resolveCommand(packageManager, "add", [
923
+ ...specs,
924
+ ...scopeRegistryArgs,
925
+ ...minReleaseAgeArgs,
926
+ ...allowBuildArgs
927
+ ]);
928
+ if (!resolved) throw new Error(`Failed to resolve install command for package manager "${packageManager}".`);
929
+ const installCommand = `${resolved.command} ${resolved.args.join(" ")}`;
930
+ if (scopeRegistryArgs.length > 0) console.log(`Installing dependencies 📦 (routing ${Array.from(scopes).join(", ")} → ${registryUrl})...`);
931
+ else console.log("Installing dependencies 📦...");
932
+ console.log(`> ${installCommand}`);
933
+ execSync(installCommand, {
934
+ stdio: "inherit",
935
+ cwd: projectPath
936
+ });
937
+ console.log("Dependency installed successfully 🎉");
938
+ } catch (error) {
939
+ console.error("❌ Failed to install dependencies");
940
+ throw error;
941
+ }
942
+ }
943
+ const { updateConfigFile } = await import("./utils-TO9lB8Xs.mjs");
944
+ try {
945
+ console.log("⚙️ Updating powerhouse config file...");
946
+ updateConfigFile(dependenciesWithVersions, projectPath, "install", args.local ? "local" : "registry", registryUrl, args.registry !== void 0);
947
+ console.log("Config file updated successfully 🎉");
948
+ } catch (error) {
949
+ console.error("❌ Failed to update config file");
950
+ throw error;
951
+ }
952
+ if (args.local) {
953
+ const { syncPackageSkills } = await import("@powerhousedao/codegen/file-builders");
954
+ for (const { path, action } of await syncPackageSkills(projectPath)) console.log(` ${path}: ${action}`);
955
+ }
956
+ if (!args.local) await warnAboutExternalDependencies(registryUrl, dependenciesWithVersions);
957
+ process.exit(0);
958
+ }
959
+ });
960
+ //#endregion
961
+ //#region src/commands/keyframes.ts
962
+ const keyframes = command({
963
+ name: "keyframes",
964
+ description: `
965
+ The keyframes command reports on and cleans up the keyframes of a running switchboard,
966
+ through its inspection-admin endpoint.
967
+
968
+ Prerequisites:
969
+ - The host serves inspection-admin (INSPECTION_ADMIN_ENABLED=true).
970
+ - The caller is one of the host's auth admins.
971
+ - The keep rules are in powerhouse.config.json under reactor.keyframes, or in PH_KEYFRAMES.
972
+
973
+ Run preview first: it only reads. clean then removes the keyframes past each type's keep
974
+ count and all keyframes of deleted documents, in small paced statements beside live
975
+ traffic. Running it again is safe. A later read that misses a keyframe replays from the
976
+ operation log, so a clean-up costs time on cold reads and never changes a document.
977
+
978
+ The disk only shrinks after reclaim, which rewrites the Keyframe table once the store is
979
+ quiet. On PGlite the store answers nothing while it rewrites. On Postgres it says what to
980
+ run by hand.
981
+ `,
982
+ args: keyframesArgs,
983
+ handler: async (args) => {
984
+ if (args.debug) console.log(args);
985
+ const { runKeyframesCommand } = await import("./keyframes-bFo9iDhT.mjs");
986
+ const exitCode = await runKeyframesCommand(args);
987
+ process.exit(exitCode);
988
+ }
989
+ });
990
+ //#endregion
991
+ //#region src/commands/list.ts
992
+ const list = command({
993
+ name: "list",
994
+ description: `
995
+ The list command displays information about installed Powerhouse packages in your project.
996
+ It reads the powerhouse.config.json file and shows the packages that are currently installed.
997
+
998
+ This command:
999
+ 1. Examines your project configuration
1000
+ 2. Lists all installed Powerhouse packages
1001
+ 3. Provides a clear overview of your project's dependencies
1002
+ 4. Helps you manage and track your Powerhouse components
1003
+ `,
1004
+ aliases: ["l"],
1005
+ args: listArgs,
1006
+ handler: async (args) => {
1007
+ if (args.debug) console.log(args);
1008
+ try {
1009
+ const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
1010
+ const projectInfo = await getPowerhouseProjectInfo();
1011
+ const { getConfig } = await import("@powerhousedao/config/node");
1012
+ const phConfig = getConfig(projectInfo.projectPath + "/powerhouse.config.json");
1013
+ if (!phConfig.packages || phConfig.packages.length === 0) {
1014
+ console.log("No packages found in the project");
1015
+ return;
1016
+ }
1017
+ console.log("Installed Packages:\n");
1018
+ phConfig.packages.forEach((pkg) => {
1019
+ console.log(pkg.version ? `${pkg.packageName}@${pkg.version}` : pkg.packageName);
1020
+ });
1021
+ } catch (_e) {
1022
+ console.log("No packages found in the project");
1023
+ }
1024
+ process.exit(0);
1025
+ }
1026
+ });
1027
+ //#endregion
1028
+ //#region src/commands/login.ts
1029
+ const login = command({
1030
+ name: "login",
1031
+ description: `
1032
+ The login command authenticates you with Renown using your Ethereum wallet. This enables
1033
+ the CLI to act on behalf of your Ethereum identity for authenticated operations.
1034
+
1035
+ This command:
1036
+ 1. Generates or loads a cryptographic identity (DID) for the CLI
1037
+ 2. Opens your browser to the Renown authentication page
1038
+ 3. You authorize the CLI's DID to act on behalf of your Ethereum address
1039
+ 4. Stores the credentials locally in .ph/.renown.json
1040
+ `,
1041
+ args: loginArgs,
1042
+ handler: async (args) => {
1043
+ if (args.debug) console.log(args);
1044
+ const { getRenown } = await import("./auth-CNhbN5UM.mjs");
1045
+ const renown = await getRenown(args.renownUrl);
1046
+ if (args.showDid) {
1047
+ console.log(renown.did);
1048
+ process.exit(0);
1049
+ }
1050
+ if (args.status) {
1051
+ const { getAuthStatus } = await import("@renown/sdk/node");
1052
+ const status = getAuthStatus(renown);
1053
+ if (!status.authenticated || !status.address) {
1054
+ console.log("Not authenticated with an Ethereum address.");
1055
+ console.log("Run \"ph login\" to authenticate.");
1056
+ } else {
1057
+ console.log("Authenticated");
1058
+ console.log(` ETH Address: ${status.address}`);
1059
+ console.log(` User DID: ${status.userDid}`);
1060
+ console.log(` Chain ID: ${status.chainId}`);
1061
+ console.log(` CLI DID: ${status.cliDid}`);
1062
+ console.log(` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`);
1063
+ console.log(` Renown URL: ${status.baseUrl}`);
1064
+ }
1065
+ process.exit(0);
1066
+ }
1067
+ if (args.logout) {
1068
+ await handleLogout();
1069
+ process.exit(0);
1070
+ }
1071
+ const { browserLogin } = await import("@renown/sdk/node");
1072
+ console.debug("Initializing cryptographic identity...");
1073
+ console.log(`CLI DID: ${renown.did}`);
1074
+ try {
1075
+ const timeoutMs = args.timeout ? args.timeout * 1e3 : void 0;
1076
+ const result = await browserLogin(renown, {
1077
+ renownUrl: args.renownUrl,
1078
+ timeoutMs,
1079
+ onLoginUrl: (url, sessionId) => {
1080
+ console.log("Opening browser for authentication...");
1081
+ console.log(`Session ID: ${sessionId.slice(0, 8)}...`);
1082
+ console.log(`Login URL: ${url}`);
1083
+ console.log();
1084
+ console.log("Waiting for authentication in browser");
1085
+ console.log(`(timeout in ${(timeoutMs ?? 3e5) / 1e3} seconds)`);
1086
+ console.log();
1087
+ console.log("Please connect your wallet and authorize this CLI to act on your behalf.");
1088
+ console.log();
1089
+ process.stdout.write("Waiting");
1090
+ },
1091
+ onPollTick: () => process.stdout.write("."),
1092
+ onBrowserOpenFailed: (url) => {
1093
+ console.error("Failed to open browser automatically.");
1094
+ console.log(`Please open this URL manually: ${url}`);
1095
+ }
1096
+ });
1097
+ console.log();
1098
+ console.log();
1099
+ console.log("Successfully authenticated!");
1100
+ console.log(` ETH Address: ${result.user.address}`);
1101
+ console.log(` User DID: ${result.user.did}`);
1102
+ console.log(` CLI DID: ${result.cliDid}`);
1103
+ console.log();
1104
+ console.log("The CLI can now act on behalf of your Ethereum identity.");
1105
+ } catch (error) {
1106
+ console.log();
1107
+ throw error;
1108
+ }
1109
+ process.exit(0);
1110
+ }
1111
+ });
1112
+ async function handleLogout() {
1113
+ const { getRenown } = await import("./auth-CNhbN5UM.mjs");
1114
+ const renown = await getRenown();
1115
+ if (!renown.user) {
1116
+ console.log("Not currently authenticated.");
1117
+ return;
1118
+ }
1119
+ try {
1120
+ await renown.logout();
1121
+ console.log("Successfully logged out.");
1122
+ } catch (error) {
1123
+ console.error("Failed to clear credentials.");
1124
+ console.debug(error);
1125
+ }
1126
+ }
1127
+ //#endregion
1128
+ //#region src/commands/logout.ts
1129
+ const logout = command({
1130
+ name: "logout",
1131
+ description: `
1132
+ The logout command removes an existing session created with 'ph login'`,
1133
+ args: {},
1134
+ handler: async () => {
1135
+ await handleLogout();
1136
+ process.exit(0);
1137
+ }
1138
+ });
1139
+ //#endregion
1140
+ //#region src/commands/mcp.ts
1141
+ const mcp = command({
1142
+ name: "mcp",
1143
+ args: mcpArgs,
1144
+ description: `
1145
+ Serve the project's reactor-mcp tools to a coding agent over stdio.
1146
+
1147
+ Use it as the MCP server command in .mcp.json, .cursor/mcp.json and
1148
+ .gemini/settings.json. Tools are listed at once, without waiting for Vetra.
1149
+ The first tool call connects to the project's running Vetra (found through
1150
+ .ph/vetra-runtime.json), or starts one in the background and waits for it to
1151
+ be ready: \`ph run vetra --strictPort\` when the project has a hosts/vetra
1152
+ host, else \`ph vetra --strictPort --watch\`. How the start goes is reported
1153
+ as MCP progress notifications when the client sent a progressToken, else on
1154
+ stderr.
1155
+ Startup failures come back as tool errors carrying Vetra's output, which is
1156
+ also written to .ph/vetra.log.
1157
+
1158
+ Beside reactor-mcp's tools it serves restartVetra, which stops the project's
1159
+ Vetra, starts it again and returns its URLs. When Vetra restarts some other
1160
+ way (stopped and started again, or \`ph vetra --restart\` in a project
1161
+ without a hosts/vetra host), the next tool call connects to the new one.
1162
+ `,
1163
+ handler: async (args) => {
1164
+ if (args.debug) console.error(args);
1165
+ const { startMcpLauncher } = await import("./mcp-VRTEA0Ib.mjs");
1166
+ await startMcpLauncher({
1167
+ projectDir: args.projectDir,
1168
+ startTimeoutSeconds: args.startTimeout
1169
+ });
1170
+ }
1171
+ });
1172
+ //#endregion
1173
+ //#region src/commands/migrate.ts
1174
+ const migrate = command({
1175
+ name: "migrate",
1176
+ args: migrateArgs,
1177
+ description: "Run migrations",
1178
+ handler: async (args) => {
1179
+ if (args.debug) console.log(args);
1180
+ const models = args.documentModels || args.documentModel.length > 0;
1181
+ const subgraphs = args.subgraphs || args.subgraph.length > 0;
1182
+ if (args.strictResolvers && !subgraphs) {
1183
+ console.error("--strict-resolvers applies only with --subgraphs or --subgraph.");
1184
+ process.exit(1);
1185
+ }
1186
+ if (args.renameConflictingTypes && !models) {
1187
+ console.error("--rename-conflicting-types applies only with --document-models or --document-model.");
1188
+ process.exit(1);
1189
+ }
1190
+ if (models || subgraphs) {
1191
+ if (args.versionPositional ?? args.version ?? args.force) {
1192
+ console.error("--document-models, --document-model, --subgraphs and --subgraph convert to code-first only; they take no version and no --force.");
1193
+ process.exit(1);
1194
+ }
1195
+ let code = 0;
1196
+ if (models) {
1197
+ const { migrateDocumentModels } = await import("./migrate-document-models-CFNqYAgo.mjs");
1198
+ code |= await migrateDocumentModels({
1199
+ projectDir: process.cwd(),
1200
+ dirs: args.documentModel,
1201
+ dryRun: Boolean(args.dryRun),
1202
+ renameConflictingTypes: Boolean(args.renameConflictingTypes)
1203
+ });
1204
+ }
1205
+ if (subgraphs) {
1206
+ const { migrateSubgraphs } = await import("./migrate-subgraphs-BG-4KEzt.mjs");
1207
+ code |= await migrateSubgraphs({
1208
+ projectDir: process.cwd(),
1209
+ dirs: args.subgraph,
1210
+ dryRun: Boolean(args.dryRun),
1211
+ strictResolvers: Boolean(args.strictResolvers)
1212
+ });
1213
+ }
1214
+ process.exit(code);
1215
+ }
1216
+ const { startMigrate } = await import("./migrate-BGFxHRgP.mjs");
1217
+ await startMigrate(args);
1218
+ process.exit(0);
1219
+ }
1220
+ });
1221
+ //#endregion
1222
+ //#region src/commands/model.ts
1223
+ const EXPERIMENTAL = "Experimental: the command, its output and the JSON report can change in any release.";
1224
+ const EXIT_CODES = `Exit codes:
1225
+ 0 ok, or skipped. Skipped means the package has no document model, so
1226
+ nothing was checked. Read "status".
1227
+ 1 invalid. The models were read and at least one is wrong.
1228
+ 2 failed. The configuration or a module could not be read, the arguments
1229
+ are wrong, or the command could not run.`;
1230
+ const OUTPUT = (name) => `Output:
1231
+ ph model ${name} a readable report on stdout
1232
+ ph model ${name} --json exactly one JSON report on stdout and nothing else
1233
+ Logs, including what the package's modules print while they load, go to
1234
+ stderr. When the command cannot run at all, it prints only a message on
1235
+ stderr and exits 2.`;
1236
+ const modelCheck = command({
1237
+ name: "check",
1238
+ description: `Check this package's document models through one set of checks:
1239
+ every model directory in documentModelsDir, whether it stores a schema-first
1240
+ <name>.json or exports a code-first model from its index.ts. Writes nothing.
1241
+
1242
+ \`tsc\` cannot run these checks: a code-first model compiles when its module is
1243
+ evaluated.
1244
+
1245
+ --release (experimental) runs the checks \`ph build --release\` runs: these,
1246
+ the release checks, and host validation, which validates every model and the
1247
+ package's scalars entry as a host that installed the package would.
1248
+
1249
+ --prepack (experimental) loads nothing. It reads the release approval
1250
+ \`ph build --release\` wrote in .ph/build/release-approval.json and exits 0
1251
+ when it matches this package, 1 when it does not (missing, unreadable, stale
1252
+ or refused), naming the reasons, and 2 when it cannot be checked. To stop a
1253
+ plain \`npm publish\` too, add it to package.json, then run
1254
+ \`ph build --release\` (package.json is published, so the approval covers it):
1255
+ "scripts": { "prepack": "ph-cli model check --prepack" }
1256
+ With --json it prints {"decision": ..., "reasons": [...]}.
1257
+
1258
+ ${EXIT_CODES}
1259
+
1260
+ ${OUTPUT("check")}
1261
+
1262
+ ${EXPERIMENTAL}`,
1263
+ args: modelCheckArgs,
1264
+ handler: async (args) => {
1265
+ if (args.debug) console.error(args);
1266
+ const [{ runModelCheck }, { exitWithModelCommand }] = await Promise.all([import("./check-CpzjVXHj.mjs"), import("./run-LRGy7zGo.mjs")]);
1267
+ await exitWithModelCommand(args.json, (streams) => runModelCheck(args, { streams }));
1268
+ }
1269
+ });
1270
+ const modelInspect = command({
1271
+ name: "inspect",
1272
+ description: `Describe this package's document models without checking them: for each
1273
+ model its digest and compatibility, and for each of its versions the source,
1274
+ scopes, scalars and operations. With <documentType>@<version>, describe that
1275
+ version only and add its full definition to the JSON report. Writes nothing.
1276
+
1277
+ ${EXIT_CODES}
1278
+
1279
+ ${OUTPUT("inspect")}
1280
+
1281
+ ${EXPERIMENTAL}`,
1282
+ args: modelInspectArgs,
1283
+ handler: async (args) => {
1284
+ if (args.debug) console.error(args);
1285
+ const [{ runModelInspect }, { exitWithModelCommand }] = await Promise.all([import("./inspect-CulIpVsF.mjs"), import("./run-LRGy7zGo.mjs")]);
1286
+ await exitWithModelCommand(args.json, (streams) => runModelInspect(args, { streams }));
1287
+ }
1288
+ });
1289
+ const model = subcommands({
1290
+ name: "model",
1291
+ description: "Check or inspect this package's document models (experimental): `check`, `inspect`.",
1292
+ cmds: {
1293
+ check: modelCheck,
1294
+ inspect: modelInspect
1295
+ }
1296
+ });
1297
+ //#endregion
1298
+ //#region src/commands/publish.ts
1299
+ function hasTagFlag(args) {
1300
+ return args.some((a) => a === "--tag" || a.startsWith("--tag="));
1301
+ }
1302
+ function isInteractive() {
1303
+ return Boolean(process.stdin.isTTY) && !process.env.CI;
1304
+ }
1305
+ async function readPrereleaseTag(projectPath, packedVersion) {
1306
+ try {
1307
+ const [{ readPackageSync }, { prerelease }] = await Promise.all([import("read-pkg"), import("semver")]);
1308
+ const version = packedVersion ?? readPackageSync({ cwd: projectPath }).version;
1309
+ if (!version) return null;
1310
+ const parts = prerelease(version);
1311
+ if (!parts || parts.length === 0) return null;
1312
+ const label = String(parts[0]);
1313
+ if (!/^[a-z][a-z0-9-]*$/i.test(label)) return null;
1314
+ return {
1315
+ version,
1316
+ tag: label
1317
+ };
1318
+ } catch {
1319
+ return null;
1320
+ }
1321
+ }
1322
+ const publish = command({
1323
+ name: "publish",
1324
+ description: `
1325
+ Publish a package to the Powerhouse registry. This is a thin wrapper around npm publish
1326
+ that automatically sets the registry URL.
1327
+
1328
+ This command:
1329
+ 0. With a release approval from ph build --release (experimental), checks that it matches
1330
+ the package and warns when it does not. --require-approval exits 1 instead; it forwards
1331
+ only --tag, --access, --otp, --dry-run, --provenance, --json and --loglevel to npm,
1332
+ refuses npm configuration in the environment that selects another package
1333
+ (npm_config_workspace, npm_config_workspaces, npm_config_include_workspace_root),
1334
+ packs the package once, checks that tarball, and publishes that tarball with
1335
+ --ignore-scripts, so a file changed after the check is not published
1336
+ 1. Resolves the registry URL (--registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default)
1337
+ 2. Checks authentication with the registry via npm whoami
1338
+ 3. Forwards all additional arguments to npm publish
1339
+ `,
1340
+ args: publishArgs,
1341
+ handler: async (args) => {
1342
+ if (args.debug) console.log(args);
1343
+ const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
1344
+ const { projectPath } = await getPowerhouseProjectInfo();
1345
+ if (!projectPath) throw new Error("Could not find project path.");
1346
+ const { checkApprovalBeforePublish } = await import("./verify-D4V5VLnG.mjs");
1347
+ if (args.requireApproval) {
1348
+ const { ALLOWED_NPM_ARGUMENTS, refusedNpmArguments, targetSelectingNpmEnvironment } = await import("./npm-args-g1Tgel4s.mjs");
1349
+ const refused = refusedNpmArguments(args.forwardedArgs);
1350
+ if (refused.length > 0) {
1351
+ console.error(`✘ ph publish --require-approval publishes only the package it checked, so it forwards only these npm arguments: ${ALLOWED_NPM_ARGUMENTS}. Not allowed: ${refused.join(" ")}`);
1352
+ process.exit(1);
1353
+ }
1354
+ const selecting = targetSelectingNpmEnvironment(process.env);
1355
+ if (selecting.length > 0) {
1356
+ console.error(`✘ ph publish --require-approval publishes only the package it checked, but the environment sets npm configuration that selects another package: ${selecting.join(", ")}. Unset it and publish again.`);
1357
+ process.exit(1);
1358
+ }
1359
+ }
1360
+ const checked = checkApprovalBeforePublish(projectPath, args.requireApproval);
1361
+ if (!checked.proceed) process.exit(1);
1362
+ const { packed } = checked;
1363
+ if (packed) process.once("exit", packed.dispose);
1364
+ try {
1365
+ const { checkNpmAuth, npmPublish, resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
1366
+ const { mintRegistryAuthToken } = await import("./registry-auth-Bm5AR-fB.mjs");
1367
+ const registryUrl = resolveRegistryUrl({
1368
+ registry: args.registry,
1369
+ projectPath
1370
+ });
1371
+ if (args.debug) console.log(">>> registryUrl", registryUrl);
1372
+ let authToken;
1373
+ try {
1374
+ authToken = await mintRegistryAuthToken(registryUrl, 300);
1375
+ if (args.debug) console.error(`>>> minted renown token for ${registryUrl} (5m TTL)`);
1376
+ } catch (err) {
1377
+ if (args.debug) console.error(`>>> renown token mint skipped: ${err.message}`);
1378
+ try {
1379
+ await checkNpmAuth(registryUrl);
1380
+ } catch {
1381
+ console.error(`Not authenticated with registry: ${registryUrl}`);
1382
+ console.error(`Run: ph login (recommended) or npm adduser --registry ${registryUrl}`);
1383
+ process.exit(1);
1384
+ }
1385
+ }
1386
+ let forwardedArgs = args.forwardedArgs;
1387
+ if (!hasTagFlag(forwardedArgs)) {
1388
+ const prereleaseInfo = await readPrereleaseTag(projectPath, packed?.manifest.version);
1389
+ if (prereleaseInfo) {
1390
+ const { version, tag } = prereleaseInfo;
1391
+ if (!isInteractive()) {
1392
+ console.error(`Detected prerelease version ${version}. npm requires an explicit dist-tag for prerelease publishes.`);
1393
+ console.error(`Re-run with --tag <label> (e.g. --tag ${tag}) to proceed.`);
1394
+ process.exit(1);
1395
+ }
1396
+ const enquirer = await import("enquirer");
1397
+ let confirmed;
1398
+ try {
1399
+ confirmed = (await enquirer.default.prompt({
1400
+ type: "confirm",
1401
+ name: "confirmed",
1402
+ message: `Detected prerelease version ${version}. Publish with --tag ${tag}?`,
1403
+ initial: true
1404
+ })).confirmed;
1405
+ } catch {
1406
+ confirmed = false;
1407
+ }
1408
+ if (!confirmed) {
1409
+ console.error(`Aborted. To publish manually: npm publish --registry ${registryUrl} --tag <label>`);
1410
+ process.exit(1);
1411
+ }
1412
+ forwardedArgs = [
1413
+ "--tag",
1414
+ tag,
1415
+ ...forwardedArgs
1416
+ ];
1417
+ }
1418
+ }
1419
+ if (args.debug) console.log(">>> command", `npm publish --registry ${registryUrl} ${forwardedArgs.join(" ")}`);
1420
+ if (args.requireApproval) {
1421
+ forwardedArgs = [
1422
+ ...forwardedArgs,
1423
+ "--ignore-scripts",
1424
+ "--workspaces=false"
1425
+ ];
1426
+ console.log("Lifecycle scripts are skipped (--ignore-scripts) and workspaces are off (--workspaces=false), so npm publishes the tarball the approval matched.");
1427
+ }
1428
+ console.log(`Publishing to ${registryUrl}...`);
1429
+ const result = await npmPublish({
1430
+ registryUrl,
1431
+ cwd: projectPath,
1432
+ args: packed ? [packed.tarball, ...forwardedArgs] : forwardedArgs,
1433
+ authToken
1434
+ });
1435
+ if (result.stdout) console.log(result.stdout);
1436
+ process.exit(0);
1437
+ } finally {
1438
+ packed?.dispose();
1439
+ }
1440
+ }
1441
+ });
1442
+ //#endregion
1443
+ //#region src/commands/registry-login.ts
1444
+ const registryLogin = command({
1445
+ name: "registry-login",
1446
+ description: `
1447
+ Log in to a Powerhouse registry using your Renown identity. Mints a longer-lived
1448
+ bearer token (default 30 days) bound to the registry's audience and writes the
1449
+ token into ~/.npmrc so raw 'npm publish' / 'npm install' work without further
1450
+ setup.
1451
+
1452
+ Prerequisites:
1453
+ Run 'ph login' first to establish a Renown identity.
1454
+
1455
+ Usage:
1456
+ ph registry-login # uses powerhouse.config.json / PH_REGISTRY_URL
1457
+ ph registry-login --registry https://registry.vetra.io
1458
+ ph registry-login --expiry 7d
1459
+ `,
1460
+ args: registryLoginArgs,
1461
+ handler: async (args) => {
1462
+ if (args.debug) console.log(args);
1463
+ const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
1464
+ const projectPath = (await getPowerhouseProjectInfo().catch(() => null))?.projectPath ?? process.cwd();
1465
+ const [{ resolveRegistryUrl, writeRegistryAuthToken }, { mintRegistryAuthToken }, { parseExpiry, formatExpiry }] = await Promise.all([
1466
+ import("@powerhousedao/shared/registry"),
1467
+ import("./registry-auth-Bm5AR-fB.mjs"),
1468
+ import("@renown/sdk/node")
1469
+ ]);
1470
+ const registryUrl = resolveRegistryUrl({
1471
+ registry: args.registry,
1472
+ projectPath
1473
+ });
1474
+ const expiresIn = parseExpiry(args.expiry);
1475
+ const npmrcPath = await writeRegistryAuthToken(registryUrl, await mintRegistryAuthToken(registryUrl, expiresIn));
1476
+ console.log(`Logged in to ${registryUrl}`);
1477
+ console.log(` Token expires in: ${formatExpiry(expiresIn)}`);
1478
+ console.log(` Wrote: ${npmrcPath}`);
1479
+ process.exit(0);
1480
+ }
1481
+ });
1482
+ //#endregion
1483
+ //#region src/commands/run.ts
1484
+ const runHost = command({
1485
+ name: "run",
1486
+ description: "Run a host from the project's hosts/ folder: `ph run <host> [verb]`. The host's own host.js names the runner module; the verb defaults to `run`. Arguments after the verb go to the runner, which names the ones it accepts.",
1487
+ args: {
1488
+ host: positional({
1489
+ type: string,
1490
+ displayName: "host",
1491
+ description: "Folder name under hosts/ (e.g. vetra, connect)."
1492
+ }),
1493
+ verb: positional({
1494
+ type: optional(string),
1495
+ displayName: "verb",
1496
+ description: "Runner verb (default: run; e.g. dev, build, serve)."
1497
+ }),
1498
+ debug: flag({
1499
+ type: optional(boolean),
1500
+ long: "debug",
1501
+ description: "Print resolved host/runner/verb before dispatch."
1502
+ }),
1503
+ stop: flag({
1504
+ type: optional(boolean),
1505
+ long: "stop",
1506
+ description: "Stop the project's running instance of this host instead of starting one: it shuts down as on Ctrl-C, and the command returns when it has."
1507
+ }),
1508
+ explain: option({
1509
+ type: optional(string),
1510
+ long: "explain",
1511
+ description: "Explain a resolved aspect instead of running: `--explain drives` prints the merged drive plan with provenance; `--explain outputs` prints what each host produces, the output tokens it reads and the start order they imply."
1512
+ }),
1513
+ argv: restPositionals({
1514
+ type: string,
1515
+ displayName: "runner arguments",
1516
+ description: "Arguments for the host's runner (e.g. --port 4001); they win over the host file."
1517
+ })
1518
+ },
1519
+ handler: async (args) => {
1520
+ if (args.explain !== void 0) {
1521
+ const { explainHost } = await import("./explain-8OEXF2Dy.mjs");
1522
+ await explainHost({
1523
+ host: args.host,
1524
+ topic: args.explain
1525
+ });
1526
+ return;
1527
+ }
1528
+ if (args.stop) {
1529
+ const { stopRunningHost } = await import("@powerhousedao/ph-run/start-run");
1530
+ await stopRunningHost({ host: args.host });
1531
+ return;
1532
+ }
1533
+ const run = {
1534
+ host: args.host,
1535
+ verb: args.verb,
1536
+ debug: args.debug,
1537
+ argv: args.argv
1538
+ };
1539
+ if (args.host === "vetra") {
1540
+ const { runVetraHost } = await import("./vetra-host-ChTpJiBJ.mjs");
1541
+ await runVetraHost(run);
1542
+ return;
1543
+ }
1544
+ const { startRun } = await import("@powerhousedao/ph-run/start-run");
1545
+ await startRun(run);
1546
+ }
1547
+ });
1548
+ //#endregion
1549
+ //#region src/commands/switchboard.ts
1550
+ const switchboard = command({
1551
+ name: "switchboard",
1552
+ aliases: ["reactor"],
1553
+ description: `
1554
+ The switchboard command starts a local Switchboard instance, which acts as the document
1555
+ processing engine for Powerhouse projects. It provides the infrastructure for document
1556
+ models, processors, and real-time updates.
1557
+
1558
+ This command:
1559
+ 1. Starts a local switchboard server
1560
+ 2. Loads document models and processors
1561
+ 3. Provides an API for document operations
1562
+ 4. Enables real-time document processing
1563
+ 5. Can authenticate with remote services using your identity from 'ph login'`,
1564
+ args: switchboardArgs,
1565
+ handler: async (args) => {
1566
+ if (args.debug) console.log(args);
1567
+ const { dbPath, migrate, migrateStatus, reset, yes } = args;
1568
+ if (reset) {
1569
+ const { resetSwitchboardDatabase } = await import("./switchboard-reset-MtTB_GAI.mjs");
1570
+ await resetSwitchboardDatabase({
1571
+ dbPath,
1572
+ yes
1573
+ });
1574
+ process.exit(0);
1575
+ }
1576
+ if (migrate || migrateStatus) {
1577
+ const { runSwitchboardMigrations } = await import("./switchboard-migrate-BqSdKJ7u.mjs");
1578
+ await runSwitchboardMigrations({
1579
+ dbPath,
1580
+ statusOnly: migrateStatus
1581
+ });
1582
+ process.exit(0);
1583
+ }
1584
+ const { startSwitchboard } = await import("@powerhousedao/ph-run/switchboard");
1585
+ const { defaultDriveUrl, renown } = await startSwitchboard(args);
1586
+ console.log(" ➜ Switchboard:", defaultDriveUrl);
1587
+ if (renown) console.log(" ➜ Identity:", renown.did);
1588
+ }
1589
+ });
1590
+ //#endregion
1591
+ //#region src/commands/uninstall.ts
1592
+ const uninstall = command({
1593
+ name: "uninstall",
1594
+ aliases: ["remove"],
1595
+ description: `
1596
+ The uninstall command removes Powerhouse dependencies from your project. It handles the
1597
+ removal of packages, updates configuration files, and ensures proper cleanup.
1598
+
1599
+ This command:
1600
+ 1. Uninstalls specified Powerhouse dependencies using your package manager
1601
+ 2. Updates powerhouse.config.json to remove the dependencies
1602
+ 3. Supports various uninstallation options and configurations
1603
+ 4. Works with ${AGENTS.join(", ")} package managers
1604
+ `,
1605
+ args: uninstallArgs,
1606
+ handler: async (args) => {
1607
+ if (args.debug) console.log(args);
1608
+ const { getPowerhouseProjectInfo, getPowerhouseProjectUninstallCommand, makeDependenciesWithVersions } = await import("@powerhousedao/shared/clis");
1609
+ const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
1610
+ if (!projectPath) throw new Error(`Could not find project path to uninstall from`);
1611
+ const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies);
1612
+ if (args.debug) console.log(">>> parsedDependencies", dependenciesWithVersions);
1613
+ if (args.debug) console.log("\n>>> projectInfo", {
1614
+ localProjectPath,
1615
+ globalProjectPath,
1616
+ packageManager,
1617
+ isGlobal
1618
+ });
1619
+ try {
1620
+ console.log("Uninstalling dependencies 📦 ...");
1621
+ const uninstallCommand = await getPowerhouseProjectUninstallCommand(packageManager, args.dependencies);
1622
+ execSync$1(uninstallCommand, {
1623
+ stdio: "inherit",
1624
+ cwd: projectPath
1625
+ });
1626
+ console.log("Dependency uninstalled successfully 🎉");
1627
+ } catch (error) {
1628
+ console.error("❌ Failed to uninstall dependencies");
1629
+ throw error;
1630
+ }
1631
+ const { removeStylesImports, updateConfigFile } = await import("./utils-TO9lB8Xs.mjs");
1632
+ try {
1633
+ console.log("⚙️ Updating powerhouse config file...");
1634
+ updateConfigFile(dependenciesWithVersions, projectPath, "uninstall");
1635
+ console.log("Config file updated successfully 🎉");
1636
+ } catch (error) {
1637
+ console.error("❌ Failed to update config file");
1638
+ throw error;
1639
+ }
1640
+ const { syncPackageSkills } = await import("@powerhousedao/codegen/file-builders");
1641
+ for (const { path, action } of await syncPackageSkills(projectPath)) console.log(` ${path}: ${action}`);
1642
+ try {
1643
+ console.log("⚙️ Updating styles.css file...");
1644
+ removeStylesImports(dependenciesWithVersions, projectPath);
1645
+ console.log("Styles file updated successfully 🎉");
1646
+ } catch (error) {
1647
+ console.error("❌ Failed to update styles file");
1648
+ throw error;
1649
+ }
1650
+ process.exit(0);
1651
+ }
1652
+ });
1653
+ //#endregion
1654
+ //#region src/commands/unpublish.ts
1655
+ const unpublish = command({
1656
+ name: "unpublish",
1657
+ description: `
1658
+ Unpublish a package from the Powerhouse registry. This is a thin wrapper around
1659
+ npm unpublish that automatically targets the Powerhouse registry and never
1660
+ reaches npmjs.org.
1661
+
1662
+ Forms:
1663
+ ph unpublish # unpublish <name>@<version> from cwd's package.json
1664
+ ph unpublish <name> # unpublish the whole package (all versions)
1665
+ ph unpublish <name>@<version> # unpublish a single version
1666
+
1667
+ Flags:
1668
+ --registry <url> # override registry URL
1669
+ --yes, -y # skip the confirmation prompt
1670
+ `,
1671
+ args: unpublishArgs,
1672
+ handler: async (args) => {
1673
+ if (args.debug) console.log(args);
1674
+ const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
1675
+ const { projectPath } = await getPowerhouseProjectInfo();
1676
+ if (!projectPath) throw new Error("Could not find project path.");
1677
+ const { checkNpmAuth, npmUnpublish, resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
1678
+ const registryUrl = resolveRegistryUrl({
1679
+ registry: args.registry,
1680
+ projectPath
1681
+ });
1682
+ const spec = await resolveSpec(args.spec, projectPath);
1683
+ if (!spec) {
1684
+ console.error("No package spec provided and could not read name/version from package.json.");
1685
+ process.exit(1);
1686
+ }
1687
+ if (args.debug) {
1688
+ console.log(">>> registryUrl", registryUrl);
1689
+ console.log(">>> spec", spec);
1690
+ }
1691
+ try {
1692
+ await checkNpmAuth(registryUrl);
1693
+ } catch {
1694
+ console.error(`Not authenticated with registry: ${registryUrl}`);
1695
+ console.error(`Run: npm adduser --registry ${registryUrl}`);
1696
+ process.exit(1);
1697
+ }
1698
+ if (!args.yes) {
1699
+ if (!await confirm(`Unpublish ${spec} from ${registryUrl}? [y/N] `)) {
1700
+ console.log("Aborted.");
1701
+ process.exit(0);
1702
+ }
1703
+ }
1704
+ if (args.debug) console.log(">>> command", `npm unpublish ${spec} --registry ${registryUrl} --force ${args.forwardedArgs.join(" ")}`);
1705
+ console.log(`Unpublishing ${spec} from ${registryUrl}...`);
1706
+ try {
1707
+ const result = await npmUnpublish({
1708
+ registryUrl,
1709
+ cwd: projectPath,
1710
+ spec,
1711
+ args: args.forwardedArgs
1712
+ });
1713
+ if (result.stdout) console.log(result.stdout);
1714
+ process.exit(0);
1715
+ } catch (err) {
1716
+ console.error(err instanceof Error ? err.message : String(err));
1717
+ process.exit(1);
1718
+ }
1719
+ }
1720
+ });
1721
+ async function resolveSpec(explicit, projectPath) {
1722
+ if (explicit) return explicit;
1723
+ try {
1724
+ const { readPackageSync } = await import("read-pkg");
1725
+ const pkg = readPackageSync({ cwd: projectPath });
1726
+ if (!pkg.name) return null;
1727
+ return pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name;
1728
+ } catch {
1729
+ return null;
1730
+ }
1731
+ }
1732
+ async function confirm(prompt) {
1733
+ const rl = createInterface({
1734
+ input: process.stdin,
1735
+ output: process.stdout
1736
+ });
1737
+ try {
1738
+ const answer = await rl.question(prompt);
1739
+ return /^y(es)?$/i.test(answer.trim());
1740
+ } finally {
1741
+ rl.close();
1742
+ }
1743
+ }
1744
+ //#endregion
1745
+ //#region src/commands/ph-cli-commands.ts
1746
+ const phCliCommands = {
1747
+ init,
1748
+ generate,
1749
+ vetra: command({
1750
+ name: "vetra",
1751
+ description: `
1752
+ The vetra command sets up a Vetra development environment for working with Vetra projects.
1753
+ It starts a Vetra Switchboard and optionally Connect Studio, enabling document collaboration
1754
+ and real-time processing with a "Vetra" drive or connection to remote drives.
1755
+
1756
+ This command:
1757
+ 1. Starts a Vetra Switchboard with a "Vetra" drive for document storage
1758
+ 2. Optionally connects to remote drives instead of creating a local drive
1759
+ 3. Starts Connect Studio pointing to the Switchboard for user interaction (unless disabled)
1760
+ 4. Enables real-time updates, collaboration, and code generation
1761
+
1762
+ Default drives:
1763
+ Connect's default drives resolve to the Vetra drive (and the preview drive
1764
+ when using --watch), plus any drives configured under
1765
+ connect.drives.defaultDrives in powerhouse.config.json - de-duplicated by
1766
+ URL, so configuring project drives does not cost you the Vetra drive.
1767
+ An explicit --default-drives-url is appended to that list (de-duplicated);
1768
+ it never replaces the Vetra drive.
1769
+
1770
+ Every drive on the local Switchboard:
1771
+ Studio has no reactor of its own: it reads and writes on the local
1772
+ Switchboard (connect.instance.reactorClient "remote"), so it lists every
1773
+ drive there, such as one an agent adds through MCP, and a drive created in
1774
+ Studio lands there too. Not with --remote-drive, or when the project sets
1775
+ connect.instance.multiReactor or reactorClient itself.
1776
+
1777
+ Preview drive app:
1778
+ Set vetra.previewDrive.app in powerhouse.config.json to the id of a drive
1779
+ app, and ph vetra --watch opens the Vetra Preview drive in that app: it sets
1780
+ the drive's app when it creates the drive and each time it starts. Without
1781
+ the field the drive keeps the app it has.
1782
+
1783
+ One Vetra per project:
1784
+ A running Vetra is recorded in .ph/vetra-runtime.json (its pid and the
1785
+ Connect, Switchboard and MCP URLs); a second \`ph vetra\` prints those and
1786
+ exits. --restart stops the recorded Vetra first, then starts this one; the
1787
+ \`ph mcp\` launcher reconnects to it on its next tool call. Studio restarts
1788
+ by itself when powerhouse.config.json changes.
1789
+ `,
1790
+ args: vetraArgs,
1791
+ handler: async (args) => {
1792
+ if (args.debug) console.log(args);
1793
+ const { startVetra } = await import("./vetra-CVNZ46pK.mjs");
1794
+ await startVetra(args);
1795
+ }
1796
+ }),
1797
+ connect,
1798
+ build: build$1,
1799
+ publish,
1800
+ unpublish,
1801
+ "access-token": accessToken,
1802
+ "registry-login": registryLogin,
1803
+ inspect,
1804
+ keyframes,
1805
+ list,
1806
+ mcp,
1807
+ migrate,
1808
+ model,
1809
+ switchboard,
1810
+ login,
1811
+ logout,
1812
+ install,
1813
+ uninstall,
1814
+ run: runHost,
1815
+ host
1816
+ };
1817
+ //#endregion
1818
+ export { phCliCommands as t };
1819
+
1820
+ //# sourceMappingURL=ph-cli-commands-Dy4vWwUm.mjs.map
1821
+ //# debugId=41e7c60a-521a-5e9a-b35c-453ca4a658f6