@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.
Files changed (110) hide show
  1. package/dist/cli.js +60 -17
  2. package/dist/codegen/index.d.ts +8 -36
  3. package/dist/codegen/index.js +6 -287
  4. package/dist/commands/clint-project-build.d.ts +83 -0
  5. package/dist/commands/clint-project-build.js +34 -0
  6. package/dist/commands/clint-project-init.d.ts +177 -0
  7. package/dist/commands/{init.js → clint-project-init.js} +75 -50
  8. package/dist/commands/clint-project-publish.d.ts +92 -0
  9. package/dist/commands/clint-project-publish.js +73 -0
  10. package/dist/commands/clint-project-regen.d.ts +94 -0
  11. package/dist/commands/{regen.js → clint-project-regen.js} +29 -5
  12. package/dist/commands/clint-skills-sync.d.ts +86 -0
  13. package/dist/commands/clint-skills-sync.js +56 -0
  14. package/dist/config.d.ts +3 -5
  15. package/dist/config.js +5 -7
  16. package/dist/framework.d.ts +322 -60
  17. package/dist/framework.gen.d.ts +50 -10
  18. package/dist/framework.gen.js +1 -1
  19. package/dist/framework.js +1 -5
  20. package/{prompts/agent-profiles/AgentBase.md → dist/gen/agent-profiles/PhClintDevAgent.md} +1 -1
  21. package/dist/gen/skills/cli-setup/.cli-docs.md +135 -0
  22. package/dist/gen/skills/cli-setup/SKILL.md +125 -0
  23. package/dist/gen/skills/cli-setup/references/00.assess-cli-needs.md +53 -0
  24. package/dist/gen/skills/cli-setup/references/01.define-config-schema.md +78 -0
  25. package/dist/gen/skills/cli-setup/references/02.wire-cli.md +141 -0
  26. package/dist/gen/skills/cli-setup/references/03.add-entrypoint.md +128 -0
  27. package/dist/gen/skills/cli-setup/references/expected-outcome.md +3 -0
  28. package/dist/gen/skills/command-definition/.cli-docs.md +84 -0
  29. package/dist/gen/skills/command-definition/SKILL.md +99 -0
  30. package/dist/gen/skills/command-definition/references/00.assess-requirements.md +58 -0
  31. package/dist/gen/skills/command-definition/references/01.define-schema.md +72 -0
  32. package/dist/gen/skills/command-definition/references/02.implement-execute.md +118 -0
  33. package/dist/gen/skills/command-definition/references/03.add-prompting.md +54 -0
  34. package/dist/gen/skills/command-definition/references/expected-outcome.md +3 -0
  35. package/dist/gen/skills/service-definition/.cli-docs.md +214 -0
  36. package/dist/gen/skills/service-definition/SKILL.md +148 -0
  37. package/dist/gen/skills/service-definition/references/00.assess-service.md +69 -0
  38. package/dist/gen/skills/service-definition/references/01.define-service.md +166 -0
  39. package/dist/gen/skills/service-definition/references/02.add-preflight.md +132 -0
  40. package/dist/gen/skills/service-definition/references/03.add-project-scanner.md +82 -0
  41. package/dist/gen/skills/service-definition/references/04.wire-events.md +120 -0
  42. package/dist/gen/skills/service-definition/references/expected-outcome.md +3 -0
  43. package/dist/main.js +0 -0
  44. package/dist/services/clint-project.d.ts +1 -0
  45. package/dist/services/clint-project.js +68 -0
  46. package/dist/spec/ensure-document.d.ts +17 -0
  47. package/dist/spec/ensure-document.js +56 -0
  48. package/dist/spec/file.d.ts +1 -4
  49. package/dist/spec/file.js +1 -34
  50. package/dist/spec/from-document.d.ts +4 -1
  51. package/dist/spec/from-document.js +4 -16
  52. package/dist/spec/types.d.ts +1 -62
  53. package/dist/spec/types.js +1 -112
  54. package/dist/triggers/publish-trigger.d.ts +81 -0
  55. package/dist/triggers/publish-trigger.js +137 -0
  56. package/dist/triggers/spec-change.d.ts +60 -18
  57. package/dist/triggers/spec-change.js +154 -101
  58. package/package.json +26 -32
  59. package/dist/codegen/builders/agent-base-md.d.ts +0 -5
  60. package/dist/codegen/builders/agent-base-md.js +0 -18
  61. package/dist/codegen/builders/agent-ts.d.ts +0 -9
  62. package/dist/codegen/builders/agent-ts.js +0 -34
  63. package/dist/codegen/builders/app-index-ts.d.ts +0 -18
  64. package/dist/codegen/builders/app-index-ts.js +0 -33
  65. package/dist/codegen/builders/build-skills-ts.d.ts +0 -4
  66. package/dist/codegen/builders/build-skills-ts.js +0 -37
  67. package/dist/codegen/builders/cli-package-json.d.ts +0 -8
  68. package/dist/codegen/builders/cli-package-json.js +0 -69
  69. package/dist/codegen/builders/cli-ts.d.ts +0 -7
  70. package/dist/codegen/builders/cli-ts.js +0 -110
  71. package/dist/codegen/builders/config-ts.d.ts +0 -8
  72. package/dist/codegen/builders/config-ts.js +0 -21
  73. package/dist/codegen/builders/eslint-config-js.d.ts +0 -4
  74. package/dist/codegen/builders/eslint-config-js.js +0 -13
  75. package/dist/codegen/builders/framework-gen-ts.d.ts +0 -20
  76. package/dist/codegen/builders/framework-gen-ts.js +0 -62
  77. package/dist/codegen/builders/framework-ts.d.ts +0 -21
  78. package/dist/codegen/builders/framework-ts.js +0 -74
  79. package/dist/codegen/builders/gitignore.d.ts +0 -4
  80. package/dist/codegen/builders/gitignore.js +0 -18
  81. package/dist/codegen/builders/index.d.ts +0 -43
  82. package/dist/codegen/builders/index.js +0 -60
  83. package/dist/codegen/builders/jest-config-js.d.ts +0 -4
  84. package/dist/codegen/builders/jest-config-js.js +0 -19
  85. package/dist/codegen/builders/main-ts.d.ts +0 -5
  86. package/dist/codegen/builders/main-ts.js +0 -13
  87. package/dist/codegen/builders/mastra-index-ts.d.ts +0 -8
  88. package/dist/codegen/builders/mastra-index-ts.js +0 -30
  89. package/dist/codegen/builders/readme-md.d.ts +0 -5
  90. package/dist/codegen/builders/readme-md.js +0 -44
  91. package/dist/codegen/builders/root-package-json.d.ts +0 -7
  92. package/dist/codegen/builders/root-package-json.js +0 -27
  93. package/dist/codegen/builders/tsconfig-json.d.ts +0 -4
  94. package/dist/codegen/builders/tsconfig-json.js +0 -22
  95. package/dist/codegen/exec.d.ts +0 -20
  96. package/dist/codegen/exec.js +0 -41
  97. package/dist/codegen/hashes.d.ts +0 -6
  98. package/dist/codegen/hashes.js +0 -60
  99. package/dist/codegen/markers.d.ts +0 -36
  100. package/dist/codegen/markers.js +0 -86
  101. package/dist/codegen/migrate/flat-to-split.d.ts +0 -15
  102. package/dist/codegen/migrate/flat-to-split.js +0 -119
  103. package/dist/codegen/scaffold.d.ts +0 -34
  104. package/dist/codegen/scaffold.js +0 -60
  105. package/dist/codegen/write.d.ts +0 -6
  106. package/dist/codegen/write.js +0 -32
  107. package/dist/commands/init.d.ts +0 -57
  108. package/dist/commands/regen.d.ts +0 -18
  109. package/prompts/skills-ext/.gitkeep +0 -0
  110. package/prompts/skills-tpl/.gitkeep +0 -0
