@powerhousedao/ph-clint-cli 0.1.0-dev.6 → 0.1.0-dev.60

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 (101) hide show
  1. package/dist/cli.js +52 -10
  2. package/dist/codegen/actions.d.ts +1 -0
  3. package/dist/codegen/actions.js +1 -0
  4. package/dist/codegen/builders/agent-ts.d.ts +4 -4
  5. package/dist/codegen/builders/agent-ts.js +92 -2
  6. package/dist/codegen/builders/app-index-ts.d.ts +3 -10
  7. package/dist/codegen/builders/app-index-ts.js +30 -20
  8. package/dist/codegen/builders/cli-package-json.d.ts +1 -8
  9. package/dist/codegen/builders/cli-package-json.js +1 -96
  10. package/dist/codegen/builders/cli-ts.js +88 -37
  11. package/dist/codegen/builders/config-ts.d.ts +1 -1
  12. package/dist/codegen/builders/config-ts.js +2 -8
  13. package/dist/codegen/builders/demo-agent-ts.d.ts +8 -0
  14. package/dist/codegen/builders/demo-agent-ts.js +50 -0
  15. package/dist/codegen/builders/eslint-config-js.d.ts +1 -1
  16. package/dist/codegen/builders/eslint-config-js.js +7 -4
  17. package/dist/codegen/builders/framework-gen-ts.d.ts +11 -6
  18. package/dist/codegen/builders/framework-gen-ts.js +73 -21
  19. package/dist/codegen/builders/framework-ts.js +33 -7
  20. package/dist/codegen/builders/index.d.ts +1 -44
  21. package/dist/codegen/builders/index.js +1 -61
  22. package/dist/codegen/builders/manifest-json.d.ts +6 -0
  23. package/dist/codegen/builders/manifest-json.js +31 -0
  24. package/dist/codegen/builders/mastra-index-ts.d.ts +3 -0
  25. package/dist/codegen/builders/mastra-index-ts.js +47 -5
  26. package/dist/codegen/builders/publish-config-js.d.ts +8 -0
  27. package/dist/codegen/builders/publish-config-js.js +33 -0
  28. package/dist/codegen/builders/publish-config-ts.d.ts +4 -2
  29. package/dist/codegen/builders/publish-config-ts.js +25 -11
  30. package/dist/codegen/builders/readme-md.js +7 -6
  31. package/dist/codegen/builders/root-package-json.js +14 -11
  32. package/dist/codegen/builders/smoke-test-ts.d.ts +2 -0
  33. package/dist/codegen/builders/smoke-test-ts.js +15 -0
  34. package/dist/codegen/exec.d.ts +1 -20
  35. package/dist/codegen/exec.js +1 -41
  36. package/dist/codegen/generated.d.ts +1 -0
  37. package/dist/codegen/generated.js +1 -0
  38. package/dist/codegen/hashes.d.ts +1 -6
  39. package/dist/codegen/hashes.js +1 -60
  40. package/dist/codegen/index.d.ts +8 -36
  41. package/dist/codegen/index.js +6 -293
  42. package/dist/codegen/markers.d.ts +1 -36
  43. package/dist/codegen/markers.js +1 -86
  44. package/dist/codegen/scaffold.d.ts +1 -34
  45. package/dist/codegen/scaffold.js +1 -60
  46. package/dist/codegen/write.d.ts +1 -6
  47. package/dist/codegen/write.js +1 -32
  48. package/dist/commands/clint-project-build.d.ts +6 -1
  49. package/dist/commands/clint-project-build.js +11 -28
  50. package/dist/commands/clint-project-init.d.ts +40 -10
  51. package/dist/commands/clint-project-init.js +55 -47
  52. package/dist/commands/clint-project-publish.d.ts +7 -1
  53. package/dist/commands/clint-project-publish.js +6 -4
  54. package/dist/commands/clint-project-regen.d.ts +6 -1
  55. package/dist/commands/clint-project-regen.js +26 -2
  56. package/dist/commands/clint-skills-sync.d.ts +15 -0
  57. package/dist/commands/clint-skills-sync.js +56 -0
  58. package/dist/framework.d.ts +6 -170
  59. package/dist/framework.gen.d.ts +1 -32
  60. package/dist/framework.js +1 -5
  61. package/{prompts/agent-profiles/AgentBase.md → dist/gen/agent-profiles/PhClintDevAgent.md} +1 -1
  62. package/dist/gen/skills/cli-setup/.cli-docs.md +135 -0
  63. package/dist/gen/skills/cli-setup/SKILL.md +125 -0
  64. package/dist/gen/skills/cli-setup/references/00.assess-cli-needs.md +53 -0
  65. package/dist/gen/skills/cli-setup/references/01.define-config-schema.md +78 -0
  66. package/dist/gen/skills/cli-setup/references/02.wire-cli.md +141 -0
  67. package/dist/gen/skills/cli-setup/references/03.add-entrypoint.md +128 -0
  68. package/dist/gen/skills/cli-setup/references/expected-outcome.md +3 -0
  69. package/dist/gen/skills/command-definition/.cli-docs.md +84 -0
  70. package/dist/gen/skills/command-definition/SKILL.md +99 -0
  71. package/dist/gen/skills/command-definition/references/00.assess-requirements.md +58 -0
  72. package/dist/gen/skills/command-definition/references/01.define-schema.md +72 -0
  73. package/dist/gen/skills/command-definition/references/02.implement-execute.md +118 -0
  74. package/dist/gen/skills/command-definition/references/03.add-prompting.md +54 -0
  75. package/dist/gen/skills/command-definition/references/expected-outcome.md +3 -0
  76. package/dist/gen/skills/service-definition/.cli-docs.md +214 -0
  77. package/dist/gen/skills/service-definition/SKILL.md +148 -0
  78. package/dist/gen/skills/service-definition/references/00.assess-service.md +69 -0
  79. package/dist/gen/skills/service-definition/references/01.define-service.md +166 -0
  80. package/dist/gen/skills/service-definition/references/02.add-preflight.md +132 -0
  81. package/dist/gen/skills/service-definition/references/03.add-project-scanner.md +82 -0
  82. package/dist/gen/skills/service-definition/references/04.wire-events.md +120 -0
  83. package/dist/gen/skills/service-definition/references/expected-outcome.md +3 -0
  84. package/dist/services/clint-project.js +21 -0
  85. package/dist/skills/sync.d.ts +1 -0
  86. package/dist/skills/sync.js +1 -0
  87. package/dist/spec/ensure-document.d.ts +17 -0
  88. package/dist/spec/ensure-document.js +56 -0
  89. package/dist/spec/file.d.ts +1 -4
  90. package/dist/spec/file.js +1 -34
  91. package/dist/spec/from-document.d.ts +4 -1
  92. package/dist/spec/from-document.js +4 -16
  93. package/dist/spec/types.d.ts +1 -62
  94. package/dist/spec/types.js +1 -112
  95. package/dist/triggers/publish-trigger.d.ts +10 -0
  96. package/dist/triggers/publish-trigger.js +133 -0
  97. package/dist/triggers/spec-change.d.ts +5 -34
  98. package/dist/triggers/spec-change.js +137 -102
  99. package/package.json +12 -12
  100. package/prompts/skills-ext/.gitkeep +0 -0
  101. package/prompts/skills-tpl/.gitkeep +0 -0
