@powerhousedao/ph-cli 6.0.2-staging.5 → 6.0.2-staging.7

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 (79) hide show
  1. package/README.md +2 -2
  2. package/dist/{assign-env-vars-B-oPplBd.mjs → assign-env-vars-W-lZmdMi.mjs} +4 -1
  3. package/dist/assign-env-vars-W-lZmdMi.mjs.map +1 -0
  4. package/dist/auth-AR3VxAIk.mjs +18 -0
  5. package/dist/auth-AR3VxAIk.mjs.map +1 -0
  6. package/dist/auth-BNkN6kS9.mjs +4 -0
  7. package/dist/build-CqtYNjiI.mjs +4 -0
  8. package/dist/build-vccTv_Jp.mjs +49 -0
  9. package/dist/build-vccTv_Jp.mjs.map +1 -0
  10. package/dist/cli.mjs +354 -67
  11. package/dist/cli.mjs.map +1 -1
  12. package/dist/{connect-build-DUiJQGfx.mjs → connect-build-B7I7HJu0.mjs} +8 -5
  13. package/dist/connect-build-B7I7HJu0.mjs.map +1 -0
  14. package/dist/{connect-preview-hSphy1QP.mjs → connect-preview-CNJkhtxL.mjs} +5 -2
  15. package/dist/connect-preview-CNJkhtxL.mjs.map +1 -0
  16. package/dist/{connect-studio-CFH0kGW1.mjs → connect-studio-DTdSFftL.mjs} +5 -2
  17. package/dist/connect-studio-DTdSFftL.mjs.map +1 -0
  18. package/dist/connect-studio-DySbZFEc.mjs +5 -0
  19. package/dist/generate-all-Cj8zjFhN.mjs +15 -0
  20. package/dist/generate-all-Cj8zjFhN.mjs.map +1 -0
  21. package/dist/{generate-app-hSK1SlOn.mjs → generate-app-KE0rbE-b.mjs} +9 -2
  22. package/dist/generate-app-KE0rbE-b.mjs.map +1 -0
  23. package/dist/{generate-document-model-ZowVACXL.mjs → generate-document-model-Cut44i6D.mjs} +9 -2
  24. package/dist/generate-document-model-Cut44i6D.mjs.map +1 -0
  25. package/dist/{generate-editor-C53z-03Q.mjs → generate-editor-DmSzWm3W.mjs} +9 -2
  26. package/dist/generate-editor-DmSzWm3W.mjs.map +1 -0
  27. package/dist/{generate-processor-BS4F98d6.mjs → generate-processor-BcuHtOSn.mjs} +9 -2
  28. package/dist/generate-processor-BcuHtOSn.mjs.map +1 -0
  29. package/dist/{generate-subgraph-D1cYT9GQ.mjs → generate-subgraph-sh0GWC6T.mjs} +9 -2
  30. package/dist/generate-subgraph-sh0GWC6T.mjs.map +1 -0
  31. package/dist/{init-BgEVXxOR.mjs → init-Cw_5H_Z1.mjs} +7 -3
  32. package/dist/init-Cw_5H_Z1.mjs.map +1 -0
  33. package/dist/{inspect-DRvimHBb.mjs → inspect-BwuBW_zW.mjs} +5 -2
  34. package/dist/inspect-BwuBW_zW.mjs.map +1 -0
  35. package/dist/migrate-DxITKzBR.mjs +62 -0
  36. package/dist/migrate-DxITKzBR.mjs.map +1 -0
  37. package/dist/registry-auth-CNH84uo4.mjs +25 -0
  38. package/dist/registry-auth-CNH84uo4.mjs.map +1 -0
  39. package/dist/scripts/setup.sh +3 -3
  40. package/dist/{switchboard-Bl2llp5U.mjs → switchboard-BsdbF-rL.mjs} +4 -1
  41. package/dist/switchboard-BsdbF-rL.mjs.map +1 -0
  42. package/dist/switchboard-GTBlxiJZ.mjs +4 -0
  43. package/dist/{switchboard-migrate-BiQJfIrc.mjs → switchboard-migrate-BumRp7rC.mjs} +4 -1
  44. package/dist/switchboard-migrate-BumRp7rC.mjs.map +1 -0
  45. package/dist/utils-C6581aex.mjs +4 -0
  46. package/dist/{utils-C6_gv4nB.mjs → utils-mth8NsDA.mjs} +6 -3
  47. package/dist/utils-mth8NsDA.mjs.map +1 -0
  48. package/dist/{vetra-D2zbrNY1.mjs → vetra-_JnFPpL5.mjs} +8 -5
  49. package/dist/vetra-_JnFPpL5.mjs.map +1 -0
  50. package/package.json +10 -14
  51. package/dist/assign-env-vars-B-oPplBd.mjs.map +0 -1
  52. package/dist/auth-mwX4ugZt.mjs +0 -15
  53. package/dist/auth-mwX4ugZt.mjs.map +0 -1
  54. package/dist/build-Fq1pNRsl.mjs +0 -33
  55. package/dist/build-Fq1pNRsl.mjs.map +0 -1
  56. package/dist/cli-CYgcGGKv.mjs +0 -140
  57. package/dist/cli-CYgcGGKv.mjs.map +0 -1
  58. package/dist/connect-build-DUiJQGfx.mjs.map +0 -1
  59. package/dist/connect-preview-hSphy1QP.mjs.map +0 -1
  60. package/dist/connect-studio-CFH0kGW1.mjs.map +0 -1
  61. package/dist/connect-studio-CV-T5IfA.mjs +0 -3
  62. package/dist/generate-all-yTycRkd3.mjs +0 -10
  63. package/dist/generate-all-yTycRkd3.mjs.map +0 -1
  64. package/dist/generate-app-hSK1SlOn.mjs.map +0 -1
  65. package/dist/generate-document-model-ZowVACXL.mjs.map +0 -1
  66. package/dist/generate-editor-C53z-03Q.mjs.map +0 -1
  67. package/dist/generate-processor-BS4F98d6.mjs.map +0 -1
  68. package/dist/generate-subgraph-D1cYT9GQ.mjs.map +0 -1
  69. package/dist/init-BgEVXxOR.mjs.map +0 -1
  70. package/dist/inspect-DRvimHBb.mjs.map +0 -1
  71. package/dist/logout-BpJEO2Ij.mjs +0 -230
  72. package/dist/logout-BpJEO2Ij.mjs.map +0 -1
  73. package/dist/migrate-CSaC4bDh.mjs +0 -11
  74. package/dist/migrate-CSaC4bDh.mjs.map +0 -1
  75. package/dist/switchboard-Bl2llp5U.mjs.map +0 -1
  76. package/dist/switchboard-DUlj8v2F.mjs +0 -2
  77. package/dist/switchboard-migrate-BiQJfIrc.mjs.map +0 -1
  78. package/dist/utils-C6_gv4nB.mjs.map +0 -1
  79. package/dist/vetra-D2zbrNY1.mjs.map +0 -1
