@powerhousedao/ph-cli 6.2.3-dev.7 → 6.2.3-dev.71

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-AR3VxAIk.mjs → auth-BFUq7CvE.mjs} +3 -3
  2. package/dist/{auth-AR3VxAIk.mjs.map → auth-BFUq7CvE.mjs.map} +1 -1
  3. package/dist/auth-CNhbN5UM.mjs +4 -0
  4. package/dist/build-C78yPntL.mjs +4 -0
  5. package/dist/build-Dj8qfSSe.mjs +349 -0
  6. package/dist/build-Dj8qfSSe.mjs.map +1 -0
  7. package/dist/{cli-connect-override-D3hh4aH_.mjs → cli-connect-override-CEJhQWRX.mjs} +39 -27
  8. package/dist/cli-connect-override-CEJhQWRX.mjs.map +1 -0
  9. package/dist/cli.d.mts +2 -1
  10. package/dist/cli.mjs +31 -1175
  11. package/dist/cli.mjs.map +1 -1
  12. package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs +2459 -0
  13. package/dist/compound-B6RZMA0Y-Cv3XMQ3Y.mjs.map +1 -0
  14. package/dist/connect-build-BfhOGbha.mjs +253 -0
  15. package/dist/connect-build-BfhOGbha.mjs.map +1 -0
  16. package/dist/{connect-config-BWGiW3IB.mjs → connect-config-DblqJgxR.mjs} +19 -12
  17. package/dist/connect-config-DblqJgxR.mjs.map +1 -0
  18. package/dist/connect-plugin-configs-D2fwYpMw.mjs +50 -0
  19. package/dist/connect-plugin-configs-D2fwYpMw.mjs.map +1 -0
  20. package/dist/connect-preview-8-qLgWKt.mjs +215 -0
  21. package/dist/connect-preview-8-qLgWKt.mjs.map +1 -0
  22. package/dist/{connect-studio-D6rfWCNB.mjs → connect-studio-DX7r4iyI.mjs} +18 -11
  23. package/dist/connect-studio-DX7r4iyI.mjs.map +1 -0
  24. package/dist/connect-studio-DmjcV8I2.mjs +4 -0
  25. package/dist/dist-CCLkwpTS.mjs +313 -0
  26. package/dist/dist-CCLkwpTS.mjs.map +1 -0
  27. package/dist/explain-DUXbB9jf.mjs +241 -0
  28. package/dist/explain-DUXbB9jf.mjs.map +1 -0
  29. package/dist/feature-flags-xwqcHEWC.mjs +4 -0
  30. package/dist/{generate-all-DrT4ZxHX.mjs → generate-all-Dgyy_kT-.mjs} +9 -3
  31. package/dist/generate-all-Dgyy_kT-.mjs.map +1 -0
  32. package/dist/{generate-app-DNNqA-H3.mjs → generate-app-BTs1u-9l.mjs} +7 -5
  33. package/dist/{generate-app-DNNqA-H3.mjs.map → generate-app-BTs1u-9l.mjs.map} +1 -1
  34. package/dist/generate-desktop-shell-Bj_3bJDL.mjs +317 -0
  35. package/dist/generate-desktop-shell-Bj_3bJDL.mjs.map +1 -0
  36. package/dist/{generate-document-model-BJXyODfm.mjs → generate-document-model-BfFIQ35q.mjs} +19 -7
  37. package/dist/generate-document-model-BfFIQ35q.mjs.map +1 -0
  38. package/dist/{generate-editor-BejvaVVT.mjs → generate-editor-CW7Do69u.mjs} +7 -5
  39. package/dist/{generate-editor-BejvaVVT.mjs.map → generate-editor-CW7Do69u.mjs.map} +1 -1
  40. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  41. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  42. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  43. package/dist/generate-piece-QTt-ddt2.mjs +65 -0
  44. package/dist/generate-piece-QTt-ddt2.mjs.map +1 -0
  45. package/dist/generate-piece-action-DbxrzfKY.mjs +29 -0
  46. package/dist/generate-piece-action-DbxrzfKY.mjs.map +1 -0
  47. package/dist/generate-piece-trigger-CqVOcL9g.mjs +30 -0
  48. package/dist/generate-piece-trigger-CqVOcL9g.mjs.map +1 -0
  49. package/dist/{generate-processor-_WOx-mMe.mjs → generate-processor-DBtTkgo5.mjs} +15 -8
  50. package/dist/generate-processor-DBtTkgo5.mjs.map +1 -0
  51. package/dist/{generate-subgraph-BsHUstpl.mjs → generate-subgraph-CVlTo7qk.mjs} +12 -6
  52. package/dist/generate-subgraph-CVlTo7qk.mjs.map +1 -0
  53. package/dist/index-BIbx17vt.d.mts +4459 -0
  54. package/dist/index-BIbx17vt.d.mts.map +1 -0
  55. package/dist/{init-BZP6gvYd.mjs → init-ScuT3z7P.mjs} +7 -5
  56. package/dist/init-ScuT3z7P.mjs.map +1 -0
  57. package/dist/{inspect-DXjbQEV_.mjs → inspect-zWJnBDMJ.mjs} +11 -4
  58. package/dist/inspect-zWJnBDMJ.mjs.map +1 -0
  59. package/dist/install-added-dependencies-DVSbzler.mjs +33 -0
  60. package/dist/install-added-dependencies-DVSbzler.mjs.map +1 -0
  61. package/dist/{migrate-jGKfE02L.mjs → migrate-DK4HK7Dn.mjs} +4 -4
  62. package/dist/{migrate-jGKfE02L.mjs.map → migrate-DK4HK7Dn.mjs.map} +1 -1
  63. package/dist/ph-cli-commands-BhzvcuzR.mjs +4 -0
  64. package/dist/ph-cli-commands-pyxDifSE.mjs +1493 -0
  65. package/dist/ph-cli-commands-pyxDifSE.mjs.map +1 -0
  66. package/dist/precompress-P6cJDPVC.mjs +77 -0
  67. package/dist/precompress-P6cJDPVC.mjs.map +1 -0
  68. package/dist/{registry-auth-DxEWCJu2.mjs → registry-auth-Bm5AR-fB.mjs} +4 -4
  69. package/dist/{registry-auth-DxEWCJu2.mjs.map → registry-auth-Bm5AR-fB.mjs.map} +1 -1
  70. package/dist/run-sugar-Ns53R6lU.mjs +39 -0
  71. package/dist/run-sugar-Ns53R6lU.mjs.map +1 -0
  72. package/dist/runners/connect.d.mts +1173 -0
  73. package/dist/runners/connect.d.mts.map +1 -0
  74. package/dist/runners/connect.mjs +270 -0
  75. package/dist/runners/connect.mjs.map +1 -0
  76. package/dist/runners/switchboard.d.mts +340 -0
  77. package/dist/runners/switchboard.d.mts.map +1 -0
  78. package/dist/runners/switchboard.mjs +294 -0
  79. package/dist/runners/switchboard.mjs.map +1 -0
  80. package/dist/schemas-D5N5U_Mf.mjs +5738 -0
  81. package/dist/schemas-D5N5U_Mf.mjs.map +1 -0
  82. package/dist/scripts/emit-runner-schemas.ts +24 -0
  83. package/dist/scripts/generate-commands-docs.ts +8 -0
  84. package/dist/scripts/manage-environment +0 -0
  85. package/dist/scripts/setup.sh +0 -0
  86. package/dist/start-run-BIaYSpHh.mjs +124 -0
  87. package/dist/start-run-BIaYSpHh.mjs.map +1 -0
  88. package/dist/superseded-config-CbSTFun2.mjs +53 -0
  89. package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
  90. package/dist/switchboard-C5zgkRl2.mjs +4 -0
  91. package/dist/switchboard-h4-XgP1h.mjs +129 -0
  92. package/dist/switchboard-h4-XgP1h.mjs.map +1 -0
  93. package/dist/{switchboard-migrate-NQ7LHWSi.mjs → switchboard-migrate-7JQZM7-5.mjs} +5 -4
  94. package/dist/{switchboard-migrate-NQ7LHWSi.mjs.map → switchboard-migrate-7JQZM7-5.mjs.map} +1 -1
  95. package/dist/{switchboard-reset-BcQXlcVf.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
  96. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  97. package/dist/{utils-C4isxXSO.mjs → utils-9KyRM0mf.mjs} +6 -34
  98. package/dist/{utils-C4isxXSO.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
  99. package/dist/utils-DAux4Ga7.mjs +4 -0
  100. package/dist/{vetra-DkF6EJMY.mjs → vetra-CnrGDPX0.mjs} +70 -35
  101. package/dist/vetra-CnrGDPX0.mjs.map +1 -0
  102. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
  103. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  104. package/package.json +39 -18
  105. package/dist/auth-BNkN6kS9.mjs +0 -4
  106. package/dist/build-C-A5-ipO.mjs +0 -4
  107. package/dist/build-uQXq6_HU.mjs +0 -71
  108. package/dist/build-uQXq6_HU.mjs.map +0 -1
  109. package/dist/cli-connect-override-D3hh4aH_.mjs.map +0 -1
  110. package/dist/connect-build-WL4axo4z.mjs +0 -43
  111. package/dist/connect-build-WL4axo4z.mjs.map +0 -1
  112. package/dist/connect-config-BWGiW3IB.mjs.map +0 -1
  113. package/dist/connect-preview-D7ypzFDc.mjs +0 -28
  114. package/dist/connect-preview-D7ypzFDc.mjs.map +0 -1
  115. package/dist/connect-studio-BIQzyq5B.mjs +0 -5
  116. package/dist/connect-studio-D6rfWCNB.mjs.map +0 -1
  117. package/dist/generate-all-DrT4ZxHX.mjs.map +0 -1
  118. package/dist/generate-document-model-BJXyODfm.mjs.map +0 -1
  119. package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
  120. package/dist/generate-subgraph-BsHUstpl.mjs.map +0 -1
  121. package/dist/init-BZP6gvYd.mjs.map +0 -1
  122. package/dist/inspect-DXjbQEV_.mjs.map +0 -1
  123. package/dist/switchboard-CJMoMzWx.mjs +0 -75
  124. package/dist/switchboard-CJMoMzWx.mjs.map +0 -1
  125. package/dist/switchboard-iRFugh8I.mjs +0 -4
  126. package/dist/switchboard-reset-BcQXlcVf.mjs.map +0 -1
  127. package/dist/utils-BzwczAW-.mjs +0 -4
  128. package/dist/vetra-DkF6EJMY.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils-C4isxXSO.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path, { dirname } from \"node:path\";\nexport const POWERHOUSE_CONFIG_FILE = \"powerhouse.config.json\";\nexport const POWERHOUSE_GLOBAL_DIR = path.join(homedir(), \".ph\");\nexport const SUPPORTED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"];\n\nexport const packageManagers = {\n bun: {\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n installCommand: \"bun add {{dependency}}\",\n uninstallCommand: \"bun remove {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"bun.lock\",\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n },\n pnpm: {\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n installCommand: \"pnpm add {{dependency}}\",\n uninstallCommand: \"pnpm remove {{dependency}}\",\n workspaceOption: \"--workspace-root\",\n lockfile: \"pnpm-lock.yaml\",\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n },\n yarn: {\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n installCommand: \"yarn add {{dependency}}\",\n uninstallCommand: \"yarn remove {{dependency}}\",\n workspaceOption: \"-W\",\n lockfile: \"yarn.lock\",\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n uninstallCommand: \"npm uninstall {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n },\n};\n\ntype PathValidation = (dir: string) => boolean;\n\nexport type PackageManager = \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\nexport type ProjectInfo = {\n isGlobal: boolean;\n path: string;\n packageManager: PackageManager;\n};\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return fs.existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getProjectInfo(debug?: boolean): ProjectInfo {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n return {\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n packageManager: getPackageManagerFromLockfile(POWERHOUSE_GLOBAL_DIR),\n };\n }\n\n return {\n isGlobal: false,\n path: projectPath,\n packageManager: getPackageManagerFromLockfile(projectPath),\n };\n}\n\n/**\n * Generates a unique drive ID based on the project path.\n * The same project path will always generate the same ID.\n * @param name - The name prefix for the drive ID (e.g., \"vetra\", \"powerhouse\")\n * @returns A unique drive ID in the format \"{name}-{hash}\"\n */\nexport function generateProjectDriveId(name: string): string {\n const projectInfo = getProjectInfo();\n const hash = crypto\n .createHash(\"sha256\")\n .update(projectInfo.path)\n .digest(\"hex\");\n const shortHash = hash.substring(0, 8);\n return `${name}-${shortHash}`;\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport function updatePackagesArray(\n currentPackages: PowerhouseConfig[\"packages\"] = [],\n dependencies: { name: string; version: string | undefined }[],\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n): PowerhouseConfig[\"packages\"] {\n const isInstall = task === \"install\";\n const mappedPackages = dependencies.map((dep) => ({\n packageName: dep.name,\n version: dep.version,\n provider,\n }));\n\n if (isInstall) {\n // Overwrite existing package if version is different\n const filteredPackages = currentPackages.filter(\n (pkg) => !dependencies.find((dep) => dep.name === pkg.packageName),\n );\n return [...filteredPackages, ...mappedPackages];\n }\n\n return currentPackages.filter(\n (pkg) => !dependencies.map((dep) => dep.name).includes(pkg.packageName),\n );\n}\n\n// Modify updateConfigFile to use the new function\nexport function updateConfigFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n registryUrl?: string,\n registryUrlExplicit = false,\n) {\n const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);\n\n if (!fs.existsSync(configPath)) {\n throw new Error(\n `powerhouse.config.json file not found. projectPath: ${projectPath}`,\n );\n }\n\n const config = JSON.parse(\n fs.readFileSync(configPath, \"utf-8\"),\n ) as PowerhouseConfig;\n\n const updatedConfig: PowerhouseConfig = {\n ...config,\n packages: updatePackagesArray(\n config.packages,\n dependencies,\n task,\n provider,\n ),\n };\n\n if (\n task === \"install\" &&\n registryUrl &&\n (registryUrlExplicit || !config.packageRegistryUrl) &&\n dependencies.length > 0\n ) {\n updatedConfig.packageRegistryUrl = registryUrl;\n }\n\n fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (fs.existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n\n/**\n * Updates the styles.css file to include imports for newly installed packages\n * @param dependencies - Array of dependencies that were installed\n * @param projectPath - Path to the project root\n */\nexport function updateStylesFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const fullCssPath = path.join(projectPath, cssPath);\n const importStatement = `@import '${cssPath}';`;\n\n // Check if the CSS file exists\n if (!fs.existsSync(fullCssPath)) {\n console.warn(`⚠️ Warning: CSS file not found at ${cssPath}`);\n continue;\n }\n\n // Check if import already exists\n if (currentStyles.includes(importStatement)) {\n continue;\n }\n\n // Find the last @import statement\n const importLines = currentStyles\n .split(\"\\n\")\n .filter((line) => line.trim().startsWith(\"@import\"));\n const lastImport = importLines[importLines.length - 1];\n\n if (lastImport) {\n // Insert new import after the last existing import\n updatedStyles = currentStyles.replace(\n lastImport,\n `${lastImport}\\n${importStatement}`,\n );\n } else {\n // If no imports exist, add at the top of the file\n updatedStyles = `${importStatement}\\n${currentStyles}`;\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n\n/**\n * Removes CSS imports for uninstalled packages from styles.css\n */\nexport function removeStylesImports(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const importStatement = `@import '${cssPath}';`;\n\n // Remove the import line if it exists\n const lines = updatedStyles.split(\"\\n\");\n const filteredLines = lines.filter(\n (line) => !line.trim().includes(importStatement),\n );\n\n if (filteredLines.length !== lines.length) {\n updatedStyles = filteredLines.join(\"\\n\");\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAKA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,SAAS,EAAE,MAAM;AAGhE,MAAa,kBAAkB;CAC7B,KAAK;EACH,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,KAAK;EACH,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACF;AAYD,SAAgB,wBAAwB;AACtC,QAAO;;AAGT,SAAgB,oBAAoB,KAAa;CAC/C,MAAM,uBAAuB,KAAK,KAAK,KAAK,uBAAuB;AAEnE,QAAO,GAAG,WAAW,qBAAqB;;AAG5C,SAAgB,oBACd,KACA,iBAAiC,uBACjC;CACA,MAAM,kBAAkB,KAAK,KAAK,KAAK,eAAe;AAEtD,KAAI,GAAG,WAAW,gBAAgB,IAAI,eAAe,IAAI,CACvD,QAAO;CAGT,MAAM,YAAY,QAAQ,IAAI;AAE9B,KAAI,cAAc,IAChB,QAAO;AAGT,QAAO,oBAAoB,WAAW,eAAe;;AAGvD,SAAgB,eAAe,OAA8B;CAC3D,MAAM,cAAc,QAAQ,KAAK;AAEjC,KAAI,MACF,SAAQ,IAAI,mBAAmB,YAAY;CAG7C,MAAM,cAAc,oBAAoB,aAAa,oBAAoB;AAEzE,KAAI,CAAC,YACH,QAA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AAQ;CAC1D,IAAI,gBAAgB;AAEpB,MAAK,MAAM,OAAO,cAAc;EAE9B,MAAM,kBAAkB,YADR,kBAAkB,IAAI,KAAK,iBACC;EAG5C,MAAM,QAAQ,cAAc,MAAM,KAAK;EACvC,MAAM,gBAAgB,MAAM,QACzB,SAAS,CAAC,KAAK,MAAM,CAAC,SAAS,gBAAgB,CACjD;AAED,MAAI,cAAc,WAAW,MAAM,OACjC,iBAAgB,cAAc,KAAK,KAAK;;AAK5C,KAAI,kBAAkB,cACpB,IAAG,cAAc,YAAY,cAAc","debug_id":"73159d3c-22a7-5dc6-8bd4-7b15f3b94c79"}
1
+ {"version":3,"file":"utils-9KyRM0mf.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path, { dirname } from \"node:path\";\nexport const POWERHOUSE_CONFIG_FILE = \"powerhouse.config.json\";\nexport const POWERHOUSE_GLOBAL_DIR = path.join(homedir(), \".ph\");\nexport const SUPPORTED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"];\n\nexport const packageManagers = {\n bun: {\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n installCommand: \"bun add {{dependency}}\",\n uninstallCommand: \"bun remove {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"bun.lock\",\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n },\n pnpm: {\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n installCommand: \"pnpm add {{dependency}}\",\n uninstallCommand: \"pnpm remove {{dependency}}\",\n workspaceOption: \"--workspace-root\",\n lockfile: \"pnpm-lock.yaml\",\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n },\n yarn: {\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n installCommand: \"yarn add {{dependency}}\",\n uninstallCommand: \"yarn remove {{dependency}}\",\n workspaceOption: \"-W\",\n lockfile: \"yarn.lock\",\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n uninstallCommand: \"npm uninstall {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n },\n};\n\ntype PathValidation = (dir: string) => boolean;\n\nexport type PackageManager = \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\nexport type ProjectInfo = {\n isGlobal: boolean;\n path: string;\n packageManager: PackageManager;\n};\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return fs.existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getProjectInfo(debug?: boolean): ProjectInfo {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n return {\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n packageManager: getPackageManagerFromLockfile(POWERHOUSE_GLOBAL_DIR),\n };\n }\n\n return {\n isGlobal: false,\n path: projectPath,\n packageManager: getPackageManagerFromLockfile(projectPath),\n };\n}\n\n/**\n * Generates a unique drive ID based on the project path.\n * The same project path will always generate the same ID.\n * @param name - The name prefix for the drive ID (e.g., \"vetra\", \"powerhouse\")\n * @returns A unique drive ID in the format \"{name}-{hash}\"\n */\nexport function generateProjectDriveId(name: string): string {\n const projectInfo = getProjectInfo();\n const hash = crypto\n .createHash(\"sha256\")\n .update(projectInfo.path)\n .digest(\"hex\");\n const shortHash = hash.substring(0, 8);\n return `${name}-${shortHash}`;\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport function updatePackagesArray(\n currentPackages: PowerhouseConfig[\"packages\"] = [],\n dependencies: { name: string; version: string | undefined }[],\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n): PowerhouseConfig[\"packages\"] {\n const isInstall = task === \"install\";\n const mappedPackages = dependencies.map((dep) => ({\n packageName: dep.name,\n version: dep.version,\n provider,\n }));\n\n if (isInstall) {\n // Overwrite existing package if version is different\n const filteredPackages = currentPackages.filter(\n (pkg) => !dependencies.find((dep) => dep.name === pkg.packageName),\n );\n return [...filteredPackages, ...mappedPackages];\n }\n\n return currentPackages.filter(\n (pkg) => !dependencies.map((dep) => dep.name).includes(pkg.packageName),\n );\n}\n\n// Modify updateConfigFile to use the new function\nexport function updateConfigFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n registryUrl?: string,\n registryUrlExplicit = false,\n) {\n const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);\n\n if (!fs.existsSync(configPath)) {\n throw new Error(\n `powerhouse.config.json file not found. projectPath: ${projectPath}`,\n );\n }\n\n const config = JSON.parse(\n fs.readFileSync(configPath, \"utf-8\"),\n ) as PowerhouseConfig;\n\n const updatedConfig: PowerhouseConfig = {\n ...config,\n packages: updatePackagesArray(\n config.packages,\n dependencies,\n task,\n provider,\n ),\n };\n\n if (\n task === \"install\" &&\n registryUrl &&\n (registryUrlExplicit || !config.packageRegistryUrl) &&\n dependencies.length > 0\n ) {\n updatedConfig.packageRegistryUrl = registryUrl;\n }\n\n fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (fs.existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n\n/**\n * Removes the CSS imports `ph install --local` used to add to style.css for\n * uninstalled packages; Connect now loads a bundled package's CSS with its code.\n */\nexport function removeStylesImports(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const importStatement = `@import '${cssPath}';`;\n\n // Remove the import line if it exists\n const lines = updatedStyles.split(\"\\n\");\n const filteredLines = lines.filter(\n (line) => !line.trim().includes(importStatement),\n );\n\n if (filteredLines.length !== lines.length) {\n updatedStyles = filteredLines.join(\"\\n\");\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAKA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,QAAQ,GAAG,KAAK;AAG/D,MAAa,kBAAkB;CAC7B,KAAK;EACH,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;CACA,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;CACA,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;CACA,KAAK;EACH,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;AACF;AAYA,SAAgB,wBAAwB;CACtC,OAAO;AACT;AAEA,SAAgB,oBAAoB,KAAa;CAC/C,MAAM,uBAAuB,KAAK,KAAK,KAAK,sBAAsB;CAElE,OAAO,GAAG,WAAW,oBAAoB;AAC3C;AAEA,SAAgB,oBACd,KACA,iBAAiC,uBACjC;CACA,MAAM,kBAAkB,KAAK,KAAK,KAAK,cAAc;CAErD,IAAI,GAAG,WAAW,eAAe,KAAK,eAAe,GAAG,GACtD,OAAO;CAGT,MAAM,YAAY,QAAQ,GAAG;CAE7B,IAAI,cAAc,KAChB,OAAO;CAGT,OAAO,oBAAoB,WAAW,cAAc;AACtD;AAEA,SAAgB,eAAe,OAA8B;CAC3D,MAAM,cAAc,QAAQ,IAAI;CAEhC,IAAI,OACF,QAAQ,IAAI,mBAAmB,WAAW;CAG5C,MAAM,cAAc,oBAAoB,aAAa,mB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AAW,UAAU,GAC3B,MAAM,IAAI,MACR,uDAAuD,aACzD;CAGF,MAAM,SAAS,KAAK,MAClB,GAAG,aAAa,YAAY,OAAO,CACrC;CAEA,MAAM,gBAAkC;EACtC,GAAG;EACH,UAAU,oBACR,OAAO,UACP,cACA,MACA,QACF;CACF;CAEA,IACE,SAAS,aACT,gBACC,uBAAuB,CAAC,OAAO,uBAChC,aAAa,SAAS,GAEtB,cAAc,qBAAqB;CAGrC,GAAG,cAAc,YAAY,KAAK,UAAU,eAAe,MAAM,CAAC,CAAC;AACrE;;;;;AA0CA,SAAgB,oBACd,cACA,aACA;CACA,MAAM,aAAa,KAAK,KAAK,aAAa,WAAW;CAGrD,IAAI,CAAC,GAAG,WAAW,UAAU,GAAG;EAC9B,QAAQ,KAAK,sDAAsD;EACnE;CACF;CAEA,MAAM,gBAAgB,GAAG,aAAa,YAAY,OAAO;CACzD,IAAI,gBAAgB;CAEpB,KAAK,MAAM,OAAO,cAAc;EAE9B,MAAM,kBAAkB,YAAY,kBADF,IAAI,KAAK,iBACC;EAG5C,MAAM,QAAQ,cAAc,MAAM,IAAI;EACtC,MAAM,gBAAgB,MAAM,QACzB,SAAS,CAAC,KAAK,KAAK,CAAC,CAAC,SAAS,eAAe,CACjD;EAEA,IAAI,cAAc,WAAW,MAAM,QACjC,gBAAgB,cAAc,KAAK,IAAI;CAE3C;CAGA,IAAI,kBAAkB,eACpB,GAAG,cAAc,YAAY,aAAa;AAE9C","debug_id":"e3fbf59a-7996-5c5c-9db7-c8d207b68849"}
@@ -0,0 +1,4 @@
1
+ import { a as generateProjectDriveId, d as updateConfigFile, u as removeStylesImports } from "./utils-9KyRM0mf.mjs";
2
+ export { generateProjectDriveId, removeStylesImports, updateConfigFile };
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]="7c1a1a3f-92dd-5f1b-bad9-e92f9f6be654")}catch(e){}}();
4
+ //# debugId=7c1a1a3f-92dd-5f1b-bad9-e92f9f6be654
@@ -1,13 +1,16 @@
1
1
 