@@ -1,36 +1 @@
1
- /**
2
- * Marker-region parsing for `@clint:begin {name}` / `@clint:end {name}`
3
- * comment blocks. Used in delta mode to splice freshly-generated regions
4
- * into an existing, user-edited file while preserving everything outside
5
- * the markers.
6
- *
7
- * The only syntactic requirement is that the markers are on their own lines,
8
- * as ordinary line comments (`//`). Indentation is preserved for output.
9
- */
10
- export interface MarkerRegion {
11
- /** Region identifier (the text after `@clint:begin`). */
12
- name: string;
13
- /** Lines *between* the begin and end markers (exclusive). */
14
- body: string[];
15
- /** Indentation of the begin line — used when rewriting. */
16
- indent: string;
17
- /** Line index of the begin marker in the source. */
18
- beginLine: number;
19
- /** Line index of the end marker in the source. */
20
- endLine: number;
21
- }
22
- /**
23
- * Parse every `@clint:begin {name}` … `@clint:end {name}` block in `source`.
24
- * Throws if markers are mismatched or unclosed.
25
- */
26
- export declare function parseMarkerRegions(source: string): MarkerRegion[];
27
- /**
28
- * Replace every region in `target` that also exists in `source` with the
29
- * `source` region's body. Leaves regions present in `target` but not `source`
30
- * untouched. Ignores regions in `source` missing from `target`.
31
- *
32
- * Returns the rewritten file content.
33
- */
34
- export declare function spliceMarkerRegions(target: string, source: string): string;
35
- /** Convenience — true if `content` contains at least one `@clint:begin`. */
36
- export declare function hasMarkers(content: string): boolean;
1
+ export { type MarkerRegion, parseMarkerRegions, spliceMarkerRegions, hasMarkers, } from '@powerhousedao/ph-clint-dev/codegen/markers';
@@ -1,86 +1 @@
1
- /**
2
- * Marker-region parsing for `@clint:begin {name}` / `@clint:end {name}`
3
- * comment blocks. Used in delta mode to splice freshly-generated regions
4
- * into an existing, user-edited file while preserving everything outside
5
- * the markers.
6
- *
7
- * The only syntactic requirement is that the markers are on their own lines,
8
- * as ordinary line comments (`//`). Indentation is preserved for output.
9
- */
10
- const BEGIN_RE = /^([ \t]*)\/\/\s*@clint:begin\s+(\S+)\s*$/;
11
- const END_RE = /^([ \t]*)\/\/\s*@clint:end\s+(\S+)\s*$/;
12
- /**
13
- * Parse every `@clint:begin {name}` … `@clint:end {name}` block in `source`.
14
- * Throws if markers are mismatched or unclosed.
15
- */
16
- export function parseMarkerRegions(source) {
17
- const lines = source.split('\n');
18
- const regions = [];
19
- let open = null;
20
- let bodyStart = 0;
21
- for (let i = 0; i < lines.length; i++) {
22
- const line = lines[i];
23
- const begin = BEGIN_RE.exec(line);
24
- if (begin) {
25
- if (open) {
26
- throw new Error(`nested @clint:begin ${begin[2]} at line ${i + 1} while ${open.name} is still open`);
27
- }
28
- open = { name: begin[2], indent: begin[1], beginLine: i };
29
- bodyStart = i + 1;
30
- continue;
31
- }
32
- const end = END_RE.exec(line);
33
- if (end) {
34
- if (!open) {
35
- throw new Error(`@clint:end ${end[2]} at line ${i + 1} without matching begin`);
36
- }
37
- if (open.name !== end[2]) {
38
- throw new Error(`@clint:end ${end[2]} at line ${i + 1} does not match open @clint:begin ${open.name}`);
39
- }
40
- regions.push({
41
- name: open.name,
42
- body: lines.slice(bodyStart, i),
43
- indent: open.indent,
44
- beginLine: open.beginLine,
45
- endLine: i,
46
- });
47
- open = null;
48
- }
49
- }
50
- if (open) {
51
- throw new Error(`unterminated @clint:begin ${open.name}`);
52
- }
53
- return regions;
54
- }
55
- /**
56
- * Replace every region in `target` that also exists in `source` with the
57
- * `source` region's body. Leaves regions present in `target` but not `source`
58
- * untouched. Ignores regions in `source` missing from `target`.
59
- *
60
- * Returns the rewritten file content.
61
- */
62
- export function spliceMarkerRegions(target, source) {
63
- const sourceRegions = parseMarkerRegions(source);
64
- const sourceByName = new Map();
65
- for (const r of sourceRegions)
66
- sourceByName.set(r.name, r);
67
- const targetRegions = parseMarkerRegions(target);
68
- if (targetRegions.length === 0)
69
- return target;
70
- const lines = target.split('\n');
71
- // Apply replacements from last to first so line indices stay valid.
72
- const sorted = [...targetRegions].sort((a, b) => b.beginLine - a.beginLine);
73
- for (const region of sorted) {
74
- const fresh = sourceByName.get(region.name);
75
- if (!fresh)
76
- continue;
77
- // Replace the body lines (exclusive of the begin/end marker lines).
78
- const bodyLen = region.endLine - region.beginLine - 1;
79
- lines.splice(region.beginLine + 1, bodyLen, ...fresh.body);
80
- }
81
- return lines.join('\n');
82
- }
83
- /** Convenience — true if `content` contains at least one `@clint:begin`. */
84
- export function hasMarkers(content) {
85
- return /^[ \t]*\/\/\s*@clint:begin\s+\S+\s*$/m.test(content);
86
- }
1
+ export { parseMarkerRegions, spliceMarkerRegions, hasMarkers, } from '@powerhousedao/ph-clint-dev/codegen/markers';
@@ -1,34 +1 @@
1
- import type { ClintProjectSpec } from '../spec/types.js';
2
- export interface PhInitOptions {
3
- /** Absolute path to the project root. */
4
- targetDir: string;
5
- /** Absolute path to `{targetDir}/{name}-app` (exists with our placeholder). */
6
- appDir: string;
7
- spec: ClintProjectSpec;
8
- /** Logger; defaults to noop. */
9
- log?: (msg: string) => void;
10
- /** Override `ph` binary name (for tests). */
11
- binName?: string;
12
- /** Stdio passthrough (tests pass 'ignore'). */
13
- stdio?: 'inherit' | 'ignore';
14
- }
15
- export interface PhInitResult {
16
- ran: boolean;
17
- exitCode?: number;
18
- reason?: string;
19
- }
20
- export declare function runPhInit(options: PhInitOptions): Promise<PhInitResult>;
21
- export interface PnpmInstallOptions {
22
- /** Directories to run `pnpm install` in, in order. */
23
- dirs: string[];
24
- log?: (msg: string) => void;
25
- /** Override `pnpm` binary name (for tests). */
26
- binName?: string;
27
- stdio?: 'inherit' | 'ignore';
28
- }
29
- export interface PnpmInstallResult {
30
- ran: string[];
31
- skipped: string[];
32
- reason?: string;
33
- }
34
- export declare function runPnpmInstall(options: PnpmInstallOptions): Promise<PnpmInstallResult>;
1
+ export { type RunProcess, type PhInitOptions, type PhInitResult, getPhVersion, runPhInit, patchAppPackageName, type PnpmInstallOptions, type PnpmInstallResult, runPnpmInstall, runPhInstallPackages, } from '@powerhousedao/ph-clint-dev/codegen/scaffold';
@@ -1,60 +1 @@
1
- /**
2
- * Post-generation side-effects: invoke `ph init` to fill in the reactor
3
- * package skeleton, and run `pnpm install` in the relevant sub-projects.
4
- *
5
- * Both steps are opt-out (flags on the init command) and both tolerate
6
- * missing binaries — they never fail the init flow, only emit warnings.
7
- */
8
- import fs from 'node:fs/promises';
9
- import path from 'node:path';
10
- import { hasCommandOnPath, runCommand } from './exec.js';
11
- export async function runPhInit(options) {
12
- const log = options.log ?? (() => { });
13
- const binName = options.binName ?? 'ph';
14
- const appFolder = path.basename(options.appDir);
15
- if (!(await hasCommandOnPath(binName))) {
16
- log(`Skipping \`${binName} init\` — \`${binName}\` is not on PATH. ` +
17
- `Install @powerhousedao/ph-cli and re-run manually inside ${appFolder}/.`);
18
- return { ran: false, reason: 'ph-not-on-path' };
19
- }
20
- // `ph init {name}` creates a fresh directory beside the cwd. Our generator
21
- // placed a `.gitkeep` + README.md placeholder there; clear it out so
22
- // ph init has a blank slate to work with.
23
- await fs.rm(options.appDir, { recursive: true, force: true });
24
- log(`Running \`${binName} init ${appFolder}\` in ${options.targetDir} …`);
25
- const result = await runCommand(binName, [
26
- 'init',
27
- appFolder,
28
- '--pnpm',
29
- '--dev',
30
- ], { cwd: options.targetDir, stdio: options.stdio ?? 'inherit' });
31
- if (result.exitCode !== 0) {
32
- log(`\`${binName} init\` exited with code ${result.exitCode}. ` +
33
- 'You can re-run it manually after resolving the issue.');
34
- }
35
- return { ran: true, exitCode: result.exitCode };
36
- }
37
- export async function runPnpmInstall(options) {
38
- const log = options.log ?? (() => { });
39
- const binName = options.binName ?? 'pnpm';
40
- if (!(await hasCommandOnPath(binName))) {
41
- log(`Skipping \`${binName} install\` — \`${binName}\` is not on PATH. ` +
42
- 'Install pnpm and re-run manually.');
43
- return { ran: [], skipped: options.dirs, reason: 'pnpm-not-on-path' };
44
- }
45
- const ran = [];
46
- for (const dir of options.dirs) {
47
- log(`Running \`${binName} install\` in ${dir} …`);
48
- const result = await runCommand(binName, ['install'], {
49
- cwd: dir,
50
- stdio: options.stdio ?? 'inherit',
51
- });
52
- if (result.exitCode !== 0) {
53
- log(`\`${binName} install\` exited with code ${result.exitCode} in ${dir}. ` +
54
- 'Retry manually once the underlying issue is resolved.');
55
- // Don't abort the whole chain — subsequent dirs may still work.
56
- }
57
- ran.push(dir);
58
- }
59
- return { ran, skipped: [] };
60
- }
1
+ export { getPhVersion, runPhInit, patchAppPackageName, runPnpmInstall, runPhInstallPackages, } from '@powerhousedao/ph-clint-dev/codegen/scaffold';
@@ -1,6 +1 @@
1
- export declare function writeFileEnsuringDir(filePath: string, content: string): Promise<void>;
2
- /**
3
- * Returns true if the directory doesn't exist or only contains ignorable
4
- * entries (`.git`, `.DS_Store`, `.ph/ph-clint-cli/project-spec.json`).
5
- */
6
- export declare function isDirEmptyEnough(dir: string): Promise<boolean>;
1
+ export { writeFileEnsuringDir, isDirEmptyEnough, } from '@powerhousedao/ph-clint-dev/codegen/write';
@@ -1,32 +1 @@
1
- /**
2
- * Low-level file-writing helpers for the code generator.
3
- */
4
- import fs from 'node:fs/promises';
5
- import path from 'node:path';
6
- export async function writeFileEnsuringDir(filePath, content) {
7
- await fs.mkdir(path.dirname(filePath), { recursive: true });
8
- await fs.writeFile(filePath, content, 'utf8');
9
- }
10
- function isEnoent(err) {
11
- return (!!err &&
12
- typeof err === 'object' &&
13
- 'code' in err &&
14
- err.code === 'ENOENT');
15
- }
16
- /**
17
- * Returns true if the directory doesn't exist or only contains ignorable
18
- * entries (`.git`, `.DS_Store`, `.ph/ph-clint-cli/project-spec.json`).
19
- */
20
- export async function isDirEmptyEnough(dir) {
21
- let entries;
22
- try {
23
- entries = await fs.readdir(dir);
24
- }
25
- catch (err) {
26
- if (isEnoent(err))
27
- return true;
28
- throw err;
29
- }
30
- const ignorable = new Set(['.git', '.DS_Store', '.ph']);
31
- return entries.every((entry) => ignorable.has(entry));
32
- }
1
+ export { writeFileEnsuringDir, isDirEmptyEnough, } from '@powerhousedao/ph-clint-dev/codegen/write';
@@ -4,4 +4,9 @@ export declare const build: import("@powerhousedao/ph-clint").Command<z.ZodObjec
4
4
  verbose: z.ZodDefault<z.ZodBoolean>;