package/dist/cli.mjs CHANGED
@@ -1,19 +1,22 @@
1
1
  #!/usr/bin/env node
2
- import { a as getVersion, i as accessToken, n as login, r as list, t as logout } from "./logout-BpJEO2Ij.mjs";
3
- import { t as runBuild } from "./build-Fq1pNRsl.mjs";
4
- import { a as updateStylesFile, i as updateConfigFile, r as removeStylesImports } from "./utils-C6_gv4nB.mjs";
5
- import { assertNodeVersion, buildArgs, captureCliError, codeArgs, connectBuildArgs, connectPreviewArgs, connectStudioArgs, debugArgs, getPowerhouseProjectInfo, getPowerhouseProjectUninstallCommand, initArgs, initCliTelemetry, inspectArgs, installArgs, makeDependenciesWithVersions, migrateArgs, phCliHelpCommands, publishArgs, switchboardArgs, uninstallArgs, unpublishArgs, vetraArgs } from "@powerhousedao/shared/clis";
2
+
3
+ !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]="03a90462-95f0-5b33-a834-6f62cdf0279b")}catch(e){}}();
4
+ import { initCliTelemetry } from "@powerhousedao/shared/clis/telemetry";
5
+ import { assertNodeVersion } from "@powerhousedao/shared/clis/utils";
6
6
  import { array, boolean, command, flag, multioption, oneOf, option, optional, run, string, subcommands } from "cmd-ts";
7
- import { AGENTS, resolveCommand } from "package-manager-detector";
7
+ import { AGENTS, accessTokenArgs, buildArgs, connectBuildArgs, connectPreviewArgs, connectStudioArgs, debugArgs, initArgs, inspectArgs, installArgs, listArgs, loginArgs, migrateArgs, phCliHelpCommands, publishArgs, registryLoginArgs, switchboardArgs, uninstallArgs, unpublishArgs, vetraArgs } from "@powerhousedao/shared/clis/args";
8
+ import { DEFAULT_EXPIRY_SECONDS } from "@powerhousedao/shared/clis/constants";
8
9
  import { Directory, File } from "cmd-ts/dist/cjs/batteries/fs.js";
9
- import { generateDBSchema } from "@powerhousedao/codegen";
10
10
  import path from "path";
11
11
  import { PROCESSOR_APPS } from "@powerhousedao/shared/processors";
12
- import { checkNpmAuth, npmPublish, npmUnpublish, resolveRegistryUrl } from "@powerhousedao/shared/registry";
13
12
  import { execSync } from "child_process";
14
- import { readPackageSync } from "read-pkg";
15
- import { prerelease } from "semver";
13
+ import { execSync as execSync$1 } from "node:child_process";
16
14
  import { createInterface } from "node:readline/promises";
15
+ //#region src/get-version.ts
16
+ function getVersion() {
17
+ return "6.0.2-staging.7";
18
+ }
19
+ //#endregion
17
20
  //#region src/utils/constants.ts
18
21
  const PH_CLI_DESCRIPTION = "The Powerhouse CLI (ph-cli) is a command-line interface tool that provides essential commands for managing Powerhouse projects. The tool and it's commands are fundamental for creating, building, and running Document Models as a builder in studio mode.";
