@powerhousedao/ph-cli 6.4.0-next.3 → 6.4.0-next.5

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 (128) hide show
  1. package/dist/auth-5bqHASGL.mjs +4 -0
  2. package/dist/auth-DYknkWfW.mjs +23 -0
  3. package/dist/auth-DYknkWfW.mjs.map +1 -0
  4. package/dist/{build-B-rPwjM8.mjs → build-CBKlv5E3.mjs} +8 -8
  5. package/dist/{build-B-rPwjM8.mjs.map → build-CBKlv5E3.mjs.map} +1 -1
  6. package/dist/build-Dr1lnv4h.mjs +4 -0
  7. package/dist/{check-B7C3Vi_b.mjs → check-CW81vbe9.mjs} +4 -4
  8. package/dist/{check-B7C3Vi_b.mjs.map → check-CW81vbe9.mjs.map} +1 -1
  9. package/dist/{check-DM7UdFTK.mjs → check-Cx_AeBQe.mjs} +7 -7
  10. package/dist/check-Cx_AeBQe.mjs.map +1 -0
  11. package/dist/{check-DeUTd514.mjs → check-DhFd9tO8.mjs} +3 -3
  12. package/dist/{cli-connect-override-Bx_g3-ZE.mjs → cli-connect-override-DKxY3lCi.mjs} +4 -4
  13. package/dist/{cli-connect-override-Bx_g3-ZE.mjs.map → cli-connect-override-DKxY3lCi.mjs.map} +1 -1
  14. package/dist/cli.mjs +9 -8
  15. package/dist/cli.mjs.map +1 -1
  16. package/dist/{compound-Q9sZSEZF-DQvtoigb.mjs → compound-g6x_KkWp-Bs7olmlI.mjs} +465 -361
  17. package/dist/compound-g6x_KkWp-Bs7olmlI.mjs.map +1 -0
  18. package/dist/{connect-build-CaTxdYcc.mjs → connect-build-DpGUrtct.mjs} +5 -5
  19. package/dist/{connect-build-CaTxdYcc.mjs.map → connect-build-DpGUrtct.mjs.map} +1 -1
  20. package/dist/{connect-config-A-U83U8U.mjs → connect-config-BpzwJln3.mjs} +4 -4
  21. package/dist/{connect-config-A-U83U8U.mjs.map → connect-config-BpzwJln3.mjs.map} +1 -1
  22. package/dist/{connect-preview-BvxXGo_W.mjs → connect-preview-B_E4SIV6.mjs} +21 -4
  23. package/dist/connect-preview-B_E4SIV6.mjs.map +1 -0
  24. package/dist/connect-studio-BPZOcwUM.mjs +214 -0
  25. package/dist/connect-studio-BPZOcwUM.mjs.map +1 -0
  26. package/dist/credentials-CmtYywgk.mjs +132 -0
  27. package/dist/credentials-CmtYywgk.mjs.map +1 -0
  28. package/dist/definitions-worker.mjs +4 -4
  29. package/dist/definitions-worker.mjs.map +1 -1
  30. package/dist/{dev-host-RhWeATKB.mjs → dev-host-CM-Jg2kY.mjs} +4 -4
  31. package/dist/{dev-host-RhWeATKB.mjs.map → dev-host-CM-Jg2kY.mjs.map} +1 -1
  32. package/dist/{dist-D_UjZsgt.mjs → dist-DPj_FB8H.mjs} +5 -5
  33. package/dist/dist-DPj_FB8H.mjs.map +1 -0
  34. package/dist/{explain-DbbHpa61.mjs → explain-DQ5ymlco.mjs} +5 -5
  35. package/dist/{explain-DbbHpa61.mjs.map → explain-DQ5ymlco.mjs.map} +1 -1
  36. package/dist/{export-FduYVQEM.mjs → export-CzeF8pob.mjs} +4 -4
  37. package/dist/{export-FduYVQEM.mjs.map → export-CzeF8pob.mjs.map} +1 -1
  38. package/dist/{files-DEHg350R.mjs → files-D6_euBBn.mjs} +4 -4
  39. package/dist/{files-DEHg350R.mjs.map → files-D6_euBBn.mjs.map} +1 -1
  40. package/dist/{generate-all-BE8UmbJv.mjs → generate-all-B9MwWXlq.mjs} +4 -4
  41. package/dist/{generate-all-BE8UmbJv.mjs.map → generate-all-B9MwWXlq.mjs.map} +1 -1
  42. package/dist/{generate-document-model-DSYPTMZg.mjs → generate-document-model-D3LKY1D7.mjs} +6 -8
  43. package/dist/generate-document-model-D3LKY1D7.mjs.map +1 -0
  44. package/dist/{generate-subgraph-EQ2ZjMp9.mjs → generate-subgraph-Q1VLh3SC.mjs} +10 -17
  45. package/dist/generate-subgraph-Q1VLh3SC.mjs.map +1 -0
  46. package/dist/{get-version-7oKMD8Gt.mjs → get-version-CTP__ORu.mjs} +4 -4
  47. package/dist/{get-version-7oKMD8Gt.mjs.map → get-version-CTP__ORu.mjs.map} +1 -1
  48. package/dist/identity-DXZFeQfC.mjs +137 -0
  49. package/dist/identity-DXZFeQfC.mjs.map +1 -0
  50. package/dist/{index-Bs1PfL3W.d.mts → index-aosqo7aM.d.mts} +5 -4
  51. package/dist/index-aosqo7aM.d.mts.map +1 -0
  52. package/dist/{inspect-CulIpVsF.mjs → inspect-BgKI8Fhd.mjs} +6 -6
  53. package/dist/{inspect-CulIpVsF.mjs.map → inspect-BgKI8Fhd.mjs.map} +1 -1
  54. package/dist/{keyframes-bFo9iDhT.mjs → keyframes-BkeORfEu.mjs} +4 -4
  55. package/dist/{keyframes-bFo9iDhT.mjs.map → keyframes-BkeORfEu.mjs.map} +1 -1
  56. package/dist/{mcp-CcZT9zT9.mjs → mcp-gcG7SW9L.mjs} +149 -7
  57. package/dist/mcp-gcG7SW9L.mjs.map +1 -0
  58. package/dist/{migrate-Ddr7YAtM.mjs → migrate-BaWZhorc.mjs} +4 -4
  59. package/dist/{migrate-Ddr7YAtM.mjs.map → migrate-BaWZhorc.mjs.map} +1 -1
  60. package/dist/{migrate-document-models-X_mVTljj.mjs → migrate-document-models-DYmkJzq3.mjs} +5 -6
  61. package/dist/migrate-document-models-DYmkJzq3.mjs.map +1 -0
  62. package/dist/{migrate-subgraphs-Ffwwm7Oy.mjs → migrate-subgraphs-BUgTeHcm.mjs} +6 -7
  63. package/dist/migrate-subgraphs-BUgTeHcm.mjs.map +1 -0
  64. package/dist/migrate-subgraphs-ChhXynqd.mjs +4 -0
  65. package/dist/{ph-cli-commands-D4Z6YSwd.mjs → ph-cli-commands-B5VkGW99.mjs} +161 -107
  66. package/dist/ph-cli-commands-B5VkGW99.mjs.map +1 -0
  67. package/dist/ph-cli-commands-CGXSo1wx.mjs +4 -0
  68. package/dist/{registry-auth-Bm5AR-fB.mjs → registry-auth-C8D5cno2.mjs} +4 -4
  69. package/dist/{registry-auth-Bm5AR-fB.mjs.map → registry-auth-C8D5cno2.mjs.map} +1 -1
  70. package/dist/render-BQE20Cnd.mjs +4 -0
  71. package/dist/{render-SVfj3m8A.mjs → render-CQdi685k.mjs} +6 -6
  72. package/dist/render-CQdi685k.mjs.map +1 -0
  73. package/dist/{run-LRGy7zGo.mjs → run-C6Vha5VN.mjs} +3 -3
  74. package/dist/{run--de_-WAz.mjs → run-sVzTTEUx.mjs} +5 -36
  75. package/dist/run-sVzTTEUx.mjs.map +1 -0
  76. package/dist/{run-sugar-CkuGJuPg.mjs → run-sugar-BuxOaRzE.mjs} +5 -5
  77. package/dist/{run-sugar-CkuGJuPg.mjs.map → run-sugar-BuxOaRzE.mjs.map} +1 -1
  78. package/dist/{run-sugar-Dd_Mu058.mjs → run-sugar-Dz-rpeMO.mjs} +3 -3
  79. package/dist/runners/connect.d.mts +20 -3
  80. package/dist/runners/connect.d.mts.map +1 -1
  81. package/dist/runners/connect.mjs +37 -15
  82. package/dist/runners/connect.mjs.map +1 -1
  83. package/dist/runners/switchboard.d.mts +1 -1
  84. package/dist/runners/switchboard.mjs +3 -3
  85. package/dist/scripts/generate-commands-docs.ts +12 -0
  86. package/dist/{subgraphs-7OYWwP-C.mjs → subgraphs-Bm9NHTCn.mjs} +5 -38
  87. package/dist/subgraphs-Bm9NHTCn.mjs.map +1 -0
  88. package/dist/{sugar-checks-CAtgUIem.mjs → sugar-checks-DL-J3l2y.mjs} +6 -6
  89. package/dist/{sugar-checks-CAtgUIem.mjs.map → sugar-checks-DL-J3l2y.mjs.map} +1 -1
  90. package/dist/{verify-DXrs0JUp.mjs → verify-BLn76w09.mjs} +5 -5
  91. package/dist/{verify-DXrs0JUp.mjs.map → verify-BLn76w09.mjs.map} +1 -1
  92. package/dist/{vetra-gateway-BHuz7pvS.mjs → vetra-gateway-D30pZgha.mjs} +5 -5
  93. package/dist/{vetra-gateway-BHuz7pvS.mjs.map → vetra-gateway-D30pZgha.mjs.map} +1 -1
  94. package/dist/vetra-gateway-DE5Hc0Fp.mjs +4 -0
  95. package/dist/vetra-host-0rSW35_r.mjs +230 -0
  96. package/dist/vetra-host-0rSW35_r.mjs.map +1 -0
  97. package/dist/{vetra-launcher-B5L3yXPo.mjs → vetra-launcher-6NKfi6Au.mjs} +45 -5
  98. package/dist/vetra-launcher-6NKfi6Au.mjs.map +1 -0
  99. package/dist/vetra-launcher-XMk_Hv0c.mjs +4 -0
  100. package/package.json +17 -15
  101. package/dist/auth-BFUq7CvE.mjs +0 -18
  102. package/dist/auth-BFUq7CvE.mjs.map +0 -1
  103. package/dist/auth-CNhbN5UM.mjs +0 -4
  104. package/dist/build-DuwAPWMY.mjs +0 -4
  105. package/dist/check-DM7UdFTK.mjs.map +0 -1
  106. package/dist/compound-Q9sZSEZF-DQvtoigb.mjs.map +0 -1
  107. package/dist/connect-preview-BvxXGo_W.mjs.map +0 -1
  108. package/dist/connect-studio-B2gugCJU.mjs +0 -106
  109. package/dist/connect-studio-B2gugCJU.mjs.map +0 -1
  110. package/dist/dist-D_UjZsgt.mjs.map +0 -1
  111. package/dist/generate-document-model-DSYPTMZg.mjs.map +0 -1
  112. package/dist/generate-subgraph-EQ2ZjMp9.mjs.map +0 -1
  113. package/dist/index-Bs1PfL3W.d.mts.map +0 -1
  114. package/dist/mcp-CcZT9zT9.mjs.map +0 -1
  115. package/dist/migrate-document-models-X_mVTljj.mjs.map +0 -1
  116. package/dist/migrate-subgraphs-DEqWkLoh.mjs +0 -4
  117. package/dist/migrate-subgraphs-Ffwwm7Oy.mjs.map +0 -1
  118. package/dist/ph-cli-commands-D4Z6YSwd.mjs.map +0 -1
  119. package/dist/ph-cli-commands-p9cO6MsE.mjs +0 -4
  120. package/dist/render-3M3DwFzO.mjs +0 -4
  121. package/dist/render-SVfj3m8A.mjs.map +0 -1
  122. package/dist/run--de_-WAz.mjs.map +0 -1
  123. package/dist/subgraphs-7OYWwP-C.mjs.map +0 -1
  124. package/dist/vetra-gateway-ag33E_Ta.mjs +0 -4
  125. package/dist/vetra-host-CYdbd3J3.mjs +0 -111
  126. package/dist/vetra-host-CYdbd3J3.mjs.map +0 -1
  127. package/dist/vetra-launcher-B5L3yXPo.mjs.map +0 -1
  128. package/dist/vetra-launcher-BUO9e74r.mjs +0 -4
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-subgraphs-Ffwwm7Oy.mjs","sources":["../src/services/installed-version.ts","../src/services/project-files.ts","../src/services/package-module-targets.ts","../src/services/project-module-references.ts","../src/services/subgraph-readers.ts","../src/services/migrate-subgraphs.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { lt, valid } from \"semver\";\nimport { getVersion } from \"../get-version.js\";\n\n/** The version of `packageName` that Node resolves from `projectDir`. */\nfunction installedVersion(\n projectDir: string,\n packageName: string,\n): string | undefined {\n for (let dir = projectDir; ; dir = dirname(dir)) {\n const manifest = join(dir, \"node_modules\", packageName, \"package.json\");\n if (existsSync(manifest)) {\n const { version } = JSON.parse(readFileSync(manifest, \"utf8\")) as {\n version?: unknown;\n };\n return typeof version === \"string\" ? version : undefined;\n }\n if (dirname(dir) === dir) return undefined;\n }\n}\n\n/**\n * Why the code `ph migrate` writes cannot run against the project's\n * `packageName`, or undefined when it can: the project must have the package\n * at this ph-cli's version or later. Unknown versions are not checked.\n */\nexport function outdatedDependency(\n projectDir: string,\n packageName: string,\n): string | undefined {\n const required = getVersion();\n if (valid(required) === null) return undefined;\n const installed = installedVersion(projectDir, packageName);\n if (installed === undefined) {\n return `${packageName} is not installed in this project. Install the project's dependencies, then migrate again.`;\n }\n if (valid(installed) === null || !lt(installed, required)) return undefined;\n return `This project has ${packageName} ${installed}, and what this ph migrate converts to code-first needs ${required} or later. Run ph migrate ${required} to upgrade the Powerhouse packages, then convert again.`;\n}\n","import { spawnSync } from \"node:child_process\";\nimport {\n chmodSync,\n existsSync,\n lstatSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmdirSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport {\n dirname,\n isAbsolute,\n join,\n posix,\n relative,\n resolve,\n sep,\n} from \"node:path\";\n\n/** Directories that never hold the package's own sources. */\nconst SKIPPED_DIRS = new Set([\n \"node_modules\",\n \"dist\",\n \"build\",\n \".ph\",\n \".git\",\n \".turbo\",\n \".vite\",\n \".tsbuild\",\n \"coverage\",\n]);\n\nexport const toPosix = (path: string) => path.split(sep).join(\"/\");\n\nexport const errorText = (error: unknown) =>\n error instanceof Error ? error.message : String(error);\n\n/**\n * Whether git ignores a file or directory, by project-relative POSIX path.\n * In a git work tree, the project's files are those `git ls-files` lists from\n * its directory: tracked ones, and untracked ones git does not ignore.\n * Outside a work tree, without git, or when git lists nothing there, as for a\n * project in an ignored directory of another repository, nothing is ignored.\n */\nexport function ignoredByGit(projectDir: string): (path: string) => boolean {\n const listed = spawnSync(\n \"git\",\n [\"ls-files\", \"--cached\", \"--others\", \"--exclude-standard\", \"-z\"],\n {\n cwd: projectDir,\n encoding: \"utf8\",\n maxBuffer: 256 * 1024 * 1024,\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n },\n );\n if (listed.status !== 0) return () => false;\n // Each listed file and the directories above it, which a walk enters.\n const kept = new Set<string>();\n for (const file of listed.stdout.split(\"\\0\")) {\n for (\n let path = file;\n path !== \"\" && path !== \".\" && !kept.has(path);\n path = posix.dirname(path)\n ) {\n kept.add(path);\n }\n }\n return kept.size === 0 ? () => false : (path) => !kept.has(path);\n}\n\n/**\n * The package's files whose names match `pattern`, by project-relative POSIX\n * path. Paths git ignores, such as build copies of sources, are left out.\n */\nexport function readProjectFiles(\n projectDir: string,\n pattern: RegExp,\n): Map<string, Buffer> {\n const files = new Map<string, Buffer>();\n const ignored = ignoredByGit(projectDir);\n const visit = (dir: string) => {\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const path = join(dir, entry.name);\n const local = toPosix(relative(projectDir, path));\n if (entry.isDirectory()) {\n if (!SKIPPED_DIRS.has(entry.name) && !ignored(local)) visit(path);\n } else if (\n entry.isFile() &&\n pattern.test(entry.name) &&\n !ignored(local)\n ) {\n files.set(local, readFileSync(path));\n }\n }\n };\n visit(projectDir);\n return files;\n}\n\n/** A file a migration writes, or deletes when `after` is null. */\nexport type FileChange = {\n readonly path: string;\n readonly after: string | null;\n};\n\n/** Each original file's contents and permissions, or null when it does not exist. */\nexport type FileBackup = ReadonlyMap<\n string,\n { readonly bytes: Buffer; readonly mode: number } | null\n>;\n\n/** Refuses links the source inventory cannot represent without following them. */\nexport function assertChangesWritable(\n projectDir: string,\n changes: readonly { readonly path: string }[],\n): void {\n const root = resolve(projectDir);\n for (const { path } of changes) {\n let current = resolve(root, path);\n const local = relative(root, current);\n if (\n local === \"\" ||\n local === \"..\" ||\n local.startsWith(`..${sep}`) ||\n isAbsolute(local)\n ) {\n throw new Error(`${path} is not a file inside this project.`);\n }\n while (current !== root) {\n if (lstatSync(current, { throwIfNoEntry: false })?.isSymbolicLink()) {\n throw new Error(\n `${toPosix(relative(root, current))} is a symbolic link. Replace it with a regular project file or directory before migrating; its target was not changed.`,\n );\n }\n current = dirname(current);\n }\n }\n}\n\n/**\n * Writes `changes` and returns the bytes they replaced. When a write fails,\n * everything already written is restored before the error is rethrown.\n */\nexport function writeChanges(\n projectDir: string,\n changes: readonly FileChange[],\n): FileBackup {\n assertChangesWritable(projectDir, changes);\n const backup = new Map<\n string,\n { readonly bytes: Buffer; readonly mode: number } | null\n >();\n for (const { path } of changes) {\n const absolute = join(projectDir, path);\n backup.set(\n path,\n existsSync(absolute)\n ? {\n bytes: readFileSync(absolute),\n mode: lstatSync(absolute).mode & 0o7777,\n }\n : null,\n );\n }\n try {\n for (const change of changes) put(projectDir, change.path, change.after);\n } catch (error) {\n restoreChanges(projectDir, backup);\n throw error;\n }\n return backup;\n}\n\n/** Restores the contents and permissions `writeChanges` replaced. */\nexport function restoreChanges(projectDir: string, backup: FileBackup) {\n for (const [path, file] of backup) {\n put(projectDir, path, file?.bytes ?? null);\n if (file !== null) chmodSync(join(projectDir, path), file.mode);\n }\n}\n\nfunction put(projectDir: string, path: string, bytes: string | Buffer | null) {\n const absolute = join(projectDir, path);\n if (bytes === null) {\n rmSync(absolute, { force: true });\n removeEmptyParents(projectDir, dirname(absolute));\n } else {\n mkdirSync(dirname(absolute), { recursive: true });\n writeFileSync(absolute, bytes);\n }\n}\n\n/** Removes `dir` and its parents while they are empty, up to the project. */\nfunction removeEmptyParents(projectDir: string, dir: string) {\n let current = dir;\n while (current.startsWith(projectDir) && current !== projectDir) {\n if (!existsSync(current) || readdirSync(current).length > 0) return;\n rmdirSync(current);\n current = dirname(current);\n }\n}\n","import { existsSync, realpathSync } from \"node:fs\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { type PackageJson, readPackageSync } from \"read-pkg\";\nimport { toPosix } from \"./project-files.js\";\n\n/** Every static alternative, without assuming which runtime conditions apply. */\nfunction alternatives(value: unknown): string[] {\n if (typeof value === \"string\") return [value];\n if (value === null || typeof value !== \"object\") return [];\n return Object.values(value).flatMap(alternatives);\n}\n\n/** Extra matching patterns are safe here: targets are protected, never rewritten. */\nfunction matchingTargets(\n mapping: unknown,\n specifier: string,\n): { pattern: string; targets: string[] }[] {\n if (mapping === null || typeof mapping !== \"object\") return [];\n return Object.entries(mapping).flatMap(([pattern, value]) => {\n if (pattern === specifier)\n return [{ pattern, targets: alternatives(value) }];\n const star = pattern.indexOf(\"*\");\n if (star === -1) return [];\n const prefix = pattern.slice(0, star);\n const suffix = pattern.slice(star + 1);\n if (\n !specifier.startsWith(prefix) ||\n !specifier.endsWith(suffix) ||\n specifier.length < prefix.length + suffix.length\n )\n return [];\n const matched = specifier.slice(\n prefix.length,\n specifier.length - suffix.length,\n );\n return [\n {\n pattern,\n targets: alternatives(value).map((target) =>\n target.replaceAll(\"*\", matched),\n ),\n },\n ];\n });\n}\n\n/** Static local targets of observed imports/self-exports in each file's package scope. */\nexport function packageModuleTargets(projectDir: string) {\n const root = resolve(projectDir);\n const packages = new Map<string, PackageJson | undefined>();\n const imports = (from: string, specifier: string) => {\n const redirects: { from: string; specifier: string }[] = [];\n let dir = dirname(join(root, from));\n for (;;) {\n if (!packages.has(dir)) {\n packages.set(\n dir,\n existsSync(join(dir, \"package.json\"))\n ? readPackageSync({ cwd: dir, normalize: false })\n : undefined,\n );\n }\n const metadata = packages.get(dir);\n if (metadata !== undefined) {\n const visit = (name: string, active: ReadonlySet<string>): string[] => {\n let matches: ReturnType<typeof matchingTargets> = [];\n if (name.startsWith(\"#\")) {\n matches = matchingTargets(metadata.imports, name);\n } else if (\n typeof metadata.name === \"string\" &&\n (name === metadata.name || name.startsWith(`${metadata.name}/`))\n ) {\n const subpath = `.${name.slice(metadata.name.length)}`;\n const exports = metadata.exports;\n const subpaths =\n exports !== null &&\n typeof exports === \"object\" &&\n Object.keys(exports).some((key) => key.startsWith(\".\"));\n matches =\n subpath === \".\" && !subpaths\n ? [{ pattern: \".\", targets: alternatives(exports) }]\n : matchingTargets(exports, subpath);\n }\n return matches.flatMap(({ pattern, targets }) => {\n const key = `${name.startsWith(\"#\") ? \"imports\" : \"exports\"}:${pattern}`;\n if (active.has(key)) {\n throw new Error(\n `Package mapping ${pattern} redirects recursively. Remove that redirect before migrating subgraphs.`,\n );\n }\n const next = new Set(active).add(key);\n return targets.flatMap((target) => {\n if (!target.startsWith(\"./\")) {\n if (\n target.startsWith(\"#\") ||\n (typeof metadata.name === \"string\" &&\n (target === metadata.name ||\n target.startsWith(`${metadata.name}/`)))\n ) {\n return visit(target, next);\n }\n redirects.push({\n from: toPosix(relative(root, join(dir, \"package.json\"))),\n specifier: target,\n });\n return [];\n }\n const file = fileURLToPath(\n new URL(target, pathToFileURL(dir + sep)),\n );\n return [toPosix(relative(root, file))];\n });\n });\n };\n return { targets: visit(specifier, new Set()), redirects };\n }\n if (dir === root) return { targets: [], redirects };\n dir = dirname(dir);\n }\n };\n const entries = (file: string, specifier: string): readonly string[] => {\n const targets = new Set<string>();\n for (const dir of new Set([dirname(file), dirname(realpathSync(file))])) {\n if (!packages.has(dir)) {\n packages.set(dir, readPackageSync({ cwd: dir, normalize: false }));\n }\n const metadata = packages.get(dir);\n if (metadata === undefined) continue;\n const paths = [\n \"./index.js\",\n ...alternatives(metadata.main),\n ...alternatives(metadata[\"module\"]),\n ...alternatives(metadata[\"browser\"]),\n ...alternatives(metadata[\"jsnext:main\"]),\n ...alternatives(metadata[\"jsnext\"]),\n ];\n const exports = metadata.exports;\n const subpaths =\n exports !== null &&\n typeof exports === \"object\" &&\n Object.keys(exports).some((key) => key.startsWith(\".\"));\n if (!subpaths) paths.push(...alternatives(exports));\n else {\n const parts = specifier.split(\"/\");\n const subpath = parts\n .slice(specifier.startsWith(\"@\") ? 2 : 1)\n .join(\"/\");\n for (const key of new Set([\n \".\",\n ...(subpath ? [`./${subpath}`] : []),\n ])) {\n paths.push(\n ...matchingTargets(exports, key).flatMap(({ targets }) => targets),\n );\n }\n }\n for (const target of paths) {\n // Legacy main fields are filesystem paths; URL-based loaders also decode them.\n targets.add(toPosix(relative(root, resolve(dir, target))));\n try {\n const url = new URL(target, pathToFileURL(dir + sep));\n if (url.protocol === \"file:\") {\n targets.add(toPosix(relative(root, fileURLToPath(url))));\n }\n } catch {\n // A literal filename need not be a valid URL.\n }\n }\n }\n return [...targets];\n };\n return { imports, entries };\n}\n","import { realpathSync } from \"node:fs\";\nimport { basename, join, posix, relative } from \"node:path\";\nimport { ts } from \"ts-morph\";\nimport { packageModuleTargets } from \"./package-module-targets.js\";\nimport { readProjectFiles, toPosix } from \"./project-files.js\";\n\nconst CODE_FILE = /\\.[cm]?[jt]sx?$/;\n\nexport type ProjectModuleReference = {\n readonly file: string;\n readonly specifier: string;\n /**\n * Some use of the specifier reads the module whole: a namespace import,\n * `export *`, or any use outside an import or export declaration, such as\n * a dynamic import.\n */\n readonly whole: boolean;\n readonly targets: readonly {\n readonly path: string;\n readonly throughPackage: boolean;\n }[];\n};\n\n/** Static module targets, including every package condition and redirected subpath. */\nexport function projectModuleReferences(\n projectDir: string,\n): readonly ProjectModuleReference[] {\n const root = realpathSync(projectDir);\n const configPath = ts.findConfigFile(root, (file) => ts.sys.fileExists(file));\n const configured =\n configPath === undefined\n ? undefined\n : ts.getParsedCommandLineOfConfigFile(\n configPath,\n {},\n {\n ...ts.sys,\n onUnRecoverableConfigFileDiagnostic: (diagnostic) => {\n throw new Error(\n ts.flattenDiagnosticMessageText(diagnostic.messageText, \"\\n\"),\n );\n },\n },\n );\n const options: ts.CompilerOptions = {\n ...configured?.options,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n resolvePackageJsonImports: true,\n resolvePackageJsonExports: true,\n };\n const resolutions = new Map<\n string,\n {\n file: string | undefined;\n packages: readonly string[];\n }\n >();\n const contents = new Map<string, string | undefined>();\n const packageTargets = packageModuleTargets(root);\n const references: ProjectModuleReference[] = [];\n for (const [sourcePath, bytes] of readProjectFiles(root, CODE_FILE)) {\n const source = ts.createSourceFile(\n sourcePath,\n bytes.toString(\"utf8\"),\n ts.ScriptTarget.Latest,\n true,\n );\n /** Each literal, and whether some use of it reads the module whole. */\n const literals = new Map<string, boolean>();\n const visit = (node: ts.Node) => {\n if (ts.isStringLiteralLike(node)) {\n literals.set(\n node.text,\n (literals.get(node.text) ?? false) || readsWhole(node),\n );\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n for (const [literal, whole] of literals) {\n const targets = new Map<string, boolean>();\n const requests = new Map<string, { from: string; named: string }>();\n const enqueue = (from: string, literal: string) => {\n const unqualified =\n literal.slice(0, 1) + literal.slice(1).split(/[?#]/, 1)[0];\n for (const named of new Set([literal, unqualified])) {\n requests.set(JSON.stringify([from, named]), { from, named });\n try {\n const decoded = decodeURIComponent(named);\n requests.set(JSON.stringify([from, decoded]), {\n from,\n named: decoded,\n });\n } catch {\n // Preserve literals that are not valid URL encodings as written.\n }\n }\n };\n enqueue(sourcePath, literal);\n for (const { from, named } of requests.values()) {\n const isRelative = /^\\.{1,2}\\//.test(named);\n const protect = (target: string, throughPackage = false) => {\n targets.set(target, throughPackage || targets.get(target) === true);\n };\n const protectPackageTarget = (target: string) => {\n protect(target, true);\n const stem = target.replace(CODE_FILE, \"\");\n for (const extension of [\n \"ts\",\n \"tsx\",\n \"mts\",\n \"cts\",\n \"js\",\n \"jsx\",\n \"mjs\",\n \"cjs\",\n ]) {\n protect(`${stem}.${extension}`, true);\n protect(`${stem}/index.${extension}`, true);\n }\n };\n const mapping = packageTargets.imports(from, named);\n for (const redirect of mapping.redirects) {\n enqueue(redirect.from, redirect.specifier);\n }\n for (const target of mapping.targets) {\n protectPackageTarget(target);\n }\n for (const mode of [\n ts.ModuleKind.ESNext,\n ts.ModuleKind.CommonJS,\n ] as const) {\n const key = JSON.stringify([posix.dirname(from), named, mode]);\n let resolution = resolutions.get(key);\n if (resolution === undefined) {\n const consulted = new Set<string>();\n const resolved = ts.resolveModuleName(\n named,\n join(root, from),\n options,\n {\n ...ts.sys,\n readFile: (file) => {\n if (!contents.has(file))\n contents.set(file, ts.sys.readFile(file));\n const text = contents.get(file);\n if (text !== undefined && basename(file) === \"package.json\")\n consulted.add(file);\n return text;\n },\n },\n undefined,\n undefined,\n mode,\n ).resolvedModule;\n resolution = {\n file: resolved?.resolvedFileName,\n packages: [...consulted],\n };\n resolutions.set(key, resolution);\n }\n if (resolution.file !== undefined) {\n protect(toPosix(relative(root, resolution.file)));\n }\n for (const file of resolution.packages) {\n for (const target of packageTargets.entries(file, named))\n protectPackageTarget(target);\n }\n }\n // Keep complete paths even when the project's resolver cannot load them.\n const paths = isRelative\n ? [posix.join(posix.dirname(from), named)]\n : [...named.matchAll(/subgraphs\\//g)].map((match) =>\n named.slice(match.index),\n );\n for (const path of paths) {\n const target = path.replace(CODE_FILE, \"\");\n protect(`${target}.ts`);\n protect(`${target}/index.ts`);\n }\n }\n if (targets.size > 0) {\n references.push({\n file: sourcePath,\n specifier: literal,\n whole,\n targets: [...targets].map(([path, throughPackage]) => ({\n path,\n throughPackage,\n })),\n });\n }\n }\n }\n return references;\n}\n\n/** Whether `literal` reads its module whole, rather than by named bindings. */\nfunction readsWhole(literal: ts.StringLiteralLike): boolean {\n const parent = literal.parent;\n if (ts.isImportDeclaration(parent)) {\n const bindings = parent.importClause?.namedBindings;\n return bindings !== undefined && ts.isNamespaceImport(bindings);\n }\n if (ts.isExportDeclaration(parent)) {\n return (\n parent.exportClause === undefined ||\n ts.isNamespaceExport(parent.exportClause)\n );\n }\n return true;\n}\n","import { projectModuleReferences } from \"./project-module-references.js\";\n\n/** Readers outside the relative import graph that codegen can rewrite. */\nexport function subgraphReaders(projectDir: string): {\n /** Subgraph files read from outside their directory. */\n readonly imported: ReadonlySet<string>;\n /** Those of them some outside reader reads whole. */\n readonly readWhole: ReadonlySet<string>;\n} {\n const found = new Set<string>();\n const whole = new Set<string>();\n for (const reference of projectModuleReferences(projectDir)) {\n const isRelative = /^\\.{1,2}\\//.test(reference.specifier);\n for (const target of reference.targets) {\n const parts = target.path.split(\"/\");\n const [top, name] = parts;\n if (top !== \"subgraphs\" || parts.length < 2) continue;\n if (\n !target.throughPackage &&\n isRelative &&\n reference.file.startsWith(`subgraphs/${name}/`)\n )\n continue;\n found.add(target.path);\n if (reference.whole) whole.add(target.path);\n }\n }\n return { imported: found, readWhole: whole };\n}\n","import {\n castResolverTypeErrors,\n migrateSubgraph,\n type ProjectTypeCheck,\n type ProjectTypeError,\n projectTypeErrors,\n resolverCallErrors,\n type ResolverTypeError,\n typeErrorMessage,\n sortedSchemaText,\n type SubgraphMigration,\n} from \"@powerhousedao/codegen\";\nimport {\n subgraphDirStyles,\n uncachedDefinitionSourceRevision,\n ViteTypeScriptSourceImportAdapter,\n} from \"@powerhousedao/codegen/utils\";\nimport { projectSubgraphGraphQL } from \"document-model\";\nimport { readSubgraphDefinitions } from \"document-model/tooling\";\nimport type { DocumentNode } from \"graphql\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { outdatedDependency } from \"./installed-version.js\";\nimport { definitionChecks } from \"./model/check.js\";\nimport { readProjectDefinitions } from \"./model/project.js\";\nimport {\n assertChangesWritable,\n errorText,\n type FileBackup,\n ignoredByGit,\n restoreChanges,\n writeChanges,\n} from \"./project-files.js\";\nimport { subgraphReaders } from \"./subgraph-readers.js\";\n\n/** A module that hangs on a top-level await must not hang `ph migrate`. */\nconst IMPORT_TIMEOUT_MS = 60_000;\nconst SCALARS_ENTRY = \"scalars/index.ts\";\nconst SOURCE_FILE = /\\.(?:[cm]?[jt]sx?|graphql)$/;\n\nexport type MigrateSubgraphsOptions = {\n readonly projectDir: string;\n /** The `subgraphs/` directories to convert; empty converts every schema-first one. */\n readonly dirs: readonly string[];\n readonly dryRun: boolean;\n /** Leave the resolver calls tsc rejects without a cast. */\n readonly strictResolvers?: boolean;\n readonly out?: (text: string) => void;\n};\n\ntype Verification =\n | { readonly ok: true }\n | { readonly ok: false; readonly reason: string };\n\n/**\n * `ph migrate --subgraphs`: converts schema-first subgraphs into code-first\n * ones. Each written directory is loaded as `ph model check` loads it and\n * must serve the schema it served before; otherwise its files are restored.\n * Without named directories, a directory whose `index.ts` holds no class is\n * skipped. Returns the exit code: 0 when every requested subgraph converted\n * or was already code-first, 1 otherwise.\n */\nexport async function migrateSubgraphs(\n options: MigrateSubgraphsOptions,\n): Promise<0 | 1> {\n const out =\n options.out ?? ((text: string) => void process.stdout.write(text));\n const { projectDir, dryRun } = options;\n let outdated = outdatedDependency(projectDir, \"@powerhousedao/reactor-api\");\n /** The composition errors `ph model check` reported before this run converted anything. */\n let composition: ReadonlySet<string> | undefined;\n /** What the project's tsc reported in the subgraphs before this run wrote anything. */\n let typeBaseline: ProjectTypeCheck | undefined;\n const outsideReaders = subgraphReaders(projectDir);\n const ignored = ignoredByGit(projectDir);\n const styles = new Map(\n subgraphDirStyles(join(projectDir, \"subgraphs\")).map(\n ({ dirName, style }) => [dirName, style] as const,\n ),\n );\n let failed = false;\n let schemaFirst = 0;\n const named = options.dirs.length > 0;\n const requested = named ? options.dirs : [...styles.keys()];\n const converted: string[] = [];\n const importer = new ViteTypeScriptSourceImportAdapter();\n const revision = uncachedDefinitionSourceRevision();\n try {\n for (const dirName of requested) {\n const label = `subgraphs/${dirName}`;\n const style = styles.get(dirName);\n if (style === undefined) {\n out(\n `${label}: not found. Name a directory of subgraphs/ that has an index.ts.\\n`,\n );\n failed = true;\n continue;\n }\n if (style === \"code-first\") {\n out(`${label}: already code-first\\n`);\n continue;\n }\n const originals = readDirectory(projectDir, dirName, ignored);\n let written: FileBackup | undefined;\n try {\n const migration = await migrateSubgraph({\n dirName,\n files: new Map(\n [...originals].map(([path, bytes]) => [\n path,\n bytes.toString(\"utf8\"),\n ]),\n ),\n importedFromOutside: outsideReaders.imported,\n readWholeFromOutside: outsideReaders.readWhole,\n });\n if (migration.kind === \"no-subgraph-class\" && !named) {\n out(`${label}: no subgraph class, skipped\\n`);\n continue;\n }\n schemaFirst++;\n if (migration.kind !== \"converted\") {\n out(refusalText(label, migration));\n failed = true;\n continue;\n }\n if (dryRun) {\n assertChangesWritable(projectDir, migration.files);\n out(`${label}: would convert ${migration.className} to code-first\\n`);\n for (const file of migration.files) out(unifiedDiff(file));\n continue;\n }\n if (outdated !== undefined) {\n out(`${label}: not converted. ${outdated}\\n`);\n outdated = \"@powerhousedao/reactor-api is too old, as above.\";\n failed = true;\n continue;\n }\n // What the host already refuses, read before this run writes anything.\n composition ??= await compositionErrors(projectDir, new Set());\n typeBaseline ??= projectTypeErrors(\n projectDir,\n requested.map((name) => `subgraphs/${name}`),\n [],\n );\n try {\n written = writeChanges(projectDir, migration.files);\n } catch (error) {\n out(\n `${label}: not converted; its files are restored. Writing them failed: ${errorText(error)}\\n`,\n );\n failed = true;\n continue;\n }\n let verification = await verify(\n projectDir,\n migration,\n importer,\n revision,\n );\n if (verification.ok) {\n const added = await compositionErrors(projectDir, composition);\n if (added.size > 0) {\n verification = {\n ok: false,\n reason: `The host would not serve the package's code-first subgraphs together:\\n${[...added].map((error) => ` ${error}`).join(\"\\n\")}\\nRename the conflicting types in one of the subgraphs, then migrate again.`,\n };\n }\n }\n if (!verification.ok) {\n restoreChanges(projectDir, written);\n out(\n `${label}: not converted; its files are restored. ${verification.reason}\\n`,\n );\n failed = true;\n continue;\n }\n converted.push(dirName);\n out(\n `${label}: converted ${migration.className} to code-first; it serves the same schema\\n`,\n );\n for (const note of migration.notes) out(`Note: ${note}\\n`);\n if (migration.sdlFile.endsWith(\"/schema.graphql\")) {\n out(\n `${migration.sdlFile} is no longer used; the schema is now in ${label}/schema.ts. It was kept, and you can delete it.\\n`,\n );\n }\n } catch (error) {\n if (written !== undefined) restoreChanges(projectDir, written);\n out(\n `${label}: not converted; its files are ${written === undefined ? \"unchanged\" : \"restored\"}. The conversion failed unexpectedly: ${errorText(error)}\\n`,\n );\n failed = true;\n }\n }\n } finally {\n await importer.disposeRevision();\n }\n if (converted.length > 0) {\n out(\n await typeReport(\n projectDir,\n converted,\n options.strictResolvers ?? false,\n typeBaseline,\n ),\n );\n }\n if (!named && schemaFirst === 0) {\n out(\"No schema-first subgraphs to convert.\\n\");\n }\n return failed ? 1 : 0;\n}\n\n/**\n * The converted resolvers TypeScript rejects. The schema-first resolver map\n * never checked a resolver's types against the schema; each converted entry\n * calls its resolver with the schema's types, so a disagreement is now a\n * type error. Unless `strict`, each rejected call is cast where it fails, so\n * it runs as before and the project compiles. Any other error the\n * conversion added to the subgraphs, against `baseline`, is reported too.\n */\nasync function typeReport(\n projectDir: string,\n converted: readonly string[],\n strict: boolean,\n baseline: ProjectTypeCheck | undefined,\n): Promise<string> {\n const dirs = converted.map((dirName) => `subgraphs/${dirName}`);\n const indexPaths = dirs.map((dir) => `${dir}/index.ts`);\n const check = () => projectTypeErrors(projectDir, dirs, indexPaths);\n const first = check();\n if (first.kind === \"untyped\") return \"\";\n if (first.kind === \"skipped\") {\n return `Note: the converted resolvers were not type-checked: ${first.reason}.\\n`;\n }\n const list = (shown: readonly ResolverTypeError[]) =>\n shown\n .map(\n ({ file, line, coordinate, message }) =>\n ` ${file}:${line} ${coordinate}: ${message}\\n`,\n )\n .join(\"\");\n const calls = resolverCallErrors(projectDir, indexPaths, first.errors);\n let report = \"\";\n let final = first;\n if (calls.length > 0) {\n const count = `${calls.length === 1 ? \"1 resolver call disagrees\" : `${calls.length} resolver calls disagree`} with the schema the subgraph serves`;\n if (strict) {\n report += `Note: ${count}, so TypeScript rejects ${calls.length === 1 ? \"it\" : \"them\"}. The schema-first map never checked them; fix each resolver's types:\\n${list(calls)}`;\n } else {\n writeChanges(projectDir, await castResolverTypeErrors(projectDir, calls));\n let after = check();\n if (\n after.kind === \"checked\" &&\n calls.some(({ message }) =>\n /^Expected (?:\\d+-)?\\d+ arguments?, but got \\d+\\./.test(message),\n )\n ) {\n const exposed = resolverCallErrors(\n projectDir,\n indexPaths,\n after.errors,\n );\n if (exposed.length > 0) {\n writeChanges(\n projectDir,\n await castResolverTypeErrors(projectDir, exposed),\n );\n calls.push(...exposed);\n after = check();\n }\n }\n if (after.kind === \"checked\") final = after;\n const left = resolverCallErrors(projectDir, indexPaths, final.errors);\n report += `Note: ${count}. The schema-first map never checked them; each call is cast where TypeScript rejects it, under a \"ph migrate:\" comment, so it runs as before and the project compiles. Fix each resolver's types, then remove its cast:\\n${list(calls)}`;\n if (left.length > 0) {\n report += `Note: ${left.length === 1 ? \"1 resolver call is\" : `${left.length} resolver calls are`} still rejected after the casts; fix ${left.length === 1 ? \"it\" : \"them\"} by hand:\\n${list(left)}`;\n }\n }\n }\n // Errors besides the resolver calls that were not there before.\n if (baseline?.kind === \"checked\") {\n const key = (error: ProjectTypeError) =>\n `${error.file.split(\"/\").slice(0, 2).join(\"/\")}|${error.lines.join(\"|\")}`;\n const before = new Map<string, number>();\n for (const error of baseline.errors) {\n before.set(key(error), (before.get(key(error)) ?? 0) + 1);\n }\n const inSchema = new Set(\n resolverCallErrors(projectDir, indexPaths, final.errors).map(\n ({ file, line, column }) => `${file}:${line}:${column}`,\n ),\n );\n const introduced = final.errors.filter((error) => {\n if (inSchema.has(`${error.file}:${error.line}:${error.column}`)) {\n return false;\n }\n const remaining = before.get(key(error)) ?? 0;\n if (remaining > 0) {\n before.set(key(error), remaining - 1);\n return false;\n }\n return true;\n });\n if (introduced.length > 0) {\n report += `Note: the conversion added ${introduced.length === 1 ? \"1 type error\" : `${introduced.length} type errors`} besides the resolver calls. That is a bug in ph migrate; please report it, and fix ${introduced.length === 1 ? \"it\" : \"them\"} by hand:\\n${introduced\n .map(\n (error) =>\n ` ${error.file}:${error.line}: ${typeErrorMessage(error)}\\n`,\n )\n .join(\"\")}`;\n }\n }\n return report;\n}\n\n/**\n * The directory's files and `scalars/index.ts`, by project-relative path.\n * Files git ignores, such as build copies, are left out.\n */\nfunction readDirectory(\n projectDir: string,\n dirName: string,\n ignored: (path: string) => boolean,\n): ReadonlyMap<string, Buffer> {\n const files = new Map<string, Buffer>();\n const dir = join(projectDir, \"subgraphs\", dirName);\n for (const entry of readdirSync(dir, {\n recursive: true,\n withFileTypes: true,\n })) {\n if (!entry.isFile() || !SOURCE_FILE.test(entry.name)) continue;\n const path = join(entry.parentPath, entry.name);\n const local = path.slice(projectDir.length + 1).replaceAll(\"\\\\\", \"/\");\n if (!ignored(local)) files.set(local, readFileSync(path));\n }\n const scalars = join(projectDir, SCALARS_ENTRY);\n if (existsSync(scalars)) files.set(SCALARS_ENTRY, readFileSync(scalars));\n return files;\n}\n\nasync function withTimeout<T>(work: Promise<T>, timeoutMs: number): Promise<T> {\n let timer: NodeJS.Timeout | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(\n () =>\n reject(\n new Error(\n `it did not finish loading within ${timeoutMs / 1000} seconds`,\n ),\n ),\n timeoutMs,\n );\n timer.unref();\n });\n try {\n return await Promise.race([work, timeout]);\n } finally {\n clearTimeout(timer);\n }\n}\n\n/**\n * The subgraph composition errors `ph model check` reports for the project,\n * leaving out those in `known`. Converted subgraphs are composed with each\n * other: a type two of them declare differently keeps one out of the host.\n */\nasync function compositionErrors(\n projectDir: string,\n known: ReadonlySet<string>,\n): Promise<Set<string>> {\n const report = await readProjectDefinitions(projectDir, (project, modules) =>\n definitionChecks.edit(project, modules),\n );\n return new Set(\n report.diagnostics\n .filter(\n ({ severity, phase }) =>\n severity === \"error\" && phase === \"composition\",\n )\n .map(({ message }) => message)\n .filter((message) => !known.has(message)),\n );\n}\n\n/** Loads the written class without constructing it and compares the schema it serves. */\nasync function verify(\n projectDir: string,\n migration: Extract<SubgraphMigration, { kind: \"converted\" }>,\n importer: ViteTypeScriptSourceImportAdapter,\n revision: ReturnType<typeof uncachedDefinitionSourceRevision>,\n): Promise<Verification> {\n const specifier = `./subgraphs/${migration.dirName}/index.ts` as const;\n let namespace: Readonly<Record<string, unknown>>;\n try {\n namespace = await withTimeout(\n importer.importModule({\n packageRoot: projectDir,\n specifier,\n packageRevision: revision,\n }),\n IMPORT_TIMEOUT_MS,\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n ok: false,\n reason: `The converted module does not load: ${message.replaceAll(projectDir, \".\")}`,\n };\n }\n const { subgraphs, diagnostics } = readSubgraphDefinitions(namespace, {\n specifier,\n });\n const errors = diagnostics.filter(({ severity }) => severity === \"error\");\n if (errors.length > 0) {\n return {\n ok: false,\n reason: `The converted subgraph does not compile:\\n${errors.map(({ message, repair }) => ` ${message} ${repair}`).join(\"\\n\")}`,\n };\n }\n const subgraph = subgraphs.find(\n ({ name }) => name === migration.subgraphName,\n );\n if (subgraph === undefined) {\n return {\n ok: false,\n reason: `${specifier} exports no code-first subgraph named ${migration.subgraphName}.`,\n };\n }\n const served = sortedSchemaText(\n projectSubgraphGraphQL(subgraph.definition) as unknown as DocumentNode,\n );\n if (served === migration.sdl) return { ok: true };\n return {\n ok: false,\n reason: `The converted subgraph serves a different schema:\\n${unifiedDiff({\n path: \"schema\",\n before: migration.sdl,\n after: served,\n })}`,\n };\n}\n\nfunction refusalText(\n label: string,\n migration: Extract<\n SubgraphMigration,\n { kind: \"refused\" | \"no-subgraph-class\" }\n >,\n): string {\n return `${label}: not converted\\n${migration.refusals\n .map(\n ({ file, line, reason, repair }) =>\n ` ${file}:${line}: ${reason}\\n ${repair}\\n`,\n )\n .join(\"\")}`;\n}\n\ntype Line = { readonly kind: \" \" | \"-\" | \"+\"; readonly text: string };\n\n/** The line edits from `before` to `after`, by longest common subsequence. */\nfunction lineEdits(\n before: readonly string[],\n after: readonly string[],\n): Line[] {\n const common: number[][] = Array.from({ length: before.length + 1 }, () =>\n new Array<number>(after.length + 1).fill(0),\n );\n for (let i = before.length - 1; i >= 0; i--) {\n for (let j = after.length - 1; j >= 0; j--) {\n common[i][j] =\n before[i] === after[j]\n ? common[i + 1][j + 1] + 1\n : Math.max(common[i + 1][j], common[i][j + 1]);\n }\n }\n const lines: Line[] = [];\n let i = 0;\n let j = 0;\n while (i < before.length || j < after.length) {\n if (i < before.length && j < after.length && before[i] === after[j]) {\n lines.push({ kind: \" \", text: before[i++] });\n j++;\n } else if (\n i < before.length &&\n (j === after.length || common[i + 1][j] >= common[i][j + 1])\n ) {\n lines.push({ kind: \"-\", text: before[i++] });\n } else {\n lines.push({ kind: \"+\", text: after[j++] });\n }\n }\n return lines;\n}\n\nconst CONTEXT = 3;\n\n/** A unified diff of one file; a new file diffs against /dev/null. */\nexport function unifiedDiff(file: {\n readonly path: string;\n readonly before: string | null;\n readonly after: string | null;\n}): string {\n const split = (text: string) =>\n text === \"\" ? [] : text.replace(/\\n$/, \"\").split(\"\\n\");\n const lines = lineEdits(split(file.before ?? \"\"), split(file.after ?? \"\"));\n const changed = lines.flatMap((line, index) =>\n line.kind === \" \" ? [] : [index],\n );\n if (changed.length === 0) return \"\";\n const hunks: [number, number][] = [];\n for (const index of changed) {\n const start = Math.max(0, index - CONTEXT);\n const end = Math.min(lines.length, index + CONTEXT + 1);\n const last = hunks.at(-1);\n if (last !== undefined && start <= last[1]) last[1] = end;\n else hunks.push([start, end]);\n }\n const header = `--- ${file.before === null ? \"/dev/null\" : `a/${file.path}`}\\n+++ ${file.after === null ? \"/dev/null\" : `b/${file.path}`}\\n`;\n return (\n header +\n hunks\n .map(([start, end]) => {\n const lineBefore = (kind: Line[\"kind\"]) =>\n lines.slice(0, start).filter((line) => line.kind !== kind).length;\n const slice = lines.slice(start, end);\n const count = (kind: Line[\"kind\"]) =>\n slice.filter((line) => line.kind !== kind).length;\n const oldCount = count(\"+\");\n const newCount = count(\"-\");\n const oldStart = oldCount === 0 ? lineBefore(\"+\") : lineBefore(\"+\") + 1;\n const newStart = newCount === 0 ? lineBefore(\"-\") : lineBefore(\"-\") + 1;\n return `@@ -${oldStart},${oldCount} +${newStart},${newCount} @@\\n${slice\n .map((line) => `${line.kind}${line.text}`)\n .join(\"\\n\")}\\n`;\n })\n .join(\"\")\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,SAAS,iBACP,YACA,aACoB;CACpB,KAAK,IAAI,MAAM,aAAc,MAAM,QAAQ,GAAG,GAAG;EAC/C,MAAM,WAAW,KAAK,KAAK,gBAAgB,aAAa,cAAc;EACtE,IAAI,WAAW,QAAQ,GAAG;GACxB,MAAM,EAAE,YAAY,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;GAG7D,OAAO,OAAO,YAAY,WAAW,UAAU,KAAA;EACjD;EACA,IAAI,QAAQ,GAAG,MAAM,KAAK,OAAO,KAAA;CACnC;AACF;;;;;;AAOA,SAAgB,mBACd,YACA,aACoB;CACpB,MAAM,WAAW,WAAW;CAC5B,IAAI,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAA;CACrC,MAAM,YAAY,iBAAiB,YAAY,WAAW;CAC1D,IAAI,cAAc,KAAA,GAChB,OAAO,GAAG,YAAY;CAExB,IAAI,MAAM,SAAS,MAAM,QAAQ,CAAC,GAAG,WAAW,QAAQ,GAAG,OAAO,KAAA;CAClE,OAAO,oBAAoB,YAAY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AAa,SAAS,KAAK,IAAI,KAAK,KAAK;OACjD,MAAM,KAAK,CAAC,OAAO,GAAG,CAAC;CAC9B;CAEA,OACE,OAFoB,KAAK,WAAW,OAAO,cAAc,KAAK,KAAK,OAAO,QAAQ,KAAK,UAAU,OAAO,cAAc,KAAK,KAAK,OAAO,MAGvI,MACG,KAAK,CAAC,OAAO,SAAS;EACrB,MAAM,cAAc,SAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,QAAQ,SAAS,KAAK,SAAS,IAAI,CAAC,CAAC;EAC7D,MAAM,QAAQ,MAAM,MAAM,OAAO,GAAG;EACpC,MAAM,SAAS,SACb,MAAM,QAAQ,SAAS,KAAK,SAAS,IAAI,CAAC,CAAC;EAC7C,MAAM,WAAW,MAAM,GAAG;EAC1B,MAAM,WAAW,MAAM,GAAG;EAG1B,OAAO,OAFU,aAAa,IAAI,WAAW,GAAG,IAAI,WAAW,GAAG,IAAI,EAE/C,GAAG,SAAS,IADlB,aAAa,IAAI,WAAW,GAAG,IAAI,WAAW,GAAG,IAAI,EACtB,GAAG,SAAS,OAAO,MAChE,KAAK,SAAS,GAAG,KAAK,OAAO,KAAK,MAAM,CAAC,CACzC,KAAK,IAAI,EAAE;CAChB,CAAC,CAAC,CACD,KAAK,EAAE;AAEd","debug_id":"7d3651a1-27f8-570b-8ac0-dbff72986a16"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ph-cli-commands-D4Z6YSwd.mjs","sources":["../src/commands/access-token.ts","../src/commands/build.ts","../src/commands/connect.ts","../src/commands/generate-all.ts","../src/utils/fs-args.ts","../src/utils/comma-separated.ts","../src/commands/generate-app.ts","../src/commands/generate-connect-routes.ts","../src/commands/generate-desktop-shell.ts","../src/commands/generate-document-model.ts","../src/commands/generate-editor.ts","../src/commands/generate-hosts.ts","../src/commands/generate-migration-file.ts","../src/commands/generate-piece-action.ts","../src/commands/generate-piece-trigger.ts","../src/commands/generate-piece.ts","../src/commands/generate-processor.ts","../src/commands/generate-subgraph.ts","../src/commands/generate.ts","../src/commands/host.ts","../src/commands/init.ts","../src/commands/inspect.ts","../src/commands/install.ts","../src/commands/keyframes.ts","../src/commands/list.ts","../src/commands/login.ts","../src/commands/logout.ts","../src/commands/mcp.ts","../src/commands/migrate.ts","../src/commands/model.ts","../src/commands/publish.ts","../src/commands/registry-login.ts","../src/commands/run.ts","../src/commands/uninstall.ts","../src/commands/unpublish.ts","../src/commands/vetra.ts","../src/commands/ph-cli-commands.ts"],"sourcesContent":["import { accessTokenArgs } from \"@powerhousedao/shared/clis/args\";\nimport { DEFAULT_EXPIRY_SECONDS } from \"@powerhousedao/shared/clis/constants\";\nimport { command } from \"cmd-ts\";\n\nexport const accessToken = command({\n name: \"access-token\",\n description: `\nThe access-token command generates a bearer token for API authentication. This token\ncan be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).\n\nThis command:\n1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential\n2. Creates a JWT bearer token with configurable expiration\n3. Outputs the token to stdout (info to stderr) for easy piping\n\nPrerequisites:\n You must have a cryptographic identity. Run 'ph login' first to:\n - Generate a keypair (stored in .ph/.keypair.json)\n - Optionally link your Ethereum address (stored in .ph/.renown.json)\n\nToken Details:\n The generated token is a JWT (JSON Web Token) containing:\n - Issuer (iss): Your CLI's DID (did:key:...)\n - Subject (sub): Your CLI's DID\n - Credential Subject: Chain ID, network ID, and address (if authenticated)\n - Expiration (exp): Based on --expiry option\n - Audience (aud): If --audience is specified\n\nOutput:\n- Token information (DID, address, expiry) is printed to stderr\n- The token itself is printed to stdout for easy piping/copying\n\nThis allows you to use the command in scripts:\n TOKEN=$(ph access-token)\n curl -H \"Authorization: Bearer $TOKEN\" http://localhost:4001/graphql\n\nUsage with APIs:\n Generate token and use with curl\n TOKEN=$(ph access-token --expiry 1d)\n curl -X POST http://localhost:4001/graphql \\\\\n -H \"Content-Type: application/json\" \\\\\n -H \"Authorization: Bearer $TOKEN\" \\\\\n -d '{\"query\": \"{ drives { id name } }\"}'\n\n Export as environment variable\n export PH_ACCESS_TOKEN=$(ph access-token)\n\nNotes:\n - Tokens are self-signed using your CLI's private key\n - No network request is made; tokens are generated locally\n - The recipient API must trust your CLI's DID to accept the token\n - For reactor-api, ensure AUTH_ENABLED=true to require authentication\n`,\n args: accessTokenArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { generateAccessToken, parseExpiry, formatExpiry } =\n await import(\"@renown/sdk/node\");\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n\n let expiresIn = DEFAULT_EXPIRY_SECONDS;\n if (args.expiry) expiresIn = parseExpiry(args.expiry);\n\n const result = await generateAccessToken(renown, {\n expiresIn,\n aud: args.audience,\n });\n\n // Output token info to stderr, token itself to stdout for piping\n console.error(`CLI DID: ${result.did}`);\n console.error(`ETH Address: ${result.address}`);\n console.error(`Token expires in: ${formatExpiry(expiresIn)}`);\n console.error(\"\");\n\n console.log(result.token);\n process.exit(0);\n },\n});\n","import { buildArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const build = command({\n name: \"build\",\n description: `\nBuild a Powerhouse package for publishing: a browser bundle and a node bundle of its\ndocument models, scalars, editors, subgraphs and processors, type declarations, and its\nstylesheet.\n\nPieces under pieces/ are built too, each into its own self-contained module under\ndist/node/pieces/<name>, with a descriptor.json and package.json written beside it and\nthe piece listed in dist/powerhouse.manifest.json. A piece takes the package's version: an\nentry in pieces/index.ts that declares version fails the build. A package that ships only\npieces is an ordinary package: it carries the same boilerplate, and every step above runs\nfor it too.\n\ntsc runs first. If it reports type errors the build asks whether to go ahead, and stops\nwhere it can't ask. --ignore-type-errors builds without asking; a package built that way\ncan load and still fail at runtime, so don't publish it.`,\n args: buildArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n try {\n const { runBuild } = await import(\"../services/build.js\");\n await runBuild(args, { checkDefinitions: true, ownsProcess: true });\n } catch (error) {\n // The message includes its cause; --debug adds the stack and the cause again.\n console.error(\n args.debug || !(error instanceof Error) ? error : error.message,\n );\n process.exit(1);\n }\n },\n});\n","import { connectConfigArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, subcommands } from \"cmd-ts\";\n\nexport const config = command({\n name: \"config\",\n description: `Read or update Connect's runtime configuration (powerhouse.config.json).\n\nModes (mutually exclusive — positional, --get, --json, and field flags cannot be combined):\n ph connect config List the effective connect.* block (defaults < source).\n ph connect config <key> Get the value at the dotted path (e.g. ph connect config connect.renown.url).\n ph connect config --get <dotted.path> Same as positional <key> (kept for backward compat).\n ph connect config <key> <value> Set a single field and dual-write to source + dist (positional).\n ph connect config --<field> <value> Set a single field via per-field flag (e.g. --renown-url https://renown.id).\n ph connect config --json '{\"renown\":{\"url\":\"…\"}}'\n Bulk-set multiple fields and dual-write. The payload is the connect.*\n block without the \"connect\" wrapper; unknown keys are rejected.\n\nWrites go to:\n - <project>/powerhouse.config.json (source — picked up by the next build)\n - <dist-dir>/powerhouse.config.json (if it exists — the currently-served SPA picks it up on refresh)\n`,\n args: connectConfigArgs,\n handler: async (args) => {\n const { runConnectConfig } = await import(\"../services/connect-config.js\");\n await runConnectConfig(args);\n },\n});\n\n// `ph connect`, `ph connect studio`, `ph connect build` and\n// `ph connect preview` never reach this command: they are sugar for\n// `ph run connect dev|build|serve` (utils/run-sugar.ts).\nexport const connect = subcommands({\n name: \"connect\",\n description: `Powerhouse Connect. \\`ph connect\\` runs the project's connect host: it is \\`ph run connect dev\\`, as is \\`ph connect studio\\`; \\`ph connect build\\` is \\`ph run connect build\\` and \\`ph connect preview\\` is \\`ph run connect serve\\`. \\`ph connect config\\` reads and writes Connect's runtime configuration.`,\n cmds: {\n config,\n },\n});\n","import { command } from \"cmd-ts\";\n\nexport const generateAllCmd = command({\n name: \"all\",\n description: \"Re-generate all modules in the current project\",\n args: {},\n handler: async () => {\n const { startGenerateAll } = await import(\"../services/generate-all.js\");\n await startGenerateAll(process.cwd());\n process.exit(0);\n },\n});\n","import { extendType, string, type Type } from \"cmd-ts\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\n// cmd-ts's `batteries/fs`, rebuilt on the root entry so bun never loads its CJS build.\n\nconst ExistingPath: Type<string, string> = extendType(string, {\n displayName: \"path\",\n description: \"An existing path\",\n from(str) {\n const resolved = path.resolve(str);\n if (!fs.existsSync(resolved)) {\n return Promise.reject(new Error(\"Path doesn't exist\"));\n }\n return Promise.resolve(resolved);\n },\n});\n\n/** A directory, or the directory of a given file. */\nexport const Directory: Type<string, string> = extendType(ExistingPath, {\n displayName: \"dir\",\n description: \"A path to a directory or a file within a directory\",\n from(resolved) {\n return Promise.resolve(\n fs.statSync(resolved).isDirectory() ? resolved : path.dirname(resolved),\n );\n },\n});\n\n/** A module's directory name or path, resolved by the command against the project. */\nexport const ModuleDir: Type<string, string> = extendType(string, {\n displayName: \"dir\",\n description: \"A module's directory name or path\",\n from: (dir) => Promise.resolve(dir),\n});\n","import type { Type } from \"cmd-ts\";\n\n/** Splits comma-separated values so `-t \"a,b\"` means the same as `-t a -t b`\n * instead of yielding the single value `\"a,b\"`, which matches nothing. */\nexport function splitCommaSeparated(values: string[]): string[] {\n return values\n .flatMap((value) => value.split(\",\"))\n .map((value) => value.trim())\n .filter((value) => value.length > 0);\n}\n\n/** `multioption` type accepting repeated and/or comma-separated values. */\nexport const CommaSeparatedStrings: Type<string[], string[]> = {\n from: (values) => Promise.resolve(splitCommaSeparated(values)),\n};\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport {\n boolean,\n command,\n flag,\n multioption,\n option,\n optional,\n string,\n} from \"cmd-ts\";\nimport { ModuleDir } from \"../utils/fs-args.js\";\nimport { CommaSeparatedStrings } from \"../utils/comma-separated.js\";\n\nexport const generateAppCmd = command({\n name: \"app\",\n description: \"Generate a drive app\",\n args: {\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description: \"The name of the drive app to generate\",\n }),\n allowedDocumentTypes: multioption({\n type: optional(CommaSeparatedStrings),\n long: \"document-types\",\n short: \"t\",\n description:\n \"The document types allowed by the new app (repeatable or comma-separated)\",\n }),\n dir: option({\n type: optional(ModuleDir),\n long: \"dir\",\n description:\n \"Name of the directory of an existing app to re-generate (my-app or editors/my-app)\",\n }),\n disableDragAndDrop: flag({\n type: boolean,\n long: \"disable-drag-and-drop\",\n description: \"Do not allow drag and drop in this drive app.\",\n defaultValue: () => false as const,\n defaultValueIsSerializable: true,\n }),\n all: flag({\n long: \"all\",\n short: \"a\",\n description: \"Re-generate all existing apps in the current project\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGenerateApp } = await import(\"../services/generate-app.js\");\n await startGenerateApp(args, process.cwd());\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const generateConnectRoutesCmd = command({\n name: \"connect-routes\",\n description:\n \"Generate .ph/connect-routes.gen.ts, the route tree hosts/connect/routes/ type-checks against, and fail if a route the package offers imports @powerhousedao/connect\",\n args: { ...debugArgs },\n handler: async () => {\n const { syncProjectConnectRoutes } =\n await import(\"../utils/sync-connect-routes.js\");\n const { checkOfferedRoutesImports } =\n await import(\"../utils/offered-routes-imports.js\");\n await syncProjectConnectRoutes(process.cwd());\n // npm run tsc and lint run this first: they fail where `ph build` would.\n await checkOfferedRoutesImports(process.cwd());\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, flag, option, optional, string } from \"cmd-ts\";\n\nexport const generateDesktopShellCmd = command({\n name: \"desktop-shell\",\n description:\n \"Scaffold a builder-owned desktop identity (hosts/desktop/app.json + icon). \" +\n \"`ph run desktop dev|build` then projects it into a native Tauri shell — no Rust.\",\n args: {\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description:\n \"Product name (window title + macOS app name). Default: the project's package name.\",\n }),\n identifier: option({\n type: optional(string),\n long: \"identifier\",\n short: \"i\",\n description:\n \"Reverse-DNS app identifier, e.g. com.acme.app. Default: inc.powerhouse.desktop.<project>.\",\n }),\n force: flag({\n long: \"force\",\n short: \"f\",\n description:\n \"Overwrite an existing app.json (protects edits by default).\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGenerateDesktopShell } =\n await import(\"../services/generate-desktop-shell.js\");\n startGenerateDesktopShell(args, process.cwd());\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, flag, option, optional, string } from \"cmd-ts\";\nimport { ModuleDir } from \"../utils/fs-args.js\";\nexport const generateDocumentModelCmd = command({\n name: \"document-model\",\n aliases: [\"doc\"],\n description: \"Generate a document model\",\n args: {\n dir: option({\n type: optional(ModuleDir),\n long: \"dir\",\n description:\n \"Name of the directory of an existing document model to re-generate (my-document-model or document-models/my-document-model)\",\n }),\n all: flag({\n long: \"all\",\n short: \"a\",\n description:\n \"Re-generate all existing document models in the current project\",\n }),\n /** @experimental Code-first scaffolding is being tested in production. */\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description:\n \"Experimental. Create a code-first document model with this name, with its editor\",\n }),\n /** @experimental Chooses code-first authoring for the model --name creates. */\n codeFirst: flag({\n long: \"code-first\",\n description:\n \"Experimental. With --name, create the model code-first. Existing models of both styles are discovered without it; ph migrate --document-model converts a schema-first one\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGenerateDocumentModel } =\n await import(\"../services/generate-document-model.js\");\n await startGenerateDocumentModel(args, process.cwd());\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, flag, option, optional, string } from \"cmd-ts\";\nimport { ModuleDir } from \"../utils/fs-args.js\";\n\nexport const generateEditorCmd = command({\n name: \"editor\",\n description: \"Generate a document editor\",\n args: {\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description: \"The name of the document editor to generate\",\n }),\n documentType: option({\n type: optional(string),\n long: \"document-type\",\n short: \"t\",\n description: \"The document type for the new editor\",\n }),\n dir: option({\n type: optional(ModuleDir),\n long: \"dir\",\n description:\n \"Name of the directory of an existing editor to re-generate (my-editor or editors/my-editor)\",\n }),\n all: flag({\n long: \"all\",\n short: \"a\",\n description: \"Re-generate all existing editors in the current project\",\n }),\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGenerateEditor } =\n await import(\"../services/generate-editor.js\");\n await startGenerateEditor(args, process.cwd());\n process.exit(0);\n },\n});\n","import { command } from \"cmd-ts\";\n\nexport const generateHostsCmd = command({\n name: \"hosts\",\n description:\n \"Generate hosts/<name>/outputs.js + outputs.d.ts (typed $output token trees) for every host whose runner declares outputs, and refresh hosts/types.d.ts. Rerun after changing a producer's runner or declared drives: a stale outputs.js fails the load.\",\n args: {},\n handler: async () => {\n const { startGenerateHosts } =\n await import(\"../services/generate-hosts.js\");\n const ok = await startGenerateHosts(process.cwd());\n process.exit(ok ? 0 : 1);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, option, optional, string } from \"cmd-ts\";\nimport { skipInstallArgs } from \"../utils/install-added-dependencies.js\";\n\nexport const generateMigrationFileCmd = command({\n name: \"migration-file\",\n description: \"Generate a migration file\",\n args: {\n migrationFile: option({\n type: string,\n long: \"path\",\n short: \"p\",\n description: \"Path to the migration file\",\n }),\n schemaFile: option({\n type: optional(string),\n long: \"schema-file\",\n description: \"Path to the output file. Defaults to './schema.ts'\",\n }),\n ...skipInstallArgs,\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGenerateMigrationFile } =\n await import(\"../services/generate-migration-file.js\");\n await startGenerateMigrationFile(args, process.cwd());\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport {\n command,\n number,\n oneOf,\n option,\n optional,\n positional,\n string,\n} from \"cmd-ts\";\nimport { skipInstallArgs } from \"../utils/install-added-dependencies.js\";\n\nexport const generatePieceActionCmd = command({\n name: \"piece-action\",\n description: \"Generate an action inside an existing piece\",\n args: {\n namePositional: positional({\n type: optional(string),\n displayName: \"name\",\n description: \"The name of the action, e.g. get-record\",\n }),\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description: \"The name of the action to generate\",\n }),\n piece: option({\n type: optional(string),\n long: \"piece\",\n short: \"p\",\n description:\n \"The piece directory under pieces/ to add the action to. Optional when the project ships exactly one piece.\",\n }),\n requireReactor: option({\n type: optional(oneOf([\"read\", \"write\"] as const)),\n long: \"require-reactor\",\n description:\n \"Declare reactor access for the action: read, or write (which includes read). The action then gets context.reactor\",\n }),\n defaultTimeoutSeconds: option({\n type: optional(number),\n long: \"default-timeout-seconds\",\n description:\n \"Write defaultTimeoutSeconds: the step timeout used when the workflow sets none\",\n }),\n defaultMaxAttempts: option({\n type: optional(number),\n long: \"default-max-attempts\",\n description:\n \"Write defaultRetry: { maxAttempts }: the attempts (1 is no retry) used when the workflow sets no retry\",\n }),\n ...skipInstallArgs,\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGeneratePieceAction } =\n await import(\"../services/generate-piece-action.js\");\n await startGeneratePieceAction(args, process.cwd());\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, oneOf, option, optional, positional, string } from \"cmd-ts\";\nimport { skipInstallArgs } from \"../utils/install-added-dependencies.js\";\n\nexport const generatePieceTriggerCmd = command({\n name: \"piece-trigger\",\n description: \"Generate a trigger inside an existing piece\",\n args: {\n namePositional: positional({\n type: optional(string),\n displayName: \"name\",\n description: \"The name of the trigger, e.g. new-record\",\n }),\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description: \"The name of the trigger to generate\",\n }),\n piece: option({\n type: optional(string),\n long: \"piece\",\n short: \"p\",\n description:\n \"The piece directory under pieces/ to add the trigger to. Optional when the project ships exactly one piece.\",\n }),\n strategy: option({\n type: oneOf([\"polling\", \"webhook\"] as const),\n long: \"strategy\",\n description:\n \"How the trigger fires: polled on a schedule, or delivered to a webhook\",\n defaultValue: () => \"polling\" as const,\n defaultValueIsSerializable: true,\n }),\n requireReactor: option({\n type: optional(oneOf([\"read\", \"write\"] as const)),\n long: \"require-reactor\",\n description:\n \"Declare reactor access for the trigger: read, or write (which includes read). Its hooks then get context.reactor\",\n }),\n ...skipInstallArgs,\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGeneratePieceTrigger } =\n await import(\"../services/generate-piece-trigger.js\");\n await startGeneratePieceTrigger(args, process.cwd());\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport {\n command,\n flag,\n oneOf,\n option,\n optional,\n positional,\n string,\n} from \"cmd-ts\";\nimport { ModuleDir } from \"../utils/fs-args.js\";\nimport { skipInstallArgs } from \"../utils/install-added-dependencies.js\";\n\nexport const generatePieceCmd = command({\n name: \"piece\",\n description:\n \"Generate a piece: a connector whose actions and triggers a workflow can call\",\n args: {\n namePositional: positional({\n type: optional(string),\n displayName: \"name\",\n description:\n \"The name of the piece to generate. Its directory is the kebab-case of this.\",\n }),\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description: \"The name of the piece to generate\",\n }),\n id: option({\n type: optional(string),\n long: \"id\",\n description:\n \"The piece id, the pieceName a workflow step holds, e.g. @acme/piece-crm. Defaults to one derived from the package name.\",\n }),\n auth: option({\n type: oneOf([\"none\", \"secret\", \"custom\"] as const),\n long: \"auth\",\n description: \"The kind of connection the piece asks for\",\n defaultValue: () => \"custom\" as const,\n defaultValueIsSerializable: true,\n }),\n description: option({\n type: optional(string),\n long: \"description\",\n description: \"One line describing what the piece connects to\",\n }),\n dir: option({\n type: optional(ModuleDir),\n long: \"dir\",\n description:\n \"Name of the directory of an existing piece to re-register (my-piece or pieces/my-piece)\",\n }),\n all: flag({\n long: \"all\",\n short: \"a\",\n description:\n \"Re-register every piece in pieces/: refresh the pieces list and the manifest, and prune what is gone\",\n }),\n ...skipInstallArgs,\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGeneratePiece } =\n await import(\"../services/generate-piece.js\");\n await startGeneratePiece(args, process.cwd());\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { PROCESSOR_APPS } from \"@powerhousedao/shared/processors\";\nimport type { Type } from \"cmd-ts\";\nimport {\n command,\n flag,\n multioption,\n oneOf,\n option,\n optional,\n string,\n} from \"cmd-ts\";\nimport { ModuleDir } from \"../utils/fs-args.js\";\nimport {\n CommaSeparatedStrings,\n splitCommaSeparated,\n} from \"../utils/comma-separated.js\";\nimport { skipInstallArgs } from \"../utils/install-added-dependencies.js\";\n\nconst ProcessorAppType: Type<string[], (\"connect\" | \"switchboard\")[]> = {\n from(rawProcessorApps) {\n const processorApps = splitCommaSeparated(rawProcessorApps);\n if (processorApps.length === 0) {\n throw new Error(\n `No arguments provided for processor apps. Must be \"connect\" and/or \"switchboard\"`,\n );\n }\n if (processorApps.length > 2) {\n throw new Error(\n `Too many arguments provided for processor apps. Must be \"connect\" and/or \"switchboard\"`,\n );\n }\n const allowed = new Set(PROCESSOR_APPS);\n if (\n !processorApps.every((p) => allowed.has(p as \"connect\" | \"switchboard\"))\n ) {\n throw new Error(\n `Processor apps can only be \"connect\" and/or \"switchboard\".`,\n );\n }\n return Promise.resolve(processorApps as (\"connect\" | \"switchboard\")[]);\n },\n};\nexport const generateProcessorCmd = command({\n name: \"processor\",\n description: \"Generate a processor\",\n args: {\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description: \"The name of the processor to generate\",\n }),\n type: option({\n type: oneOf([\"analytics\", \"relationalDb\"] as const),\n long: \"type\",\n description: \"The type of processor to generate\",\n defaultValue: () => \"analytics\" as const,\n defaultValueIsSerializable: true,\n }),\n documentTypes: multioption({\n type: CommaSeparatedStrings,\n long: \"document-types\",\n short: \"t\",\n description:\n \"The document types the processor will run on (repeatable or comma-separated)\",\n defaultValue: () => [],\n defaultValueIsSerializable: true,\n }),\n apps: multioption({\n long: \"apps\",\n type: ProcessorAppType,\n description:\n \"Whether the processor will run in switchboard (nodejs), connect (browser), or both\",\n defaultValue: () => [\"switchboard\" as const, \"connect\" as const],\n defaultValueIsSerializable: true,\n }),\n dir: option({\n type: optional(ModuleDir),\n long: \"dir\",\n description:\n \"Name of the directory of an existing processor to re-generate (my-processor or processors/my-processor)\",\n }),\n all: flag({\n long: \"all\",\n short: \"a\",\n description: \"Re-generate all existing processors in the current project\",\n }),\n ...skipInstallArgs,\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGenerateProcessor } =\n await import(\"../services/generate-processor.js\");\n await startGenerateProcessor(args, process.cwd());\n process.exit(0);\n },\n});\n","import { debugArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, flag, option, optional, string } from \"cmd-ts\";\nimport { ModuleDir } from \"../utils/fs-args.js\";\nimport { skipInstallArgs } from \"../utils/install-added-dependencies.js\";\n\nexport const generateSubgraphCmd = command({\n name: \"subgraph\",\n description: \"Generate a subgraph\",\n args: {\n name: option({\n type: optional(string),\n long: \"name\",\n short: \"n\",\n description: \"The name of the subgraph to generate\",\n }),\n dir: option({\n type: optional(ModuleDir),\n long: \"dir\",\n description:\n \"Name of the directory of an existing subgraph to re-generate (my-subgraph or subgraphs/my-subgraph)\",\n }),\n all: flag({\n long: \"all\",\n short: \"a\",\n description: \"Re-generate all existing subgraphs in the current project\",\n }),\n /** @experimental */\n codeFirst: flag({\n long: \"code-first\",\n description:\n \"Experimental. With --name, create a new subgraph code-first. Existing subgraphs keep their own style; ph migrate --subgraph converts one\",\n }),\n ...skipInstallArgs,\n ...debugArgs,\n },\n handler: async (args) => {\n const { startGenerateSubgraph } =\n await import(\"../services/generate-subgraph.js\");\n await startGenerateSubgraph(args, process.cwd());\n process.exit(0);\n },\n});\n","import { subcommands } from \"cmd-ts\";\nimport { generateAllCmd } from \"./generate-all.js\";\nimport { generateAppCmd } from \"./generate-app.js\";\nimport { generateConnectRoutesCmd } from \"./generate-connect-routes.js\";\nimport { generateDesktopShellCmd } from \"./generate-desktop-shell.js\";\nimport { generateDocumentModelCmd } from \"./generate-document-model.js\";\nimport { generateEditorCmd } from \"./generate-editor.js\";\nimport { generateHostsCmd } from \"./generate-hosts.js\";\nimport { generateMigrationFileCmd } from \"./generate-migration-file.js\";\nimport { generatePieceActionCmd } from \"./generate-piece-action.js\";\nimport { generatePieceTriggerCmd } from \"./generate-piece-trigger.js\";\nimport { generatePieceCmd } from \"./generate-piece.js\";\nimport { generateProcessorCmd } from \"./generate-processor.js\";\nimport { generateSubgraphCmd } from \"./generate-subgraph.js\";\n\n/** Exported for tests. */\nexport const generateCmds = {\n all: generateAllCmd,\n \"document-model\": generateDocumentModelCmd,\n editor: generateEditorCmd,\n app: generateAppCmd,\n processor: generateProcessorCmd,\n subgraph: generateSubgraphCmd,\n piece: generatePieceCmd,\n \"piece-action\": generatePieceActionCmd,\n \"piece-trigger\": generatePieceTriggerCmd,\n \"migration-file\": generateMigrationFileCmd,\n \"connect-routes\": generateConnectRoutesCmd,\n \"desktop-shell\": generateDesktopShellCmd,\n hosts: generateHostsCmd,\n} as const;\n\nexport const generate = subcommands({\n name: \"generate\",\n description: `The generate command creates code for Powerhouse modules. It helps you create new code from scratch, or to re-generate existing code in your project.`,\n cmds: generateCmds,\n});\n","import { hostCheckArgs, hostExportArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command, subcommands } from \"cmd-ts\";\n\nexport const check = command({\n name: \"check\",\n description:\n \"Check a host the way `ph run` would, without starting it: every load, \" +\n \"validation, resolution and boot issue, grouped by host file. Exits 1 \" +\n \"on any issue. `--env <file>` checks against that file alone.\",\n args: hostCheckArgs,\n handler: async (args) => {\n const { runHostCheck } = await import(\"../services/host/check.js\");\n const { output, exitCode } = await runHostCheck(args);\n console.log(output);\n // Not process.exit: on macOS a piped stdout is async and would be cut.\n process.exitCode = exitCode;\n },\n});\n\n// `export` is a reserved word.\nexport const exportCmd = command({\n name: \"export\",\n description:\n \"Print a host as declared, with every member a compound names, as JSON \" +\n \"(tokens unresolved). `--out` writes it to a file instead.\",\n args: hostExportArgs,\n handler: async (args) => {\n const { runHostExport } = await import(\"../services/host/export.js\");\n const { stdout, stderr, exitCode } = await runHostExport(args);\n if (stdout !== undefined) process.stdout.write(stdout);\n if (stderr !== undefined) process.stderr.write(stderr);\n process.exitCode = exitCode;\n },\n});\n\nexport const host = subcommands({\n name: \"host\",\n description: \"Inspect the project's hosts/: `check`, `export`.\",\n cmds: { check, export: exportCmd },\n});\n","import { initArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const init = command({\n name: \"init\",\n description: \"Initialize a new project\",\n args: initArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log({ args });\n }\n const { startInit } = await import(\"../services/init.js\");\n await startInit(args);\n process.exit(0);\n },\n});\n","import { inspectArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const inspect = command({\n name: \"inspect\",\n description: `\nThe inspect command examines and provides detailed information about a Powerhouse package.\nIt helps you understand the structure, dependencies, and configuration of packages in\nyour project.\n\nThis command:\n1. Analyzes the specified package\n2. Retrieves detailed information about its structure and configuration\n3. Displays package metadata, dependencies, and other relevant information\n4. Helps troubleshoot package-related issues`,\n aliases: [\"is\"],\n args: inspectArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { startInspect } = await import(\"../services/inspect.js\");\n startInspect(args);\n process.exit(0);\n },\n});\n","import { installArgs } from \"@powerhousedao/shared/clis/args\";\nimport { execSync } from \"child_process\";\nimport { command } from \"cmd-ts\";\n\nconst MANIFEST_TIMEOUT_MS = 10_000;\n\n// The external packages a registry package's manifest lists; none when unreadable.\nexport async function fetchExternalDependencies(\n registryUrl: string,\n dependency: { name: string; version?: string },\n): Promise<string[]> {\n const base = registryUrl.endsWith(\"/\") ? registryUrl : `${registryUrl}/`;\n const spec = dependency.version\n ? `${dependency.name}@${dependency.version}`\n : dependency.name;\n try {\n const response = await fetch(\n `${base}-/cdn/${spec}/powerhouse.manifest.json`,\n { signal: AbortSignal.timeout(MANIFEST_TIMEOUT_MS) },\n );\n if (!response.ok) return [];\n const manifest = (await response.json()) as {\n externalDependencies?: unknown;\n };\n const external = manifest.externalDependencies;\n return typeof external === \"object\" && external !== null\n ? Object.keys(external).sort()\n : [];\n } catch {\n return [];\n }\n}\n\nexport async function warnAboutExternalDependencies(\n registryUrl: string,\n dependencies: { name: string; version?: string }[],\n): Promise<void> {\n // Fetched together: each manifest may take the whole timeout.\n const found = await Promise.all(\n dependencies.map((dependency) =>\n fetchExternalDependencies(registryUrl, dependency),\n ),\n );\n for (const [i, dependency] of dependencies.entries()) {\n const external = found[i];\n if (external.length === 0) continue;\n console.warn(\n `⚠ ${dependency.name}: its subgraphs and processors need packages with native addons or WebAssembly modules (${external.join(\", \")}) ` +\n `and only run when the package is installed locally: ph install --local ${dependency.name}\\n` +\n ` Its pieces work either way.`,\n );\n }\n}\n\nexport const install = command({\n name: \"install\",\n aliases: [\"add\", \"i\"],\n description: `\nThe install command adds Powerhouse dependencies to your project.\n\nBy default it only registers the package in powerhouse.config.json with\nprovider \"registry\" — Connect will load it from the registry CDN at runtime.\n\nWith --local, the package is also installed into node_modules and marked\nas provider \"local\" — it will be bundled into ph connect build so the\npreview works without the registry being reachable.\n\nResolution order for the registry URL:\n --registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default\n `,\n args: installArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { getPowerhouseProjectInfo, makeDependenciesWithVersions } =\n await import(\"@powerhousedao/shared/clis\");\n\n const {\n projectPath,\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n } = await getPowerhouseProjectInfo(args);\n\n if (!projectPath) {\n throw new Error(`Could not find project path to install from.`);\n }\n\n const { resolveRegistryUrl } =\n await import(\"@powerhousedao/shared/registry\");\n const registryUrl = resolveRegistryUrl({\n registry: args.registry,\n projectPath,\n });\n\n if (args.debug) {\n console.log(\">>> registryUrl\", registryUrl);\n }\n\n const dependenciesWithVersions = await makeDependenciesWithVersions(\n args.dependencies,\n registryUrl,\n );\n\n if (args.debug) {\n console.log(\">>> parsedDependencies\", dependenciesWithVersions);\n console.log(\"\\n>>> projectInfo\", {\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n });\n }\n\n if (args.local) {\n if (dependenciesWithVersions.length === 0) {\n throw new Error(\n \"--local requires at least one package name (e.g. ph install --local @scope/pkg)\",\n );\n }\n try {\n const specs = dependenciesWithVersions.map((d) =>\n d.version ? `${d.name}@${d.version}` : d.name,\n );\n\n // Route only the scopes of the packages being installed to the\n // resolved registry, leaving transitive deps from other scopes\n // (and unscoped packages) on the package manager's default. This\n // avoids requiring a project-level .npmrc when the user already\n // has packageRegistryUrl in powerhouse.config.json.\n const scopes = new Set<string>();\n for (const dep of dependenciesWithVersions) {\n if (dep.name.startsWith(\"@\")) {\n const scope = dep.name.split(\"/\")[0];\n scopes.add(scope);\n }\n }\n const scopeRegistryArgs = Array.from(scopes).map(\n (scope) => `--${scope}:registry=${registryUrl}`,\n );\n\n const minReleaseAgeArgs =\n packageManager === \"pnpm\" ? [\"--config.minimum-release-age=0\"] : [];\n\n const allowBuildArgs =\n packageManager === \"pnpm\" && args.allowBuild.length > 0\n ? [`--allow-build=${args.allowBuild.join(\",\")}`]\n : [];\n\n const { resolveCommand } = await import(\"package-manager-detector\");\n const resolved = resolveCommand(packageManager, \"add\", [\n ...specs,\n ...scopeRegistryArgs,\n ...minReleaseAgeArgs,\n ...allowBuildArgs,\n ]);\n if (!resolved) {\n throw new Error(\n `Failed to resolve install command for package manager \"${packageManager}\".`,\n );\n }\n const installCommand = `${resolved.command} ${resolved.args.join(\" \")}`;\n if (scopeRegistryArgs.length > 0) {\n console.log(\n `Installing dependencies 📦 (routing ${Array.from(scopes).join(\", \")} → ${registryUrl})...`,\n );\n } else {\n console.log(\"Installing dependencies 📦...\");\n }\n console.log(`> ${installCommand}`);\n execSync(installCommand, {\n stdio: \"inherit\",\n cwd: projectPath,\n });\n console.log(\"Dependency installed successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to install dependencies\");\n throw error;\n }\n }\n\n const { updateConfigFile } = await import(\"../utils.js\");\n\n try {\n console.log(\"⚙️ Updating powerhouse config file...\");\n updateConfigFile(\n dependenciesWithVersions,\n projectPath,\n \"install\",\n args.local ? \"local\" : \"registry\",\n registryUrl,\n args.registry !== undefined,\n );\n console.log(\"Config file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update config file\");\n throw error;\n }\n\n if (args.local) {\n // A local install puts the package in node_modules, skills included.\n const { syncPackageSkills } =\n await import(\"@powerhousedao/codegen/file-builders\");\n for (const { path, action } of await syncPackageSkills(projectPath)) {\n console.log(` ${path}: ${action}`);\n }\n }\n\n if (!args.local) {\n await warnAboutExternalDependencies(\n registryUrl,\n dependenciesWithVersions,\n );\n }\n\n process.exit(0);\n },\n});\n","import { keyframesArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const keyframes = command({\n name: \"keyframes\",\n description: `\nThe keyframes command reports on and cleans up the keyframes of a running switchboard,\nthrough its inspection-admin endpoint.\n\nPrerequisites:\n - The host serves inspection-admin (INSPECTION_ADMIN_ENABLED=true).\n - The caller is one of the host's auth admins.\n - The keep rules are in powerhouse.config.json under reactor.keyframes, or in PH_KEYFRAMES.\n\nRun preview first: it only reads. clean then removes the keyframes past each type's keep\ncount and all keyframes of deleted documents, in small paced statements beside live\ntraffic. Running it again is safe. A later read that misses a keyframe replays from the\noperation log, so a clean-up costs time on cold reads and never changes a document.\n\nThe disk only shrinks after reclaim, which rewrites the Keyframe table once the store is\nquiet. On PGlite the store answers nothing while it rewrites. On Postgres it says what to\nrun by hand.\n`,\n args: keyframesArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const { runKeyframesCommand } = await import(\"../services/keyframes.js\");\n const exitCode = await runKeyframesCommand(args);\n process.exit(exitCode);\n },\n});\n","import { listArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const list = command({\n name: \"list\",\n description: `\nThe list command displays information about installed Powerhouse packages in your project.\nIt reads the powerhouse.config.json file and shows the packages that are currently installed.\n\nThis command:\n1. Examines your project configuration\n2. Lists all installed Powerhouse packages\n3. Provides a clear overview of your project's dependencies\n4. Helps you manage and track your Powerhouse components\n`,\n aliases: [\"l\"],\n args: listArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n try {\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n const projectInfo = await getPowerhouseProjectInfo();\n\n const { getConfig } = await import(\"@powerhousedao/config/node\");\n const phConfig = getConfig(\n projectInfo.projectPath + \"/powerhouse.config.json\",\n );\n\n if (!phConfig.packages || phConfig.packages.length === 0) {\n console.log(\"No packages found in the project\");\n return;\n }\n\n console.log(\"Installed Packages:\\n\");\n phConfig.packages.forEach((pkg) => {\n console.log(\n pkg.version ? `${pkg.packageName}@${pkg.version}` : pkg.packageName,\n );\n });\n } catch (_e) {\n console.log(\"No packages found in the project\");\n }\n process.exit(0);\n },\n});\n","import { loginArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const login = command({\n name: \"login\",\n description: `\nThe login command authenticates you with Renown using your Ethereum wallet. This enables\nthe CLI to act on behalf of your Ethereum identity for authenticated operations.\n\nThis command:\n1. Generates or loads a cryptographic identity (DID) for the CLI\n2. Opens your browser to the Renown authentication page\n3. You authorize the CLI's DID to act on behalf of your Ethereum address\n4. Stores the credentials locally in .ph/.renown.json\n `,\n args: loginArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown(args.renownUrl);\n\n if (args.showDid) {\n console.log(renown.did);\n process.exit(0);\n }\n\n if (args.status) {\n const { getAuthStatus } = await import(\"@renown/sdk/node\");\n const status = getAuthStatus(renown);\n if (!status.authenticated || !status.address) {\n console.log(\"Not authenticated with an Ethereum address.\");\n console.log('Run \"ph login\" to authenticate.');\n } else {\n console.log(\"Authenticated\");\n console.log(` ETH Address: ${status.address}`);\n console.log(` User DID: ${status.userDid}`);\n console.log(` Chain ID: ${status.chainId}`);\n console.log(` CLI DID: ${status.cliDid}`);\n console.log(\n ` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`,\n );\n console.log(` Renown URL: ${status.baseUrl}`);\n }\n process.exit(0);\n }\n\n if (args.logout) {\n await handleLogout();\n process.exit(0);\n }\n\n const { browserLogin } = await import(\"@renown/sdk/node\");\n\n console.debug(\"Initializing cryptographic identity...\");\n console.log(`CLI DID: ${renown.did}`);\n\n try {\n const timeoutMs = args.timeout ? args.timeout * 1000 : undefined;\n\n const result = await browserLogin(renown, {\n renownUrl: args.renownUrl,\n timeoutMs,\n onLoginUrl: (url, sessionId) => {\n console.log(\"Opening browser for authentication...\");\n console.log(`Session ID: ${sessionId.slice(0, 8)}...`);\n console.log(`Login URL: ${url}`);\n console.log();\n console.log(\"Waiting for authentication in browser\");\n console.log(`(timeout in ${(timeoutMs ?? 300_000) / 1000} seconds)`);\n console.log();\n console.log(\n \"Please connect your wallet and authorize this CLI to act on your behalf.\",\n );\n console.log();\n process.stdout.write(\"Waiting\");\n },\n onPollTick: () => process.stdout.write(\".\"),\n onBrowserOpenFailed: (url) => {\n console.error(\"Failed to open browser automatically.\");\n console.log(`Please open this URL manually: ${url}`);\n },\n });\n\n console.log(); // New line after dots\n console.log();\n console.log(\"Successfully authenticated!\");\n console.log(` ETH Address: ${result.user.address}`);\n console.log(` User DID: ${result.user.did}`);\n console.log(` CLI DID: ${result.cliDid}`);\n console.log();\n console.log(\"The CLI can now act on behalf of your Ethereum identity.\");\n } catch (error) {\n console.log(); // New line after dots\n throw error;\n }\n\n process.exit(0);\n },\n});\n\nexport async function handleLogout() {\n const { getRenown } = await import(\"../services/auth.js\");\n const renown = await getRenown();\n if (!renown.user) {\n console.log(\"Not currently authenticated.\");\n return;\n }\n\n try {\n await renown.logout();\n console.log(\"Successfully logged out.\");\n } catch (error) {\n console.error(\"Failed to clear credentials.\");\n console.debug(error);\n }\n}\n","import { command } from \"cmd-ts\";\nimport { handleLogout } from \"./login.js\";\n\nexport const logout = command({\n name: \"logout\",\n description: `\nThe logout command removes an existing session created with 'ph login'`,\n args: {},\n handler: async () => {\n await handleLogout();\n process.exit(0);\n },\n});\n","import { mcpArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const mcp = command({\n name: \"mcp\",\n args: mcpArgs,\n description: `\nServe the project's reactor-mcp tools to a coding agent over stdio.\n\nUse it as the MCP server command in .mcp.json, .cursor/mcp.json and\n.gemini/settings.json. Tools are listed at once, without waiting for the\nproject's dev stack. The first tool call connects to the running one (found\nthrough .ph/vetra-runtime.json), or starts one in the background and waits\nfor it to be ready: \\`ph run dev --strictPort\\`, the project's hosts/dev host\n(hosts/vetra in a project that has it and no hosts/dev). How\nthe start goes is reported as MCP progress notifications when the client sent a progressToken, else on\nstderr.\nStartup failures come back as tool errors carrying the stack's output, which\nis also written to .ph/vetra.log.\n\nBeside reactor-mcp's tools it serves restartVetra, which stops the project's\ndev stack, starts it again and returns its URLs. When the stack restarts some\nother way (stopped and started again), the next tool call connects to the new\none.\n`,\n handler: async (args) => {\n if (args.debug) {\n console.error(args);\n }\n const { startMcpLauncher } = await import(\"../services/mcp.js\");\n await startMcpLauncher({\n projectDir: args.projectDir,\n startTimeoutSeconds: args.startTimeout,\n });\n },\n});\n","import { migrateArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const migrate = command({\n name: \"migrate\",\n args: migrateArgs,\n description: \"Run migrations\",\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n const models = args.documentModels || args.documentModel.length > 0;\n const subgraphs = args.subgraphs || args.subgraph.length > 0;\n if (args.strictResolvers && !subgraphs) {\n console.error(\n \"--strict-resolvers applies only with --subgraphs or --subgraph.\",\n );\n process.exit(1);\n }\n if (args.renameConflictingTypes && !models) {\n console.error(\n \"--rename-conflicting-types applies only with --document-models or --document-model.\",\n );\n process.exit(1);\n }\n if (models || subgraphs) {\n if (args.versionPositional ?? args.version ?? args.force) {\n console.error(\n \"--document-models, --document-model, --subgraphs and --subgraph convert to code-first only; they take no version and no --force.\",\n );\n process.exit(1);\n }\n let code = 0;\n if (models) {\n const { migrateDocumentModels } =\n await import(\"../services/migrate-document-models.js\");\n code |= await migrateDocumentModels({\n projectDir: process.cwd(),\n dirs: args.documentModel,\n dryRun: Boolean(args.dryRun),\n renameConflictingTypes: Boolean(args.renameConflictingTypes),\n });\n }\n if (subgraphs) {\n const { migrateSubgraphs } =\n await import(\"../services/migrate-subgraphs.js\");\n code |= await migrateSubgraphs({\n projectDir: process.cwd(),\n dirs: args.subgraph,\n dryRun: Boolean(args.dryRun),\n strictResolvers: Boolean(args.strictResolvers),\n });\n }\n process.exit(code);\n }\n const { startMigrate } = await import(\"../services/migrate.js\");\n await startMigrate(args);\n process.exit(0);\n },\n});\n","import {\n modelCheckArgs,\n modelInspectArgs,\n} from \"@powerhousedao/shared/clis/args\";\nimport { command, subcommands } from \"cmd-ts\";\n\nconst EXPERIMENTAL =\n \"Experimental: the command, its output and the JSON report can change in any release.\";\n\nconst EXIT_CODES = `Exit codes:\n 0 ok, or skipped. Skipped means the package has no document model, so\n nothing was checked. Read \"status\".\n 1 invalid. The models were read and at least one is wrong.\n 2 failed. The configuration or a module could not be read, the arguments\n are wrong, or the command could not run.`;\n\nconst OUTPUT = (name: string) => `Output:\n ph model ${name} a readable report on stdout\n ph model ${name} --json exactly one JSON report on stdout and nothing else\nLogs, including what the package's modules print while they load, go to\nstderr. When the command cannot run at all, it prints only a message on\nstderr and exits 2.`;\n\nexport const modelCheck = command({\n name: \"check\",\n description: `Check this package's document models through one set of checks:\nevery model directory in documentModelsDir, whether it stores a schema-first\n<name>.json or exports a code-first model from its index.ts. Writes nothing.\n\n\\`tsc\\` cannot run these checks: a code-first model compiles when its module is\nevaluated.\n\n--release (experimental) runs the checks \\`ph build --release\\` runs: these,\nthe release checks, and host validation, which validates every model and the\npackage's scalars entry as a host that installed the package would.\n\n--prepack (experimental) loads nothing. It reads the release approval\n\\`ph build --release\\` wrote in .ph/build/release-approval.json and exits 0\nwhen it matches this package, 1 when it does not (missing, unreadable, stale\nor refused), naming the reasons, and 2 when it cannot be checked. To stop a\nplain \\`npm publish\\` too, add it to package.json, then run\n\\`ph build --release\\` (package.json is published, so the approval covers it):\n \"scripts\": { \"prepack\": \"ph-cli model check --prepack\" }\nWith --json it prints {\"decision\": ..., \"reasons\": [...]}.\n\n${EXIT_CODES}\n\n${OUTPUT(\"check\")}\n\n${EXPERIMENTAL}`,\n args: modelCheckArgs,\n handler: async (args) => {\n if (args.debug) {\n console.error(args);\n }\n const [{ runModelCheck }, { exitWithModelCommand }] = await Promise.all([\n import(\"../services/model/check.js\"),\n import(\"../services/model/run.js\"),\n ]);\n await exitWithModelCommand(args.json, (streams) =>\n runModelCheck(args, { streams }),\n );\n },\n});\n\nexport const modelInspect = command({\n name: \"inspect\",\n description: `Describe this package's document models without checking them: for each\nmodel its digest and compatibility, and for each of its versions the source,\nscopes, scalars and operations. With <documentType>@<version>, describe that\nversion only and add its full definition to the JSON report. Writes nothing.\n\n${EXIT_CODES}\n\n${OUTPUT(\"inspect\")}\n\n${EXPERIMENTAL}`,\n args: modelInspectArgs,\n handler: async (args) => {\n if (args.debug) {\n console.error(args);\n }\n const [{ runModelInspect }, { exitWithModelCommand }] = await Promise.all([\n import(\"../services/model/inspect.js\"),\n import(\"../services/model/run.js\"),\n ]);\n await exitWithModelCommand(args.json, (streams) =>\n runModelInspect(args, { streams }),\n );\n },\n});\n\nexport const model = subcommands({\n name: \"model\",\n description:\n \"Check or inspect this package's document models (experimental): `check`, `inspect`.\",\n cmds: { check: modelCheck, inspect: modelInspect },\n});\n","import { publishArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nfunction hasTagFlag(args: string[]): boolean {\n return args.some((a) => a === \"--tag\" || a.startsWith(\"--tag=\"));\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nasync function readPrereleaseTag(\n projectPath: string,\n packedVersion: string | undefined,\n): Promise<{\n version: string;\n tag: string;\n} | null> {\n try {\n const [{ readPackageSync }, { prerelease }] = await Promise.all([\n import(\"read-pkg\"),\n import(\"semver\"),\n ]);\n const version =\n packedVersion ?? readPackageSync({ cwd: projectPath }).version;\n if (!version) return null;\n const parts = prerelease(version);\n if (!parts || parts.length === 0) return null;\n const label = String(parts[0]);\n // semver may surface numeric-only prerelease ids (e.g. `1.0.0-0`);\n // npm requires an alphanumeric dist-tag, so skip those.\n if (!/^[a-z][a-z0-9-]*$/i.test(label)) return null;\n return { version, tag: label };\n } catch {\n return null;\n }\n}\n\nexport const publish = command({\n name: \"publish\",\n description: `\nPublish a package to the Powerhouse registry. This is a thin wrapper around npm publish\nthat automatically sets the registry URL.\n\nThis command:\n0. With a release approval from ph build --release (experimental), checks that it matches\n the package and warns when it does not. --require-approval exits 1 instead; it forwards\n only --tag, --access, --otp, --dry-run, --provenance, --json and --loglevel to npm,\n refuses npm configuration in the environment that selects another package\n (npm_config_workspace, npm_config_workspaces, npm_config_include_workspace_root),\n packs the package once, checks that tarball, and publishes that tarball with\n --ignore-scripts, so a file changed after the check is not published\n1. Resolves the registry URL (--registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default)\n2. Checks authentication with the registry via npm whoami\n3. Forwards all additional arguments to npm publish\n `,\n args: publishArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n const { projectPath } = await getPowerhouseProjectInfo();\n\n if (!projectPath) {\n throw new Error(\"Could not find project path.\");\n }\n\n const { checkApprovalBeforePublish } =\n await import(\"../services/release/verify.js\");\n if (args.requireApproval) {\n const {\n ALLOWED_NPM_ARGUMENTS,\n refusedNpmArguments,\n targetSelectingNpmEnvironment,\n } = await import(\"../services/release/npm-args.js\");\n const refused = refusedNpmArguments(args.forwardedArgs);\n if (refused.length > 0) {\n console.error(\n `✘ ph publish --require-approval publishes only the package it checked, so it forwards only these npm arguments: ${ALLOWED_NPM_ARGUMENTS}. Not allowed: ${refused.join(\" \")}`,\n );\n process.exit(1);\n }\n const selecting = targetSelectingNpmEnvironment(process.env);\n if (selecting.length > 0) {\n console.error(\n `✘ ph publish --require-approval publishes only the package it checked, but the environment sets npm configuration that selects another package: ${selecting.join(\", \")}. Unset it and publish again.`,\n );\n process.exit(1);\n }\n }\n const checked = checkApprovalBeforePublish(\n projectPath,\n args.requireApproval,\n );\n if (!checked.proceed) {\n process.exit(1);\n }\n const { packed } = checked;\n if (packed) process.once(\"exit\", packed.dispose);\n try {\n const { checkNpmAuth, npmPublish, resolveRegistryUrl } =\n await import(\"@powerhousedao/shared/registry\");\n const { mintRegistryAuthToken } =\n await import(\"../services/registry-auth.js\");\n\n const registryUrl = resolveRegistryUrl({\n registry: args.registry,\n projectPath,\n });\n\n if (args.debug) {\n console.log(\">>> registryUrl\", registryUrl);\n }\n\n // Try Renown auth first: if the user is logged in via `ph login`, mint a\n // short-lived registry-bound bearer token. Falling back to the legacy\n // `npm adduser` (htpasswd) path keeps existing flows working until the\n // grace period ends.\n let authToken: string | undefined;\n try {\n authToken = await mintRegistryAuthToken(registryUrl, 5 * 60);\n if (args.debug) {\n console.error(`>>> minted renown token for ${registryUrl} (5m TTL)`);\n }\n } catch (err) {\n if (args.debug) {\n console.error(\n `>>> renown token mint skipped: ${(err as Error).message}`,\n );\n }\n try {\n await checkNpmAuth(registryUrl);\n } catch {\n console.error(`Not authenticated with registry: ${registryUrl}`);\n console.error(\n `Run: ph login (recommended) or npm adduser --registry ${registryUrl}`,\n );\n process.exit(1);\n }\n }\n\n let forwardedArgs = args.forwardedArgs;\n\n if (!hasTagFlag(forwardedArgs)) {\n const prereleaseInfo = await readPrereleaseTag(\n projectPath,\n packed?.manifest.version,\n );\n if (prereleaseInfo) {\n const { version, tag } = prereleaseInfo;\n if (!isInteractive()) {\n console.error(\n `Detected prerelease version ${version}. npm requires an explicit dist-tag for prerelease publishes.`,\n );\n console.error(\n `Re-run with --tag <label> (e.g. --tag ${tag}) to proceed.`,\n );\n process.exit(1);\n }\n\n const enquirer = await import(\"enquirer\");\n\n let confirmed: boolean;\n try {\n const answer = await enquirer.default.prompt<{\n confirmed: boolean;\n }>({\n type: \"confirm\",\n name: \"confirmed\",\n message: `Detected prerelease version ${version}. Publish with --tag ${tag}?`,\n initial: true,\n });\n confirmed = answer.confirmed;\n } catch {\n // user aborted the prompt (Ctrl-C); treat as decline\n confirmed = false;\n }\n\n if (!confirmed) {\n console.error(\n `Aborted. To publish manually: npm publish --registry ${registryUrl} --tag <label>`,\n );\n process.exit(1);\n }\n\n forwardedArgs = [\"--tag\", tag, ...forwardedArgs];\n }\n }\n\n if (args.debug) {\n console.log(\n \">>> command\",\n `npm publish --registry ${registryUrl} ${forwardedArgs.join(\" \")}`,\n );\n }\n\n if (args.requireApproval) {\n // The approval checked this package's files as they are: a prepack,\n // prepare or prepublishOnly script would change them after that check,\n // and an .npmrc `workspace` would publish another package, which npm\n // refuses alongside --workspaces=false.\n forwardedArgs = [\n ...forwardedArgs,\n \"--ignore-scripts\",\n \"--workspaces=false\",\n ];\n console.log(\n \"Lifecycle scripts are skipped (--ignore-scripts) and workspaces are off (--workspaces=false), so npm publishes the tarball the approval matched.\",\n );\n }\n\n console.log(`Publishing to ${registryUrl}...`);\n const result = await npmPublish({\n registryUrl,\n cwd: projectPath,\n args: packed ? [packed.tarball, ...forwardedArgs] : forwardedArgs,\n authToken,\n });\n if (result.stdout) {\n console.log(result.stdout);\n }\n\n process.exit(0);\n } finally {\n packed?.dispose();\n }\n },\n});\n","import { registryLoginArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\n\nexport const registryLogin = command({\n name: \"registry-login\",\n description: `\nLog in to a Powerhouse registry using your Renown identity. Mints a longer-lived\nbearer token (default 30 days) bound to the registry's audience and writes the\ntoken into ~/.npmrc so raw 'npm publish' / 'npm install' work without further\nsetup.\n\nPrerequisites:\n Run 'ph login' first to establish a Renown identity.\n\nUsage:\n ph registry-login # uses powerhouse.config.json / PH_REGISTRY_URL\n ph registry-login --registry https://registry.vetra.io\n ph registry-login --expiry 7d\n `,\n args: registryLoginArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n const projectInfo = await getPowerhouseProjectInfo().catch(() => null);\n const projectPath = projectInfo?.projectPath ?? process.cwd();\n\n const [\n { resolveRegistryUrl, writeRegistryAuthToken },\n { mintRegistryAuthToken },\n { parseExpiry, formatExpiry },\n ] = await Promise.all([\n import(\"@powerhousedao/shared/registry\"),\n import(\"../services/registry-auth.js\"),\n import(\"@renown/sdk/node\"),\n ]);\n\n const registryUrl = resolveRegistryUrl({\n registry: args.registry,\n projectPath,\n });\n\n const expiresIn = parseExpiry(args.expiry);\n\n const token = await mintRegistryAuthToken(registryUrl, expiresIn);\n const npmrcPath = await writeRegistryAuthToken(registryUrl, token);\n\n console.log(`Logged in to ${registryUrl}`);\n console.log(` Token expires in: ${formatExpiry(expiresIn)}`);\n console.log(` Wrote: ${npmrcPath}`);\n process.exit(0);\n },\n});\n","import {\n boolean,\n command,\n flag,\n option,\n optional,\n positional,\n restPositionals,\n string,\n} from \"cmd-ts\";\nimport { isDevHost } from \"../utils/dev-host.js\";\n\nexport const runHost = command({\n name: \"run\",\n description:\n \"Run a host from the project's hosts/ folder: `ph run <host> [verb]`. \" +\n \"The host's own host.js names the runner module; the verb defaults to `run`. \" +\n \"Arguments after the verb go to the runner, which names the ones it accepts. \" +\n \"`ph run <package>/<host>` runs a host that an installed package supplies.\",\n args: {\n host: positional({\n type: string,\n displayName: \"host\",\n description:\n \"Folder name under hosts/ (e.g. dev, connect), or `<package>/<host>` \" +\n \"for one in an installed package's hosts/ (e.g. `@acme/tools/studio`).\",\n }),\n verb: positional({\n type: optional(string),\n displayName: \"verb\",\n description: \"Runner verb (default: run; e.g. dev, build, serve).\",\n }),\n debug: flag({\n type: optional(boolean),\n long: \"debug\",\n description: \"Print resolved host/runner/verb before dispatch.\",\n }),\n stop: flag({\n type: optional(boolean),\n long: \"stop\",\n description:\n \"Stop the project's running instance of this host instead of \" +\n \"starting one: it shuts down as on Ctrl-C, and the command returns \" +\n \"when it has.\",\n }),\n explain: option({\n type: optional(string),\n long: \"explain\",\n description:\n \"Explain a resolved aspect instead of running: `--explain drives` \" +\n \"prints the merged drive plan with provenance; `--explain outputs` \" +\n \"prints what each host produces, the output tokens it reads and \" +\n \"the start order they imply.\",\n }),\n // cli.ts moves the runner's arguments behind a `--` (forwardRunnerArgv).\n argv: restPositionals({\n type: string,\n displayName: \"runner arguments\",\n description:\n \"Arguments for the host's runner (e.g. --port 4001); they win over \" +\n \"the host file.\",\n }),\n },\n handler: async (args) => {\n if (args.explain !== undefined) {\n const { explainHost } = await import(\"../services/run/explain.js\");\n await explainHost({ host: args.host, topic: args.explain });\n return;\n }\n if (args.stop) {\n const { stopRunningHost } =\n await import(\"@powerhousedao/ph-run/start-run\");\n await stopRunningHost({ host: args.host });\n return;\n }\n const run = {\n host: args.host,\n verb: args.verb,\n debug: args.debug,\n argv: args.argv,\n };\n // What `ph dev` is sugar for (run-sugar.ts): the stack keeps the runtime\n // record `ph mcp` reads.\n if (isDevHost(args.host)) {\n const { runVetraHost } = await import(\"../services/run/vetra-host.js\");\n await runVetraHost(run);\n return;\n }\n const { startRun } = await import(\"@powerhousedao/ph-run/start-run\");\n await startRun(run);\n },\n});\n","import { AGENTS, uninstallArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\nimport { execSync } from \"node:child_process\";\n\nexport const uninstall = command({\n name: \"uninstall\",\n aliases: [\"remove\"],\n description: `\nThe uninstall command removes Powerhouse dependencies from your project. It handles the\nremoval of packages, updates configuration files, and ensures proper cleanup.\n\nThis command:\n1. Uninstalls specified Powerhouse dependencies using your package manager\n2. Updates powerhouse.config.json to remove the dependencies\n3. Supports various uninstallation options and configurations\n4. Works with ${AGENTS.join(\", \")} package managers\n`,\n args: uninstallArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const {\n getPowerhouseProjectInfo,\n getPowerhouseProjectUninstallCommand,\n makeDependenciesWithVersions,\n } = await import(\"@powerhousedao/shared/clis\");\n\n const {\n projectPath,\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n } = await getPowerhouseProjectInfo(args);\n\n if (!projectPath) {\n throw new Error(`Could not find project path to uninstall from`);\n }\n\n const dependenciesWithVersions = await makeDependenciesWithVersions(\n args.dependencies,\n );\n\n if (args.debug) {\n console.log(\">>> parsedDependencies\", dependenciesWithVersions);\n }\n\n if (args.debug) {\n console.log(\"\\n>>> projectInfo\", {\n localProjectPath,\n globalProjectPath,\n packageManager,\n isGlobal,\n });\n }\n\n try {\n console.log(\"Uninstalling dependencies 📦 ...\");\n const uninstallCommand = await getPowerhouseProjectUninstallCommand(\n packageManager,\n args.dependencies,\n );\n execSync(uninstallCommand, {\n stdio: \"inherit\",\n cwd: projectPath,\n });\n console.log(\"Dependency uninstalled successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to uninstall dependencies\");\n throw error;\n }\n\n const { removeStylesImports, updateConfigFile } =\n await import(\"../utils.js\");\n\n try {\n console.log(\"⚙️ Updating powerhouse config file...\");\n updateConfigFile(dependenciesWithVersions, projectPath, \"uninstall\");\n console.log(\"Config file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update config file\");\n throw error;\n }\n\n // Skills of the removed packages leave with them.\n const { syncPackageSkills } =\n await import(\"@powerhousedao/codegen/file-builders\");\n for (const { path, action } of await syncPackageSkills(projectPath)) {\n console.log(` ${path}: ${action}`);\n }\n\n try {\n console.log(\"⚙️ Updating styles.css file...\");\n removeStylesImports(dependenciesWithVersions, projectPath);\n console.log(\"Styles file updated successfully 🎉\");\n } catch (error) {\n console.error(\"❌ Failed to update styles file\");\n throw error;\n }\n\n process.exit(0);\n },\n});\n","import { unpublishArgs } from \"@powerhousedao/shared/clis/args\";\nimport { command } from \"cmd-ts\";\nimport { createInterface } from \"node:readline/promises\";\n\nexport const unpublish = command({\n name: \"unpublish\",\n description: `\nUnpublish a package from the Powerhouse registry. This is a thin wrapper around\nnpm unpublish that automatically targets the Powerhouse registry and never\nreaches npmjs.org.\n\nForms:\n ph unpublish # unpublish <name>@<version> from cwd's package.json\n ph unpublish <name> # unpublish the whole package (all versions)\n ph unpublish <name>@<version> # unpublish a single version\n\nFlags:\n --registry <url> # override registry URL\n --yes, -y # skip the confirmation prompt\n `,\n args: unpublishArgs,\n handler: async (args) => {\n if (args.debug) {\n console.log(args);\n }\n\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n const { projectPath } = await getPowerhouseProjectInfo();\n\n if (!projectPath) {\n throw new Error(\"Could not find project path.\");\n }\n\n const { checkNpmAuth, npmUnpublish, resolveRegistryUrl } =\n await import(\"@powerhousedao/shared/registry\");\n\n const registryUrl = resolveRegistryUrl({\n registry: args.registry,\n projectPath,\n });\n\n const spec = await resolveSpec(args.spec, projectPath);\n if (!spec) {\n console.error(\n \"No package spec provided and could not read name/version from package.json.\",\n );\n process.exit(1);\n }\n\n if (args.debug) {\n console.log(\">>> registryUrl\", registryUrl);\n console.log(\">>> spec\", spec);\n }\n\n try {\n await checkNpmAuth(registryUrl);\n } catch {\n console.error(`Not authenticated with registry: ${registryUrl}`);\n console.error(`Run: npm adduser --registry ${registryUrl}`);\n process.exit(1);\n }\n\n if (!args.yes) {\n const confirmed = await confirm(\n `Unpublish ${spec} from ${registryUrl}? [y/N] `,\n );\n if (!confirmed) {\n console.log(\"Aborted.\");\n process.exit(0);\n }\n }\n\n if (args.debug) {\n console.log(\n \">>> command\",\n `npm unpublish ${spec} --registry ${registryUrl} --force ${args.forwardedArgs.join(\" \")}`,\n );\n }\n\n console.log(`Unpublishing ${spec} from ${registryUrl}...`);\n try {\n const result = await npmUnpublish({\n registryUrl,\n cwd: projectPath,\n spec,\n args: args.forwardedArgs,\n });\n if (result.stdout) {\n console.log(result.stdout);\n }\n process.exit(0);\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n },\n});\n\nasync function resolveSpec(\n explicit: string | undefined,\n projectPath: string,\n): Promise<string | null> {\n if (explicit) return explicit;\n try {\n const { readPackageSync } = await import(\"read-pkg\");\n const pkg = readPackageSync({ cwd: projectPath });\n if (!pkg.name) return null;\n return pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name;\n } catch {\n return null;\n }\n}\n\nasync function confirm(prompt: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n try {\n const answer = await rl.question(prompt);\n return /^y(es)?$/i.test(answer.trim());\n } finally {\n rl.close();\n }\n}\n","import { command, optional, positional, restPositionals, string } from \"cmd-ts\";\nimport {\n VETRA_STUDIO_HOST,\n VETRA_STUDIO_PACKAGE,\n} from \"../services/vetra-gateway.js\";\n\n/**\n * `ph vetra`, the gateway to Vetra Studio. cli.ts hands every `ph vetra` but\n * its help to the gateway (services/vetra-gateway.ts), which makes it the\n * `ph run` of the studio host: this command gives the help and the docs.\n */\nexport const vetra = command({\n name: \"vetra\",\n description:\n `Open Vetra Studio: \\`ph vetra [verb]\\` is \\`ph run ${VETRA_STUDIO_HOST} [verb]\\`, ` +\n `the studio host of the ${VETRA_STUDIO_PACKAGE} package. ` +\n `A project without the package gets it first: \\`ph vetra\\` installs it as a devDependency, ` +\n \"at this ph-cli's version, with the project's package manager. \" +\n \"The runner arguments, --stop and --explain work as for `ph run`. \" +\n \"The dev mode that `ph vetra` started before 6.4 (the project's hosts/vetra) is `ph dev`.\",\n args: {\n verb: positional({\n type: optional(string),\n displayName: \"verb\",\n description: \"Verb of the studio host (default: the host's own).\",\n }),\n argv: restPositionals({\n type: string,\n displayName: \"runner arguments\",\n description:\n \"Arguments for the studio host's runner, as `ph run` takes them.\",\n }),\n },\n handler: () => {\n // Not reached: cli.ts runs `ph vetra` through the gateway.\n throw new Error(\n `\\`ph vetra\\` is \\`ph run ${VETRA_STUDIO_HOST}\\`, through the gateway in cli.ts.`,\n );\n },\n});\n","import { accessToken } from \"./access-token.js\";\nimport { build } from \"./build.js\";\nimport { connect } from \"./connect.js\";\nimport { generate } from \"./generate.js\";\nimport { host } from \"./host.js\";\nimport { init } from \"./init.js\";\nimport { inspect } from \"./inspect.js\";\nimport { install } from \"./install.js\";\nimport { keyframes } from \"./keyframes.js\";\nimport { list } from \"./list.js\";\nimport { login } from \"./login.js\";\nimport { logout } from \"./logout.js\";\nimport { mcp } from \"./mcp.js\";\nimport { migrate } from \"./migrate.js\";\nimport { model } from \"./model.js\";\nimport { publish } from \"./publish.js\";\nimport { registryLogin } from \"./registry-login.js\";\nimport { runHost } from \"./run.js\";\nimport { uninstall } from \"./uninstall.js\";\nimport { unpublish } from \"./unpublish.js\";\nimport { vetra } from \"./vetra.js\";\n\nexport const phCliCommands = {\n init,\n generate,\n connect,\n build,\n publish,\n unpublish,\n \"access-token\": accessToken,\n \"registry-login\": registryLogin,\n inspect,\n keyframes,\n list,\n mcp,\n migrate,\n model,\n login,\n logout,\n install,\n uninstall,\n run: runHost,\n host,\n vetra,\n} as const;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,MAAa,cAAc,QAAQ;CACjC,MAAM;CACN,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cb,MAAM;CACN,SAAS,OAAO,SAAS;EACvB,IAAI,KAAK,OACP,QAAQ,IAAI,IAAI;EAGlB,MAAM,EAAE,qBAAqB,aAAa,iBACxC,MAAM,OAAO;EACf,MAAM,EAAE,cAAc,MAAM,OAAO;EACnC,MAAM,SAAS,MAAM,UAAU;EAE/B,IAAI,YAAY;EAChB,IAAI,KAAK,QAAQ,YAAY,YAAY,KAAK,MAAM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AAY,CAAC;EAChD,IAAI,CAAC,IAAI,MAAM,OAAO;EACtB,OAAO,IAAI,UAAU,GAAG,IAAI,KAAK,GAAG,IAAI,YAAY,IAAI;CAC1D,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAe,QAAQ,QAAkC;CACvD,MAAM,KAAK,gBAAgB;EAAE,OAAO,QAAQ;EAAO,QAAQ,QAAQ;CAAO,CAAC;CAC3E,IAAI;EACF,MAAM,SAAS,MAAM,GAAG,SAAS,MAAM;EACvC,OAAO,YAAY,KAAK,OAAO,KAAK,CAAC;CACvC,UAAU;EACR,GAAG,MAAM;CACX;AACF;;;AEpGA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA,gBAAgB;CAChB,kBAAkB;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,KAAK;CACL;CACA,ODhCmB,QAAQ;EAC3B,MAAM;EACN,aACE,sDAAsD,kBAAkB,oCAC9C,qBAAqB;EAKjD,MAAM;GACJ,MAAM,WAAW;IACf,MAAM,SAAS,MAAM;IACrB,aAAa;IACb,aAAa;GACf,CAAC;GACD,MAAM,gBAAgB;IACpB,MAAM;IACN,aAAa;IACb,aACE;GACJ,CAAC;EACH;EACA,eAAe;GAEb,MAAM,IAAI,MACR,4BAA4B,kBAAkB,mCAChD;EACF;CACF,CCIE;AACF","debug_id":"d9725588-ce21-5651-b8da-3c4e72510054"}
@@ -1,4 +0,0 @@
1
- import { t as phCliCommands } from "./ph-cli-commands-D4Z6YSwd.mjs";
2
- export { phCliCommands };
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="209bb7c6-cd01-5c53-891b-eee91120ef5f")}catch(e){}}();
4
- //# debugId=209bb7c6-cd01-5c53-891b-eee91120ef5f
@@ -1,4 +0,0 @@
1
- import { t as renderCheckReport } from "./render-SVfj3m8A.mjs";
2
- export { renderCheckReport };
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f3214a62-6a6f-5d4f-b59e-0ee03ecd54d8")}catch(e){}}();
4
- //# debugId=f3214a62-6a6f-5d4f-b59e-0ee03ecd54d8
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-SVfj3m8A.mjs","sources":["../src/services/model/render.ts"],"sourcesContent":["import type {\n DefinitionCheckReport,\n DefinitionCheckSkipReason,\n DefinitionDiagnostic,\n} from \"@powerhousedao/shared/document-model\";\nimport {\n type DefinitionInspectionReport,\n type DocumentModelInspection,\n formatDefinitionDiagnostic,\n formatDefinitionSource,\n type SubgraphInspection,\n type SubgraphInspectionReport,\n} from \"document-model/tooling\";\n\nconst SKIP_REASONS: Readonly<Record<DefinitionCheckSkipReason, string>> = {\n \"no-document-models\": \"The models directory holds no document model\",\n};\n\nconst plural = (count: number, noun: string, nouns = `${noun}s`) =>\n `${count} ${count === 1 ? noun : nouns}`;\n\nfunction statusLine(\n report: DefinitionCheckReport | DefinitionInspectionReport,\n counted: string,\n): string {\n const { documentModelsDir, sources, stored } = report.sourceSet;\n return `${report.status}: ${counted} (${documentModelsDir}: ${plural(sources.length, \"code-first entry\", \"code-first entries\")}, ${plural(stored.length, \"stored model\")})`;\n}\n\nfunction skipped(reason: DefinitionCheckSkipReason | undefined): string[] {\n if (reason === undefined) return [];\n return [`${SKIP_REASONS[reason]}, so nothing was checked.`];\n}\n\nfunction diagnosticLines(\n diagnostics: readonly DefinitionDiagnostic[],\n): string[] {\n const errors = diagnostics.filter(\n ({ severity }) => severity === \"error\",\n ).length;\n return [\n ...diagnostics.map(formatDefinitionDiagnostic),\n `${plural(errors, \"error\")}, ${plural(diagnostics.length - errors, \"warning\")}`,\n ];\n}\n\nexport function renderCheckReport(report: DefinitionCheckReport): string {\n return [\n statusLine(report, plural(report.definitions.length, \"definition\")),\n ...skipped(report.skipReason),\n ...report.definitions.map(\n ({ kind, key, version, source }) =>\n ` ${kind} ${key}${version === undefined ? \"\" : ` v${version}`} ${formatDefinitionSource(source)}`,\n ),\n ...diagnosticLines(report.diagnostics),\n ].join(\"\\n\");\n}\n\ntype FamilyInspection = DefinitionInspectionReport[\"families\"][number];\n\nfunction operationLine(\n operation: DocumentModelInspection[\"modules\"][number][\"operations\"][number],\n): string {\n const errors = operation.errors.map(({ key, code }) =>\n code === null ? key : `${key} (${code})`,\n );\n return [\n ` ${operation.actionType}`,\n operation.scope,\n `input ${operation.input ?? \"none\"}`,\n ...(errors.length === 0 ? [] : [`errors ${errors.join(\", \")}`]),\n ].join(\" \");\n}\n\nfunction versionLines(\n documentType: string,\n model: DocumentModelInspection,\n): string[] {\n return [\n ` ${documentType}@${model.version}`,\n ` source ${formatDefinitionSource(model.source)}`,\n ` scopes global ${model.scopes.global}, local ${model.scopes.local ?? \"none\"}`,\n ` scalars ${\n model.scalars.length === 0\n ? \"none\"\n : model.scalars\n .map(({ name, implementation }) => `${name} (${implementation})`)\n .join(\", \")\n }`,\n ...model.modules.flatMap((module) => [\n ` module ${module.name}`,\n ...module.operations.map(operationLine),\n ]),\n ];\n}\n\nfunction familyLines(family: FamilyInspection): string[] {\n const { identity, scalarCoercion, serialization } = family.compatibility;\n return [\n `${family.documentType} ${family.name} (${family.extension})`,\n ` digest ${family.digest}`,\n ` compatibility identity ${identity}, scalar coercion ${scalarCoercion}, serialization ${serialization}`,\n ...family.versions.flatMap((model) =>\n versionLines(family.documentType, model),\n ),\n ];\n}\n\nfunction subgraphLines(subgraph: SubgraphInspection): string[] {\n if (subgraph.style === \"schema-first\") {\n return [\n ` ${subgraph.name ?? \"(unnamed)\"} schema-first ${formatDefinitionSource(subgraph.source)}`,\n ];\n }\n return [\n ` ${subgraph.name} code-first ${formatDefinitionSource(subgraph.source)}`,\n ` digest ${subgraph.digest}`,\n ` entries ${subgraph.entries.join(\", \")}`,\n ` types ${subgraph.types.length === 0 ? \"none\" : subgraph.types.join(\", \")}`,\n ];\n}\n\nexport function renderInspectionReport(\n report: DefinitionInspectionReport | SubgraphInspectionReport,\n): string {\n return [\n statusLine(\n report,\n plural(\n report.families.reduce((sum, { versions }) => sum + versions.length, 0),\n \"model\",\n ),\n ),\n ...(report.status === \"skipped\"\n ? [\n \"The models directory holds no document model, so there is nothing to inspect.\",\n ]\n : []),\n ...report.families.flatMap(familyLines),\n ...(report.definition === undefined\n ? []\n : [\"The full definition of this model is in --json, as `definition`.\"]),\n ...(\"subgraphs\" in report\n ? [\n `subgraphs: ${report.subgraphs.length}`,\n ...report.subgraphs.flatMap(subgraphLines),\n ]\n : []),\n ...diagnosticLines(report.diagnostics),\n ].join(\"\\n\");\n}\n"],"names":[],"mappings":";;;;AAcA,MAAM,eAAoE,EACxE,sBAAsB,+CACxB;AAEA,MAAM,UAAU,OAAe,MAAc,QAAQ,GAAG,KAAK,OAC3D,GAAG,MAAM,GAAG,UAAU,IAAI,OAAO;AAEnC,SAAS,WACP,QACA,SACQ;CACR,MAAM,EAAE,mBAAmB,SAAS,WAAW,OAAO;CACtD,OAAO,GAAG,OAAO,OAAO,IAAI,QAAQ,IAAI,kBAAkB,IAAI,OAAO,QAAQ,QAAQ,oBAAoB,oBAAoB,EAAE,IAAI,OAAO,OAAO,QAAQ,cAAc,EAAE;AAC3K;AAEA,SAAS,QAAQ,QAAyD;CACxE,IAAI,WAAW,KAAA,GAAW,OAAO,CAAC;CAClC,OAAO,CAAC,GAAG,aAAa,QAAQ,0BAA0B;AAC5D;AAEA,SAAS,gBACP,aACU;CACV,MAAM,SAAS,YAAY,QACxB,EAAE,eAAe,aAAa,OACjC,CAAC,CAAC;CACF,OAAO,CACL,GAAG,YAAY,IAAI,0BAA0B,GAC7C,GAAG,OAAO,QAAQ,OAAO,EAAE,IAAI,OAAO,YAAY,S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Y,OAAO;EACnB,4BAA4B,SAAS,oBAAoB,eAAe,kBAAkB;EAC1F,GAAG,OAAO,SAAS,SAAS,UAC1B,aAAa,OAAO,cAAc,KAAK,CACzC;CACF;AACF;AAEA,SAAS,cAAc,UAAwC;CAC7D,IAAI,SAAS,UAAU,gBACrB,OAAO,CACL,KAAK,SAAS,QAAQ,YAAY,gBAAgB,uBAAuB,SAAS,MAAM,GAC1F;CAEF,OAAO;EACL,KAAK,SAAS,KAAK,cAAc,uBAAuB,SAAS,MAAM;EACvE,cAAc,SAAS;EACvB,eAAe,SAAS,QAAQ,KAAK,IAAI;EACzC,aAAa,SAAS,MAAM,WAAW,IAAI,SAAS,SAAS,MAAM,KAAK,IAAI;CAC9E;AACF;AAEA,SAAgB,uBACd,QACQ;CACR,OAAO;EACL,WACE,QACA,OACE,OAAO,SAAS,QAAQ,KAAK,EAAE,eAAe,MAAM,SAAS,QAAQ,CAAC,GACtE,OACF,CACF;EACA,GAAI,OAAO,WAAW,YAClB,CACE,+EACF,IACA,CAAC;EACL,GAAG,OAAO,SAAS,QAAQ,WAAW;EACtC,GAAI,OAAO,eAAe,KAAA,IACtB,CAAC,IACD,CAAC,kEAAkE;EACvE,GAAI,eAAe,SACf,CACE,cAAc,OAAO,UAAU,UAC/B,GAAG,OAAO,UAAU,QAAQ,aAAa,CAC3C,IACA,CAAC;EACL,GAAG,gBAAgB,OAAO,WAAW;CACvC,CAAC,CAAC,KAAK,IAAI;AACb","debug_id":"5939d67e-5cfe-543e-bbf7-81ab64b3a6f5"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run--de_-WAz.mjs","sources":["../src/services/model/project.ts","../src/services/model/run.ts"],"sourcesContent":["import {\n uncachedDefinitionSourceRevision,\n ViteTypeScriptSourceImportAdapter,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n DefinitionSourceLoader,\n loadProjectDefinitions,\n type ProjectDefinitions,\n} from \"document-model/tooling\";\nimport { join } from \"node:path\";\n\n/** Imports more of the package through the importer that loaded its definitions. */\nexport type ProjectModules = {\n readonly importModule: (\n specifier: `./${string}`,\n ) => Promise<Readonly<Record<string, unknown>>>;\n};\n\n/**\n * Loads the package's definitions with codegen's Vite importer, hands them to\n * `read`, then disposes the loader. The package's own modules are imported\n * into this process: `ph model` runs it in its own process, `ph build` in the\n * definitions worker.\n */\nexport async function readProjectDefinitions<R>(\n projectRoot: string,\n read: (\n project: ProjectDefinitions,\n modules: ProjectModules,\n ) => R | Promise<R>,\n options: { readonly allowMissingConfig?: boolean } = {},\n): Promise<R> {\n const importer = new ViteTypeScriptSourceImportAdapter();\n const loader = new DefinitionSourceLoader(importer);\n const packageRevision = uncachedDefinitionSourceRevision();\n try {\n const project = await loadProjectDefinitions({\n loader,\n configFile: join(projectRoot, \"powerhouse.config.json\"),\n ...(options.allowMissingConfig === true && { allowMissingConfig: true }),\n packageRevision,\n importedFiles: (specifier) => importer.filesImportedBy(specifier),\n });\n return await read(project, {\n importModule: (specifier) =>\n importer.importModule({\n packageRoot: project.packageRoot,\n specifier,\n packageRevision,\n }),\n });\n } finally {\n await loader.dispose();\n }\n}\n","import type { DefinitionCheckReport } from \"@powerhousedao/shared/document-model\";\nimport type { ProjectDefinitions } from \"document-model/tooling\";\nimport { type ProjectModules, readProjectDefinitions } from \"./project.js\";\n\nexport type ModelStreams = {\n readonly out: (text: string) => void;\n readonly err: (text: string) => void;\n};\n\nexport type ModelRunOptions = {\n /** Default: the directory ph-cli runs in, which ph-cmd sets to the project root. */\n readonly projectRoot?: string;\n readonly streams?: ModelStreams;\n};\n\ntype Status = DefinitionCheckReport[\"status\"];\n\nconst EXIT_CODES: Readonly<Record<Status, 0 | 1 | 2>> = {\n ok: 0,\n skipped: 0,\n invalid: 1,\n failed: 2,\n};\n\nexport const processStreams: ModelStreams = {\n out: (text) => void process.stdout.write(text),\n err: (text) => void process.stderr.write(text),\n};\n\n/** Sends what is written to stdout to `write` until the returned restore runs. */\nfunction redirectStdout(write: (text: string) => void): () => void {\n const original = process.stdout.write.bind(process.stdout);\n process.stdout.write = ((chunk: string | Uint8Array, ...rest: unknown[]) => {\n write(typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString());\n const callback = rest.find((value) => typeof value === \"function\");\n (callback as (() => void) | undefined)?.();\n return true;\n }) as typeof process.stdout.write;\n return () => {\n process.stdout.write = original;\n };\n}\n\n/** Vite and the package's own modules may print while they load. */\nasync function stdoutTo<T>(\n write: (text: string) => void,\n work: () => Promise<T>,\n): Promise<T> {\n const restore = redirectStdout(write);\n try {\n return await work();\n } finally {\n restore();\n }\n}\n\n/**\n * Loads the project once, builds a report from it and prints the report.\n * Returns the exit code: 0 ok or skipped, 1 invalid, 2 failed or not run.\n * Any throw, from loading through printing, is exit 2: exit 1 means the\n * models were read and one is wrong.\n */\nexport async function runModelCommand<R extends { readonly status: Status }>(\n request: {\n readonly name: string;\n readonly json: boolean;\n readonly read: (\n project: ProjectDefinitions,\n modules: ProjectModules,\n ) => R | Promise<R>;\n readonly render: (report: R) => string;\n },\n options: ModelRunOptions,\n): Promise<number> {\n const streams = options.streams ?? processStreams;\n const projectRoot = options.projectRoot ?? process.cwd();\n try {\n const report = await stdoutTo(streams.err, () =>\n readProjectDefinitions(projectRoot, request.read),\n );\n const text = request.json ? JSON.stringify(report) : request.render(report);\n streams.out(`${text}\\n`);\n return EXIT_CODES[report.status];\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n streams.err(`${request.name} could not run: ${message}\\n`);\n return 2;\n }\n}\n\n/**\n * Runs a `ph model` command as the process and exits with its code once\n * stdout and stderr have flushed. Returning instead would let a timer that a\n * package module started keep the process alive after the report.\n *\n * With `--json`, stdout belongs to the report for the whole run: anything\n * else printed, even by a module's timer after loading, goes to stderr. The\n * report goes out through the writer saved before the redirect.\n */\nexport async function exitWithModelCommand(\n json: boolean,\n run: (streams: ModelStreams) => Promise<number>,\n): Promise<never> {\n const writeStdout = process.stdout.write.bind(process.stdout);\n const streams: ModelStreams = json\n ? { out: (text) => void writeStdout(text), err: processStreams.err }\n : processStreams;\n if (json) redirectStdout(processStreams.err);\n const code = await run(streams);\n return await new Promise<never>(() => {\n process.stderr.write(\"\", () => writeStdout(\"\", () => process.exit(code)));\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBA,eAAsB,uBACpB,aACA,MAIA,UAAqD,CAAC,GAC1C;CACZ,MAAM,WAAW,IAAI,kCAAkC;CACvD,MAAM,SAAS,IAAI,uBAAuB,QAAQ;CAClD,MAAM,kBAAkB,iCAAiC;CACzD,IAAI;EACF,MAAM,UAAU,MAAM,uBAAuB;GAC3C;GACA,YAAY,KAAK,aAAa,wBAAwB;GACtD,GAAI,QAAQ,uBAAuB,QAAQ,EAAE,oBAAoB,KAAK;GACtE;GACA,gBAAgB,cAAc,SAAS,gBAAgB,SAAS;EAClE,CAAC;EACD,OAAO,MAAM,KAAK,SAAS,EACzB,eAAe,cACb,SAAS,aAAa;GACpB,aAAa,QAAQ;GACrB;GACA;EACF,CAAC,EACL,CAAC;CACH,UAAU;EACR,MAAM,OAAO,QAAQ;CACvB;AACF;;;ACrCA,MAAM,aAAkD;CACtD,IAAI;CACJ,SAAS;CACT,SAAS;CACT,QAAQ;AACV;AAEA,MAAa,iBAA+B;CAC1C,MAAM,SAAS,KAAK,QAAQ,OAAO,MAAM,IAAI;CAC7C,MAAM,SAAS,KAAK,QAAQ,OAAO,MAAM,IAAI;AAC/C;;AAGA,SAAS,eAAe,OAA2C;CACjE,MAAM,WAAW,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;CACzD,QAAQ,OAAO,UAAU,OAA4B,GAAG,SAAoB;EAC1E,MAAM,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,CAAC;EAEvE,KADsB,MAAM,UAAU,OAAO,UAAU,UAC/C,CAAC,GAAgC;EACzC,OAAO;CACT;CACA,aAAa;EACX,QAAQ,OAAO,QAAQ;CACzB;AACF;;AAGA,eAAe,SACb,OACA,MACY;CACZ,MAAM,UAAU,eAAe,KAAK;CACpC,IAAI;EACF,OAAO,MAAM,KAAK;CACpB,UAAU;EACR,QAAQ;CACV;AACF;;;;;;;AAQA,eAAsB,gBACpB,SASA,SACiB;CACjB,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,cAAc,QAAQ,eAAe,QAAQ,IAAI;CACvD,IAAI;EACF,MAAM,SAAS,MAAM,SAAS,QAAQ,WACpC,uBAAuB,aAAa,QAAQ,IAAI,CAClD;EACA,MAAM,OAAO,QAAQ,OAAO,KAAK,UAAU,MAAM,IAAI,QAAQ,OAAO,MAAM;EAC1E,QAAQ,IAAI,GAAG,KAAK,GAAG;EACvB,OAAO,WAAW,OAAO;CAC3B,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,QAAQ,IAAI,GAAG,QAAQ,KAAK,kBAAkB,QAAQ,GAAG;EACzD,OAAO;CACT;AACF;;;;;;;;;;AAWA,eAAsB,qBACpB,MACA,KACgB;CAChB,MAAM,cAAc,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;CAC5D,MAAM,UAAwB,OAC1B;EAAE,MAAM,SAAS,KAAK,YAAY,IAAI;EAAG,KAAK,eAAe;CAAI,IACjE;CACJ,IAAI,MAAM,eAAe,eAAe,GAAG;CAC3C,MAAM,OAAO,MAAM,IAAI,OAAO;CAC9B,OAAO,MAAM,IAAI,cAAqB;EACpC,QAAQ,OAAO,MAAM,UAAU,YAAY,UAAU,QAAQ,KAAK,IAAI,CAAC,CAAC;CAC1E,CAAC;AACH","debug_id":"66d6833e-9bf6-50d7-896a-8bee425c7813"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"subgraphs-7OYWwP-C.mjs","sources":["../src/services/model/schema-first/sdl-sources.ts","../src/services/model/subgraphs.ts"],"sourcesContent":["import type { SchemaFirstSubgraphSource } from \"document-model/tooling\";\nimport { readFileSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst SDL_FILES: readonly (readonly [\n string,\n SchemaFirstSubgraphSource[\"language\"],\n])[] = [\n [\"schema.graphql\", \"graphql\"],\n [\"schema.ts\", \"typescript\"],\n [\"index.ts\", \"typescript\"],\n];\n\nconst LITERAL_NAME = /\\bname(?:\\s*:\\s*string)?\\s*=\\s*[\"'`]([^\"'`$]+)[\"'`]/;\n\nfunction readText(path: string): string | null {\n if (!(statSync(path, { throwIfNoEntry: false })?.isFile() ?? false)) {\n return null;\n }\n return readFileSync(path, \"utf8\");\n}\n\nexport function schemaFirstSource(\n projectRoot: string,\n dir: string,\n): SchemaFirstSubgraphSource {\n const unit = `./subgraphs/${dir}/` as const;\n const index = readText(join(projectRoot, \"subgraphs\", dir, \"index.ts\"));\n const name = index?.match(LITERAL_NAME)?.[1] ?? null;\n for (const [file, language] of SDL_FILES) {\n const text = readText(join(projectRoot, \"subgraphs\", dir, file));\n if (text !== null) {\n return {\n unit,\n name,\n source: { specifier: `${unit}${file}` },\n language,\n text,\n };\n }\n }\n return {\n unit,\n name,\n source: { specifier: `${unit}index.ts` },\n language: \"typescript\",\n text: null,\n };\n}\n","import { projectSubgraphGraphQL } from \"document-model\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport {\n type ProjectDefinitions,\n readSubgraphDefinitions,\n subgraphCheckInput,\n type SubgraphCheckInput,\n type SubgraphDefinitions,\n type SubgraphHostConflict,\n type SubgraphImportFailure,\n type SubgraphInventoryEntry,\n} from \"document-model/tooling\";\nimport { statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ProjectModules } from \"./project.js\";\nimport { schemaFirstSource } from \"./schema-first/sdl-sources.js\";\nimport { scanSubgraphs, SUBGRAPHS_ENTRY } from \"./subgraph-gate.js\";\n\nconst SCALARS_ENTRY = \"./scalars/index.ts\";\n\n/** A module that hangs on a top-level await must not hang `ph model`. */\nconst IMPORT_TIMEOUT_MS = 60_000;\n\nexport type ProjectSubgraphs = {\n readonly input: SubgraphCheckInput;\n readonly inventory: readonly SubgraphInventoryEntry[];\n};\n\ntype Imported =\n | { readonly ok: true; readonly namespace: object }\n | { readonly ok: false; readonly failure: SubgraphImportFailure };\n\nasync function importModule(\n modules: ProjectModules,\n specifier: `./${string}`,\n packageRoot: string,\n timeoutMs: number,\n): Promise<Imported> {\n let timer: NodeJS.Timeout | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(\n () =>\n reject(\n new Error(\n `it did not finish loading within ${timeoutMs / 1000} seconds`,\n ),\n ),\n timeoutMs,\n );\n timer.unref();\n });\n try {\n return {\n ok: true,\n namespace: await Promise.race([modules.importModule(specifier), timeout]),\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n ok: false,\n failure: { specifier, reason: message.replaceAll(packageRoot, \".\") },\n };\n } finally {\n clearTimeout(timer);\n }\n}\n\n/** The host's admission of the code-first subgraphs, replayed against its built-in subgraphs and the package's document models. */\nasync function replayHostAdmission(\n { subgraphs }: SubgraphDefinitions,\n artifacts: ProjectDefinitions[\"artifacts\"],\n): Promise<readonly SubgraphHostConflict[]> {\n if (subgraphs.length === 0) return [];\n const models = new Map(\n artifacts.map(({ documentType, documentModel }) => [\n documentType,\n documentModel.global,\n ]),\n );\n const { findPackageSubgraphConflicts } =\n await import(\"@powerhousedao/reactor-api/subgraph-types\");\n const { conflicts } = await findPackageSubgraphConflicts(\n subgraphs.map(({ name, definition }) => ({\n name,\n // The host serves the printed projection, parsed again.\n typeDefs: parse(\n print(projectSubgraphGraphQL(definition) as unknown as DocumentNode),\n ),\n })),\n [...models.values()],\n );\n return Array.from(conflicts).flatMap(\n ([subgraph, { nameHeldBy, claims }]): SubgraphHostConflict[] =>\n nameHeldBy === \"package\"\n ? []\n : [\n {\n subgraph,\n ...(nameHeldBy !== undefined && { nameHeldBy }),\n claims,\n },\n ],\n );\n}\n\nconst usesPackageScalars = ({ subgraphs }: SubgraphDefinitions) =>\n subgraphs.some(({ definition }) =>\n definition.scalars.some(({ implementation }) =>\n implementation.startsWith(\"package#\"),\n ),\n );\n\n/**\n * `undefined` when the project has no code-first subgraph: then nothing here\n * imports a module, and projects without one keep the reports they had. A\n * module that fails or outlives `timeoutMs` becomes a diagnostic.\n */\nexport async function readProjectSubgraphs(\n project: Pick<ProjectDefinitions, \"packageRoot\" | \"artifacts\">,\n modules: ProjectModules,\n timeoutMs: number = IMPORT_TIMEOUT_MS,\n): Promise<ProjectSubgraphs | undefined> {\n const root = project.packageRoot;\n const styles = scanSubgraphs(root);\n if (!styles.hasCodeFirst) return undefined;\n const schemaFirst = styles.schemaFirstUnits.map((dir) =>\n schemaFirstSource(root, dir),\n );\n const subgraphs = await importModule(\n modules,\n SUBGRAPHS_ENTRY,\n root,\n timeoutMs,\n );\n if (!subgraphs.ok) {\n return subgraphCheckInput({\n definitions: { subgraphs: [], diagnostics: [] },\n schemaFirst,\n importFailures: [subgraphs.failure],\n });\n }\n const definitions = readSubgraphDefinitions(subgraphs.namespace, {\n specifier: SUBGRAPHS_ENTRY,\n });\n const hostConflicts = await replayHostAdmission(\n definitions,\n project.artifacts,\n );\n if (!usesPackageScalars(definitions)) {\n return subgraphCheckInput({ definitions, schemaFirst, hostConflicts });\n }\n if (\n !(\n statSync(join(root, SCALARS_ENTRY), {\n throwIfNoEntry: false,\n })?.isFile() ?? false\n )\n ) {\n return subgraphCheckInput({\n definitions,\n schemaFirst,\n hostConflicts,\n scalars: null,\n });\n }\n const scalars = await importModule(modules, SCALARS_ENTRY, root, timeoutMs);\n return subgraphCheckInput(\n scalars.ok\n ? { definitions, schemaFirst, hostConflicts, scalars: scalars.namespace }\n : {\n definitions,\n schemaFirst,\n hostConflicts,\n importFailures: [scalars.failure],\n },\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,YAGC;CACL,CAAC,kBAAkB,SAAS;CAC5B,CAAC,aAAa,YAAY;CAC1B,CAAC,YAAY,YAAY;AAC3B;AAEA,MAAM,eAAe;AAErB,SAAS,SAAS,MAA6B;CAC7C,IAAI,EAAE,S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AM,aAAa,GAAG,EAClC,gBAAgB,MAClB,CAAC,CAAC,EAAE,OAAO,KAAK,QAGlB,OAAO,mBAAmB;EACxB;EACA;EACA;EACA,SAAS;CACX,CAAC;CAEH,MAAM,UAAU,MAAM,aAAa,SAAS,eAAe,MAAM,SAAS;CAC1E,OAAO,mBACL,QAAQ,KACJ;EAAE;EAAa;EAAa;EAAe,SAAS,QAAQ;CAAU,IACtE;EACE;EACA;EACA;EACA,gBAAgB,CAAC,QAAQ,OAAO;CAClC,CACN;AACF","debug_id":"1d9c1c84-45e5-55d7-970d-52f2a0d6a487"}
@@ -1,4 +0,0 @@
1
- import { c as vetraGateway } from "./vetra-gateway-BHuz7pvS.mjs";
2
- export { vetraGateway };
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f734f1fd-bdbd-56f6-bc8e-267e364dce34")}catch(e){}}();
4
- //# debugId=f734f1fd-bdbd-56f6-bc8e-267e364dce34