5
5
  }, z.core.$strip>, {
6
6
  text: string;
7
- }, Record<string, unknown>>;
7
+ }, {
8
+ model: string;
9
+ devServicePort: number;
10
+ phVersion: string;
11
+ apiKey?: string | undefined;
12
+ }, import("@powerhousedao/ph-clint").InferRegistry<readonly [import("document-model").DocumentModelModule<import("@powerhousedao/ph-clint-app").PhClintProjectPHState>]>>;
@@ -1,50 +1,33 @@
1
1
  import path from 'node:path';
2
- import { spawn } from 'node:child_process';
3
- import { defineCommand } from '@powerhousedao/ph-clint';
2
+ import { defineCommand } from '../framework.js';
4
3
  import { z } from 'zod';
5
4
  import { detectLayout } from '@powerhousedao/ph-clint-dev';
6
5
  const inputSchema = z.object({
7
6
  dir: z.string().optional().describe('Project root directory (default: cwd)'),
8
7
  verbose: z.boolean().default(false),
9
8
  });
10
- function execInDir(dir, cmd, verbose) {
11
- return new Promise((resolve, reject) => {
12
- const proc = spawn(cmd, {
13
- cwd: dir,
14
- shell: true,
15
- stdio: verbose ? 'inherit' : 'pipe',
16
- });
17
- let stderr = '';
18
- if (!verbose && proc.stderr) {
19
- proc.stderr.on('data', (data) => {
20
- stderr += data.toString();
21
- });
22
- }
23
- proc.on('close', (code) => {
24
- if (code === 0)
25
- resolve();
26
- else
27
- reject(new Error(`Command "${cmd}" failed in ${dir} (exit ${code})${stderr ? `:\n${stderr}` : ''}`));
28
- });
29
- proc.on('error', (err) => reject(err));
30
- });
31
- }
32
9
  export const build = defineCommand({
33
10
  id: 'clint-project-build',
34
11
  description: 'Build all packages in the project',
35
12
  inputSchema,
36
- execute: async (input, { workdir, stdout }) => {
13
+ execute: async (input, { workdir, stdout, runProcess }) => {
37
14
  const dir = path.resolve(input.dir ?? workdir);
38
15
  const layout = detectLayout(dir);
39
16
  if (layout?.type === 'split') {
40
17
  stdout(`Building app package (${layout.app})...\n`);
41
- await execInDir(layout.app, 'pnpm build', input.verbose);
18
+ const appResult = await runProcess('pnpm build', { cwd: layout.app, timeout: 120_000 });
19
+ if (!appResult.success)
20
+ return { text: `App build failed.` };
42
21
  stdout(`Building cli package (${layout.cli})...\n`);
43
- await execInDir(layout.cli, 'pnpm build', input.verbose);
22
+ const cliResult = await runProcess('pnpm build', { cwd: layout.cli, timeout: 120_000 });
23
+ if (!cliResult.success)
24
+ return { text: `CLI build failed.` };
44
25
  }
45
26
  else {
46
27
  stdout(`Building project...\n`);
47
- await execInDir(layout?.cli ?? dir, 'pnpm build', input.verbose);
28
+ const result = await runProcess('pnpm build', { cwd: layout?.cli ?? dir, timeout: 120_000 });
29
+ if (!result.success)
30
+ return { text: `Build failed.` };
48
31
  }
49
32
  return { text: 'Build complete.' };
50
33
  },
@@ -8,7 +8,6 @@ declare const inputSchema: z.ZodObject<{
8
8
  enableMastra: z.ZodDefault<z.ZodBoolean>;
9
9
  enableRoutine: z.ZodDefault<z.ZodBoolean>;
10
10
  force: z.ZodDefault<z.ZodBoolean>;
11
- skipPhInit: z.ZodDefault<z.ZodBoolean>;
12
11
  skipInstall: z.ZodDefault<z.ZodBoolean>;
13
12
  }, z.core.$strip>;
14
13
  type InitInput = z.output<typeof inputSchema>;
@@ -21,7 +20,6 @@ export declare const init: import("@powerhousedao/ph-clint").Command<z.ZodObject
21
20
  enableMastra: z.ZodDefault<z.ZodBoolean>;
22
21
  enableRoutine: z.ZodDefault<z.ZodBoolean>;
23
22
  force: z.ZodDefault<z.ZodBoolean>;
24
- skipPhInit: z.ZodDefault<z.ZodBoolean>;
25
23
  skipInstall: z.ZodDefault<z.ZodBoolean>;
26
24
  }, z.core.$strip>, {
27
25
  text: string;
@@ -35,23 +33,55 @@ export declare const init: import("@powerhousedao/ph-clint").Command<z.ZodObject
35
33
  version: string;
36
34
  description: string;
37
35
  features: {
38
- powerhouse: {
39
- enabled: boolean;
40
- switchboard: boolean;
41
- connect: boolean;
42
- };
36
+ powerhouse: "Disabled" | "Reactor" | "Switchboard" | "Connect";
43
37
  mastra: {
44
38
  enabled: boolean;
39
+ agentId: string | null;
40
+ agentName: string | null;
41
+ agentDescription: string | null;
42
+ agentImage: string | null;
43
+ models: {
44
+ id: string;
45
+ isDefault: boolean;
46
+ }[];
47
+ profiles: {
48
+ id: string;
49
+ title: string;
50
+ content: string;
51
+ }[];
52
+ common: {
53
+ enableChat: boolean;
54
+ };
45
55
  };
46
56
  routine: {
47
57
  enabled: boolean;
48
58
  };
49
59
  };
50
- documentTypes: string[];
60
+ packages: {
61
+ id: string;
62
+ packageName: string;
63
+ documentTypes: string[];
64
+ version: string | null;
65
+ }[];
66
+ externalSkills: {
67
+ id: string;
68
+ name: string;
69
+ githubUrl: string;
70
+ }[];
71
+ deployment: {
72
+ proxyEnabled: boolean;
73
+ supportedResources: string[];
74
+ };
51
75
  scope?: string | undefined;
52
- bin?: string | undefined;
76
+ documentId?: string | undefined;
77
+ documentType?: string | undefined;
53
78
  };
54
79
  fileCount: number;
55
80
  };
56
- }, Record<string, unknown>>;
81
+ }, {
82
+ model: string;
83
+ devServicePort: number;
84
+ phVersion: string;
85
+ apiKey?: string | undefined;
86
+ }, import("@powerhousedao/ph-clint").InferRegistry<readonly [import("document-model").DocumentModelModule<import("@powerhousedao/ph-clint-app").PhClintProjectPHState>]>>;
57
87
  export {};
