@powerhousedao/ph-clint-cli 0.1.0-dev.4 → 0.1.0-dev.6

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/cli.js CHANGED
@@ -7,9 +7,8 @@
7
7
  * Everything outside the markers is user-editable and preserved.
8
8
  */
9
9
  import path from 'node:path';
10
- import { fileURLToPath } from 'node:url';
11
10
  import { defineCli, buildDefaultReactor } from '@powerhousedao/ph-clint';
12
- import { CLI_NAME, CLI_VERSION } from './config.js';
11
+ import { CLI_NAME, CLI_VERSION, CLI_ROOT } from './config.js';
13
12
  import { configSchema, secretsSchema } from './framework.js';
14
13
  // @clint:begin imports
15
14
  import { documentModels } from '@powerhousedao/ph-clint-app';
@@ -22,8 +21,7 @@ import { clintProject } from './services/clint-project.js';
22
21
  import { specChangeTrigger } from './triggers/spec-change.js';
23
22
  // @clint:end imports
24
23
  // Connect (ph connect) must run inside the Reactor Package (ph-clint-app).
25
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
26
- const appDir = path.resolve(__dirname, '../../ph-clint-app');
24
+ const appDir = path.resolve(CLI_ROOT, '../ph-clint-app');
27
25
  export const cli = defineCli({
28
26
  name: CLI_NAME,
29
27
  version: CLI_VERSION,
@@ -5,8 +5,36 @@
5
5
  * `{root}/{name}-cli/package.json`. Otherwise at `{root}/package.json`.
6
6
  */
7
7
  import { getBinName, getPackageName, } from '../../spec/types.js';
8
- /** Pinned version range for peer ph-clint packages emitted into generated projects. */
9
- const PH_CLINT_VERSION = '^0.1.0';
8
+ import { CLI_VERSION } from '../../config.js';
9
+ /**
10
+ * Derive a semver range from the running ph-clint-cli version that respects
11
+ * the dev / staging / production channel boundary. This is the version range
12
+ * emitted into *scaffolded* projects' package.json for @powerhousedao/ph-clint
13
+ * and @powerhousedao/ph-clint-dev dependencies.
14
+ *
15
+ * CLI_VERSION is the version of ph-clint-cli itself (read from its own
16
+ * package.json at startup). Since all framework packages share a lockstep
17
+ * version, this is also the correct base for the dependency range.
18
+ *
19
+ * Examples:
20
+ * "0.1.0" → "^0.1.0" (production — stable only)
21
+ * "0.1.0-staging.2" → "^0.1.0-staging.0" (staging + stable)
22
+ * "0.1.0-dev.4" → "^0.1.0-dev.0" (dev + staging + stable)
23
+ *
24
+ * This works because semver orders prereleases alphabetically:
25
+ * dev.N < staging.N < release. A caret range starting at dev.0 naturally
26
+ * upgrades through staging to production.
27
+ */
28
+ function phClintRange(version) {
29
+ const match = /^(\d+\.\d+\.\d+)(?:-([a-z]+)\.\d+)?/.exec(version);
30
+ if (!match)
31
+ return `^${version}`;
32
+ const base = match[1];
33
+ const channel = match[2]; // "dev", "staging", or undefined
34
+ return channel ? `^${base}-${channel}.0` : `^${base}`;
35
+ }
36
+ /** Version range for @powerhousedao/ph-clint{,-dev} deps in scaffolded projects. */
37
+ const PH_CLINT_VERSION = phClintRange(CLI_VERSION);
10
38
  const POWERHOUSE_VERSION = '6.0.0-dev.170';
11
39
  export function buildCliPackageJson(spec) {
12
40
  const { mastra, powerhouse } = spec.features;
@@ -10,13 +10,12 @@ export function buildCliTs(spec) {
10
10
  lines.push(' */');
11
11
  if (powerhouse.enabled) {
12
12
  lines.push(`import path from 'node:path';`);
13
- lines.push(`import { fileURLToPath } from 'node:url';`);
14
13
  lines.push(`import { defineCli, buildDefaultReactor } from '@powerhousedao/ph-clint';`);
15
14
  }
16
15
  else {
17
16
  lines.push(`import { defineCli } from '@powerhousedao/ph-clint';`);
18
17
  }
19
- lines.push(`import { CLI_NAME, CLI_VERSION } from './config.js';`);
18
+ lines.push(`import { CLI_NAME, CLI_VERSION${powerhouse.enabled ? ', CLI_ROOT' : ''} } from './config.js';`);
20
19
  lines.push(`import { configSchema, secretsSchema } from './framework.js';`);
21
20
  lines.push('');
22
21
  lines.push('// @clint:begin imports');
@@ -29,8 +28,7 @@ export function buildCliTs(spec) {
29
28
  lines.push('// @clint:end imports');
30
29
  lines.push('');
31
30
  if (powerhouse.enabled) {
32
- lines.push(`const __dirname = path.dirname(fileURLToPath(import.meta.url));`);
33
- lines.push(`const appDir = path.resolve(__dirname, '../../${spec.name}-app');`);
31
+ lines.push(`const appDir = path.resolve(CLI_ROOT, '../${spec.name}-app');`);
34
32
  lines.push('');
35
33
  }
36
34
  lines.push('export const cli = defineCli({');
@@ -71,10 +69,21 @@ export function buildCliTs(spec) {
71
69
  lines.push('');
72
70
  lines.push(' // @clint:begin interactive');
73
71
  lines.push(' interactive: {');
74
- lines.push(` welcome: ({ workdir }) =>`);
72
+ const ctxArgs = [];
73
+ if (powerhouse.enabled && (powerhouse.switchboard || powerhouse.connect)) {
74
+ ctxArgs.push('config');
75
+ }
76
+ ctxArgs.push('workdir');
77
+ lines.push(` welcome: ({ ${ctxArgs.join(', ')} }) =>`);
75
78
  lines.push(' [');
76
79
  lines.push(' `${CLI_NAME} v${CLI_VERSION}`,');
77
80
  lines.push(' `Workdir: ${workdir}`,');
81
+ if (powerhouse.enabled && powerhouse.switchboard) {
82
+ lines.push(' `Switchboard: http://localhost:${config.switchboardPort}`,');
83
+ }
84
+ if (powerhouse.enabled && powerhouse.connect) {
85
+ lines.push(' `Connect: http://localhost:${config.connectPort}`,');
86
+ }
78
87
  lines.push(" '',");
79
88
  if (mastra.enabled) {
80
89
  lines.push(" 'Type a message to talk to the agent, or /help for commands.',");
@@ -1,21 +1,17 @@
1
- /**
2
- * Builds `src/config.ts` — CLI identity constants (name, version, project
3
- * root path). The Zod `configSchema` / `secretsSchema` are emitted by
4
- * `buildFrameworkTs` into `src/framework.ts` (user-owned, init-only) so users
5
- * can extend them without fighting the generator.
6
- */
7
- import { getBinName, } from '../../spec/types.js';
8
1
  export function buildConfigTs(spec) {
9
- const cliName = getBinName(spec);
2
+ const hasCustomBin = !!spec.bin;
10
3
  const lines = [];
11
- lines.push(`import path from 'node:path';`);
12
- lines.push(`import { fileURLToPath } from 'node:url';`);
4
+ lines.push(`import { readPackageInfo } from '@powerhousedao/ph-clint';`);
13
5
  lines.push('');
14
- lines.push('/** CLI name — used for config resolution, env var prefixing, and .ph/ paths. */');
15
- lines.push(`export const CLI_NAME = '${cliName}';`);
16
- lines.push(`export const CLI_VERSION = '${spec.version}';`);
6
+ lines.push('const pkg = readPackageInfo(import.meta.url);');
17
7
  lines.push('');
18
- lines.push('/** Project root — resolved from this file location. */');
19
- lines.push('export const PROJECT_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \'..\');');
8
+ lines.push('export const CLI_ROOT = pkg.root;');
9
+ if (hasCustomBin) {
10
+ lines.push(`export const CLI_NAME = '${spec.bin}';`);
11
+ }
12
+ else {
13
+ lines.push(`export const CLI_NAME = pkg.name.replace(/-cli$/, '');`);
14
+ }
15
+ lines.push('export const CLI_VERSION = pkg.version;');
20
16
  return lines.join('\n') + '\n';
21
17
  }
@@ -39,5 +39,6 @@ export interface FileBuilder {
39
39
  export declare const CLI_FILE_BUILDERS: FileBuilder[];
40
40
  export { buildCliPackageJson, buildCliTs, buildConfigTs, buildMainTs, buildTsconfigJson, buildJestConfigJs, buildEslintConfigJs, buildGitignore, buildMastraIndexTs, buildBuildSkillsScript, buildAgentBaseMd, buildAgentTs, buildFrameworkGenTs, buildFrameworkTs, };
41
41
  export { buildRootPackageJson } from './root-package-json.js';
42
+ export { buildPublishConfigTs } from './publish-config-ts.js';
42
43
  export { buildReadme } from './readme-md.js';
43
44
  export { buildAppIndexTs } from './app-index-ts.js';
@@ -56,5 +56,6 @@ export const CLI_FILE_BUILDERS = [
56
56
  ];
57
57
  export { buildCliPackageJson, buildCliTs, buildConfigTs, buildMainTs, buildTsconfigJson, buildJestConfigJs, buildEslintConfigJs, buildGitignore, buildMastraIndexTs, buildBuildSkillsScript, buildAgentBaseMd, buildAgentTs, buildFrameworkGenTs, buildFrameworkTs, };
58
58
  export { buildRootPackageJson } from './root-package-json.js';
59
+ export { buildPublishConfigTs } from './publish-config-ts.js';
59
60
  export { buildReadme } from './readme-md.js';
60
61
  export { buildAppIndexTs } from './app-index-ts.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Builds the root `publish.config.ts` for split-layout projects.
3
+ * Defines a single lockstep group containing both the app and cli packages.
4
+ */
5
+ import { type ClintProjectSpec } from '../../spec/types.js';
6
+ export declare function buildPublishConfigTs(spec: ClintProjectSpec): string;
@@ -0,0 +1,18 @@
1
+ export function buildPublishConfigTs(spec) {
2
+ const app = `${spec.name}-app`;
3
+ const cli = `${spec.name}-cli`;
4
+ return `import { definePublishConfig } from '@powerhousedao/ph-clint-dev/publish';
5
+
6
+ export default definePublishConfig({
7
+ groups: {
8
+ '${spec.name}': {
9
+ version: '${spec.version}',
10
+ packages: [
11
+ { path: '${app}', category: 'app' },
12
+ { path: '${cli}', category: 'cli' },
13
+ ],
14
+ },
15
+ },
16
+ });
17
+ `;
18
+ }
@@ -2,6 +2,9 @@
2
2
  * Builds the *root* `package.json` for split-layout projects (Powerhouse
3
3
  * enabled). A plain passthrough — deliberately no pnpm workspaces because
4
4
  * they interfere with `{name}-app`'s own `pnpm build`.
5
+ *
6
+ * Uses `pnpm --prefix <dir>` for all orchestration scripts — no cwd mutation.
7
+ * Build order: app first, then cli (cli depends on app via `file:` dep).
5
8
  */
6
9
  import { type ClintProjectSpec } from '../../spec/types.js';
7
10
  export declare function buildRootPackageJson(spec: ClintProjectSpec): string;
@@ -2,26 +2,35 @@
2
2
  * Builds the *root* `package.json` for split-layout projects (Powerhouse
3
3
  * enabled). A plain passthrough — deliberately no pnpm workspaces because
4
4
  * they interfere with `{name}-app`'s own `pnpm build`.
5
+ *
6
+ * Uses `pnpm --prefix <dir>` for all orchestration scripts — no cwd mutation.
7
+ * Build order: app first, then cli (cli depends on app via `file:` dep).
5
8
  */
6
9
  import { getPackageName, } from '../../spec/types.js';
7
10
  export function buildRootPackageJson(spec) {
8
11
  const cli = `${spec.name}-cli`;
9
12
  const app = `${spec.name}-app`;
13
+ const prefix = (dir, cmd) => `pnpm --prefix ${dir} ${cmd}`;
14
+ const both = (cmd) => `${prefix(app, cmd)} && ${prefix(cli, cmd)}`;
15
+ const scripts = {
16
+ install: both('install'),
17
+ build: both('build'),
18
+ test: both('test'),
19
+ dev: prefix(cli, 'dev'),
20
+ start: prefix(cli, 'start'),
21
+ lint: prefix(cli, 'lint'),
22
+ 'app:dev': prefix(app, 'dev'),
23
+ 'cli:dev': prefix(cli, 'dev'),
24
+ 'publish:dev': `${prefix(cli, 'exec ph-publish')} dev -c ./publish.config.ts`,
25
+ 'publish:staging': `${prefix(cli, 'exec ph-publish')} staging -c ./publish.config.ts`,
26
+ 'publish:production': `${prefix(cli, 'exec ph-publish')} production -c ./publish.config.ts`,
27
+ };
10
28
  const pkg = {
11
29
  name: getPackageName(spec),
12
30
  version: spec.version,
13
31
  private: true,
14
32
  ...(spec.description ? { description: spec.description } : {}),
15
- scripts: {
16
- install: `cd ${app} && pnpm install && cd ../${cli} && pnpm install`,
17
- build: `cd ${app} && pnpm build && cd ../${cli} && pnpm build`,
18
- dev: `cd ${cli} && pnpm dev`,
19
- start: `cd ${cli} && pnpm start`,
20
- test: `cd ${app} && pnpm test && cd ../${cli} && pnpm test`,
21
- lint: `cd ${cli} && pnpm lint`,
22
- 'app:dev': `cd ${app} && pnpm dev`,
23
- 'cli:dev': `cd ${cli} && pnpm dev`,
24
- },
33
+ scripts,
25
34
  };
26
35
  return JSON.stringify(pkg, null, 2) + '\n';
27
36
  }
@@ -35,7 +35,7 @@ import { hashContent, hashFile, readHashes, writeHashes, } from './hashes.js';
35
35
  import { hasMarkers, spliceMarkerRegions } from './markers.js';
36
36
  import { writeFileEnsuringDir, isDirEmptyEnough } from './write.js';
37
37
  import { migrateFlatToSplit } from './migrate/flat-to-split.js';
38
- import { CLI_FILE_BUILDERS, buildReadme, buildRootPackageJson, buildAppIndexTs, } from './builders/index.js';
38
+ import { CLI_FILE_BUILDERS, buildReadme, buildRootPackageJson, buildPublishConfigTs, buildAppIndexTs, } from './builders/index.js';
39
39
  /**
40
40
  * Generate / reconcile a project at `targetDir` from the given spec.
41
41
  */
@@ -106,6 +106,12 @@ function planFiles(spec, targetDir) {
106
106
  absolutePath: rootPkg,
107
107
  content: buildRootPackageJson(spec),
108
108
  });
109
+ const publishConfig = path.join(targetDir, 'publish.config.ts');
110
+ planned.push({
111
+ relativePath: 'publish.config.ts',
112
+ absolutePath: publishConfig,
113
+ content: buildPublishConfigTs(spec),
114
+ });
109
115
  const appGitkeep = path.join(appDir, '.gitkeep');
110
116
  planned.push({
111
117
  relativePath: path.relative(targetDir, appGitkeep),
package/dist/config.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /** CLI name — used for config resolution, env var prefixing, and .ph/ paths. */
2
- export declare const CLI_NAME = "ph-clint";
3
- export declare const CLI_VERSION = "0.0.0";
4
- /** Project root — resolved from this file's location. */
5
- export declare const PROJECT_ROOT: string;
1
+ export declare const CLI_ROOT: string;
2
+ export declare const CLI_NAME: string;
3
+ export declare const CLI_VERSION: string;
package/dist/config.js CHANGED
@@ -1,7 +1,5 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- /** CLI name — used for config resolution, env var prefixing, and .ph/ paths. */
4
- export const CLI_NAME = 'ph-clint';
5
- export const CLI_VERSION = '0.0.0';
6
- /** Project root — resolved from this file's location. */
7
- export const PROJECT_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
1
+ import { readPackageInfo } from '@powerhousedao/ph-clint';
2
+ const pkg = readPackageInfo(import.meta.url);
3
+ export const CLI_ROOT = pkg.root;
4
+ export const CLI_NAME = pkg.name.replace(/-cli$/, '');
5
+ export const CLI_VERSION = pkg.version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-clint-cli",
3
- "version": "0.1.0-dev.4",
3
+ "version": "0.1.0-dev.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,8 +25,8 @@
25
25
  "mastra:start": "mastra start"
26
26
  },
27
27
  "dependencies": {
28
- "@powerhousedao/ph-clint": "^0.1.0-dev.4",
29
- "@powerhousedao/ph-clint-app": "^0.1.0-dev.4",
28
+ "@powerhousedao/ph-clint": "^0.1.0-dev.6",
29
+ "@powerhousedao/ph-clint-app": "^0.1.0-dev.6",
30
30
  "@mastra/core": "^1.22.0",
31
31
  "@mastra/libsql": "^1.7.4",
32
32
  "@mastra/memory": "^1.13.1",
@@ -48,7 +48,7 @@
48
48
  "@jest/globals": "^30.2.0",
49
49
  "@types/node": "^25.5.2",
50
50
  "jest": "^30.2.0",
51
- "@powerhousedao/ph-clint-dev": "^0.1.0-dev.4",
51
+ "@powerhousedao/ph-clint-dev": "^0.1.0-dev.6",
52
52
  "ts-jest": "^29.4.6",
53
53
  "tsx": "^4.19.0",
54
54
  "typescript": "^6.0.2"