@powerhousedao/ph-cli 6.0.0-dev.200 → 6.0.0-dev.202
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{assign-env-vars-CzHgn5ax.mjs → assign-env-vars-B-oPplBd.mjs} +1 -1
- package/dist/{assign-env-vars-CzHgn5ax.mjs.map → assign-env-vars-B-oPplBd.mjs.map} +1 -1
- package/dist/{auth-wgUd0D0V.mjs → auth-mwX4ugZt.mjs} +1 -1
- package/dist/{auth-wgUd0D0V.mjs.map → auth-mwX4ugZt.mjs.map} +1 -1
- package/dist/{build-BflSHYLP.mjs → build-Fq1pNRsl.mjs} +1 -1
- package/dist/{build-BflSHYLP.mjs.map → build-Fq1pNRsl.mjs.map} +1 -1
- package/dist/cli-CYgcGGKv.mjs +140 -0
- package/dist/cli-CYgcGGKv.mjs.map +1 -0
- package/dist/cli.mjs +20 -379
- package/dist/cli.mjs.map +1 -1
- package/dist/{connect-build-oDJKd0aN.mjs → connect-build-DUiJQGfx.mjs} +3 -3
- package/dist/{connect-build-oDJKd0aN.mjs.map → connect-build-DUiJQGfx.mjs.map} +1 -1
- package/dist/{connect-preview-4Xe7Lm1V.mjs → connect-preview-hSphy1QP.mjs} +2 -2
- package/dist/{connect-preview-4Xe7Lm1V.mjs.map → connect-preview-hSphy1QP.mjs.map} +1 -1
- package/dist/{connect-studio-38_NrT_a.mjs → connect-studio-CFH0kGW1.mjs} +2 -2
- package/dist/{connect-studio-38_NrT_a.mjs.map → connect-studio-CFH0kGW1.mjs.map} +1 -1
- package/dist/connect-studio-CV-T5IfA.mjs +3 -0
- package/dist/{generate-all-B2zuJ01M.mjs → generate-all-yTycRkd3.mjs} +1 -1
- package/dist/{generate-all-B2zuJ01M.mjs.map → generate-all-yTycRkd3.mjs.map} +1 -1
- package/dist/{generate-app-DKShBXn7.mjs → generate-app-hSK1SlOn.mjs} +1 -1
- package/dist/{generate-app-DKShBXn7.mjs.map → generate-app-hSK1SlOn.mjs.map} +1 -1
- package/dist/{generate-document-model-wud-Ezfp.mjs → generate-document-model-ZowVACXL.mjs} +1 -1
- package/dist/{generate-document-model-wud-Ezfp.mjs.map → generate-document-model-ZowVACXL.mjs.map} +1 -1
- package/dist/{generate-editor-BJbBk8c5.mjs → generate-editor-C53z-03Q.mjs} +1 -1
- package/dist/{generate-editor-BJbBk8c5.mjs.map → generate-editor-C53z-03Q.mjs.map} +1 -1
- package/dist/{generate-processor-BF3yxDSa.mjs → generate-processor-BS4F98d6.mjs} +1 -1
- package/dist/{generate-processor-BF3yxDSa.mjs.map → generate-processor-BS4F98d6.mjs.map} +1 -1
- package/dist/{generate-subgraph-mkgADj_1.mjs → generate-subgraph-D1cYT9GQ.mjs} +1 -1
- package/dist/{generate-subgraph-mkgADj_1.mjs.map → generate-subgraph-D1cYT9GQ.mjs.map} +1 -1
- package/dist/{init-iDbH337G.mjs → init-BgEVXxOR.mjs} +1 -1
- package/dist/{init-iDbH337G.mjs.map → init-BgEVXxOR.mjs.map} +1 -1
- package/dist/{inspect-C5s3gQIQ.mjs → inspect-D7H8gCuH.mjs} +2 -2
- package/dist/{inspect-C5s3gQIQ.mjs.map → inspect-D7H8gCuH.mjs.map} +1 -1
- package/dist/logout-BpJEO2Ij.mjs +230 -0
- package/dist/logout-BpJEO2Ij.mjs.map +1 -0
- package/dist/{migrate-CIBhw4np.mjs → migrate-CSaC4bDh.mjs} +1 -1
- package/dist/{migrate-CIBhw4np.mjs.map → migrate-CSaC4bDh.mjs.map} +1 -1
- package/dist/{switchboard-vPgnxFrM.mjs → switchboard-Bl2llp5U.mjs} +1 -1
- package/dist/{switchboard-vPgnxFrM.mjs.map → switchboard-Bl2llp5U.mjs.map} +1 -1
- package/dist/switchboard-DUlj8v2F.mjs +2 -0
- package/dist/{switchboard-migrate-COGf5HBF.mjs → switchboard-migrate-BiQJfIrc.mjs} +1 -1
- package/dist/{switchboard-migrate-COGf5HBF.mjs.map → switchboard-migrate-BiQJfIrc.mjs.map} +1 -1
- package/dist/{utils-CFkM2mAC.mjs → utils-B6ZD50VC.mjs} +1 -1
- package/dist/{utils-CFkM2mAC.mjs.map → utils-B6ZD50VC.mjs.map} +1 -1
- package/dist/{vetra-B7ofmdqk.mjs → vetra-1k4IHQEV.mjs} +5 -5
- package/dist/{vetra-B7ofmdqk.mjs.map → vetra-1k4IHQEV.mjs.map} +1 -1
- package/package.json +10 -10
- package/dist/connect-studio-DuH6WcoA.mjs +0 -3
- package/dist/switchboard-CiIwAwyR.mjs +0 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { a as getVersion, i as accessToken, n as login, r as list, t as logout } from "./logout-BpJEO2Ij.mjs";
|
|
3
|
+
import { t as runBuild } from "./build-Fq1pNRsl.mjs";
|
|
4
|
+
import { a as updateStylesFile, i as updateConfigFile, r as removeStylesImports } from "./utils-B6ZD50VC.mjs";
|
|
5
|
+
import { assertNodeVersion, buildArgs, captureCliError, codeArgs, connectBuildArgs, connectPreviewArgs, connectStudioArgs, debugArgs, getPowerhouseProjectInfo, getPowerhouseProjectUninstallCommand, initArgs, initCliTelemetry, inspectArgs, installArgs, makeDependenciesWithVersions, migrateArgs, phCliHelpCommands, publishArgs, switchboardArgs, uninstallArgs, unpublishArgs, vetraArgs } from "@powerhousedao/shared/clis";
|
|
5
6
|
import { array, boolean, command, flag, multioption, oneOf, option, optional, run, string, subcommands } from "cmd-ts";
|
|
6
7
|
import { AGENTS, resolveCommand } from "package-manager-detector";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { defineCli, defineCommand } from "@powerhousedao/ph-clint";
|
|
9
|
-
import { getConfig as getConfig$1 } from "@powerhousedao/config/node";
|
|
10
8
|
import { Directory, File } from "cmd-ts/dist/cjs/batteries/fs.js";
|
|
11
9
|
import { generateDBSchema } from "@powerhousedao/codegen";
|
|
12
10
|
import path from "path";
|
|
@@ -16,11 +14,6 @@ import { execSync } from "child_process";
|
|
|
16
14
|
import { readPackageSync } from "read-pkg";
|
|
17
15
|
import { prerelease } from "semver";
|
|
18
16
|
import { createInterface } from "node:readline/promises";
|
|
19
|
-
//#region src/get-version.ts
|
|
20
|
-
function getVersion() {
|
|
21
|
-
return process.env.WORKSPACE_VERSION || process.env.npm_package_version || "unknown";
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
17
|
//#region src/utils/constants.ts
|
|
25
18
|
const PH_CLI_DESCRIPTION = "The Powerhouse CLI (ph-cli) is a command-line interface tool that provides essential commands for managing Powerhouse projects. The tool and it's commands are fundamental for creating, building, and running Document Models as a builder in studio mode.";
|
|
26
19
|
const phCliHelp = subcommands({
|
|
@@ -30,77 +23,6 @@ const phCliHelp = subcommands({
|
|
|
30
23
|
cmds: phCliHelpCommands
|
|
31
24
|
});
|
|
32
25
|
//#endregion
|
|
33
|
-
//#region src/commands/access-token.ts
|
|
34
|
-
const accessToken = command({
|
|
35
|
-
name: "access-token",
|
|
36
|
-
description: `
|
|
37
|
-
The access-token command generates a bearer token for API authentication. This token
|
|
38
|
-
can be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).
|
|
39
|
-
|
|
40
|
-
This command:
|
|
41
|
-
1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential
|
|
42
|
-
2. Creates a JWT bearer token with configurable expiration
|
|
43
|
-
3. Outputs the token to stdout (info to stderr) for easy piping
|
|
44
|
-
|
|
45
|
-
Prerequisites:
|
|
46
|
-
You must have a cryptographic identity. Run 'ph login' first to:
|
|
47
|
-
- Generate a keypair (stored in .ph/.keypair.json)
|
|
48
|
-
- Optionally link your Ethereum address (stored in .ph/.renown.json)
|
|
49
|
-
|
|
50
|
-
Token Details:
|
|
51
|
-
The generated token is a JWT (JSON Web Token) containing:
|
|
52
|
-
- Issuer (iss): Your CLI's DID (did:key:...)
|
|
53
|
-
- Subject (sub): Your CLI's DID
|
|
54
|
-
- Credential Subject: Chain ID, network ID, and address (if authenticated)
|
|
55
|
-
- Expiration (exp): Based on --expiry option
|
|
56
|
-
- Audience (aud): If --audience is specified
|
|
57
|
-
|
|
58
|
-
Output:
|
|
59
|
-
- Token information (DID, address, expiry) is printed to stderr
|
|
60
|
-
- The token itself is printed to stdout for easy piping/copying
|
|
61
|
-
|
|
62
|
-
This allows you to use the command in scripts:
|
|
63
|
-
TOKEN=$(ph access-token)
|
|
64
|
-
curl -H "Authorization: Bearer $TOKEN" http://localhost:4001/graphql
|
|
65
|
-
|
|
66
|
-
Usage with APIs:
|
|
67
|
-
Generate token and use with curl
|
|
68
|
-
TOKEN=$(ph access-token --expiry 1d)
|
|
69
|
-
curl -X POST http://localhost:4001/graphql \\
|
|
70
|
-
-H "Content-Type: application/json" \\
|
|
71
|
-
-H "Authorization: Bearer $TOKEN" \\
|
|
72
|
-
-d '{"query": "{ drives { id name } }"}'
|
|
73
|
-
|
|
74
|
-
Export as environment variable
|
|
75
|
-
export PH_ACCESS_TOKEN=$(ph access-token)
|
|
76
|
-
|
|
77
|
-
Notes:
|
|
78
|
-
- Tokens are self-signed using your CLI's private key
|
|
79
|
-
- No network request is made; tokens are generated locally
|
|
80
|
-
- The recipient API must trust your CLI's DID to accept the token
|
|
81
|
-
- For reactor-api, ensure AUTH_ENABLED=true to require authentication
|
|
82
|
-
`,
|
|
83
|
-
args: accessTokenArgs,
|
|
84
|
-
handler: async (args) => {
|
|
85
|
-
if (args.debug) console.log(args);
|
|
86
|
-
const { generateAccessToken, parseExpiry, formatExpiry } = await import("@renown/sdk/node");
|
|
87
|
-
const { getRenown } = await import("./auth-wgUd0D0V.mjs");
|
|
88
|
-
const renown = await getRenown();
|
|
89
|
-
let expiresIn = DEFAULT_EXPIRY_SECONDS;
|
|
90
|
-
if (args.expiry) expiresIn = parseExpiry(args.expiry);
|
|
91
|
-
const result = await generateAccessToken(renown, {
|
|
92
|
-
expiresIn,
|
|
93
|
-
aud: args.audience
|
|
94
|
-
});
|
|
95
|
-
console.error(`CLI DID: ${result.did}`);
|
|
96
|
-
console.error(`ETH Address: ${result.address}`);
|
|
97
|
-
console.error(`Token expires in: ${formatExpiry(expiresIn)}`);
|
|
98
|
-
console.error("");
|
|
99
|
-
console.log(result.token);
|
|
100
|
-
process.exit(0);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
//#endregion
|
|
104
26
|
//#region src/commands/build.ts
|
|
105
27
|
const build$1 = command({
|
|
106
28
|
name: "build",
|
|
@@ -116,288 +38,6 @@ const build$1 = command({
|
|
|
116
38
|
}
|
|
117
39
|
});
|
|
118
40
|
//#endregion
|
|
119
|
-
//#region src/code/adapter.ts
|
|
120
|
-
var ExitSignal = class extends Error {
|
|
121
|
-
constructor(code) {
|
|
122
|
-
super(`process.exit(${code}) intercepted`);
|
|
123
|
-
this.code = code;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
function adaptCmdTs(opts) {
|
|
127
|
-
return defineCommand({
|
|
128
|
-
id: opts.id,
|
|
129
|
-
description: opts.description.trim(),
|
|
130
|
-
inputSchema: opts.inputSchema,
|
|
131
|
-
execute: async (input, ctx) => {
|
|
132
|
-
const buf = [];
|
|
133
|
-
const origLog = console.log;
|
|
134
|
-
const origErr = console.error;
|
|
135
|
-
const origExit = process.exit;
|
|
136
|
-
const origNonInteractive = process.env.PH_NONINTERACTIVE;
|
|
137
|
-
const capture = (args) => {
|
|
138
|
-
const line = args.map((a) => typeof a === "string" ? a : safeStringify(a)).join(" ");
|
|
139
|
-
buf.push(line);
|
|
140
|
-
ctx.stdout(line + "\n");
|
|
141
|
-
};
|
|
142
|
-
console.log = (...a) => capture(a);
|
|
143
|
-
console.error = (...a) => capture(a);
|
|
144
|
-
process.exit = (code = 0) => {
|
|
145
|
-
throw new ExitSignal(code);
|
|
146
|
-
};
|
|
147
|
-
process.env.PH_NONINTERACTIVE = "1";
|
|
148
|
-
try {
|
|
149
|
-
await opts.invoke(input);
|
|
150
|
-
} catch (e) {
|
|
151
|
-
if (e instanceof ExitSignal) {
|
|
152
|
-
if (e.code !== 0) buf.push(`(command exited with code ${e.code})`);
|
|
153
|
-
} else throw e;
|
|
154
|
-
} finally {
|
|
155
|
-
console.log = origLog;
|
|
156
|
-
console.error = origErr;
|
|
157
|
-
process.exit = origExit;
|
|
158
|
-
if (origNonInteractive === void 0) delete process.env.PH_NONINTERACTIVE;
|
|
159
|
-
else process.env.PH_NONINTERACTIVE = origNonInteractive;
|
|
160
|
-
}
|
|
161
|
-
return buf.join("\n");
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function safeStringify(value) {
|
|
166
|
-
try {
|
|
167
|
-
return JSON.stringify(value);
|
|
168
|
-
} catch {
|
|
169
|
-
return String(value);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/commands/list.ts
|
|
174
|
-
const list = command({
|
|
175
|
-
name: "list",
|
|
176
|
-
description: `
|
|
177
|
-
The list command displays information about installed Powerhouse packages in your project.
|
|
178
|
-
It reads the powerhouse.config.json file and shows the packages that are currently installed.
|
|
179
|
-
|
|
180
|
-
This command:
|
|
181
|
-
1. Examines your project configuration
|
|
182
|
-
2. Lists all installed Powerhouse packages
|
|
183
|
-
3. Provides a clear overview of your project's dependencies
|
|
184
|
-
4. Helps you manage and track your Powerhouse components
|
|
185
|
-
`,
|
|
186
|
-
aliases: ["l"],
|
|
187
|
-
args: listArgs,
|
|
188
|
-
handler: async (args) => {
|
|
189
|
-
if (args.debug) console.log(args);
|
|
190
|
-
try {
|
|
191
|
-
const projectInfo = await getPowerhouseProjectInfo();
|
|
192
|
-
console.log("\n>>> projectInfo", projectInfo);
|
|
193
|
-
const phConfig = getConfig$1(projectInfo.projectPath + "/powerhouse.config.json");
|
|
194
|
-
if (!phConfig.packages || phConfig.packages.length === 0) {
|
|
195
|
-
console.log("No packages found in the project");
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
console.log("Installed Packages:\n");
|
|
199
|
-
phConfig.packages.forEach((pkg) => {
|
|
200
|
-
console.log(pkg.packageName);
|
|
201
|
-
});
|
|
202
|
-
} catch (e) {
|
|
203
|
-
console.log("No packages found in the project");
|
|
204
|
-
}
|
|
205
|
-
process.exit(0);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
//#endregion
|
|
209
|
-
//#region src/commands/login.ts
|
|
210
|
-
const login = command({
|
|
211
|
-
name: "login",
|
|
212
|
-
description: `
|
|
213
|
-
The login command authenticates you with Renown using your Ethereum wallet. This enables
|
|
214
|
-
the CLI to act on behalf of your Ethereum identity for authenticated operations.
|
|
215
|
-
|
|
216
|
-
This command:
|
|
217
|
-
1. Generates or loads a cryptographic identity (DID) for the CLI
|
|
218
|
-
2. Opens your browser to the Renown authentication page
|
|
219
|
-
3. You authorize the CLI's DID to act on behalf of your Ethereum address
|
|
220
|
-
4. Stores the credentials locally in .ph/.renown.json
|
|
221
|
-
`,
|
|
222
|
-
args: loginArgs,
|
|
223
|
-
handler: async (args) => {
|
|
224
|
-
if (args.debug) console.log(args);
|
|
225
|
-
const { getRenown } = await import("./auth-wgUd0D0V.mjs");
|
|
226
|
-
const renown = await getRenown(args.renownUrl);
|
|
227
|
-
if (args.showDid) {
|
|
228
|
-
console.log(renown.did);
|
|
229
|
-
process.exit(0);
|
|
230
|
-
}
|
|
231
|
-
if (args.status) {
|
|
232
|
-
const { getAuthStatus } = await import("@renown/sdk/node");
|
|
233
|
-
const status = getAuthStatus(renown);
|
|
234
|
-
if (!status.authenticated || !status.address) {
|
|
235
|
-
console.log("Not authenticated with an Ethereum address.");
|
|
236
|
-
console.log("Run \"ph login\" to authenticate.");
|
|
237
|
-
} else {
|
|
238
|
-
console.log("Authenticated");
|
|
239
|
-
console.log(` ETH Address: ${status.address}`);
|
|
240
|
-
console.log(` User DID: ${status.userDid}`);
|
|
241
|
-
console.log(` Chain ID: ${status.chainId}`);
|
|
242
|
-
console.log(` CLI DID: ${status.cliDid}`);
|
|
243
|
-
console.log(` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`);
|
|
244
|
-
console.log(` Renown URL: ${status.baseUrl}`);
|
|
245
|
-
}
|
|
246
|
-
process.exit(0);
|
|
247
|
-
}
|
|
248
|
-
if (args.logout) {
|
|
249
|
-
await handleLogout();
|
|
250
|
-
process.exit(0);
|
|
251
|
-
}
|
|
252
|
-
const { browserLogin } = await import("@renown/sdk/node");
|
|
253
|
-
console.debug("Initializing cryptographic identity...");
|
|
254
|
-
console.log(`CLI DID: ${renown.did}`);
|
|
255
|
-
try {
|
|
256
|
-
const timeoutMs = args.timeout ? args.timeout * 1e3 : void 0;
|
|
257
|
-
const result = await browserLogin(renown, {
|
|
258
|
-
renownUrl: args.renownUrl,
|
|
259
|
-
timeoutMs,
|
|
260
|
-
onLoginUrl: (url, sessionId) => {
|
|
261
|
-
console.log("Opening browser for authentication...");
|
|
262
|
-
console.log(`Session ID: ${sessionId.slice(0, 8)}...`);
|
|
263
|
-
console.log(`Login URL: ${url}`);
|
|
264
|
-
console.log();
|
|
265
|
-
console.log("Waiting for authentication in browser");
|
|
266
|
-
console.log(`(timeout in ${(timeoutMs ?? 3e5) / 1e3} seconds)`);
|
|
267
|
-
console.log();
|
|
268
|
-
console.log("Please connect your wallet and authorize this CLI to act on your behalf.");
|
|
269
|
-
console.log();
|
|
270
|
-
process.stdout.write("Waiting");
|
|
271
|
-
},
|
|
272
|
-
onPollTick: () => process.stdout.write("."),
|
|
273
|
-
onBrowserOpenFailed: (url) => {
|
|
274
|
-
console.error("Failed to open browser automatically.");
|
|
275
|
-
console.log(`Please open this URL manually: ${url}`);
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
console.log();
|
|
279
|
-
console.log();
|
|
280
|
-
console.log("Successfully authenticated!");
|
|
281
|
-
console.log(` ETH Address: ${result.user.address}`);
|
|
282
|
-
console.log(` User DID: ${result.user.did}`);
|
|
283
|
-
console.log(` CLI DID: ${result.cliDid}`);
|
|
284
|
-
console.log();
|
|
285
|
-
console.log("The CLI can now act on behalf of your Ethereum identity.");
|
|
286
|
-
} catch (error) {
|
|
287
|
-
console.log();
|
|
288
|
-
throw error;
|
|
289
|
-
}
|
|
290
|
-
process.exit(0);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
async function handleLogout() {
|
|
294
|
-
const { getRenown } = await import("./auth-wgUd0D0V.mjs");
|
|
295
|
-
const renown = await getRenown();
|
|
296
|
-
if (!renown.user) {
|
|
297
|
-
console.log("Not currently authenticated.");
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
try {
|
|
301
|
-
await renown.logout();
|
|
302
|
-
console.log("Successfully logged out.");
|
|
303
|
-
} catch (error) {
|
|
304
|
-
console.error("Failed to clear credentials.");
|
|
305
|
-
console.debug(error);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region src/commands/logout.ts
|
|
310
|
-
const logout = command({
|
|
311
|
-
name: "logout",
|
|
312
|
-
description: `
|
|
313
|
-
The logout command removes an existing session created with 'ph login'`,
|
|
314
|
-
args: {},
|
|
315
|
-
handler: async () => {
|
|
316
|
-
await handleLogout();
|
|
317
|
-
process.exit(0);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
//#endregion
|
|
321
|
-
//#region src/code/commands.ts
|
|
322
|
-
const debugSchema = { debug: z.boolean().optional() };
|
|
323
|
-
const phCliAdaptedCommands = [
|
|
324
|
-
adaptCmdTs({
|
|
325
|
-
id: "list",
|
|
326
|
-
description: "List installed Powerhouse packages from powerhouse.config.json.",
|
|
327
|
-
inputSchema: z.object({ ...debugSchema }),
|
|
328
|
-
invoke: (input) => list.handler(input)
|
|
329
|
-
}),
|
|
330
|
-
adaptCmdTs({
|
|
331
|
-
id: "logout",
|
|
332
|
-
description: "Remove the local Renown session created with `ph login`.",
|
|
333
|
-
inputSchema: z.object({}),
|
|
334
|
-
invoke: () => logout.handler({})
|
|
335
|
-
}),
|
|
336
|
-
adaptCmdTs({
|
|
337
|
-
id: "access-token",
|
|
338
|
-
description: "Generate a bearer JWT for Powerhouse APIs using the local DID. Requires `ph login` first.",
|
|
339
|
-
inputSchema: z.object({
|
|
340
|
-
expiry: z.string().optional().describe("Token expiry, e.g. \"7d\", \"24h\", \"3600s\"."),
|
|
341
|
-
audience: z.string().optional().describe("Target audience URL."),
|
|
342
|
-
...debugSchema
|
|
343
|
-
}),
|
|
344
|
-
invoke: (input) => accessToken.handler(input)
|
|
345
|
-
})
|
|
346
|
-
];
|
|
347
|
-
//#endregion
|
|
348
|
-
//#region src/code/agent.ts
|
|
349
|
-
const SYSTEM_INSTRUCTIONS = `You are ph code — a Powerhouse-flavored coding agent that runs inside the \`ph\` CLI.
|
|
350
|
-
|
|
351
|
-
You have direct access to the user's Powerhouse project via tools that wrap real \`ph\` commands.
|
|
352
|
-
Use the tools to answer questions and take action; never invent output.
|
|
353
|
-
|
|
354
|
-
Style:
|
|
355
|
-
- Be concise. Show command results, don't paraphrase them.
|
|
356
|
-
- When the user asks something that maps to a tool, call the tool first and then summarize.
|
|
357
|
-
- When in doubt about an action's blast radius, ask before running it.`;
|
|
358
|
-
async function createNimbyStyleAgent(ctx) {
|
|
359
|
-
const { createMastraHelpers } = await import("@powerhousedao/ph-clint/mastra");
|
|
360
|
-
const { Agent } = await import("@mastra/core/agent");
|
|
361
|
-
const m = createMastraHelpers(ctx);
|
|
362
|
-
const tools = await m.getTools();
|
|
363
|
-
const memory = await m.createMemory();
|
|
364
|
-
const cfg = ctx.config;
|
|
365
|
-
const modelId = cfg.model ?? "anthropic/claude-sonnet-4-5";
|
|
366
|
-
if (cfg.modelUrl && !process.env.OPENAI_API_KEY) process.env.OPENAI_API_KEY = "local";
|
|
367
|
-
const agent = new Agent({
|
|
368
|
-
id: "ph-code",
|
|
369
|
-
name: "ph code",
|
|
370
|
-
instructions: SYSTEM_INSTRUCTIONS,
|
|
371
|
-
model: cfg.modelUrl ? {
|
|
372
|
-
id: modelId,
|
|
373
|
-
url: cfg.modelUrl
|
|
374
|
-
} : modelId,
|
|
375
|
-
tools,
|
|
376
|
-
memory
|
|
377
|
-
});
|
|
378
|
-
return m.wrapAgent(agent, { maxSteps: 40 });
|
|
379
|
-
}
|
|
380
|
-
//#endregion
|
|
381
|
-
//#region src/code/cli.ts
|
|
382
|
-
const configSchema = z.object({
|
|
383
|
-
model: z.string().default("anthropic/claude-sonnet-4-5").describe("Mastra model id, e.g. \"anthropic/claude-sonnet-4-5\" or \"openai/Qwen3.6-27B-Q4_K_M.gguf\" for a local server."),
|
|
384
|
-
modelUrl: z.string().optional().describe("Optional base URL for the model provider (OpenAI-compatible). Set this to point at a local LLM, e.g. \"http://192.168.178.191:8100/v1\".")
|
|
385
|
-
});
|
|
386
|
-
const secretsSchema = z.object({ anthropicApiKey: z.string().optional().describe("Anthropic API key. Reads from ANTHROPIC_API_KEY by default.") });
|
|
387
|
-
function buildPhCodeCli() {
|
|
388
|
-
const cli = defineCli({
|
|
389
|
-
name: "ph-code",
|
|
390
|
-
version: getVersion(),
|
|
391
|
-
description: "Powerhouse coding agent. Runs your installed Powerhouse tools through a Mastra-driven REPL.",
|
|
392
|
-
configSchema,
|
|
393
|
-
secretsSchema,
|
|
394
|
-
commands: phCliAdaptedCommands,
|
|
395
|
-
interactive: { welcome: "ph code — type a prompt or /help. Ctrl-D to exit." }
|
|
396
|
-
});
|
|
397
|
-
cli.configureAgent(createNimbyStyleAgent);
|
|
398
|
-
return cli;
|
|
399
|
-
}
|
|
400
|
-
//#endregion
|
|
401
41
|
//#region src/commands/code.ts
|
|
402
42
|
const code = command({
|
|
403
43
|
name: "code",
|
|
@@ -411,6 +51,7 @@ Examples:
|
|
|
411
51
|
`,
|
|
412
52
|
args: codeArgs,
|
|
413
53
|
handler: async (args) => {
|
|
54
|
+
const { buildPhCodeCli } = await import("./cli-CYgcGGKv.mjs");
|
|
414
55
|
const cli = buildPhCodeCli();
|
|
415
56
|
const argv = [
|
|
416
57
|
"node",
|
|
@@ -439,7 +80,7 @@ This command:
|
|
|
439
80
|
args: connectStudioArgs,
|
|
440
81
|
handler: async (args) => {
|
|
441
82
|
if (args.debug) console.log(args);
|
|
442
|
-
const { runConnectStudio } = await import("./connect-studio-
|
|
83
|
+
const { runConnectStudio } = await import("./connect-studio-CV-T5IfA.mjs");
|
|
443
84
|
await runConnectStudio(args);
|
|
444
85
|
}
|
|
445
86
|
}),
|
|
@@ -451,7 +92,7 @@ external packages included
|
|
|
451
92
|
args: connectBuildArgs,
|
|
452
93
|
handler: async (args) => {
|
|
453
94
|
if (args.debug) console.log(args);
|
|
454
|
-
const { runConnectBuild } = await import("./connect-build-
|
|
95
|
+
const { runConnectBuild } = await import("./connect-build-DUiJQGfx.mjs");
|
|
455
96
|
await runConnectBuild(args);
|
|
456
97
|
process.exit(0);
|
|
457
98
|
}
|
|
@@ -464,7 +105,7 @@ NOTE: You must run \`ph connect build\` first
|
|
|
464
105
|
args: connectPreviewArgs,
|
|
465
106
|
handler: async (args) => {
|
|
466
107
|
if (args.debug) console.log(args);
|
|
467
|
-
const { runConnectPreview } = await import("./connect-preview-
|
|
108
|
+
const { runConnectPreview } = await import("./connect-preview-hSphy1QP.mjs");
|
|
468
109
|
await runConnectPreview(args);
|
|
469
110
|
}
|
|
470
111
|
})
|
|
@@ -477,7 +118,7 @@ const generateAllCmd = command({
|
|
|
477
118
|
description: "Re-generate all modules in the current project",
|
|
478
119
|
args: {},
|
|
479
120
|
handler: async () => {
|
|
480
|
-
const { startGenerateAll } = await import("./generate-all-
|
|
121
|
+
const { startGenerateAll } = await import("./generate-all-yTycRkd3.mjs");
|
|
481
122
|
await startGenerateAll(process.cwd());
|
|
482
123
|
process.exit(0);
|
|
483
124
|
}
|
|
@@ -521,7 +162,7 @@ const generateAppCmd = command({
|
|
|
521
162
|
...debugArgs
|
|
522
163
|
},
|
|
523
164
|
handler: async (args) => {
|
|
524
|
-
const { startGenerateApp } = await import("./generate-app-
|
|
165
|
+
const { startGenerateApp } = await import("./generate-app-hSK1SlOn.mjs");
|
|
525
166
|
await startGenerateApp(args, process.cwd());
|
|
526
167
|
process.exit(0);
|
|
527
168
|
}
|
|
@@ -553,7 +194,7 @@ const generateDocumentModelCmd = command({
|
|
|
553
194
|
...debugArgs
|
|
554
195
|
},
|
|
555
196
|
handler: async (args) => {
|
|
556
|
-
const { startGenerateDocumentModel } = await import("./generate-document-model-
|
|
197
|
+
const { startGenerateDocumentModel } = await import("./generate-document-model-ZowVACXL.mjs");
|
|
557
198
|
await startGenerateDocumentModel(args, process.cwd());
|
|
558
199
|
process.exit(0);
|
|
559
200
|
}
|
|
@@ -590,7 +231,7 @@ const generateEditorCmd = command({
|
|
|
590
231
|
...debugArgs
|
|
591
232
|
},
|
|
592
233
|
handler: async (args) => {
|
|
593
|
-
const { startGenerateEditor } = await import("./generate-editor-
|
|
234
|
+
const { startGenerateEditor } = await import("./generate-editor-C53z-03Q.mjs");
|
|
594
235
|
await startGenerateEditor(args, process.cwd());
|
|
595
236
|
process.exit(0);
|
|
596
237
|
}
|
|
@@ -674,7 +315,7 @@ const generateProcessorCmd = command({
|
|
|
674
315
|
...debugArgs
|
|
675
316
|
},
|
|
676
317
|
handler: async (args) => {
|
|
677
|
-
const { startGenerateProcessor } = await import("./generate-processor-
|
|
318
|
+
const { startGenerateProcessor } = await import("./generate-processor-BS4F98d6.mjs");
|
|
678
319
|
await startGenerateProcessor(args, process.cwd());
|
|
679
320
|
process.exit(0);
|
|
680
321
|
}
|
|
@@ -705,7 +346,7 @@ const generateSubgraphCmd = command({
|
|
|
705
346
|
...debugArgs
|
|
706
347
|
},
|
|
707
348
|
handler: async (args) => {
|
|
708
|
-
const { startGenerateSubgraph } = await import("./generate-subgraph-
|
|
349
|
+
const { startGenerateSubgraph } = await import("./generate-subgraph-D1cYT9GQ.mjs");
|
|
709
350
|
await startGenerateSubgraph(args, process.cwd());
|
|
710
351
|
process.exit(0);
|
|
711
352
|
}
|
|
@@ -733,7 +374,7 @@ const init = command({
|
|
|
733
374
|
args: initArgs,
|
|
734
375
|
handler: async (args) => {
|
|
735
376
|
if (args.debug) console.log({ args });
|
|
736
|
-
const { startInit } = await import("./init-
|
|
377
|
+
const { startInit } = await import("./init-BgEVXxOR.mjs");
|
|
737
378
|
await startInit(args);
|
|
738
379
|
process.exit(0);
|
|
739
380
|
}
|
|
@@ -756,7 +397,7 @@ This command:
|
|
|
756
397
|
args: inspectArgs,
|
|
757
398
|
handler: async (args) => {
|
|
758
399
|
if (args.debug) console.log(args);
|
|
759
|
-
const { startInspect } = await import("./inspect-
|
|
400
|
+
const { startInspect } = await import("./inspect-D7H8gCuH.mjs");
|
|
760
401
|
startInspect(args);
|
|
761
402
|
process.exit(0);
|
|
762
403
|
}
|
|
@@ -852,7 +493,7 @@ const migrate$1 = command({
|
|
|
852
493
|
description: "Run migrations",
|
|
853
494
|
handler: async (args) => {
|
|
854
495
|
if (args.debug) console.log(args);
|
|
855
|
-
const { startMigrate } = await import("./migrate-
|
|
496
|
+
const { startMigrate } = await import("./migrate-CSaC4bDh.mjs");
|
|
856
497
|
await startMigrate(args);
|
|
857
498
|
process.exit(0);
|
|
858
499
|
}
|
|
@@ -975,14 +616,14 @@ This command:
|
|
|
975
616
|
const { basePath, dbPath, migrate, migrateStatus } = args;
|
|
976
617
|
if (basePath) process.env.BASE_PATH = basePath;
|
|
977
618
|
if (migrate || migrateStatus) {
|
|
978
|
-
const { runSwitchboardMigrations } = await import("./switchboard-migrate-
|
|
619
|
+
const { runSwitchboardMigrations } = await import("./switchboard-migrate-BiQJfIrc.mjs");
|
|
979
620
|
await runSwitchboardMigrations({
|
|
980
621
|
dbPath,
|
|
981
622
|
statusOnly: migrateStatus
|
|
982
623
|
});
|
|
983
624
|
process.exit(0);
|
|
984
625
|
}
|
|
985
|
-
const { startSwitchboard } = await import("./switchboard-
|
|
626
|
+
const { startSwitchboard } = await import("./switchboard-DUlj8v2F.mjs");
|
|
986
627
|
const { defaultDriveUrl, renown } = await startSwitchboard(args);
|
|
987
628
|
console.log(" ➜ Switchboard:", defaultDriveUrl);
|
|
988
629
|
if (renown) console.log(" ➜ Identity:", renown.did);
|
|
@@ -1155,7 +796,7 @@ This command:
|
|
|
1155
796
|
args: vetraArgs,
|
|
1156
797
|
handler: async (args) => {
|
|
1157
798
|
if (args.debug) console.log(args);
|
|
1158
|
-
const { startVetra } = await import("./vetra-
|
|
799
|
+
const { startVetra } = await import("./vetra-1k4IHQEV.mjs");
|
|
1159
800
|
await startVetra(args);
|
|
1160
801
|
}
|
|
1161
802
|
}),
|