@powerhousedao/ph-clint-cli 0.1.0-dev.52 → 0.1.0-dev.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -2
- package/dist/codegen/actions.d.ts +1 -46
- package/dist/codegen/actions.js +1 -424
- package/dist/codegen/builders/app-index-ts.js +24 -20
- package/dist/codegen/builders/cli-package-json.d.ts +1 -8
- package/dist/codegen/builders/cli-package-json.js +1 -128
- package/dist/codegen/builders/index.d.ts +1 -51
- package/dist/codegen/builders/index.js +1 -84
- package/dist/codegen/exec.d.ts +1 -2
- package/dist/codegen/exec.js +1 -14
- package/dist/codegen/generated.d.ts +1 -17
- package/dist/codegen/generated.js +1 -49
- package/dist/codegen/hashes.d.ts +1 -6
- package/dist/codegen/hashes.js +1 -60
- package/dist/codegen/index.d.ts +8 -39
- package/dist/codegen/index.js +6 -407
- package/dist/codegen/markers.d.ts +1 -36
- package/dist/codegen/markers.js +1 -86
- package/dist/codegen/scaffold.d.ts +1 -72
- package/dist/codegen/scaffold.js +1 -150
- package/dist/codegen/write.d.ts +1 -6
- package/dist/codegen/write.js +1 -32
- package/dist/commands/clint-project-init.js +2 -2
- package/dist/commands/clint-project-regen.js +1 -1
- package/dist/commands/clint-skills-sync.d.ts +1 -1
- package/dist/commands/clint-skills-sync.js +1 -1
- package/dist/framework.js +1 -1
- package/dist/skills/sync.d.ts +1 -40
- package/dist/skills/sync.js +1 -119
- package/dist/spec/ensure-document.js +9 -15
- package/dist/spec/file.d.ts +1 -4
- package/dist/spec/file.js +1 -34
- package/dist/spec/types.d.ts +1 -164
- package/dist/spec/types.js +1 -209
- package/dist/triggers/publish-trigger.js +1 -1
- package/dist/triggers/spec-change.js +7 -1
- package/package.json +9 -9
|
@@ -1,128 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Builds the CLI-side `package.json` (the ph-clint CLI itself).
|
|
3
|
-
*
|
|
4
|
-
* When `features.powerhouse.enabled`, this file lives at
|
|
5
|
-
* `{root}/{name}-cli/package.json`. Otherwise at `{root}/package.json`.
|
|
6
|
-
*/
|
|
7
|
-
import { getAppDirName, getAppPackageName, getBinName, getPackageName, phAtLeast, } from '../../spec/types.js';
|
|
8
|
-
import { CLI_VERSION } from '../../config.js';
|
|
9
|
-
import { getPhVersion } from '../scaffold.js';
|
|
10
|
-
/**
|
|
11
|
-
* Derive a semver range from the running ph-clint-cli version that respects
|
|
12
|
-
* the dev / staging / production channel boundary. This is the version range
|
|
13
|
-
* emitted into *scaffolded* projects' package.json for @powerhousedao/ph-clint
|
|
14
|
-
* and @powerhousedao/ph-clint-dev dependencies.
|
|
15
|
-
*
|
|
16
|
-
* CLI_VERSION is the version of ph-clint-cli itself (read from its own
|
|
17
|
-
* package.json at startup). Since all framework packages share a lockstep
|
|
18
|
-
* version, this is also the correct base for the dependency range.
|
|
19
|
-
*
|
|
20
|
-
* Examples:
|
|
21
|
-
* "0.1.0" → "^0.1.0" (production — stable only)
|
|
22
|
-
* "0.1.0-staging.2" → "^0.1.0-staging.0" (staging + stable)
|
|
23
|
-
* "0.1.0-dev.4" → "^0.1.0-dev.0" (dev + staging + stable)
|
|
24
|
-
*
|
|
25
|
-
* This works because semver orders prereleases alphabetically:
|
|
26
|
-
* dev.N < staging.N < release. A caret range starting at dev.0 naturally
|
|
27
|
-
* upgrades through staging to production.
|
|
28
|
-
*/
|
|
29
|
-
function phClintRange(version) {
|
|
30
|
-
const match = /^(\d+\.\d+\.\d+)(?:-([a-z]+)\.\d+)?/.exec(version);
|
|
31
|
-
if (!match)
|
|
32
|
-
return `^${version}`;
|
|
33
|
-
const base = match[1];
|
|
34
|
-
const channel = match[2]; // "dev", "staging", or undefined
|
|
35
|
-
// For prerelease channels, pin exact version. Caret ranges like ^0.1.0-dev.0
|
|
36
|
-
// resolve to `latest` dist-tag (0.1.0-dev.0) instead of the highest match,
|
|
37
|
-
// causing "export not found" errors when the scaffolding CLI is newer.
|
|
38
|
-
return channel ? version : `^${base}`;
|
|
39
|
-
}
|
|
40
|
-
/** Version range for @powerhousedao/ph-clint{,-dev} deps in scaffolded projects. */
|
|
41
|
-
const PH_CLINT_VERSION = phClintRange(CLI_VERSION);
|
|
42
|
-
const POWERHOUSE_VERSION_FALLBACK = '6.0.0-dev.170';
|
|
43
|
-
let _powerhouseVersion;
|
|
44
|
-
function getPowerhouseVersion() {
|
|
45
|
-
if (_powerhouseVersion === undefined) {
|
|
46
|
-
_powerhouseVersion = getPhVersion('ph') ?? POWERHOUSE_VERSION_FALLBACK;
|
|
47
|
-
}
|
|
48
|
-
return _powerhouseVersion;
|
|
49
|
-
}
|
|
50
|
-
export function buildCliPackageJson(spec) {
|
|
51
|
-
const { mastra, powerhouse } = spec.features;
|
|
52
|
-
const pkgName = getPackageName(spec);
|
|
53
|
-
const bin = getBinName(spec);
|
|
54
|
-
const dependencies = {
|
|
55
|
-
'@powerhousedao/ph-clint': PH_CLINT_VERSION,
|
|
56
|
-
zod: '^4.3.6',
|
|
57
|
-
};
|
|
58
|
-
if (mastra.enabled) {
|
|
59
|
-
dependencies['@mastra/core'] = '^1.22.0';
|
|
60
|
-
dependencies['@mastra/libsql'] = '^1.7.4';
|
|
61
|
-
dependencies['@mastra/mcp'] = '^1.4.1';
|
|
62
|
-
dependencies['@mastra/memory'] = '^1.13.1';
|
|
63
|
-
}
|
|
64
|
-
if (phAtLeast(powerhouse, 'Reactor')) {
|
|
65
|
-
const appPkg = getAppPackageName(spec);
|
|
66
|
-
const appDir = getAppDirName(spec);
|
|
67
|
-
dependencies[appPkg] = `file:../${appDir}`;
|
|
68
|
-
dependencies['@powerhousedao/reactor'] = getPowerhouseVersion();
|
|
69
|
-
dependencies['@powerhousedao/reactor-api'] = getPowerhouseVersion();
|
|
70
|
-
dependencies['@powerhousedao/shared'] = getPowerhouseVersion();
|
|
71
|
-
dependencies['document-model'] = getPowerhouseVersion();
|
|
72
|
-
// External reactor packages (non-app) as versioned dependencies.
|
|
73
|
-
// Compare bare names (without scope) so that a spec entry with
|
|
74
|
-
// packageName "foo-app" still matches the scoped "@scope/foo-app".
|
|
75
|
-
const appBare = appPkg.replace(/^@[^/]+\//, '');
|
|
76
|
-
for (const pkg of spec.packages) {
|
|
77
|
-
const pkgBare = pkg.packageName.replace(/^@[^/]+\//, '');
|
|
78
|
-
if (pkgBare === appBare)
|
|
79
|
-
continue;
|
|
80
|
-
dependencies[pkg.packageName] = 'latest';
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const scripts = {
|
|
84
|
-
'build:skills': 'tsx scripts/build-skills.ts',
|
|
85
|
-
'build:manifest': 'build-manifest',
|
|
86
|
-
build: 'pnpm build:skills && tsc && pnpm build:manifest',
|
|
87
|
-
dev: 'tsx src/main.ts',
|
|
88
|
-
start: 'node dist/main.js',
|
|
89
|
-
test: "NODE_OPTIONS='--experimental-vm-modules' jest --detectOpenHandles",
|
|
90
|
-
lint: 'eslint src',
|
|
91
|
-
};
|
|
92
|
-
if (mastra.enabled) {
|
|
93
|
-
scripts['mastra:dev'] = 'mastra dev';
|
|
94
|
-
scripts['mastra:build'] = 'mastra build';
|
|
95
|
-
scripts['mastra:start'] = 'mastra start';
|
|
96
|
-
}
|
|
97
|
-
// Single-layout: publish scripts live in the CLI package.json (which IS the
|
|
98
|
-
// root). Split-layout gets these from root-package-json.ts instead.
|
|
99
|
-
if (!phAtLeast(powerhouse, 'Reactor')) {
|
|
100
|
-
scripts['publish:dev'] = 'ph-publish dev -c ./publish.config.js';
|
|
101
|
-
scripts['publish:staging'] = 'ph-publish staging -c ./publish.config.js';
|
|
102
|
-
scripts['publish:production'] = 'ph-publish production -c ./publish.config.js';
|
|
103
|
-
}
|
|
104
|
-
const pkg = {
|
|
105
|
-
name: pkgName,
|
|
106
|
-
version: spec.version,
|
|
107
|
-
publishConfig: { access: 'public' },
|
|
108
|
-
type: 'module',
|
|
109
|
-
};
|
|
110
|
-
if (spec.description)
|
|
111
|
-
pkg.description = spec.description;
|
|
112
|
-
pkg.bin = { [bin]: './dist/main.js' };
|
|
113
|
-
pkg.files = ['dist'];
|
|
114
|
-
pkg.scripts = scripts;
|
|
115
|
-
pkg.dependencies = dependencies;
|
|
116
|
-
pkg.devDependencies = {
|
|
117
|
-
'@jest/globals': '^30.2.0',
|
|
118
|
-
'@types/node': '^25.5.2',
|
|
119
|
-
jest: '^30.2.0',
|
|
120
|
-
'@powerhousedao/ph-clint-dev': PH_CLINT_VERSION,
|
|
121
|
-
'ts-jest': '^29.4.6',
|
|
122
|
-
tsx: '^4.19.0',
|
|
123
|
-
typescript: '^6.0.2',
|
|
124
|
-
'typescript-eslint': '^8.33.0',
|
|
125
|
-
};
|
|
126
|
-
pkg.engines = { node: '>=22.13.0' };
|
|
127
|
-
return JSON.stringify(pkg, null, 2) + '\n';
|
|
128
|
-
}
|
|
1
|
+
export { buildCliPackageJson } from '@powerhousedao/ph-clint-dev/codegen/builders';
|
|
@@ -1,51 +1 @@
|
|
|
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';
|
|
1
|
+
export { type FileBuilder, CLI_FILE_BUILDERS, getProfileFileBuilders, buildCliPackageJson, buildCliTs, buildConfigTs, buildMainTs, buildTsconfigJson, buildJestConfigJs, buildEslintConfigJs, buildGitignore, buildMastraIndexTs, buildBuildSkillsScript, buildAgentBaseMd, buildAgentTs, buildDemoAgentTs, buildFrameworkGenTs, buildFrameworkTs, buildManifestJson, buildSmokeTestTs, buildRootPackageJson, buildPublishConfigJs, buildReadme, buildAppIndexTs, } from '@powerhousedao/ph-clint-dev/codegen/builders';
|
|
@@ -1,84 +1 @@
|
|
|
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';
|
|
1
|
+
export { CLI_FILE_BUILDERS, getProfileFileBuilders, buildCliPackageJson, buildCliTs, buildConfigTs, buildMainTs, buildTsconfigJson, buildJestConfigJs, buildEslintConfigJs, buildGitignore, buildMastraIndexTs, buildBuildSkillsScript, buildAgentBaseMd, buildAgentTs, buildDemoAgentTs, buildFrameworkGenTs, buildFrameworkTs, buildManifestJson, buildSmokeTestTs, buildRootPackageJson, buildPublishConfigJs, buildReadme, buildAppIndexTs, } from '@powerhousedao/ph-clint-dev/codegen/builders';
|
package/dist/codegen/exec.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function hasCommandOnPath(command: string): Promise<boolean>;
|
|
1
|
+
export { hasCommandOnPath, getPhVersion, } from '@powerhousedao/ph-clint-dev/codegen/exec';
|
package/dist/codegen/exec.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Small helpers for invoking external commands during code generation.
|
|
3
|
-
*/
|
|
4
|
-
import { spawn } from 'node:child_process';
|
|
5
|
-
/** Returns true if `command` is on PATH. */
|
|
6
|
-
export async function hasCommandOnPath(command) {
|
|
7
|
-
return new Promise((resolve) => {
|
|
8
|
-
const child = spawn(process.platform === 'win32' ? 'where' : 'which', [command], {
|
|
9
|
-
stdio: 'ignore',
|
|
10
|
-
});
|
|
11
|
-
child.once('error', () => resolve(false));
|
|
12
|
-
child.once('close', (code) => resolve(code === 0));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
1
|
+
export { hasCommandOnPath, getPhVersion, } from '@powerhousedao/ph-clint-dev/codegen/exec';
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export interface GeneratedState {
|
|
3
|
-
name: string;
|
|
4
|
-
scope: string | undefined;
|
|
5
|
-
cliFolderName: string;
|
|
6
|
-
appFolderName: string;
|
|
7
|
-
/** True once `ph init` has run successfully in the app dir. */
|
|
8
|
-
appInitialized: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare function getGeneratedPath(targetDir: string): string;
|
|
11
|
-
export declare function readGeneratedState(targetDir: string): Promise<GeneratedState | null>;
|
|
12
|
-
export declare function writeGeneratedState(targetDir: string, state: GeneratedState): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Derive a `GeneratedState` from a spec. The `appInitialized` flag must be
|
|
15
|
-
* supplied by the caller (it depends on filesystem state, not the spec).
|
|
16
|
-
*/
|
|
17
|
-
export declare function generatedStateFromSpec(spec: ClintProjectSpec, appInitialized: boolean): GeneratedState;
|
|
1
|
+
export { type GeneratedState, getGeneratedPath, readGeneratedState, writeGeneratedState, generatedStateFromSpec, } from '@powerhousedao/ph-clint-dev/codegen/generated';
|
|
@@ -1,49 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Tracks the derived state from the last successful code generation.
|
|
3
|
-
*
|
|
4
|
-
* Stored at `{targetDir}/.ph/ph-clint-cli/generated.json`. Used to detect
|
|
5
|
-
* folder renames (name/scope changes) and re-apply patches that depend on
|
|
6
|
-
* the project identity.
|
|
7
|
-
*/
|
|
8
|
-
import fs from 'node:fs/promises';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import { getAppFolderName, getCliFolderName, } from '../spec/types.js';
|
|
11
|
-
const GEN_DIR = path.join('.ph', 'ph-clint-cli');
|
|
12
|
-
const GEN_FILE = 'generated.json';
|
|
13
|
-
export function getGeneratedPath(targetDir) {
|
|
14
|
-
return path.join(targetDir, GEN_DIR, GEN_FILE);
|
|
15
|
-
}
|
|
16
|
-
export async function readGeneratedState(targetDir) {
|
|
17
|
-
try {
|
|
18
|
-
const raw = await fs.readFile(getGeneratedPath(targetDir), 'utf8');
|
|
19
|
-
return JSON.parse(raw);
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
if (err &&
|
|
23
|
-
typeof err === 'object' &&
|
|
24
|
-
'code' in err &&
|
|
25
|
-
err.code === 'ENOENT') {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
throw err;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export async function writeGeneratedState(targetDir, state) {
|
|
32
|
-
const file = getGeneratedPath(targetDir);
|
|
33
|
-
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
34
|
-
await fs.writeFile(file, JSON.stringify(state, null, 2) + '\n', 'utf8');
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Derive a `GeneratedState` from a spec. The `appInitialized` flag must be
|
|
38
|
-
* supplied by the caller (it depends on filesystem state, not the spec).
|
|
39
|
-
*/
|
|
40
|
-
export function generatedStateFromSpec(spec, appInitialized) {
|
|
41
|
-
const split = spec.features.powerhouse !== 'Disabled';
|
|
42
|
-
return {
|
|
43
|
-
name: spec.name,
|
|
44
|
-
scope: spec.scope,
|
|
45
|
-
cliFolderName: split ? getCliFolderName(spec) : '',
|
|
46
|
-
appFolderName: split ? getAppFolderName(spec) : '',
|
|
47
|
-
appInitialized,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
1
|
+
export { getGeneratedPath, readGeneratedState, writeGeneratedState, generatedStateFromSpec, } from '@powerhousedao/ph-clint-dev/codegen/generated';
|
package/dist/codegen/hashes.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export type HashRecord
|
|
2
|
-
export declare function getHashesPath(targetDir: string): string;
|
|
3
|
-
export declare function hashContent(content: string): string;
|
|
4
|
-
export declare function hashFile(filePath: string): Promise<string | null>;
|
|
5
|
-
export declare function readHashes(targetDir: string): Promise<HashRecord>;
|
|
6
|
-
export declare function writeHashes(targetDir: string, hashes: HashRecord): Promise<void>;
|
|
1
|
+
export { type HashRecord, getHashesPath, hashContent, hashFile, readHashes, writeHashes, } from '@powerhousedao/ph-clint-dev/codegen/hashes';
|
package/dist/codegen/hashes.js
CHANGED
|
@@ -1,60 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Per-file content hashes written by the generator so subsequent runs can
|
|
3
|
-
* detect whether a previously-generated file has been hand-edited.
|
|
4
|
-
*
|
|
5
|
-
* Stored at `{targetDir}/.ph/ph-clint-cli/.hashes.json` alongside the project
|
|
6
|
-
* spec. Keys are paths relative to the project root.
|
|
7
|
-
*/
|
|
8
|
-
import crypto from 'node:crypto';
|
|
9
|
-
import fs from 'node:fs/promises';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
const HASHES_DIR = path.join('.ph', 'ph-clint-cli');
|
|
12
|
-
const HASHES_FILE = '.hashes.json';
|
|
13
|
-
export function getHashesPath(targetDir) {
|
|
14
|
-
return path.join(targetDir, HASHES_DIR, HASHES_FILE);
|
|
15
|
-
}
|
|
16
|
-
export function hashContent(content) {
|
|
17
|
-
return crypto.createHash('sha256').update(content, 'utf8').digest('hex');
|
|
18
|
-
}
|
|
19
|
-
function isEnoent(err) {
|
|
20
|
-
return (!!err &&
|
|
21
|
-
typeof err === 'object' &&
|
|
22
|
-
'code' in err &&
|
|
23
|
-
err.code === 'ENOENT');
|
|
24
|
-
}
|
|
25
|
-
export async function hashFile(filePath) {
|
|
26
|
-
try {
|
|
27
|
-
const content = await fs.readFile(filePath, 'utf8');
|
|
28
|
-
return hashContent(content);
|
|
29
|
-
}
|
|
30
|
-
catch (err) {
|
|
31
|
-
if (isEnoent(err))
|
|
32
|
-
return null;
|
|
33
|
-
throw err;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export async function readHashes(targetDir) {
|
|
37
|
-
try {
|
|
38
|
-
const raw = await fs.readFile(getHashesPath(targetDir), 'utf8');
|
|
39
|
-
const parsed = JSON.parse(raw);
|
|
40
|
-
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
41
|
-
return parsed;
|
|
42
|
-
}
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
if (isEnoent(err))
|
|
47
|
-
return {};
|
|
48
|
-
throw err;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export async function writeHashes(targetDir, hashes) {
|
|
52
|
-
const file = getHashesPath(targetDir);
|
|
53
|
-
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
54
|
-
// Sort keys for stable output across runs.
|
|
55
|
-
const sorted = {};
|
|
56
|
-
for (const key of Object.keys(hashes).sort()) {
|
|
57
|
-
sorted[key] = hashes[key];
|
|
58
|
-
}
|
|
59
|
-
await fs.writeFile(file, JSON.stringify(sorted, null, 2) + '\n', 'utf8');
|
|
60
|
-
}
|
|
1
|
+
export { getHashesPath, hashContent, hashFile, readHashes, writeHashes, } from '@powerhousedao/ph-clint-dev/codegen/hashes';
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -1,42 +1,11 @@
|
|
|
1
|
-
import { type ClintProjectSpec } from '../spec/types.js';
|
|
2
|
-
import { type PostGenAction } from './actions.js';
|
|
3
|
-
export type GenerateMode = 'create' | 'update' | 'auto';
|
|
4
|
-
export interface GenerateProjectOptions {
|
|
5
|
-
/** Absolute path to the project root. */
|
|
6
|
-
targetDir: string;
|
|
7
|
-
spec: ClintProjectSpec;
|
|
8
|
-
/** Defaults to `'auto'` — create if no persisted spec, else update. */
|
|
9
|
-
mode?: GenerateMode;
|
|
10
|
-
/** Create mode: allow writing into a non-empty directory. */
|
|
11
|
-
allowNonEmpty?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Update mode: overwrite user-edited files (hash-mismatch) anyway.
|
|
14
|
-
* Also relaxes the git-dirty guard on flat → split migration.
|
|
15
|
-
*/
|
|
16
|
-
force?: boolean;
|
|
17
|
-
/** Optional warning sink (diagnostics, not errors). */
|
|
18
|
-
onWarn?: (msg: string) => void;
|
|
19
|
-
}
|
|
20
|
-
export interface GeneratedFile {
|
|
21
|
-
absolutePath: string;
|
|
22
|
-
relativePath: string;
|
|
23
|
-
}
|
|
24
|
-
export interface GenerateProjectResult {
|
|
25
|
-
mode: 'create' | 'update';
|
|
26
|
-
/** Files newly written or rewritten. */
|
|
27
|
-
files: GeneratedFile[];
|
|
28
|
-
/** Files skipped because the user had edited them. */
|
|
29
|
-
skipped: GeneratedFile[];
|
|
30
|
-
/** Files removed because the new spec no longer emits them. */
|
|
31
|
-
deleted: GeneratedFile[];
|
|
32
|
-
/** True if a flat → split migration ran. */
|
|
33
|
-
migrated: boolean;
|
|
34
|
-
cliDir: string;
|
|
35
|
-
appDir: string | null;
|
|
36
|
-
/** Pending post-generation actions derived from what changed. */
|
|
37
|
-
pendingActions: PostGenAction[];
|
|
38
|
-
}
|
|
39
1
|
/**
|
|
40
|
-
*
|
|
2
|
+
* Re-exports from @powerhousedao/ph-clint-dev/codegen with CLI_VERSION default.
|
|
41
3
|
*/
|
|
4
|
+
import { type GenerateProjectOptions as DevGenerateProjectOptions, type GenerateProjectResult, type GenerateMode, type GeneratedFile } from '@powerhousedao/ph-clint-dev/codegen';
|
|
5
|
+
import type { CodegenContext } from '@powerhousedao/ph-clint-dev/codegen/types';
|
|
6
|
+
export type { GenerateProjectResult, GenerateMode, GeneratedFile, CodegenContext };
|
|
7
|
+
export interface GenerateProjectOptions extends Omit<DevGenerateProjectOptions, 'context'> {
|
|
8
|
+
/** Codegen context; defaults to CLI_VERSION when omitted. */
|
|
9
|
+
context?: CodegenContext;
|
|
10
|
+
}
|
|
42
11
|
export declare function generateProject(options: GenerateProjectOptions): Promise<GenerateProjectResult>;
|