@@ -0,0 +1,177 @@
1
+ import { z } from 'zod';
2
+ import { type ClintProjectSpec } from '../spec/types.js';
3
+ declare const inputSchema: z.ZodObject<{
4
+ dir: z.ZodOptional<z.ZodString>;
5
+ name: z.ZodString;
6
+ description: z.ZodOptional<z.ZodString>;
7
+ enablePowerhouse: z.ZodDefault<z.ZodBoolean>;
8
+ enableMastra: z.ZodDefault<z.ZodBoolean>;
9
+ enableRoutine: z.ZodDefault<z.ZodBoolean>;
10
+ enableObservability: z.ZodDefault<z.ZodBoolean>;
11
+ force: z.ZodDefault<z.ZodBoolean>;
12
+ skipInstall: z.ZodDefault<z.ZodBoolean>;
13
+ }, z.core.$strip>;
14
+ type InitInput = z.output<typeof inputSchema>;
15
+ export declare function buildSpec(input: InitInput): ClintProjectSpec;
16
+ export declare const init: import("@powerhousedao/ph-clint").Command<z.ZodObject<{
17
+ dir: z.ZodOptional<z.ZodString>;
18
+ name: z.ZodString;
19
+ description: z.ZodOptional<z.ZodString>;
20
+ enablePowerhouse: z.ZodDefault<z.ZodBoolean>;
21
+ enableMastra: z.ZodDefault<z.ZodBoolean>;
22
+ enableRoutine: z.ZodDefault<z.ZodBoolean>;
23
+ enableObservability: z.ZodDefault<z.ZodBoolean>;
24
+ force: z.ZodDefault<z.ZodBoolean>;
25
+ skipInstall: z.ZodDefault<z.ZodBoolean>;
26
+ }, z.core.$strip>, {
27
+ text: string;
28
+ data?: undefined;
29
+ } | {
30
+ text: string;
31
+ data: {
32
+ targetDir: string;
33
+ spec: {
34
+ name: string;
35
+ version: string;
36
+ description: string;
37
+ features: {
38
+ powerhouse: "Disabled" | "Reactor" | "Switchboard" | "Connect";
39
+ mastra: {
40
+ enabled: boolean;
41
+ mainAgent: {
42
+ description: string | null;
43
+ image: string | null;
44
+ id: string;
45
+ name: string;
46
+ modelId: string;
47
+ profileIds: string[];
48
+ skills: string[];
49
+ toolPatterns: string[];
50
+ } | null;
51
+ subAgents: {
52
+ description: string;
53
+ id: string;
54
+ name: string;
55
+ modelId: string;
56
+ profileIds: string[];
57
+ skills: string[];
58
+ toolPatterns: string[];
59
+ }[];
60
+ models: {
61
+ id: string;
62
+ }[];
63
+ profiles: {
64
+ id: string;
65
+ title: string;
66
+ content: string;
67
+ }[];
68
+ common: {
69
+ enableChat: boolean;
70
+ };
71
+ };
72
+ routine: {
73
+ enabled: boolean;
74
+ };
75
+ };
76
+ packages: {
77
+ id: string;
78
+ packageName: string;
79
+ documentTypes: string[];
80
+ version: string | null;
81
+ }[];
82
+ externalSkills: {
83
+ id: string;
84
+ name: string;
85
+ githubUrl: string;
86
+ }[];
87
+ deployment: {
88
+ proxyEnabled: boolean;
89
+ observabilityEnabled: boolean;
90
+ supportedResources: string[];
91
+ dockerfile?: string | undefined;
92
+ dockerTarget?: string | undefined;
93
+ };
94
+ scope?: string | undefined;
95
+ documentId?: string | undefined;
96
+ documentType?: string | undefined;
97
+ };
98
+ fileCount: number;
99
+ };
100
+ }, {
101
+ model: string;
102
+ devServicePort: number;
103
+ phVersion: string;
104
+ apiKey?: string | undefined;
105
+ }, import("@powerhousedao/ph-clint").InferRegistry<readonly [{
106
+ readonly version: 1;
107
+ readonly reducer: import("document-model").Reducer<import("@powerhousedao/ph-clint-app").PhClintProjectPHState>;
108
+ readonly actions: {
109
+ setAgentModel: (input: import("@powerhousedao/ph-clint-app").SetAgentModelInput) => import("@powerhousedao/ph-clint-app").SetAgentModelAction;
110
+ addAgentProfileRef: (input: import("@powerhousedao/ph-clint-app").AddAgentProfileRefInput) => import("@powerhousedao/ph-clint-app").AddAgentProfileRefAction;
111
+ removeAgentProfileRef: (input: import("@powerhousedao/ph-clint-app").RemoveAgentProfileRefInput) => import("@powerhousedao/ph-clint-app").RemoveAgentProfileRefAction;
112
+ reorderAgentProfileRefs: (input: import("@powerhousedao/ph-clint-app").ReorderAgentProfileRefsInput) => import("@powerhousedao/ph-clint-app").ReorderAgentProfileRefsAction;
113
+ addAgentSkill: (input: import("@powerhousedao/ph-clint-app").AddAgentSkillInput) => import("@powerhousedao/ph-clint-app").AddAgentSkillAction;
114
+ removeAgentSkill: (input: import("@powerhousedao/ph-clint-app").RemoveAgentSkillInput) => import("@powerhousedao/ph-clint-app").RemoveAgentSkillAction;
115
+ addAgentToolPattern: (input: import("@powerhousedao/ph-clint-app").AddAgentToolPatternInput) => import("@powerhousedao/ph-clint-app").AddAgentToolPatternAction;
116
+ removeAgentToolPattern: (input: import("@powerhousedao/ph-clint-app").RemoveAgentToolPatternInput) => import("@powerhousedao/ph-clint-app").RemoveAgentToolPatternAction;
117
+ addSubAgent: (input: import("@powerhousedao/ph-clint-app").AddSubAgentInput) => import("@powerhousedao/ph-clint-app").AddSubAgentAction;
118
+ removeSubAgent: (input: import("@powerhousedao/ph-clint-app").RemoveSubAgentInput) => import("@powerhousedao/ph-clint-app").RemoveSubAgentAction;
119
+ setSubAgentName: (input: import("@powerhousedao/ph-clint-app").SetSubAgentNameInput) => import("@powerhousedao/ph-clint-app").SetSubAgentNameAction;
120
+ setSubAgentDescription: (input: import("@powerhousedao/ph-clint-app").SetSubAgentDescriptionInput) => import("@powerhousedao/ph-clint-app").SetSubAgentDescriptionAction;
121
+ setMainAgentName: (input: import("@powerhousedao/ph-clint-app").SetMainAgentNameInput) => import("@powerhousedao/ph-clint-app").SetMainAgentNameAction;
122
+ setMainAgentDescription: (input: import("@powerhousedao/ph-clint-app").SetMainAgentDescriptionInput) => import("@powerhousedao/ph-clint-app").SetMainAgentDescriptionAction;
123
+ clearMainAgentDescription: (input: import("@powerhousedao/ph-clint-app").ClearMainAgentDescriptionInput) => import("@powerhousedao/ph-clint-app").ClearMainAgentDescriptionAction;
124
+ setMainAgentImage: (input: import("@powerhousedao/ph-clint-app").SetMainAgentImageInput) => import("@powerhousedao/ph-clint-app").SetMainAgentImageAction;
125
+ clearMainAgentImage: (input: import("@powerhousedao/ph-clint-app").ClearMainAgentImageInput) => import("@powerhousedao/ph-clint-app").ClearMainAgentImageAction;
126
+ addProfile: (input: import("@powerhousedao/ph-clint-app").AddProfileInput) => import("@powerhousedao/ph-clint-app").AddProfileAction;
127
+ updateProfile: (input: import("@powerhousedao/ph-clint-app").UpdateProfileInput) => import("@powerhousedao/ph-clint-app").UpdateProfileAction;
128
+ removeProfile: (input: import("@powerhousedao/ph-clint-app").RemoveProfileInput) => import("@powerhousedao/ph-clint-app").RemoveProfileAction;
129
+ reorderProfiles: (input: import("@powerhousedao/ph-clint-app").ReorderProfilesInput) => import("@powerhousedao/ph-clint-app").ReorderProfilesAction;
130
+ addModel: (input: import("@powerhousedao/ph-clint-app").AddModelInput) => import("@powerhousedao/ph-clint-app").AddModelAction;
131
+ removeModel: (input: import("@powerhousedao/ph-clint-app").RemoveModelInput) => import("@powerhousedao/ph-clint-app").RemoveModelAction;
132
+ enableMastra: (input: import("@powerhousedao/ph-clint-app").EnableMastraInput) => import("@powerhousedao/ph-clint-app").EnableMastraAction;
133
+ disableMastra: (input: import("@powerhousedao/ph-clint-app").DisableMastraInput) => import("@powerhousedao/ph-clint-app").DisableMastraAction;
134
+ setEnableChat: (input: import("@powerhousedao/ph-clint-app").SetEnableChatInput) => import("@powerhousedao/ph-clint-app").SetEnableChatAction;
135
+ addSupportedResource: (input: import("@powerhousedao/ph-clint-app").AddSupportedResourceInput) => import("@powerhousedao/ph-clint-app").AddSupportedResourceAction;
136
+ removeSupportedResource: (input: import("@powerhousedao/ph-clint-app").RemoveSupportedResourceInput) => import("@powerhousedao/ph-clint-app").RemoveSupportedResourceAction;
137
+ setProxyEnabled: (input: import("@powerhousedao/ph-clint-app").SetProxyEnabledInput) => import("@powerhousedao/ph-clint-app").SetProxyEnabledAction;
138
+ setObservabilityEnabled: (input: import("@powerhousedao/ph-clint-app").SetObservabilityEnabledInput) => import("@powerhousedao/ph-clint-app").SetObservabilityEnabledAction;
139
+ importSpec: (input: import("@powerhousedao/ph-clint-app").ImportSpecInput) => import("@powerhousedao/ph-clint-app").ImportSpecAction;
140
+ bumpVersion: (input: import("@powerhousedao/ph-clint-app").BumpVersionInput) => import("@powerhousedao/ph-clint-app").BumpVersionAction;
141
+ publishDev: (input: import("@powerhousedao/ph-clint-app").PublishDevInput) => import("@powerhousedao/ph-clint-app").PublishDevAction;
142
+ publishStaging: (input: import("@powerhousedao/ph-clint-app").PublishStagingInput) => import("@powerhousedao/ph-clint-app").PublishStagingAction;
143
+ publishProduction: (input: import("@powerhousedao/ph-clint-app").PublishProductionInput) => import("@powerhousedao/ph-clint-app").PublishProductionAction;
144
+ setPublishStatus: (input: import("@powerhousedao/ph-clint-app").SetPublishStatusInput) => import("@powerhousedao/ph-clint-app").SetPublishStatusAction;
145
+ addExternalSkill: (input: import("@powerhousedao/ph-clint-app").AddExternalSkillInput) => import("@powerhousedao/ph-clint-app").AddExternalSkillAction;
146
+ removeExternalSkill: (input: import("@powerhousedao/ph-clint-app").RemoveExternalSkillInput) => import("@powerhousedao/ph-clint-app").RemoveExternalSkillAction;
147
+ setExternalSkillName: (input: import("@powerhousedao/ph-clint-app").SetExternalSkillNameInput) => import("@powerhousedao/ph-clint-app").SetExternalSkillNameAction;
148
+ setExternalSkillGithubUrl: (input: import("@powerhousedao/ph-clint-app").SetExternalSkillGithubUrlInput) => import("@powerhousedao/ph-clint-app").SetExternalSkillGithubUrlAction;
149
+ addPowerhousePackage: (input: import("@powerhousedao/ph-clint-app").AddPowerhousePackageInput) => import("@powerhousedao/ph-clint-app").AddPowerhousePackageAction;
150
+ removePowerhousePackage: (input: import("@powerhousedao/ph-clint-app").RemovePowerhousePackageInput) => import("@powerhousedao/ph-clint-app").RemovePowerhousePackageAction;
151
+ addPackageDocumentType: (input: import("@powerhousedao/ph-clint-app").AddPackageDocumentTypeInput) => import("@powerhousedao/ph-clint-app").AddPackageDocumentTypeAction;
152
+ removePackageDocumentType: (input: import("@powerhousedao/ph-clint-app").RemovePackageDocumentTypeInput) => import("@powerhousedao/ph-clint-app").RemovePackageDocumentTypeAction;
153
+ setPackageVersion: (input: import("@powerhousedao/ph-clint-app").SetPackageVersionInput) => import("@powerhousedao/ph-clint-app").SetPackageVersionAction;
154
+ enableRoutine: (input: import("@powerhousedao/ph-clint-app").EnableRoutineInput) => import("@powerhousedao/ph-clint-app").EnableRoutineAction;
155
+ disableRoutine: (input: import("@powerhousedao/ph-clint-app").DisableRoutineInput) => import("@powerhousedao/ph-clint-app").DisableRoutineAction;
156
+ setPowerhouseLevel: (input: import("@powerhousedao/ph-clint-app").SetPowerhouseLevelInput) => import("@powerhousedao/ph-clint-app").SetPowerhouseLevelAction;
157
+ setDescription: (input: import("@powerhousedao/ph-clint-app").SetDescriptionInput) => import("@powerhousedao/ph-clint-app").SetDescriptionAction;
158
+ setVersion: (input: import("@powerhousedao/ph-clint-app").SetVersionInput) => import("@powerhousedao/ph-clint-app").SetVersionAction;
159
+ setPackageIdentifier: (input: import("@powerhousedao/ph-clint-app").SetPackageIdentifierInput) => import("@powerhousedao/ph-clint-app").SetPackageIdentifierAction;
160
+ setName: (name: string | {
161
+ name: string;
162
+ }) => import("document-model").SetNameAction;
163
+ setPreferredEditor: (input: string | null | {
164
+ preferredEditor: string | null;
165
+ }) => import("document-model").SetPreferredEditorAction;
166
+ undo: (count?: number, scope?: string) => import("document-model").UndoAction;
167
+ redo: (count?: number, scope?: string) => import("document-model").RedoAction;
168
+ prune: (start?: number, end?: number, scope?: string) => import("document-model").SchemaPruneAction;
169
+ loadState: <TState extends import("document-model").PHBaseState = import("document-model").PHBaseState>(state: TState & {
170
+ name: string;
171
+ }, operations: number) => import("document-model").LoadStateAction;
172
+ noop: (scope?: string) => import("document-model").NOOPAction;
173
+ };
174
+ readonly utils: import("document-model").DocumentModelUtils<import("@powerhousedao/ph-clint-app").PhClintProjectPHState>;
175
+ readonly documentModel: import("document-model").DocumentModelPHState;
176
+ }]>>;
177
+ export {};
@@ -1,28 +1,29 @@
1
1
  /**
2
- * `ph-clint init` — the project bootstrap wizard.
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.'),
@@ -39,59 +40,86 @@ const inputSchema = z.object({
39
40
  .boolean()
40
41
  .default(false)
41
42
  .describe('Enable the tick-based routine loop'),
42
- force: z
43
+ enableObservability: z
43
44
  .boolean()
44
45
  .default(false)
45
- .describe('Overwrite files if the target directory is not empty'),
46
- skipPhInit: z
46
+ .describe('Wire @powerhousedao/ph-clint-observability into the generated CLI. ' +
47
+ 'The generated CLI will ask its end-user for telemetry consent on first run.'),
48
+ force: z
47
49
  .boolean()
48
50
  .default(false)
49
- .describe('Do not run `ph init` in the app folder after scaffolding'),
51
+ .describe('Overwrite files if the target directory is not empty'),
50
52
  skipInstall: z
51
53
  .boolean()
52
54
  .default(false)
53
55
  .describe('Do not run `pnpm install` after scaffolding'),
54
56
  });
55
- /** Parse `@scope/name` into { scope, name }. */
57
+ /** Parse `@scope/name` into { scope, name }. Auto-appends `-cli` if missing. */
56
58
  function splitPackageName(raw) {
57
59
  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] };
