@powerhousedao/ph-cli 6.0.2-staging.1 → 6.0.2-staging.3
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-B-oPplBd.mjs +15 -0
- package/dist/assign-env-vars-B-oPplBd.mjs.map +1 -0
- package/dist/auth-mwX4ugZt.mjs +15 -0
- package/dist/auth-mwX4ugZt.mjs.map +1 -0
- package/dist/build-Fq1pNRsl.mjs +33 -0
- package/dist/build-Fq1pNRsl.mjs.map +1 -0
- package/dist/cli-CYgcGGKv.mjs +140 -0
- package/dist/cli-CYgcGGKv.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +860 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/connect-build-DUiJQGfx.mjs +35 -0
- package/dist/connect-build-DUiJQGfx.mjs.map +1 -0
- package/dist/connect-preview-hSphy1QP.mjs +27 -0
- package/dist/connect-preview-hSphy1QP.mjs.map +1 -0
- package/dist/connect-studio-CFH0kGW1.mjs +28 -0
- package/dist/connect-studio-CFH0kGW1.mjs.map +1 -0
- package/dist/connect-studio-CV-T5IfA.mjs +3 -0
- package/dist/generate-all-yTycRkd3.mjs +10 -0
- package/dist/generate-all-yTycRkd3.mjs.map +1 -0
- package/dist/generate-app-hSK1SlOn.mjs +31 -0
- package/dist/generate-app-hSK1SlOn.mjs.map +1 -0
- package/dist/generate-document-model-ZowVACXL.mjs +17 -0
- package/dist/generate-document-model-ZowVACXL.mjs.map +1 -0
- package/dist/generate-editor-C53z-03Q.mjs +31 -0
- package/dist/generate-editor-C53z-03Q.mjs.map +1 -0
- package/dist/generate-processor-BS4F98d6.mjs +22 -0
- package/dist/generate-processor-BS4F98d6.mjs.map +1 -0
- package/dist/generate-subgraph-D1cYT9GQ.mjs +20 -0
- package/dist/generate-subgraph-D1cYT9GQ.mjs.map +1 -0
- package/dist/init-BgEVXxOR.mjs +124 -0
- package/dist/init-BgEVXxOR.mjs.map +1 -0
- package/dist/inspect-DRvimHBb.mjs +45 -0
- package/dist/inspect-DRvimHBb.mjs.map +1 -0
- package/dist/logout-BpJEO2Ij.mjs +230 -0
- package/dist/logout-BpJEO2Ij.mjs.map +1 -0
- package/dist/migrate-CSaC4bDh.mjs +11 -0
- package/dist/migrate-CSaC4bDh.mjs.map +1 -0
- package/dist/scripts/generate-commands-docs.ts +14 -0
- package/dist/switchboard-Bl2llp5U.mjs +72 -0
- package/dist/switchboard-Bl2llp5U.mjs.map +1 -0
- package/dist/switchboard-DUlj8v2F.mjs +2 -0
- package/dist/switchboard-migrate-BiQJfIrc.mjs +50 -0
- package/dist/switchboard-migrate-BiQJfIrc.mjs.map +1 -0
- package/dist/utils-C6_gv4nB.mjs +162 -0
- package/dist/utils-C6_gv4nB.mjs.map +1 -0
- package/dist/vetra-D2zbrNY1.mjs +420 -0
- package/dist/vetra-D2zbrNY1.mjs.map +1 -0
- package/package.json +35 -26
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/scripts/generate-commands-docs.d.ts +0 -2
- package/dist/scripts/generate-commands-docs.d.ts.map +0 -1
- package/dist/src/cli.d.ts +0 -3
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -395510
- package/dist/src/commands/access-token.d.ts +0 -14
- package/dist/src/commands/access-token.d.ts.map +0 -1
- package/dist/src/commands/connect.d.ts +0 -249
- package/dist/src/commands/connect.d.ts.map +0 -1
- package/dist/src/commands/generate.d.ts +0 -62
- package/dist/src/commands/generate.d.ts.map +0 -1
- package/dist/src/commands/index.d.ts +0 -13
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/commands/inspect.d.ts +0 -12
- package/dist/src/commands/inspect.d.ts.map +0 -1
- package/dist/src/commands/install.d.ts +0 -22
- package/dist/src/commands/install.d.ts.map +0 -1
- package/dist/src/commands/list.d.ts +0 -10
- package/dist/src/commands/list.d.ts.map +0 -1
- package/dist/src/commands/login.d.ts +0 -24
- package/dist/src/commands/login.d.ts.map +0 -1
- package/dist/src/commands/logout.d.ts +0 -6
- package/dist/src/commands/logout.d.ts.map +0 -1
- package/dist/src/commands/migrate.d.ts +0 -12
- package/dist/src/commands/migrate.d.ts.map +0 -1
- package/dist/src/commands/ph-cli-commands.d.ts +0 -419
- package/dist/src/commands/ph-cli-commands.d.ts.map +0 -1
- package/dist/src/commands/ph-cli-help.d.ts +0 -400
- package/dist/src/commands/ph-cli-help.d.ts.map +0 -1
- package/dist/src/commands/ph-cli.d.ts +0 -506
- package/dist/src/commands/ph-cli.d.ts.map +0 -1
- package/dist/src/commands/service.d.ts +0 -12
- package/dist/src/commands/service.d.ts.map +0 -1
- package/dist/src/commands/switchboard.d.ts +0 -46
- package/dist/src/commands/switchboard.d.ts.map +0 -1
- package/dist/src/commands/uninstall.d.ts +0 -22
- package/dist/src/commands/uninstall.d.ts.map +0 -1
- package/dist/src/commands/vetra.d.ts +0 -64
- package/dist/src/commands/vetra.d.ts.map +0 -1
- package/dist/src/get-version.d.ts +0 -2
- package/dist/src/get-version.d.ts.map +0 -1
- package/dist/src/help.d.ts +0 -65
- package/dist/src/help.d.ts.map +0 -1
- package/dist/src/services/auth.d.ts +0 -21
- package/dist/src/services/auth.d.ts.map +0 -1
- package/dist/src/services/connect-build.d.ts +0 -3
- package/dist/src/services/connect-build.d.ts.map +0 -1
- package/dist/src/services/connect-preview.d.ts +0 -3
- package/dist/src/services/connect-preview.d.ts.map +0 -1
- package/dist/src/services/connect-studio.d.ts +0 -4
- package/dist/src/services/connect-studio.d.ts.map +0 -1
- package/dist/src/services/generate.d.ts +0 -3
- package/dist/src/services/generate.d.ts.map +0 -1
- package/dist/src/services/inspect.d.ts +0 -3
- package/dist/src/services/inspect.d.ts.map +0 -1
- package/dist/src/services/migrate.d.ts +0 -3
- package/dist/src/services/migrate.d.ts.map +0 -1
- package/dist/src/services/switchboard-migrate.d.ts +0 -7
- package/dist/src/services/switchboard-migrate.d.ts.map +0 -1
- package/dist/src/services/switchboard.d.ts +0 -23
- package/dist/src/services/switchboard.d.ts.map +0 -1
- package/dist/src/services/vetra.d.ts +0 -3
- package/dist/src/services/vetra.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -28
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/utils/assign-env-vars.d.ts +0 -3
- package/dist/src/utils/assign-env-vars.d.ts.map +0 -1
- package/dist/src/utils/configure-vetra-github-url.d.ts +0 -12
- package/dist/src/utils/configure-vetra-github-url.d.ts.map +0 -1
- package/dist/src/utils/constants.d.ts +0 -2
- package/dist/src/utils/constants.d.ts.map +0 -1
- package/dist/src/utils/resolve-connect-dirs.d.ts +0 -5
- package/dist/src/utils/resolve-connect-dirs.d.ts.map +0 -1
- package/dist/src/utils.d.ts +0 -112
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { setConnectEnv } from "@powerhousedao/shared/connect";
|
|
2
|
+
//#region src/utils/assign-env-vars.ts
|
|
3
|
+
function assignEnvVars(args) {
|
|
4
|
+
const { connectBasePath, defaultDrivesUrl, drivesPreserveStrategy, disableLocalPackages } = args;
|
|
5
|
+
setConnectEnv({
|
|
6
|
+
PH_CONNECT_BASE_PATH: connectBasePath,
|
|
7
|
+
PH_CONNECT_DEFAULT_DRIVES_URL: defaultDrivesUrl,
|
|
8
|
+
PH_CONNECT_DRIVES_PRESERVE_STRATEGY: drivesPreserveStrategy,
|
|
9
|
+
PH_DISABLE_LOCAL_PACKAGE: disableLocalPackages
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { assignEnvVars as t };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=assign-env-vars-B-oPplBd.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assign-env-vars-B-oPplBd.mjs","names":[],"sources":["../src/utils/assign-env-vars.ts"],"sourcesContent":["import type {\n ConnectBuildArgs,\n ConnectPreviewArgs,\n ConnectStudioArgs,\n} from \"../types.js\";\nimport { setConnectEnv } from \"@powerhousedao/shared/connect\";\n\nexport function assignEnvVars(\n args: ConnectBuildArgs | ConnectPreviewArgs | ConnectStudioArgs,\n) {\n const {\n connectBasePath,\n defaultDrivesUrl,\n drivesPreserveStrategy,\n disableLocalPackages,\n } = args;\n\n setConnectEnv({\n PH_CONNECT_BASE_PATH: connectBasePath,\n PH_CONNECT_DEFAULT_DRIVES_URL: defaultDrivesUrl,\n PH_CONNECT_DRIVES_PRESERVE_STRATEGY: drivesPreserveStrategy,\n PH_DISABLE_LOCAL_PACKAGE: disableLocalPackages,\n });\n}\n"],"mappings":";;AAOA,SAAgB,cACd,MACA;CACA,MAAM,EACJ,iBACA,kBACA,wBACA,yBACE;AAEJ,eAAc;EACZ,sBAAsB;EACtB,+BAA+B;EAC/B,qCAAqC;EACrC,0BAA0B;EAC3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RenownBuilder } from "@renown/sdk/node";
|
|
2
|
+
//#region src/services/auth.ts
|
|
3
|
+
let renownInstance = null;
|
|
4
|
+
/**
|
|
5
|
+
* Get or create the Renown instance
|
|
6
|
+
* Uses PH_RENOWN_PRIVATE_KEY env var if set, otherwise generates/loads from file
|
|
7
|
+
*/
|
|
8
|
+
async function getRenown(baseUrl) {
|
|
9
|
+
if (!renownInstance) renownInstance = await new RenownBuilder("ph-cli", { baseUrl }).build();
|
|
10
|
+
return renownInstance;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getRenown };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=auth-mwX4ugZt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-mwX4ugZt.mjs","names":[],"sources":["../src/services/auth.ts"],"sourcesContent":["import { RenownBuilder, type IRenown } from \"@renown/sdk/node\";\n\n// Singleton instance of Renown\nlet renownInstance: IRenown | null = null;\n\n/**\n * Get or create the Renown instance\n * Uses PH_RENOWN_PRIVATE_KEY env var if set, otherwise generates/loads from file\n */\nexport async function getRenown(baseUrl?: string): Promise<IRenown> {\n if (!renownInstance) {\n renownInstance = await new RenownBuilder(\"ph-cli\", { baseUrl }).build();\n }\n return renownInstance;\n}\n"],"mappings":";;AAGA,IAAI,iBAAiC;;;;;AAMrC,eAAsB,UAAU,SAAoC;AAClE,KAAI,CAAC,eACH,kBAAiB,MAAM,IAAI,cAAc,UAAU,EAAE,SAAS,CAAC,CAAC,OAAO;AAEzE,QAAO"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { browserBuildConfig, nodeBuildConfig } from "@powerhousedao/shared/clis";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { detect, resolveCommand } from "package-manager-detector";
|
|
5
|
+
import { build } from "tsdown";
|
|
6
|
+
//#region src/services/build.ts
|
|
7
|
+
async function runBuild(args) {
|
|
8
|
+
const { outDir } = args;
|
|
9
|
+
await build({
|
|
10
|
+
...browserBuildConfig,
|
|
11
|
+
outDir: join(outDir, "browser")
|
|
12
|
+
});
|
|
13
|
+
await build({
|
|
14
|
+
...nodeBuildConfig,
|
|
15
|
+
outDir: join(outDir, "node")
|
|
16
|
+
});
|
|
17
|
+
const executeLocalCommand = resolveCommand((await detect())?.agent ?? "npm", "execute-local", [
|
|
18
|
+
"tailwindcss",
|
|
19
|
+
"-i",
|
|
20
|
+
"./style.css",
|
|
21
|
+
"-o",
|
|
22
|
+
"./dist/style.css"
|
|
23
|
+
]);
|
|
24
|
+
if (executeLocalCommand === null) {
|
|
25
|
+
console.error("You need to have tailwindcss installed to use the `build` command.");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
execSync(`${executeLocalCommand.command} ${executeLocalCommand.args.join(" ")}`);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { runBuild as t };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=build-Fq1pNRsl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-Fq1pNRsl.mjs","names":["tsdownBuild"],"sources":["../src/services/build.ts"],"sourcesContent":["import {\n browserBuildConfig,\n nodeBuildConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"node:child_process\";\nimport { join } from \"node:path\";\nimport { detect, resolveCommand } from \"package-manager-detector\";\nimport { build as tsdownBuild } from \"tsdown\";\nimport type { BuildArgs } from \"../types.js\";\n\nexport async function runBuild(args: BuildArgs) {\n const { outDir } = args;\n\n await tsdownBuild({\n ...browserBuildConfig,\n outDir: join(outDir, \"browser\"),\n });\n\n await tsdownBuild({\n ...nodeBuildConfig,\n outDir: join(outDir, \"node\"),\n });\n\n const detectResult = await detect();\n const executeLocalCommand = resolveCommand(\n detectResult?.agent ?? \"npm\",\n \"execute-local\",\n [\"tailwindcss\", \"-i\", \"./style.css\", \"-o\", \"./dist/style.css\"],\n );\n if (executeLocalCommand === null) {\n console.error(\n \"You need to have tailwindcss installed to use the `build` command.\",\n );\n process.exit(1);\n }\n execSync(\n `${executeLocalCommand.command} ${executeLocalCommand.args.join(\" \")}`,\n );\n}\n"],"mappings":";;;;;;AAUA,eAAsB,SAAS,MAAiB;CAC9C,MAAM,EAAE,WAAW;AAEnB,OAAMA,MAAY;EAChB,GAAG;EACH,QAAQ,KAAK,QAAQ,UAAU;EAChC,CAAC;AAEF,OAAMA,MAAY;EAChB,GAAG;EACH,QAAQ,KAAK,QAAQ,OAAO;EAC7B,CAAC;CAGF,MAAM,sBAAsB,gBADP,MAAM,QAAQ,GAEnB,SAAS,OACvB,iBACA;EAAC;EAAe;EAAM;EAAe;EAAM;EAAmB,CAC/D;AACD,KAAI,wBAAwB,MAAM;AAChC,UAAQ,MACN,qEACD;AACD,UAAQ,KAAK,EAAE;;AAEjB,UACE,GAAG,oBAAoB,QAAQ,GAAG,oBAAoB,KAAK,KAAK,IAAI,GACrE"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { a as getVersion, i as accessToken, r as list, t as logout } from "./logout-BpJEO2Ij.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { defineCli, defineCommand } from "@powerhousedao/ph-clint";
|
|
4
|
+
//#region src/code/adapter.ts
|
|
5
|
+
var ExitSignal = class extends Error {
|
|
6
|
+
constructor(code) {
|
|
7
|
+
super(`process.exit(${code}) intercepted`);
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
function adaptCmdTs(opts) {
|
|
12
|
+
return defineCommand({
|
|
13
|
+
id: opts.id,
|
|
14
|
+
description: opts.description.trim(),
|
|
15
|
+
inputSchema: opts.inputSchema,
|
|
16
|
+
execute: async (input, ctx) => {
|
|
17
|
+
const buf = [];
|
|
18
|
+
const origLog = console.log;
|
|
19
|
+
const origErr = console.error;
|
|
20
|
+
const origExit = process.exit;
|
|
21
|
+
const origNonInteractive = process.env.PH_NONINTERACTIVE;
|
|
22
|
+
const capture = (args) => {
|
|
23
|
+
const line = args.map((a) => typeof a === "string" ? a : safeStringify(a)).join(" ");
|
|
24
|
+
buf.push(line);
|
|
25
|
+
ctx.stdout(line + "\n");
|
|
26
|
+
};
|
|
27
|
+
console.log = (...a) => capture(a);
|
|
28
|
+
console.error = (...a) => capture(a);
|
|
29
|
+
process.exit = (code = 0) => {
|
|
30
|
+
throw new ExitSignal(code);
|
|
31
|
+
};
|
|
32
|
+
process.env.PH_NONINTERACTIVE = "1";
|
|
33
|
+
try {
|
|
34
|
+
await opts.invoke(input);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
if (e instanceof ExitSignal) {
|
|
37
|
+
if (e.code !== 0) buf.push(`(command exited with code ${e.code})`);
|
|
38
|
+
} else throw e;
|
|
39
|
+
} finally {
|
|
40
|
+
console.log = origLog;
|
|
41
|
+
console.error = origErr;
|
|
42
|
+
process.exit = origExit;
|
|
43
|
+
if (origNonInteractive === void 0) delete process.env.PH_NONINTERACTIVE;
|
|
44
|
+
else process.env.PH_NONINTERACTIVE = origNonInteractive;
|
|
45
|
+
}
|
|
46
|
+
return buf.join("\n");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function safeStringify(value) {
|
|
51
|
+
try {
|
|
52
|
+
return JSON.stringify(value);
|
|
53
|
+
} catch {
|
|
54
|
+
return String(value);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/code/commands.ts
|
|
59
|
+
const debugSchema = { debug: z.boolean().optional() };
|
|
60
|
+
const phCliAdaptedCommands = [
|
|
61
|
+
adaptCmdTs({
|
|
62
|
+
id: "list",
|
|
63
|
+
description: "List installed Powerhouse packages from powerhouse.config.json.",
|
|
64
|
+
inputSchema: z.object({ ...debugSchema }),
|
|
65
|
+
invoke: (input) => list.handler(input)
|
|
66
|
+
}),
|
|
67
|
+
adaptCmdTs({
|
|
68
|
+
id: "logout",
|
|
69
|
+
description: "Remove the local Renown session created with `ph login`.",
|
|
70
|
+
inputSchema: z.object({}),
|
|
71
|
+
invoke: () => logout.handler({})
|
|
72
|
+
}),
|
|
73
|
+
adaptCmdTs({
|
|
74
|
+
id: "access-token",
|
|
75
|
+
description: "Generate a bearer JWT for Powerhouse APIs using the local DID. Requires `ph login` first.",
|
|
76
|
+
inputSchema: z.object({
|
|
77
|
+
expiry: z.string().optional().describe("Token expiry, e.g. \"7d\", \"24h\", \"3600s\"."),
|
|
78
|
+
audience: z.string().optional().describe("Target audience URL."),
|
|
79
|
+
...debugSchema
|
|
80
|
+
}),
|
|
81
|
+
invoke: (input) => accessToken.handler(input)
|
|
82
|
+
})
|
|
83
|
+
];
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/code/agent.ts
|
|
86
|
+
const SYSTEM_INSTRUCTIONS = `You are ph code — a Powerhouse-flavored coding agent that runs inside the \`ph\` CLI.
|
|
87
|
+
|
|
88
|
+
You have direct access to the user's Powerhouse project via tools that wrap real \`ph\` commands.
|
|
89
|
+
Use the tools to answer questions and take action; never invent output.
|
|
90
|
+
|
|
91
|
+
Style:
|
|
92
|
+
- Be concise. Show command results, don't paraphrase them.
|
|
93
|
+
- When the user asks something that maps to a tool, call the tool first and then summarize.
|
|
94
|
+
- When in doubt about an action's blast radius, ask before running it.`;
|
|
95
|
+
async function createNimbyStyleAgent(ctx) {
|
|
96
|
+
const { createMastraHelpers } = await import("@powerhousedao/ph-clint/mastra");
|
|
97
|
+
const { Agent } = await import("@mastra/core/agent");
|
|
98
|
+
const m = createMastraHelpers(ctx);
|
|
99
|
+
const tools = await m.getTools();
|
|
100
|
+
const memory = await m.createMemory();
|
|
101
|
+
const cfg = ctx.config;
|
|
102
|
+
const modelId = cfg.model ?? "anthropic/claude-sonnet-4-5";
|
|
103
|
+
if (cfg.modelUrl && !process.env.OPENAI_API_KEY) process.env.OPENAI_API_KEY = "local";
|
|
104
|
+
const agent = new Agent({
|
|
105
|
+
id: "ph-code",
|
|
106
|
+
name: "ph code",
|
|
107
|
+
instructions: SYSTEM_INSTRUCTIONS,
|
|
108
|
+
model: cfg.modelUrl ? {
|
|
109
|
+
id: modelId,
|
|
110
|
+
url: cfg.modelUrl
|
|
111
|
+
} : modelId,
|
|
112
|
+
tools,
|
|
113
|
+
memory
|
|
114
|
+
});
|
|
115
|
+
return m.wrapAgent(agent, { maxSteps: 40 });
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/code/cli.ts
|
|
119
|
+
const configSchema = z.object({
|
|
120
|
+
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."),
|
|
121
|
+
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\".")
|
|
122
|
+
});
|
|
123
|
+
const secretsSchema = z.object({ anthropicApiKey: z.string().optional().describe("Anthropic API key. Reads from ANTHROPIC_API_KEY by default.") });
|
|
124
|
+
function buildPhCodeCli() {
|
|
125
|
+
const cli = defineCli({
|
|
126
|
+
name: "ph-code",
|
|
127
|
+
version: getVersion(),
|
|
128
|
+
description: "Powerhouse coding agent. Runs your installed Powerhouse tools through a Mastra-driven REPL.",
|
|
129
|
+
configSchema,
|
|
130
|
+
secretsSchema,
|
|
131
|
+
commands: phCliAdaptedCommands,
|
|
132
|
+
interactive: { welcome: "ph code — type a prompt or /help. Ctrl-D to exit." }
|
|
133
|
+
});
|
|
134
|
+
cli.configureAgent(createNimbyStyleAgent);
|
|
135
|
+
return cli;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
export { buildPhCodeCli };
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=cli-CYgcGGKv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-CYgcGGKv.mjs","names":["listCmd","logoutCmd","accessTokenCmd"],"sources":["../src/code/adapter.ts","../src/code/commands.ts","../src/code/agent.ts","../src/code/cli.ts"],"sourcesContent":["import type { z } from \"zod\";\nimport { defineCommand } from \"@powerhousedao/ph-clint\";\nimport type { Command } from \"@powerhousedao/ph-clint\";\n\nclass ExitSignal extends Error {\n constructor(public code: number) {\n super(`process.exit(${code}) intercepted`);\n }\n}\n\nexport interface AdaptOptions<TSchema extends z.ZodType> {\n id: string;\n description: string;\n inputSchema: TSchema;\n invoke: (input: z.output<TSchema>) => Promise<void>;\n}\n\nexport function adaptCmdTs<TSchema extends z.ZodType>(\n opts: AdaptOptions<TSchema>,\n): Command<TSchema> {\n return defineCommand({\n id: opts.id,\n description: opts.description.trim(),\n inputSchema: opts.inputSchema,\n execute: async (input, ctx) => {\n const buf: string[] = [];\n const origLog = console.log;\n const origErr = console.error;\n // eslint-disable-next-line @typescript-eslint/unbound-method -- intercepting process.exit on purpose\n const origExit = process.exit;\n const origNonInteractive = process.env.PH_NONINTERACTIVE;\n\n const capture = (args: unknown[]) => {\n const line = args\n .map((a) => (typeof a === \"string\" ? a : safeStringify(a)))\n .join(\" \");\n buf.push(line);\n ctx.stdout(line + \"\\n\");\n };\n\n console.log = (...a: unknown[]) => capture(a);\n console.error = (...a: unknown[]) => capture(a);\n // Intercept process.exit so the agent REPL doesn't die.\n (process as unknown as { exit: (code?: number) => never }).exit = (\n code = 0,\n ) => {\n throw new ExitSignal(code);\n };\n process.env.PH_NONINTERACTIVE = \"1\";\n\n try {\n await opts.invoke(input);\n } catch (e) {\n if (e instanceof ExitSignal) {\n if (e.code !== 0) {\n buf.push(`(command exited with code ${e.code})`);\n }\n } else {\n throw e;\n }\n } finally {\n console.log = origLog;\n console.error = origErr;\n (process as unknown as { exit: typeof origExit }).exit = origExit;\n if (origNonInteractive === undefined) {\n delete process.env.PH_NONINTERACTIVE;\n } else {\n process.env.PH_NONINTERACTIVE = origNonInteractive;\n }\n }\n\n return buf.join(\"\\n\");\n },\n });\n}\n\nfunction safeStringify(value: unknown): string {\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n","import { z } from \"zod\";\nimport { adaptCmdTs } from \"./adapter.js\";\nimport { list as listCmd } from \"../commands/list.js\";\nimport { logout as logoutCmd } from \"../commands/logout.js\";\nimport { accessToken as accessTokenCmd } from \"../commands/access-token.js\";\n\nconst debugSchema = { debug: z.boolean().optional() };\n\nexport const listAdapted = adaptCmdTs({\n id: \"list\",\n description:\n \"List installed Powerhouse packages from powerhouse.config.json.\",\n inputSchema: z.object({ ...debugSchema }),\n invoke: (input) => listCmd.handler(input as never),\n});\n\nexport const logoutAdapted = adaptCmdTs({\n id: \"logout\",\n description: \"Remove the local Renown session created with `ph login`.\",\n inputSchema: z.object({}),\n invoke: () => logoutCmd.handler({} as never),\n});\n\nexport const accessTokenAdapted = adaptCmdTs({\n id: \"access-token\",\n description:\n \"Generate a bearer JWT for Powerhouse APIs using the local DID. \" +\n \"Requires `ph login` first.\",\n inputSchema: z.object({\n expiry: z\n .string()\n .optional()\n .describe('Token expiry, e.g. \"7d\", \"24h\", \"3600s\".'),\n audience: z.string().optional().describe(\"Target audience URL.\"),\n ...debugSchema,\n }),\n invoke: (input) => accessTokenCmd.handler(input as never),\n});\n\nexport const phCliAdaptedCommands = [\n listAdapted,\n logoutAdapted,\n accessTokenAdapted,\n];\n","import type { AgentSetupContext, AgentProvider } from \"@powerhousedao/ph-clint\";\n\nconst SYSTEM_INSTRUCTIONS = `You are ph code — a Powerhouse-flavored coding agent that runs inside the \\`ph\\` CLI.\n\nYou have direct access to the user's Powerhouse project via tools that wrap real \\`ph\\` commands.\nUse the tools to answer questions and take action; never invent output.\n\nStyle:\n- Be concise. Show command results, don't paraphrase them.\n- When the user asks something that maps to a tool, call the tool first and then summarize.\n- When in doubt about an action's blast radius, ask before running it.`;\n\nexport async function createNimbyStyleAgent(\n ctx: AgentSetupContext,\n): Promise<AgentProvider> {\n const { createMastraHelpers } =\n await import(\"@powerhousedao/ph-clint/mastra\");\n const { Agent } = await import(\"@mastra/core/agent\");\n\n const m = createMastraHelpers(ctx);\n const tools = await m.getTools();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- ph-clint's Memory return type is `any`\n const memory = await m.createMemory();\n\n const cfg = ctx.config as { model?: string; modelUrl?: string };\n const modelId = cfg.model ?? \"anthropic/claude-sonnet-4-5\";\n // For local OpenAI-compatible endpoints the API key is unused but Mastra/\n // the AI-SDK still requires the env var to be set. Keep the user's value\n // if they set one, otherwise drop in a placeholder so the call goes through.\n if (cfg.modelUrl && !process.env.OPENAI_API_KEY) {\n process.env.OPENAI_API_KEY = \"local\";\n }\n // Cast through `unknown`: Mastra's MastraModelConfig types don't yet model\n // the `{ id, url }` form, but the runtime accepts it (see rupert-mastra).\n const model = (cfg.modelUrl\n ? { id: modelId, url: cfg.modelUrl }\n : modelId) as unknown as string;\n\n const agent = new Agent({\n id: \"ph-code\",\n name: \"ph code\",\n instructions: SYSTEM_INSTRUCTIONS,\n model,\n tools,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- forwarded from ph-clint's Memory helper\n memory,\n });\n\n return m.wrapAgent(agent, { maxSteps: 40 });\n}\n","import { z } from \"zod\";\nimport { defineCli } from \"@powerhousedao/ph-clint\";\nimport { phCliAdaptedCommands } from \"./commands.js\";\nimport { createNimbyStyleAgent } from \"./agent.js\";\nimport { getVersion } from \"../get-version.js\";\n\nconst configSchema = z.object({\n model: z\n .string()\n .default(\"anthropic/claude-sonnet-4-5\")\n .describe(\n 'Mastra model id, e.g. \"anthropic/claude-sonnet-4-5\" or ' +\n '\"openai/Qwen3.6-27B-Q4_K_M.gguf\" for a local server.',\n ),\n modelUrl: z\n .string()\n .optional()\n .describe(\n \"Optional base URL for the model provider (OpenAI-compatible). \" +\n 'Set this to point at a local LLM, e.g. \"http://192.168.178.191:8100/v1\".',\n ),\n});\n\nconst secretsSchema = z.object({\n anthropicApiKey: z\n .string()\n .optional()\n .describe(\"Anthropic API key. Reads from ANTHROPIC_API_KEY by default.\"),\n});\n\nexport function buildPhCodeCli() {\n const cli = defineCli({\n name: \"ph-code\",\n version: getVersion(),\n description:\n \"Powerhouse coding agent. Runs your installed Powerhouse tools through a Mastra-driven REPL.\",\n configSchema,\n secretsSchema,\n commands: phCliAdaptedCommands,\n interactive: {\n welcome: \"ph code — type a prompt or /help. Ctrl-D to exit.\",\n },\n });\n cli.configureAgent(createNimbyStyleAgent);\n return cli;\n}\n"],"mappings":";;;;AAIA,IAAM,aAAN,cAAyB,MAAM;CAC7B,YAAY,MAAqB;AAC/B,QAAM,gBAAgB,KAAK,eAAe;AADzB,OAAA,OAAA;;;AAYrB,SAAgB,WACd,MACkB;AAClB,QAAO,cAAc;EACnB,IAAI,KAAK;EACT,aAAa,KAAK,YAAY,MAAM;EACpC,aAAa,KAAK;EAClB,SAAS,OAAO,OAAO,QAAQ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