@powerhousedao/ph-clint-cli 0.1.0-dev.19 → 0.1.0-dev.20
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.
|
@@ -74,21 +74,10 @@ export function buildCliTs(spec) {
|
|
|
74
74
|
lines.push('');
|
|
75
75
|
lines.push(' // @clint:begin interactive');
|
|
76
76
|
lines.push(' interactive: {');
|
|
77
|
-
|
|
78
|
-
if (phAtLeast(ph, 'Switchboard')) {
|
|
79
|
-
ctxArgs.push('config');
|
|
80
|
-
}
|
|
81
|
-
ctxArgs.push('workdir');
|
|
82
|
-
lines.push(` welcome: ({ ${ctxArgs.join(', ')} }) =>`);
|
|
77
|
+
lines.push(` welcome: ({ workdir }) =>`);
|
|
83
78
|
lines.push(' [');
|
|
84
79
|
lines.push(' `${CLI_NAME} v${CLI_VERSION}`,');
|
|
85
80
|
lines.push(' `Workdir: ${workdir}`,');
|
|
86
|
-
if (phAtLeast(ph, 'Switchboard')) {
|
|
87
|
-
lines.push(' `Switchboard: http://localhost:${config.switchboardPort}`,');
|
|
88
|
-
}
|
|
89
|
-
if (phAtLeast(ph, 'Connect')) {
|
|
90
|
-
lines.push(' `Connect: http://localhost:${config.connectPort}`,');
|
|
91
|
-
}
|
|
92
81
|
lines.push(" '',");
|
|
93
82
|
if (mastra.enabled) {
|
|
94
83
|
lines.push(" 'Type a message to talk to the agent, or /help for commands.',");
|
|
@@ -11,12 +11,20 @@ export interface PhInitOptions {
|
|
|
11
11
|
binName?: string;
|
|
12
12
|
/** Stdio passthrough (tests pass 'ignore'). */
|
|
13
13
|
stdio?: 'inherit' | 'ignore';
|
|
14
|
+
/** Explicit Powerhouse version to pin `ph init` to (tag or semver). */
|
|
15
|
+
phVersion?: string;
|
|
14
16
|
}
|
|
15
17
|
export interface PhInitResult {
|
|
16
18
|
ran: boolean;
|
|
17
19
|
exitCode?: number;
|
|
18
20
|
reason?: string;
|
|
19
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Detect the installed `ph` CLI version by parsing `ph --version` output.
|
|
24
|
+
* Returns the version string (e.g. '6.0.0-dev.194') or undefined if
|
|
25
|
+
* detection fails.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getPhVersion(binName: string): string | undefined;
|
|
20
28
|
export declare function runPhInit(options: PhInitOptions): Promise<PhInitResult>;
|
|
21
29
|
export interface PnpmInstallOptions {
|
|
22
30
|
/** Directories to run `pnpm install` in, in order. */
|
package/dist/codegen/scaffold.js
CHANGED
|
@@ -7,7 +7,26 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import fs from 'node:fs/promises';
|
|
9
9
|
import path from 'node:path';
|
|
10
|
+
import { execFileSync } from 'node:child_process';
|
|
10
11
|
import { hasCommandOnPath, runCommand } from './exec.js';
|
|
12
|
+
/**
|
|
13
|
+
* Detect the installed `ph` CLI version by parsing `ph --version` output.
|
|
14
|
+
* Returns the version string (e.g. '6.0.0-dev.194') or undefined if
|
|
15
|
+
* detection fails.
|
|
16
|
+
*/
|
|
17
|
+
export function getPhVersion(binName) {
|
|
18
|
+
try {
|
|
19
|
+
const output = execFileSync(binName, ['--version'], {
|
|
20
|
+
encoding: 'utf-8',
|
|
21
|
+
timeout: 5_000,
|
|
22
|
+
});
|
|
23
|
+
const match = output.match(/PH CMD version:\s*(\S+)/);
|
|
24
|
+
return match?.[1];
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
11
30
|
export async function runPhInit(options) {
|
|
12
31
|
const log = options.log ?? (() => { });
|
|
13
32
|
const binName = options.binName ?? 'ph';
|
|
@@ -17,16 +36,25 @@ export async function runPhInit(options) {
|
|
|
17
36
|
`Install @powerhousedao/ph-cli and re-run manually inside ${appFolder}/.`);
|
|
18
37
|
return { ran: false, reason: 'ph-not-on-path' };
|
|
19
38
|
}
|
|
39
|
+
// Pin ph init to the same version as the installed ph CLI, so the
|
|
40
|
+
// generated app uses matching Powerhouse packages.
|
|
41
|
+
const phVersion = options.phVersion ?? getPhVersion(binName);
|
|
42
|
+
const tags = ['dev', 'staging', 'latest'];
|
|
43
|
+
const versionArgs = phVersion
|
|
44
|
+
? tags.includes(phVersion)
|
|
45
|
+
? [`--${phVersion}`]
|
|
46
|
+
: ['--version', phVersion]
|
|
47
|
+
: ['--dev']; // fallback if detection fails
|
|
20
48
|
// `ph init {name}` creates a fresh directory beside the cwd. Our generator
|
|
21
49
|
// placed a `.gitkeep` + README.md placeholder there; clear it out so
|
|
22
50
|
// ph init has a blank slate to work with.
|
|
23
51
|
await fs.rm(options.appDir, { recursive: true, force: true });
|
|
24
|
-
log(`Running \`${binName} init ${appFolder}\` in ${options.targetDir} …`);
|
|
52
|
+
log(`Running \`${binName} init ${appFolder}\` (version: ${phVersion ?? 'auto'}) in ${options.targetDir} …`);
|
|
25
53
|
const result = await runCommand(binName, [
|
|
26
54
|
'init',
|
|
27
55
|
appFolder,
|
|
56
|
+
...versionArgs,
|
|
28
57
|
'--pnpm',
|
|
29
|
-
'--dev',
|
|
30
58
|
], { cwd: options.targetDir, stdio: options.stdio ?? 'inherit' });
|
|
31
59
|
if (result.exitCode !== 0) {
|
|
32
60
|
log(`\`${binName} init\` exited with code ${result.exitCode}. ` +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/ph-clint-cli",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.20",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@mastra/libsql": "^1.7.4",
|
|
31
31
|
"@mastra/memory": "^1.13.1",
|
|
32
32
|
"@powerhousedao/ph-clint": "0.1.0-dev.18",
|
|
33
|
-
"@powerhousedao/ph-clint-app": "^0.1.0-dev.
|
|
33
|
+
"@powerhousedao/ph-clint-app": "^0.1.0-dev.20",
|
|
34
34
|
"@powerhousedao/ph-clint-dev": "0.1.0-dev.18",
|
|
35
35
|
"@powerhousedao/reactor": "6.0.0-dev.170",
|
|
36
36
|
"@powerhousedao/reactor-api": "6.0.0-dev.170",
|