60
+ if (match) {
61
+ const name = match[2].endsWith('-cli') ? match[2] : `${match[2]}-cli`;
62
+ return { scope: `@${match[1]}`, name };
63
+ }
60
64
  if (raw.startsWith('@')) {
61
65
  throw new Error(`invalid package name "${raw}" — expected "@scope/name" with lowercase letters, digits, hyphens`);
62
66
  }
63
67
  if (!/^[a-z0-9][a-z0-9-]*$/.test(raw)) {
64
68
  throw new Error(`invalid project name "${raw}" — expected lowercase letters, digits, hyphens`);
65
69
  }
66
- return { name: raw };
70
+ const name = raw.endsWith('-cli') ? raw : `${raw}-cli`;
71
+ return { name };
67
72
  }
68
73
  export function buildSpec(input) {
69
74
  const { scope, name } = splitPackageName(input.name);
70
75
  // Routine is forced on when Mastra is on — the REPL-only path works, but
71
76
  // the agent routine loop is what most users actually want.
72
77
  const routine = input.enableRoutine || input.enableMastra;
78
+ const baseName = name.replace(/-cli$/, '');
79
+ const mastra = input.enableMastra
80
+ ? {
81
+ enabled: true,
82
+ models: [{ id: 'anthropic/claude-sonnet-4-5' }],
83
+ profiles: [{ id: 'base', title: 'Base', content: 'You are a helpful assistant.' }],
84
+ mainAgent: {
85
+ id: `${baseName}-agent`,
86
+ name: `${baseName.charAt(0).toUpperCase()}${baseName.slice(1).replace(/-(\w)/g, (_, c) => ' ' + c.toUpperCase())} Agent`,
87
+ description: null,
88
+ image: null,
89
+ modelId: 'anthropic/claude-sonnet-4-5',
90
+ profileIds: ['base'],
91
+ skills: [],
92
+ toolPatterns: [],
93
+ },
94
+ subAgents: [],
95
+ }
96
+ : { enabled: false };
73
97
  const candidate = {
74
98
  name,
75
99
  scope,
76
100
  description: input.description ?? '',
77
101
  features: {
78
- powerhouse: { enabled: input.enablePowerhouse },
79
- mastra: { enabled: input.enableMastra },
102
+ powerhouse: input.enablePowerhouse ? 'Connect' : 'Disabled',
103
+ mastra,
80
104
  routine: { enabled: routine },
81
105
  },
82
106
  };
107
+ if (input.enableObservability) {
108
+ candidate.deployment = { observabilityEnabled: true };
109
+ }
83
110
  return clintProjectSpecSchema.parse(candidate);
84
111
  }