@@ -2,27 +2,28 @@
2
2
  * `ph-clint clint-project-init` — the project bootstrap wizard.
3
3
  *
4
4
  * Behavior:
5
- * 1. Resolve target dir (positional `dir`, defaults to cwd).
5
+ * 1. Resolve target dir (positional `dir`, defaults to the project name).
6
6
  * 2. Assert it is empty (or `--force`).
7
7
  * 3. Collect project identity + feature toggles (prompt for missing).
8
8
  * 4. Assemble a ClintProjectSpec and validate with Zod.
9
9
  * 5. Write the spec + emit the generated tree via `generateProject`.
10
- * 6. (Split layout) run `ph init` in `{name}-app/` unless `--skip-ph-init`.
10
+ * 6. (Split layout) run `ph init` in `{name}-app/`.
11
11
  * 7. Run `pnpm install` in generated sub-projects unless `--skip-install`.
12
12
  * 8. Print next-steps guidance.
13
13
  */
14
14
  import path from 'node:path';
15
- import { defineCommand } from '@powerhousedao/ph-clint';
15
+ import { defineCommand } from '../framework.js';
16
16
  import { z } from 'zod';
17
17
  import { clintProjectSpecSchema, } from '../spec/types.js';
18
18
  import { generateProject } from '../codegen/index.js';