2
- !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]="0be7e354-5024-5332-aa33-5bc37e651ed4")}catch(e){}}();
3
- import { a as parseDefaultDrivesUrl } from "./cli-connect-override-D3hh4aH_.mjs";
4
- import { t as runConnectStudio } from "./connect-studio-D6rfWCNB.mjs";
5
- import { a as generateProjectDriveId } from "./utils-C4isxXSO.mjs";
6
- import { n as startSwitchboard$1 } from "./switchboard-CJMoMzWx.mjs";
2
+ !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]="bd7945b3-cb7b-5147-93ad-9fd89f126138")}catch(e){}}();
3
+ import { i as mergeDefaultDrives, u as rebaseDriveUrl } from "./dist-CCLkwpTS.mjs";
4
+ import { a as parseDefaultDrivesUrl, i as wasFlagExplicitlyPassed } from "./cli-connect-override-CEJhQWRX.mjs";
5
+ import { t as runConnectStudio } from "./connect-studio-DX7r4iyI.mjs";
6
+ import { a as generateProjectDriveId } from "./utils-9KyRM0mf.mjs";
7
+ import { i as POWERHOUSE_DRIVE_ICON, r as startSwitchboard$1 } from "./switchboard-h4-XgP1h.mjs";
8
+ import fs from "node:fs";
9
+ import path, { join } from "node:path";
7
10
  import { execSync } from "node:child_process";