85
112
  export const init = defineCommand({
86
- id: 'init',
113
+ id: 'clint-project-init',
87
114
  description: 'Initialize a new ph-clint project in the target directory',
88
115
  inputSchema,
89
116
  prompt: {
90
117
  promptForDefaults: true,
91
118
  promptOptional: ['description'],
92
119
  },
93
- execute: async (input, { workdir, stdout }) => {
94
- const targetDir = path.resolve(workdir, input.dir ?? '.');
120
+ execute: async (input, { workdir, stdout, reactor: getReactor, folders, runProcess }) => {
121
+ const { name: bareName } = splitPackageName(input.name);
122
+ const targetDir = path.resolve(workdir, input.dir ?? bareName);
95
123
  if (!input.force) {
96
124
  const empty = await isDirEmptyEnough(targetDir);
97
125
  if (!empty) {
@@ -109,44 +137,41 @@ export const init = defineCommand({
109
137
  allowNonEmpty: input.force,
110
138
  });
111
139
  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
- }
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);
140
+ // Create spec document in personal drive (if reactor available)
141
+ if (getReactor && folders) {
142
+ try {
143
+ const reactor = await getReactor();
144
+ if (reactor) {
145
+ const { docId } = await ensureSpecDocument({
146
+ spec, targetDir, reactor, folders,
147
+ });
148
+ stdout(`Created spec document ${docId} in Clint Folders/specs/${spec.name}\n`);
149
+ }
132
150
  }
133
- else {
134
- dirs.push(targetDir);
151
+ catch (err) {
152
+ // Non-fatal — trigger will pick it up on next startup
153
+ stdout(`Note: could not create spec document — ${err instanceof Error ? err.message : String(err)}\n`);
135
154
  }
136
- await runPnpmInstall({
137
- dirs,
138
- log: (msg) => stdout(msg + '\n'),
139
- });
140
155
  }
156
+ // Run post-generation actions (ph-init, install, build, skills-sync).
157
+ // Only skip cli-install — in split layout, ph-init handles app install
158
+ // internally, and app-build must still run so the CLI can link to it.
159
+ const skip = new Set();
160
+ if (input.skipInstall) {
161
+ skip.add('cli-install');
162
+ }
163
+ await runPostGenActions(result.pendingActions, {
164
+ log: (msg) => stdout(msg + '\n'),
165
+ runProcess,
166
+ skip,
167
+ });
168
+ const split = spec.features.powerhouse !== 'Disabled';
141
169
  const next = [];
142
170
  next.push('');
143
171
  next.push('Next steps:');
144
172
  const relDir = path.relative(workdir, targetDir) || '.';
145
173
  if (split) {
146
174
  next.push(` cd ${relDir}`);
147
- if (input.skipPhInit) {
148
- next.push(` cd ${spec.name}-app && ph init . && cd ..`);
149
- }
150
175
  if (input.skipInstall) {
151
176
  next.push(' pnpm install');
152
177
  }
@@ -159,7 +184,7 @@ export const init = defineCommand({
159
184
  next.push(' pnpm dev');
160
185
  }
161
186
  next.push('');
162
- next.push('Edit the project spec and run `ph-clint regen` to regenerate.');
187
+ next.push('Edit the project spec and run `ph-clint clint-project-regen` to regenerate.');
163
188
  return {
164
189
  text: next.join('\n'),
165
190
  data: { targetDir, spec, fileCount: result.files.length },
@@ -0,0 +1,92 @@
1
+ import { z } from 'zod';
2
+ export declare const clintProjectPublish: import("@powerhousedao/ph-clint").Command<z.ZodObject<{
3
+ tag: z.ZodEnum<{
4
+ dev: "dev";
5
+ staging: "staging";
6
+ production: "production";
7
+ }>;
8
+ dir: z.ZodOptional<z.ZodString>;
9
+ dryRun: z.ZodDefault<z.ZodBoolean>;
10
+ skipBuild: z.ZodDefault<z.ZodBoolean>;
11
+ skipGitCheck: z.ZodDefault<z.ZodBoolean>;
12
+ verbose: z.ZodDefault<z.ZodBoolean>;
13
+ }, z.core.$strip>, {
14
+ text: string;
15
+ data: import("@powerhousedao/ph-clint-dev/publish").PublishResult;
16
+ }, {
17
+ model: string;
18
+ devServicePort: number;
19
+ phVersion: string;
20
+ apiKey?: string | undefined;
21
+ }, import("@powerhousedao/ph-clint").InferRegistry<readonly [{
22
+ readonly version: 1;
23
+ readonly reducer: import("document-model").Reducer<import("@powerhousedao/ph-clint-app").PhClintProjectPHState>;
24
+ readonly actions: {
25
+ setAgentModel: (input: import("@powerhousedao/ph-clint-app").SetAgentModelInput) => import("@powerhousedao/ph-clint-app").SetAgentModelAction;
26
+ addAgentProfileRef: (input: import("@powerhousedao/ph-clint-app").AddAgentProfileRefInput) => import("@powerhousedao/ph-clint-app").AddAgentProfileRefAction;
27
+ removeAgentProfileRef: (input: import("@powerhousedao/ph-clint-app").RemoveAgentProfileRefInput) => import("@powerhousedao/ph-clint-app").RemoveAgentProfileRefAction;
28
+ reorderAgentProfileRefs: (input: import("@powerhousedao/ph-clint-app").ReorderAgentProfileRefsInput) => import("@powerhousedao/ph-clint-app").ReorderAgentProfileRefsAction;
29
+ addAgentSkill: (input: import("@powerhousedao/ph-clint-app").AddAgentSkillInput) => import("@powerhousedao/ph-clint-app").AddAgentSkillAction;
30
+ removeAgentSkill: (input: import("@powerhousedao/ph-clint-app").RemoveAgentSkillInput) => import("@powerhousedao/ph-clint-app").RemoveAgentSkillAction;
31
+ addAgentToolPattern: (input: import("@powerhousedao/ph-clint-app").AddAgentToolPatternInput) => import("@powerhousedao/ph-clint-app").AddAgentToolPatternAction;
32
+ removeAgentToolPattern: (input: import("@powerhousedao/ph-clint-app").RemoveAgentToolPatternInput) => import("@powerhousedao/ph-clint-app").RemoveAgentToolPatternAction;
33
+ addSubAgent: (input: import("@powerhousedao/ph-clint-app").AddSubAgentInput) => import("@powerhousedao/ph-clint-app").AddSubAgentAction;
34
+ removeSubAgent: (input: import("@powerhousedao/ph-clint-app").RemoveSubAgentInput) => import("@powerhousedao/ph-clint-app").RemoveSubAgentAction;
35
+ setSubAgentName: (input: import("@powerhousedao/ph-clint-app").SetSubAgentNameInput) => import("@powerhousedao/ph-clint-app").SetSubAgentNameAction;
36
+ setSubAgentDescription: (input: import("@powerhousedao/ph-clint-app").SetSubAgentDescriptionInput) => import("@powerhousedao/ph-clint-app").SetSubAgentDescriptionAction;
37
+ setMainAgentName: (input: import("@powerhousedao/ph-clint-app").SetMainAgentNameInput) => import("@powerhousedao/ph-clint-app").SetMainAgentNameAction;
38
+ setMainAgentDescription: (input: import("@powerhousedao/ph-clint-app").SetMainAgentDescriptionInput) => import("@powerhousedao/ph-clint-app").SetMainAgentDescriptionAction;
39
+ clearMainAgentDescription: (input: import("@powerhousedao/ph-clint-app").ClearMainAgentDescriptionInput) => import("@powerhousedao/ph-clint-app").ClearMainAgentDescriptionAction;
40
+ setMainAgentImage: (input: import("@powerhousedao/ph-clint-app").SetMainAgentImageInput) => import("@powerhousedao/ph-clint-app").SetMainAgentImageAction;
41
+ clearMainAgentImage: (input: import("@powerhousedao/ph-clint-app").ClearMainAgentImageInput) => import("@powerhousedao/ph-clint-app").ClearMainAgentImageAction;
42
+ addProfile: (input: import("@powerhousedao/ph-clint-app").AddProfileInput) => import("@powerhousedao/ph-clint-app").AddProfileAction;
43
+ updateProfile: (input: import("@powerhousedao/ph-clint-app").UpdateProfileInput) => import("@powerhousedao/ph-clint-app").UpdateProfileAction;
44
+ removeProfile: (input: import("@powerhousedao/ph-clint-app").RemoveProfileInput) => import("@powerhousedao/ph-clint-app").RemoveProfileAction;
45
+ reorderProfiles: (input: import("@powerhousedao/ph-clint-app").ReorderProfilesInput) => import("@powerhousedao/ph-clint-app").ReorderProfilesAction;
46
+ addModel: (input: import("@powerhousedao/ph-clint-app").AddModelInput) => import("@powerhousedao/ph-clint-app").AddModelAction;
47
+ removeModel: (input: import("@powerhousedao/ph-clint-app").RemoveModelInput) => import("@powerhousedao/ph-clint-app").RemoveModelAction;
48
+ enableMastra: (input: import("@powerhousedao/ph-clint-app").EnableMastraInput) => import("@powerhousedao/ph-clint-app").EnableMastraAction;
49
+ disableMastra: (input: import("@powerhousedao/ph-clint-app").DisableMastraInput) => import("@powerhousedao/ph-clint-app").DisableMastraAction;
50
+ setEnableChat: (input: import("@powerhousedao/ph-clint-app").SetEnableChatInput) => import("@powerhousedao/ph-clint-app").SetEnableChatAction;
51
+ addSupportedResource: (input: import("@powerhousedao/ph-clint-app").AddSupportedResourceInput) => import("@powerhousedao/ph-clint-app").AddSupportedResourceAction;
52
+ removeSupportedResource: (input: import("@powerhousedao/ph-clint-app").RemoveSupportedResourceInput) => import("@powerhousedao/ph-clint-app").RemoveSupportedResourceAction;
53
+ setProxyEnabled: (input: import("@powerhousedao/ph-clint-app").SetProxyEnabledInput) => import("@powerhousedao/ph-clint-app").SetProxyEnabledAction;
54
+ setObservabilityEnabled: (input: import("@powerhousedao/ph-clint-app").SetObservabilityEnabledInput) => import("@powerhousedao/ph-clint-app").SetObservabilityEnabledAction;
55
+ importSpec: (input: import("@powerhousedao/ph-clint-app").ImportSpecInput) => import("@powerhousedao/ph-clint-app").ImportSpecAction;
56
+ bumpVersion: (input: import("@powerhousedao/ph-clint-app").BumpVersionInput) => import("@powerhousedao/ph-clint-app").BumpVersionAction;
57
+ publishDev: (input: import("@powerhousedao/ph-clint-app").PublishDevInput) => import("@powerhousedao/ph-clint-app").PublishDevAction;
58
+ publishStaging: (input: import("@powerhousedao/ph-clint-app").PublishStagingInput) => import("@powerhousedao/ph-clint-app").PublishStagingAction;
59
+ publishProduction: (input: import("@powerhousedao/ph-clint-app").PublishProductionInput) => import("@powerhousedao/ph-clint-app").PublishProductionAction;
60
+ setPublishStatus: (input: import("@powerhousedao/ph-clint-app").SetPublishStatusInput) => import("@powerhousedao/ph-clint-app").SetPublishStatusAction;
61
+ addExternalSkill: (input: import("@powerhousedao/ph-clint-app").AddExternalSkillInput) => import("@powerhousedao/ph-clint-app").AddExternalSkillAction;
62
+ removeExternalSkill: (input: import("@powerhousedao/ph-clint-app").RemoveExternalSkillInput) => import("@powerhousedao/ph-clint-app").RemoveExternalSkillAction;
63
+ setExternalSkillName: (input: import("@powerhousedao/ph-clint-app").SetExternalSkillNameInput) => import("@powerhousedao/ph-clint-app").SetExternalSkillNameAction;
64
+ setExternalSkillGithubUrl: (input: import("@powerhousedao/ph-clint-app").SetExternalSkillGithubUrlInput) => import("@powerhousedao/ph-clint-app").SetExternalSkillGithubUrlAction;
65
+ addPowerhousePackage: (input: import("@powerhousedao/ph-clint-app").AddPowerhousePackageInput) => import("@powerhousedao/ph-clint-app").AddPowerhousePackageAction;
66
+ removePowerhousePackage: (input: import("@powerhousedao/ph-clint-app").RemovePowerhousePackageInput) => import("@powerhousedao/ph-clint-app").RemovePowerhousePackageAction;
67
+ addPackageDocumentType: (input: import("@powerhousedao/ph-clint-app").AddPackageDocumentTypeInput) => import("@powerhousedao/ph-clint-app").AddPackageDocumentTypeAction;
68
+ removePackageDocumentType: (input: import("@powerhousedao/ph-clint-app").RemovePackageDocumentTypeInput) => import("@powerhousedao/ph-clint-app").RemovePackageDocumentTypeAction;
69
+ setPackageVersion: (input: import("@powerhousedao/ph-clint-app").SetPackageVersionInput) => import("@powerhousedao/ph-clint-app").SetPackageVersionAction;
70
+ enableRoutine: (input: import("@powerhousedao/ph-clint-app").EnableRoutineInput) => import("@powerhousedao/ph-clint-app").EnableRoutineAction;
71
+ disableRoutine: (input: import("@powerhousedao/ph-clint-app").DisableRoutineInput) => import("@powerhousedao/ph-clint-app").DisableRoutineAction;
72
+ setPowerhouseLevel: (input: import("@powerhousedao/ph-clint-app").SetPowerhouseLevelInput) => import("@powerhousedao/ph-clint-app").SetPowerhouseLevelAction;
73
+ setDescription: (input: import("@powerhousedao/ph-clint-app").SetDescriptionInput) => import("@powerhousedao/ph-clint-app").SetDescriptionAction;
74
+ setVersion: (input: import("@powerhousedao/ph-clint-app").SetVersionInput) => import("@powerhousedao/ph-clint-app").SetVersionAction;
75
+ setPackageIdentifier: (input: import("@powerhousedao/ph-clint-app").SetPackageIdentifierInput) => import("@powerhousedao/ph-clint-app").SetPackageIdentifierAction;
76
+ setName: (name: string | {
77
+ name: string;
78
+ }) => import("document-model").SetNameAction;
79
+ setPreferredEditor: (input: string | null | {
80
+ preferredEditor: string | null;
81
+ }) => import("document-model").SetPreferredEditorAction;
82
+ undo: (count?: number, scope?: string) => import("document-model").UndoAction;
83
+ redo: (count?: number, scope?: string) => import("document-model").RedoAction;
84
+ prune: (start?: number, end?: number, scope?: string) => import("document-model").SchemaPruneAction;
85
+ loadState: <TState extends import("document-model").PHBaseState = import("document-model").PHBaseState>(state: TState & {
86
+ name: string;
87
+ }, operations: number) => import("document-model").LoadStateAction;
88
+ noop: (scope?: string) => import("document-model").NOOPAction;
89
+ };
90
+ readonly utils: import("document-model").DocumentModelUtils<import("@powerhousedao/ph-clint-app").PhClintProjectPHState>;
91
+ readonly documentModel: import("document-model").DocumentModelPHState;
92
+ }]>>;
@@ -0,0 +1,73 @@
1
+ import path from 'node:path';
2
+ import { defineCommand } from '../framework.js';
3
+ import { z } from 'zod';
4
+ import { resolvePublishPlan, buildPackages, publishPackages, } from '@powerhousedao/ph-clint-dev/publish';
5
+ const inputSchema = z.object({
6
+ tag: z.enum(['dev', 'staging', 'production']).describe('Release channel'),
7
+ dir: z.string().optional().describe('Project root directory'),
8
+ dryRun: z.boolean().default(false).describe('Preview without publishing'),
9
+ skipBuild: z.boolean().default(false),
10
+ skipGitCheck: z.boolean().default(false).describe('Skip git working tree check'),
11
+ verbose: z.boolean().default(false),
12
+ });
13
+ function formatPlanPreview(plan) {
14
+ const lines = [];
15
+ const distTag = plan.tag === 'production' ? 'latest' : plan.tag;
16
+ lines.push(`Publish plan:`);
17
+ lines.push(` Group: ${plan.groupName}`);
18
+ lines.push(` Version: ${plan.version}`);
19
+ lines.push(` Tag: ${distTag}`);
20
+ lines.push(` Registry: ${plan.registry}`);
21
+ lines.push(` Packages:`);
22
+ for (const pkg of plan.packages) {
23
+ lines.push(` - ${pkg.name}`);
24
+ }
25
+ return lines.join('\n');
26
+ }
27
+ export const clintProjectPublish = defineCommand({
28
+ id: 'clint-project-publish',
29
+ description: 'Publish project packages to npm',
30
+ inputSchema,
31
+ execute: async (input, { workdir, stdout }) => {
32
+ const dir = path.resolve(input.dir ?? workdir);
33
+ const logLines = [];
34
+ const log = (msg) => {
35
+ logLines.push(msg);
36
+ stdout(msg + '\n');
37
+ };
38
+ // 1. Resolve plan — discover config from the target dir, not process.cwd().
39
+ const configFile = path.join(dir, 'publish.config.js');
40
+ const plan = await resolvePublishPlan({
41
+ tag: input.tag,
42
+ configPath: configFile,
43
+ skipGitCheck: input.dryRun || input.skipGitCheck,
44
+ log,
45
+ });
46
+ // 2. Show preview
47
+ stdout(formatPlanPreview(plan) + '\n');
48
+ // 3. Build
49
+ if (!input.skipBuild) {
50
+ await buildPackages(plan, { verbose: input.verbose, log });
51
+ }
52
+ // 4. Publish (or dry-run)
53
+ const result = await publishPackages(plan, {
54
+ dryRun: input.dryRun,
55
+ verbose: input.verbose,
56
+ log,
57
+ });
58
+ if (result.success) {
59
+ return {
60
+ text: result.dryRun
61
+ ? `Dry run complete — ${plan.packages.length} packages validated at ${result.version}.`
62
+ : `Published ${result.published.length} packages at ${result.version}.`,
63
+ data: result,
64
+ };
65
+ }
66
+ else {
67
+ return {
68
+ text: `Publish failed. Published: ${result.published.length}, Failed: ${result.failed.length}.`,
69
+ data: result,
70
+ };
71
+ }
72
+ },
73
+ });