@powerhousedao/ph-clint-cli 0.1.0-dev.49 → 0.1.0-dev.50

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.
@@ -12,7 +12,9 @@ function providerImport(provider) {
12
12
  }
13
13
  }
14
14
  function buildDemoAgent(spec) {
15
- const id = spec.features.mastra.agentId ?? spec.name;
15
+ const mastra = spec.features.mastra;
16
+ const id = mastra.agentId ?? spec.name;
17
+ const name = mastra.agentName ?? id;
16
18
  return [
17
19
  "import type { AgentProvider, AgentSetupContext, StreamChunk } from '@powerhousedao/ph-clint';",
18
20
  "import type { Config } from '../framework.js';",
@@ -24,6 +26,7 @@ function buildDemoAgent(spec) {
24
26
  'function createDemoAgent(): AgentProvider {',
25
27
  ' return {',
26
28
  ` id: '${id}',`,
29
+ ` name: '${name}',`,
27
30
  ' async *stream(prompt) {',
28
31
  ' yield {',
29
32
  " type: 'text-delta',",
@@ -99,6 +102,12 @@ function buildRealAgent(spec) {
99
102
  lines.push(' enableLogging: ctx.config.agentLogging,');
100
103
  lines.push(" logDirectory: store.getStoreFolder('logs'),");
101
104
  lines.push(' cacheControl: true,');
105
+ if (mastra.agentDescription) {
106
+ lines.push(` description: ${JSON.stringify(mastra.agentDescription)},`);
107
+ }
108
+ if (mastra.agentImage) {
109
+ lines.push(` image: ${JSON.stringify(mastra.agentImage)},`);
110
+ }
102
111
  lines.push(' };');
103
112
  lines.push(' return m.wrapAgent(agent, wrapOpts);');
104
113
  lines.push('}');
@@ -49,9 +49,7 @@ function getPowerhouseVersion() {
49
49
  }
50
50
  export function buildCliPackageJson(spec) {
51
51
  const { mastra, powerhouse } = spec.features;
52
- const pkgName = phAtLeast(powerhouse, 'Reactor')
53
- ? `${getPackageName(spec)}-cli`
54
- : getPackageName(spec);
52
+ const pkgName = getPackageName(spec);
55
53
  const bin = getBinName(spec);
56
54
  const dependencies = {
57
55
  '@powerhousedao/ph-clint': PH_CLINT_VERSION,
@@ -43,6 +43,9 @@ export function buildCliTs(spec) {
43
43
  if (mastra.enabled) {
44
44
  lines.push(`import { createAgent } from './agents/agent.js';`);
45
45
  }
46
+ if (mastra.enabled && mastra.common?.enableChat) {
47
+ lines.push(`import { chatSessionWatchTrigger } from '@powerhousedao/clint-common/chat';`);
48
+ }
46
49
  lines.push('// @clint:end imports');
47
50
  lines.push('');
48
51
  lines.push('export const cli = defineCli({');
@@ -66,8 +69,8 @@ export function buildCliTs(spec) {
66
69
  lines.push(' // @clint:end services');
67
70
  lines.push('');
68
71
  lines.push(' // @clint:begin triggers');
69
- if (routine.enabled) {
70
- lines.push(' triggers: [],');
72
+ if (mastra.enabled && mastra.common?.enableChat) {
73
+ lines.push(' triggers: [chatSessionWatchTrigger],');
71
74
  }
72
75
  else {
73
76
  lines.push(' triggers: [],');
@@ -5,4 +5,4 @@
5
5
  * can extend them without fighting the generator.
6
6
  */
7
7
  import { type ClintProjectSpec } from '../../spec/types.js';
8
- export declare function buildConfigTs(spec: ClintProjectSpec): string;
8
+ export declare function buildConfigTs(_spec: ClintProjectSpec): string;
@@ -1,17 +1,11 @@
1
- export function buildConfigTs(spec) {
2
- const hasCustomBin = !!spec.bin;
1
+ export function buildConfigTs(_spec) {
3
2
  const lines = [];
4
3
  lines.push(`import { readPackageInfo } from '@powerhousedao/ph-clint';`);
5
4
  lines.push('');
6
5
  lines.push('const pkg = readPackageInfo(import.meta.url);');
7
6
  lines.push('');
8
7
  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
- }
8
+ lines.push(`export const CLI_NAME = pkg.name.replace(/-cli$/, '');`);
15
9
  lines.push('export const CLI_VERSION = pkg.version;');
16
10
  return lines.join('\n') + '\n';
17
11
  }
@@ -4,6 +4,9 @@ export function buildDemoAgentTs(spec) {
4
4
  if (!mastra.enabled || !mastra.agentId || mastra.models.length === 0)
5
5
  return null;
6
6
  const agentId = mastra.agentId;
7
+ const agentName = mastra.agentName ?? agentId;
8
+ const agentDescription = mastra.agentDescription;
9
+ const agentImage = mastra.agentImage;
7
10
  return [
8
11
  "import type { AgentProvider, StreamChunk } from '@powerhousedao/ph-clint';",
9
12
  '',
@@ -17,6 +20,9 @@ export function buildDemoAgentTs(spec) {
17
20
  '',
18
21
  ' return {',
19
22
  ` id: '${agentId}',`,
23
+ ` name: '${agentName}',`,
24
+ ...(agentDescription ? [` description: ${JSON.stringify(agentDescription)},`] : []),
25
+ ...(agentImage ? [` image: ${JSON.stringify(agentImage)},`] : []),
20
26
  ' async *stream(prompt, opts) {',
21
27
  " const threadId = opts?.threadId ?? 'default';",
22
28
  ' if (!conversations.has(threadId)) {',
@@ -4,16 +4,17 @@
4
4
  * Split-layout: a lockstep group with both app and cli packages.
5
5
  * Single-layout: a single-package group at `.`.
6
6
  */
7
- import { phAtLeast } from '../../spec/types.js';
7
+ import { phAtLeast, getBinName, getAppFolderName, getCliFolderName, } from '../../spec/types.js';
8
8
  export function buildPublishConfigJs(spec) {
9
9
  const split = phAtLeast(spec.features.powerhouse, 'Reactor');
10
10
  // The publish pipeline appends the prerelease suffix (e.g. -dev.0), so we
11
11
  // only store the base semver (M.m.p) here.
12
12
  const baseVersion = spec.version.replace(/-.*$/, '');
13
+ const binName = getBinName(spec);
13
14
  const packages = split
14
15
  ? `[
15
- { path: '${spec.name}-app', category: 'app' },
16
- { path: '${spec.name}-cli', category: 'cli' },
16
+ { path: '${getAppFolderName(spec)}', category: 'app' },
17
+ { path: '${getCliFolderName(spec)}', category: 'cli' },
17
18
  ]`
18
19
  : `[
19
20
  { path: '.', category: 'cli' },
@@ -22,7 +23,7 @@ export function buildPublishConfigJs(spec) {
22
23
  // definePublishConfig is an identity function; a plain export is equivalent.
23
24
  export default {
24
25
  groups: {
25
- '${spec.name}': {
26
+ '${binName}': {
26
27
  version: '${baseVersion}',
27
28
  packages: ${packages},
28
29
  },
@@ -6,10 +6,10 @@
6
6
  * Uses `pnpm --prefix <dir>` for all orchestration scripts — no cwd mutation.
7
7
  * Build order: app first, then cli (cli depends on app via `file:` dep).
8
8
  */
9
- import { getPackageName, phAtLeast, } from '../../spec/types.js';
9
+ import { getAppFolderName, getBinName, getCliFolderName, phAtLeast, } from '../../spec/types.js';
10
10
  export function buildRootPackageJson(spec) {
11
- const cli = `${spec.name}-cli`;
12
- const app = `${spec.name}-app`;
11
+ const cli = getCliFolderName(spec);
12
+ const app = getAppFolderName(spec);
13
13
  const prefix = (dir, cmd) => `pnpm --prefix ${dir} ${cmd}`;
14
14
  const both = (cmd) => `${prefix(app, cmd)} && ${prefix(cli, cmd)}`;
15
15
  const connectEnabled = phAtLeast(spec.features.powerhouse, 'Connect');
@@ -28,7 +28,7 @@ export function buildRootPackageJson(spec) {
28
28
  'publish:production': `${prefix(cli, 'exec ph-publish')} production -c ../publish.config.js${connectEnabled ? ' --verify-connect' : ''}`,
29
29
  };
30
30
  const pkg = {
31
- name: getPackageName(spec),
31
+ name: spec.scope ? `${spec.scope}/${getBinName(spec)}` : getBinName(spec),
32
32
  version: spec.version,
33
33
  private: true,
34
34
  type: 'module',
@@ -94,7 +94,7 @@ export async function runPhInit(options) {
94
94
  export async function patchAppPackageName(appDir, spec, log) {
95
95
  const appFolder = path.basename(appDir);
96
96
  const scopedName = spec.scope
97
- ? `@${spec.scope}/${appFolder}`
97
+ ? `${spec.scope}/${appFolder}`
98
98
  : appFolder;
99
99
  const appPkgJsonPath = path.join(appDir, 'package.json');
100
100
  try {
@@ -49,6 +49,9 @@ export declare const init: import("@powerhousedao/ph-clint").Command<z.ZodObject
49
49
  title: string;
50
50
  content: string;
51
51
  }[];
52
+ common: {
53
+ enableChat: boolean;
54
+ };
52
55
  };
53
56
  routine: {
54
57
  enabled: boolean;
@@ -58,6 +61,7 @@ export declare const init: import("@powerhousedao/ph-clint").Command<z.ZodObject
58
61
  id: string;
59
62
  packageName: string;
60
63
  documentTypes: string[];
64
+ version: string | null;
61
65
  }[];
62
66
  externalSkills: {
63
67
  id: string;
@@ -69,7 +73,6 @@ export declare const init: import("@powerhousedao/ph-clint").Command<z.ZodObject
69
73
  supportedResources: string[];
70
74
  };
71
75
  scope?: string | undefined;
72
- bin?: string | undefined;
73
76
  documentId?: string | undefined;
74
77
  documentType?: string | undefined;
75
78
  };
@@ -53,7 +53,7 @@ const inputSchema = z.object({
53
53
  function splitPackageName(raw) {
54
54
  const match = /^@([a-z0-9][a-z0-9-]*)\/([a-z0-9][a-z0-9-]*)$/.exec(raw);
55
55
  if (match)
56
- return { scope: match[1], name: match[2] };
56
+ return { scope: `@${match[1]}`, name: match[2] };
57
57
  if (raw.startsWith('@')) {
58
58
  throw new Error(`invalid package name "${raw}" — expected "@scope/name" with lowercase letters, digits, hyphens`);
59
59
  }
@@ -9,30 +9,8 @@ export function specFromDocumentState(state, meta) {
9
9
  if (!state.name)
10
10
  return null;
11
11
  const parsed = clintProjectSpecSchema.safeParse({
12
- name: state.name,
12
+ ...state,
13
13
  scope: state.scope ?? undefined,
14
- version: state.version,
15
- description: state.description,
16
- bin: state.bin ?? undefined,
17
- features: {
18
- powerhouse: state.features.powerhouse,
19
- mastra: { ...state.features.mastra },
20
- routine: { ...state.features.routine },
21
- },
22
- packages: state.packages.map((p) => ({
23
- id: p.id,
24
- packageName: p.packageName,
25
- documentTypes: [...p.documentTypes],
26
- })),
27
- externalSkills: state.externalSkills.map((s) => ({
28
- id: s.id,
29
- name: s.name,
30
- githubUrl: s.githubUrl,
31
- })),
32
- deployment: {
33
- proxyEnabled: state.deployment.proxyEnabled,
34
- supportedResources: [...state.deployment.supportedResources],
35
- },
36
14
  documentId: meta?.documentId,
37
15
  documentType: meta?.documentType,
38
16
  });
@@ -38,6 +38,7 @@ export declare const powerhousePackageSchema: z.ZodObject<{
38
38
  id: z.ZodString;
39
39
  packageName: z.ZodString;
40
40
  documentTypes: z.ZodDefault<z.ZodArray<z.ZodString>>;
41
+ version: z.ZodDefault<z.ZodNullable<z.ZodString>>;
41
42
  }, z.core.$strip>;
42
43
  export type PowerhousePackage = z.infer<typeof powerhousePackageSchema>;
43
44
  export declare const externalSkillSchema: z.ZodObject<{
@@ -51,7 +52,6 @@ export declare const clintProjectSpecSchema: z.ZodObject<{
51
52
  scope: z.ZodOptional<z.ZodString>;
52
53
  version: z.ZodDefault<z.ZodString>;
53
54
  description: z.ZodDefault<z.ZodString>;
54
- bin: z.ZodOptional<z.ZodString>;
55
55
  features: z.ZodDefault<z.ZodObject<{
56
56
  powerhouse: z.ZodDefault<z.ZodEnum<{
57
57
  Disabled: "Disabled";
@@ -74,6 +74,9 @@ export declare const clintProjectSpecSchema: z.ZodObject<{
74
74
  title: z.ZodString;
75
75
  content: z.ZodString;
76
76
  }, z.core.$strip>>>;
77
+ common: z.ZodDefault<z.ZodObject<{
78
+ enableChat: z.ZodDefault<z.ZodBoolean>;
79
+ }, z.core.$strip>>;
77
80
  }, z.core.$strip>>;
78
81
  routine: z.ZodDefault<z.ZodObject<{
79
82
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -83,6 +86,7 @@ export declare const clintProjectSpecSchema: z.ZodObject<{
83
86
  id: z.ZodString;
84
87
  packageName: z.ZodString;
85
88
  documentTypes: z.ZodDefault<z.ZodArray<z.ZodString>>;
89
+ version: z.ZodDefault<z.ZodNullable<z.ZodString>>;
86
90
  }, z.core.$strip>>>;
87
91
  externalSkills: z.ZodDefault<z.ZodArray<z.ZodObject<{
88
92
  id: z.ZodString;
@@ -98,9 +102,9 @@ export declare const clintProjectSpecSchema: z.ZodObject<{
98
102
  }, z.core.$strip>;
99
103
  export type ClintProjectSpec = z.infer<typeof clintProjectSpecSchema>;
100
104
  export type ClintProjectSpecInput = z.input<typeof clintProjectSpecSchema>;
101
- /** npm package name (e.g. `@scope/foo` or `foo`). */
105
+ /** npm package name (e.g. `@scope/my-tool-cli` or `my-tool-cli`). */
102
106
  export declare function getPackageName(spec: ClintProjectSpec): string;
103
- /** bin name (defaults to the bare project name). */
107
+ /** bin name (strips -cli suffix, e.g. `my-tool-cli` → `my-tool`). */
104
108
  export declare function getBinName(spec: ClintProjectSpec): string;
105
109
  /**
106
110
  * Name of the CLI sub-folder when the project is split (Powerhouse enabled).
@@ -118,11 +122,11 @@ export declare function getAppFolderName(spec: ClintProjectSpec): string;
118
122
  */
119
123
  export declare function getAllDocumentTypes(spec: ClintProjectSpec): string[];
120
124
  /**
121
- * The app npm package name (`@scope/{name}-app` or `{name}-app`).
125
+ * The app npm package name (`@scope/my-tool-app` or `my-tool-app`).
122
126
  * Matches what the document model reducer stores in `packages[].packageName`.
123
127
  */
124
128
  export declare function getAppPackageName(spec: ClintProjectSpec): string;
125
- /** Directory name for the app package (`{name}-app`, no scope prefix). */
129
+ /** Directory name for the app package (e.g. `my-tool-app`, no scope prefix). */
126
130
  export declare function getAppDirName(spec: ClintProjectSpec): string;
127
131
  /**
128
132
  * Folder slug for a documentType ID. The slug is the portion after the last
@@ -35,6 +35,9 @@ export const agentProfileSchema = z.object({
35
35
  title: z.string(),
36
36
  content: z.string(),
37
37
  });
38
+ const mastraCommonSchema = z.object({
39
+ enableChat: z.boolean().default(false),
40
+ });
38
41
  const mastraFeatureSchema = z.object({
39
42
  enabled: z.boolean().default(false),
40
43
  agentId: z.string().nullable().default(null),
@@ -43,6 +46,7 @@ const mastraFeatureSchema = z.object({
43
46
  agentImage: z.string().nullable().default(null),
44
47
  models: z.array(agentModelSchema).default([]),
45
48
  profiles: z.array(agentProfileSchema).default([]),
49
+ common: mastraCommonSchema.default({ enableChat: false }),
46
50
  });
47
51
  const routineFeatureSchema = z.object({
48
52
  enabled: z.boolean().default(false),
@@ -55,12 +59,14 @@ const DEFAULT_MASTRA = {
55
59
  agentImage: null,
56
60
  models: [],
57
61
  profiles: [],
62
+ common: { enableChat: false },
58
63
  };
59
64
  const DEFAULT_ROUTINE = { enabled: false };
60
65
  export const powerhousePackageSchema = z.object({
61
66
  id: z.string(),
62
67
  packageName: z.string(),
63
68
  documentTypes: z.array(z.string()).default([]),
69
+ version: z.string().nullable().default(null),
64
70
  });
65
71
  export const externalSkillSchema = z.object({
66
72
  id: z.string(),
@@ -70,14 +76,13 @@ export const externalSkillSchema = z.object({
70
76
  export const clintProjectSpecSchema = z.object({
71
77
  name: z
72
78
  .string()
73
- .regex(/^[a-z0-9][a-z0-9-]*$/, 'lowercase letters, digits, hyphens only'),
79
+ .regex(/^[a-z0-9][a-z0-9-]*-cli$/, 'must end with -cli, lowercase letters, digits, hyphens only'),
74
80
  scope: z
75
81
  .string()
76
- .regex(/^[a-z0-9][a-z0-9-]*$/, 'lowercase letters, digits, hyphens only')
82
+ .regex(/^@[a-z0-9][a-z0-9-]*$/, 'must start with @, lowercase letters, digits, hyphens only')
77
83
  .optional(),
78
84
  version: z.string().default('0.0.1-dev.0'),
79
85
  description: z.string().default(''),
80
- bin: z.string().optional(),
81
86
  features: z
82
87
  .object({
83
88
  powerhouse: powerhouseLevelSchema,
@@ -111,26 +116,26 @@ export const clintProjectSpecSchema = z.object({
111
116
  /** Document type of the source specification document. */
112
117
  documentType: z.string().optional(),
113
118
  });
114
- /** npm package name (e.g. `@scope/foo` or `foo`). */
119
+ /** npm package name (e.g. `@scope/my-tool-cli` or `my-tool-cli`). */
115
120
  export function getPackageName(spec) {
116
- return spec.scope ? `@${spec.scope}/${spec.name}` : spec.name;
121
+ return spec.scope ? `${spec.scope}/${spec.name}` : spec.name;
117
122
  }
118
- /** bin name (defaults to the bare project name). */
123
+ /** bin name (strips -cli suffix, e.g. `my-tool-cli` → `my-tool`). */
119
124
  export function getBinName(spec) {
120
- return spec.bin ?? spec.name;
125
+ return spec.name.replace(/-cli$/, '');
121
126
  }
122
127
  /**
123
128
  * Name of the CLI sub-folder when the project is split (Powerhouse enabled).
124
129
  * For flat projects this is irrelevant — callers use the project root directly.
125
130
  */
126
131
  export function getCliFolderName(spec) {
127
- return `${spec.name}-cli`;
132
+ return spec.name;
128
133
  }
129
134
  /**
130
135
  * Name of the reactor-package sub-folder when the project is split.
131
136
  */
132
137
  export function getAppFolderName(spec) {
133
- return `${spec.name}-app`;
138
+ return spec.name.replace(/-cli$/, '-app');
134
139
  }
135
140
  /**
136
141
  * Flat list of all document types across all packages. Convenience for
@@ -141,16 +146,16 @@ export function getAllDocumentTypes(spec) {
141
146
  return spec.packages.flatMap((p) => p.documentTypes);
142
147
  }
143
148
  /**
144
- * The app npm package name (`@scope/{name}-app` or `{name}-app`).
149
+ * The app npm package name (`@scope/my-tool-app` or `my-tool-app`).
145
150
  * Matches what the document model reducer stores in `packages[].packageName`.
146
151
  */
147
152
  export function getAppPackageName(spec) {
148
- const base = `${spec.name}-app`;
149
- return spec.scope ? `@${spec.scope}/${base}` : base;
153
+ const base = getAppFolderName(spec);
154
+ return spec.scope ? `${spec.scope}/${base}` : base;
150
155
  }
151
- /** Directory name for the app package (`{name}-app`, no scope prefix). */
156
+ /** Directory name for the app package (e.g. `my-tool-app`, no scope prefix). */
152
157
  export function getAppDirName(spec) {
153
- return `${spec.name}-app`;
158
+ return getAppFolderName(spec);
154
159
  }
155
160
  /**
156
161
  * Folder slug for a documentType ID. The slug is the portion after the last
@@ -81,7 +81,6 @@ export function specToImportInput(spec) {
81
81
  scope: spec.scope ?? null,
82
82
  version: spec.version,
83
83
  description: spec.description,
84
- bin: spec.bin ?? null,
85
84
  powerhouse: spec.features.powerhouse,
86
85
  mastraEnabled: spec.features.mastra.enabled,
87
86
  routineEnabled: spec.features.routine.enabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-clint-cli",
3
- "version": "0.1.0-dev.49",
3
+ "version": "0.1.0-dev.50",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -29,9 +29,9 @@
29
29
  "@mastra/core": "^1.22.0",
30
30
  "@mastra/libsql": "^1.7.4",
31
31
  "@mastra/memory": "^1.13.1",
32
- "@powerhousedao/ph-clint": "^0.1.0-dev.49",
33
- "@powerhousedao/ph-clint-app": "^0.1.0-dev.49",
34
- "@powerhousedao/ph-clint-dev": "^0.1.0-dev.49",
32
+ "@powerhousedao/ph-clint": "^0.1.0-dev.50",
33
+ "@powerhousedao/ph-clint-app": "^0.1.0-dev.50",
34
+ "@powerhousedao/ph-clint-dev": "^0.1.0-dev.50",
35
35
  "@powerhousedao/reactor": "6.0.0-dev.170",
36
36
  "@powerhousedao/reactor-api": "6.0.0-dev.170",
37
37
  "@powerhousedao/shared": "6.0.0-dev.170",