@powerhousedao/ph-cli 6.2.3-dev.9 → 6.2.3-dev.90

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