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