8
11
  import { blue, green, red, yellow } from "colorette";
9
- import fs from "node:fs";
10
- import path from "node:path";
12
+ import { getConfig } from "@powerhousedao/shared/clis";
13
+ import { resolvePhDir } from "@powerhousedao/shared/clis/ph-dir";
11
14
  import { createLogger } from "vite";
12
15
  import { createVetraDocument, getVetraDocuments, setPackageGithubUrl } from "@powerhousedao/common/utils";
13
16
  import { isPortAvailable } from "@powerhousedao/switchboard/server";
@@ -255,9 +258,8 @@ async function resolveSwitchboardPort(requested) {
255
258
  }
256
259
  //#endregion
257
260
  //#region src/utils/vetra-runtime.ts
258
- const RECORD_REL = path.join(".ph", "vetra-runtime.json");
259
261
  const READY_TIMEOUT_MS = 2e3;
260
- const recordPath = (projectDir) => path.join(projectDir, RECORD_REL);
262
+ const recordPath = (projectDir) => path.join(resolvePhDir(projectDir), "vetra-runtime.json");
261
263
  function readVetraRuntime(projectDir) {
262
264
  try {
263
265
  return JSON.parse(fs.readFileSync(recordPath(projectDir), "utf8"));
@@ -355,20 +357,6 @@ function syncMcpPort(projectDir, port) {
355
357
  const VETRA_DRIVE_NAME = "vetra";
356
358
  const getDefaultVetraUrl = (port) => `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;
357
359
  const getDriveId = (driveUrl) => driveUrl?.split("/").pop() ?? generateProjectDriveId(VETRA_DRIVE_NAME);
358
- const rebaseDriveUrl = (driveUrl, publicBase) => {
359
- let url;
360
- try {
361
- url = new URL(driveUrl);
362
- } catch {
363
- return driveUrl;
364
- }
365
- if (![
366
- "localhost",
367
- "127.0.0.1",
368
- "[::1]"
369
- ].includes(url.hostname)) return driveUrl;
370
- return `${publicBase.replace(/\/+$/, "")}${url.pathname}`;
371
- };
372
360
  function createViteLogger(color) {
373
361
  const customLogger = createLogger("info");
374
362
  const loggerInfo = customLogger.info.bind(customLogger);
@@ -396,7 +384,7 @@ async function startVetraPreviewDrive(reactor, port, verbose) {
396
384
  slug: previewDriveId,
397
385
  global: {
398
386
  name: "Vetra Preview",
399
- icon: "https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreifddkbopiyvcirf7vaqar74th424r5phlxkdxniirdyg3qgu2ajha",
387
+ icon: POWERHOUSE_DRIVE_ICON,
400
388
  nodes: []
401
389
  },
402
390
  local: {
@@ -406,8 +394,25 @@ async function startVetraPreviewDrive(reactor, port, verbose) {
406
394
  triggers: []
407
395
  }
408
396
  }, port);
409
- if (verbose) console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));
410
- return driveUrl;
397
+ if (verbose && driveUrl) console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));
398
+ return driveUrl ?? null;
399
+ }
400
+ async function seedWorkflowsDrive(reactor, port, verbose) {
401
+ const workflowsDrive = {
402
+ id: generateProjectDriveId("workflows"),
403
+ slug: "workflows",
404
+ global: { name: "Workflows" },
405
+ preferredEditor: "workflow-studio",
406
+ local: {
407
+ availableOffline: true,
408
+ listeners: [],
409
+ sharingType: "public",
410
+ triggers: []
411
+ }
412
+ };
413
+ const driveUrl = await addDefaultDrive(reactor, workflowsDrive, port);
414
+ if (verbose && driveUrl) console.log(blue(`Vetra Switchboard: Workflows drive: ${driveUrl}`));
415
+ return driveUrl ?? null;
411
416
  }
412
417
  async function startLocalVetraSwitchboard(args, logger) {
413
418
  const { connectPort, switchboardPort, dev, packages, disableLocalPackages, debug, httpsKeyFile, httpsCertFile, remoteDrive, interactive, watch, verbose } = args;
@@ -454,6 +459,12 @@ async function startLocalVetraSwitchboard(args, logger) {
454
459
  } catch (error) {
455
460
  console.error(error);
456
461
  }
462
+ let workflowsDriveUrl = null;
463
+ if (switchboard.workflowsEnabled) try {
464
+ workflowsDriveUrl = await seedWorkflowsDrive(switchboard.reactor, actualSwitchboardPort, verbose);
465
+ } catch (error) {
466
+ console.error(error);
467
+ }
457
468
  if (verbose) {
458
469
  console.log(blue(`Vetra Switchboard: Started successfully`));
459
470
  if (remoteDrive) console.log(blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`));
@@ -462,10 +473,12 @@ async function startLocalVetraSwitchboard(args, logger) {
462
473
  console.log(blue(`Vetra Switchboard: http://localhost:${actualSwitchboardPort}/graphql`));
463
474
  console.log(blue(` ➜ Drive URL: ${switchboard.defaultDriveUrl}`));
464
475
  if (previewDriveUrl) console.log(blue(` ➜ Preview Drive URL: ${previewDriveUrl}`));
476
+ if (workflowsDriveUrl) console.log(blue(` ➜ Workflows Drive URL: ${workflowsDriveUrl}`));
465
477
  }
466
478
  return {
467
479
  driveUrl: switchboard.defaultDriveUrl || "",
468
480
  previewDriveUrl,
481
+ workflowsDriveUrl,
469
482
  switchboardPort: actualSwitchboardPort
470
483
  };
471
484
  } catch (error) {
@@ -511,6 +524,7 @@ async function startVetra(args) {
511
524
  }, switchboardLogger);
