@powerhousedao/ph-cli 6.0.0-dev.172 → 6.0.0-dev.173
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.
- package/dist/{auth-BeA5gDPQ.mjs → auth-wgUd0D0V.mjs} +4 -12
- package/dist/auth-wgUd0D0V.mjs.map +1 -0
- package/dist/cli.mjs +63 -158
- package/dist/cli.mjs.map +1 -1
- package/package.json +10 -10
- package/dist/auth-BeA5gDPQ.mjs.map +0 -1
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import { RenownBuilder } from "@renown/sdk/node";
|
|
3
2
|
//#region src/services/auth.ts
|
|
4
|
-
join(process.cwd(), ".ph/.renown.json");
|
|
5
3
|
let renownInstance = null;
|
|
6
4
|
/**
|
|
7
|
-
* Generate a UUID v4 for session IDs
|
|
8
|
-
*/
|
|
9
|
-
function generateSessionId() {
|
|
10
|
-
return crypto.randomUUID();
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
5
|
* Get or create the Renown instance
|
|
14
6
|
* Uses PH_RENOWN_PRIVATE_KEY env var if set, otherwise generates/loads from file
|
|
15
7
|
*/
|
|
16
|
-
async function getRenown() {
|
|
17
|
-
if (!renownInstance) renownInstance = await new RenownBuilder("ph-cli").build();
|
|
8
|
+
async function getRenown(baseUrl) {
|
|
9
|
+
if (!renownInstance) renownInstance = await new RenownBuilder("ph-cli", { baseUrl }).build();
|
|
18
10
|
return renownInstance;
|
|
19
11
|
}
|
|
20
12
|
//#endregion
|
|
21
|
-
export {
|
|
13
|
+
export { getRenown };
|
|
22
14
|
|
|
23
|
-
//# sourceMappingURL=auth-
|
|
15
|
+
//# sourceMappingURL=auth-wgUd0D0V.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-wgUd0D0V.mjs","names":[],"sources":["../src/services/auth.ts"],"sourcesContent":["import { RenownBuilder, type IRenown } from \"@renown/sdk/node\";\n\n// Singleton instance of Renown\nlet renownInstance: IRenown | null = null;\n\n/**\n * Get or create the Renown instance\n * Uses PH_RENOWN_PRIVATE_KEY env var if set, otherwise generates/loads from file\n */\nexport async function getRenown(baseUrl?: string): Promise<IRenown> {\n if (!renownInstance) {\n renownInstance = await new RenownBuilder(\"ph-cli\", { baseUrl }).build();\n }\n return renownInstance;\n}\n"],"mappings":";;AAGA,IAAI,iBAAiC;;;;;AAMrC,eAAsB,UAAU,SAAoC;AAClE,KAAI,CAAC,eACH,kBAAiB,MAAM,IAAI,cAAc,UAAU,EAAE,SAAS,CAAC,CAAC,OAAO;AAEzE,QAAO"}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as runBuild } from "./build-BflSHYLP.mjs";
|
|
3
3
|
import { a as updateStylesFile, i as updateConfigFile, r as removeStylesImports } from "./utils-DbFSkp_Q.mjs";
|
|
4
|
-
import { DEFAULT_EXPIRY_SECONDS,
|
|
4
|
+
import { DEFAULT_EXPIRY_SECONDS, accessTokenArgs, assertNodeVersion, buildArgs, connectBuildArgs, connectPreviewArgs, connectStudioArgs, generateArgs, getConfig, getPowerhouseProjectInfo, getPowerhouseProjectInstallCommand, getPowerhouseProjectUninstallCommand, initArgs, inspectArgs, installArgs, listArgs, loginArgs, makeDependenciesWithVersions, migrateArgs, phCliHelpCommands, publishArgs, switchboardArgs, uninstallArgs, vetraArgs } from "@powerhousedao/shared/clis";
|
|
5
5
|
import { command, run, subcommands } from "cmd-ts";
|
|
6
6
|
import { AGENTS } from "package-manager-detector";
|
|
7
7
|
import { DEFAULT_REGISTRY_URL } from "@powerhousedao/config";
|
|
@@ -75,53 +75,23 @@ Notes:
|
|
|
75
75
|
args: accessTokenArgs,
|
|
76
76
|
handler: async (args) => {
|
|
77
77
|
if (args.debug) console.log(args);
|
|
78
|
-
const {
|
|
78
|
+
const { generateAccessToken, parseExpiry, formatExpiry } = await import("@renown/sdk/node");
|
|
79
|
+
const { getRenown } = await import("./auth-wgUd0D0V.mjs");
|
|
79
80
|
const renown = await getRenown();
|
|
80
|
-
const did = renown.did;
|
|
81
|
-
const user = renown.user;
|
|
82
|
-
if (!user || !user.credential) throw new Error("Not authenticated. Run 'ph login' first to authenticate with Renown. A Renown credential is required to generate valid bearer tokens.");
|
|
83
|
-
const address = user.address;
|
|
84
81
|
let expiresIn = DEFAULT_EXPIRY_SECONDS;
|
|
85
82
|
if (args.expiry) expiresIn = parseExpiry(args.expiry);
|
|
86
|
-
const
|
|
83
|
+
const result = await generateAccessToken(renown, {
|
|
87
84
|
expiresIn,
|
|
88
85
|
aud: args.audience
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (expiryDays > 0) expiryStr = expiryHours > 0 ? `${expiryDays} day${expiryDays > 1 ? "s" : ""} and ${expiryHours} hour${expiryHours > 1 ? "s" : ""}` : `${expiryDays} day${expiryDays > 1 ? "s" : ""}`;
|
|
94
|
-
else if (expiryHours > 0) expiryStr = `${expiryHours} hour${expiryHours > 1 ? "s" : ""}`;
|
|
95
|
-
else expiryStr = `${expiresIn} seconds`;
|
|
96
|
-
console.error(`CLI DID: ${did}`);
|
|
97
|
-
console.error(`ETH Address: ${address}`);
|
|
98
|
-
console.error(`Token expires in: ${expiryStr}`);
|
|
86
|
+
});
|
|
87
|
+
console.error(`CLI DID: ${result.did}`);
|
|
88
|
+
console.error(`ETH Address: ${result.address}`);
|
|
89
|
+
console.error(`Token expires in: ${formatExpiry(expiresIn)}`);
|
|
99
90
|
console.error("");
|
|
100
|
-
console.log(token);
|
|
91
|
+
console.log(result.token);
|
|
101
92
|
process.exit(0);
|
|
102
93
|
}
|
|
103
94
|
});
|
|
104
|
-
/**
|
|
105
|
-
* Parse expiry string to seconds
|
|
106
|
-
* Supports formats: "7d" (days), "24h" (hours), "3600" (seconds), "3600s" (seconds)
|
|
107
|
-
*/
|
|
108
|
-
function parseExpiry(expiry) {
|
|
109
|
-
const trimmed = expiry.trim().toLowerCase();
|
|
110
|
-
if (trimmed.endsWith("d")) {
|
|
111
|
-
const days = parseInt(trimmed.slice(0, -1), 10);
|
|
112
|
-
if (isNaN(days) || days <= 0) throw new Error(`Invalid expiry format: ${expiry}. Days must be a positive number.`);
|
|
113
|
-
return days * SECONDS_IN_DAY;
|
|
114
|
-
}
|
|
115
|
-
if (trimmed.endsWith("h")) {
|
|
116
|
-
const hours = parseInt(trimmed.slice(0, -1), 10);
|
|
117
|
-
if (isNaN(hours) || hours <= 0) throw new Error(`Invalid expiry format: ${expiry}. Hours must be a positive number.`);
|
|
118
|
-
return hours * 60 * 60;
|
|
119
|
-
}
|
|
120
|
-
const numericValue = trimmed.endsWith("s") ? trimmed.slice(0, -1) : trimmed;
|
|
121
|
-
const seconds = parseInt(numericValue, 10);
|
|
122
|
-
if (isNaN(seconds) || seconds <= 0) throw new Error(`Invalid expiry format: ${expiry}. Expected a positive number or format like "7d", "24h", "3600s".`);
|
|
123
|
-
return seconds;
|
|
124
|
-
}
|
|
125
95
|
//#endregion
|
|
126
96
|
//#region src/commands/build.ts
|
|
127
97
|
const build$1 = command({
|
|
@@ -364,141 +334,76 @@ This command:
|
|
|
364
334
|
args: loginArgs,
|
|
365
335
|
handler: async (args) => {
|
|
366
336
|
if (args.debug) console.log(args);
|
|
337
|
+
const { getRenown } = await import("./auth-wgUd0D0V.mjs");
|
|
338
|
+
const renown = await getRenown(args.renownUrl);
|
|
367
339
|
if (args.showDid) {
|
|
368
|
-
|
|
340
|
+
console.log(renown.did);
|
|
369
341
|
process.exit(0);
|
|
370
342
|
}
|
|
371
343
|
if (args.status) {
|
|
372
|
-
await
|
|
344
|
+
const { getAuthStatus } = await import("@renown/sdk/node");
|
|
345
|
+
const status = getAuthStatus(renown);
|
|
346
|
+
if (!status.authenticated || !status.address) {
|
|
347
|
+
console.log("Not authenticated with an Ethereum address.");
|
|
348
|
+
console.log("Run \"ph login\" to authenticate.");
|
|
349
|
+
} else {
|
|
350
|
+
console.log("Authenticated");
|
|
351
|
+
console.log(` ETH Address: ${status.address}`);
|
|
352
|
+
console.log(` User DID: ${status.userDid}`);
|
|
353
|
+
console.log(` Chain ID: ${status.chainId}`);
|
|
354
|
+
console.log(` CLI DID: ${status.cliDid}`);
|
|
355
|
+
console.log(` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`);
|
|
356
|
+
console.log(` Renown URL: ${status.baseUrl}`);
|
|
357
|
+
}
|
|
373
358
|
process.exit(0);
|
|
374
359
|
}
|
|
375
360
|
if (args.logout) {
|
|
376
361
|
await handleLogout();
|
|
377
362
|
process.exit(0);
|
|
378
363
|
}
|
|
379
|
-
const
|
|
380
|
-
const timeoutMs = args.timeout ? args.timeout * 1e3 : DEFAULT_TIMEOUT_MS;
|
|
364
|
+
const { browserLogin } = await import("@renown/sdk/node");
|
|
381
365
|
console.debug("Initializing cryptographic identity...");
|
|
382
|
-
const { generateSessionId, getRenown } = await import("./auth-BeA5gDPQ.mjs");
|
|
383
|
-
const renown = await getRenown();
|
|
384
|
-
if (renown.user) {
|
|
385
|
-
console.error(`Already authenticated as ${renown.user.address}\nUse "ph logout" to sign out first.`);
|
|
386
|
-
process.exit(1);
|
|
387
|
-
}
|
|
388
366
|
console.log(`CLI DID: ${renown.did}`);
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
367
|
+
try {
|
|
368
|
+
const timeoutMs = args.timeout ? args.timeout * 1e3 : void 0;
|
|
369
|
+
const result = await browserLogin(renown, {
|
|
370
|
+
renownUrl: args.renownUrl,
|
|
371
|
+
timeoutMs,
|
|
372
|
+
onLoginUrl: (url, sessionId) => {
|
|
373
|
+
console.log("Opening browser for authentication...");
|
|
374
|
+
console.log(`Session ID: ${sessionId.slice(0, 8)}...`);
|
|
375
|
+
console.log(`Login URL: ${url}`);
|
|
376
|
+
console.log();
|
|
377
|
+
console.log("Waiting for authentication in browser");
|
|
378
|
+
console.log(`(timeout in ${(timeoutMs ?? 3e5) / 1e3} seconds)`);
|
|
379
|
+
console.log();
|
|
380
|
+
console.log("Please connect your wallet and authorize this CLI to act on your behalf.");
|
|
381
|
+
console.log();
|
|
382
|
+
process.stdout.write("Waiting");
|
|
383
|
+
},
|
|
384
|
+
onPollTick: () => process.stdout.write("."),
|
|
385
|
+
onBrowserOpenFailed: (url) => {
|
|
386
|
+
console.error("Failed to open browser automatically.");
|
|
387
|
+
console.log(`Please open this URL manually: ${url}`);
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
console.log();
|
|
391
|
+
console.log();
|
|
392
|
+
console.log("Successfully authenticated!");
|
|
393
|
+
console.log(` ETH Address: ${result.user.address}`);
|
|
394
|
+
console.log(` User DID: ${result.user.did}`);
|
|
395
|
+
console.log(` CLI DID: ${result.cliDid}`);
|
|
396
|
+
console.log();
|
|
397
|
+
console.log("The CLI can now act on behalf of your Ethereum identity.");
|
|
398
|
+
} catch (error) {
|
|
399
|
+
console.log();
|
|
400
|
+
throw error;
|
|
401
|
+
}
|
|
415
402
|
process.exit(0);
|
|
416
403
|
}
|
|
417
404
|
});
|
|
418
|
-
const DEFAULT_TIMEOUT_MS = 300 * 1e3;
|
|
419
|
-
const POLL_INTERVAL_MS = 2e3;
|
|
420
|
-
/**
|
|
421
|
-
* Open a URL in the default browser
|
|
422
|
-
*/
|
|
423
|
-
async function openBrowser(url) {
|
|
424
|
-
const { exec } = await import("node:child_process");
|
|
425
|
-
const { promisify } = await import("node:util");
|
|
426
|
-
const execAsync = promisify(exec);
|
|
427
|
-
const platform = process.platform;
|
|
428
|
-
try {
|
|
429
|
-
if (platform === "darwin") await execAsync(`open "${url}"`);
|
|
430
|
-
else if (platform === "win32") await execAsync(`start "" "${url}"`);
|
|
431
|
-
else await execAsync(`xdg-open "${url}"`);
|
|
432
|
-
} catch (error) {
|
|
433
|
-
console.error("Failed to open browser automatically.");
|
|
434
|
-
console.log(`Please open this URL manually: ${url}`);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Poll the session endpoint until ready or timeout
|
|
439
|
-
*/
|
|
440
|
-
async function pollSession(renownUrl, sessionId, timeoutMs) {
|
|
441
|
-
const startTime = Date.now();
|
|
442
|
-
const sessionUrl = `${renownUrl}/api/console/session/${sessionId}`;
|
|
443
|
-
while (Date.now() - startTime < timeoutMs) try {
|
|
444
|
-
const response = await fetch(sessionUrl);
|
|
445
|
-
if (!response.ok) {
|
|
446
|
-
console.error(`Session check failed: ${response.status}`);
|
|
447
|
-
await sleep(POLL_INTERVAL_MS);
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
const data = await response.json();
|
|
451
|
-
if (data.status === "ready") return data;
|
|
452
|
-
process.stdout.write(".");
|
|
453
|
-
await sleep(POLL_INTERVAL_MS);
|
|
454
|
-
} catch (error) {
|
|
455
|
-
await sleep(POLL_INTERVAL_MS);
|
|
456
|
-
}
|
|
457
|
-
return null;
|
|
458
|
-
}
|
|
459
|
-
function sleep(ms) {
|
|
460
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Show current authentication status
|
|
464
|
-
*/
|
|
465
|
-
async function showStatus() {
|
|
466
|
-
const { getRenown } = await import("./auth-BeA5gDPQ.mjs");
|
|
467
|
-
const renown = await getRenown();
|
|
468
|
-
const user = renown.user;
|
|
469
|
-
if (!user || !user.credential) {
|
|
470
|
-
console.log("Not authenticated with an Ethereum address.");
|
|
471
|
-
console.log("Run \"ph login\" to authenticate.");
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
const issuanceDate = new Date(user.credential.issuanceDate);
|
|
475
|
-
console.log("Authenticated");
|
|
476
|
-
console.log(` ETH Address: ${user.address}`);
|
|
477
|
-
console.log(` User DID: ${user.did}`);
|
|
478
|
-
console.log(` Chain ID: ${user.chainId}`);
|
|
479
|
-
console.log(` CLI DID: ${renown.did}`);
|
|
480
|
-
console.log(` Authenticated at: ${issuanceDate.toLocaleString()}`);
|
|
481
|
-
console.log(` Renown URL: ${renown.baseUrl}`);
|
|
482
|
-
process.exit(0);
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Show just the CLI DID
|
|
486
|
-
*/
|
|
487
|
-
async function showDid() {
|
|
488
|
-
try {
|
|
489
|
-
const { generateSessionId, getRenown } = await import("./auth-BeA5gDPQ.mjs");
|
|
490
|
-
const renown = await getRenown();
|
|
491
|
-
console.log(renown.did);
|
|
492
|
-
} catch (e) {
|
|
493
|
-
console.error("Failed to get DID:");
|
|
494
|
-
throw e;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Logout and clear credentials
|
|
499
|
-
*/
|
|
500
405
|
async function handleLogout() {
|
|
501
|
-
const { getRenown } = await import("./auth-
|
|
406
|
+
const { getRenown } = await import("./auth-wgUd0D0V.mjs");
|
|
502
407
|
const renown = await getRenown();
|
|
503
408
|
if (!renown.user) {
|
|
504
409
|
console.log("Not currently authenticated.");
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":["version","build","getConfig","getConfig"],"sources":["../src/get-version.ts","../src/utils/constants.ts","../src/commands/ph-cli-help.ts","../src/commands/access-token.ts","../src/commands/build.ts","../src/commands/connect.ts","../src/commands/generate.ts","../src/commands/init.ts","../src/commands/inspect.ts","../src/commands/install.ts","../src/commands/list.ts","../src/commands/login.ts","../src/commands/logout.ts","../src/commands/migrate.ts","../src/commands/publish.ts","../src/commands/switchboard.ts","../src/commands/uninstall.ts","../src/commands/vetra.ts","../src/commands/ph-cli-commands.ts","../src/commands/ph-cli.ts","../src/cli.ts"],"sourcesContent":["export function getVersion() {\n return (\n process.env.WORKSPACE_VERSION ||\n process.env.npm_package_version ||\n \"unknown\"\n );\n}\n","export const PH_CLI_DESCRIPTION =\n \"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.\" as const;\n","import { phCliHelpCommands } from \"@powerhousedao/shared/clis\";\nimport { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { PH_CLI_DESCRIPTION } from \"../utils/constants.js\";\n\nconst version = getVersion();\nexport const phCliHelp = subcommands({\n name: \"ph-cli\",\n description: PH_CLI_DESCRIPTION,\n version,\n cmds: phCliHelpCommands,\n});\n","import {\n accessTokenArgs,\n DEFAULT_EXPIRY_SECONDS,\n SECONDS_IN_DAY,\n} from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const accessToken = command({\n name: \"access-token\",\n description: `\nThe access-token command generates a bearer token for API authentication. This token\ncan be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).\n\nThis command:\n1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential\n2. Creates a JWT bearer token with configurable expiration\n3. Outputs the token to stdout (info to stderr) for easy piping\n\nPrerequisites:\n You must have a cryptographic identity. Run 'ph login' first to:\n - Generate a keypair (stored in .ph/.keypair.json)\n - Optionally link your Ethereum address (stored in .ph/.renown.json)\n\nToken Details:\n The generated token is a JWT (JSON Web Token) containing:\n - Issuer (iss): Your CLI's DID (did:key:...)\n - Subject (sub): Your CLI's DID\n - Credential Subject: Chain ID, network ID, and address (if authenticated)\n - Expiration (exp): Based on --expiry option\n - Audience (aud): If --audience is specified\n\nOutput:\n- Token information (DID, address, expiry) is printed to stderr\n- The token itself is printed to stdout for easy piping/copying\n\nThis allows you to use the command in scripts:\n TOKEN=$(ph access-token)\n curl -H \"Authorization: Bearer $TOKEN\" http://localhost:4001/graphql\n\nUsage with APIs:\n Generate token and use with curl\n TOKEN=$(ph access-token --expiry 1d)\n curl -X POST http://localhost:4001/graphql \\\\\n -H \"Content-Type: application/json\" \\\\\n -H \"Authorization: Bearer $TOKEN\" \\\\\n -d '{\"query\": \"{ drives { id name } }\"}'\n\n Export as environment variable\n export PH_ACCESS_TOKEN=$(ph access-token)\n\nNotes:\n - Tokens are self-signed using your CLI's private key\n - No network request is made; tokens are generated locally\n - The recipient API must trust your CLI's DID to accept the token\n - For reactor-api, ensure AUTH_ENABLED=true to require authentication\n`,\n args: accessTokenArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n const did = renown.did;\n const user = renown.user;\n\n // Require Renown authentication - user must have done 'ph login'\n if (!user || !user.credential) {\n throw new Error(\n \"Not authenticated. Run 'ph login' first to authenticate with Renown. A Renown credential is required to generate valid bearer tokens.\",\n );\n }\n\n const address = user.address;\n\n // Parse expiry\n let expiresIn = DEFAULT_EXPIRY_SECONDS;\n if (args.expiry) expiresIn = parseExpiry(args.expiry);\n\n // Generate the bearer token;\n const token = await renown.getBearerToken(\n {\n expiresIn,\n aud: args.audience,\n },\n true,\n );\n\n // Calculate human-readable expiry\n const expiryDays = Math.floor(expiresIn / SECONDS_IN_DAY);\n const expiryHours = Math.floor((expiresIn % SECONDS_IN_DAY) / 3600);\n let expiryStr: string;\n if (expiryDays > 0) {\n expiryStr =\n expiryHours > 0\n ? `${expiryDays} day${expiryDays > 1 ? \"s\" : \"\"} and ${expiryHours} hour${expiryHours > 1 ? \"s\" : \"\"}`\n : `${expiryDays} day${expiryDays > 1 ? \"s\" : \"\"}`;\n } else if (expiryHours > 0) {\n expiryStr = `${expiryHours} hour${expiryHours > 1 ? \"s\" : \"\"}`;\n } else {\n expiryStr = `${expiresIn} seconds`;\n }\n\n // Output token info to stderr, token itself to stdout for piping\n console.error(`CLI DID: ${did}`);\n console.error(`ETH Address: ${address}`);\n console.error(`Token expires in: ${expiryStr}`);\n console.error(\"\");\n\n // Output just the token to stdout (for easy piping/copying)\n console.log(token);\n process.exit(0);\n },\n});\n\n/**\n * Parse expiry string to seconds\n * Supports formats: \"7d\" (days), \"24h\" (hours), \"3600\" (seconds), \"3600s\" (seconds)\n */\nfunction parseExpiry(expiry: string): number {\n const trimmed = expiry.trim().toLowerCase();\n\n // Check for day format (e.g., \"7d\")\n if (trimmed.endsWith(\"d\")) {\n const days = parseInt(trimmed.slice(0, -1), 10);\n if (isNaN(days) || days <= 0) {\n throw new Error(\n `Invalid expiry format: ${expiry}. Days must be a positive number.`,\n );\n }\n return days * SECONDS_IN_DAY;\n }\n\n // Check for hour format (e.g., \"24h\")\n if (trimmed.endsWith(\"h\")) {\n const hours = parseInt(trimmed.slice(0, -1), 10);\n if (isNaN(hours) || hours <= 0) {\n throw new Error(\n `Invalid expiry format: ${expiry}. Hours must be a positive number.`,\n );\n }\n return hours * 60 * 60;\n }\n\n // Check for seconds format (e.g., \"3600s\" or just \"3600\")\n const numericValue = trimmed.endsWith(\"s\") ? trimmed.slice(0, -1) : trimmed;\n\n const seconds = parseInt(numericValue, 10);\n if (isNaN(seconds) || seconds <= 0) {\n throw new Error(\n `Invalid expiry format: ${expiry}. Expected a positive number or format like \"7d\", \"24h\", \"3600s\".`,\n );\n }\n\n return seconds;\n}\n","import { buildArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\nimport { runBuild } from \"../services/build.js\";\n\nexport const build = command({\n name: \"build\",\n args: buildArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n try {\n await runBuild(args);\n } catch (error) {\n console.error(error);\n process.exit(1);\n }\n },\n});\n","import {\n connectBuildArgs,\n connectPreviewArgs,\n connectStudioArgs,\n} from \"@powerhousedao/shared/clis\";\nimport { command, subcommands } from \"cmd-ts\";\nexport const studio = command({\n name: \"studio\",\n description: `The studio command starts the Connect Studio, a development environment for building\nand testing Powerhouse applications. It provides a visual interface for working with\nyour project.\n\nThis command:\n1. Starts a local Connect Studio server\n2. Provides a web interface for development\n3. Allows you to interact with your project components\n4. Supports various configuration options for customization\n`,\n args: connectStudioArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { runConnectStudio } = await import(\"../services/connect-studio.js\");\n await runConnectStudio(args);\n },\n});\n\nexport const build = command({\n name: \"build\",\n description: `The Connect build command creates a production build with the project's local and\nexternal packages included\n`,\n args: connectBuildArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { runConnectBuild } = await import(\"../services/connect-build.js\");\n await runConnectBuild(args);\n process.exit(0);\n },\n});\n\nexport const preview = command({\n name: \"preview\",\n description: `The Connect preview command previews a built Connect project.\nNOTE: You must run \\`ph connect build\\` first\n`,\n args: connectPreviewArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { runConnectPreview } =\n await import(\"../services/connect-preview.js\");\n await runConnectPreview(args);\n },\n});\n\nexport const connect = subcommands({\n name: \"connect\",\n description: `Powerhouse Connect commands. Use with \\`studio\\`, \\`build\\` or \\`preview\\`. Defaults to \\`studio\\` if not specified.`,\n cmds: {\n studio,\n build,\n preview,\n },\n});\n","import { generateArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const generate = command({\n name: \"generate\",\n description: `\nThe generate command creates code from document models. It helps you build editors, \nprocessors, and other components based on your document model files.\n\nThis command:\n1. Reads document model definitions\n2. Generates code for specified components (editors, processors, etc.)\n3. Supports customization of output and generation options\n4. Can watch files for changes and regenerate code automatically\n`,\n args: generateArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startGenerate } = await import(\"../services/generate.js\");\n await startGenerate(args);\n process.exit(0);\n },\n});\n","import { initArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const init = command({\n name: \"init\",\n description: \"Initialize a new project\",\n args: initArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n const { startInit } = await import(\"../services/init.js\");\n await startInit(args);\n process.exit(0);\n },\n});\n","import { inspectArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const inspect = command({\n name: \"inspect\",\n description: `\nThe inspect command examines and provides detailed information about a Powerhouse package.\nIt helps you understand the structure, dependencies, and configuration of packages in\nyour project.\n\nThis command:\n1. Analyzes the specified package\n2. Retrieves detailed information about its structure and configuration\n3. Displays package metadata, dependencies, and other relevant information\n4. Helps troubleshoot package-related issues`,\n aliases: [\"is\"],\n args: inspectArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startInspect } = await import(\"../services/inspect.js\");\n startInspect(args);\n process.exit(0);\n },\n});\n","import { DEFAULT_REGISTRY_URL } from \"@powerhousedao/config\";\nimport {\n getConfig,\n getPowerhouseProjectInfo,\n getPowerhouseProjectInstallCommand,\n installArgs,\n makeDependenciesWithVersions,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"child_process\";\nimport { command } from \"cmd-ts\";\nimport { join } from \"path\";\nimport { updateConfigFile, updateStylesFile } from \"../utils.js\";\n\nexport const install = command({\n name: \"install\",\n aliases: [\"add\", \"i\"],\n description: `\nThe install command adds Powerhouse dependencies to your project. It installs packages\nfrom the Powerhouse registry by default and updates configuration files.\n\nThis command:\n1. Resolves the registry URL (--registry flag > powerhouse.config.json > PH_REGISTRY_URL env > default)\n2. Installs the package using your package manager with the resolved registry\n3. Updates powerhouse.config.json to include the new dependencies\n4. Updates style.css with CSS imports if applicable\n `,\n args: installArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const {\n projectPath,\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n } = await getPowerhouseProjectInfo(args);\n\n if (!projectPath) {\n throw new Error(`Could not find project path to install from.`);\n }\n\n // Resolve registry URL: flag > config > env > default\n const configPath = join(projectPath, \"powerhouse.config.json\");\n const config = getConfig(configPath);\n const registryUrl =\n args.registry ??\n config.packageRegistryUrl ??\n process.env.PH_REGISTRY_URL ??\n DEFAULT_REGISTRY_URL;\n\n if (args.debug) {\n console.log(\">>> registryUrl\", registryUrl);\n }\n\n const dependenciesWithVersions = await makeDependenciesWithVersions(\n args.dependencies,\n registryUrl,\n );\n\n if (args.debug) {\n console.log(\">>> parsedDependencies\", dependenciesWithVersions);\n }\n\n if (args.debug) {\n console.log(\"\\n>>> projectInfo\", {\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n });\n }\n\n try {\n console.log(`installing dependencies 📦 from ${registryUrl}...`);\n const installCommand = getPowerhouseProjectInstallCommand(\n packageManager,\n [\"--registry\", registryUrl],\n );\n execSync(installCommand, {\n stdio: \"inherit\",\n cwd: projectPath,\n });\n console.log(\"Dependency installed successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to install dependencies\");\n throw error;\n }\n\n if (args.debug) {\n console.log(\"\\n>>> updateConfigFile arguments:\");\n console.log(\">>> dependencies\", args.dependencies);\n console.log(\">>> projectPath\", projectPath);\n }\n\n try {\n console.log(\"⚙️ Updating powerhouse config file...\");\n updateConfigFile(dependenciesWithVersions, projectPath, \"install\");\n console.log(\"Config file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update config file\");\n throw error;\n }\n\n try {\n console.log(\"⚙️ Updating styles.css file...\");\n updateStylesFile(dependenciesWithVersions, projectPath);\n console.log(\"Styles file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update styles file\");\n throw error;\n }\n\n process.exit(0);\n },\n});\n","import { getConfig } from \"@powerhousedao/config/node\";\nimport { getPowerhouseProjectInfo, listArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const list = command({\n name: \"list\",\n description: `\nThe list command displays information about installed Powerhouse packages in your project.\nIt reads the powerhouse.config.json file and shows the packages that are currently installed.\n\nThis command:\n1. Examines your project configuration\n2. Lists all installed Powerhouse packages\n3. Provides a clear overview of your project's dependencies\n4. Helps you manage and track your Powerhouse components\n`,\n aliases: [\"l\"],\n args: listArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n try {\n const projectInfo = await getPowerhouseProjectInfo();\n console.log(\"\\n>>> projectInfo\", projectInfo);\n\n const phConfig = getConfig(\n projectInfo.projectPath + \"/powerhouse.config.json\",\n );\n\n if (!phConfig.packages || phConfig.packages.length === 0) {\n console.log(\"No packages found in the project\");\n return;\n }\n\n console.log(\"Installed Packages:\\n\");\n phConfig.packages.forEach((pkg) => {\n console.log(pkg.packageName);\n });\n } catch (e) {\n console.log(\"No packages found in the project\");\n }\n process.exit(0);\n },\n});\n","import { loginArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const login = command({\n name: \"login\",\n description: `\nThe login command authenticates you with Renown using your Ethereum wallet. This enables\nthe CLI to act on behalf of your Ethereum identity for authenticated operations.\n\nThis command:\n1. Generates or loads a cryptographic identity (DID) for the CLI\n2. Opens your browser to the Renown authentication page\n3. You authorize the CLI's DID to act on behalf of your Ethereum address\n4. Stores the credentials locally in .ph/.renown.json\n `,\n args: loginArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n if (args.showDid) {\n await showDid();\n process.exit(0);\n }\n\n // Handle status check\n if (args.status) {\n await showStatus();\n process.exit(0);\n }\n\n // Handle logout\n if (args.logout) {\n await handleLogout();\n process.exit(0);\n }\n\n const renownUrl = args.renownUrl;\n const timeoutMs = args.timeout ? args.timeout * 1000 : DEFAULT_TIMEOUT_MS;\n\n console.debug(\"Initializing cryptographic identity...\");\n\n const { generateSessionId, getRenown } =\n await import(\"../services/auth.js\");\n const renown = await getRenown();\n\n // Check if already authenticated\n if (renown.user) {\n console.error(\n `Already authenticated as ${renown.user.address}\\nUse \"ph logout\" to sign out first.`,\n );\n process.exit(1);\n }\n\n // Get the CLI's DID from Renown\n console.log(`CLI DID: ${renown.did}`);\n\n // Generate session ID\n const sessionId = generateSessionId();\n\n // Build the login URL with connect DID\n const loginUrl = new URL(`${renownUrl}/console`);\n loginUrl.searchParams.set(\"session\", sessionId);\n loginUrl.searchParams.set(\"connect\", renown.did);\n loginUrl.searchParams.set(\"app\", renown.did);\n\n console.log(\"Opening browser for authentication...\");\n console.log(`Session ID: ${sessionId.slice(0, 8)}...`);\n console.log();\n\n // Open browser\n await openBrowser(loginUrl.toString());\n\n console.log(\"Waiting for authentication in browser\");\n console.log(`(timeout in ${timeoutMs / 1000} seconds)`);\n console.log();\n console.log(\n \"Please connect your wallet and authorize this CLI to act on your behalf.\",\n );\n console.log();\n process.stdout.write(\"Waiting\");\n\n // Poll for session completion\n const result = await pollSession(renownUrl, sessionId, timeoutMs);\n\n console.log(); // New line after dots\n\n if (!result) {\n throw new Error(\n \"\\nAuthentication timed out. \\nPlease try again with: ph login\",\n );\n }\n\n const user = await renown.login(result.did);\n\n console.log();\n console.log(\"Successfully authenticated!\");\n console.log(` ETH Address: ${user.address}`);\n console.log(` User DID: ${user.did}`);\n console.log(` CLI DID: ${renown.did}`);\n console.log();\n console.log(\"The CLI can now act on behalf of your Ethereum identity.\");\n process.exit(0);\n },\n});\n\ninterface PendingSessionResponse {\n sessionId: string;\n status: \"pending\";\n}\n\ninterface ReadySessionResponse {\n sessionId: string;\n status: \"ready\";\n address: string;\n chainId: number;\n did: string;\n credentialId: string;\n userDocumentId: string;\n}\n\ntype SessionResponse = PendingSessionResponse | ReadySessionResponse;\n\nconst DEFAULT_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes\nconst POLL_INTERVAL_MS = 2000; // 2 seconds\n\n/**\n * Open a URL in the default browser\n */\nasync function openBrowser(url: string): Promise<void> {\n const { exec } = await import(\"node:child_process\");\n const { promisify } = await import(\"node:util\");\n const execAsync = promisify(exec);\n\n const platform = process.platform;\n\n try {\n if (platform === \"darwin\") {\n await execAsync(`open \"${url}\"`);\n } else if (platform === \"win32\") {\n await execAsync(`start \"\" \"${url}\"`);\n } else {\n // Linux and others\n await execAsync(`xdg-open \"${url}\"`);\n }\n } catch (error) {\n console.error(\"Failed to open browser automatically.\");\n console.log(`Please open this URL manually: ${url}`);\n }\n}\n\n/**\n * Poll the session endpoint until ready or timeout\n */\nasync function pollSession(\n renownUrl: string,\n sessionId: string,\n timeoutMs: number,\n): Promise<ReadySessionResponse | null> {\n const startTime = Date.now();\n const sessionUrl = `${renownUrl}/api/console/session/${sessionId}`;\n\n while (Date.now() - startTime < timeoutMs) {\n try {\n const response = await fetch(sessionUrl);\n\n if (!response.ok) {\n console.error(`Session check failed: ${response.status}`);\n await sleep(POLL_INTERVAL_MS);\n continue;\n }\n\n const data = (await response.json()) as SessionResponse;\n\n if (data.status === \"ready\") {\n return data;\n }\n\n // Still pending, wait and try again\n process.stdout.write(\".\");\n await sleep(POLL_INTERVAL_MS);\n } catch (error) {\n // Network error, wait and retry\n await sleep(POLL_INTERVAL_MS);\n }\n }\n\n return null; // Timeout reached\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Show current authentication status\n */\nasync function showStatus(): Promise<void> {\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n const user = renown.user;\n if (!user || !user.credential) {\n console.log(\"Not authenticated with an Ethereum address.\");\n console.log('Run \"ph login\" to authenticate.');\n return;\n }\n\n const issuanceDate = new Date(user.credential.issuanceDate);\n console.log(\"Authenticated\");\n console.log(` ETH Address: ${user.address}`);\n console.log(` User DID: ${user.did}`);\n console.log(` Chain ID: ${user.chainId}`);\n console.log(` CLI DID: ${renown.did}`);\n console.log(` Authenticated at: ${issuanceDate.toLocaleString()}`);\n console.log(` Renown URL: ${renown.baseUrl}`);\n\n process.exit(0);\n}\n\n/**\n * Show just the CLI DID\n */\nasync function showDid(): Promise<void> {\n try {\n const { generateSessionId, getRenown } =\n await import(\"../services/auth.js\");\n const renown = await getRenown();\n console.log(renown.did);\n } catch (e) {\n console.error(\"Failed to get DID:\");\n throw e;\n }\n}\n\n/**\n * Logout and clear credentials\n */\nexport async function handleLogout() {\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n if (!renown.user) {\n console.log(\"Not currently authenticated.\");\n return;\n }\n\n try {\n await renown.logout();\n console.log(\"Successfully logged out.\");\n } catch (error) {\n console.error(\"Failed to clear credentials.\");\n console.debug(error);\n }\n}\n","import { command } from \"cmd-ts\";\nimport { handleLogout } from \"./login.js\";\n\nexport const logout = command({\n name: \"logout\",\n description: `\nThe logout command removes an existing session created with 'ph login'`,\n args: {},\n handler: async () => {\n await handleLogout();\n process.exit(0);\n },\n});\n","import { migrateArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const migrate = command({\n name: \"migrate\",\n args: migrateArgs,\n description: \"Run migrations\",\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startMigrate } = await import(\"../services/migrate.js\");\n await startMigrate(args);\n process.exit(0);\n },\n});\n","import { DEFAULT_REGISTRY_URL } from \"@powerhousedao/config\";\nimport { getConfig } from \"@powerhousedao/config/node\";\nimport {\n getPowerhouseProjectInfo,\n publishArgs,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"child_process\";\nimport { command } from \"cmd-ts\";\nimport { join } from \"path\";\n\nexport const publish = command({\n name: \"publish\",\n description: `\nPublish a package to the Powerhouse registry. This is a thin wrapper around npm publish\nthat automatically sets the registry URL.\n\nThis command:\n1. Resolves the registry URL (--registry flag > powerhouse.config.json > PH_REGISTRY_URL env > default)\n2. Checks authentication with the registry via npm whoami\n3. Forwards all additional arguments to npm publish\n `,\n args: publishArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { projectPath } = await getPowerhouseProjectInfo();\n\n if (!projectPath) {\n throw new Error(\"Could not find project path.\");\n }\n\n // Resolve registry URL: flag > config > env > default\n const configPath = join(projectPath, \"powerhouse.config.json\");\n const config = getConfig(configPath);\n const registryUrl =\n args.registry ??\n process.env.PH_REGISTRY_URL ??\n config.packageRegistryUrl ??\n DEFAULT_REGISTRY_URL;\n\n if (args.debug) {\n console.log(\">>> registryUrl\", registryUrl);\n }\n\n // Check authentication\n try {\n execSync(`npm whoami --registry ${registryUrl}`, { stdio: \"pipe\" });\n } catch {\n console.error(`Not authenticated with registry: ${registryUrl}`);\n console.error(`Run: npm adduser --registry ${registryUrl}`);\n process.exit(1);\n }\n\n // Forward remaining args to npm publish\n const forwardedArgs = args.forwardedArgs;\n const cmd =\n `npm publish --registry ${registryUrl} ${forwardedArgs.join(\" \")}`.trim();\n\n if (args.debug) {\n console.log(\">>> command\", cmd);\n }\n\n console.log(`Publishing to ${registryUrl}...`);\n execSync(cmd, { stdio: \"inherit\", cwd: projectPath });\n\n process.exit(0);\n },\n});\n","import { switchboardArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const switchboard = command({\n name: \"switchboard\",\n aliases: [\"reactor\"],\n description: `\nThe switchboard command starts a local Switchboard instance, which acts as the document\nprocessing engine for Powerhouse projects. It provides the infrastructure for document\nmodels, processors, and real-time updates.\n\nThis command:\n1. Starts a local switchboard server\n2. Loads document models and processors\n3. Provides an API for document operations\n4. Enables real-time document processing\n5. Can authenticate with remote services using your identity from 'ph login'`,\n args: switchboardArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { basePath, dbPath, migrate, migrateStatus } = args;\n if (basePath) {\n process.env.BASE_PATH = basePath;\n }\n\n if (migrate || migrateStatus) {\n const { runSwitchboardMigrations } =\n await import(\"../services/switchboard-migrate.js\");\n await runSwitchboardMigrations({\n dbPath,\n statusOnly: migrateStatus,\n });\n process.exit(0);\n }\n\n const { startSwitchboard } = await import(\"../services/switchboard.js\");\n const { defaultDriveUrl, renown } = await startSwitchboard(args);\n console.log(\" ➜ Switchboard:\", defaultDriveUrl);\n if (renown) {\n console.log(\" ➜ Identity:\", renown.did);\n }\n },\n});\n","import {\n getPowerhouseProjectInfo,\n getPowerhouseProjectUninstallCommand,\n makeDependenciesWithVersions,\n uninstallArgs,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"child_process\";\nimport { command } from \"cmd-ts\";\nimport { AGENTS } from \"package-manager-detector\";\nimport { removeStylesImports, updateConfigFile } from \"../utils.js\";\n\nexport const uninstall = command({\n name: \"uninstall\",\n aliases: [\"remove\"],\n description: `\nThe uninstall command removes Powerhouse dependencies from your project. It handles the\nremoval of packages, updates configuration files, and ensures proper cleanup.\n\nThis command:\n1. Uninstalls specified Powerhouse dependencies using your package manager\n2. Updates powerhouse.config.json to remove the dependencies\n3. Supports various uninstallation options and configurations\n4. Works with ${AGENTS.join(\", \")} package managers\n`,\n args: uninstallArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const {\n projectPath,\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n } = await getPowerhouseProjectInfo(args);\n\n if (!projectPath) {\n throw new Error(`Could not find project path to uninstall from`);\n }\n\n const dependenciesWithVersions = await makeDependenciesWithVersions(\n args.dependencies,\n );\n\n if (args.debug) {\n console.log(\">>> parsedDependencies\", dependenciesWithVersions);\n }\n\n if (args.debug) {\n console.log(\"\\n>>> projectInfo\", {\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n });\n }\n\n try {\n console.log(\"Uninstalling dependencies 📦 ...\");\n const uninstallCommand =\n await getPowerhouseProjectUninstallCommand(packageManager);\n execSync(uninstallCommand, {\n stdio: \"inherit\",\n cwd: projectPath,\n });\n console.log(\"Dependency uninstalled successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to uninstall dependencies\");\n throw error;\n }\n\n try {\n console.log(\"⚙️ Updating powerhouse config file...\");\n updateConfigFile(dependenciesWithVersions, projectPath, \"uninstall\");\n console.log(\"Config file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update config file\");\n throw error;\n }\n\n try {\n console.log(\"⚙️ Updating styles.css file...\");\n removeStylesImports(dependenciesWithVersions, projectPath);\n console.log(\"Styles file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update styles file\");\n throw error;\n }\n\n process.exit(0);\n },\n});\n","import { vetraArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const vetra = command({\n name: \"vetra\",\n description: `\nThe vetra command sets up a Vetra development environment for working with Vetra projects.\nIt starts a Vetra Switchboard and optionally Connect Studio, enabling document collaboration \nand real-time processing with a \"Vetra\" drive or connection to remote drives.\n\nThis command:\n1. Starts a Vetra Switchboard with a \"Vetra\" drive for document storage\n2. Optionally connects to remote drives instead of creating a local drive\n3. Starts Connect Studio pointing to the Switchboard for user interaction (unless disabled)\n4. Enables real-time updates, collaboration, and code generation`,\n args: vetraArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startVetra } = await import(\"../services/vetra.js\");\n await startVetra(args);\n },\n});\n","import { accessToken } from \"./access-token.js\";\nimport { build } from \"./build.js\";\nimport { connect } from \"./connect.js\";\nimport { generate } from \"./generate.js\";\nimport { init } from \"./init.js\";\nimport { inspect } from \"./inspect.js\";\nimport { install } from \"./install.js\";\nimport { list } from \"./list.js\";\nimport { login } from \"./login.js\";\nimport { logout } from \"./logout.js\";\nimport { migrate } from \"./migrate.js\";\nimport { publish } from \"./publish.js\";\nimport { switchboard } from \"./switchboard.js\";\nimport { uninstall } from \"./uninstall.js\";\nimport { vetra } from \"./vetra.js\";\n\nexport const phCliCommands = {\n init,\n generate,\n vetra,\n connect,\n build,\n publish,\n \"access-token\": accessToken,\n inspect,\n list,\n migrate,\n switchboard,\n login,\n logout,\n install,\n uninstall,\n} as const;\n","import { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { PH_CLI_DESCRIPTION } from \"../utils/constants.js\";\nimport { phCliCommands } from \"./ph-cli-commands.js\";\n\nconst version = getVersion();\nexport const phCli = subcommands({\n name: \"ph-cli\",\n description: PH_CLI_DESCRIPTION,\n version,\n cmds: phCliCommands,\n});\n","#!/usr/bin/env node\nimport { assertNodeVersion } from \"@powerhousedao/shared/clis\";\nimport { run } from \"cmd-ts\";\nimport { phCliHelp } from \"./commands/ph-cli-help.js\";\nimport { phCli } from \"./commands/ph-cli.js\";\n\nasync function main() {\n assertNodeVersion();\n const args = process.argv.slice(2);\n const hasNoArgs = args.length === 0;\n const isHelp = args.some((arg) => arg === \"--help\" || arg === \"-h\");\n const isTopLevelHelp = isHelp && args.length === 1;\n const showTopLevelHelp = hasNoArgs || isTopLevelHelp;\n const cli = showTopLevelHelp ? phCliHelp : phCli;\n const [command, ...restArgs] = args;\n if (\n command === \"connect\" &&\n ![\"studio\", \"build\", \"preview\"].includes(args[1]) &&\n !isHelp\n ) {\n const argsWithDefaultConnectSubCommand = [\"connect\", \"studio\", ...restArgs];\n await run(cli, argsWithDefaultConnectSubCommand);\n } else {\n await run(cli, args);\n }\n}\n\nawait main().catch((error) => {\n const isDebug = process.argv.slice(2).includes(\"--debug\");\n if (isDebug) {\n throw error;\n }\n if (error instanceof Error) {\n console.error(error.message);\n process.exit(1);\n } else {\n throw error;\n }\n});\n"],"mappings":";;;;;;;;;;;AAAA,SAAgB,aAAa;AAC3B,QACE,QAAQ,IAAI,qBACZ,QAAQ,IAAI,uBACZ;;;;ACJJ,MAAa,qBACX;ACKF,MAAa,YAAY,YAAY;CACnC,MAAM;CACN,aAAa;CACb,SAJc,YAAY;CAK1B,MAAM;CACP,CAAC;;;ACJF,MAAa,cAAc,QAAQ;CACjC,MAAM;CACN,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cb,MAAM;CACN,SAAS,OAAO,SAAS;AACvB,MAAI,KAAK,MACP,SAAQ,IAAI,KAAK;EAGnB,MAAM,EAAE,cAAc,MAAM,OAAO;EACnC,MAAM,SAAS,MAAM,WAAW;EAChC,MAAM,MAAM,OAAO;EACnB,MAAM,OAAO,OAAO;AAGpB,MAA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KAEhD,OAAM,IAAI,KAAK,KAAK;;AAIxB,MAAM,MAAM,CAAC,OAAO,UAAU;AAE5B,KADgB,QAAQ,KAAK,MAAM,EAAE,CAAC,SAAS,UAAU,CAEvD,OAAM;AAER,KAAI,iBAAiB,OAAO;AAC1B,UAAQ,MAAM,MAAM,QAAQ;AAC5B,UAAQ,KAAK,EAAE;OAEf,OAAM;EAER"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["version","build","getConfig","getConfig"],"sources":["../src/get-version.ts","../src/utils/constants.ts","../src/commands/ph-cli-help.ts","../src/commands/access-token.ts","../src/commands/build.ts","../src/commands/connect.ts","../src/commands/generate.ts","../src/commands/init.ts","../src/commands/inspect.ts","../src/commands/install.ts","../src/commands/list.ts","../src/commands/login.ts","../src/commands/logout.ts","../src/commands/migrate.ts","../src/commands/publish.ts","../src/commands/switchboard.ts","../src/commands/uninstall.ts","../src/commands/vetra.ts","../src/commands/ph-cli-commands.ts","../src/commands/ph-cli.ts","../src/cli.ts"],"sourcesContent":["export function getVersion() {\n return (\n process.env.WORKSPACE_VERSION ||\n process.env.npm_package_version ||\n \"unknown\"\n );\n}\n","export const PH_CLI_DESCRIPTION =\n \"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.\" as const;\n","import { phCliHelpCommands } from \"@powerhousedao/shared/clis\";\nimport { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { PH_CLI_DESCRIPTION } from \"../utils/constants.js\";\n\nconst version = getVersion();\nexport const phCliHelp = subcommands({\n name: \"ph-cli\",\n description: PH_CLI_DESCRIPTION,\n version,\n cmds: phCliHelpCommands,\n});\n","import {\n accessTokenArgs,\n DEFAULT_EXPIRY_SECONDS,\n} from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const accessToken = command({\n name: \"access-token\",\n description: `\nThe access-token command generates a bearer token for API authentication. This token\ncan be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).\n\nThis command:\n1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential\n2. Creates a JWT bearer token with configurable expiration\n3. Outputs the token to stdout (info to stderr) for easy piping\n\nPrerequisites:\n You must have a cryptographic identity. Run 'ph login' first to:\n - Generate a keypair (stored in .ph/.keypair.json)\n - Optionally link your Ethereum address (stored in .ph/.renown.json)\n\nToken Details:\n The generated token is a JWT (JSON Web Token) containing:\n - Issuer (iss): Your CLI's DID (did:key:...)\n - Subject (sub): Your CLI's DID\n - Credential Subject: Chain ID, network ID, and address (if authenticated)\n - Expiration (exp): Based on --expiry option\n - Audience (aud): If --audience is specified\n\nOutput:\n- Token information (DID, address, expiry) is printed to stderr\n- The token itself is printed to stdout for easy piping/copying\n\nThis allows you to use the command in scripts:\n TOKEN=$(ph access-token)\n curl -H \"Authorization: Bearer $TOKEN\" http://localhost:4001/graphql\n\nUsage with APIs:\n Generate token and use with curl\n TOKEN=$(ph access-token --expiry 1d)\n curl -X POST http://localhost:4001/graphql \\\\\n -H \"Content-Type: application/json\" \\\\\n -H \"Authorization: Bearer $TOKEN\" \\\\\n -d '{\"query\": \"{ drives { id name } }\"}'\n\n Export as environment variable\n export PH_ACCESS_TOKEN=$(ph access-token)\n\nNotes:\n - Tokens are self-signed using your CLI's private key\n - No network request is made; tokens are generated locally\n - The recipient API must trust your CLI's DID to accept the token\n - For reactor-api, ensure AUTH_ENABLED=true to require authentication\n`,\n args: accessTokenArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { generateAccessToken, parseExpiry, formatExpiry } =\n await import(\"@renown/sdk/node\");\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n\n let expiresIn = DEFAULT_EXPIRY_SECONDS;\n if (args.expiry) expiresIn = parseExpiry(args.expiry);\n\n const result = await generateAccessToken(renown, {\n expiresIn,\n aud: args.audience,\n });\n\n // Output token info to stderr, token itself to stdout for piping\n console.error(`CLI DID: ${result.did}`);\n console.error(`ETH Address: ${result.address}`);\n console.error(`Token expires in: ${formatExpiry(expiresIn)}`);\n console.error(\"\");\n\n console.log(result.token);\n process.exit(0);\n },\n});\n","import { buildArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\nimport { runBuild } from \"../services/build.js\";\n\nexport const build = command({\n name: \"build\",\n args: buildArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n try {\n await runBuild(args);\n } catch (error) {\n console.error(error);\n process.exit(1);\n }\n },\n});\n","import {\n connectBuildArgs,\n connectPreviewArgs,\n connectStudioArgs,\n} from \"@powerhousedao/shared/clis\";\nimport { command, subcommands } from \"cmd-ts\";\nexport const studio = command({\n name: \"studio\",\n description: `The studio command starts the Connect Studio, a development environment for building\nand testing Powerhouse applications. It provides a visual interface for working with\nyour project.\n\nThis command:\n1. Starts a local Connect Studio server\n2. Provides a web interface for development\n3. Allows you to interact with your project components\n4. Supports various configuration options for customization\n`,\n args: connectStudioArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { runConnectStudio } = await import(\"../services/connect-studio.js\");\n await runConnectStudio(args);\n },\n});\n\nexport const build = command({\n name: \"build\",\n description: `The Connect build command creates a production build with the project's local and\nexternal packages included\n`,\n args: connectBuildArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { runConnectBuild } = await import(\"../services/connect-build.js\");\n await runConnectBuild(args);\n process.exit(0);\n },\n});\n\nexport const preview = command({\n name: \"preview\",\n description: `The Connect preview command previews a built Connect project.\nNOTE: You must run \\`ph connect build\\` first\n`,\n args: connectPreviewArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { runConnectPreview } =\n await import(\"../services/connect-preview.js\");\n await runConnectPreview(args);\n },\n});\n\nexport const connect = subcommands({\n name: \"connect\",\n description: `Powerhouse Connect commands. Use with \\`studio\\`, \\`build\\` or \\`preview\\`. Defaults to \\`studio\\` if not specified.`,\n cmds: {\n studio,\n build,\n preview,\n },\n});\n","import { generateArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const generate = command({\n name: \"generate\",\n description: `\nThe generate command creates code from document models. It helps you build editors, \nprocessors, and other components based on your document model files.\n\nThis command:\n1. Reads document model definitions\n2. Generates code for specified components (editors, processors, etc.)\n3. Supports customization of output and generation options\n4. Can watch files for changes and regenerate code automatically\n`,\n args: generateArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startGenerate } = await import(\"../services/generate.js\");\n await startGenerate(args);\n process.exit(0);\n },\n});\n","import { initArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const init = command({\n name: \"init\",\n description: \"Initialize a new project\",\n args: initArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n const { startInit } = await import(\"../services/init.js\");\n await startInit(args);\n process.exit(0);\n },\n});\n","import { inspectArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const inspect = command({\n name: \"inspect\",\n description: `\nThe inspect command examines and provides detailed information about a Powerhouse package.\nIt helps you understand the structure, dependencies, and configuration of packages in\nyour project.\n\nThis command:\n1. Analyzes the specified package\n2. Retrieves detailed information about its structure and configuration\n3. Displays package metadata, dependencies, and other relevant information\n4. Helps troubleshoot package-related issues`,\n aliases: [\"is\"],\n args: inspectArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startInspect } = await import(\"../services/inspect.js\");\n startInspect(args);\n process.exit(0);\n },\n});\n","import { DEFAULT_REGISTRY_URL } from \"@powerhousedao/config\";\nimport {\n getConfig,\n getPowerhouseProjectInfo,\n getPowerhouseProjectInstallCommand,\n installArgs,\n makeDependenciesWithVersions,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"child_process\";\nimport { command } from \"cmd-ts\";\nimport { join } from \"path\";\nimport { updateConfigFile, updateStylesFile } from \"../utils.js\";\n\nexport const install = command({\n name: \"install\",\n aliases: [\"add\", \"i\"],\n description: `\nThe install command adds Powerhouse dependencies to your project. It installs packages\nfrom the Powerhouse registry by default and updates configuration files.\n\nThis command:\n1. Resolves the registry URL (--registry flag > powerhouse.config.json > PH_REGISTRY_URL env > default)\n2. Installs the package using your package manager with the resolved registry\n3. Updates powerhouse.config.json to include the new dependencies\n4. Updates style.css with CSS imports if applicable\n `,\n args: installArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const {\n projectPath,\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n } = await getPowerhouseProjectInfo(args);\n\n if (!projectPath) {\n throw new Error(`Could not find project path to install from.`);\n }\n\n // Resolve registry URL: flag > config > env > default\n const configPath = join(projectPath, \"powerhouse.config.json\");\n const config = getConfig(configPath);\n const registryUrl =\n args.registry ??\n config.packageRegistryUrl ??\n process.env.PH_REGISTRY_URL ??\n DEFAULT_REGISTRY_URL;\n\n if (args.debug) {\n console.log(\">>> registryUrl\", registryUrl);\n }\n\n const dependenciesWithVersions = await makeDependenciesWithVersions(\n args.dependencies,\n registryUrl,\n );\n\n if (args.debug) {\n console.log(\">>> parsedDependencies\", dependenciesWithVersions);\n }\n\n if (args.debug) {\n console.log(\"\\n>>> projectInfo\", {\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n });\n }\n\n try {\n console.log(`installing dependencies 📦 from ${registryUrl}...`);\n const installCommand = getPowerhouseProjectInstallCommand(\n packageManager,\n [\"--registry\", registryUrl],\n );\n execSync(installCommand, {\n stdio: \"inherit\",\n cwd: projectPath,\n });\n console.log(\"Dependency installed successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to install dependencies\");\n throw error;\n }\n\n if (args.debug) {\n console.log(\"\\n>>> updateConfigFile arguments:\");\n console.log(\">>> dependencies\", args.dependencies);\n console.log(\">>> projectPath\", projectPath);\n }\n\n try {\n console.log(\"⚙️ Updating powerhouse config file...\");\n updateConfigFile(dependenciesWithVersions, projectPath, \"install\");\n console.log(\"Config file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update config file\");\n throw error;\n }\n\n try {\n console.log(\"⚙️ Updating styles.css file...\");\n updateStylesFile(dependenciesWithVersions, projectPath);\n console.log(\"Styles file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update styles file\");\n throw error;\n }\n\n process.exit(0);\n },\n});\n","import { getConfig } from \"@powerhousedao/config/node\";\nimport { getPowerhouseProjectInfo, listArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const list = command({\n name: \"list\",\n description: `\nThe list command displays information about installed Powerhouse packages in your project.\nIt reads the powerhouse.config.json file and shows the packages that are currently installed.\n\nThis command:\n1. Examines your project configuration\n2. Lists all installed Powerhouse packages\n3. Provides a clear overview of your project's dependencies\n4. Helps you manage and track your Powerhouse components\n`,\n aliases: [\"l\"],\n args: listArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n try {\n const projectInfo = await getPowerhouseProjectInfo();\n console.log(\"\\n>>> projectInfo\", projectInfo);\n\n const phConfig = getConfig(\n projectInfo.projectPath + \"/powerhouse.config.json\",\n );\n\n if (!phConfig.packages || phConfig.packages.length === 0) {\n console.log(\"No packages found in the project\");\n return;\n }\n\n console.log(\"Installed Packages:\\n\");\n phConfig.packages.forEach((pkg) => {\n console.log(pkg.packageName);\n });\n } catch (e) {\n console.log(\"No packages found in the project\");\n }\n process.exit(0);\n },\n});\n","import { loginArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const login = command({\n name: \"login\",\n description: `\nThe login command authenticates you with Renown using your Ethereum wallet. This enables\nthe CLI to act on behalf of your Ethereum identity for authenticated operations.\n\nThis command:\n1. Generates or loads a cryptographic identity (DID) for the CLI\n2. Opens your browser to the Renown authentication page\n3. You authorize the CLI's DID to act on behalf of your Ethereum address\n4. Stores the credentials locally in .ph/.renown.json\n `,\n args: loginArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown(args.renownUrl);\n\n if (args.showDid) {\n console.log(renown.did);\n process.exit(0);\n }\n\n if (args.status) {\n const { getAuthStatus } = await import(\"@renown/sdk/node\");\n const status = getAuthStatus(renown);\n if (!status.authenticated || !status.address) {\n console.log(\"Not authenticated with an Ethereum address.\");\n console.log('Run \"ph login\" to authenticate.');\n } else {\n console.log(\"Authenticated\");\n console.log(` ETH Address: ${status.address}`);\n console.log(` User DID: ${status.userDid}`);\n console.log(` Chain ID: ${status.chainId}`);\n console.log(` CLI DID: ${status.cliDid}`);\n console.log(\n ` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`,\n );\n console.log(` Renown URL: ${status.baseUrl}`);\n }\n process.exit(0);\n }\n\n if (args.logout) {\n await handleLogout();\n process.exit(0);\n }\n\n const { browserLogin } = await import(\"@renown/sdk/node\");\n\n console.debug(\"Initializing cryptographic identity...\");\n console.log(`CLI DID: ${renown.did}`);\n\n try {\n const timeoutMs = args.timeout ? args.timeout * 1000 : undefined;\n\n const result = await browserLogin(renown, {\n renownUrl: args.renownUrl,\n timeoutMs,\n onLoginUrl: (url, sessionId) => {\n console.log(\"Opening browser for authentication...\");\n console.log(`Session ID: ${sessionId.slice(0, 8)}...`);\n console.log(`Login URL: ${url}`);\n console.log();\n console.log(\"Waiting for authentication in browser\");\n console.log(`(timeout in ${(timeoutMs ?? 300_000) / 1000} seconds)`);\n console.log();\n console.log(\n \"Please connect your wallet and authorize this CLI to act on your behalf.\",\n );\n console.log();\n process.stdout.write(\"Waiting\");\n },\n onPollTick: () => process.stdout.write(\".\"),\n onBrowserOpenFailed: (url) => {\n console.error(\"Failed to open browser automatically.\");\n console.log(`Please open this URL manually: ${url}`);\n },\n });\n\n console.log(); // New line after dots\n console.log();\n console.log(\"Successfully authenticated!\");\n console.log(` ETH Address: ${result.user.address}`);\n console.log(` User DID: ${result.user.did}`);\n console.log(` CLI DID: ${result.cliDid}`);\n console.log();\n console.log(\"The CLI can now act on behalf of your Ethereum identity.\");\n } catch (error) {\n console.log(); // New line after dots\n throw error;\n }\n\n process.exit(0);\n },\n});\n\nexport async function handleLogout() {\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n if (!renown.user) {\n console.log(\"Not currently authenticated.\");\n return;\n }\n\n try {\n await renown.logout();\n console.log(\"Successfully logged out.\");\n } catch (error) {\n console.error(\"Failed to clear credentials.\");\n console.debug(error);\n }\n}\n","import { command } from \"cmd-ts\";\nimport { handleLogout } from \"./login.js\";\n\nexport const logout = command({\n name: \"logout\",\n description: `\nThe logout command removes an existing session created with 'ph login'`,\n args: {},\n handler: async () => {\n await handleLogout();\n process.exit(0);\n },\n});\n","import { migrateArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const migrate = command({\n name: \"migrate\",\n args: migrateArgs,\n description: \"Run migrations\",\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startMigrate } = await import(\"../services/migrate.js\");\n await startMigrate(args);\n process.exit(0);\n },\n});\n","import { DEFAULT_REGISTRY_URL } from \"@powerhousedao/config\";\nimport { getConfig } from \"@powerhousedao/config/node\";\nimport {\n getPowerhouseProjectInfo,\n publishArgs,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"child_process\";\nimport { command } from \"cmd-ts\";\nimport { join } from \"path\";\n\nexport const publish = command({\n name: \"publish\",\n description: `\nPublish a package to the Powerhouse registry. This is a thin wrapper around npm publish\nthat automatically sets the registry URL.\n\nThis command:\n1. Resolves the registry URL (--registry flag > powerhouse.config.json > PH_REGISTRY_URL env > default)\n2. Checks authentication with the registry via npm whoami\n3. Forwards all additional arguments to npm publish\n `,\n args: publishArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { projectPath } = await getPowerhouseProjectInfo();\n\n if (!projectPath) {\n throw new Error(\"Could not find project path.\");\n }\n\n // Resolve registry URL: flag > config > env > default\n const configPath = join(projectPath, \"powerhouse.config.json\");\n const config = getConfig(configPath);\n const registryUrl =\n args.registry ??\n process.env.PH_REGISTRY_URL ??\n config.packageRegistryUrl ??\n DEFAULT_REGISTRY_URL;\n\n if (args.debug) {\n console.log(\">>> registryUrl\", registryUrl);\n }\n\n // Check authentication\n try {\n execSync(`npm whoami --registry ${registryUrl}`, { stdio: \"pipe\" });\n } catch {\n console.error(`Not authenticated with registry: ${registryUrl}`);\n console.error(`Run: npm adduser --registry ${registryUrl}`);\n process.exit(1);\n }\n\n // Forward remaining args to npm publish\n const forwardedArgs = args.forwardedArgs;\n const cmd =\n `npm publish --registry ${registryUrl} ${forwardedArgs.join(\" \")}`.trim();\n\n if (args.debug) {\n console.log(\">>> command\", cmd);\n }\n\n console.log(`Publishing to ${registryUrl}...`);\n execSync(cmd, { stdio: \"inherit\", cwd: projectPath });\n\n process.exit(0);\n },\n});\n","import { switchboardArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const switchboard = command({\n name: \"switchboard\",\n aliases: [\"reactor\"],\n description: `\nThe switchboard command starts a local Switchboard instance, which acts as the document\nprocessing engine for Powerhouse projects. It provides the infrastructure for document\nmodels, processors, and real-time updates.\n\nThis command:\n1. Starts a local switchboard server\n2. Loads document models and processors\n3. Provides an API for document operations\n4. Enables real-time document processing\n5. Can authenticate with remote services using your identity from 'ph login'`,\n args: switchboardArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { basePath, dbPath, migrate, migrateStatus } = args;\n if (basePath) {\n process.env.BASE_PATH = basePath;\n }\n\n if (migrate || migrateStatus) {\n const { runSwitchboardMigrations } =\n await import(\"../services/switchboard-migrate.js\");\n await runSwitchboardMigrations({\n dbPath,\n statusOnly: migrateStatus,\n });\n process.exit(0);\n }\n\n const { startSwitchboard } = await import(\"../services/switchboard.js\");\n const { defaultDriveUrl, renown } = await startSwitchboard(args);\n console.log(\" ➜ Switchboard:\", defaultDriveUrl);\n if (renown) {\n console.log(\" ➜ Identity:\", renown.did);\n }\n },\n});\n","import {\n getPowerhouseProjectInfo,\n getPowerhouseProjectUninstallCommand,\n makeDependenciesWithVersions,\n uninstallArgs,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"child_process\";\nimport { command } from \"cmd-ts\";\nimport { AGENTS } from \"package-manager-detector\";\nimport { removeStylesImports, updateConfigFile } from \"../utils.js\";\n\nexport const uninstall = command({\n name: \"uninstall\",\n aliases: [\"remove\"],\n description: `\nThe uninstall command removes Powerhouse dependencies from your project. It handles the\nremoval of packages, updates configuration files, and ensures proper cleanup.\n\nThis command:\n1. Uninstalls specified Powerhouse dependencies using your package manager\n2. Updates powerhouse.config.json to remove the dependencies\n3. Supports various uninstallation options and configurations\n4. Works with ${AGENTS.join(\", \")} package managers\n`,\n args: uninstallArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const {\n projectPath,\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n } = await getPowerhouseProjectInfo(args);\n\n if (!projectPath) {\n throw new Error(`Could not find project path to uninstall from`);\n }\n\n const dependenciesWithVersions = await makeDependenciesWithVersions(\n args.dependencies,\n );\n\n if (args.debug) {\n console.log(\">>> parsedDependencies\", dependenciesWithVersions);\n }\n\n if (args.debug) {\n console.log(\"\\n>>> projectInfo\", {\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n });\n }\n\n try {\n console.log(\"Uninstalling dependencies 📦 ...\");\n const uninstallCommand =\n await getPowerhouseProjectUninstallCommand(packageManager);\n execSync(uninstallCommand, {\n stdio: \"inherit\",\n cwd: projectPath,\n });\n console.log(\"Dependency uninstalled successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to uninstall dependencies\");\n throw error;\n }\n\n try {\n console.log(\"⚙️ Updating powerhouse config file...\");\n updateConfigFile(dependenciesWithVersions, projectPath, \"uninstall\");\n console.log(\"Config file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update config file\");\n throw error;\n }\n\n try {\n console.log(\"⚙️ Updating styles.css file...\");\n removeStylesImports(dependenciesWithVersions, projectPath);\n console.log(\"Styles file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update styles file\");\n throw error;\n }\n\n process.exit(0);\n },\n});\n","import { vetraArgs } from \"@powerhousedao/shared/clis\";\nimport { command } from \"cmd-ts\";\n\nexport const vetra = command({\n name: \"vetra\",\n description: `\nThe vetra command sets up a Vetra development environment for working with Vetra projects.\nIt starts a Vetra Switchboard and optionally Connect Studio, enabling document collaboration \nand real-time processing with a \"Vetra\" drive or connection to remote drives.\n\nThis command:\n1. Starts a Vetra Switchboard with a \"Vetra\" drive for document storage\n2. Optionally connects to remote drives instead of creating a local drive\n3. Starts Connect Studio pointing to the Switchboard for user interaction (unless disabled)\n4. Enables real-time updates, collaboration, and code generation`,\n args: vetraArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startVetra } = await import(\"../services/vetra.js\");\n await startVetra(args);\n },\n});\n","import { accessToken } from \"./access-token.js\";\nimport { build } from \"./build.js\";\nimport { connect } from \"./connect.js\";\nimport { generate } from \"./generate.js\";\nimport { init } from \"./init.js\";\nimport { inspect } from \"./inspect.js\";\nimport { install } from \"./install.js\";\nimport { list } from \"./list.js\";\nimport { login } from \"./login.js\";\nimport { logout } from \"./logout.js\";\nimport { migrate } from \"./migrate.js\";\nimport { publish } from \"./publish.js\";\nimport { switchboard } from \"./switchboard.js\";\nimport { uninstall } from \"./uninstall.js\";\nimport { vetra } from \"./vetra.js\";\n\nexport const phCliCommands = {\n init,\n generate,\n vetra,\n connect,\n build,\n publish,\n \"access-token\": accessToken,\n inspect,\n list,\n migrate,\n switchboard,\n login,\n logout,\n install,\n uninstall,\n} as const;\n","import { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { PH_CLI_DESCRIPTION } from \"../utils/constants.js\";\nimport { phCliCommands } from \"./ph-cli-commands.js\";\n\nconst version = getVersion();\nexport const phCli = subcommands({\n name: \"ph-cli\",\n description: PH_CLI_DESCRIPTION,\n version,\n cmds: phCliCommands,\n});\n","#!/usr/bin/env node\nimport { assertNodeVersion } from \"@powerhousedao/shared/clis\";\nimport { run } from \"cmd-ts\";\nimport { phCliHelp } from \"./commands/ph-cli-help.js\";\nimport { phCli } from \"./commands/ph-cli.js\";\n\nasync function main() {\n assertNodeVersion();\n const args = process.argv.slice(2);\n const hasNoArgs = args.length === 0;\n const isHelp = args.some((arg) => arg === \"--help\" || arg === \"-h\");\n const isTopLevelHelp = isHelp && args.length === 1;\n const showTopLevelHelp = hasNoArgs || isTopLevelHelp;\n const cli = showTopLevelHelp ? phCliHelp : phCli;\n const [command, ...restArgs] = args;\n if (\n command === \"connect\" &&\n ![\"studio\", \"build\", \"preview\"].includes(args[1]) &&\n !isHelp\n ) {\n const argsWithDefaultConnectSubCommand = [\"connect\", \"studio\", ...restArgs];\n await run(cli, argsWithDefaultConnectSubCommand);\n } else {\n await run(cli, args);\n }\n}\n\nawait main().catch((error) => {\n const isDebug = process.argv.slice(2).includes(\"--debug\");\n if (isDebug) {\n throw error;\n }\n if (error instanceof Error) {\n console.error(error.message);\n process.exit(1);\n } else {\n throw error;\n }\n});\n"],"mappings":";;;;;;;;;;;AAAA,SAAgB,aAAa;AAC3B,QACE,QAAQ,IAAI,qBACZ,QAAQ,IAAI,uBACZ;;;;ACJJ,MAAa,qBACX;ACKF,MAAa,YAAY,YAAY;CACnC,MAAM;CACN,aAAa;CACb,SAJc,YAAY;CAK1B,MAAM;CACP,CAAC;;;ACLF,MAAa,cAAc,QAAQ;CACjC,MAAM;CACN,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cb,MAAM;CACN,SAAS,OAAO,SAAS;AACvB,MAAI,KAAK,MACP,SAAQ,IAAI,KAAK;EAGnB,MAAM,EAAE,qBAAqB,aAAa,iBACxC,MAAM,OAAO;EACf,MAAM,EAAE,cAAc,MAAM,O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;;AAIxB,MAAM,MAAM,CAAC,OAAO,UAAU;AAE5B,KADgB,QAAQ,KAAK,MAAM,EAAE,CAAC,SAAS,UAAU,CAEvD,OAAM;AAER,KAAI,iBAAiB,OAAO;AAC1B,UAAQ,MAAM,MAAM,QAAQ;AAC5B,UAAQ,KAAK,EAAE;OAEf,OAAM;EAER"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/ph-cli",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.173",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"semver": "7.7.4",
|
|
38
38
|
"ts-morph": "27.0.2",
|
|
39
39
|
"write-package": "7.2.0",
|
|
40
|
-
"@powerhousedao/codegen": "6.0.0-dev.
|
|
41
|
-
"document-model": "6.0.0-dev.
|
|
42
|
-
"@powerhousedao/config": "6.0.0-dev.
|
|
43
|
-
"@powerhousedao/common": "6.0.0-dev.
|
|
44
|
-
"@powerhousedao/reactor": "6.0.0-dev.
|
|
45
|
-
"@powerhousedao/shared": "6.0.0-dev.
|
|
46
|
-
"@powerhousedao/switchboard": "6.0.0-dev.
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
40
|
+
"@powerhousedao/codegen": "6.0.0-dev.173",
|
|
41
|
+
"document-model": "6.0.0-dev.173",
|
|
42
|
+
"@powerhousedao/config": "6.0.0-dev.173",
|
|
43
|
+
"@powerhousedao/common": "6.0.0-dev.173",
|
|
44
|
+
"@powerhousedao/reactor": "6.0.0-dev.173",
|
|
45
|
+
"@powerhousedao/shared": "6.0.0-dev.173",
|
|
46
|
+
"@powerhousedao/switchboard": "6.0.0-dev.173",
|
|
47
|
+
"@renown/sdk": "6.0.0-dev.173",
|
|
48
|
+
"@powerhousedao/builder-tools": "6.0.0-dev.173"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "25.2.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-BeA5gDPQ.mjs","names":[],"sources":["../src/services/auth.ts"],"sourcesContent":["import { RenownBuilder, type IRenown } from \"@renown/sdk/node\";\nimport { join } from \"node:path\";\n\nconst AUTH_FILE = \".ph/.renown.json\";\nconst AUTH_PATH = join(process.cwd(), AUTH_FILE);\n\n// Singleton instance of Renown\nlet renownInstance: IRenown | null = null;\n\nexport interface StoredCredentials {\n address: string;\n chainId: number;\n userDid: string;\n appDid: string;\n credentialId: string;\n userDocumentId?: string;\n authenticatedAt: string;\n renownUrl: string;\n}\n\n/**\n * Generate a UUID v4 for session IDs\n */\nexport function generateSessionId(): string {\n return crypto.randomUUID();\n}\n\n/**\n * Get or create the Renown instance\n * Uses PH_RENOWN_PRIVATE_KEY env var if set, otherwise generates/loads from file\n */\nexport async function getRenown(): Promise<IRenown> {\n if (!renownInstance) {\n renownInstance = await new RenownBuilder(\"ph-cli\").build();\n }\n return renownInstance;\n}\n"],"mappings":";;;AAIkB,KAAK,QAAQ,KAAK,EADlB,mBAC8B;AAGhD,IAAI,iBAAiC;;;;AAgBrC,SAAgB,oBAA4B;AAC1C,QAAO,OAAO,YAAY;;;;;;AAO5B,eAAsB,YAA8B;AAClD,KAAI,CAAC,eACH,kBAAiB,MAAM,IAAI,cAAc,SAAS,CAAC,OAAO;AAE5D,QAAO"}
|