@powerhousedao/ph-clint-cli 0.1.0-dev.52 → 0.1.0-dev.54

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.
Files changed (37) hide show
  1. package/dist/cli.js +3 -2
  2. package/dist/codegen/actions.d.ts +1 -46
  3. package/dist/codegen/actions.js +1 -424
  4. package/dist/codegen/builders/app-index-ts.js +24 -20
  5. package/dist/codegen/builders/cli-package-json.d.ts +1 -8
  6. package/dist/codegen/builders/cli-package-json.js +1 -128
  7. package/dist/codegen/builders/index.d.ts +1 -51
  8. package/dist/codegen/builders/index.js +1 -84
  9. package/dist/codegen/exec.d.ts +1 -2
  10. package/dist/codegen/exec.js +1 -14
  11. package/dist/codegen/generated.d.ts +1 -17
  12. package/dist/codegen/generated.js +1 -49
  13. package/dist/codegen/hashes.d.ts +1 -6
  14. package/dist/codegen/hashes.js +1 -60
  15. package/dist/codegen/index.d.ts +8 -39
  16. package/dist/codegen/index.js +6 -407
  17. package/dist/codegen/markers.d.ts +1 -36
  18. package/dist/codegen/markers.js +1 -86
  19. package/dist/codegen/scaffold.d.ts +1 -72
  20. package/dist/codegen/scaffold.js +1 -150
  21. package/dist/codegen/write.d.ts +1 -6
  22. package/dist/codegen/write.js +1 -32
  23. package/dist/commands/clint-project-init.js +2 -2
  24. package/dist/commands/clint-project-regen.js +1 -1
  25. package/dist/commands/clint-skills-sync.d.ts +1 -1
  26. package/dist/commands/clint-skills-sync.js +1 -1
  27. package/dist/framework.js +1 -1
  28. package/dist/skills/sync.d.ts +1 -40
  29. package/dist/skills/sync.js +1 -119
  30. package/dist/spec/ensure-document.js +9 -15
  31. package/dist/spec/file.d.ts +1 -4
  32. package/dist/spec/file.js +1 -34
  33. package/dist/spec/types.d.ts +1 -164
  34. package/dist/spec/types.js +1 -209
  35. package/dist/triggers/publish-trigger.js +1 -1
  36. package/dist/triggers/spec-change.js +7 -1
  37. package/package.json +9 -9