512
525
  const driveUrl = switchboardResult.driveUrl || remoteDrive || "";
513
526
  const previewDriveUrl = switchboardResult.previewDriveUrl;
527
+ const workflowsDriveUrl = switchboardResult.workflowsDriveUrl;
514
528
  const actualSwitchboardPort = switchboardResult.switchboardPort;
515
529
  writeVetraRuntime(projectDir, {
516
530
  pid: process.pid,
@@ -539,19 +553,40 @@ async function startVetra(args) {
539
553
  }
540
554
  if (verbose) console.log("Starting Codegen Reactor...");
541
555
  if (!disableConnect) {
556
+ const publicBase = args.drivesPublicBase;
557
+ const browserDriveUrl = publicBase ? rebaseDriveUrl(driveUrl, publicBase) : driveUrl;
558
+ const browserPreviewDriveUrl = previewDriveUrl && publicBase ? rebaseDriveUrl(previewDriveUrl, publicBase) : previewDriveUrl;
559
+ const browserWorkflowsDriveUrl = workflowsDriveUrl && publicBase ? rebaseDriveUrl(workflowsDriveUrl, publicBase) : workflowsDriveUrl;
560
+ const vetraDriveEntries = [
561
+ ...browserDriveUrl ? [{
562
+ url: browserDriveUrl,
563
+ name: null,
564
+ icon: null
565
+ }] : [],
566
+ ...browserPreviewDriveUrl ? [{
567
+ url: browserPreviewDriveUrl,
568
+ name: null,
569
+ icon: null
570
+ }] : [],
571
+ ...browserWorkflowsDriveUrl ? [{
572
+ url: browserWorkflowsDriveUrl,
573
+ name: null,
574
+ icon: null
575
+ }] : []
576
+ ];
577
+ const configuredDefaultDrives = getConfig(join(projectDir, "powerhouse.config.json")).connect?.drives?.defaultDrives ?? [];
578
+ const resolvedDefaultDrives = mergeDefaultDrives(vetraDriveEntries, configuredDefaultDrives);
542
579
  if (verbose) {
543
580
  console.log("Starting Connect...");
544
- const drives = previewDriveUrl ? `${driveUrl}, ${previewDriveUrl}` : driveUrl;
545
- console.log(` ➜ Connect will use drives: ${drives}`);
581
+ const flagDefaultDrives = wasFlagExplicitlyPassed("default-drives-url") ? parseDefaultDrivesUrl(args.defaultDrivesUrl ?? "") : [];
582
+ const printedDefaultDrives = mergeDefaultDrives(resolvedDefaultDrives, flagDefaultDrives);
583
+ console.log(` ➜ Connect will use default drives: ${printedDefaultDrives.map((d) => "url" in d ? d.url : `local:${d.id}`).join(", ")}`);
546
584
  }
547
585
  console.log();
548
586
  console.log(green(`Vetra Connect: http://localhost:${connectPort}`));
549
587
  const customViteLogger = createViteLogger(green);
550
- const publicBase = args.drivesPublicBase;
551
- const browserDriveUrl = publicBase ? rebaseDriveUrl(driveUrl, publicBase) : driveUrl;
552
- const browserPreviewDriveUrl = previewDriveUrl && publicBase ? rebaseDriveUrl(previewDriveUrl, publicBase) : previewDriveUrl;
553
588
  const vetraDrivesOverride = { drives: {
554
- defaultDrives: parseDefaultDrivesUrl(browserPreviewDriveUrl ? [browserDriveUrl, browserPreviewDriveUrl].join(",") : browserDriveUrl),
589
+ defaultDrives: resolvedDefaultDrives,
555
590
  preserveStrategy: "preserve-all"
556
591
  } };
557
592
  await runConnectStudio({
@@ -573,7 +608,7 @@ async function startVetra(args) {
573
608
  }
574
609
  }
575
610
  //#endregion
576
- export { startVetra };
611
+ export { seedWorkflowsDrive, startVetra };
577
612
 
578
- //# sourceMappingURL=vetra-DkF6EJMY.mjs.map
579
- //# debugId=0be7e354-5024-5332-aa33-5bc37e651ed4
613
+ //# sourceMappingURL=vetra-CnrGDPX0.mjs.map
614
+ //# debugId=bd7945b3-cb7b-5147-93ad-9fd89f126138
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vetra-CnrGDPX0.mjs","sources":["../src/utils/configure-vetra-github-url.ts","../src/utils/resolve-switchboard-port.ts","../src/utils/vetra-runtime.ts","../src/services/vetra.ts"],"sourcesContent":["import {\n createVetraDocument,\n getVetraDocuments,\n setPackageGithubUrl,\n} from \"@powerhousedao/common/utils\";\nimport { red } from \"colorette\";\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\n\n/**\n * Get git remote URL (origin)\n * @returns Git remote URL or null if not configured\n */\nfunction getGitRemoteUrl(): string | null {\n try {\n const url = execSync(\"git remote get-url origin\", {\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim();\n return url || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Prompt user to enter a custom GitHub URL\n */\nasync function promptForCustomUrl(): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(\"\\nEnter GitHub URL (or press Enter to skip): \");\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const url = answer.trim();\n resolve(url || null);\n });\n });\n}\n\n/**\n * Prompt yes/no question\n */\nasync function promptYesNo(question: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(`\\n${question} (y/n): `);\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const response = answer.trim().toLowerCase();\n resolve(response === \"y\" || response === \"yes\");\n });\n });\n}\n\n/**\n * Prompt user to select or enter GitHub URL\n * @param gitRemoteUrl - Git remote URL if available\n * @returns Selected URL or null if skipped\n */\nasync function promptForGithubUrl(\n gitRemoteUrl: string | null,\n): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\\n\" + \"=\".repeat(50));\n console.log(\"🔍 Vetra Package Configuration\");\n console.log(\"=\".repeat(50));\n console.log(\n \"\\nWe detected a Vetra package document in your remote drive without a GitHub URL configured.\",\n );\n console.log(\"\\nWould you like to configure the GitHub URL now?\");\n\n if (gitRemoteUrl) {\n console.log(`\\nGit remote URL detected: ${gitRemoteUrl}`);\n console.log(\"\\nOptions:\");\n console.log(\"1. Use detected URL\");\n console.log(\"2. Enter a different URL\");\n console.log(\"3. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-3): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n resolve(gitRemoteUrl);\n } else if (choice === \"2\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"3\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-3): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n } else {\n console.log(\"\\nNo git remote URL detected.\");\n console.log(\"\\nOptions:\");\n console.log(\"1. Enter GitHub URL manually\");\n console.log(\"2. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-2): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"2\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-2): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n }\n });\n}\n\n/**\n * Set git remote URL (origin)\n */\nfunction setGitRemoteUrl(url: string): void {\n try {\n execSync(`git remote add origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin set to: ${url}`);\n } catch {\n try {\n execSync(`git remote set-url origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin updated to: ${url}`);\n } catch {\n console.error(red(`❌ Failed to set git remote URL`));\n }\n }\n}\n\n/**\n * Validates documents and returns the target document to use\n * Warns if multiple documents found\n */\nfunction validateAndSelectDocument<T>(documents: T[]): T | null {\n if (documents.length === 0) {\n return null;\n }\n\n if (documents.length > 1) {\n console.warn(\n `⚠️ Warning: Multiple Vetra documents found (${documents.length}). Using first document.`,\n );\n }\n\n return documents[0];\n}\n\nasync function applyGithubUrlConfiguration(\n graphqlEndpoint: string,\n vetraDriveId: string,\n documentId: string,\n selectedUrl: string,\n shouldSetRemote: boolean,\n): Promise<void> {\n // Set package GitHub URL\n await setPackageGithubUrl(\n graphqlEndpoint,\n vetraDriveId,\n documentId,\n selectedUrl,\n );\n\n console.log(`✅ GitHub URL configured: ${selectedUrl}`);\n\n // Set git remote URL if requested\n if (shouldSetRemote) {\n setGitRemoteUrl(selectedUrl);\n }\n}\n\nfunction logVerbose(message: string, verbose?: boolean): void {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sleep for a specified number of milliseconds\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Configure GitHub URL for Vetra documents\n * @param switchboardPort - Port where switchboard is running\n * @param vetraDriveUrl - Remote drive URL\n * @param verbose - Enable verbose logging\n */\nexport async function configureVetraGithubUrl(\n switchboardPort: number,\n vetraDriveUrl: string,\n verbose?: boolean,\n): Promise<void> {\n logVerbose(\"Checking GitHub URL configuration...\", verbose);\n\n try {\n const graphqlEndpoint = `http://localhost:${switchboardPort}/graphql`;\n const vetraDriveId = vetraDriveUrl.split(\"/\").pop();\n if (!vetraDriveId) {\n throw new Error(\"Invalid vetraDriveUrl: unable to extract drive ID\");\n }\n\n const documents = await getVetraDocuments(graphqlEndpoint, vetraDriveId);\n\n // Skip if already configured\n if (documents.some((doc) => doc.githubUrl)) {\n logVerbose(\"GitHub URL already configured, skipping setup\", verbose);\n return;\n }\n\n // Get or create target document\n let targetDocumentId: string;\n const targetDocument = validateAndSelectDocument(documents);\n\n // Collect user input\n const gitRemoteUrl = getGitRemoteUrl();\n const selectedUrl = await promptForGithubUrl(gitRemoteUrl);\n\n if (!selectedUrl) {\n logVerbose(\"GitHub URL configuration skipped\", verbose);\n return;\n }\n\n let shouldSetRemote = false;\n if (selectedUrl !== gitRemoteUrl && !gitRemoteUrl) {\n shouldSetRemote = await promptYesNo(\"Set this as your git remote URL?\");\n }\n\n if (!targetDocument) {\n logVerbose(\"No Vetra documents found, creating new document...\", verbose);\n\n targetDocumentId = await createVetraDocument(\n graphqlEndpoint,\n vetraDriveId,\n \"vetra-package\",\n );\n\n logVerbose(`Created new document: ${targetDocumentId}`, verbose);\n } else {\n targetDocumentId = targetDocument.id;\n }\n\n await applyGithubUrlConfiguration(\n graphqlEndpoint,\n vetraDriveId,\n targetDocumentId,\n selectedUrl,\n shouldSetRemote,\n );\n } catch (error) {\n console.error(\n red(\n `⚠️ GitHub URL configuration failed: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n logVerbose(String(error), verbose);\n }\n}\n","import { isPortAvailable } from \"@powerhousedao/switchboard/server\";\nimport { yellow } from \"colorette\";\n\nconst MAX_FALLBACK_ATTEMPTS = 20;\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nasync function findFreePort(start: number): Promise<number | null> {\n for (let i = 0; i < MAX_FALLBACK_ATTEMPTS; i++) {\n const candidate = start + i;\n if (await isPortAvailable(candidate)) return candidate;\n }\n return null;\n}\n\n/**\n * Resolve the port switchboard should bind to. If the requested port is free,\n * returns it unchanged. If it's in use, walks forward for the next free port\n * and — in an interactive terminal — asks the user to confirm the fallback.\n * In CI / piped contexts the fallback is applied automatically so scripts\n * don't hang on an unanswered prompt.\n *\n * Throws a process.exit(1) when the user declines the prompt or when no free\n * port is available in the search window.\n */\nexport async function resolveSwitchboardPort(\n requested: number,\n): Promise<number> {\n if (await isPortAvailable(requested)) return requested;\n\n const candidate = await findFreePort(requested + 1);\n if (candidate === null) {\n console.error(\n `Port ${requested} is in use and no free port was found in the range ${requested}-${requested + MAX_FALLBACK_ATTEMPTS - 1}.`,\n );\n process.exit(1);\n }\n\n if (!isInteractive()) {\n console.log(\n yellow(\n `Port ${requested} is in use. Falling back to port ${candidate} (non-interactive; skipping confirmation).`,\n ),\n );\n return candidate;\n }\n\n const enquirer = await import(\"enquirer\");\n\n let confirmed: boolean;\n try {\n const answer = await enquirer.default.prompt<{ confirmed: boolean }>({\n type: \"confirm\",\n name: \"confirmed\",\n message: `Port ${requested} is in use. Use port ${candidate} instead?`,\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. Free port ${requested} or pass --switchboard-port <port> to choose a different port.`,\n );\n process.exit(1);\n }\n\n return candidate;\n}\n","import { resolvePhDir } from \"@powerhousedao/shared/clis/ph-dir\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport type VetraRuntimeRecord = {\n pid: number;\n projectName: string;\n switchboardPort: number;\n connectPort: number;\n mcpUrl: string;\n startedAt: string;\n};\n\nexport type VetraProbe =\n | { status: \"none\" }\n | { status: \"stale\" }\n | { status: \"live\"; record: VetraRuntimeRecord }\n | { status: \"foreign\"; record: VetraRuntimeRecord };\n\nconst READY_TIMEOUT_MS = 2000;\n\n// Under the project's .ph tree — relocated with it by PH_USER_DATA_DIR.\nconst recordPath = (projectDir: string) =>\n path.join(resolvePhDir(projectDir), \"vetra-runtime.json\");\n\nexport function readVetraRuntime(\n projectDir: string,\n): VetraRuntimeRecord | undefined {\n try {\n return JSON.parse(\n fs.readFileSync(recordPath(projectDir), \"utf8\"),\n ) as VetraRuntimeRecord;\n } catch {\n // Missing or corrupt: either way there is no usable record.\n return undefined;\n }\n}\n\nexport function writeVetraRuntime(\n projectDir: string,\n record: VetraRuntimeRecord,\n): void {\n const target = recordPath(projectDir);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\\n`);\n}\n\nexport function clearVetraRuntime(projectDir: string): void {\n try {\n fs.rmSync(recordPath(projectDir));\n } catch {\n // Already gone.\n }\n}\n\nfunction isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means the process exists but belongs to another user.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nasync function isReady(port: number): Promise<boolean> {\n try {\n const response = await fetch(`http://localhost:${port}/ready`, {\n signal: AbortSignal.timeout(READY_TIMEOUT_MS),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * Decide whether the recorded instance is actually serving this project.\n *\n * All three checks are load-bearing. A pid can be reused by an unrelated\n * process, so a live pid proves nothing on its own. Another project's\n * switchboard would answer `/ready` on its own port, so a healthy `/ready`\n * proves nothing either. And the recorded `projectName` is what separates\n * \"my instance\" from \"someone else's instance that happens to hold this\n * port\" — which is precisely the confusion that let an agent write document\n * models into a different project's drive.\n *\n * A stale record is deleted so the next start is unblocked. A foreign one is\n * left alone: it describes something that is alive.\n */\nexport async function probeVetraRuntime(\n projectDir: string,\n projectName: string,\n): Promise<VetraProbe> {\n const record = readVetraRuntime(projectDir);\n if (!record) return { status: \"none\" };\n\n if (!isPidAlive(record.pid) || !(await isReady(record.switchboardPort))) {\n clearVetraRuntime(projectDir);\n return { status: \"stale\" };\n }\n\n if (record.projectName !== projectName) {\n return { status: \"foreign\", record };\n }\n return { status: \"live\", record };\n}\n\nconst MCP_FILES = [\".mcp.json\", path.join(\".cursor\", \"mcp.json\")];\n\n/**\n * Point every generated MCP config at `port`, returning the files changed.\n *\n * An MCP client resolves these files at session start and cannot read the\n * project config or `.env`, so when an override moves the port the literal\n * has to be corrected on disk. Rewrites in place rather than regenerating,\n * so any other servers or hand-added keys survive.\n */\nexport function syncMcpPort(projectDir: string, port: number): string[] {\n const changed: string[] = [];\n for (const rel of MCP_FILES) {\n const target = path.join(projectDir, rel);\n if (!fs.existsSync(target)) continue;\n\n let parsed: { mcpServers?: Record<string, { url?: string }> };\n try {\n parsed = JSON.parse(fs.readFileSync(target, \"utf8\")) as typeof parsed;\n } catch {\n // Hand-broken JSON is the author's to fix; don't clobber it.\n continue;\n }\n\n const server = parsed.mcpServers?.[\"reactor-mcp\"];\n if (!server?.url) continue;\n\n const wanted = `http://localhost:${port}/mcp`;\n if (server.url === wanted) continue;\n\n server.url = wanted;\n fs.writeFileSync(target, `${JSON.stringify(parsed, null, 2)}\\n`);\n changed.push(rel);\n }\n return changed;\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport { getConfig } from \"@powerhousedao/shared/clis\";\nimport { addDefaultDrive } from \"@powerhousedao/switchboard/utils\";\nimport { join } from \"node:path\";\nimport { blue, green, red, yellow, type Color } from \"colorette\";\nimport type { ILogger } from \"document-model\";\nimport { childLogger, setLogLevel } from \"document-model\";\nimport { createLogger } from \"vite\";\nimport type { VetraArgs } from \"../types.js\";\nimport { generateProjectDriveId, POWERHOUSE_CONFIG_FILE } from \"../utils.js\";\nimport { wasFlagExplicitlyPassed } from \"../utils/cli-connect-override.js\";\nimport {\n configureVetraGithubUrl,\n sleep,\n} from \"../utils/configure-vetra-github-url.js\";\nimport { POWERHOUSE_DRIVE_ICON } from \"../utils/drive-icons.js\";\nimport { mergeDefaultDrives, rebaseDriveUrl } from \"@powerhousedao/host-core\";\nimport { parseDefaultDrivesUrl } from \"../utils/parse-default-drives.js\";\nimport { resolveSwitchboardPort } from \"../utils/resolve-switchboard-port.js\";\nimport {\n clearVetraRuntime,\n probeVetraRuntime,\n syncMcpPort,\n writeVetraRuntime,\n} from \"../utils/vetra-runtime.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport { startSwitchboard } from \"./switchboard.js\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;\n\nconst getDriveId = (driveUrl: string | undefined): string =>\n driveUrl?.split(\"/\").pop() ?? generateProjectDriveId(VETRA_DRIVE_NAME);\n\n// rebaseDriveUrl moved to @powerhousedao/host-core (uniform-runners P1.4) —\n// one implementation shared by this classic path and the generic compound.\n\nfunction createViteLogger(color: Color) {\n const customLogger = createLogger(\"info\");\n const loggerInfo = customLogger.info.bind(customLogger);\n customLogger.info = (msg, options) => {\n loggerInfo(color(msg), options);\n };\n const loggerWarn = customLogger.warn.bind(customLogger);\n customLogger.warn = (msg, options) => {\n loggerWarn(yellow(msg), options);\n };\n const loggerError = customLogger.error.bind(customLogger);\n customLogger.error = (msg, options) => {\n loggerError(red(msg), options);\n };\n\n const loggerWarnOnce = customLogger.warnOnce.bind(customLogger);\n customLogger.warnOnce = (msg, options) => {\n loggerWarnOnce(yellow(msg), options);\n };\n return customLogger;\n}\n\nasync function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n): Promise<string | null> {\n const previewDriveId = generateProjectDriveId(\"preview\");\n\n const previewDrive = {\n id: previewDriveId,\n slug: previewDriveId,\n global: {\n name: \"Vetra Preview\",\n icon: POWERHOUSE_DRIVE_ICON,\n nodes: [],\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\" as const,\n triggers: [],\n },\n };\n\n const driveUrl = await addDefaultDrive(reactor, previewDrive, port);\n\n if (verbose && driveUrl) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl ?? null;\n}\n\n// Opens in Workflow Studio; only seeded when the switchboard runs workflows.\n// Exported for the switchboard bridge runner: a hosts project with\n// reactor.workflows enabled seeds the SAME project-hashed drive this vetra\n// path does, until drive provisioning becomes a plugin contribution.\nexport async function seedWorkflowsDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n): Promise<string | null> {\n const workflowsDrive = {\n id: generateProjectDriveId(\"workflows\"),\n slug: \"workflows\",\n global: { name: \"Workflows\" },\n preferredEditor: \"workflow-studio\",\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\" as const,\n triggers: [],\n },\n };\n\n const driveUrl = await addDefaultDrive(reactor, workflowsDrive, port);\n\n if (verbose && driveUrl) {\n console.log(blue(`Vetra Switchboard: Workflows drive: ${driveUrl}`));\n }\n return driveUrl ?? null;\n}\nasync function startLocalVetraSwitchboard(args: VetraArgs, logger?: ILogger) {\n const {\n connectPort,\n switchboardPort,\n dev,\n packages,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n remoteDrive,\n interactive,\n watch,\n verbose,\n } = args;\n\n // Convert single remote drive to array if provided\n const remoteDrives = remoteDrive ? [remoteDrive] : [];\n\n const vetraProcessorConfig: VetraProcessorConfigType = {\n interactive,\n driveUrl: remoteDrive ?? getDefaultVetraUrl(connectPort),\n driveId: getDriveId(remoteDrive),\n };\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\n\n const vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n // When the user didn't opt into strict-port semantics, check for a port\n // conflict up front and ask for confirmation before binding a fallback.\n // Doing this in the CLI layer keeps the interactive prompt out of the\n // switchboard server package and aligns with the existing prerelease-tag\n // confirmation flow in `ph publish`.\n const resolvedSwitchboardPort = args.strictPort\n ? switchboardPort\n : await resolveSwitchboardPort(switchboardPort);\n\n try {\n const switchboard = await startSwitchboard(\n {\n ...args,\n useVetraDrive: true, // Use Vetra drive instead of Powerhouse drive\n mcp: true,\n port: resolvedSwitchboardPort,\n // We've already probed and (when interactive) confirmed the port with\n // the user, so keep the server from running its own fallback on top.\n strictPort: true,\n dev,\n packages,\n remoteDrives,\n vetraDriveId,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n processorConfig,\n basePath: undefined,\n keypairPath: undefined,\n dbPath: args.dbPath,\n useIdentity: undefined,\n migrate: undefined,\n migrateStatus: undefined,\n reset: undefined,\n yes: undefined,\n requireIdentity: undefined,\n },\n logger,\n );\n\n const actualSwitchboardPort = switchboard.port;\n\n // Add preview drive (only in watch mode)\n let previewDriveUrl: string | null = null;\n if (watch) {\n try {\n previewDriveUrl = await startVetraPreviewDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n verbose,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n let workflowsDriveUrl: string | null = null;\n if (switchboard.workflowsEnabled) {\n try {\n workflowsDriveUrl = await seedWorkflowsDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n verbose,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Started successfully`));\n if (remoteDrive) {\n console.log(\n blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`),\n );\n }\n } else {\n console.log();\n console.log(\n blue(\n `Vetra Switchboard: http://localhost:${actualSwitchboardPort}/graphql`,\n ),\n );\n console.log(blue(` ➜ Drive URL: ${switchboard.defaultDriveUrl}`));\n if (previewDriveUrl) {\n console.log(blue(` ➜ Preview Drive URL: ${previewDriveUrl}`));\n }\n if (workflowsDriveUrl) {\n console.log(blue(` ➜ Workflows Drive URL: ${workflowsDriveUrl}`));\n }\n }\n return {\n driveUrl: switchboard.defaultDriveUrl || \"\",\n previewDriveUrl: previewDriveUrl,\n workflowsDriveUrl,\n switchboardPort: actualSwitchboardPort,\n };\n } catch (error) {\n console.error(\n red(\n `Vetra Switchboard: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n throw error instanceof Error ? error : new Error(String(error));\n }\n}\n\nexport async function startVetra(args: VetraArgs) {\n const {\n connectPort,\n verbose,\n remoteDrive,\n disableConnect,\n debug,\n httpsCertFile,\n httpsKeyFile,\n disableLocalPackages,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n watchTimeout,\n } = args;\n\n const switchboardLogger = childLogger([\"vetra\", \"switchboard\"]);\n\n // One Vetra per project. Two instances over one working tree would contend\n // for the same `.ph/read-model.db` and `.ph/reactor-storage`, and leave the\n // project with two drives that diverge.\n const projectDir = process.cwd();\n const { readPackageSync } = await import(\"read-pkg\");\n const projectName = readPackageSync({ cwd: projectDir }).name;\n const probe = await probeVetraRuntime(projectDir, projectName);\n\n if (probe.status === \"live\") {\n console.log();\n console.log(green(\"Vetra is already running for this project.\"));\n console.log(\n green(` ➜ Connect: http://localhost:${probe.record.connectPort}`),\n );\n console.log(\n green(\n ` ➜ Switchboard: http://localhost:${probe.record.switchboardPort}/graphql`,\n ),\n );\n console.log(\n `Stop that instance (pid ${probe.record.pid}) if you need to restart it.`,\n );\n return;\n }\n\n if (probe.status === \"foreign\") {\n console.error(\n red(\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`,\n ),\n );\n process.exit(1);\n }\n\n try {\n // Set default log level to info if not already specified\n if (!process.env.LOG_LEVEL) {\n setLogLevel(\"info\");\n }\n\n if (verbose) {\n switchboardLogger.info(\"Starting Vetra Switchboard...\");\n if (remoteDrive) {\n const source = remoteDrive\n ? \"command line argument\"\n : \"powerhouse.config.json\";\n switchboardLogger.info(`Using vetraUrl from ${source}: ${remoteDrive}`);\n }\n }\n const switchboardResult = await startLocalVetraSwitchboard(\n {\n ...args,\n dev: true, // Vetra always runs in dev mode to load local packages\n httpsKeyFile,\n httpsCertFile,\n disableLocalPackages,\n debug,\n },\n switchboardLogger,\n );\n const driveUrl: string = switchboardResult.driveUrl || remoteDrive || \"\";\n const previewDriveUrl = switchboardResult.previewDriveUrl;\n const workflowsDriveUrl = switchboardResult.workflowsDriveUrl;\n const actualSwitchboardPort = switchboardResult.switchboardPort;\n\n // Record what we actually bound, so a second `ph vetra` can tell a live\n // instance from a stale file, and so an agent can see the real ports.\n writeVetraRuntime(projectDir, {\n pid: process.pid,\n projectName,\n switchboardPort: actualSwitchboardPort,\n connectPort,\n mcpUrl: `http://localhost:${actualSwitchboardPort}/mcp`,\n startedAt: new Date().toISOString(),\n });\n const releaseRuntimeRecord = () => clearVetraRuntime(projectDir);\n process.on(\"exit\", releaseRuntimeRecord);\n process.on(\"SIGINT\", () => {\n releaseRuntimeRecord();\n process.exit(130);\n });\n process.on(\"SIGTERM\", () => {\n releaseRuntimeRecord();\n process.exit(143);\n });\n\n // An MCP client resolved `.mcp.json` before this process started and\n // cannot re-read it, so a drifted literal means the agent is pointed at\n // the wrong port — possibly another project's reactor. Correct the file\n // and say so plainly; we cannot fix the already-open client ourselves.\n const driftedMcpFiles = syncMcpPort(projectDir, actualSwitchboardPort);\n if (driftedMcpFiles.length > 0) {\n console.log(\n yellow(\n `Updated ${driftedMcpFiles.join(\" and \")} to port ${actualSwitchboardPort}. ` +\n `Reconnect your MCP client (/mcp) to pick it up. ` +\n `This edit is local — do not commit it.`,\n ),\n );\n }\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n // give some time for the drive to process initial strands\n await sleep(3000);\n\n await configureVetraGithubUrl(\n actualSwitchboardPort,\n remoteDrive,\n verbose,\n );\n\n // give some time for the user to read log messages\n await sleep(2000);\n }\n\n if (verbose) {\n console.log(\"Starting Codegen Reactor...\");\n }\n\n // Start Connect pointing to the drive (unless disabled)\n if (!disableConnect) {\n // --drives-public-base: advertise proxy-reachable drive URLs to the\n // browser instead of the switchboard's localhost origin.\n const publicBase = args.drivesPublicBase;\n const browserDriveUrl = publicBase\n ? rebaseDriveUrl(driveUrl, publicBase)\n : driveUrl;\n const browserPreviewDriveUrl =\n previewDriveUrl && publicBase\n ? rebaseDriveUrl(previewDriveUrl, publicBase)\n : previewDriveUrl;\n const browserWorkflowsDriveUrl =\n workflowsDriveUrl && publicBase\n ? rebaseDriveUrl(workflowsDriveUrl, publicBase)\n : workflowsDriveUrl;\n\n // The resolved default-drive list: vetra's own drives first (the\n // Vetra drive, the preview drive in watch mode, and the Workflows\n // drive when workflows are on), then the\n // project's configured `connect.drives.defaultDrives` from\n // powerhouse.config.json (issue #3023). A drive vetra also starts is\n // listed only once. An explicit `--default-drives-url` is appended on\n // top of this list by buildStudioConnectOverride — it never replaces\n // the vetra drives.\n const vetraDriveEntries = [\n ...(browserDriveUrl\n ? [{ url: browserDriveUrl, name: null, icon: null }]\n : []),\n ...(browserPreviewDriveUrl\n ? [{ url: browserPreviewDriveUrl, name: null, icon: null }]\n : []),\n ...(browserWorkflowsDriveUrl\n ? [{ url: browserWorkflowsDriveUrl, name: null, icon: null }]\n : []),\n ];\n const configuredDefaultDrives =\n getConfig(join(projectDir, POWERHOUSE_CONFIG_FILE)).connect?.drives\n ?.defaultDrives ?? [];\n const resolvedDefaultDrives = mergeDefaultDrives(\n vetraDriveEntries,\n configuredDefaultDrives,\n );\n\n if (verbose) {\n console.log(\"Starting Connect...\");\n // Mirror buildStudioConnectOverride: an explicit\n // --default-drives-url is appended to the resolved list.\n const flagDefaultDrives = wasFlagExplicitlyPassed(\"default-drives-url\")\n ? parseDefaultDrivesUrl(args.defaultDrivesUrl ?? \"\")\n : [];\n const printedDefaultDrives = mergeDefaultDrives(\n resolvedDefaultDrives,\n flagDefaultDrives,\n );\n console.log(\n ` ➜ Connect will use default drives: ${printedDefaultDrives\n .map((d) => (\"url\" in d ? d.url : `local:${d.id}`))\n .join(\", \")}`,\n );\n }\n console.log();\n console.log(green(`Vetra Connect: http://localhost:${connectPort}`));\n\n const customViteLogger = createViteLogger(green);\n\n // Programmatic override forwarded to the Connect runtime config —\n // vetra always sets these regardless of what the user typed on the\n // command line. We pass it as the explicit third arg to\n // runConnectStudio so it survives the `wasFlagExplicitlyPassed`\n // gating (the user didn't pass --default-drives-url; vetra is setting\n // it itself).\n const vetraDrivesOverride = {\n drives: {\n defaultDrives: resolvedDefaultDrives,\n preserveStrategy: \"preserve-all\" as const,\n },\n };\n\n await runConnectStudio(\n {\n ...args,\n port: connectPort,\n disableLocalPackages,\n debug,\n host: host,\n open: open,\n cors: cors,\n strictPort: strictPort,\n printUrls: printUrls,\n bindCLIShortcuts: bindCLIShortcuts,\n watchTimeout: watchTimeout,\n },\n customViteLogger,\n vetraDrives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M;IAAK,CAAC,IAC1D,CAAC;GACP;GACA,MAAM,0BACJ,UAAU,KAAK,YAAA,wBAAkC,CAAC,CAAC,CAAC,SAAS,QACzD,iBAAiB,CAAC;GACxB,MAAM,wBAAwB,mBAC5B,mBACA,uBACF;GAEA,IAAI,SAAS;IACX,QAAQ,IAAI,qBAAqB;IAGjC,MAAM,oBAAoB,wBAAwB,oBAAoB,IAClE,sBAAsB,KAAK,oBAAoB,EAAE,IACjD,CAAC;IACL,MAAM,uBAAuB,mBAC3B,uBACA,iBACF;IACA,QAAQ,IACN,yCAAyC,qBACtC,KAAK,MAAO,SAAS,IAAI,EAAE,MAAM,SAAS,EAAE,IAAK,CAAC,CAClD,KAAK,IAAI,GACd;GACF;GACA,QAAQ,IAAI;GACZ,QAAQ,IAAI,MAAM,mCAAmC,aAAa,CAAC;GAEnE,MAAM,mBAAmB,iBAAiB,KAAK;GAQ/C,MAAM,sBAAsB,EAC1B,QAAQ;IACN,eAAe;IACf,kBAAkB;GACpB,EACF;GAEA,MAAM,iBACJ;IACE,GAAG;IACH,MAAM;IACN;IACA;IACM;IACA;IACA;IACM;IACD;IACO;IACJ;GAChB,GACA,kBACA,mBACF;EACF;CACF,SAAS,OAAO;EACd,QAAQ,MAAM,KAAK;CACrB;AACF","debug_id":"bd7945b3-cb7b-5147-93ad-9fd89f126138"}
@@ -0,0 +1,19 @@
1
+
2
+ !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]="8f90996d-2865-5564-b0aa-35c99867095d")}catch(e){}}();
3
+ import { lintSubgraphTypes } from "@powerhousedao/vetra/codegen";
4
+ //#region src/utils/warn-subgraph-type-conflicts.ts
5
+ async function warnSubgraphTypeConflicts(projectDir) {
6
+ let warnings;
7
+ try {
8
+ warnings = await lintSubgraphTypes(projectDir);
9
+ } catch (error) {
10
+ console.warn("⚠ Failed to check subgraph type names:", error);
11
+ return;
12
+ }
13
+ for (const warning of warnings) console.warn(`⚠ ${warning}`);
14
+ }
15
+ //#endregion
16
+ export { warnSubgraphTypeConflicts as t };
17
+
18
+ //# sourceMappingURL=warn-subgraph-type-conflicts-BOHBmThq.mjs.map
19
+ //# debugId=8f90996d-2865-5564-b0aa-35c99867095d
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn-subgraph-type-conflicts-BOHBmThq.mjs","sources":["../src/utils/warn-subgraph-type-conflicts.ts"],"sourcesContent":["import { lintSubgraphTypes } from \"@powerhousedao/vetra/codegen\";\n\nexport async function warnSubgraphTypeConflicts(\n projectDir: string,\n): Promise<void> {\n let warnings: string[];\n try {\n warnings = await lintSubgraphTypes(projectDir);\n } catch (error) {\n console.warn(\"⚠ Failed to check subgraph type names:\", error);\n return;\n }\n for (const warning of warnings) console.warn(`⚠ ${warning}`);\n}\n"],"names":[],"mappings":";;;;AAEA,eAAsB,0BACpB,YACe;CACf,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,kBAAkB,UAAU;CAC/C,SAAS,OAAO;EACd,QAAQ,KAAK,0CAA0C,KAAK;EAC5D;CACF;CACA,KAAK,MAAM,WAAW,UAAU,QAAQ,KAAK,KAAK,SAAS;AAC7D","debug_id":"8f90996d-2865-5564-b0aa-35c99867095d"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "6.2.3-dev.7",
3
+ "version": "6.2.3-dev.71",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -17,39 +17,56 @@
17
17
  "bin": {
18
18
  "ph-cli": "./dist/cli.mjs"
19
19
  },