19
- import { isDirEmptyEnough } from '../codegen/write.js';
20
- import { runPhInit, runPnpmInstall } from '../codegen/scaffold.js';
19
+ import { isDirEmptyEnough } from '@powerhousedao/ph-clint-dev/codegen/write';
20
+ import { runPostGenActions } from '@powerhousedao/ph-clint-dev/codegen/actions';
21
+ import { ensureSpecDocument } from '../spec/ensure-document.js';
21
22
  const inputSchema = z.object({
22
23
  dir: z
23
24
  .string()
24
25
  .optional()
25
- .describe('Target directory (defaults to the current directory)'),
26
+ .describe('Target directory (defaults to the project name)'),
26
27
  name: z
27
28
  .string()
28
29
  .describe('Project name — bare, or `@scope/name`. Lowercase letters, digits, hyphens.'),
@@ -43,40 +44,49 @@ const inputSchema = z.object({
43
44
  .boolean()
44
45
  .default(false)
45
46
  .describe('Overwrite files if the target directory is not empty'),
46
- skipPhInit: z
47
- .boolean()
48
- .default(false)
49
- .describe('Do not run `ph init` in the app folder after scaffolding'),
50
47
  skipInstall: z
51
48
  .boolean()
52
49
  .default(false)
53
50
  .describe('Do not run `pnpm install` after scaffolding'),
54
51
  });
55
- /** Parse `@scope/name` into { scope, name }. */
52
+ /** Parse `@scope/name` into { scope, name }. Auto-appends `-cli` if missing. */
56
53
  function splitPackageName(raw) {
57
54
  const match = /^@([a-z0-9][a-z0-9-]*)\/([a-z0-9][a-z0-9-]*)$/.exec(raw);
58
- if (match)
59
- return { scope: match[1], name: match[2] };
55
+ if (match) {
56
+ const name = match[2].endsWith('-cli') ? match[2] : `${match[2]}-cli`;
57
+ return { scope: `@${match[1]}`, name };
58
+ }
60
59
  if (raw.startsWith('@')) {
61
60
  throw new Error(`invalid package name "${raw}" — expected "@scope/name" with lowercase letters, digits, hyphens`);
62
61
  }
63
62
  if (!/^[a-z0-9][a-z0-9-]*$/.test(raw)) {
64
63
  throw new Error(`invalid project name "${raw}" — expected lowercase letters, digits, hyphens`);
65
64
  }
66
- return { name: raw };
65
+ const name = raw.endsWith('-cli') ? raw : `${raw}-cli`;
66
+ return { name };
67
67
  }
68
68
  export function buildSpec(input) {
69
69
  const { scope, name } = splitPackageName(input.name);
70
70
  // Routine is forced on when Mastra is on — the REPL-only path works, but
71
71
  // the agent routine loop is what most users actually want.
72
72
  const routine = input.enableRoutine || input.enableMastra;
73
+ const baseName = name.replace(/-cli$/, '');
74
+ const mastra = input.enableMastra
75
+ ? {
76
+ enabled: true,
77
+ agentId: `${baseName}-agent`,
78
+ agentName: `${baseName.charAt(0).toUpperCase()}${baseName.slice(1).replace(/-(\w)/g, (_, c) => ' ' + c.toUpperCase())} Agent`,
79
+ models: [{ id: 'anthropic/claude-sonnet-4-5', isDefault: true }],
80
+ profiles: [{ id: 'base', title: 'Base', content: 'You are a helpful assistant.' }],
81
+ }
82
+ : { enabled: false };
73
83
  const candidate = {
74
84
  name,
75
85
  scope,
76
86
  description: input.description ?? '',
77
87
  features: {
78
- powerhouse: { enabled: input.enablePowerhouse },
79
- mastra: { enabled: input.enableMastra },
88
+ powerhouse: input.enablePowerhouse ? 'Connect' : 'Disabled',
89
+ mastra,
80
90
  routine: { enabled: routine },
81
91
  },
82
92
  };
@@ -90,8 +100,9 @@ export const init = defineCommand({
90
100
  promptForDefaults: true,
91
101
  promptOptional: ['description'],
92
102
  },
93
- execute: async (input, { workdir, stdout }) => {
94
- const targetDir = path.resolve(workdir, input.dir ?? '.');
103
+ execute: async (input, { workdir, stdout, reactor: getReactor, folders, runProcess }) => {
104
+ const { name: bareName } = splitPackageName(input.name);
105
+ const targetDir = path.resolve(workdir, input.dir ?? bareName);
95
106
  if (!input.force) {
96
107
  const empty = await isDirEmptyEnough(targetDir);
97
108
  if (!empty) {
@@ -109,44 +120,41 @@ export const init = defineCommand({
109
120
  allowNonEmpty: input.force,
110
121
  });
111
122
  stdout(`Generated ${result.files.length} files in ${targetDir}\n`);
112
- const split = spec.features.powerhouse.enabled;
113
- // Reactor package scaffolding (split layout only).
114
- if (split && result.appDir && !input.skipPhInit) {
115
- const phResult = await runPhInit({
116
- targetDir,
117
- appDir: result.appDir,
118
- spec,
119
- log: (msg) => stdout(msg + '\n'),
120
- });
121
- if (!phResult.ran) {
122
- stdout(`Note: \`ph init\` did not run — ${phResult.reason ?? 'see above'}.\n`);
123
+ // Create spec document in personal drive (if reactor available)
124
+ if (getReactor && folders) {
125
+ try {
126
+ const reactor = await getReactor();
127
+ if (reactor) {
128
+ const { docId } = await ensureSpecDocument({
129
+ spec, targetDir, reactor, folders,
130
+ });
131
+ stdout(`Created spec document ${docId} in Clint Folders/specs/${spec.name}\n`);
132
+ }
123
133
  }
124
- }
125
- // Dependency installation.
126
- if (!input.skipInstall) {
127
- const dirs = [];
128
- if (split) {
129
- if (result.appDir)
130
- dirs.push(result.appDir);
131
- dirs.push(result.cliDir);
134
+ catch (err) {
135
+ // Non-fatal — trigger will pick it up on next startup
136
+ stdout(`Note: could not create spec document — ${err instanceof Error ? err.message : String(err)}\n`);
132
137
  }
133
- else {
134
- dirs.push(targetDir);
135
- }
136
- await runPnpmInstall({
137
- dirs,
138
- log: (msg) => stdout(msg + '\n'),
139
- });
140
138
  }
139
+ // Run post-generation actions (ph-init, install, build, skills-sync).
140
+ // Only skip cli-install — in split layout, ph-init handles app install
141
+ // internally, and app-build must still run so the CLI can link to it.
142
+ const skip = new Set();
143
+ if (input.skipInstall) {
144
+ skip.add('cli-install');
145
+ }
146
+ await runPostGenActions(result.pendingActions, {
147
+ log: (msg) => stdout(msg + '\n'),
148
+ runProcess,
149
+ skip,
150
+ });
151
+ const split = spec.features.powerhouse !== 'Disabled';
141
152
  const next = [];
142
153
  next.push('');
143
154
  next.push('Next steps:');
144
155
  const relDir = path.relative(workdir, targetDir) || '.';
145
156
  if (split) {
146
157
  next.push(` cd ${relDir}`);
147
- if (input.skipPhInit) {
148
- next.push(` cd ${spec.name}-app && ph init . && cd ..`);
149
- }
150
158
  if (input.skipInstall) {
151
159
  next.push(' pnpm install');
152
160
  }
@@ -8,8 +8,14 @@ export declare const clintProjectPublish: import("@powerhousedao/ph-clint").Comm
8
8
  dir: z.ZodOptional<z.ZodString>;
9
9
  dryRun: z.ZodDefault<z.ZodBoolean>;
10
10
  skipBuild: z.ZodDefault<z.ZodBoolean>;
11
+ skipGitCheck: z.ZodDefault<z.ZodBoolean>;
11
12
  verbose: z.ZodDefault<z.ZodBoolean>;
12
13
  }, z.core.$strip>, {
13
14
  text: string;
14
15
  data: import("@powerhousedao/ph-clint-dev/publish").PublishResult;
15
- }, Record<string, unknown>>;
16
+ }, {
17
+ model: string;
18
+ devServicePort: number;
19
+ phVersion: string;
20
+ apiKey?: string | undefined;
21
+ }, import("@powerhousedao/ph-clint").InferRegistry<readonly [import("document-model").DocumentModelModule<import("@powerhousedao/ph-clint-app").PhClintProjectPHState>]>>;
@@ -1,5 +1,5 @@
1
1
  import path from 'node:path';
2
- import { defineCommand } from '@powerhousedao/ph-clint';
2
+ import { defineCommand } from '../framework.js';
3
3
  import { z } from 'zod';
4
4
  import { resolvePublishPlan, buildPackages, publishPackages, } from '@powerhousedao/ph-clint-dev/publish';
5
5
  const inputSchema = z.object({
@@ -7,6 +7,7 @@ const inputSchema = z.object({
7
7
  dir: z.string().optional().describe('Project root directory'),
8
8
  dryRun: z.boolean().default(false).describe('Preview without publishing'),
9
9
  skipBuild: z.boolean().default(false),
10
+ skipGitCheck: z.boolean().default(false).describe('Skip git working tree check'),
10
11
  verbose: z.boolean().default(false),
11
12
  });
12
13
  function formatPlanPreview(plan) {
@@ -34,11 +35,12 @@ export const clintProjectPublish = defineCommand({
34
35
  logLines.push(msg);
35
36
  stdout(msg + '\n');
36
37
  };
37
- // 1. Resolve plan
38
+ // 1. Resolve plan — discover config from the target dir, not process.cwd().
39
+ const configFile = path.join(dir, 'publish.config.js');
38
40
  const plan = await resolvePublishPlan({
39
41
  tag: input.tag,
40
- configPath: undefined, // auto-discover from dir
41
- skipGitCheck: input.dryRun,
42
+ configPath: configFile,
43
+ skipGitCheck: input.dryRun || input.skipGitCheck,
42
44
  log,
43
45
  });
44
46
  // 2. Show preview
@@ -15,4 +15,9 @@ export declare const regen: import("@powerhousedao/ph-clint").Command<z.ZodObjec
15
15
  migrated: boolean;
16
16
  warnings: string[];
17
17
  };
18
- }, Record<string, unknown>>;
18
+ }, {
19
+ model: string;
20
+ devServicePort: number;
21
+ phVersion: string;
22
+ apiKey?: string | undefined;
23
+ }, import("@powerhousedao/ph-clint").InferRegistry<readonly [import("document-model").DocumentModelModule<import("@powerhousedao/ph-clint-app").PhClintProjectPHState>]>>;