@powerhousedao/ph-cli 6.3.0-dev.2 → 6.3.0-dev.3

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 (44) hide show
  1. package/dist/build-BdQFCpwz.mjs +4 -0
  2. package/dist/{build-DEARgWyg.mjs → build-CgLN1cEZ.mjs} +4 -4
  3. package/dist/{build-DEARgWyg.mjs.map → build-CgLN1cEZ.mjs.map} +1 -1
  4. package/dist/{check-CklNk7AL.mjs → check-C_x7U-2Y.mjs} +3 -3
  5. package/dist/{check-C4kc91Oy.mjs → check-VPcldr0Q.mjs} +4 -4
  6. package/dist/{check-C4kc91Oy.mjs.map → check-VPcldr0Q.mjs.map} +1 -1
  7. package/dist/cli.mjs +3 -3
  8. package/dist/{connect-build-8Y-QmOJ5.mjs → connect-build-q1QDwrH9.mjs} +4 -4
  9. package/dist/{connect-build-8Y-QmOJ5.mjs.map → connect-build-q1QDwrH9.mjs.map} +1 -1
  10. package/dist/{connect-studio-CBtduPet.mjs → connect-studio-Ds-mfXJI.mjs} +9 -6
  11. package/dist/connect-studio-Ds-mfXJI.mjs.map +1 -0
  12. package/dist/{connect-studio-BNSe_8PI.mjs → connect-studio-KdRWcq-A.mjs} +3 -3
  13. package/dist/definitions-worker.mjs +1 -1
  14. package/dist/{generate-document-model-OQPfeHs-.mjs → generate-document-model-BiD6ovXc.mjs} +4 -4
  15. package/dist/generate-document-model-BiD6ovXc.mjs.map +1 -0
  16. package/dist/{get-version-DATiLAmB.mjs → get-version-L0a1H7iV.mjs} +4 -4
  17. package/dist/{get-version-DATiLAmB.mjs.map → get-version-L0a1H7iV.mjs.map} +1 -1
  18. package/dist/{mcp-BV_EZ15p.mjs → mcp-CfSjPzKW.mjs} +4 -4
  19. package/dist/{mcp-BV_EZ15p.mjs.map → mcp-CfSjPzKW.mjs.map} +1 -1
  20. package/dist/{migrate-Bg-HBsYa.mjs → migrate-C5sxTyiG.mjs} +4 -4
  21. package/dist/{migrate-Bg-HBsYa.mjs.map → migrate-C5sxTyiG.mjs.map} +1 -1
  22. package/dist/migrate-document-models-B1TXNVes.mjs +489 -0
  23. package/dist/migrate-document-models-B1TXNVes.mjs.map +1 -0
  24. package/dist/migrate-subgraphs-Cn7bX56b.mjs +710 -0
  25. package/dist/migrate-subgraphs-Cn7bX56b.mjs.map +1 -0
  26. package/dist/migrate-subgraphs-SdawH0GP.mjs +4 -0
  27. package/dist/{ph-cli-commands--2HdnZaA.mjs → ph-cli-commands-Ctnl0Ckw.mjs} +45 -21
  28. package/dist/ph-cli-commands-Ctnl0Ckw.mjs.map +1 -0
  29. package/dist/ph-cli-commands-DPhz3gjb.mjs +4 -0
  30. package/dist/runners/connect.mjs +2 -2
  31. package/dist/runners/switchboard.mjs +1 -1
  32. package/dist/{verify-Go5DrPvf.mjs → verify-DxhwtFdv.mjs} +4 -4
  33. package/dist/{verify-Go5DrPvf.mjs.map → verify-DxhwtFdv.mjs.map} +1 -1
  34. package/dist/{vetra-CmTg8Lja.mjs → vetra-BmluhGRB.mjs} +4 -4
  35. package/dist/{vetra-CmTg8Lja.mjs.map → vetra-BmluhGRB.mjs.map} +1 -1
  36. package/package.json +17 -17
  37. package/dist/build-rj6WVkRW.mjs +0 -4
  38. package/dist/connect-studio-CBtduPet.mjs.map +0 -1
  39. package/dist/generate-document-model-OQPfeHs-.mjs.map +0 -1
  40. package/dist/migrate-subgraphs-Bm3zpsO9.mjs +0 -214
  41. package/dist/migrate-subgraphs-Bm3zpsO9.mjs.map +0 -1
  42. package/dist/migrate-subgraphs-De_rX4Hv.mjs +0 -4
  43. package/dist/ph-cli-commands--2HdnZaA.mjs.map +0 -1
  44. package/dist/ph-cli-commands-BdA9sXDE.mjs +0 -4
