@powerhousedao/ph-clint-cli 0.1.0-dev.95 → 0.1.0-dev.97

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 (63) hide show
  1. package/package.json +25 -25
  2. package/dist/codegen/actions.d.ts +0 -46
  3. package/dist/codegen/actions.js +0 -424
  4. package/dist/codegen/builders/agent-base-md.d.ts +0 -5
  5. package/dist/codegen/builders/agent-base-md.js +0 -18
  6. package/dist/codegen/builders/agent-ts.d.ts +0 -9
  7. package/dist/codegen/builders/agent-ts.js +0 -124
  8. package/dist/codegen/builders/app-index-ts.d.ts +0 -11
  9. package/dist/codegen/builders/app-index-ts.js +0 -43
  10. package/dist/codegen/builders/build-skills-ts.d.ts +0 -4
  11. package/dist/codegen/builders/build-skills-ts.js +0 -37
  12. package/dist/codegen/builders/cli-package-json.d.ts +0 -8
  13. package/dist/codegen/builders/cli-package-json.js +0 -128
  14. package/dist/codegen/builders/cli-ts.d.ts +0 -7
  15. package/dist/codegen/builders/cli-ts.js +0 -170
  16. package/dist/codegen/builders/config-ts.d.ts +0 -8
  17. package/dist/codegen/builders/config-ts.js +0 -11
  18. package/dist/codegen/builders/demo-agent-ts.d.ts +0 -8
  19. package/dist/codegen/builders/demo-agent-ts.js +0 -50
  20. package/dist/codegen/builders/eslint-config-js.d.ts +0 -4
  21. package/dist/codegen/builders/eslint-config-js.js +0 -16
  22. package/dist/codegen/builders/framework-gen-ts.d.ts +0 -25
  23. package/dist/codegen/builders/framework-gen-ts.js +0 -114
  24. package/dist/codegen/builders/framework-ts.d.ts +0 -21
  25. package/dist/codegen/builders/framework-ts.js +0 -100
  26. package/dist/codegen/builders/gitignore.d.ts +0 -4
  27. package/dist/codegen/builders/gitignore.js +0 -18
  28. package/dist/codegen/builders/index.d.ts +0 -52
  29. package/dist/codegen/builders/index.js +0 -85
  30. package/dist/codegen/builders/jest-config-js.d.ts +0 -4
  31. package/dist/codegen/builders/jest-config-js.js +0 -19
  32. package/dist/codegen/builders/main-ts.d.ts +0 -5
  33. package/dist/codegen/builders/main-ts.js +0 -13
  34. package/dist/codegen/builders/manifest-json.d.ts +0 -6
  35. package/dist/codegen/builders/manifest-json.js +0 -31
  36. package/dist/codegen/builders/mastra-index-ts.d.ts +0 -11
  37. package/dist/codegen/builders/mastra-index-ts.js +0 -72
  38. package/dist/codegen/builders/publish-config-js.d.ts +0 -8
  39. package/dist/codegen/builders/publish-config-js.js +0 -33
  40. package/dist/codegen/builders/readme-md.d.ts +0 -5
  41. package/dist/codegen/builders/readme-md.js +0 -45
  42. package/dist/codegen/builders/root-package-json.d.ts +0 -10
  43. package/dist/codegen/builders/root-package-json.js +0 -39
  44. package/dist/codegen/builders/smoke-test-ts.d.ts +0 -2
  45. package/dist/codegen/builders/smoke-test-ts.js +0 -15
  46. package/dist/codegen/builders/tsconfig-json.d.ts +0 -4
  47. package/dist/codegen/builders/tsconfig-json.js +0 -22
  48. package/dist/codegen/exec.d.ts +0 -2
  49. package/dist/codegen/exec.js +0 -14
  50. package/dist/codegen/generated.d.ts +0 -17
  51. package/dist/codegen/generated.js +0 -49
  52. package/dist/codegen/hashes.d.ts +0 -6
  53. package/dist/codegen/hashes.js +0 -60
  54. package/dist/codegen/markers.d.ts +0 -36
  55. package/dist/codegen/markers.js +0 -86
  56. package/dist/codegen/migrate/flat-to-split.d.ts +0 -15
  57. package/dist/codegen/migrate/flat-to-split.js +0 -119
  58. package/dist/codegen/scaffold.d.ts +0 -72
  59. package/dist/codegen/scaffold.js +0 -150
  60. package/dist/codegen/write.d.ts +0 -6
  61. package/dist/codegen/write.js +0 -32
  62. package/dist/skills/sync.d.ts +0 -40
  63. package/dist/skills/sync.js +0 -119
