@powerhousedao/ph-clint-cli 0.1.0-dev.1 → 0.1.0-dev.100
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 +60 -17
- package/dist/codegen/index.d.ts +8 -36
- package/dist/codegen/index.js +6 -287
- package/dist/commands/clint-project-build.d.ts +83 -0
- package/dist/commands/clint-project-build.js +34 -0
- package/dist/commands/clint-project-init.d.ts +177 -0
- package/dist/commands/{init.js → clint-project-init.js} +75 -50
- package/dist/commands/clint-project-publish.d.ts +92 -0
- package/dist/commands/clint-project-publish.js +73 -0
- package/dist/commands/clint-project-regen.d.ts +94 -0
- package/dist/commands/{regen.js → clint-project-regen.js} +29 -5
- package/dist/commands/clint-skills-sync.d.ts +86 -0
- package/dist/commands/clint-skills-sync.js +56 -0
- package/dist/config.d.ts +3 -5
- package/dist/config.js +5 -7
- package/dist/framework.d.ts +322 -60
- package/dist/framework.gen.d.ts +50 -10
- package/dist/framework.gen.js +1 -1
- package/dist/framework.js +1 -5
- package/{prompts/agent-profiles/AgentBase.md → dist/gen/agent-profiles/PhClintDevAgent.md} +1 -1
- package/dist/gen/skills/cli-setup/.cli-docs.md +135 -0
- package/dist/gen/skills/cli-setup/SKILL.md +125 -0
- package/dist/gen/skills/cli-setup/references/00.assess-cli-needs.md +53 -0
- package/dist/gen/skills/cli-setup/references/01.define-config-schema.md +78 -0
- package/dist/gen/skills/cli-setup/references/02.wire-cli.md +141 -0
- package/dist/gen/skills/cli-setup/references/03.add-entrypoint.md +128 -0
- package/dist/gen/skills/cli-setup/references/expected-outcome.md +3 -0
- package/dist/gen/skills/command-definition/.cli-docs.md +84 -0
- package/dist/gen/skills/command-definition/SKILL.md +99 -0
- package/dist/gen/skills/command-definition/references/00.assess-requirements.md +58 -0
- package/dist/gen/skills/command-definition/references/01.define-schema.md +72 -0
- package/dist/gen/skills/command-definition/references/02.implement-execute.md +118 -0
- package/dist/gen/skills/command-definition/references/03.add-prompting.md +54 -0
- package/dist/gen/skills/command-definition/references/expected-outcome.md +3 -0
- package/dist/gen/skills/service-definition/.cli-docs.md +214 -0
- package/dist/gen/skills/service-definition/SKILL.md +148 -0
- package/dist/gen/skills/service-definition/references/00.assess-service.md +69 -0
- package/dist/gen/skills/service-definition/references/01.define-service.md +166 -0
- package/dist/gen/skills/service-definition/references/02.add-preflight.md +132 -0
- package/dist/gen/skills/service-definition/references/03.add-project-scanner.md +82 -0
- package/dist/gen/skills/service-definition/references/04.wire-events.md +120 -0
- package/dist/gen/skills/service-definition/references/expected-outcome.md +3 -0
- package/dist/main.js +0 -0
- package/dist/services/clint-project.d.ts +1 -0
- package/dist/services/clint-project.js +68 -0
- package/dist/spec/ensure-document.d.ts +17 -0
- package/dist/spec/ensure-document.js +56 -0
- package/dist/spec/file.d.ts +1 -4
- package/dist/spec/file.js +1 -34
- package/dist/spec/from-document.d.ts +4 -1
- package/dist/spec/from-document.js +4 -16
- package/dist/spec/types.d.ts +1 -62
- package/dist/spec/types.js +1 -112
- package/dist/triggers/publish-trigger.d.ts +81 -0
- package/dist/triggers/publish-trigger.js +137 -0
- package/dist/triggers/spec-change.d.ts +60 -18
- package/dist/triggers/spec-change.js +154 -101
- package/package.json +26 -32
- package/dist/codegen/builders/agent-base-md.d.ts +0 -5
- package/dist/codegen/builders/agent-base-md.js +0 -18
- package/dist/codegen/builders/agent-ts.d.ts +0 -9
- package/dist/codegen/builders/agent-ts.js +0 -34
- package/dist/codegen/builders/app-index-ts.d.ts +0 -18
- package/dist/codegen/builders/app-index-ts.js +0 -33
- package/dist/codegen/builders/build-skills-ts.d.ts +0 -4
- package/dist/codegen/builders/build-skills-ts.js +0 -37
- package/dist/codegen/builders/cli-package-json.d.ts +0 -8
- package/dist/codegen/builders/cli-package-json.js +0 -69
- package/dist/codegen/builders/cli-ts.d.ts +0 -7
- package/dist/codegen/builders/cli-ts.js +0 -110
- package/dist/codegen/builders/config-ts.d.ts +0 -8
- package/dist/codegen/builders/config-ts.js +0 -21
- package/dist/codegen/builders/eslint-config-js.d.ts +0 -4
- package/dist/codegen/builders/eslint-config-js.js +0 -13
- package/dist/codegen/builders/framework-gen-ts.d.ts +0 -20
- package/dist/codegen/builders/framework-gen-ts.js +0 -62
- package/dist/codegen/builders/framework-ts.d.ts +0 -21
- package/dist/codegen/builders/framework-ts.js +0 -74
- package/dist/codegen/builders/gitignore.d.ts +0 -4
- package/dist/codegen/builders/gitignore.js +0 -18
- package/dist/codegen/builders/index.d.ts +0 -43
- package/dist/codegen/builders/index.js +0 -60
- package/dist/codegen/builders/jest-config-js.d.ts +0 -4
- package/dist/codegen/builders/jest-config-js.js +0 -19
- package/dist/codegen/builders/main-ts.d.ts +0 -5
- package/dist/codegen/builders/main-ts.js +0 -13
- package/dist/codegen/builders/mastra-index-ts.d.ts +0 -8
- package/dist/codegen/builders/mastra-index-ts.js +0 -30
- package/dist/codegen/builders/readme-md.d.ts +0 -5
- package/dist/codegen/builders/readme-md.js +0 -44
- package/dist/codegen/builders/root-package-json.d.ts +0 -7
- package/dist/codegen/builders/root-package-json.js +0 -27
- package/dist/codegen/builders/tsconfig-json.d.ts +0 -4
- package/dist/codegen/builders/tsconfig-json.js +0 -22
- package/dist/codegen/exec.d.ts +0 -20
- package/dist/codegen/exec.js +0 -41
- package/dist/codegen/hashes.d.ts +0 -6
- package/dist/codegen/hashes.js +0 -60
- package/dist/codegen/markers.d.ts +0 -36
- package/dist/codegen/markers.js +0 -86
- package/dist/codegen/migrate/flat-to-split.d.ts +0 -15
- package/dist/codegen/migrate/flat-to-split.js +0 -119
- package/dist/codegen/scaffold.d.ts +0 -34
- package/dist/codegen/scaffold.js +0 -60
- package/dist/codegen/write.d.ts +0 -6
- package/dist/codegen/write.js +0 -32
- package/dist/commands/init.d.ts +0 -57
- package/dist/commands/regen.d.ts +0 -18
- package/prompts/skills-ext/.gitkeep +0 -0
- package/prompts/skills-tpl/.gitkeep +0 -0
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
export function buildCliTs(spec) {
|
|
2
|
-
const { mastra, routine, powerhouse } = spec.features;
|
|
3
|
-
const lines = [];
|
|
4
|
-
lines.push('/**');
|
|
5
|
-
lines.push(' * CLI definition.');
|
|
6
|
-
lines.push(' *');
|
|
7
|
-
lines.push(' * Generated by ph-clint. Regions bracketed by @clint:begin/@clint:end');
|
|
8
|
-
lines.push(' * markers are rewritten by ph-clint when the project spec changes.');
|
|
9
|
-
lines.push(' * Everything outside the markers is user-editable and preserved.');
|
|
10
|
-
lines.push(' */');
|
|
11
|
-
if (powerhouse.enabled) {
|
|
12
|
-
lines.push(`import path from 'node:path';`);
|
|
13
|
-
lines.push(`import { fileURLToPath } from 'node:url';`);
|
|
14
|
-
lines.push(`import { defineCli, buildDefaultReactor } from '@powerhousedao/ph-clint';`);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
lines.push(`import { defineCli } from '@powerhousedao/ph-clint';`);
|
|
18
|
-
}
|
|
19
|
-
lines.push(`import { CLI_NAME, CLI_VERSION } from './config.js';`);
|
|
20
|
-
lines.push(`import { configSchema, secretsSchema } from './framework.js';`);
|
|
21
|
-
lines.push('');
|
|
22
|
-
lines.push('// @clint:begin imports');
|
|
23
|
-
if (powerhouse.enabled) {
|
|
24
|
-
lines.push(`import { documentModels } from '${spec.name}-app';`);
|
|
25
|
-
}
|
|
26
|
-
if (mastra.enabled) {
|
|
27
|
-
lines.push(`import { createAgent } from './agents/agent.js';`);
|
|
28
|
-
}
|
|
29
|
-
lines.push('// @clint:end imports');
|
|
30
|
-
lines.push('');
|
|
31
|
-
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');`);
|
|
34
|
-
lines.push('');
|
|
35
|
-
}
|
|
36
|
-
lines.push('export const cli = defineCli({');
|
|
37
|
-
lines.push(' name: CLI_NAME,');
|
|
38
|
-
lines.push(' version: CLI_VERSION,');
|
|
39
|
-
lines.push(' description: `${CLI_NAME} v${CLI_VERSION}`,');
|
|
40
|
-
lines.push(' configSchema,');
|
|
41
|
-
lines.push(' secretsSchema,');
|
|
42
|
-
lines.push('');
|
|
43
|
-
lines.push(' // @clint:begin commands');
|
|
44
|
-
lines.push(' commands: [],');
|
|
45
|
-
lines.push(' // @clint:end commands');
|
|
46
|
-
lines.push('');
|
|
47
|
-
lines.push(' // @clint:begin services');
|
|
48
|
-
lines.push(' services: [],');
|
|
49
|
-
lines.push(' // @clint:end services');
|
|
50
|
-
lines.push('');
|
|
51
|
-
lines.push(' // @clint:begin triggers');
|
|
52
|
-
if (routine.enabled) {
|
|
53
|
-
lines.push(' triggers: [],');
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
lines.push(' triggers: [],');
|
|
57
|
-
}
|
|
58
|
-
lines.push(' // @clint:end triggers');
|
|
59
|
-
lines.push('');
|
|
60
|
-
lines.push(' // @clint:begin prompts');
|
|
61
|
-
lines.push(' prompts: {');
|
|
62
|
-
lines.push(' sources: [],');
|
|
63
|
-
lines.push(' agents: {},');
|
|
64
|
-
lines.push(' skills: {},');
|
|
65
|
-
lines.push(' },');
|
|
66
|
-
lines.push(' // @clint:end prompts');
|
|
67
|
-
lines.push('');
|
|
68
|
-
lines.push(' // @clint:begin events');
|
|
69
|
-
lines.push(' events: {},');
|
|
70
|
-
lines.push(' // @clint:end events');
|
|
71
|
-
lines.push('');
|
|
72
|
-
lines.push(' // @clint:begin interactive');
|
|
73
|
-
lines.push(' interactive: {');
|
|
74
|
-
lines.push(` welcome: ({ workdir }) =>`);
|
|
75
|
-
lines.push(' [');
|
|
76
|
-
lines.push(' `${CLI_NAME} v${CLI_VERSION}`,');
|
|
77
|
-
lines.push(' `Workdir: ${workdir}`,');
|
|
78
|
-
lines.push(" '',");
|
|
79
|
-
if (mastra.enabled) {
|
|
80
|
-
lines.push(" 'Type a message to talk to the agent, or /help for commands.',");
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
lines.push(" 'Type /help for commands.',");
|
|
84
|
-
}
|
|
85
|
-
lines.push(" ].join('\\n'),");
|
|
86
|
-
lines.push(' },');
|
|
87
|
-
lines.push(' // @clint:end interactive');
|
|
88
|
-
lines.push('});');
|
|
89
|
-
lines.push('');
|
|
90
|
-
lines.push('// @clint:begin reactor');
|
|
91
|
-
if (powerhouse.enabled) {
|
|
92
|
-
lines.push('cli.configureReactor({');
|
|
93
|
-
lines.push(' create: (ctx) =>');
|
|
94
|
-
lines.push(' buildDefaultReactor(ctx, {');
|
|
95
|
-
lines.push(' documentModels,');
|
|
96
|
-
lines.push(` drive: { name: '${spec.name}' },`);
|
|
97
|
-
lines.push(' }),');
|
|
98
|
-
lines.push(` switchboard: { enabled: ${String(powerhouse.switchboard)} },`);
|
|
99
|
-
lines.push(` connect: { enabled: ${String(powerhouse.connect)}, workdir: appDir },`);
|
|
100
|
-
lines.push('});');
|
|
101
|
-
}
|
|
102
|
-
lines.push('// @clint:end reactor');
|
|
103
|
-
lines.push('');
|
|
104
|
-
lines.push('// @clint:begin mastra');
|
|
105
|
-
if (mastra.enabled) {
|
|
106
|
-
lines.push('cli.configureAgent(createAgent);');
|
|
107
|
-
}
|
|
108
|
-
lines.push('// @clint:end mastra');
|
|
109
|
-
return lines.join('\n') + '\n';
|
|
110
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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 { type ClintProjectSpec } from '../../spec/types.js';
|
|
8
|
-
export declare function buildConfigTs(spec: ClintProjectSpec): string;
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
export function buildConfigTs(spec) {
|
|
9
|
-
const cliName = getBinName(spec);
|
|
10
|
-
const lines = [];
|
|
11
|
-
lines.push(`import path from 'node:path';`);
|
|
12
|
-
lines.push(`import { fileURLToPath } from 'node:url';`);
|
|
13
|
-
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}';`);
|
|
17
|
-
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)), \'..\');');
|
|
20
|
-
return lines.join('\n') + '\n';
|
|
21
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds `eslint.config.js` for the CLI — placeholder flat config.
|
|
3
|
-
*/
|
|
4
|
-
export function buildEslintConfigJs() {
|
|
5
|
-
return [
|
|
6
|
-
'// @clint:begin eslint',
|
|
7
|
-
'// Placeholder ESLint flat config — replaced by codegen when the',
|
|
8
|
-
"// project's lint stack is configured.",
|
|
9
|
-
'export default [];',
|
|
10
|
-
'// @clint:end eslint',
|
|
11
|
-
'',
|
|
12
|
-
].join('\n');
|
|
13
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds `src/framework.gen.ts` — the fully machine-owned half of the
|
|
3
|
-
* typed-binding split. Regenerated on every `init` and `update`; holds the
|
|
4
|
-
* `defineRegistry([...] as const)` call that describes which document models
|
|
5
|
-
* are bound into `framework.ts`'s typed factories.
|
|
6
|
-
*
|
|
7
|
-
* Kept deliberately small: this file exports only `registry` and the
|
|
8
|
-
* `Registry` type. The `createTypes` call lives in `framework.ts` (the
|
|
9
|
-
* user-owned half) so `configSchema` edits stay local and we avoid an import
|
|
10
|
-
* cycle between the two files.
|
|
11
|
-
*
|
|
12
|
-
* Emitted only when Powerhouse is enabled — flat-layout impls have no
|
|
13
|
-
* reactor package to import modules from and bind `createTypes` directly in
|
|
14
|
-
* `framework.ts`. When Powerhouse is on but no `documentTypes` are declared,
|
|
15
|
-
* we still emit this file with an empty `defineRegistry([])` so impl code's
|
|
16
|
-
* `import { registry } from './framework.gen.js'` keeps resolving across
|
|
17
|
-
* regens.
|
|
18
|
-
*/
|
|
19
|
-
import { type ClintProjectSpec } from '../../spec/types.js';
|
|
20
|
-
export declare function buildFrameworkGenTs(spec: ClintProjectSpec): string | null;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds `src/framework.gen.ts` — the fully machine-owned half of the
|
|
3
|
-
* typed-binding split. Regenerated on every `init` and `update`; holds the
|
|
4
|
-
* `defineRegistry([...] as const)` call that describes which document models
|
|
5
|
-
* are bound into `framework.ts`'s typed factories.
|
|
6
|
-
*
|
|
7
|
-
* Kept deliberately small: this file exports only `registry` and the
|
|
8
|
-
* `Registry` type. The `createTypes` call lives in `framework.ts` (the
|
|
9
|
-
* user-owned half) so `configSchema` edits stay local and we avoid an import
|
|
10
|
-
* cycle between the two files.
|
|
11
|
-
*
|
|
12
|
-
* Emitted only when Powerhouse is enabled — flat-layout impls have no
|
|
13
|
-
* reactor package to import modules from and bind `createTypes` directly in
|
|
14
|
-
* `framework.ts`. When Powerhouse is on but no `documentTypes` are declared,
|
|
15
|
-
* we still emit this file with an empty `defineRegistry([])` so impl code's
|
|
16
|
-
* `import { registry } from './framework.gen.js'` keeps resolving across
|
|
17
|
-
* regens.
|
|
18
|
-
*/
|
|
19
|
-
import { getDocumentTypeModuleName, } from '../../spec/types.js';
|
|
20
|
-
/** Local package name of the reactor package for this project. */
|
|
21
|
-
function appPackageName(spec) {
|
|
22
|
-
return `${spec.name}-app`;
|
|
23
|
-
}
|
|
24
|
-
export function buildFrameworkGenTs(spec) {
|
|
25
|
-
if (!spec.features.powerhouse.enabled)
|
|
26
|
-
return null;
|
|
27
|
-
const pkg = appPackageName(spec);
|
|
28
|
-
const entries = spec.documentTypes.map((docType) => ({
|
|
29
|
-
docType,
|
|
30
|
-
name: getDocumentTypeModuleName(docType),
|
|
31
|
-
}));
|
|
32
|
-
const lines = [];
|
|
33
|
-
lines.push('/**');
|
|
34
|
-
lines.push(' * THIS FILE IS GENERATED BY ph-clint-cli. DO NOT EDIT.');
|
|
35
|
-
lines.push(' *');
|
|
36
|
-
lines.push(' * Regenerated on every `ph-clint regen` and on every spec-change');
|
|
37
|
-
lines.push(' * tick. Put custom bindings in `framework.ts`, not here — edits to');
|
|
38
|
-
lines.push(' * this file will be overwritten.');
|
|
39
|
-
lines.push(' */');
|
|
40
|
-
lines.push(`import { defineRegistry } from '@powerhousedao/ph-clint';`);
|
|
41
|
-
for (const e of entries) {
|
|
42
|
-
lines.push(`import { ${e.name} } from '${pkg}';`);
|
|
43
|
-
}
|
|
44
|
-
lines.push('');
|
|
45
|
-
lines.push('/**');
|
|
46
|
-
lines.push(' * Typed document registry derived from the reactor package\'s document models.');
|
|
47
|
-
lines.push(' * Regenerated whenever the spec\'s `documentTypes` list changes.');
|
|
48
|
-
lines.push(' */');
|
|
49
|
-
if (entries.length === 0) {
|
|
50
|
-
lines.push('export const registry = defineRegistry([] as const);');
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
lines.push('export const registry = defineRegistry([');
|
|
54
|
-
for (const e of entries) {
|
|
55
|
-
lines.push(` ${e.name},`);
|
|
56
|
-
}
|
|
57
|
-
lines.push('] as const);');
|
|
58
|
-
}
|
|
59
|
-
lines.push('');
|
|
60
|
-
lines.push('export type Registry = typeof registry;');
|
|
61
|
-
return lines.join('\n') + '\n';
|
|
62
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds `src/framework.ts` — the user-owned half of the typed-binding split.
|
|
3
|
-
*
|
|
4
|
-
* Emitted **only on create**. Once the file exists, codegen never overwrites
|
|
5
|
-
* it: users are expected to extend `configSchema` and `secretsSchema` here,
|
|
6
|
-
* and those edits must survive regens.
|
|
7
|
-
*
|
|
8
|
-
* Behavior differs by layout:
|
|
9
|
-
*
|
|
10
|
-
* - **Powerhouse enabled** — this file declares `configSchema`/`secretsSchema`
|
|
11
|
-
* and re-exports `registry`, `defineCommand`, `defineTrigger`,
|
|
12
|
-
* `defineService`, and `createDocumentChangeTrigger` from the companion
|
|
13
|
-
* `framework.gen.ts`. Adding a document type to the spec regenerates
|
|
14
|
-
* `framework.gen.ts`; this file keeps resolving its re-exports unchanged.
|
|
15
|
-
*
|
|
16
|
-
* - **Powerhouse disabled** — no reactor package exists to register modules
|
|
17
|
-
* against, so this file binds `createTypes({ configSchema })` directly and
|
|
18
|
-
* exports the typed factories from here. No `framework.gen.ts` is emitted.
|
|
19
|
-
*/
|
|
20
|
-
import { type ClintProjectSpec } from '../../spec/types.js';
|
|
21
|
-
export declare function buildFrameworkTs(spec: ClintProjectSpec): string;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
export function buildFrameworkTs(spec) {
|
|
2
|
-
const { mastra, powerhouse } = spec.features;
|
|
3
|
-
const hasGen = powerhouse.enabled;
|
|
4
|
-
const lines = [];
|
|
5
|
-
lines.push('/**');
|
|
6
|
-
lines.push(' * Per-CLI typed framework binding.');
|
|
7
|
-
lines.push(' *');
|
|
8
|
-
lines.push(' * This file is USER-OWNED. ph-clint-cli emits it once at project');
|
|
9
|
-
lines.push(' * creation and never overwrites it afterwards — edit `configSchema`');
|
|
10
|
-
lines.push(' * and `secretsSchema` freely.');
|
|
11
|
-
if (hasGen) {
|
|
12
|
-
lines.push(' *');
|
|
13
|
-
lines.push(' * Typed factories (`defineCommand`, `defineTrigger`, ...) and the');
|
|
14
|
-
lines.push(' * document `registry` come from `framework.gen.ts`, which IS');
|
|
15
|
-
lines.push(' * regenerated whenever the spec\'s `documentTypes` list changes.');
|
|
16
|
-
}
|
|
17
|
-
lines.push(' */');
|
|
18
|
-
lines.push(`import { z } from 'zod';`);
|
|
19
|
-
lines.push(`import { createTypes } from '@powerhousedao/ph-clint';`);
|
|
20
|
-
if (hasGen) {
|
|
21
|
-
lines.push(`import { registry } from './framework.gen.js';`);
|
|
22
|
-
}
|
|
23
|
-
lines.push('');
|
|
24
|
-
lines.push('export const configSchema = z.object({');
|
|
25
|
-
if (mastra.enabled) {
|
|
26
|
-
lines.push(" model: z.string().default('anthropic/claude-haiku-4-5').describe('LLM model to use'),");
|
|
27
|
-
}
|
|
28
|
-
// Ports are derived from CLI name by resolveReactorDefaults() — no config fields needed.
|
|
29
|
-
// Override via switchboard.port / connect.port in configureReactor() if required.
|
|
30
|
-
lines.push(' // Add your own config fields here — this file survives regens.');
|
|
31
|
-
lines.push('});');
|
|
32
|
-
lines.push('');
|
|
33
|
-
lines.push('export const secretsSchema = z.object({');
|
|
34
|
-
if (mastra.enabled) {
|
|
35
|
-
lines.push(" apiKey: z.string().optional().describe('LLM API key'),");
|
|
36
|
-
}
|
|
37
|
-
lines.push('});');
|
|
38
|
-
lines.push('');
|
|
39
|
-
lines.push('export type Config = z.infer<typeof configSchema> &');
|
|
40
|
-
lines.push(' z.infer<typeof secretsSchema>;');
|
|
41
|
-
lines.push('');
|
|
42
|
-
lines.push('const fullConfigSchema = configSchema.merge(secretsSchema);');
|
|
43
|
-
lines.push('');
|
|
44
|
-
if (hasGen) {
|
|
45
|
-
lines.push('export const {');
|
|
46
|
-
lines.push(' defineCommand,');
|
|
47
|
-
lines.push(' defineTrigger,');
|
|
48
|
-
lines.push(' defineService,');
|
|
49
|
-
lines.push(' createDocumentChangeTrigger,');
|
|
50
|
-
lines.push('} = createTypes({');
|
|
51
|
-
lines.push(' configSchema: fullConfigSchema,');
|
|
52
|
-
lines.push(' registry,');
|
|
53
|
-
lines.push('});');
|
|
54
|
-
lines.push('');
|
|
55
|
-
lines.push(`export { registry } from './framework.gen.js';`);
|
|
56
|
-
lines.push(`export type { Registry } from './framework.gen.js';`);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
lines.push('/**');
|
|
60
|
-
lines.push(' * No reactor package — bind `createTypes` directly so');
|
|
61
|
-
lines.push(' * `defineCommand` / `defineTrigger` / `defineService` still pick up');
|
|
62
|
-
lines.push(' * the typed config. Enable `features.powerhouse` in the project spec');
|
|
63
|
-
lines.push(' * and codegen will switch these exports to a registry-backed');
|
|
64
|
-
lines.push(' * `framework.gen.ts`.');
|
|
65
|
-
lines.push(' */');
|
|
66
|
-
lines.push('export const {');
|
|
67
|
-
lines.push(' defineCommand,');
|
|
68
|
-
lines.push(' defineTrigger,');
|
|
69
|
-
lines.push(' defineService,');
|
|
70
|
-
lines.push(' createDocumentChangeTrigger,');
|
|
71
|
-
lines.push('} = createTypes({ configSchema: fullConfigSchema });');
|
|
72
|
-
}
|
|
73
|
-
return lines.join('\n') + '\n';
|
|
74
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds `.gitignore` for the CLI.
|
|
3
|
-
*/
|
|
4
|
-
export function buildGitignore() {
|
|
5
|
-
return [
|
|
6
|
-
'node_modules/',
|
|
7
|
-
'dist/',
|
|
8
|
-
'gen/',
|
|
9
|
-
'.mastra/',
|
|
10
|
-
'.ph/',
|
|
11
|
-
'coverage/',
|
|
12
|
-
'*.tsbuildinfo',
|
|
13
|
-
'*.db',
|
|
14
|
-
'*.db-shm',
|
|
15
|
-
'*.db-wal',
|
|
16
|
-
'',
|
|
17
|
-
].join('\n');
|
|
18
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registry of file builders. Each entry knows its own relative path (within
|
|
3
|
-
* the CLI sub-tree) and a function that builds its content from the spec.
|
|
4
|
-
*
|
|
5
|
-
* Orchestrated by `codegen/index.ts` — it walks this registry, adjusts paths
|
|
6
|
-
* for flat vs split layouts, and writes the files.
|
|
7
|
-
*/
|
|
8
|
-
import { buildCliPackageJson } from './cli-package-json.js';
|
|
9
|
-
import { buildCliTs } from './cli-ts.js';
|
|
10
|
-
import { buildConfigTs } from './config-ts.js';
|
|
11
|
-
import { buildMainTs } from './main-ts.js';
|
|
12
|
-
import { buildTsconfigJson } from './tsconfig-json.js';
|
|
13
|
-
import { buildJestConfigJs } from './jest-config-js.js';
|
|
14
|
-
import { buildEslintConfigJs } from './eslint-config-js.js';
|
|
15
|
-
import { buildGitignore } from './gitignore.js';
|
|
16
|
-
import { buildMastraIndexTs } from './mastra-index-ts.js';
|
|
17
|
-
import { buildBuildSkillsScript } from './build-skills-ts.js';
|
|
18
|
-
import { buildAgentBaseMd } from './agent-base-md.js';
|
|
19
|
-
import { buildAgentTs } from './agent-ts.js';
|
|
20
|
-
import { buildFrameworkGenTs } from './framework-gen-ts.js';
|
|
21
|
-
import { buildFrameworkTs } from './framework-ts.js';
|
|
22
|
-
import { type ClintProjectSpec } from '../../spec/types.js';
|
|
23
|
-
/**
|
|
24
|
-
* A spec-driven file builder. Returns `null` from `build` to indicate the
|
|
25
|
-
* file should not be emitted for the given spec.
|
|
26
|
-
*/
|
|
27
|
-
export interface FileBuilder {
|
|
28
|
-
/** Path relative to the CLI root (flat or `{name}-cli/`). */
|
|
29
|
-
relativePath: string;
|
|
30
|
-
build(spec: ClintProjectSpec): string | null;
|
|
31
|
-
/**
|
|
32
|
-
* When true, this file is only emitted on `mode: 'create'`. In `update`
|
|
33
|
-
* mode the planner ignores the builder entirely, leaving any on-disk
|
|
34
|
-
* version untouched regardless of hash state. Used for files that carry
|
|
35
|
-
* user-owned hand edits (e.g. `src/framework.ts`'s `configSchema`).
|
|
36
|
-
*/
|
|
37
|
-
initOnly?: boolean;
|
|
38
|
-
}
|
|
39
|
-
export declare const CLI_FILE_BUILDERS: FileBuilder[];
|
|
40
|
-
export { buildCliPackageJson, buildCliTs, buildConfigTs, buildMainTs, buildTsconfigJson, buildJestConfigJs, buildEslintConfigJs, buildGitignore, buildMastraIndexTs, buildBuildSkillsScript, buildAgentBaseMd, buildAgentTs, buildFrameworkGenTs, buildFrameworkTs, };
|
|
41
|
-
export { buildRootPackageJson } from './root-package-json.js';
|
|
42
|
-
export { buildReadme } from './readme-md.js';
|
|
43
|
-
export { buildAppIndexTs } from './app-index-ts.js';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registry of file builders. Each entry knows its own relative path (within
|
|
3
|
-
* the CLI sub-tree) and a function that builds its content from the spec.
|
|
4
|
-
*
|
|
5
|
-
* Orchestrated by `codegen/index.ts` — it walks this registry, adjusts paths
|
|
6
|
-
* for flat vs split layouts, and writes the files.
|
|
7
|
-
*/
|
|
8
|
-
import { buildCliPackageJson } from './cli-package-json.js';
|
|
9
|
-
import { buildCliTs } from './cli-ts.js';
|
|
10
|
-
import { buildConfigTs } from './config-ts.js';
|
|
11
|
-
import { buildMainTs } from './main-ts.js';
|
|
12
|
-
import { buildTsconfigJson } from './tsconfig-json.js';
|
|
13
|
-
import { buildJestConfigJs } from './jest-config-js.js';
|
|
14
|
-
import { buildEslintConfigJs } from './eslint-config-js.js';
|
|
15
|
-
import { buildGitignore } from './gitignore.js';
|
|
16
|
-
import { buildMastraIndexTs } from './mastra-index-ts.js';
|
|
17
|
-
import { buildBuildSkillsScript } from './build-skills-ts.js';
|
|
18
|
-
import { buildAgentBaseMd } from './agent-base-md.js';
|
|
19
|
-
import { buildAgentTs } from './agent-ts.js';
|
|
20
|
-
import { buildFrameworkGenTs } from './framework-gen-ts.js';
|
|
21
|
-
import { buildFrameworkTs } from './framework-ts.js';
|
|
22
|
-
export const CLI_FILE_BUILDERS = [
|
|
23
|
-
{ relativePath: 'package.json', build: buildCliPackageJson },
|
|
24
|
-
{ relativePath: 'tsconfig.json', build: () => buildTsconfigJson() },
|
|
25
|
-
{ relativePath: 'jest.config.js', build: () => buildJestConfigJs() },
|
|
26
|
-
{ relativePath: 'eslint.config.js', build: () => buildEslintConfigJs() },
|
|
27
|
-
{ relativePath: '.gitignore', build: () => buildGitignore() },
|
|
28
|
-
{ relativePath: 'src/main.ts', build: () => buildMainTs() },
|
|
29
|
-
{ relativePath: 'src/cli.ts', build: buildCliTs },
|
|
30
|
-
{ relativePath: 'src/config.ts', build: buildConfigTs },
|
|
31
|
-
// User-owned; init-only. Holds `configSchema` + `secretsSchema` edits.
|
|
32
|
-
{ relativePath: 'src/framework.ts', build: buildFrameworkTs, initOnly: true },
|
|
33
|
-
// Machine-owned; regenerated on every run. Null when no document types.
|
|
34
|
-
{ relativePath: 'src/framework.gen.ts', build: buildFrameworkGenTs },
|
|
35
|
-
{ relativePath: 'src/mastra/index.ts', build: buildMastraIndexTs },
|
|
36
|
-
{ relativePath: 'scripts/build-skills.ts', build: () => buildBuildSkillsScript() },
|
|
37
|
-
{ relativePath: 'prompts/agent-profiles/AgentBase.md', build: buildAgentBaseMd },
|
|
38
|
-
{
|
|
39
|
-
relativePath: 'src/agents/agent.ts',
|
|
40
|
-
build: (spec) => (spec.features.mastra.enabled ? buildAgentTs(spec) : null),
|
|
41
|
-
},
|
|
42
|
-
// Gitkeep placeholders so directories are tracked in git when otherwise empty.
|
|
43
|
-
{ relativePath: 'src/commands/.gitkeep', build: () => '' },
|
|
44
|
-
{ relativePath: 'src/services/.gitkeep', build: () => '' },
|
|
45
|
-
{
|
|
46
|
-
relativePath: 'src/triggers/.gitkeep',
|
|
47
|
-
build: (spec) => (spec.features.routine.enabled ? '' : ''),
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
relativePath: 'src/agents/.gitkeep',
|
|
51
|
-
build: (spec) => (spec.features.mastra.enabled ? null : ''),
|
|
52
|
-
},
|
|
53
|
-
{ relativePath: 'prompts/skills-tpl/.gitkeep', build: () => '' },
|
|
54
|
-
{ relativePath: 'prompts/skills-ext/.gitkeep', build: () => '' },
|
|
55
|
-
{ relativePath: 'tests/.gitkeep', build: () => '' },
|
|
56
|
-
];
|
|
57
|
-
export { buildCliPackageJson, buildCliTs, buildConfigTs, buildMainTs, buildTsconfigJson, buildJestConfigJs, buildEslintConfigJs, buildGitignore, buildMastraIndexTs, buildBuildSkillsScript, buildAgentBaseMd, buildAgentTs, buildFrameworkGenTs, buildFrameworkTs, };
|
|
58
|
-
export { buildRootPackageJson } from './root-package-json.js';
|
|
59
|
-
export { buildReadme } from './readme-md.js';
|
|
60
|
-
export { buildAppIndexTs } from './app-index-ts.js';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds `jest.config.js` for the CLI.
|
|
3
|
-
*/
|
|
4
|
-
export function buildJestConfigJs() {
|
|
5
|
-
return [
|
|
6
|
-
"/** @type {import('jest').Config} */",
|
|
7
|
-
'export default {',
|
|
8
|
-
" extensionsToTreatAsEsm: ['.ts'],",
|
|
9
|
-
' transform: {',
|
|
10
|
-
" '^.+\\\\.ts$': ['ts-jest', { useESM: true }],",
|
|
11
|
-
' },',
|
|
12
|
-
' moduleNameMapper: {',
|
|
13
|
-
" '^(\\\\.{1,2}/.*)\\\\.js$': '$1',",
|
|
14
|
-
' },',
|
|
15
|
-
" testMatch: ['**/tests/**/*.test.ts'],",
|
|
16
|
-
'};',
|
|
17
|
-
'',
|
|
18
|
-
].join('\n');
|
|
19
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds `src/main.ts` — the bin entry point. Always identical regardless
|
|
3
|
-
* of feature toggles.
|
|
4
|
-
*/
|
|
5
|
-
export function buildMainTs() {
|
|
6
|
-
return [
|
|
7
|
-
'#!/usr/bin/env node',
|
|
8
|
-
"import { cli } from './cli.js';",
|
|
9
|
-
'',
|
|
10
|
-
'cli.run(process.argv);',
|
|
11
|
-
'',
|
|
12
|
-
].join('\n');
|
|
13
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds `src/mastra/index.ts` — Mastra Studio entry point.
|
|
3
|
-
*
|
|
4
|
-
* When Mastra is off, emit a no-op placeholder so the directory still exists
|
|
5
|
-
* and `mastra dev` fails predictably rather than importing partial code.
|
|
6
|
-
*/
|
|
7
|
-
import { type ClintProjectSpec } from '../../spec/types.js';
|
|
8
|
-
export declare function buildMastraIndexTs(spec: ClintProjectSpec): string;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export function buildMastraIndexTs(spec) {
|
|
2
|
-
const { mastra } = spec.features;
|
|
3
|
-
if (!mastra.enabled) {
|
|
4
|
-
return [
|
|
5
|
-
'/**',
|
|
6
|
-
' * Mastra Studio entry point — placeholder. Enable the `mastra` feature to',
|
|
7
|
-
' * populate this file. Until then `mastra:*` scripts are effectively no-ops.',
|
|
8
|
-
' */',
|
|
9
|
-
'// @clint:begin mastra-index',
|
|
10
|
-
'export {};',
|
|
11
|
-
'// @clint:end mastra-index',
|
|
12
|
-
'',
|
|
13
|
-
].join('\n');
|
|
14
|
-
}
|
|
15
|
-
// When Mastra is enabled but we still emit the demo `AgentProvider` shim
|
|
16
|
-
// (not a real `@mastra/core` Agent), there is no `mastra` export yet —
|
|
17
|
-
// `mastra dev` will surface a helpful message once you wire a real Agent.
|
|
18
|
-
return [
|
|
19
|
-
'/**',
|
|
20
|
-
' * Mastra Studio entry point for `mastra dev` / `mastra build` / `mastra start`.',
|
|
21
|
-
' *',
|
|
22
|
-
" * Re-export a configured `@mastra/core` Mastra instance from here once you",
|
|
23
|
-
" * replace the demo createAgent shim with a real Mastra Agent.",
|
|
24
|
-
' */',
|
|
25
|
-
'// @clint:begin mastra-index',
|
|
26
|
-
'export {};',
|
|
27
|
-
'// @clint:end mastra-index',
|
|
28
|
-
'',
|
|
29
|
-
].join('\n');
|
|
30
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds the project README for a freshly-generated ph-clint project.
|
|
3
|
-
*/
|
|
4
|
-
import { getPackageName, } from '../../spec/types.js';
|
|
5
|
-
export function buildReadme(spec) {
|
|
6
|
-
const { mastra, routine, powerhouse } = spec.features;
|
|
7
|
-
const title = getPackageName(spec);
|
|
8
|
-
const lines = [];
|
|
9
|
-
lines.push(`# ${title}`);
|
|
10
|
-
lines.push('');
|
|
11
|
-
lines.push(spec.description || 'A ph-clint-based project.');
|
|
12
|
-
lines.push('');
|
|
13
|
-
lines.push('## Getting started');
|
|
14
|
-
lines.push('');
|
|
15
|
-
lines.push('```sh');
|
|
16
|
-
lines.push('pnpm install');
|
|
17
|
-
lines.push('pnpm dev');
|
|
18
|
-
lines.push('```');
|
|
19
|
-
lines.push('');
|
|
20
|
-
lines.push('## Enabled features');
|
|
21
|
-
lines.push('');
|
|
22
|
-
lines.push(`- **Powerhouse**: ${powerhouse.enabled ? 'on' : 'off'}`);
|
|
23
|
-
if (powerhouse.enabled) {
|
|
24
|
-
lines.push(` - Switchboard: ${powerhouse.switchboard ? 'on' : 'off'}`);
|
|
25
|
-
lines.push(` - Connect: ${powerhouse.connect ? 'on' : 'off'}`);
|
|
26
|
-
}
|
|
27
|
-
lines.push(`- **Mastra agent**: ${mastra.enabled ? 'on' : 'off'}`);
|
|
28
|
-
lines.push(`- **Routine loop**: ${routine.enabled ? 'on' : 'off'}`);
|
|
29
|
-
lines.push('');
|
|
30
|
-
lines.push('## Regenerate');
|
|
31
|
-
lines.push('');
|
|
32
|
-
lines.push('Toggle features or update metadata in `.ph/ph-clint-cli/project-spec.json`,');
|
|
33
|
-
lines.push('then re-run `ph-clint` to regenerate.');
|
|
34
|
-
lines.push('');
|
|
35
|
-
if (powerhouse.enabled) {
|
|
36
|
-
lines.push('## Split layout');
|
|
37
|
-
lines.push('');
|
|
38
|
-
lines.push(`This project is split into \`${spec.name}-cli/\` (the CLI) and \`${spec.name}-app/\` (the Powerhouse reactor package).`);
|
|
39
|
-
lines.push('');
|
|
40
|
-
lines.push(`Run \`ph init\` inside \`${spec.name}-app/\` to scaffold the reactor package layout (document-models, editors, manifest, etc.).`);
|
|
41
|
-
lines.push('');
|
|
42
|
-
}
|
|
43
|
-
return lines.join('\n');
|
|
44
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds the *root* `package.json` for split-layout projects (Powerhouse
|
|
3
|
-
* enabled). A plain passthrough — deliberately no pnpm workspaces because
|
|
4
|
-
* they interfere with `{name}-app`'s own `pnpm build`.
|
|
5
|
-
*/
|
|
6
|
-
import { type ClintProjectSpec } from '../../spec/types.js';
|
|
7
|
-
export declare function buildRootPackageJson(spec: ClintProjectSpec): string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds the *root* `package.json` for split-layout projects (Powerhouse
|
|
3
|
-
* enabled). A plain passthrough — deliberately no pnpm workspaces because
|
|
4
|
-
* they interfere with `{name}-app`'s own `pnpm build`.
|
|
5
|
-
*/
|
|
6
|
-
import { getPackageName, } from '../../spec/types.js';
|
|
7
|
-
export function buildRootPackageJson(spec) {
|
|
8
|
-
const cli = `${spec.name}-cli`;
|
|
9
|
-
const app = `${spec.name}-app`;
|
|
10
|
-
const pkg = {
|
|
11
|
-
name: getPackageName(spec),
|
|
12
|
-
version: spec.version,
|
|
13
|
-
private: true,
|
|
14
|
-
...(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
|
-
},
|
|
25
|
-
};
|
|
26
|
-
return JSON.stringify(pkg, null, 2) + '\n';
|
|
27
|
-
}
|