19
22
  const phCliHelp = subcommands({
@@ -23,6 +26,77 @@ const phCliHelp = subcommands({
23
26
  cmds: phCliHelpCommands
24
27
  });
25
28
  //#endregion
29
+ //#region src/commands/access-token.ts
30
+ const accessToken = command({
31
+ name: "access-token",
32
+ description: `
33
+ The access-token command generates a bearer token for API authentication. This token
34
+ can be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).
35
+
36
+ This command:
37
+ 1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential
38
+ 2. Creates a JWT bearer token with configurable expiration
39
+ 3. Outputs the token to stdout (info to stderr) for easy piping
40
+
41
+ Prerequisites:
42
+ You must have a cryptographic identity. Run 'ph login' first to:
43
+ - Generate a keypair (stored in .ph/.keypair.json)
44
+ - Optionally link your Ethereum address (stored in .ph/.renown.json)
45
+
46
+ Token Details:
47
+ The generated token is a JWT (JSON Web Token) containing:
48
+ - Issuer (iss): Your CLI's DID (did:key:...)
49
+ - Subject (sub): Your CLI's DID
50
+ - Credential Subject: Chain ID, network ID, and address (if authenticated)
51
+ - Expiration (exp): Based on --expiry option
52
+ - Audience (aud): If --audience is specified
53
+
54
+ Output:
55
+ - Token information (DID, address, expiry) is printed to stderr
56
+ - The token itself is printed to stdout for easy piping/copying
57
+
58
+ This allows you to use the command in scripts:
59
+ TOKEN=$(ph access-token)
60
+ curl -H "Authorization: Bearer $TOKEN" http://localhost:4001/graphql
61
+
62
+ Usage with APIs:
63
+ Generate token and use with curl
64
+ TOKEN=$(ph access-token --expiry 1d)
65
+ curl -X POST http://localhost:4001/graphql \\
66
+ -H "Content-Type: application/json" \\
67
+ -H "Authorization: Bearer $TOKEN" \\
68
+ -d '{"query": "{ drives { id name } }"}'
69
+
70
+ Export as environment variable
71
+ export PH_ACCESS_TOKEN=$(ph access-token)
72
+
73
+ Notes:
74
+ - Tokens are self-signed using your CLI's private key
75
+ - No network request is made; tokens are generated locally
76
+ - The recipient API must trust your CLI's DID to accept the token
77
+ - For reactor-api, ensure AUTH_ENABLED=true to require authentication
78
+ `,
79
+ args: accessTokenArgs,
80
+ handler: async (args) => {
81
+ if (args.debug) console.log(args);
82
+ const { generateAccessToken, parseExpiry, formatExpiry } = await import("@renown/sdk/node");
83
+ const { getRenown } = await import("./auth-BNkN6kS9.mjs");
84
+ const renown = await getRenown();
85
+ let expiresIn = DEFAULT_EXPIRY_SECONDS;
86
+ if (args.expiry) expiresIn = parseExpiry(args.expiry);
87
+ const result = await generateAccessToken(renown, {
88
+ expiresIn,
89
+ aud: args.audience
90
+ });
91
+ console.error(`CLI DID: ${result.did}`);
92
+ console.error(`ETH Address: ${result.address}`);
93
+ console.error(`Token expires in: ${formatExpiry(expiresIn)}`);
94
+ console.error("");
95
+ console.log(result.token);
96
+ process.exit(0);
97
+ }
98
+ });
99
+ //#endregion
26
100
  //#region src/commands/build.ts
27
101
  const build$1 = command({
28
102
  name: "build",
@@ -30,6 +104,7 @@ const build$1 = command({
30
104
  handler: async (args) => {
31
105
  if (args.debug) console.log(args);
32
106
  try {
107
+ const { runBuild } = await import("./build-CqtYNjiI.mjs");
33
108
  await runBuild(args);
34
109
  } catch (error) {
35
110
  console.error(error);
@@ -37,30 +112,6 @@ const build$1 = command({
37
112
  }
38
113
  }
39
114
  });
40
- //#endregion
41
- //#region src/commands/code.ts
42
- const code = command({
43
- name: "code",
44
- description: `
45
- Open the Powerhouse coding agent — a REPL backed by Mastra that has every
46
- installed Powerhouse tool available as an agent tool.
47
-
48
- Examples:
49
- ph code Start the interactive REPL.
50
- ph code "list my installed packs" One-shot agent prompt.
51
- `,
52
- args: codeArgs,
53
- handler: async (args) => {
54
- const { buildPhCodeCli } = await import("./cli-CYgcGGKv.mjs");
55
- const cli = buildPhCodeCli();
56
- const argv = [
57
- "node",
58
- "ph-code",
59
- ...args.rest.length === 0 ? ["-i"] : args.rest
60
- ];
61
- await cli.run(argv);
62
- }
63
- });
64
115
  const connect = subcommands({
65
116
  name: "connect",
66
117
  description: `Powerhouse Connect commands. Use with \`studio\`, \`build\` or \`preview\`. Defaults to \`studio\` if not specified.`,
@@ -80,7 +131,7 @@ This command:
80
131
  args: connectStudioArgs,
81
132
  handler: async (args) => {
82
133
  if (args.debug) console.log(args);
83
- const { runConnectStudio } = await import("./connect-studio-CV-T5IfA.mjs");
134
+ const { runConnectStudio } = await import("./connect-studio-DySbZFEc.mjs");
84
135
  await runConnectStudio(args);
85
136
  }
86
137
  }),
@@ -92,7 +143,7 @@ external packages included
92
143
  args: connectBuildArgs,
93
144
  handler: async (args) => {
94
145
  if (args.debug) console.log(args);
95
- const { runConnectBuild } = await import("./connect-build-DUiJQGfx.mjs");
146
+ const { runConnectBuild } = await import("./connect-build-B7I7HJu0.mjs");
96
147
  await runConnectBuild(args);
97
148
  process.exit(0);
98
149
  }
@@ -105,7 +156,7 @@ NOTE: You must run \`ph connect build\` first
105
156
  args: connectPreviewArgs,
106
157
  handler: async (args) => {
107
158
  if (args.debug) console.log(args);
108
- const { runConnectPreview } = await import("./connect-preview-hSphy1QP.mjs");
159
+ const { runConnectPreview } = await import("./connect-preview-CNJkhtxL.mjs");
109
160
  await runConnectPreview(args);
110
161
  }
111
162
  })
@@ -118,7 +169,7 @@ const generateAllCmd = command({
118
169
  description: "Re-generate all modules in the current project",
119
170
  args: {},
120
171
  handler: async () => {
121
- const { startGenerateAll } = await import("./generate-all-yTycRkd3.mjs");
172
+ const { startGenerateAll } = await import("./generate-all-Cj8zjFhN.mjs");
122
173
  await startGenerateAll(process.cwd());
123
174
  process.exit(0);
124
175
  }
@@ -162,7 +213,7 @@ const generateAppCmd = command({
162
213
  ...debugArgs
163
214
  },
164
215
  handler: async (args) => {
165
- const { startGenerateApp } = await import("./generate-app-hSK1SlOn.mjs");
216
+ const { startGenerateApp } = await import("./generate-app-KE0rbE-b.mjs");
166
217
  await startGenerateApp(args, process.cwd());
167
218
  process.exit(0);
168
219
  }
@@ -194,7 +245,7 @@ const generateDocumentModelCmd = command({
194
245
  ...debugArgs
195
246
  },
196
247
  handler: async (args) => {
197
- const { startGenerateDocumentModel } = await import("./generate-document-model-ZowVACXL.mjs");
248
+ const { startGenerateDocumentModel } = await import("./generate-document-model-Cut44i6D.mjs");
198
249
  await startGenerateDocumentModel(args, process.cwd());
199
250
  process.exit(0);
200
251
  }
@@ -231,7 +282,7 @@ const generateEditorCmd = command({
231
282
  ...debugArgs
232
283
  },
233
284
  handler: async (args) => {
234
- const { startGenerateEditor } = await import("./generate-editor-C53z-03Q.mjs");
285
+ const { startGenerateEditor } = await import("./generate-editor-DmSzWm3W.mjs");
235
286
  await startGenerateEditor(args, process.cwd());
236
287
  process.exit(0);
237
288
  }
@@ -256,6 +307,7 @@ const generateMigrationFileCmd = command({
256
307
  ...debugArgs
257
308
  },
258
309
  handler: async ({ migrationFile, schemaFile }) => {
310
+ const { generateDBSchema } = await import("@powerhousedao/codegen");
259
311
  await generateDBSchema({
260
312
  migrationFile: path.join(process.cwd(), migrationFile),
261
313
  schemaFile: schemaFile ? path.join(process.cwd(), schemaFile) : void 0
@@ -315,7 +367,7 @@ const generateProcessorCmd = command({
315
367
  ...debugArgs
316
368
  },
317
369
  handler: async (args) => {
318
- const { startGenerateProcessor } = await import("./generate-processor-BS4F98d6.mjs");
370
+ const { startGenerateProcessor } = await import("./generate-processor-BcuHtOSn.mjs");
319
371
  await startGenerateProcessor(args, process.cwd());
320
372
  process.exit(0);
321
373
  }
@@ -346,7 +398,7 @@ const generateSubgraphCmd = command({
346
398
  ...debugArgs
347
399
  },
348
400
  handler: async (args) => {
349
- const { startGenerateSubgraph } = await import("./generate-subgraph-D1cYT9GQ.mjs");
401
+ const { startGenerateSubgraph } = await import("./generate-subgraph-sh0GWC6T.mjs");
350
402
  await startGenerateSubgraph(args, process.cwd());
351
403
  process.exit(0);
352
404
  }
@@ -374,7 +426,7 @@ const init = command({
374
426
  args: initArgs,
375
427
  handler: async (args) => {
376
428
  if (args.debug) console.log({ args });
377
- const { startInit } = await import("./init-BgEVXxOR.mjs");
429
+ const { startInit } = await import("./init-Cw_5H_Z1.mjs");
378
430
  await startInit(args);
379
431
  process.exit(0);
380
432
  }
@@ -397,7 +449,7 @@ This command:
397
449
  args: inspectArgs,
398
450
  handler: async (args) => {
399
451
  if (args.debug) console.log(args);
400
- const { startInspect } = await import("./inspect-DRvimHBb.mjs");
452
+ const { startInspect } = await import("./inspect-BwuBW_zW.mjs");
401
453
  startInspect(args);
402
454
  process.exit(0);
403
455
  }
@@ -423,8 +475,10 @@ Resolution order for the registry URL:
423
475
  args: installArgs,
424
476
  handler: async (args) => {
425
477
  if (args.debug) console.log(args);
478
+ const { getPowerhouseProjectInfo, makeDependenciesWithVersions } = await import("@powerhousedao/shared/clis");
426
479
  const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
427
480
  if (!projectPath) throw new Error(`Could not find project path to install from.`);
481
+ const { resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
428
482
  const registryUrl = resolveRegistryUrl({
429
483
  registry: args.registry,
430
484
  projectPath
@@ -450,7 +504,15 @@ Resolution order for the registry URL:
450
504
  scopes.add(scope);
451
505
  }
452
506
  const scopeRegistryArgs = Array.from(scopes).map((scope) => `--${scope}:registry=${registryUrl}`);
453
- const resolved = resolveCommand(packageManager, "add", [...specs, ...scopeRegistryArgs]);
507
+ const minReleaseAgeArgs = packageManager === "pnpm" ? ["--config.minimum-release-age=0"] : [];
508
+ const allowBuildArgs = packageManager === "pnpm" && args.allowBuild.length > 0 ? [`--allow-build=${args.allowBuild.join(",")}`] : [];
509
+ const { resolveCommand } = await import("package-manager-detector");
510
+ const resolved = resolveCommand(packageManager, "add", [
511
+ ...specs,
512
+ ...scopeRegistryArgs,
513
+ ...minReleaseAgeArgs,
514
+ ...allowBuildArgs
515
+ ]);
454
516
  if (!resolved) throw new Error(`Failed to resolve install command for package manager "${packageManager}".`);
455
517
  const installCommand = `${resolved.command} ${resolved.args.join(" ")}`;
456
518
  if (scopeRegistryArgs.length > 0) console.log(`Installing dependencies 📦 (routing ${Array.from(scopes).join(", ")} → ${registryUrl})...`);
@@ -466,6 +528,7 @@ Resolution order for the registry URL:
466
528
  throw error;
467
529
  }
468
530
  }
531
+ const { updateConfigFile, updateStylesFile } = await import("./utils-C6581aex.mjs");
469
532
  try {
470
533
  console.log("⚙️ Updating powerhouse config file...");
471
534
  updateConfigFile(dependenciesWithVersions, projectPath, "install", args.local ? "local" : "registry", registryUrl);
@@ -486,14 +549,164 @@ Resolution order for the registry URL:
486
549
  }
487
550
  });
488
551
  //#endregion
552
+ //#region src/commands/list.ts
553
+ const list = command({
554
+ name: "list",
555
+ description: `
556
+ The list command displays information about installed Powerhouse packages in your project.
557
+ It reads the powerhouse.config.json file and shows the packages that are currently installed.
558
+
559
+ This command:
560
+ 1. Examines your project configuration
561
+ 2. Lists all installed Powerhouse packages
562
+ 3. Provides a clear overview of your project's dependencies
563
+ 4. Helps you manage and track your Powerhouse components
564
+ `,
565
+ aliases: ["l"],
566
+ args: listArgs,
567
+ handler: async (args) => {
568
+ if (args.debug) console.log(args);
569
+ try {
570
+ const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
571
+ const projectInfo = await getPowerhouseProjectInfo();
572
+ console.log("\n>>> projectInfo", projectInfo);
573
+ const { getConfig } = await import("@powerhousedao/config/node");
574
+ const phConfig = getConfig(projectInfo.projectPath + "/powerhouse.config.json");
575
+ if (!phConfig.packages || phConfig.packages.length === 0) {
576
+ console.log("No packages found in the project");
577
+ return;
578
+ }
579
+ console.log("Installed Packages:\n");
580
+ phConfig.packages.forEach((pkg) => {
581
+ console.log(pkg.packageName);
582
+ });
583
+ } catch (e) {
584
+ console.log("No packages found in the project");
585
+ }
586
+ process.exit(0);
587
+ }
588
+ });
589
+ //#endregion
590
+ //#region src/commands/login.ts
591
+ const login = command({
592
+ name: "login",
593
+ description: `
594
+ The login command authenticates you with Renown using your Ethereum wallet. This enables
595
+ the CLI to act on behalf of your Ethereum identity for authenticated operations.
596
+
597
+ This command:
598
+ 1. Generates or loads a cryptographic identity (DID) for the CLI
599
+ 2. Opens your browser to the Renown authentication page
600
+ 3. You authorize the CLI's DID to act on behalf of your Ethereum address
601
+ 4. Stores the credentials locally in .ph/.renown.json
602
+ `,
603
+ args: loginArgs,
604
+ handler: async (args) => {
605
+ if (args.debug) console.log(args);
606
+ const { getRenown } = await import("./auth-BNkN6kS9.mjs");
607
+ const renown = await getRenown(args.renownUrl);
608
+ if (args.showDid) {
609
+ console.log(renown.did);
610
+ process.exit(0);
611
+ }
612
+ if (args.status) {
613
+ const { getAuthStatus } = await import("@renown/sdk/node");
614
+ const status = getAuthStatus(renown);
615
+ if (!status.authenticated || !status.address) {
616
+ console.log("Not authenticated with an Ethereum address.");
617
+ console.log("Run \"ph login\" to authenticate.");
618
+ } else {
619
+ console.log("Authenticated");
620
+ console.log(` ETH Address: ${status.address}`);
621
+ console.log(` User DID: ${status.userDid}`);
622
+ console.log(` Chain ID: ${status.chainId}`);
623
+ console.log(` CLI DID: ${status.cliDid}`);
624
+ console.log(` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`);
625
+ console.log(` Renown URL: ${status.baseUrl}`);
626
+ }
627
+ process.exit(0);
628
+ }
629
+ if (args.logout) {
630
+ await handleLogout();
631
+ process.exit(0);
632
+ }
633
+ const { browserLogin } = await import("@renown/sdk/node");
634
+ console.debug("Initializing cryptographic identity...");
635
+ console.log(`CLI DID: ${renown.did}`);
636
+ try {
637
+ const timeoutMs = args.timeout ? args.timeout * 1e3 : void 0;
638
+ const result = await browserLogin(renown, {
639
+ renownUrl: args.renownUrl,
640
+ timeoutMs,
641
+ onLoginUrl: (url, sessionId) => {
642
+ console.log("Opening browser for authentication...");
643
+ console.log(`Session ID: ${sessionId.slice(0, 8)}...`);
644
+ console.log(`Login URL: ${url}`);
645
+ console.log();
646
+ console.log("Waiting for authentication in browser");
647
+ console.log(`(timeout in ${(timeoutMs ?? 3e5) / 1e3} seconds)`);
648
+ console.log();
649
+ console.log("Please connect your wallet and authorize this CLI to act on your behalf.");
650
+ console.log();
651
+ process.stdout.write("Waiting");
652
+ },
653
+ onPollTick: () => process.stdout.write("."),
654
+ onBrowserOpenFailed: (url) => {
655
+ console.error("Failed to open browser automatically.");
656
+ console.log(`Please open this URL manually: ${url}`);
657
+ }
658
+ });
659
+ console.log();
660
+ console.log();
661
+ console.log("Successfully authenticated!");
662
+ console.log(` ETH Address: ${result.user.address}`);
663
+ console.log(` User DID: ${result.user.did}`);
664
+ console.log(` CLI DID: ${result.cliDid}`);
665
+ console.log();
666
+ console.log("The CLI can now act on behalf of your Ethereum identity.");
667
+ } catch (error) {
668
+ console.log();
669
+ throw error;
670
+ }
671
+ process.exit(0);
672
+ }
673
+ });
674
+ async function handleLogout() {
675
+ const { getRenown } = await import("./auth-BNkN6kS9.mjs");
676
+ const renown = await getRenown();
677
+ if (!renown.user) {
678
+ console.log("Not currently authenticated.");
679
+ return;
680
+ }
681
+ try {
682
+ await renown.logout();
683
+ console.log("Successfully logged out.");
684
+ } catch (error) {
685
+ console.error("Failed to clear credentials.");
686
+ console.debug(error);
687
+ }
688
+ }
689
+ //#endregion
690
+ //#region src/commands/logout.ts
691
+ const logout = command({
692
+ name: "logout",
693
+ description: `
694
+ The logout command removes an existing session created with 'ph login'`,
695
+ args: {},
696
+ handler: async () => {
697
+ await handleLogout();
698
+ process.exit(0);
699
+ }
700
+ });
701
+ //#endregion
489
702
  //#region src/commands/migrate.ts
490
- const migrate$1 = command({
703
+ const migrate = command({
491
704
  name: "migrate",
492
705
  args: migrateArgs,
493
706
  description: "Run migrations",
494
707
  handler: async (args) => {
495
708
  if (args.debug) console.log(args);
496
- const { startMigrate } = await import("./migrate-CSaC4bDh.mjs");
709
+ const { startMigrate } = await import("./migrate-DxITKzBR.mjs");
497
710
  await startMigrate(args);
498
711
  process.exit(0);
499
712
  }
@@ -506,8 +719,9 @@ function hasTagFlag(args) {
506
719
  function isInteractive() {
507
720
  return Boolean(process.stdin.isTTY) && !process.env.CI;
508
721
  }
509
- function readPrereleaseTag(projectPath) {
722
+ async function readPrereleaseTag(projectPath) {
510
723
  try {
724
+ const [{ readPackageSync }, { prerelease }] = await Promise.all([import("read-pkg"), import("semver")]);
511
725
  const pkg = readPackageSync({ cwd: projectPath });
512
726
  if (!pkg.version) return null;
513
727
  const parts = prerelease(pkg.version);
@@ -536,23 +750,33 @@ This command:
536
750
  args: publishArgs,
537
751
  handler: async (args) => {
538
752
  if (args.debug) console.log(args);
753
+ const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
539
754
  const { projectPath } = await getPowerhouseProjectInfo();
540
755
  if (!projectPath) throw new Error("Could not find project path.");
756
+ const { checkNpmAuth, npmPublish, resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
757
+ const { mintRegistryAuthToken } = await import("./registry-auth-CNH84uo4.mjs");
541
758
  const registryUrl = resolveRegistryUrl({
542
759
  registry: args.registry,
543
760
  projectPath
544
761
  });
545
762
  if (args.debug) console.log(">>> registryUrl", registryUrl);
763
+ let authToken;
546
764
  try {
547
- await checkNpmAuth(registryUrl);
548
- } catch {
549
- console.error(`Not authenticated with registry: ${registryUrl}`);
550
- console.error(`Run: npm adduser --registry ${registryUrl}`);
551
- process.exit(1);
765
+ authToken = await mintRegistryAuthToken(registryUrl, 300);
766
+ if (args.debug) console.error(`>>> minted renown token for ${registryUrl} (5m TTL)`);
767
+ } catch (err) {
768
+ if (args.debug) console.error(`>>> renown token mint skipped: ${err.message}`);
769
+ try {
770
+ await checkNpmAuth(registryUrl);
771
+ } catch {
772
+ console.error(`Not authenticated with registry: ${registryUrl}`);
773
+ console.error(`Run: ph login (recommended) or npm adduser --registry ${registryUrl}`);
774
+ process.exit(1);
775
+ }
552
776
  }
553
777
  let forwardedArgs = args.forwardedArgs;
554
778
  if (!hasTagFlag(forwardedArgs)) {
555
- const prereleaseInfo = readPrereleaseTag(projectPath);
779
+ const prereleaseInfo = await readPrereleaseTag(projectPath);
556
780
  if (prereleaseInfo) {
557
781
  const { version, tag } = prereleaseInfo;
558
782
  if (!isInteractive()) {
@@ -588,13 +812,54 @@ This command:
588
812
  const result = await npmPublish({
589
813
  registryUrl,
590
814
  cwd: projectPath,
591
- args: forwardedArgs
815
+ args: forwardedArgs,
816
+ authToken
592
817
  });
593
818
  if (result.stdout) console.log(result.stdout);
594
819
  process.exit(0);
595
820
  }
596
821
  });
597
822
  //#endregion
823
+ //#region src/commands/registry-login.ts
824
+ const registryLogin = command({
825
+ name: "registry-login",
826
+ description: `
827
+ Log in to a Powerhouse registry using your Renown identity. Mints a longer-lived
828
+ bearer token (default 30 days) bound to the registry's audience and writes the
829
+ token into ~/.npmrc so raw 'npm publish' / 'npm install' work without further
830
+ setup.
831
+
832
+ Prerequisites:
833
+ Run 'ph login' first to establish a Renown identity.
834
+
835
+ Usage:
836
+ ph registry-login # uses powerhouse.config.json / PH_REGISTRY_URL
837
+ ph registry-login --registry https://registry.dev.vetra.io
838
+ ph registry-login --expiry 7d
839
+ `,
840
+ args: registryLoginArgs,
841
+ handler: async (args) => {
842
+ if (args.debug) console.log(args);
843
+ const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
844
+ const projectPath = (await getPowerhouseProjectInfo().catch(() => null))?.projectPath ?? process.cwd();
845
+ const [{ resolveRegistryUrl, writeRegistryAuthToken }, { mintRegistryAuthToken }, { parseExpiry, formatExpiry }] = await Promise.all([
846
+ import("@powerhousedao/shared/registry"),
847
+ import("./registry-auth-CNH84uo4.mjs"),
848
+ import("@renown/sdk/node")
849
+ ]);
850
+ const registryUrl = resolveRegistryUrl({
851
+ registry: args.registry,
852
+ projectPath
853
+ });
854
+ const expiresIn = parseExpiry(args.expiry);
855
+ const npmrcPath = await writeRegistryAuthToken(registryUrl, await mintRegistryAuthToken(registryUrl, expiresIn));
856
+ console.log(`Logged in to ${registryUrl}`);
857
+ console.log(` Token expires in: ${formatExpiry(expiresIn)}`);
858
+ console.log(` Wrote: ${npmrcPath}`);
859
+ process.exit(0);
860
+ }
861
+ });
862
+ //#endregion
598
863
  //#region src/commands/switchboard.ts
599
864
  const switchboard = command({
600
865
  name: "switchboard",
@@ -616,14 +881,14 @@ This command:
616
881
  const { basePath, dbPath, migrate, migrateStatus } = args;
617
882
  if (basePath) process.env.BASE_PATH = basePath;
618
883
  if (migrate || migrateStatus) {
619
- const { runSwitchboardMigrations } = await import("./switchboard-migrate-BiQJfIrc.mjs");
884
+ const { runSwitchboardMigrations } = await import("./switchboard-migrate-BumRp7rC.mjs");
620
885
  await runSwitchboardMigrations({
621
886
  dbPath,
622
887
  statusOnly: migrateStatus
623
888
  });
624
889
  process.exit(0);
625
890
  }
626
- const { startSwitchboard } = await import("./switchboard-DUlj8v2F.mjs");
891
+ const { startSwitchboard } = await import("./switchboard-GTBlxiJZ.mjs");
627
892
  const { defaultDriveUrl, renown } = await startSwitchboard(args);
628
893
  console.log(" ➜ Switchboard:", defaultDriveUrl);
629
894
  if (renown) console.log(" ➜ Identity:", renown.did);
@@ -647,6 +912,7 @@ This command:
647
912
  args: uninstallArgs,
648
913
  handler: async (args) => {
649
914
  if (args.debug) console.log(args);
915
+ const { getPowerhouseProjectInfo, getPowerhouseProjectUninstallCommand, makeDependenciesWithVersions } = await import("@powerhousedao/shared/clis");
650
916
  const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
651
917
  if (!projectPath) throw new Error(`Could not find project path to uninstall from`);
652
918
  const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies);
@@ -659,7 +925,7 @@ This command:
659
925
  });
660
926
  try {
661
927
  console.log("Uninstalling dependencies 📦 ...");
662
- execSync(await getPowerhouseProjectUninstallCommand(packageManager), {
928
+ execSync$1(await getPowerhouseProjectUninstallCommand(packageManager, args.dependencies), {
663
929
  stdio: "inherit",
664
930
  cwd: projectPath
665
931
  });
@@ -668,6 +934,7 @@ This command:
668
934
  console.error("❌ Failed to uninstall dependencies");
669
935
  throw error;
670
936
  }
937
+ const { removeStylesImports, updateConfigFile } = await import("./utils-C6581aex.mjs");
671
938
  try {
672
939
  console.log("⚙️ Updating powerhouse config file...");
673
940
  updateConfigFile(dependenciesWithVersions, projectPath, "uninstall");
@@ -708,13 +975,15 @@ Flags:
708
975
  args: unpublishArgs,
709
976
  handler: async (args) => {
710
977
  if (args.debug) console.log(args);
978
+ const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
711
979
  const { projectPath } = await getPowerhouseProjectInfo();
712
980
  if (!projectPath) throw new Error("Could not find project path.");
981
+ const { checkNpmAuth, npmUnpublish, resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
713
982
  const registryUrl = resolveRegistryUrl({
714
983
  registry: args.registry,
715
984
  projectPath
716
985
  });
717
- const spec = resolveSpec(args.spec, projectPath);
986
+ const spec = await resolveSpec(args.spec, projectPath);
718
987
  if (!spec) {
719
988
  console.error("No package spec provided and could not read name/version from package.json.");
720
989
  process.exit(1);
@@ -753,9 +1022,10 @@ Flags:
753
1022
  }
754
1023
  }
755
1024
  });
756
- function resolveSpec(explicit, projectPath) {
1025
+ async function resolveSpec(explicit, projectPath) {
757
1026
  if (explicit) return explicit;
758
1027
  try {
1028
+ const { readPackageSync } = await import("read-pkg");
759
1029
  const pkg = readPackageSync({ cwd: projectPath });
760
1030
  if (!pkg.name) return null;
761
1031
  return pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name;
@@ -779,7 +1049,6 @@ async function confirm(prompt) {
779
1049
  //#region src/commands/ph-cli-commands.ts
780
1050
  const phCliCommands = {
781
1051
  init,
782
- code,
783
1052
  generate,
784
1053
  vetra: command({
785
1054
  name: "vetra",
@@ -796,7 +1065,7 @@ This command:
796
1065
  args: vetraArgs,
797
1066
  handler: async (args) => {
798
1067
  if (args.debug) console.log(args);
799
- const { startVetra } = await import("./vetra-D2zbrNY1.mjs");
1068
+ const { startVetra } = await import("./vetra-_JnFPpL5.mjs");
800
1069
  await startVetra(args);
801
1070
  }
802
1071
  }),
@@ -805,9 +1074,10 @@ This command:
805
1074
  publish,
806
1075
  unpublish,
807
1076
  "access-token": accessToken,
1077
+ "registry-login": registryLogin,
808
1078
  inspect,
809
1079
  list,
810
- migrate: migrate$1,
1080
+ migrate,
811
1081
  switchboard,
812
1082
  login,
813
1083
  logout,
@@ -822,18 +1092,34 @@ const phCli = subcommands({
822
1092
  });
823
1093
  //#endregion
824
1094
  //#region src/cli.ts
1095
+ let sentryClient = void 0;
1096
+ const COMMANDS_WITH_SUBCOMMANDS = new Set(["connect", "vetra"]);
1097
+ function detectPackageManager() {
1098
+ const ua = process.env.npm_config_user_agent;
1099
+ if (!ua) return void 0;
1100
+ return ua.split(" ")[0]?.split("/")[0] || void 0;
1101
+ }
825
1102
  async function main() {
826
1103
  assertNodeVersion();
827
- await initCliTelemetry({
1104
+ sentryClient = await initCliTelemetry({
828
1105
  cliName: "ph-cli",
829
1106
  release: getVersion()
830
1107
  });
831
1108
  const args = process.argv.slice(2);
1109
+ const command = args[0];
1110
+ const subcommand = command && COMMANDS_WITH_SUBCOMMANDS.has(command) && args[1] && !args[1].startsWith("-") ? args[1] : void 0;
1111
+ sentryClient?.attachInvocationContext({
1112
+ command,
1113
+ subcommand,
1114
+ pm: detectPackageManager(),
1115
+ argv: args,
1116
+ cwd: process.cwd()
1117
+ });
832
1118
  const hasNoArgs = args.length === 0;
833
1119
  const isHelp = args.some((arg) => arg === "--help" || arg === "-h");
834
1120
  const isTopLevelHelp = isHelp && args.length === 1;
835
1121
  const cli = hasNoArgs || isTopLevelHelp ? phCliHelp : phCli;
836
- const [command, ...restArgs] = args;
1122
+ const restArgs = args.slice(1);
837
1123
  if (command === "connect" && ![
838
1124
  "studio",
839
1125
  "build",
@@ -847,7 +1133,7 @@ async function main() {
847
1133
  }
848
1134
  await main().catch(async (error) => {
849
1135
  const isDebug = process.argv.slice(2).includes("--debug");
850
- await captureCliError(error);
1136
+ await sentryClient?.captureCliError(error);
851
1137
  if (isDebug) throw error;
852
1138
  if (error instanceof Error) {
853
1139
  console.error(error.message);
@@ -857,4 +1143,5 @@ await main().catch(async (error) => {
857
1143
  //#endregion
858
1144
  export {};
859
1145
 
860
- //# sourceMappingURL=cli.mjs.map
1146
+ //# sourceMappingURL=cli.mjs.map
1147
+ //# debugId=03a90462-95f0-5b33-a834-6f62cdf0279b