@@ -1,25 +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([...])` call that describes which document models
5
- * are bound into `framework.ts`'s typed factories.
6
- *
7
- * Iterates all packages' document types. The app package's modules are
8
- * imported from the local `{name}-app` package; external packages' modules
9
- * are imported from their npm package name.
10
- *
11
- * Document type entries may be explicit IDs (`powerhouse/ph-clint-project`)
12
- * or glob patterns (`*​/*`, `powerhouse/*`, `acme/doc-*`). Explicit IDs
13
- * produce static named imports; glob patterns import the package's
14
- * `documentModels` array and filter at runtime so newly-added document
15
- * models are picked up without a codegen re-run.
16
- *
17
- * Emitted only when Powerhouse is enabled — flat-layout impls have no
18
- * reactor package to import modules from and bind `createTypes` directly in
19
- * `framework.ts`. When Powerhouse is on but no document types are declared,
20
- * we still emit this file with an empty `defineRegistry([])` so impl code's
21
- * `import { registry } from './framework.gen.js'` keeps resolving across
22
- * regens.
23
- */
24
- import { type ClintProjectSpec } from '../../spec/types.js';
25
- export declare function buildFrameworkGenTs(spec: ClintProjectSpec): string | null;
@@ -1,114 +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([...])` call that describes which document models
5
- * are bound into `framework.ts`'s typed factories.
6
- *
7
- * Iterates all packages' document types. The app package's modules are
8
- * imported from the local `{name}-app` package; external packages' modules
9
- * are imported from their npm package name.
10
- *
11
- * Document type entries may be explicit IDs (`powerhouse/ph-clint-project`)
12
- * or glob patterns (`*​/*`, `powerhouse/*`, `acme/doc-*`). Explicit IDs
13
- * produce static named imports; glob patterns import the package's
14
- * `documentModels` array and filter at runtime so newly-added document
15
- * models are picked up without a codegen re-run.
16
- *
17
- * Emitted only when Powerhouse is enabled — flat-layout impls have no
18
- * reactor package to import modules from and bind `createTypes` directly in
19
- * `framework.ts`. When Powerhouse is on but no document types are declared,
20
- * we still emit this file with an empty `defineRegistry([])` so impl code's
21
- * `import { registry } from './framework.gen.js'` keeps resolving across
22
- * regens.
23
- */
24
- import { docTypeGlobToRegex, getAppPackageName, getDocumentTypeModuleName, getDocumentTypeSlug, isDocTypeGlob, phAtLeast, } from '../../spec/types.js';
25
- export function buildFrameworkGenTs(spec) {
26
- if (!phAtLeast(spec.features.powerhouse, 'Reactor'))
27
- return null;
28
- const appPkg = getAppPackageName(spec);
29
- // Collect entries across packages. Each package may contribute both
30
- // explicit named imports and glob-based runtime filters.
31
- const entries = [];
32
- let globCounter = 0;
33
- for (const pkg of spec.packages) {
34
- const isApp = pkg.packageName === appPkg;
35
- // Collect glob patterns for this package (may be multiple).
36
- const globs = pkg.documentTypes.filter(isDocTypeGlob);
37
- const explicits = pkg.documentTypes.filter((dt) => !isDocTypeGlob(dt));
38
- for (const docType of explicits) {
39
- const slug = getDocumentTypeSlug(docType);
40
- entries.push({
41
- kind: 'explicit',
42
- name: getDocumentTypeModuleName(docType),
43
- importFrom: isApp ? appPkg : `${pkg.packageName}/document-models/${slug}`,
44
- });
45
- }
46
- if (globs.length > 0) {
47
- // Merge all globs for this package into a single regex alternation.
48
- const combined = globs.length === 1
49
- ? docTypeGlobToRegex(globs[0])
50
- : globs.map((g) => `(?:${docTypeGlobToRegex(g)})`).join('|');
51
- const alias = globCounter === 0 ? 'globModels' : `globModels${globCounter}`;
52
- globCounter++;
53
- entries.push({
54
- kind: 'glob',
55
- modelsAlias: alias,
56
- importFrom: isApp ? appPkg : pkg.packageName,
57
- regexSource: combined,
58
- });
59
- }
60
- }
61
- const hasGlobs = entries.some((e) => e.kind === 'glob');
62
- const lines = [];
63
- lines.push('/**');
64
- lines.push(' * THIS FILE IS GENERATED BY ph-clint-cli. DO NOT EDIT.');
65
- lines.push(' *');
66
- lines.push(' * Regenerated on every `ph-clint clint-project-regen` and on every spec-change');
67
- lines.push(' * tick. Put custom bindings in `framework.ts`, not here — edits to');
68
- lines.push(' * this file will be overwritten.');
69
- lines.push(' */');
70
- lines.push(`import { defineRegistry } from '@powerhousedao/ph-clint';`);
71
- // Emit imports — named imports for explicit entries, documentModels for globs.
72
- for (const e of entries) {
73
- if (e.kind === 'explicit') {
74
- lines.push(`import { ${e.name} } from '${e.importFrom}';`);
75
- }
76
- else {
77
- lines.push(`import { documentModels as ${e.modelsAlias} } from '${e.importFrom}';`);
78
- }
79
- }
80
- lines.push('');
81
- lines.push('/**');
82
- lines.push(' * Typed document registry derived from the reactor package\'s document models.');
83
- lines.push(' * Regenerated whenever the spec\'s packages or document types change.');
84
- lines.push(' */');
85
- if (entries.length === 0) {
86
- lines.push('export const registry = defineRegistry([] as const);');
87
- }
88
- else if (!hasGlobs) {
89
- // Pure explicit — use `as const` for full type inference.
90
- lines.push('export const registry = defineRegistry([');
91
- for (const e of entries) {
92
- if (e.kind === 'explicit') {
93
- lines.push(` ${e.name},`);
94
- }
95
- }
96
- lines.push('] as const);');
97
- }
98
- else {
99
- // Mix of explicit + glob — runtime filter loses `as const` inference.
100
- lines.push('export const registry = defineRegistry([');
101
- for (const e of entries) {
102
- if (e.kind === 'explicit') {
103
- lines.push(` ${e.name},`);
104
- }
105
- else {
106
- lines.push(` ...${e.modelsAlias}.filter((m) => /${e.regexSource}/.test(m.documentModel.global.id)),`);
107
- }
108
- }
109
- lines.push(']);');
110
- }
111
- lines.push('');
112
- lines.push('export type Registry = typeof registry;');
113
- return lines.join('\n') + '\n';
114
- }
@@ -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,100 +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 { phAtLeast } from '../../spec/types.js';
21
- export function buildFrameworkTs(spec) {
22
- const { mastra, powerhouse } = spec.features;
23
- const hasGen = phAtLeast(powerhouse, 'Reactor');
24
- const lines = [];
25
- lines.push('/**');
26
- lines.push(' * Per-CLI typed framework binding.');
27
- lines.push(' *');
28
- lines.push(' * This file is USER-OWNED. ph-clint-cli emits it once at project');
29
- lines.push(' * creation and never overwrites it afterwards — edit `configSchema`');
30
- lines.push(' * and `secretsSchema` freely.');
31
- if (hasGen) {
32
- lines.push(' *');
33
- lines.push(' * Typed factories (`defineCommand`, `defineTrigger`, ...) and the');
34
- lines.push(' * document `registry` come from `framework.gen.ts`, which IS');
35
- lines.push(' * regenerated whenever the spec\'s `documentTypes` list changes.');
36
- }
37
- lines.push(' */');
38
- lines.push(`import { z } from 'zod';`);
39
- lines.push(`import { createTypes } from '@powerhousedao/ph-clint';`);
40
- if (hasGen) {
41
- lines.push(`import { registry } from './framework.gen.js';`);
42
- }
43
- lines.push('');
44
- lines.push('export const configSchema = z.object({');
45
- lines.push(' // @clint:begin framework-config');
46
- if (mastra.enabled) {
47
- const defaultModel = mastra.models.find(m => m.isDefault)?.id ?? 'anthropic/claude-sonnet-4-5';
48
- lines.push(` model: z.string().default('${defaultModel}').describe('LLM model to use'),`, ` agentLogging: z.boolean().default(false).describe('Enable agent conversation logging'),`);
49
- }
50
- lines.push(' // @clint:end framework-config');
51
- lines.push('});');
52
- lines.push('');
53
- lines.push('export const secretsSchema = z.object({');
54
- lines.push(' // @clint:begin framework-secrets');
55
- if (mastra.enabled) {
56
- const providers = [...new Set(mastra.models.map(m => m.id.split(/[:/]/)[0]))];
57
- for (const provider of providers) {
58
- const field = `${provider}ApiKey`;
59
- lines.push(` ${field}: z.string().optional().describe('${provider} API key'),`);
60
- }
61
- }
62
- lines.push(' // @clint:end framework-secrets');
63
- lines.push('});');
64
- lines.push('');
65
- lines.push('export type Config = z.infer<typeof configSchema> &');
66
- lines.push(' z.infer<typeof secretsSchema>;');
67
- lines.push('');
68
- lines.push('const fullConfigSchema = configSchema.extend(secretsSchema.shape);');
69
- lines.push('');
70
- if (hasGen) {
71
- lines.push('export const {');
72
- lines.push(' defineCommand,');
73
- lines.push(' defineTrigger,');
74
- lines.push(' defineService,');
75
- lines.push(' createDocumentChangeTrigger,');
76
- lines.push('} = createTypes({');
77
- lines.push(' configSchema: fullConfigSchema,');
78
- lines.push(' registry,');
79
- lines.push('});');
80
- lines.push('');
81
- lines.push(`export { registry } from './framework.gen.js';`);
82
- lines.push(`export type { Registry } from './framework.gen.js';`);
83
- }
84
- else {
85
- lines.push('/**');
86
- lines.push(' * No reactor package — bind `createTypes` directly so');
87
- lines.push(' * `defineCommand` / `defineTrigger` / `defineService` still pick up');
88
- lines.push(' * the typed config. Enable `features.powerhouse` in the project spec');
89
- lines.push(' * and codegen will switch these exports to a registry-backed');
90
- lines.push(' * `framework.gen.ts`.');
91
- lines.push(' */');
92
- lines.push('export const {');
93
- lines.push(' defineCommand,');
94
- lines.push(' defineTrigger,');
95
- lines.push(' defineService,');
96
- lines.push(' createDocumentChangeTrigger,');
97
- lines.push('} = createTypes({ configSchema: fullConfigSchema });');
98
- }
99
- return lines.join('\n') + '\n';
100
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Builds `.gitignore` for the CLI.
3
- */
4
- export declare function buildGitignore(): string;
@@ -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,52 +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 { buildDemoAgentTs } from './demo-agent-ts.js';
21
- import { buildFrameworkGenTs } from './framework-gen-ts.js';
22
- import { buildFrameworkTs } from './framework-ts.js';
23
- import { buildManifestJson } from './manifest-json.js';
24
- import { buildSmokeTestTs } from './smoke-test-ts.js';
25
- import { type ClintProjectSpec } from '../../spec/types.js';
26
- /**
27
- * A spec-driven file builder. Returns `null` from `build` to indicate the
28
- * file should not be emitted for the given spec.
29
- */
30
- export interface FileBuilder {
31
- /** Path relative to the CLI root (flat or `{name}-cli/`). */
32
- relativePath: string;
33
- build(spec: ClintProjectSpec): string | null;
34
- /**
35
- * When true, this file is only emitted on `mode: 'create'`. In `update`
36
- * mode the planner ignores the builder entirely, leaving any on-disk
37
- * version untouched regardless of hash state. Used for files that carry
38
- * user-owned hand edits (e.g. `src/framework.ts`'s `configSchema`).
39
- */
40
- initOnly?: boolean;
41
- }
42
- /**
43
- * Generate dynamic file builders for agent profile markdown files.
44
- * One file per profile in `prompts/agent-profiles/{id}.md`.
45
- */
46
- export declare function getProfileFileBuilders(spec: ClintProjectSpec): FileBuilder[];
47
- export declare const CLI_FILE_BUILDERS: FileBuilder[];
48
- export { buildCliPackageJson, buildCliTs, buildConfigTs, buildMainTs, buildTsconfigJson, buildJestConfigJs, buildEslintConfigJs, buildGitignore, buildMastraIndexTs, buildBuildSkillsScript, buildAgentBaseMd, buildAgentTs, buildDemoAgentTs, buildFrameworkGenTs, buildFrameworkTs, buildManifestJson, buildSmokeTestTs, };
49
- export { buildRootPackageJson } from './root-package-json.js';
50
- export { buildPublishConfigJs } from './publish-config-js.js';
51
- export { buildReadme } from './readme-md.js';
52
- export { buildAppIndexTs } from './app-index-ts.js';
@@ -1,85 +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 { buildDemoAgentTs } from './demo-agent-ts.js';
21
- import { buildFrameworkGenTs } from './framework-gen-ts.js';
22
- import { buildFrameworkTs } from './framework-ts.js';
23
- import { buildManifestJson } from './manifest-json.js';
24
- import { buildSmokeTestTs } from './smoke-test-ts.js';
25
- /**
26
- * Generate dynamic file builders for agent profile markdown files.
27
- * One file per profile in `prompts/agent-profiles/{id}.md`.
28
- */
29
- export function getProfileFileBuilders(spec) {
30
- const { mastra } = spec.features;
31
- if (!mastra.enabled || mastra.profiles.length === 0)
32
- return [];
33
- return mastra.profiles.map((profile) => ({
34
- relativePath: `prompts/agent-profiles/${profile.id}.md`,
35
- build: () => profile.content + '\n',
36
- }));
37
- }
38
- export const CLI_FILE_BUILDERS = [
39
- { relativePath: 'powerhouse.manifest.json', build: buildManifestJson },
40
- { relativePath: 'package.json', build: buildCliPackageJson },
41
- { relativePath: 'tsconfig.json', build: () => buildTsconfigJson() },
42
- { relativePath: 'jest.config.js', build: () => buildJestConfigJs() },
43
- { relativePath: 'eslint.config.js', build: () => buildEslintConfigJs() },
44
- { relativePath: '.gitignore', build: () => buildGitignore() },
45
- { relativePath: 'src/main.ts', build: () => buildMainTs() },
46
- { relativePath: 'src/cli.ts', build: buildCliTs },
47
- { relativePath: 'src/config.ts', build: buildConfigTs },
48
- // User-owned outside markers; generated config/secrets inside markers.
49
- { relativePath: 'src/framework.ts', build: buildFrameworkTs },
50
- // Machine-owned; regenerated on every run. Null when no document types.
51
- { relativePath: 'src/framework.gen.ts', build: buildFrameworkGenTs },
52
- { relativePath: 'src/mastra/index.ts', build: buildMastraIndexTs },
53
- { relativePath: 'scripts/build-skills.ts', build: () => buildBuildSkillsScript() },
54
- {
55
- relativePath: 'prompts/agent-profiles/AgentBase.md',
56
- build: (spec) => (spec.features.mastra.profiles.length > 0 ? null : buildAgentBaseMd(spec)),
57
- },
58
- {
59
- relativePath: 'src/agents/agent.ts',
60
- build: (spec) => (spec.features.mastra.enabled ? buildAgentTs(spec) : null),
61
- },
62
- {
63
- relativePath: 'src/agents/demo-agent.ts',
64
- build: buildDemoAgentTs,
65
- },
66
- // Gitkeep placeholders so directories are tracked in git when otherwise empty.
67
- { relativePath: 'src/commands/.gitkeep', build: () => '' },
68
- { relativePath: 'src/services/.gitkeep', build: () => '' },
69
- {
70
- relativePath: 'src/triggers/.gitkeep',
71
- build: (spec) => (spec.features.routine.enabled ? '' : ''),
72
- },
73
- {
74
- relativePath: 'src/agents/.gitkeep',
75
- build: (spec) => (spec.features.mastra.enabled ? null : ''),
76
- },
77
- { relativePath: 'prompts/skills-tpl/.gitkeep', build: () => '' },
78
- { relativePath: 'prompts/skills-ext/.gitkeep', build: () => '' },
79
- { relativePath: 'tests/smoke.test.ts', build: buildSmokeTestTs, initOnly: true },
80
- ];
81
- export { buildCliPackageJson, buildCliTs, buildConfigTs, buildMainTs, buildTsconfigJson, buildJestConfigJs, buildEslintConfigJs, buildGitignore, buildMastraIndexTs, buildBuildSkillsScript, buildAgentBaseMd, buildAgentTs, buildDemoAgentTs, buildFrameworkGenTs, buildFrameworkTs, buildManifestJson, buildSmokeTestTs, };
82
- export { buildRootPackageJson } from './root-package-json.js';
83
- export { buildPublishConfigJs } from './publish-config-js.js';
84
- export { buildReadme } from './readme-md.js';
85
- export { buildAppIndexTs } from './app-index-ts.js';
@@ -1,4 +0,0 @@
1
- /**
2
- * Builds `jest.config.js` for the CLI.
3
- */
4
- export declare function buildJestConfigJs(): string;
@@ -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,5 +0,0 @@
1
- /**
2
- * Builds `src/main.ts` — the bin entry point. Always identical regardless
3
- * of feature toggles.
4
- */
5
- export declare function buildMainTs(): string;
@@ -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,6 +0,0 @@
1
- /**
2
- * Builds `powerhouse.manifest.json` — a machine-readable manifest describing
3
- * the CLI project's capabilities for service discovery and deployment.
4
- */
5
- import { type ClintProjectSpec } from '../../spec/types.js';
6
- export declare function buildManifestJson(spec: ClintProjectSpec): string;
@@ -1,31 +0,0 @@
1
- /**
2
- * Builds `powerhouse.manifest.json` — a machine-readable manifest describing
3
- * the CLI project's capabilities for service discovery and deployment.
4
- */
5
- import { getBinName, getAppPackageName, phAtLeast, } from '../../spec/types.js';
6
- export function buildManifestJson(spec) {
7
- const { mastra, powerhouse } = spec.features;
8
- const agent = mastra.enabled
9
- ? {
10
- id: mastra.agentId ?? spec.name,
11
- name: mastra.agentName ?? spec.name,
12
- description: mastra.agentDescription ?? null,
13
- image: mastra.agentImage ?? null,
14
- models: mastra.models.map((m) => ({ id: m.id, default: m.isDefault })),
15
- }
16
- : false;
17
- const ph = phAtLeast(powerhouse, 'Reactor')
18
- ? {
19
- support: powerhouse,
20
- package: getAppPackageName(spec),
21
- }
22
- : false;
23
- const manifest = {
24
- type: 'clint-project',
25
- features: { agent, powerhouse: ph },
26
- serviceCommand: getBinName(spec),
27
- proxyEnabled: spec.deployment.proxyEnabled,
28
- supportedResources: spec.deployment.supportedResources,
29
- };
30
- return JSON.stringify(manifest, null, 2) + '\n';
31
- }
@@ -1,11 +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
- * When Mastra is on with full agent config, bootstrap the CLI and re-export
8
- * the configured Mastra Agent via `cli.bootstrap()`.
9
- */
10
- import { type ClintProjectSpec } from '../../spec/types.js';
11
- export declare function buildMastraIndexTs(spec: ClintProjectSpec): string;
@@ -1,72 +0,0 @@
1
- /**
2
- * Derive the `{PROVIDER}_API_KEY` env var name from a provider prefix
3
- * (e.g. `anthropic` → `ANTHROPIC_API_KEY`).
4
- */
5
- function getApiKeyEnvVar(provider) {
6
- return `${provider.toUpperCase()}_API_KEY`;
7
- }
8
- export function buildMastraIndexTs(spec) {
9
- const { mastra } = spec.features;
10
- if (!mastra.enabled) {
11
- return [
12
- '// @clint:begin mastra-index',
13
- '/**',
14
- ' * Mastra Studio entry point — placeholder. Enable the `mastra` feature to',
15
- ' * populate this file. Until then `mastra:*` scripts are effectively no-ops.',
16
- ' */',
17
- 'export {};',
18
- '// @clint:end mastra-index',
19
- '',
20
- ].join('\n');
21
- }
22
- // Full agent config available — emit bootstrap-based Mastra instance
23
- if (mastra.agentId && mastra.models.length > 0) {
24
- const providers = [...new Set(mastra.models.map(m => m.id.split(/[:/]/)[0]))];
25
- const lines = [
26
- '// @clint:begin mastra-index',
27
- '/**',
28
- ' * Mastra Studio entry point for `mastra dev` / `mastra build` / `mastra start`.',
29
- ' *',
30
- ' * Bootstraps the CLI to get the configured agent, then exports a Mastra',
31
- ' * instance for Studio integration.',
32
- ' */',
33
- "import { Mastra } from '@mastra/core/mastra';",
34
- "import type { Agent } from '@mastra/core/agent';",
35
- "import path from 'node:path';",
36
- "import { cli } from '../cli.js';",
37
- "import { CLI_ROOT } from '../config.js';",
38
- '',
39
- "// Under `mastra dev`, CLI_ROOT points to .mastra/ (bundler output).",
40
- '// The actual project root is its parent.',
41
- "const projectRoot = path.basename(CLI_ROOT) === '.mastra'",
42
- ' ? path.dirname(CLI_ROOT)',
43
- ' : CLI_ROOT;',
44
- '',
45
- 'const rt = await cli.bootstrap({ workdir: projectRoot });',
46
- '',
47
- ];
48
- // API key env bridge for Studio
49
- lines.push(`// Workaround: Mastra Studio checks process.env for API keys directly.`, `// Bridge the ph-clint resolved keys so Studio's provider detection works.`);
50
- for (const provider of providers) {
51
- const field = `${provider}ApiKey`;
52
- const envVar = getApiKeyEnvVar(provider);
53
- lines.push(`{`, ` const key = rt.config.${field} as string | undefined;`, ` if (key && !process.env.${envVar}) process.env.${envVar} = key;`, `}`);
54
- }
55
- lines.push('');
56
- lines.push('const mastraAgent = await rt.mastraAgent as Agent | undefined;', '', 'export const mastra = new Mastra({', ' agents: mastraAgent ? { [mastraAgent.id]: mastraAgent } : {},', '});', '// @clint:end mastra-index', '');
57
- return lines.join('\n');
58
- }
59
- // Mastra enabled but no full agent config yet — placeholder
60
- return [
61
- '// @clint:begin mastra-index',
62
- '/**',
63
- ' * Mastra Studio entry point for `mastra dev` / `mastra build` / `mastra start`.',
64
- ' *',
65
- " * Re-export a configured `@mastra/core` Mastra instance from here once you",
66
- " * replace the demo createAgent shim with a real Mastra Agent.",
67
- ' */',
68
- 'export {};',
69
- '// @clint:end mastra-index',
70
- '',
71
- ].join('\n');
72
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Builds the root `publish.config.js`.
3
- *
4
- * Split-layout: a lockstep group with both app and cli packages.
5
- * Single-layout: a single-package group at `.`.
6
- */
7
- import { type ClintProjectSpec } from '../../spec/types.js';
8
- export declare function buildPublishConfigJs(spec: ClintProjectSpec): string;
@@ -1,33 +0,0 @@
1
- /**
2
- * Builds the root `publish.config.js`.
3
- *
4
- * Split-layout: a lockstep group with both app and cli packages.
5
- * Single-layout: a single-package group at `.`.
6
- */
7
- import { phAtLeast, getBinName, getAppFolderName, getCliFolderName, } from '../../spec/types.js';
8
- export function buildPublishConfigJs(spec) {
9
- const split = phAtLeast(spec.features.powerhouse, 'Reactor');
10
- // The publish pipeline appends the prerelease suffix (e.g. -dev.0), so we
11
- // only store the base semver (M.m.p) here.
12
- const baseVersion = spec.version.replace(/-.*$/, '');
13
- const binName = getBinName(spec);
14
- const packages = split
15
- ? `[
16
- { path: '${getAppFolderName(spec)}', category: 'app' },
17
- { path: '${getCliFolderName(spec)}', category: 'cli' },
18
- ]`
19
- : `[
20
- { path: '.', category: 'cli' },
21
- ]`;
22
- return `// Publish config — loaded by ph-clint's publish pipeline.
23
- // definePublishConfig is an identity function; a plain export is equivalent.
24
- export default {
25
- groups: {
26
- '${binName}': {
27
- version: '${baseVersion}',
28
- packages: ${packages},
29
- },
30
- },
31
- };
32
- `;
33
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Builds the project README for a freshly-generated ph-clint project.
3
- */
4
- import { type ClintProjectSpec } from '../../spec/types.js';
5
- export declare function buildReadme(spec: ClintProjectSpec): string;