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

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({');
@@ -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
  }
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.5",
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.5",
29
+ "@powerhousedao/ph-clint-app": "^0.1.0-dev.5",
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.5",
52
52
  "ts-jest": "^29.4.6",
53
53
  "tsx": "^4.19.0",
54
54
  "typescript": "^6.0.2"