20
+ "exports": {
21
+ "./package.json": "./package.json",
22
+ "./runners/connect": {
23
+ "source": "./src/runners/connect.ts",
24
+ "types": "./dist/runners/connect.d.mts",
25
+ "import": "./dist/runners/connect.mjs",
26
+ "default": "./dist/runners/connect.mjs"
27
+ },
28
+ "./runners/switchboard": {
29
+ "source": "./src/runners/switchboard.ts",
30
+ "types": "./dist/runners/switchboard.d.mts",
31
+ "import": "./dist/runners/switchboard.mjs",
32
+ "default": "./dist/runners/switchboard.mjs"
33
+ }
34
+ },
20
35
  "files": [
21
36
  "dist"
22
37
  ],
23
38
  "keywords": [],
24
39
  "author": "",
25
40
  "dependencies": {
26
- "@powerhousedao/builder-tools": "6.2.3-dev.7",
27
- "@powerhousedao/codegen": "6.2.3-dev.7",
28
- "@powerhousedao/common": "6.2.3-dev.7",
29
- "@powerhousedao/config": "6.2.3-dev.7",
30
- "@powerhousedao/reactor": "6.2.3-dev.7",
31
- "@powerhousedao/shared": "6.2.3-dev.7",
32
- "@powerhousedao/switchboard": "6.2.3-dev.7",
33
- "@powerhousedao/vetra": "6.2.3-dev.7",
34
- "@renown/sdk": "6.2.3-dev.7",
41
+ "@powerhousedao/builder-tools": "6.2.3-dev.71",
42
+ "@powerhousedao/codegen": "6.2.3-dev.71",
43
+ "@powerhousedao/common": "6.2.3-dev.71",
44
+ "@powerhousedao/config": "6.2.3-dev.71",
45
+ "@powerhousedao/reactor": "6.2.3-dev.71",
46
+ "@powerhousedao/shared": "6.2.3-dev.71",
47
+ "@powerhousedao/switchboard": "6.2.3-dev.71",
48
+ "@powerhousedao/vetra": "6.2.3-dev.71",
49
+ "@renown/sdk": "6.2.3-dev.71",
35
50
  "@sentry/node-core": "^10.52.0",
36
- "@tsdown/css": "0.21.1",
51
+ "@tsdown/css": "0.23.0",
52
+ "@vercel/nft": "^1.11.0",
37
53
  "ajv": "^8.18.0",
38
54
  "chalk": "5.6.2",
39
55
  "change-case": "5.4.4",
40
56
  "cmd-ts": "0.15.0",
41
57
  "colorette": "2.0.20",
42
- "document-model": "6.2.3-dev.7",
58
+ "document-model": "6.2.3-dev.71",
43
59
  "enquirer": "2.4.1",
44
60
  "kysely": "0.28.16",
45
61
  "package-manager-detector": "1.6.0",
46
62
  "pg": "8.18.0",
47
63
  "read-pkg": "10.1.0",
48
64
  "remeda": "2.33.7",
49
- "rolldown": "1.0.0-rc.8",
65
+ "rolldown": "1.2.9",
50
66
  "semver": "7.7.4",
51
- "tsdown": "0.21.1",
52
- "vite": "8.0.10"
67
+ "sirv": "^3.0.2",
68
+ "tsdown": "0.23.0",
69
+ "vite": "8.3.4"
53
70
  },