@@ -19,7 +19,7 @@ const verbs = [
19
19
  /** Build the project's reactor package (the SAME service as `ph build`) — what
20
20
  * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
21
21
  async function build(host, _ctx) {
22
- const { runBuild } = await import("../build-rj6WVkRW.mjs");
22
+ const { runBuild } = await import("../build-BdQFCpwz.mjs");
23
23
  const { classicBuildArgs } = await import("../classic-args-mH_DVsgC.mjs");
24
24
  const classic = await classicBuildArgs();
25
25
  await runBuild({
@@ -1,6 +1,6 @@
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]="c577d81d-1b84-5691-9f37-683e8c75d4ea")}catch(e){}}();
3
- import { t as getVersion } from "./get-version-DATiLAmB.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]="1f4c75ad-91d6-5484-817f-d5377a1a18be")}catch(e){}}();
3
+ import { t as getVersion } from "./get-version-L0a1H7iV.mjs";
4
4
  import { f as verifyReleaseApproval, i as revisionFiles, n as publishedFiles, o as packRelease, r as readReleaseApproval, s as packedDigests, u as decisionWithoutApproval } from "./files-D6_euBBn.mjs";
5
5
  //#region src/services/release/verify.ts
6
6
  /**
@@ -67,5 +67,5 @@ function checkApprovalBeforePublish(packageRoot, required) {
67
67
  //#endregion
68
68
  export { checkApprovalBeforePublish, renderReleaseDecision, verifyRelease };
69
69
 
70
- //# sourceMappingURL=verify-Go5DrPvf.mjs.map
71
- //# debugId=c577d81d-1b84-5691-9f37-683e8c75d4ea
70
+ //# sourceMappingURL=verify-DxhwtFdv.mjs.map
71
+ //# debugId=1f4c75ad-91d6-5484-817f-d5377a1a18be
@@ -1 +1 @@
1
- {"version":3,"file":"verify-Go5DrPvf.mjs","sources":["../src/services/release/verify.ts"],"sourcesContent":["import { getVersion } from \"../../get-version.js\";\nimport {\n type ApprovalRead,\n decisionWithoutApproval,\n type ReleaseDecision,\n verifyReleaseApproval,\n} from \"./approval.js\";\nimport { publishedFiles, readReleaseApproval, revisionFiles } from \"./files.js\";\nimport { packedDigests, packRelease, type PackedRelease } from \"./pack.js\";\nimport type { FileDigest } from \"./revision.js\";\n\n/**\n * Compares the package as it is now with its release approval: the files\n * the revision reads, with the output directory and exclusions the approval\n * records, and what `npm pack` publishes, or `published` when the caller\n * already packed it. Throws when either cannot be read.\n */\nexport function verifyRelease(\n packageRoot: string,\n read: ApprovalRead = readReleaseApproval(packageRoot),\n published?: readonly FileDigest[],\n): ReleaseDecision {\n if (read.kind !== \"found\") return decisionWithoutApproval(read);\n const { approval } = read;\n return verifyReleaseApproval(approval, {\n phCliVersion: getVersion(),\n files: revisionFiles(packageRoot, [\n approval.outDir,\n ...approval.packageRevision.excluded,\n ]),\n publishedFiles: published ?? publishedFiles(packageRoot),\n });\n}\n\nconst HEADLINES: Readonly<Record<ReleaseDecision[\"decision\"], string>> = {\n approved: \"the release approval matches this package\",\n missing: \"this package has no release approval\",\n unreadable: \"the release approval cannot be read\",\n stale: \"the release approval does not match this package\",\n refused: \"the release approval records a release check that did not pass\",\n};\n\n/** The decision and each reason on its own line. */\nexport function renderReleaseDecision(decision: ReleaseDecision): string {\n return [\n `${decision.decision}: ${HEADLINES[decision.decision]}`,\n ...decision.reasons.map((reason) => ` - ${reason}`),\n ].join(\"\\n\");\n}\n\n/**\n * Whether `ph publish` goes on. With `--require-approval`, `packed` is the\n * tarball the approval was checked against: publish that file, and call its\n * `dispose` once done.\n */\nexport type PublishCheck =\n | { readonly proceed: false }\n | { readonly proceed: true; readonly packed?: PackedRelease };\n\n/**\n * Checks the release approval before `ph publish` resolves a registry.\n * Without an approval file and without `required`, does nothing, as before\n * approvals existed. Otherwise a decision other than approved is a warning,\n * or with `required` a refusal.\n */\nexport function checkApprovalBeforePublish(\n packageRoot: string,\n required: boolean,\n): PublishCheck {\n const read = readReleaseApproval(packageRoot);\n if (read.kind === \"missing\" && !required) return { proceed: true };\n let text: string;\n let packed: PackedRelease | undefined;\n let approved = false;\n try {\n if (required && read.kind === \"found\") packed = packRelease(packageRoot);\n const decision = verifyRelease(\n packageRoot,\n read,\n packed && packedDigests(packed),\n );\n approved = decision.decision === \"approved\";\n text = renderReleaseDecision(decision);\n } catch (error) {\n text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;\n }\n if (approved) {\n console.log(`✔ ${text}`);\n return { proceed: true, packed };\n }\n packed?.dispose();\n if (required) {\n console.error(\n `✘ ${text}\\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`,\n );\n return { proceed: false };\n }\n console.warn(\n `⚠ ${text}\\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`,\n );\n return { proceed: true };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cACd,aACA,OAAqB,oBAAoB,WAAW,GACpD,WACiB;CACjB,IAAI,KAAK,SAAS,SAAS,OAAO,wBAAwB,IAAI;CAC9D,MAAM,EAAE,aAAa;CACrB,OAAO,sBAAsB,UAAU;EACrC,cAAc,WAAW;EACzB,OAAO,cAAc,aAAa,CAChC,SAAS,QACT,GAAG,SAAS,gBAAgB,QAC9B,CAAC;EACD,gBAAgB,aAAa,eAAe,WAAW;CACzD,CAAC;AACH;AAEA,MAAM,YAAmE;CACvE,UAAU;CACV,SAAS;CACT,YAAY;CACZ,OAAO;CACP,SAAS;AACX;;AAGA,SAAgB,sBAAsB,UAAmC;CACvE,OAAO,CACL,GAAG,SAAS,SAAS,IAAI,UAAU,SAAS,aAC5C,GAAG,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,CACrD,CAAC,CAAC,KAAK,IAAI;AACb;;;;;;;AAiBA,SAAgB,2BACd,aACA,UACc;CACd,MAAM,OAAO,oBAAoB,WAAW;CAC5C,IAAI,KAAK,SAAS,aAAa,CAAC,UAAU,OAAO,EAAE,SAAS,KAAK;CACjE,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CACf,IAAI;EACF,IAAI,YAAY,KAAK,SAAS,SAAS,SAAS,YAAY,WAAW;EACvE,MAAM,WAAW,cACf,aACA,MACA,UAAU,cAAc,MAAM,CAChC;EACA,WAAW,SAAS,aAAa;EACjC,OAAO,sBAAsB,QAAQ;CACvC,SAAS,OAAO;EACd,OAAO,8CAA8C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC5G;CACA,IAAI,UAAU;EACZ,QAAQ,IAAI,KAAK,MAAM;EACvB,OAAO;GAAE,SAAS;GAAM;EAAO;CACjC;CACA,QAAQ,QAAQ;CAChB,IAAI,UAAU;EACZ,QAAQ,MACN,KAAK,KAAK,gHACZ;EACA,OAAO,EAAE,SAAS,MAAM;CAC1B;CACA,QAAQ,KACN,KAAK,KAAK,sHACZ;CACA,OAAO,EAAE,SAAS,KAAK;AACzB","debug_id":"c577d81d-1b84-5691-9f37-683e8c75d4ea"}
1
+ {"version":3,"file":"verify-DxhwtFdv.mjs","sources":["../src/services/release/verify.ts"],"sourcesContent":["import { getVersion } from \"../../get-version.js\";\nimport {\n type ApprovalRead,\n decisionWithoutApproval,\n type ReleaseDecision,\n verifyReleaseApproval,\n} from \"./approval.js\";\nimport { publishedFiles, readReleaseApproval, revisionFiles } from \"./files.js\";\nimport { packedDigests, packRelease, type PackedRelease } from \"./pack.js\";\nimport type { FileDigest } from \"./revision.js\";\n\n/**\n * Compares the package as it is now with its release approval: the files\n * the revision reads, with the output directory and exclusions the approval\n * records, and what `npm pack` publishes, or `published` when the caller\n * already packed it. Throws when either cannot be read.\n */\nexport function verifyRelease(\n packageRoot: string,\n read: ApprovalRead = readReleaseApproval(packageRoot),\n published?: readonly FileDigest[],\n): ReleaseDecision {\n if (read.kind !== \"found\") return decisionWithoutApproval(read);\n const { approval } = read;\n return verifyReleaseApproval(approval, {\n phCliVersion: getVersion(),\n files: revisionFiles(packageRoot, [\n approval.outDir,\n ...approval.packageRevision.excluded,\n ]),\n publishedFiles: published ?? publishedFiles(packageRoot),\n });\n}\n\nconst HEADLINES: Readonly<Record<ReleaseDecision[\"decision\"], string>> = {\n approved: \"the release approval matches this package\",\n missing: \"this package has no release approval\",\n unreadable: \"the release approval cannot be read\",\n stale: \"the release approval does not match this package\",\n refused: \"the release approval records a release check that did not pass\",\n};\n\n/** The decision and each reason on its own line. */\nexport function renderReleaseDecision(decision: ReleaseDecision): string {\n return [\n `${decision.decision}: ${HEADLINES[decision.decision]}`,\n ...decision.reasons.map((reason) => ` - ${reason}`),\n ].join(\"\\n\");\n}\n\n/**\n * Whether `ph publish` goes on. With `--require-approval`, `packed` is the\n * tarball the approval was checked against: publish that file, and call its\n * `dispose` once done.\n */\nexport type PublishCheck =\n | { readonly proceed: false }\n | { readonly proceed: true; readonly packed?: PackedRelease };\n\n/**\n * Checks the release approval before `ph publish` resolves a registry.\n * Without an approval file and without `required`, does nothing, as before\n * approvals existed. Otherwise a decision other than approved is a warning,\n * or with `required` a refusal.\n */\nexport function checkApprovalBeforePublish(\n packageRoot: string,\n required: boolean,\n): PublishCheck {\n const read = readReleaseApproval(packageRoot);\n if (read.kind === \"missing\" && !required) return { proceed: true };\n let text: string;\n let packed: PackedRelease | undefined;\n let approved = false;\n try {\n if (required && read.kind === \"found\") packed = packRelease(packageRoot);\n const decision = verifyRelease(\n packageRoot,\n read,\n packed && packedDigests(packed),\n );\n approved = decision.decision === \"approved\";\n text = renderReleaseDecision(decision);\n } catch (error) {\n text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;\n }\n if (approved) {\n console.log(`✔ ${text}`);\n return { proceed: true, packed };\n }\n packed?.dispose();\n if (required) {\n console.error(\n `✘ ${text}\\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`,\n );\n return { proceed: false };\n }\n console.warn(\n `⚠ ${text}\\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`,\n );\n return { proceed: true };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cACd,aACA,OAAqB,oBAAoB,WAAW,GACp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817f-d5377a1a18be"}
@@ -1,8 +1,8 @@
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]="3ecf6b6d-e3b9-59e4-a26e-543fcd3c9bf6")}catch(e){}}();
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]="c707015a-3471-5138-870f-09b3d88af64d")}catch(e){}}();
3
3
  import { i as mergeDefaultDrives, s as rebaseDriveUrl } from "./dist-seTzvoSw.mjs";
4
4
  import { a as parseDefaultDrivesUrl, i as wasFlagExplicitlyPassed } from "./cli-connect-override-31gBnNxd.mjs";
5
- import { t as runConnectStudio } from "./connect-studio-CBtduPet.mjs";
5
+ import { t as runConnectStudio } from "./connect-studio-Ds-mfXJI.mjs";
6
6
  import { a as generateProjectDriveId, s as getProjectInfo, t as POWERHOUSE_CONFIG_FILE } from "./utils-9KyRM0mf.mjs";
7
7
  import { c as syncMcpPortNotices, i as clearVetraRuntime, l as vetraRuntimeRecord, n as runVetraRefusal, o as probeVetraRuntime, u as writeVetraRuntime } from "./vetra-instance-B0bXPj7g.mjs";
8
8
  import { i as stopVetra } from "./vetra-launch-T_uLKaR3.mjs";