@@ -1,209 +1 @@
1
- /**
2
- * ClintProjectSpec — the in-memory shape that describes a ph-clint
3
- * implementation project. Persisted at
4
- * `{impl-project}/.ph/ph-clint-cli/project-spec.json` and consumed by
5
- * the code generator (src/codegen/).
6
- *
7
- * Intentionally minimal. Richer structure (services, skills, agents,
8
- * triggers, document-models) gets added in later phases as each
9
- * generator step actually needs it.
10
- */
11
- import { z } from 'zod';
12
- /**
13
- * Ordered Powerhouse integration level. Higher levels imply all lower ones:
14
- * Disabled → Reactor → Switchboard → Connect
15
- */
16
- export const POWERHOUSE_LEVELS = [
17
- 'Disabled',
18
- 'Reactor',
19
- 'Switchboard',
20
- 'Connect',
21
- ];
22
- export const powerhouseLevelSchema = z
23
- .enum(POWERHOUSE_LEVELS)
24
- .default('Disabled');
25
- /** Check whether `level` is at least `threshold` in the ordered enum. */
26
- export function phAtLeast(level, threshold) {
27
- return (POWERHOUSE_LEVELS.indexOf(level) >= POWERHOUSE_LEVELS.indexOf(threshold));
28
- }
29
- export const agentModelSchema = z.object({
30
- id: z.string(),
31
- isDefault: z.boolean(),
32
- });
33
- export const agentProfileSchema = z.object({
34
- id: z.string(),
35
- title: z.string(),
36
- content: z.string(),
37
- });
38
- const mastraCommonSchema = z.object({
39
- enableChat: z.boolean().default(false),
40
- });
41
- const mastraFeatureSchema = z.object({
42
- enabled: z.boolean().default(false),
43
- agentId: z.string().nullable().default(null),
44
- agentName: z.string().nullable().default(null),
45
- agentDescription: z.string().nullable().default(null),
46
- agentImage: z.string().nullable().default(null),
47
- models: z.array(agentModelSchema).default([]),
48
- profiles: z.array(agentProfileSchema).default([]),
49
- common: mastraCommonSchema.default({ enableChat: false }),
50
- });
51
- const routineFeatureSchema = z.object({
52
- enabled: z.boolean().default(false),
53
- });
54
- const DEFAULT_MASTRA = {
55
- enabled: false,
56
- agentId: null,
57
- agentName: null,
58
- agentDescription: null,
59
- agentImage: null,
60
- models: [],
61
- profiles: [],
62
- common: { enableChat: false },
63
- };
64
- const DEFAULT_ROUTINE = { enabled: false };
65
- export const powerhousePackageSchema = z.object({
66
- id: z.string(),
67
- packageName: z.string(),
68
- documentTypes: z.array(z.string()).default([]),
69
- version: z.string().nullable().default(null),
70
- });
71
- export const externalSkillSchema = z.object({
72
- id: z.string(),
73
- name: z.string(),
74
- githubUrl: z.string(),
75
- });
76
- export const clintProjectSpecSchema = z.object({
77
- name: z
78
- .string()
79
- .regex(/^[a-z0-9][a-z0-9-]*-cli$/, 'must end with -cli, lowercase letters, digits, hyphens only'),
80
- scope: z
81
- .string()
82
- .regex(/^@[a-z0-9][a-z0-9-]*$/, 'must start with @, lowercase letters, digits, hyphens only')
83
- .optional(),
84
- version: z.string().default('0.0.1-dev.0'),
85
- description: z.string().default(''),
86
- features: z
87
- .object({
88
- powerhouse: powerhouseLevelSchema,
89
- mastra: mastraFeatureSchema.default(DEFAULT_MASTRA),
90
- routine: routineFeatureSchema.default(DEFAULT_ROUTINE),
91
- })
92
- .default({
93
- powerhouse: 'Disabled',
94
- mastra: DEFAULT_MASTRA,
95
- routine: DEFAULT_ROUTINE,
96
- }),
97
- /**
98
- * Reactor packages and their document types. Each entry groups a package
99
- * name with the document type IDs it provides. The app package (project's
100
- * own reactor package) uses a `file:` dependency; external packages become
101
- * versioned npm dependencies. Drives codegen of `framework.gen.ts`,
102
- * `app/index.ts`, and `cli/package.json`.
103
- */
104
- packages: z.array(powerhousePackageSchema).default([]),
105
- /**
106
- * External skills from the skills.sh ecosystem. Each skill has a name
107
- * (kebab-case) and a GitHub URL for installation.
108
- */
109
- externalSkills: z.array(externalSkillSchema).default([]),
110
- deployment: z.object({
111
- proxyEnabled: z.boolean().default(false),
112
- supportedResources: z.array(z.string()).default([]),
113
- }).default({ proxyEnabled: false, supportedResources: [] }),
114
- /** ID of the source specification document (if backed by a Powerhouse document). */
115
- documentId: z.string().optional(),
116
- /** Document type of the source specification document. */
117
- documentType: z.string().optional(),
118
- });
119
- /** npm package name (e.g. `@scope/my-tool-cli` or `my-tool-cli`). */
120
- export function getPackageName(spec) {
121
- return spec.scope ? `${spec.scope}/${spec.name}` : spec.name;
122
- }
123
- /** bin name (strips -cli suffix, e.g. `my-tool-cli` → `my-tool`). */
124
- export function getBinName(spec) {
125
- return spec.name.replace(/-cli$/, '');
126
- }
127
- /**
128
- * Name of the CLI sub-folder when the project is split (Powerhouse enabled).
129
- * For flat projects this is irrelevant — callers use the project root directly.
130
- */
131
- export function getCliFolderName(spec) {
132
- return spec.name;
133
- }
134
- /**
135
- * Name of the reactor-package sub-folder when the project is split.
136
- */
137
- export function getAppFolderName(spec) {
138
- return spec.name.replace(/-cli$/, '-app');
139
- }
140
- /**
141
- * Flat list of all document types across all packages. Convenience for
142
- * codegen that needs to iterate every registered document type regardless
143
- * of which package provides it.
144
- */
145
- export function getAllDocumentTypes(spec) {
146
- return spec.packages.flatMap((p) => p.documentTypes);
147
- }
148
- /**
149
- * The app npm package name (`@scope/my-tool-app` or `my-tool-app`).
150
- * Matches what the document model reducer stores in `packages[].packageName`.
151
- */
152
- export function getAppPackageName(spec) {
153
- const base = getAppFolderName(spec);
154
- return spec.scope ? `${spec.scope}/${base}` : base;
155
- }
156
- /** Directory name for the app package (e.g. `my-tool-app`, no scope prefix). */
157
- export function getAppDirName(spec) {
158
- return getAppFolderName(spec);
159
- }
160
- /**
161
- * Folder slug for a documentType ID. The slug is the portion after the last
162
- * `/` (e.g. `powerhouse/ph-clint-project` → `ph-clint-project`). Matches the
163
- * convention used by Powerhouse's reactor-package codegen — each document
164
- * model lives at `document-models/<slug>/`.
165
- */
166
- export function getDocumentTypeSlug(documentType) {
167
- const lastSlash = documentType.lastIndexOf('/');
168
- return lastSlash >= 0 ? documentType.slice(lastSlash + 1) : documentType;
169
- }
170
- /**
171
- * PascalCase export name for a documentType ID. Powerhouse's module
172
- * generator exports each module as `PascalCase(<slug>)` (e.g.
173
- * `powerhouse/ph-clint-project` → `PhClintProject`). The top-level reactor
174
- * package re-exports these names, so this helper gives codegen the string
175
- * it needs both for the import and the `defineRegistry` entry.
176
- */
177
- export function getDocumentTypeModuleName(documentType) {
178
- const slug = getDocumentTypeSlug(documentType);
179
- return slug
180
- .split(/[-_]/)
181
- .filter((s) => s.length > 0)
182
- .map((s) => s[0].toUpperCase() + s.slice(1))
183
- .join('');
184
- }
185
- /**
186
- * Returns true when a documentType entry contains glob wildcards (`*`).
187
- * Glob entries like `*​/*`, `powerhouse/*`, or `powerhouse/doc-*` are spec
188
- * shorthand meaning "all matching document types from this package" and
189
- * must be resolved at runtime rather than emitted as static imports.
190
- */
191
- export function isDocTypeGlob(documentType) {
192
- return documentType.includes('*');
193
- }
194
- /**
195
- * Convert a documentType glob pattern to a regex source string suitable
196
- * for embedding in a `/pattern/` literal. Each `*` matches any non-`/`
197
- * characters. Forward slashes are escaped so the output is safe inside
198
- * `/.../`.
199
- *
200
- * Examples:
201
- * `*​/*` → `^[^\/]*\/[^\/]*$` (any org, any name)
202
- * `powerhouse/*` → `^powerhouse\/[^\/]*$`
203
- * `powerhouse/doc-*` → `^powerhouse\/doc-[^\/]*$`
204
- */
205
- export function docTypeGlobToRegex(pattern) {
206
- const escaped = pattern.replace(/[.+?^${}()|[\]\\\/]/g, '\\$&');
207
- const withWildcards = escaped.replace(/\*/g, '[^\\/]*');
208
- return `^${withWildcards}$`;
209
- }
1
+ export { POWERHOUSE_LEVELS, powerhouseLevelSchema, phAtLeast, agentModelSchema, agentProfileSchema, powerhousePackageSchema, externalSkillSchema, clintProjectSpecSchema, getPackageName, getBinName, getCliFolderName, getAppFolderName, getAllDocumentTypes, getAppPackageName, getAppDirName, getDocumentTypeSlug, getDocumentTypeModuleName, isDocTypeGlob, docTypeGlobToRegex, } from '@powerhousedao/ph-clint-dev/spec';
@@ -104,7 +104,7 @@ export const publishTrigger = createDocumentChangeTrigger({
104
104
  try {
105
105
  stdout(`${TAG} invoking clint-project-publish --tag ${cliTag}\n`);
106
106
  const { clintProjectPublish } = await import('../commands/clint-project-publish.js');
107
- const result = await clintProjectPublish.execute({ tag: cliTag, dryRun: false, skipBuild: false, skipGitCheck: true, verbose: false }, ctx.commandContext);
107
+ const result = await clintProjectPublish.execute({ tag: cliTag, dir: workdir, dryRun: false, skipBuild: false, skipGitCheck: true, verbose: false }, ctx.commandContext);
108
108
  success = !result.text.includes('failed');
109
109
  }
110
110
  catch (err) {
@@ -19,7 +19,7 @@ import path from 'node:path';
19
19
  import { scanProjects, getProjectMapping } from '@powerhousedao/ph-clint';
20
20
  import { createDocumentChangeTrigger } from '../framework.js';
21
21
  import { generateProject } from '../codegen/index.js';
22
- import { runPostGenActions } from '../codegen/actions.js';
22
+ import { runPostGenActions } from '@powerhousedao/ph-clint-dev/codegen/actions';
23
23
  import { specFromDocumentState } from '../spec/from-document.js';
24
24
  import { readProjectSpec, writeProjectSpec } from '../spec/file.js';
25
25
  import { ensureSpecDocument } from '../spec/ensure-document.js';
@@ -105,12 +105,18 @@ export function specToImportInput(spec) {
105
105
  name: s.name,
106
106
  githubUrl: s.githubUrl,
107
107
  })),
108
+ agentDescription: spec.features.mastra.agentDescription ?? null,
109
+ agentImage: spec.features.mastra.agentImage ?? null,
110
+ enableChat: spec.features.mastra.common.enableChat,
111
+ proxyEnabled: spec.deployment.proxyEnabled,
112
+ supportedResources: spec.deployment.supportedResources,
108
113
  };