54
71
  "devDependencies": {
55
72
  "@types/node": "25.2.3",
@@ -58,16 +75,20 @@
58
75
  "copyfiles": "2.4.1",
59
76
  "ts-morph": "27.0.2",
60
77
  "write-package": "7.2.0",
61
- "zod": "4.3.6"
78
+ "zod": "^4.5.4",
79
+ "@powerhousedao/desktop": "6.2.3-dev.71",
80
+ "@powerhousedao/host-core": "6.2.3-dev.71"
62
81
  },
63
82
  "scripts": {
64
83
  "tsc": "tsc",
65
- "lint": "eslint",
84
+ "lint": "cd ../.. && oxlint clis/ph-cli",
85
+ "test": "vitest --run",
66
86
  "generate-docs": "bun run scripts/generate-commands-docs.ts",
67
87
  "build": "tsdown",
68
88
  "postbuild": "bun generate-docs && bun copy-scripts",
69
89
  "copy-scripts": "copyfiles scripts/* dist/",
70
90
  "dev": "bun run ./src/cli.ts",
71
- "cli": "node ./dist/cli.mjs"
91
+ "cli": "node ./dist/cli.mjs",
92
+ "emit-schemas": "tsx scripts/emit-runner-schemas.ts"
72
93
  }
73
94
  }