@@ -347,5 +347,5 @@ async function startVetra(args) {
347
347
  //#endregion
348
348
  export { startVetra };
349
349
 
350
- //# sourceMappingURL=vetra-CmTg8Lja.mjs.map
351
- //# debugId=3ecf6b6d-e3b9-59e4-a26e-543fcd3c9bf6
350
+ //# sourceMappingURL=vetra-BmluhGRB.mjs.map
351
+ //# debugId=c707015a-3471-5138-870f-09b3d88af64d
@@ -1 +1 @@
1
- {"version":3,"file":"vetra-CmTg8Lja.mjs","sources":["../src/utils/resolve-switchboard-port.ts","../src/services/vetra.ts"],"sourcesContent":["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 { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport {\n getConfig,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} 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 {\n generateProjectDriveId,\n getProjectInfo,\n POWERHOUSE_CONFIG_FILE,\n} from \"../utils.js\";\nimport { wasFlagExplicitlyPassed } from \"../utils/cli-connect-override.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 syncMcpPortNotices,\n vetraRuntimeRecord,\n writeVetraRuntime,\n} from \"../utils/vetra-runtime.js\";\nimport { stopVetra } from \"../utils/vetra-launch.js\";\nimport { runVetraRefusal } from \"../utils/vetra-instance.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport {\n configureVetraRemoteDrive,\n printVetraSwitchboardUrls,\n vetraProcessorConfigOf,\n} from \"./vetra-switchboard.js\";\nimport {\n POWERHOUSE_DRIVE_ICON,\n seedWorkflowsDrive,\n startSwitchboard,\n} from \"@powerhousedao/ph-run/switchboard\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${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\n/** Creates the Vetra Preview drive, or opens it, and opens it in `app` when given. */\nexport async function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n app?: string,\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(\n reactor,\n { ...previewDrive, preferredEditor: app },\n port,\n );\n\n if (app && driveUrl) {\n await openDriveIn(reactor, previewDriveId, app);\n }\n\n if (verbose && driveUrl) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl ?? null;\n}\n\n/** Sets the drive's app unless it already has it; a drive from an earlier run keeps its old one otherwise. */\nasync function openDriveIn(\n reactor: IReactorClient,\n driveId: string,\n app: string,\n): Promise<void> {\n const drive = await reactor.read.get(driveId);\n if (drive.header.meta?.preferredEditor === app) {\n return;\n }\n const handle = await reactor.write.setPreferredEditor(driveId, app);\n await handle.readable;\n}\n\n// Studio's drives, read and written on the local Switchboard, so Studio and agents see one set\n// of drives (not with a remote Vetra drive, or a project that sets multiReactor or reactorClient), and no cookie banner.\nexport function buildVetraStudioOverride(\n defaultDrives: PHConnectDefaultDrive[],\n options: {\n remoteDrive?: string;\n projectConnect?: PHConnectRuntimeConfig;\n } = {},\n): PHConnectRuntimeConfig {\n const override: PHConnectRuntimeConfig = {\n drives: { defaultDrives, preserveStrategy: \"preserve-all\" },\n };\n // A first visit's cookie dialog covers the local Studio, agents' browsers included.\n if (options.projectConnect?.app?.cookieBanner === undefined) {\n override.app = { cookieBanner: false };\n }\n const instance = options.projectConnect?.instance;\n if (\n !options.remoteDrive &&\n instance?.multiReactor === undefined &&\n instance?.reactorClient === undefined\n ) {\n override.instance = {\n reactorClient: \"remote\",\n } as typeof override.instance;\n }\n return override;\n}\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 vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n const vetraProcessorConfig = vetraProcessorConfigOf({\n interactive,\n remoteDrive,\n localDriveUrl: getDefaultVetraUrl(connectPort),\n localDriveId: vetraDriveId,\n });\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\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 getConfig(join(process.cwd(), POWERHOUSE_CONFIG_FILE)).vetra\n ?.previewDrive?.app,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n let workflowsDriveUrl: string | null = null;\n if (switchboard.workflowsEnabled) {\n try {\n // Opens in Workflow Studio.\n workflowsDriveUrl = await seedWorkflowsDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n getProjectInfo().path,\n );\n if (verbose && workflowsDriveUrl) {\n console.log(\n blue(`Vetra Switchboard: Workflows drive: ${workflowsDriveUrl}`),\n );\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n printVetraSwitchboardUrls({\n verbose,\n remoteDrive,\n switchboardPort: actualSwitchboardPort,\n driveUrl: switchboard.defaultDriveUrl,\n previewDriveUrl,\n workflowsDriveUrl,\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 let probe = await probeVetraRuntime(projectDir, projectName);\n\n if (\n args.restart &&\n (probe.status === \"live\" || probe.status === \"starting\")\n ) {\n console.log(`Stopping this project's Vetra (pid ${probe.record.pid})...`);\n await stopVetra({ projectDir, projectName });\n probe = await probeVetraRuntime(projectDir, projectName);\n }\n\n if (probe.status === \"live\" || probe.status === \"starting\") {\n console.log();\n console.log(\n green(\n probe.status === \"live\"\n ? \"Vetra is already running for this project.\"\n : \"Vetra is already starting for this project.\",\n ),\n );\n const { record } = probe;\n console.log(\n green(\n ` ➜ Connect: ${record.connectUrl ?? `http://localhost:${record.connectPort}`}`,\n ),\n );\n console.log(\n green(\n ` ➜ Switchboard: ${record.switchboardUrl ?? `http://localhost:${record.switchboardPort}/graphql`}`,\n ),\n );\n console.log(\n `Run \\`ph vetra --restart\\` to restart it, or stop it (pid ${probe.record.pid}).`,\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 // The same project may be held by `ph run vetra` instead: its stack opens\n // the same stores, and publishes this record only once it is ready.\n const hostsRefusal = runVetraRefusal(projectDir, projectName);\n if (hostsRefusal) {\n console.error(red(hostsRefusal));\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 const runtimeRecord = vetraRuntimeRecord({\n projectName,\n switchboardPort: actualSwitchboardPort,\n connectPort,\n ...(disableConnect\n ? {}\n : { connectUrl: `http://localhost:${connectPort}/` }),\n });\n writeVetraRuntime(projectDir, runtimeRecord);\n // A restarted Vetra may already have written its own.\n const releaseRuntimeRecord = () =>\n clearVetraRuntime(projectDir, process.pid);\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 for (const notice of syncMcpPortNotices(\n projectDir,\n actualSwitchboardPort,\n )) {\n console.log(yellow(notice));\n }\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n await configureVetraRemoteDrive(\n actualSwitchboardPort,\n remoteDrive,\n verbose,\n );\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 // Read again each time Studio restarts for a changed powerhouse.config.json.\n const studioDrives = () => {\n const projectConnect = getConfig(\n join(projectDir, POWERHOUSE_CONFIG_FILE),\n ).connect;\n const drives = mergeDefaultDrives(\n vetraDriveEntries,\n projectConnect?.drives?.defaultDrives ?? [],\n );\n return { projectConnect, drives };\n };\n const resolvedDefaultDrives = studioDrives().drives;\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 const { projectConnect, drives } = studioDrives();\n return buildVetraStudioOverride(drives, {\n remoteDrive,\n projectConnect,\n });\n };\n\n const studio = 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 vetraDrivesOverride,\n { reloadOnConfigChange: true },\n );\n // Vite may have taken another port, and the base path is Connect's.\n const connectUrl = studio.resolvedUrls?.local[0];\n if (connectUrl && connectUrl !== runtimeRecord.connectUrl) {\n writeVetraRuntime(projectDir, {\n ...runtimeRecord,\n connectPort: Number(new URL(connectUrl).port) || connectPort,\n connectUrl,\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAM,wBAAwB;AAE9B,SAAS,gBAAyB;CAChC,OAAO,QAAQ,QAAQ,MAAM,KAAK,KAAK,CAAC,QAAQ,IAAI;AACtD;AAEA,eAAe,aAAa,OAAuC;CACjE,KAAK,IAAI,IAAI,GAAG,IAAI,uBAAuB,KAAK;EAC9C,MAAM,YAAY,QAAQ;EAC1B,IAAI,MAAM,gBAAgB,SAAS,GAAG,OAAO;CAC/C;CACA,OAAO;AACT;;;;;;;;;;;AAYA,eAAsB,uBACpB,WACiB;CACjB,IAAI,MAAM,gBAAgB,SAAS,GAAG,OAAO;CAE7C,MAAM,YAAY,MAAM,aAAa,YAAY,CAAC;CAClD,IAAI,cAAc,MAAM;EACtB,QAAQ,MACN,QAAQ,UAAU,qDAAqD,UAAU,GAAG,YAAY,wBAAwB,EAAE,EAC5H;EACA,QAAQ,KAAK,CAAC;CAChB;CAEA,IAAI,CAAC,cAAc,GAAG;EACpB,QAAQ,IACN,OACE,QAAQ,UAAU,mCAAmC,UAA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AC;GACP;GAEA,MAAM,qBAAqB;IACzB,MAAM,iBAAiB,UACrB,KAAK,YAAY,sBAAsB,CACzC,CAAC,CAAC;IAKF,OAAO;KAAE;KAAgB,QAJV,mBACb,mBACA,gBAAgB,QAAQ,iBAAiB,CAAC,CAEd;IAAE;GAClC;GACA,MAAM,wBAAwB,aAAa,CAAC,CAAC;GAE7C,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,4BAA4B;IAChC,MAAM,EAAE,gBAAgB,WAAW,aAAa;IAChD,OAAO,yBAAyB,QAAQ;KACtC;KACA;IACF,CAAC;GACH;GAqBA,MAAM,cAAa,MAnBE,iBACnB;IACE,GAAG;IACH,MAAM;IACN;IACA;IACM;IACA;IACA;IACM;IACD;IACO;IACJ;GAChB,GACA,kBACA,qBACA,EAAE,sBAAsB,KAAK,CAC/B,EAAA,CAE0B,cAAc,MAAM;GAC9C,IAAI,cAAc,eAAe,cAAc,YAC7C,kBAAkB,YAAY;IAC5B,GAAG;IACH,aAAa,OAAO,IAAI,IAAI,UAAU,CAAC,CAAC,IAAI,KAAK;IACjD;GACF,CAAC;EAEL;CACF,SAAS,OAAO;EACd,QAAQ,MAAM,KAAK;CACrB;AACF","debug_id":"3ecf6b6d-e3b9-59e4-a26e-543fcd3c9bf6"}
1
+ {"version":3,"file":"vetra-BmluhGRB.mjs","sources":["../src/utils/resolve-switchboard-port.ts","../src/services/vetra.ts"],"sourcesContent":["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 { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport {\n getConfig,\n type PHConnectDefaultDrive,\n type PHConnectRuntimeConfig,\n} 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 {\n generateProjectDriveId,\n getProjectInfo,\n POWERHOUSE_CONFIG_FILE,\n} from \"../utils.js\";\nimport { wasFlagExplicitlyPassed } from \"../utils/cli-connect-override.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 syncMcpPortNotices,\n vetraRuntimeRecord,\n writeVetraRuntime,\n} from \"../utils/vetra-runtime.js\";\nimport { stopVetra } from \"../utils/vetra-launch.js\";\nimport { runVetraRefusal } from \"../utils/vetra-instance.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport {\n configureVetraRemoteDrive,\n printVetraSwitchboardUrls,\n vetraProcessorConfigOf,\n} from \"./vetra-switchboard.js\";\nimport {\n POWERHOUSE_DRIVE_ICON,\n seedWorkflowsDrive,\n startSwitchboard,\n} from \"@powerhousedao/ph-run/switchboard\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${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\n/** Creates the Vetra Preview drive, or opens it, and opens it in `app` when given. */\nexport async function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n app?: string,\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(\n reactor,\n { ...previewDrive, preferredEditor: app },\n port,\n );\n\n if (app && driveUrl) {\n await openDriveIn(reactor, previewDriveId, app);\n }\n\n if (verbose && driveUrl) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl ?? null;\n}\n\n/** Sets the drive's app unless it already has it; a drive from an earlier run keeps its old one otherwise. */\nasync function openDriveIn(\n reactor: IReactorClient,\n driveId: string,\n app: string,\n): Promise<void> {\n const drive = await reactor.read.get(driveId);\n if (drive.header.meta?.preferredEditor === app) {\n return;\n }\n const handle = await reactor.write.setPreferredEditor(driveId, app);\n await handle.readable;\n}\n\n// Studio's drives, read and written on the local Switchboard, so Studio and agents see one set\n// of drives (not with a remote Vetra drive, or a project that sets multiReactor or reactorClient), and no cookie banner.\nexport function buildVetraStudioOverride(\n defaultDrives: PHConnectDefaultDrive[],\n options: {\n remoteDrive?: string;\n projectConnect?: PHConnectRuntimeConfig;\n } = {},\n): PHConnectRuntimeConfig {\n const override: PHConnectRuntimeConfig = {\n drives: { defaultDrives, preserveStrategy: \"preserve-all\" },\n };\n // A first visit's cookie dialog covers the local Studio, agents' browsers included.\n if (options.projectConnect?.app?.cookieBanner === undefined) {\n override.app = { cookieBanner: false };\n }\n const instance = options.projectConnect?.instance;\n if (\n !options.remoteDrive &&\n instance?.multiReactor === undefined &&\n instance?.reactorClient === undefined\n ) {\n override.instance = {\n reactorClient: \"remote\",\n } as typeof override.instance;\n }\n return override;\n}\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 vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n const vetraProcessorConfig = vetraProcessorConfigOf({\n interactive,\n remoteDrive,\n localDriveUrl: getDefaultVetraUrl(connectPort),\n localDriveId: vetraDriveId,\n });\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\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 getConfig(join(process.cwd(), POWERHOUSE_CONFIG_FILE)).vetra\n ?.previewDrive?.app,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n let workflowsDriveUrl: string | null = null;\n if (switchboard.workflowsEnabled) {\n try {\n // Opens in Workflow Studio.\n workflowsDriveUrl = await seedWorkflowsDrive(\n switchboard.reactor,\n actualSwitchboardPort,\n getProjectInfo().path,\n );\n if (verbose && workflowsDriveUrl) {\n console.log(\n blue(`Vetra Switchboard: Workflows drive: ${workflowsDriveUrl}`),\n );\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n printVetraSwitchboardUrls({\n verbose,\n remoteDrive,\n switchboardPort: actualSwitchboardPort,\n driveUrl: switchboard.defaultDriveUrl,\n previewDriveUrl,\n workflowsDriveUrl,\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 let probe = await probeVetraRuntime(projectDir, projectName);\n\n if (\n args.restart &&\n (probe.status === \"live\" || probe.status === \"starting\")\n ) {\n console.log(`Stopping this project's Vetra (pid ${probe.record.pid})...`);\n await stopVetra({ projectDir, projectName });\n probe = await probeVetraRuntime(projectDir, projectName);\n }\n\n if (probe.status === \"live\" || probe.status === \"starting\") {\n console.log();\n console.log(\n green(\n probe.status === \"live\"\n ? \"Vetra is already running for this project.\"\n : \"Vetra is already starting for this project.\",\n ),\n );\n const { record } = probe;\n console.log(\n green(\n ` ➜ Connect: ${record.connectUrl ?? `http://localhost:${record.connectPort}`}`,\n ),\n );\n console.log(\n green(\n ` ➜ Switchboard: ${record.switchboardUrl ?? `http://localhost:${record.switchboardPort}/graphql`}`,\n ),\n );\n console.log(\n `Run \\`ph vetra --restart\\` to restart it, or stop it (pid ${probe.record.pid}).`,\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 // The same project may be held by `ph run vetra` instead: its stack opens\n // the same stores, and publishes this record only once it is ready.\n const hostsRefusal = runVetraRefusal(projectDir, projectName);\n if (hostsRefusal) {\n console.error(red(hostsRefusal));\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 const runtimeRecord = vetraRuntimeRecord({\n projectName,\n switchboardPort: actualSwitchboardPort,\n connectPort,\n ...(disableConnect\n ? {}\n : { connectUrl: `http://localhost:${connectPort}/` }),\n });\n writeVetraRuntime(projectDir, runtimeRecord);\n // A restarted Vetra may already have written its own.\n const releaseRuntimeRecord = () =>\n clearVetraRuntime(projectDir, process.pid);\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 for (const notice of syncMcpPortNotices(\n projectDir,\n actualSwitchboardPort,\n )) {\n console.log(yellow(notice));\n }\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n await configureVetraRemoteDrive(\n actualSwitchboardPort,\n remoteDrive,\n verbose,\n );\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 // Read again each time Studio restarts for a changed powerhouse.config.json.\n const studioDrives = () => {\n const projectConnect = getConfig(\n join(projectDir, POWERHOUSE_CONFIG_FILE),\n ).connect;\n const drives = mergeDefaultDrives(\n vetraDriveEntries,\n projectConnect?.drives?.defaultDrives ?? [],\n );\n return { projectConnect, drives };\n };\n const resolvedDefaultDrives = studioDrives().drives;\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 const { projectConnect, drives } = studioDrives();\n return buildVetraStudioOverride(drives, {\n remoteDrive,\n projectConnect,\n });\n };\n\n const studio = 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 vetraDrivesOverride,\n { reloadOnConfigChange: true },\n );\n // Vite may have taken another port, and the base path is Connect's.\n const connectUrl = studio.resolvedUrls?.local[0];\n if (connectUrl && connectUrl !== runtimeRecord.connectUrl) {\n writeVetraRuntime(projectDir, {\n ...runtimeRecord,\n connectPort: Number(new URL(connectUrl).port) || connectPort,\n connectUrl,\n });\n }\n }\n } catch (error) {\n console.error(error);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAM,wBAAwB;AAE9B,SAAS,gBAAyB;CAChC,OAAO,QAAQ,QAAQ,MAAM,KAAK,KAAK,CAAC,QAAQ,IAAI;AACtD;AAEA,eAAe,aAAa,OAAuC;CACjE,KAAK,IAAI,IAAI,GAAG,IAAI,uBAAuB,KAAK;EAC9C,MAAM,YAAY,QAAQ;EAC1B,IAAI,MAAM,gBAAgB,SAAS,GAAG,OAAO;CAC/C;CACA,OAAO;AACT;;;;;;;;;;;AAYA,eAAsB,uBACpB,WACiB;CACjB,IAAI,MAAM,gBAAgB,SAAS,GAAG,OAAO;CAE7C,MAAM,YAAY,MAAM,aAAa,YAAY,CAAC;CAClD,IAAI,cAAc,MAAM;EACtB,QAAQ,MACN,QAAQ,UAAU,qDAAqD,UAAU,GAAG,YAAY,wBAAwB,EAAE,EAC5H;EACA,QAAQ,KAAK,CAAC;CAChB;CAEA,IAAI,CAAC,cAAc,GAAG;EACpB,QAAQ,IACN,OACE,QAAQ,UAAU,mCAAmC,UAAU,2CACjE,CACF;EACA,OAAO;CACT;CAE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,MAAM,iBAAiB,UACrB,KAAK,YAAY,sBAAsB,CACzC,CAAC,CAAC;IAKF,OAAO;KAAE;KAAgB,QAJV,mBACb,mBACA,gBAAgB,QAAQ,iBAAiB,CAAC,CAEd;IAAE;GAClC;GACA,MAAM,wBAAwB,aAAa,CAAC,CAAC;GAE7C,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,4BAA4B;IAChC,MAAM,EAAE,gBAAgB,WAAW,aAAa;IAChD,OAAO,yBAAyB,QAAQ;KACtC;KACA;IACF,CAAC;GACH;GAqBA,MAAM,cAAa,MAnBE,iBACnB;IACE,GAAG;IACH,MAAM;IACN;IACA;IACM;IACA;IACA;IACM;IACD;IACO;IACJ;GAChB,GACA,kBACA,qBACA,EAAE,sBAAsB,KAAK,CAC/B,EAAA,CAE0B,cAAc,MAAM;GAC9C,IAAI,cAAc,eAAe,cAAc,YAC7C,kBAAkB,YAAY;IAC5B,GAAG;IACH,aAAa,OAAO,IAAI,IAAI,UAAU,CAAC,CAAC,IAAI,KAAK;IACjD;GACF,CAAC;EAEL;CACF,SAAS,OAAO;EACd,QAAQ,MAAM,KAAK;CACrB;AACF","debug_id":"c707015a-3471-5138-870f-09b3d88af64d"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "6.3.0-dev.2",
3
+ "version": "6.3.0-dev.3",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -40,18 +40,18 @@
40
40
  "dependencies": {
41
41
  "@modelcontextprotocol/sdk": "1.29.0",
42
42
  "@originjs/vite-plugin-commonjs": "^1.0.3",
43
- "@powerhousedao/builder-tools": "6.3.0-dev.2",
44
- "@powerhousedao/codegen": "6.3.0-dev.2",
45
- "@powerhousedao/common": "6.3.0-dev.2",
46
- "@powerhousedao/config": "6.3.0-dev.2",
47
- "@powerhousedao/ph-run": "6.3.0-dev.2",
48
- "@powerhousedao/reactor": "6.3.0-dev.2",
49
- "@powerhousedao/reactor-api": "6.3.0-dev.2",
50
- "@powerhousedao/reactor-mcp": "6.3.0-dev.2",
51
- "@powerhousedao/shared": "6.3.0-dev.2",
52
- "@powerhousedao/switchboard": "6.3.0-dev.2",
53
- "@powerhousedao/vetra": "6.3.0-dev.2",
54
- "@renown/sdk": "6.3.0-dev.2",
43
+ "@powerhousedao/builder-tools": "6.3.0-dev.3",
44
+ "@powerhousedao/codegen": "6.3.0-dev.3",
45
+ "@powerhousedao/common": "6.3.0-dev.3",
46
+ "@powerhousedao/config": "6.3.0-dev.3",
47
+ "@powerhousedao/ph-run": "6.3.0-dev.3",
48
+ "@powerhousedao/reactor": "6.3.0-dev.3",
49
+ "@powerhousedao/reactor-api": "6.3.0-dev.3",
50
+ "@powerhousedao/reactor-mcp": "6.3.0-dev.3",
51
+ "@powerhousedao/shared": "6.3.0-dev.3",
52
+ "@powerhousedao/switchboard": "6.3.0-dev.3",
53
+ "@powerhousedao/vetra": "6.3.0-dev.3",
54
+ "@renown/sdk": "6.3.0-dev.3",
55
55
  "@sentry/node-core": "^10.52.0",
56
56
  "@tsdown/css": "0.23.0",
57
57
  "@vercel/nft": "^1.11.0",
@@ -60,7 +60,7 @@
60
60
  "change-case": "5.4.4",
61
61
  "cmd-ts": "0.15.0",
62
62
  "colorette": "2.0.20",
63
- "document-model": "6.3.0-dev.2",
63
+ "document-model": "6.3.0-dev.3",
64
64
  "dotenv": "16.4.7",
65
65
  "enquirer": "2.4.1",
66
66
  "graphql": "^16",
@@ -71,6 +71,7 @@
71
71
  "remeda": "2.33.7",
72
72
  "rolldown": "1.2.9",
73
73
  "semver": "7.7.4",
74
+ "ts-morph": "27.0.2",
74
75
  "tsdown": "0.23.0",
75
76
  "vite": "8.3.4"
76
77
  },
@@ -79,11 +80,10 @@
79
80
  "@types/npm-registry-fetch": "^8.0.9",
80
81
  "@types/pg": "8.16.0",
81
82
  "copyfiles": "2.4.1",
82
- "ts-morph": "27.0.2",
83
83
  "write-package": "7.2.0",
84
84
  "zod": "^4.5.4",
85
- "@powerhousedao/desktop": "6.3.0-dev.2",
86
- "@powerhousedao/host-core": "6.3.0-dev.2"
85
+ "@powerhousedao/desktop": "6.3.0-dev.3",
86
+ "@powerhousedao/host-core": "6.3.0-dev.3"
87
87
  },
88
88
  "scripts": {
89
89
  "tsc": "tsc",
@@ -1,4 +0,0 @@
1
- import { t as runBuild } from "./build-DEARgWyg.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]="7fffa36f-9dd6-5278-a66a-f0d8dcd6d043")}catch(e){}}();
4
- //# debugId=7fffa36f-9dd6-5278-a66a-f0d8dcd6d043
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-studio-CBtduPet.mjs","sources":["../src/services/connect-studio.ts"],"sourcesContent":["import { getConnectBaseViteConfig } from \"@powerhousedao/builder-tools\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport { readFileSync, watch } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport type { InlineConfig, Logger, ViteDevServer } from \"vite\";\nimport { createServer, mergeConfig } from \"vite\";\nimport type { ConnectStudioArgs } from \"../types.js\";\nimport { buildStudioConnectOverride } from \"../utils/cli-connect-override.js\";\nimport { switchboardProxy } from \"../utils/switchboard-proxy.js\";\n\nconst CONFIG_FILE = \"powerhouse.config.json\";\nconst RELOAD_DEBOUNCE_MS = 200;\n\nexport type ConnectStudioOptions = {\n routes?: string | false;\n cacheDir?: string;\n /** Starts a new dev server when powerhouse.config.json changes; the open tab reloads. */\n reloadOnConfigChange?: boolean;\n /** The switchboard origin whose paths this server proxies (runner.proxy). */\n proxy?: string;\n /** Runs each restart's server start, for a caller that started the first\n * one inside a wrapper of its own. */\n restartWith?: (start: () => Promise<ViteDevServer>) => Promise<ViteDevServer>;\n /** Handed what stops Studio for good, before it resolves: the config\n * watcher and whichever server is current. The first server's own `close`\n * stops neither once a config change has replaced it. */\n exposeStop?: (stop: () => Promise<void>) => void;\n};\n\nfunction readConfig(file: string): unknown {\n try {\n return JSON.parse(readFileSync(file, \"utf8\"));\n } catch {\n // Missing or mid-edit: nothing to compare yet.\n return undefined;\n }\n}\n\n/** Resolves to the first dev server; with reloadOnConfigChange a config change replaces it. */\nexport async function runConnectStudio(\n args: ConnectStudioArgs,\n customLogger?: Logger,\n callerOverride?:\n | PHConnectRuntimeConfig\n | (() => PHConnectRuntimeConfig | undefined),\n {\n routes,\n cacheDir,\n reloadOnConfigChange,\n proxy,\n restartWith,\n exposeStop,\n }: ConnectStudioOptions = {},\n): Promise<ViteDevServer> {\n const { port, host, open, cors, strictPort, printUrls, bindCLIShortcuts } =\n args;\n const mode = \"development\";\n\n const dirname = process.cwd();\n const configFile = join(dirname, CONFIG_FILE);\n\n const start = async (first: boolean) => {\n const override =\n typeof callerOverride === \"function\" ? callerOverride() : callerOverride;\n const baseConfig = getConnectBaseViteConfig({\n mode,\n dirname,\n cliConnectOverride: buildStudioConnectOverride(args, override),\n routes,\n cacheDir,\n });\n const devServerConfig: InlineConfig = {\n // A restart reloads the open tab rather than opening another.\n server: {\n port,\n host,\n open: first && open,\n cors,\n strictPort,\n ...(proxy ? { proxy: switchboardProxy(proxy) } : {}),\n },\n customLogger,\n };\n const server = await createServer(mergeConfig(baseConfig, devServerConfig));\n await server.listen();\n if (bindCLIShortcuts) server.bindCLIShortcuts({ print: first });\n return server;\n };\n\n const first = await start(true);\n if (printUrls) first.printUrls();\n if (!reloadOnConfigChange) {\n exposeStop?.(() => first.close());\n return first;\n }\n\n let server = first;\n let loaded = readConfig(configFile);\n let timer: NodeJS.Timeout | undefined;\n let restarts = Promise.resolve();\n let stopped = false;\n const restart = async () => {\n if (stopped) return;\n const current = readConfig(configFile);\n if (current === undefined || isDeepStrictEqual(current, loaded)) return;\n loaded = current;\n server.config.logger.info(\n `[connect] ${CONFIG_FILE} changed; restarting Studio with it.`,\n { timestamp: true },\n );\n await server.close();\n server = await (restartWith\n ? restartWith(() => start(false))\n : start(false));\n };\n // The folder, not the file: editors save by replacing it.\n const watcher = watch(dirname, (_event, file) => {\n if (file !== CONFIG_FILE) return;\n clearTimeout(timer);\n timer = setTimeout(() => {\n restarts = restarts.then(restart).catch((error: unknown) => {\n server.config.logger.error(\n `[connect] Could not restart Studio: ${error instanceof Error ? error.message : String(error)}`,\n );\n });\n }, RELOAD_DEBOUNCE_MS);\n });\n watcher.unref();\n exposeStop?.(async () => {\n stopped = true;\n clearTimeout(timer);\n watcher.close();\n // A restart under way ends first: it leaves the server to close.\n await restarts;\n await server.close();\n });\n return first;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAWA,MAAM,cAAc;AACpB,MAAM,qBAAqB;AAkB3B,SAAS,WAAW,MAAuB;CACzC,IAAI;EACF,OAAO,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;CAC9C,QAAQ;EAEN;CACF;AACF;;AAGA,eAAsB,iBACpB,MACA,cACA,gBAGA,EACE,QACA,UACA,sBACA,OACA,aACA,eACwB,CAAC,GACH;CACxB,MAAM,EAAE,MAAM,MAAM,MAAM,MAAM,YAAY,WAAW,qBACrD;CACF,MAAM,OAAO;CAEb,MAAM,UAAU,QAAQ,IA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CAAC,CAAC,OAAO,UAAmB;IAC1D,OAAO,OAAO,OAAO,MACnB,uCAAuC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC9F;GACF,CAAC;EACH,GAAG,kBAAkB;CACvB,CAAC;CACD,QAAQ,MAAM;CACd,aAAa,YAAY;EACvB,UAAU;EACV,aAAa,KAAK;EAClB,QAAQ,MAAM;EAEd,MAAM;EACN,MAAM,OAAO,MAAM;CACrB,CAAC;CACD,OAAO;AACT","debug_id":"b8e2158a-a83f-5d7c-ac26-90f065b32ab5"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-document-model-OQPfeHs-.mjs","sources":["../src/services/definitions/code-first-scaffold.ts","../src/services/generate-document-model.ts"],"sourcesContent":["import type { ModelGeneration } from \"@powerhousedao/codegen\";\nimport { capitalCase, kebabCase } from \"change-case\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readPackage } from \"read-pkg\";\nimport type { Project } from \"ts-morph\";\n\nexport async function scaffoldCodeFirstDocumentModel(\n generation: ModelGeneration,\n name: string,\n projectDir: string,\n project: Project,\n) {\n const modelName = name.trim();\n if (modelName === \"\") {\n throw new Error(\"--name needs a document model name.\");\n }\n const namespace = await documentTypeNamespace(projectDir);\n const documentType = `${namespace}/${kebabCase(modelName)}`;\n const editorName = `${capitalCase(modelName)} Editor`;\n const editorDirName = kebabCase(editorName);\n if (existsSync(join(projectDir, \"editors\", editorDirName))) {\n throw new Error(\n `editors/${editorDirName} already exists. Choose another --name, or move that editor first.`,\n );\n }\n\n const result = await generation.scaffoldDocumentModel(\n {\n name: modelName,\n documentType,\n author: { name: namespace, website: null },\n },\n project,\n );\n for (const path of result.written) {\n console.log(`Wrote ${path}`);\n }\n\n await generation.generateEditor(\n {\n editorName,\n documentTypes: [documentType],\n editorId: editorDirName,\n editorDirName,\n },\n project,\n );\n await project.save();\n console.log(`Generated editor \"${editorName}\" in editors/${editorDirName}`);\n}\n\nasync function documentTypeNamespace(projectDir: string) {\n const { name } = await readPackage({ cwd: projectDir, normalize: false });\n if (!name) {\n throw new Error(\n \"--name puts the document type under the package name. Add a name to package.json.\",\n );\n }\n return name.replace(/^@/, \"\").replaceAll(\"/\", \"-\");\n}\n","import { loadDocumentModel, modelGeneration } from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n documentModelsDirOf,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n extractDocumentModelDocuments,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport { handleMutuallyExclusiveOptions } from \"@powerhousedao/shared/clis\";\nimport type { DocumentModelDocument } from \"@powerhousedao/shared/document-model\";\nimport { existsSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\nimport type { GenerateDocumentModelArgs } from \"../types.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\nimport { scaffoldCodeFirstDocumentModel } from \"./definitions/code-first-scaffold.js\";\n\n/** The configured documentModelsDir, package-relative, for messages and paths. */\nfunction modelsDirOf(projectDir: string) {\n return relative(projectDir, documentModelsDirOf(projectDir).path).replaceAll(\n \"\\\\\",\n \"/\",\n );\n}\n\nexport async function startGenerateDocumentModel(\n args: GenerateDocumentModelArgs,\n projectDir: string,\n) {\n const { document, dir, all, extract, name, codeFirst, debug } = args;\n if (debug) {\n console.log({ args });\n }\n if (name !== undefined && !codeFirst) {\n throw new Error(\n \"--name creates a code-first document model. Pass --code-first.\",\n );\n }\n if (codeFirst && name === undefined) {\n throw new Error(\n \"--code-first only chooses how --name creates a model. Existing models of both styles are discovered without it; drop --code-first.\",\n );\n }\n const project = buildTsMorphProject(projectDir);\n if (name !== undefined) {\n handleMutuallyExclusiveOptions(\n {\n \"--name\": name,\n \"--document\": document,\n \"--dir\": dir,\n \"--all\": all || undefined,\n \"--extract\": extract || undefined,\n },\n \"generation mode\",\n );\n await scaffoldCodeFirstDocumentModel(\n modelGeneration,\n name,\n projectDir,\n project,\n );\n return;\n }\n if (extract) {\n const docs = extractDocumentModelDocuments(project);\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n if (all) {\n const { documentModels, unreadableDirs, codeFirstDocumentModels } =\n await modelGeneration.generateAllDocumentModels(project);\n await project.save();\n if (\n documentModels.length === 0 &&\n unreadableDirs.length === 0 &&\n codeFirstDocumentModels.length === 0\n ) {\n console.log(`No document models found in ${modelsDirOf(projectDir)}/.`);\n }\n for (const { name } of documentModels) {\n console.log(`Regenerated document model \"${name}\"`);\n }\n for (const { name } of codeFirstDocumentModels) {\n console.log(`Updated the exports of code-first document model \"${name}\"`);\n }\n for (const dirName of unreadableDirs) {\n console.warn(\n `Skipped ${modelsDirOf(projectDir)}/${dirName}: it has no readable ${dirName}.json, and no index.ts in it exports a code-first model. Kept the manifest's document models.`,\n );\n }\n await warnSubgraphTypeConflicts(projectDir);\n return;\n } else if (document) {\n if (document.endsWith(\".phd\")) {\n const doc = (await getDocument(document)) as DocumentModelDocument;\n await modelGeneration.generateDocumentModel(doc.state.global, project);\n } else {\n const state = await loadDocumentModel(document);\n await modelGeneration.generateDocumentModel(state, project);\n }\n } else if (dir) {\n const modelsDir = modelsDirOf(projectDir);\n const dirName = resolveModuleDirName(\n projectDir,\n modelsDir,\n dir,\n \"my-document-model\",\n );\n const specPath = join(projectDir, modelsDir, dirName, `${dirName}.json`);\n if (!existsSync(specPath)) {\n throw new Error(`${modelsDir}/${dirName} has no ${dirName}.json.`);\n }\n const state = await loadDocumentModel(specPath);\n await modelGeneration.generateDocumentModel(state, project);\n await project.save();\n console.log(\n `Regenerated document model \"${state.name}\" in ${modelsDir}/${dirName}`,\n );\n await warnSubgraphTypeConflicts(projectDir);\n return;\n } else {\n console.log(\n \"Please specify one of `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n await warnSubgraphTypeConflicts(projectDir);\n}\n"],"names":[],"mappings":";;;;;;;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AO;EAC5D;CACF,OAAO,IAAI,KAAK;EACd,MAAM,YAAY,YAAY,UAAU;EACxC,MAAM,UAAU,qBACd,YACA,WACA,KACA,mBACF;EACA,MAAM,WAAW,KAAK,YAAY,WAAW,SAAS,GAAG,QAAQ,MAAM;EACvE,IAAI,CAAC,WAAW,QAAQ,GACtB,MAAM,IAAI,MAAM,GAAG,UAAU,GAAG,QAAQ,UAAU,QAAQ,OAAO;EAEnE,MAAM,QAAQ,MAAM,kBAAkB,QAAQ;EAC9C,MAAM,gBAAgB,sBAAsB,OAAO,OAAO;EAC1D,MAAM,QAAQ,KAAK;EACnB,QAAQ,IACN,+BAA+B,MAAM,KAAK,OAAO,UAAU,GAAG,SAChE;EACA,MAAM,0BAA0B,UAAU;EAC1C;CACF,OAAO;EACL,QAAQ,IACN,+DACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,MAAM,0BAA0B,UAAU;AAC5C","debug_id":"9abb9264-65d9-577b-a83a-145383e907f3"}
@@ -1,214 +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]="52c36e97-ca4b-5c79-9c95-2311aac341a3")}catch(e){}}();
3
- import { existsSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
4
- import { join } from "node:path";
5
- import { migrateSubgraph, sortedSchemaText } from "@powerhousedao/codegen";
6
- import { readSubgraphDefinitions } from "document-model/tooling";
7
- import { projectSubgraphGraphQL } from "document-model";
8
- import { ViteTypeScriptSourceImportAdapter, subgraphDirStyles, uncachedDefinitionSourceRevision } from "@powerhousedao/codegen/utils";
9
- //#region src/services/migrate-subgraphs.ts
10
- /** A module that hangs on a top-level await must not hang `ph migrate`. */
11
- const IMPORT_TIMEOUT_MS = 6e4;
12
- const SCALARS_ENTRY = "scalars/index.ts";
13
- const SOURCE_FILE = /\.(?:[cm]?[jt]sx?|graphql)$/;
14
- /**
15
- * `ph migrate --subgraphs`: converts schema-first subgraphs into code-first
16
- * ones. Each written directory is loaded as `ph model check` loads it and
17
- * must serve the schema it served before; otherwise its files are restored.
18
- * Without named directories, a directory whose `index.ts` holds no class is
19
- * skipped. Returns the exit code: 0 when every requested subgraph converted
20
- * or was already code-first, 1 otherwise.
21
- */
22
- async function migrateSubgraphs(options) {
23
- const out = options.out ?? ((text) => void process.stdout.write(text));
24
- const { projectDir, dryRun } = options;
25
- const styles = new Map(subgraphDirStyles(join(projectDir, "subgraphs")).map(({ dirName, style }) => [dirName, style]));
26
- let failed = false;
27
- let schemaFirst = 0;
28
- const named = options.dirs.length > 0;
29
- const requested = named ? options.dirs : [...styles.keys()];
30
- const converted = [];
31
- const importer = new ViteTypeScriptSourceImportAdapter();
32
- const revision = uncachedDefinitionSourceRevision();
33
- try {
34
- for (const dirName of requested) {
35
- const label = `subgraphs/${dirName}`;
36
- const style = styles.get(dirName);
37
- if (style === void 0) {
38
- out(`${label}: not found. Name a directory of subgraphs/ that has an index.ts.\n`);
39
- failed = true;
40
- continue;
41
- }
42
- if (style === "code-first") {
43
- out(`${label}: already code-first\n`);
44
- continue;
45
- }
46
- const originals = readDirectory(projectDir, dirName);
47
- const migration = await migrateSubgraph({
48
- dirName,
49
- files: new Map([...originals].map(([path, bytes]) => [path, bytes.toString("utf8")]))
50
- });
51
- if (migration.kind === "no-subgraph-class" && !named) {
52
- out(`${label}: no subgraph class, skipped\n`);
53
- continue;
54
- }
55
- schemaFirst++;
56
- if (migration.kind !== "converted") {
57
- out(refusalText(label, migration));
58
- failed = true;
59
- continue;
60
- }
61
- if (dryRun) {
62
- out(`${label}: would convert ${migration.className} to code-first\n`);
63
- for (const file of migration.files) out(unifiedDiff(file));
64
- continue;
65
- }
66
- writeFiles(projectDir, migration.files);
67
- const verification = await verify(projectDir, migration, importer, revision);
68
- if (!verification.ok) {
69
- restoreFiles(projectDir, migration.files, originals);
70
- out(`${label}: not converted; its files are restored. ${verification.reason}\n`);
71
- failed = true;
72
- continue;
73
- }
74
- converted.push(dirName);
75
- out(`${label}: converted ${migration.className} to code-first; it serves the same schema\n`);
76
- if (migration.sdlFile.endsWith("/schema.graphql")) out(`${migration.sdlFile} is no longer used; the schema is now in ${label}/schema.ts. It was kept, and you can delete it.\n`);
77
- }
78
- } finally {
79
- await importer.disposeRevision();
80
- }
81
- if (!named && schemaFirst === 0) out("No schema-first subgraphs to convert.\n");
82
- return failed ? 1 : 0;
83
- }
84
- /** The directory's files and `scalars/index.ts`, by project-relative path. */
85
- function readDirectory(projectDir, dirName) {
86
- const files = /* @__PURE__ */ new Map();
87
- const dir = join(projectDir, "subgraphs", dirName);
88
- for (const entry of readdirSync(dir, {
89
- recursive: true,
90
- withFileTypes: true
91
- })) {
92
- if (!entry.isFile() || !SOURCE_FILE.test(entry.name)) continue;
93
- const path = join(entry.parentPath, entry.name);
94
- files.set(path.slice(projectDir.length + 1).replaceAll("\\", "/"), readFileSync(path));
95
- }
96
- const scalars = join(projectDir, SCALARS_ENTRY);
97
- if (existsSync(scalars)) files.set(SCALARS_ENTRY, readFileSync(scalars));
98
- return files;
99
- }
100
- function writeFiles(projectDir, files) {
101
- for (const file of files) writeFileSync(join(projectDir, file.path), file.after);
102
- }
103
- function restoreFiles(projectDir, files, originals) {
104
- for (const file of files) {
105
- const original = originals.get(file.path);
106
- if (original === void 0) rmSync(join(projectDir, file.path), { force: true });
107
- else writeFileSync(join(projectDir, file.path), original);
108
- }
109
- }
110
- async function withTimeout(work, timeoutMs) {
111
- let timer;
112
- const timeout = new Promise((_, reject) => {
113
- timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`it did not finish loading within ${timeoutMs / 1e3} seconds`)), timeoutMs);
114
- timer.unref();
115
- });
116
- try {
117
- return await Promise.race([work, timeout]);
118
- } finally {
119
- clearTimeout(timer);
120
- }
121
- }
122
- /** Loads the written class without constructing it and compares the schema it serves. */
123
- async function verify(projectDir, migration, importer, revision) {
124
- const specifier = `./subgraphs/${migration.dirName}/index.ts`;
125
- let namespace;
126
- try {
127
- namespace = await withTimeout(importer.importModule({
128
- packageRoot: projectDir,
129
- specifier,
130
- packageRevision: revision
131
- }), IMPORT_TIMEOUT_MS);
132
- } catch (error) {
133
- return {
134
- ok: false,
135
- reason: `The converted module does not load: ${(error instanceof Error ? error.message : String(error)).replaceAll(projectDir, ".")}`
136
- };
137
- }
138
- const { subgraphs, diagnostics } = readSubgraphDefinitions(namespace, { specifier });
139
- const errors = diagnostics.filter(({ severity }) => severity === "error");
140
- if (errors.length > 0) return {
141
- ok: false,
142
- reason: `The converted subgraph does not compile:\n${errors.map(({ message, repair }) => ` ${message} ${repair}`).join("\n")}`
143
- };
144
- const subgraph = subgraphs.find(({ name }) => name === migration.subgraphName);
145
- if (subgraph === void 0) return {
146
- ok: false,
147
- reason: `${specifier} exports no code-first subgraph named ${migration.subgraphName}.`
148
- };
149
- const served = sortedSchemaText(projectSubgraphGraphQL(subgraph.definition));
150
- if (served === migration.sdl) return { ok: true };
151
- return {
152
- ok: false,
153
- reason: `The converted subgraph serves a different schema:\n${unifiedDiff({
154
- path: "schema",
155
- before: migration.sdl,
156
- after: served
157
- })}`
158
- };
159
- }
160
- function refusalText(label, migration) {
161
- return `${label}: not converted\n${migration.refusals.map(({ file, line, reason, repair }) => ` ${file}:${line}: ${reason}\n ${repair}\n`).join("")}`;
162
- }
163
- /** The line edits from `before` to `after`, by longest common subsequence. */
164
- function lineEdits(before, after) {
165
- const common = Array.from({ length: before.length + 1 }, () => new Array(after.length + 1).fill(0));
166
- for (let i = before.length - 1; i >= 0; i--) for (let j = after.length - 1; j >= 0; j--) common[i][j] = before[i] === after[j] ? common[i + 1][j + 1] + 1 : Math.max(common[i + 1][j], common[i][j + 1]);
167
- const lines = [];
168
- let i = 0;
169
- let j = 0;
170
- while (i < before.length || j < after.length) if (i < before.length && j < after.length && before[i] === after[j]) {
171
- lines.push({
172
- kind: " ",
173
- text: before[i++]
174
- });
175
- j++;
176
- } else if (i < before.length && (j === after.length || common[i + 1][j] >= common[i][j + 1])) lines.push({
177
- kind: "-",
178
- text: before[i++]
179
- });
180
- else lines.push({
181
- kind: "+",
182
- text: after[j++]
183
- });
184
- return lines;
185
- }
186
- const CONTEXT = 3;
187
- /** A unified diff of one file; a new file diffs against /dev/null. */
188
- function unifiedDiff(file) {
189
- const split = (text) => text === "" ? [] : text.replace(/\n$/, "").split("\n");
190
- const lines = lineEdits(split(file.before ?? ""), split(file.after));
191
- const changed = lines.flatMap((line, index) => line.kind === " " ? [] : [index]);
192
- if (changed.length === 0) return "";
193
- const hunks = [];
194
- for (const index of changed) {
195
- const start = Math.max(0, index - CONTEXT);
196
- const end = Math.min(lines.length, index + CONTEXT + 1);
197
- const last = hunks.at(-1);
198
- if (last !== void 0 && start <= last[1]) last[1] = end;
199
- else hunks.push([start, end]);
200
- }
201
- return `--- ${file.before === null ? "/dev/null" : `a/${file.path}`}\n+++ b/${file.path}\n` + hunks.map(([start, end]) => {
202
- const lineBefore = (kind) => lines.slice(0, start).filter((line) => line.kind !== kind).length;
203
- const slice = lines.slice(start, end);
204
- const count = (kind) => slice.filter((line) => line.kind !== kind).length;
205
- const oldCount = count("+");
206
- const newCount = count("-");
207
- return `@@ -${oldCount === 0 ? lineBefore("+") : lineBefore("+") + 1},${oldCount} +${newCount === 0 ? lineBefore("-") : lineBefore("-") + 1},${newCount} @@\n${slice.map((line) => `${line.kind}${line.text}`).join("\n")}\n`;
208
- }).join("");
209
- }
210
- //#endregion
211
- export { unifiedDiff as n, migrateSubgraphs as t };
212
-
213
- //# sourceMappingURL=migrate-subgraphs-Bm3zpsO9.mjs.map
214
- //# debugId=52c36e97-ca4b-5c79-9c95-2311aac341a3
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-subgraphs-Bm3zpsO9.mjs","sources":["../src/services/migrate-subgraphs.ts"],"sourcesContent":["import {\n migrateSubgraph,\n sortedSchemaText,\n type SubgraphMigration,\n type SubgraphMigrationFile,\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 {\n existsSync,\n readdirSync,\n readFileSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\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 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 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);\n const migration = await migrateSubgraph({\n dirName,\n files: new Map(\n [...originals].map(([path, bytes]) => [path, bytes.toString(\"utf8\")]),\n ),\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 out(`${label}: would convert ${migration.className} to code-first\\n`);\n for (const file of migration.files) out(unifiedDiff(file));\n continue;\n }\n writeFiles(projectDir, migration.files);\n const verification = await verify(\n projectDir,\n migration,\n importer,\n revision,\n );\n if (!verification.ok) {\n restoreFiles(projectDir, migration.files, originals);\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 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 }\n } finally {\n await importer.disposeRevision();\n }\n if (!named && schemaFirst === 0) {\n out(\"No schema-first subgraphs to convert.\\n\");\n }\n return failed ? 1 : 0;\n}\n\n/** The directory's files and `scalars/index.ts`, by project-relative path. */\nfunction readDirectory(\n projectDir: string,\n dirName: string,\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 files.set(\n path.slice(projectDir.length + 1).replaceAll(\"\\\\\", \"/\"),\n readFileSync(path),\n );\n }\n const scalars = join(projectDir, SCALARS_ENTRY);\n if (existsSync(scalars)) files.set(SCALARS_ENTRY, readFileSync(scalars));\n return files;\n}\n\nfunction writeFiles(\n projectDir: string,\n files: readonly SubgraphMigrationFile[],\n) {\n for (const file of files)\n writeFileSync(join(projectDir, file.path), file.after);\n}\n\nfunction restoreFiles(\n projectDir: string,\n files: readonly SubgraphMigrationFile[],\n originals: ReadonlyMap<string, Buffer>,\n) {\n for (const file of files) {\n const original = originals.get(file.path);\n if (original === undefined)\n rmSync(join(projectDir, file.path), { force: true });\n else writeFileSync(join(projectDir, file.path), original);\n }\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/** 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;\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+++ 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":";;;;;;;;;;AAwBA,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;AACtB,MAAM,cAAc;;;;;;;;;AAsBpB,eAAsB,iBACpB,SACgB;CAChB,MAAM,MACJ,QAAQ,SAAS,SAAiB,KAAK,QAAQ,OAAO,MAAM,IAAI;CAClE,MAAM,EAAE,YAAY,WAAW;CAC/B,MAAM,SAAS,IAAI,IACjB,kBAAkB,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAC9C,EAAE,SAAS,YAAY,CAAC,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K,EAAE;AAEd","debug_id":"52c36e97-ca4b-5c79-9c95-2311aac341a3"}
@@ -1,4 +0,0 @@
1
- import { t as migrateSubgraphs } from "./migrate-subgraphs-Bm3zpsO9.mjs";
2
- export { migrateSubgraphs };
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]="4ba8dfb6-0ddf-5954-8a5e-2b498c1009ba")}catch(e){}}();
4
- //# debugId=4ba8dfb6-0ddf-5954-8a5e-2b498c1009ba