109
114
  }
110
115
  export const specChangeTrigger = createDocumentChangeTrigger({
111
116
  id: 'spec-change',
112
117
  documentType: DOCUMENT_TYPE,
113
118
  // No documentId → watches ALL ph-clint-project docs
119
+ callOnEmpty: true, // bootstrap from disk when no documents exist yet
114
120
  async onChange(docs, ctx) {
115
121
  const log = ctx.context.log;
116
122
  const folders = ctx.context.folders;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-clint-cli",
3
- "version": "0.1.0-dev.52",
3
+ "version": "0.1.0-dev.54",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -17,7 +17,7 @@
17
17
  "build": "pnpm build:skills && tsc",
18
18
  "dev": "tsx src/main.ts",
19
19
  "start": "node dist/main.js",
20
- "test": "NODE_OPTIONS='--experimental-vm-modules' jest --detectOpenHandles",
20
+ "test": "NODE_OPTIONS='--experimental-vm-modules' jest --detectOpenHandles --coverage",
21
21
  "test:e2e": "NODE_OPTIONS='--experimental-vm-modules' jest --detectOpenHandles --testPathPatterns 'tests/(e2e|codegen-e2e)/' --testPathIgnorePatterns '/node_modules/'",
22
22
  "lint": "eslint src",
23
23
  "mastra:dev": "mastra dev",
@@ -29,13 +29,13 @@
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.52",
33
- "@powerhousedao/ph-clint-app": "^0.1.0-dev.52",
34
- "@powerhousedao/ph-clint-dev": "^0.1.0-dev.52",
35
- "@powerhousedao/reactor": "6.0.0-dev.170",
36
- "@powerhousedao/reactor-api": "6.0.0-dev.170",
37
- "@powerhousedao/shared": "6.0.0-dev.170",
38
- "document-model": "6.0.0-dev.170",
32
+ "@powerhousedao/ph-clint": "^0.1.0-dev.54",
33
+ "@powerhousedao/ph-clint-app": "^0.1.0-dev.54",
34
+ "@powerhousedao/ph-clint-dev": "^0.1.0-dev.54",
35
+ "@powerhousedao/reactor": "6.0.0-dev.216",
36
+ "@powerhousedao/reactor-api": "6.0.0-dev.216",
37
+ "@powerhousedao/shared": "6.0.0-dev.216",
38
+ "document-model": "6.0.0-dev.216",
39
39
  "kysely": "^0.27.0",
40
40
  "kysely-pglite-dialect": "^1.3.0",
41
41
  "zod": "^4.3.6"