@@ -1,4 +0,0 @@
1
- import { t as getRenown } from "./auth-AR3VxAIk.mjs";
2
- export { getRenown };
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]="cf92d68d-d125-5b6a-84e7-bc1c770b8437")}catch(e){}}();
4
- //# debugId=cf92d68d-d125-5b6a-84e7-bc1c770b8437
@@ -1,4 +0,0 @@
1
- import { n as runBuild } from "./build-uQXq6_HU.mjs";
2
- export { runBuild };
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]="07cbb8f4-54b7-5333-be22-8ce017cd9e53")}catch(e){}}();
4
- //# debugId=07cbb8f4-54b7-5333-be22-8ce017cd9e53
@@ -1,71 +0,0 @@
1
-
2
- !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]="a81d56d6-7b6c-5288-ac91-899d56570def")}catch(e){}}();
3
- import { execSync } from "node:child_process";
4
- import { browserBuildConfig, nodeBuildConfig } from "@powerhousedao/shared/build-config";
5
- import { existsSync, readFileSync } from "node:fs";
6
- import { join } from "node:path";
7
- import { detect, resolveCommand } from "package-manager-detector";
8
- import { readPackage } from "read-pkg";
9
- import { build } from "tsdown";
10
- //#region src/services/build.ts
11
- /**
12
- * A Powerhouse package's `powerhouse.manifest.json` "name" must match its
13
- * `package.json` "name" — Connect and the registry resolve installed versions
14
- * by treating the manifest name as the npm package name, so a mismatch silently
15
- * breaks resolution. Fail the build early if they diverge. No-op when the
16
- * project has no manifest (nothing to compare).
17
- */
18
- async function assertManifestNameMatchesPackage(projectPath) {
19
- const manifestPath = join(projectPath, "powerhouse.manifest.json");
20
- if (!existsSync(manifestPath)) return;
21
- const { name: packageName } = await readPackage({ cwd: projectPath });
22
- let manifestName;
23
- try {
24
- manifestName = JSON.parse(readFileSync(manifestPath, "utf-8")).name;
25
- } catch {
26
- throw new Error(`Failed to parse "powerhouse.manifest.json" at ${manifestPath}. Make sure it is valid JSON.`);
27
- }
28
- if (manifestName !== packageName) throw new Error(`Package name mismatch — "package.json" and "powerhouse.manifest.json" must have the same "name":\n package.json "name": ${JSON.stringify(packageName)}\n powerhouse.manifest.json "name": ${JSON.stringify(manifestName)}\n\nUpdate one so they match, then run the build again.`);
29
- }
30
- async function runBuild(args) {
31
- const { outDir } = args;
32
- await assertManifestNameMatchesPackage(process.cwd());
33
- await build({
34
- ...browserBuildConfig,
35
- outDir: join(outDir, "browser")
36
- });
37
- await build({
38
- ...nodeBuildConfig,
39
- outDir: join(outDir, "node")
40
- });
41
- const agent = (await detect())?.agent ?? "npm";
42
- const tscCommand = resolveCommand(agent, "execute-local", ["tsc", "--build"]);
43
- if (tscCommand === null) {
44
- console.error("You need to have typescript installed to use the `build` command.");
45
- process.exit(1);
46
- }
47
- console.log("\n▶ Emitting types via tsc...");
48
- try {
49
- execSync(`${tscCommand.command} ${tscCommand.args.join(" ")}`, { stdio: "inherit" });
50
- console.log("✔ Types emitted to", join(outDir, "types"));
51
- } catch {
52
- console.warn("✘ tsc reported errors above; declarations were still written. Fix the errors to keep types accurate.");
53
- }
54
- const executeLocalCommand = resolveCommand(agent, "execute-local", [
55
- "tailwindcss",
56
- "-i",
57
- "./style.css",
58
- "-o",
59
- "./dist/style.css"
60
- ]);
61
- if (executeLocalCommand === null) {
62
- console.error("You need to have tailwindcss installed to use the `build` command.");
63
- process.exit(1);
64
- }
65
- execSync(`${executeLocalCommand.command} ${executeLocalCommand.args.join(" ")}`);
66
- }
67
- //#endregion
68
- export { runBuild as n, assertManifestNameMatchesPackage as t };
69
-
70
- //# sourceMappingURL=build-uQXq6_HU.mjs.map
71
- //# debugId=a81d56d6-7b6c-5288-ac91-899d56570def
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-uQXq6_HU.mjs","sources":["../src/services/build.ts"],"sourcesContent":["import {\n browserBuildConfig,\n nodeBuildConfig,\n} from \"@powerhousedao/shared/build-config\";\nimport { execSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { detect, resolveCommand } from \"package-manager-detector\";\nimport { readPackage } from \"read-pkg\";\nimport { build as tsdownBuild } from \"tsdown\";\nimport type { BuildArgs } from \"../types.js\";\n\n/**\n * A Powerhouse package's `powerhouse.manifest.json` \"name\" must match its\n * `package.json` \"name\" — Connect and the registry resolve installed versions\n * by treating the manifest name as the npm package name, so a mismatch silently\n * breaks resolution. Fail the build early if they diverge. No-op when the\n * project has no manifest (nothing to compare).\n */\nexport async function assertManifestNameMatchesPackage(projectPath: string) {\n const manifestPath = join(projectPath, \"powerhouse.manifest.json\");\n if (!existsSync(manifestPath)) return;\n\n const { name: packageName } = await readPackage({ cwd: projectPath });\n\n let manifestName: unknown;\n try {\n manifestName = (\n JSON.parse(readFileSync(manifestPath, \"utf-8\")) as { name?: unknown }\n ).name;\n } catch {\n throw new Error(\n `Failed to parse \"powerhouse.manifest.json\" at ${manifestPath}. Make sure it is valid JSON.`,\n );\n }\n\n if (manifestName !== packageName) {\n throw new Error(\n `Package name mismatch — \"package.json\" and \"powerhouse.manifest.json\" must have the same \"name\":\\n` +\n ` package.json \"name\": ${JSON.stringify(packageName)}\\n` +\n ` powerhouse.manifest.json \"name\": ${JSON.stringify(manifestName)}\\n\\n` +\n `Update one so they match, then run the build again.`,\n );\n }\n}\n\nexport async function runBuild(args: BuildArgs) {\n const { outDir } = args;\n\n // Fail fast if the manifest name and package.json name have drifted apart.\n await assertManifestNameMatchesPackage(process.cwd());\n\n await tsdownBuild({\n ...browserBuildConfig,\n outDir: join(outDir, \"browser\"),\n });\n\n await tsdownBuild({\n ...nodeBuildConfig,\n outDir: join(outDir, \"node\"),\n });\n\n const detectResult = await detect();\n const agent = detectResult?.agent ?? \"npm\";\n\n // Emit types with tsc\n const tscCommand = resolveCommand(agent, \"execute-local\", [\"tsc\", \"--build\"]);\n if (tscCommand === null) {\n console.error(\n \"You need to have typescript installed to use the `build` command.\",\n );\n process.exit(1);\n }\n console.log(\"\\n▶ Emitting types via tsc...\");\n try {\n execSync(`${tscCommand.command} ${tscCommand.args.join(\" \")}`, {\n stdio: \"inherit\",\n });\n console.log(\"✔ Types emitted to\", join(outDir, \"types\"));\n } catch {\n console.warn(\n \"✘ tsc reported errors above; declarations were still written. Fix the errors to keep types accurate.\",\n );\n }\n\n const executeLocalCommand = resolveCommand(agent, \"execute-local\", [\n \"tailwindcss\",\n \"-i\",\n \"./style.css\",\n \"-o\",\n \"./dist/style.css\",\n ]);\n if (executeLocalCommand === null) {\n console.error(\n \"You need to have tailwindcss installed to use the `build` command.\",\n );\n process.exit(1);\n }\n execSync(\n `${executeLocalCommand.command} ${executeLocalCommand.args.join(\" \")}`,\n );\n}\n"],"names":["tsdownBuild"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,eAAsB,iCAAiC,aAAqB;CAC1E,MAAM,eAAe,KAAK,aAAa,2BAA2B;AAClE,KAAI,CAAC,WAAW,aAAa,CAAE;CAE/B,MAAM,EAAE,MAAM,gBAAgB,MAAM,YAAY,EAAE,KAAK,aAAa,CAAC;CAErE,IAAI;AACJ,KAAI;AACF,iBACE,KAAK,MAAM,aAAa,cAAc,QAAQ,CAAC,CAC/C;SACI;AACN,QAAM,IAAI,MACR,iDAAiD,aAAa,+BAC/D;;AAGH,KAAI,iBAAiB,YACnB,OAAM,IAAI,MACR,wIACwC,KAAK,UAAU,YAAY,CAAC,uCAC5B,KAAK,UAAU,aAAa,CAAC,yDAEtE;;AAIL,eAAsB,SAAS,MAAiB;CAC9C,MAAM,EAAE,WAAW;AAGnB,OAAM,iCAAiC,QAAQ,KAAK,CAAC;AAErD,OAAMA,MAAY;EAChB,GAAG;EACH,QAAQ,KAAK,QAAQ,UAAU;EAChC,CAAC;AAEF,OAAMA,MAAY;EAChB,GAAG;EACH,QAAQ,KAAK,QAAQ,OAAO;EAC7B,CAAC;CAGF,MAAM,SADe,MAAM,QAAQ,GACP,SAAS;CAGrC,MAAM,aAAa,eAAe,OAAO,iBAAiB,CAAC,OAAO,UAAU,CAAC;AAC7E,KAAI,eAAe,MAAM;AACvB,UAAQ,MACN,oEACD;AACD,UAAQ,KAAK,EAAE;;AAEjB,SAAQ,IAAI,gC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