@proofkit/cli 2.0.0-beta.24 → 2.0.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/add-h15IdCWp.js +57 -0
- package/dist/add-h15IdCWp.js.map +1 -0
- package/dist/{addPackageDependency-BGZl7xc5.js → addPackageDependency-BUJ8tT5i.js} +2 -2
- package/dist/{addPackageDependency-BGZl7xc5.js.map → addPackageDependency-BUJ8tT5i.js.map} +1 -1
- package/dist/{consts-BZnOMxpW.js → consts-CE9CE6Fo.js} +4 -4
- package/dist/{consts-BZnOMxpW.js.map → consts-CE9CE6Fo.js.map} +1 -1
- package/dist/{deploy-D25sPO7K.js → deploy-BJryOaec.js} +3 -3
- package/dist/{deploy-D25sPO7K.js.map → deploy-BJryOaec.js.map} +1 -1
- package/dist/errors-DxuuVXoQ.js +2 -0
- package/dist/errors-DxuuVXoQ.js.map +1 -0
- package/dist/{fmdapi-BO4QL0F8.js → fmdapi-D4f7TrLy.js} +2 -2
- package/dist/{fmdapi-BO4QL0F8.js.map → fmdapi-D4f7TrLy.js.map} +1 -1
- package/dist/{fmdapi-DyRYZWzI.js → fmdapi-H4o2qGE2.js} +3 -3
- package/dist/{fmdapi-DyRYZWzI.js.map → fmdapi-H4o2qGE2.js.map} +1 -1
- package/dist/{getUserPkgManager-Cph_6l1P.js → getUserPkgManager-CZwrE7fs.js} +1 -1
- package/dist/{getUserPkgManager-Cph_6l1P.js.map → getUserPkgManager-CZwrE7fs.js.map} +1 -1
- package/dist/{globalOptions-CkqEi9uC.js → globalOptions-C6fknjPB.js} +1 -1
- package/dist/{globalOptions-CkqEi9uC.js.map → globalOptions-C6fknjPB.js.map} +1 -1
- package/dist/{index-DALPpGd1.d.ts → index-D9Y-xAF1.d.ts} +124 -42
- package/dist/index-D9Y-xAF1.d.ts.map +1 -0
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/{logger-DCEXcH26.js → logger-DxbfijxS.js} +1 -1
- package/dist/{logger-DCEXcH26.js.map → logger-DxbfijxS.js.map} +1 -1
- package/dist/{parseSettings-DJ2m9sgJ.js → parseSettings-xU5Rw3Ne.js} +1 -1
- package/dist/{parseSettings-DJ2m9sgJ.js.map → parseSettings-xU5Rw3Ne.js.map} +1 -1
- package/dist/{proofkit-webviewer-73IB1OBU.js → proofkit-webviewer-Baa93FAx.js} +2 -2
- package/dist/{proofkit-webviewer-73IB1OBU.js.map → proofkit-webviewer-Baa93FAx.js.map} +1 -1
- package/dist/remove-COo1Ju8v.js +2 -0
- package/dist/remove-COo1Ju8v.js.map +1 -0
- package/dist/typegen-DrfVmQfx.js +2 -0
- package/dist/{typegen-DyXaif5O.js.map → typegen-DrfVmQfx.js.map} +1 -1
- package/dist/update-Cpyhj57Y.js +7 -0
- package/dist/{update-FX71y5b3.js.map → update-Cpyhj57Y.js.map} +1 -1
- package/dist/utils-DGwyHkvO.js +3 -0
- package/dist/{utils-DymV7zmv.js.map → utils-DGwyHkvO.js.map} +1 -1
- package/package.json +3 -3
- package/template/nextjs-mantine/package.json +2 -1
- package/template/nextjs-shadcn/package.json +2 -0
- package/template/vite-wv/package.json +2 -2
- package/dist/add-DrcID6d6.js +0 -57
- package/dist/add-DrcID6d6.js.map +0 -1
- package/dist/index-DALPpGd1.d.ts.map +0 -1
- package/dist/remove-BOCU6In3.js +0 -2
- package/dist/remove-BOCU6In3.js.map +0 -1
- package/dist/typegen-DyXaif5O.js +0 -2
- package/dist/update-FX71y5b3.js +0 -7
- package/dist/utils-DymV7zmv.js +0 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["parseJsonc","chalk","intro","clackIntro","log","clackLog","note","clackNote","spinner","clackSpinner","isCancel","clackIsCancel","inquirerInput","inquirerPassword","inquirerConfirm","inquirerSelect","inquirerSearch","inquirerCheckbox","isCancel","log","note","fs","createSpinner","optionalArg","textArg","withArgDescription","optionalOption","textOption","withOptionDescription","choiceOption","makeCommand","booleanOption","withCommandDescription","nodeContextLayer"],"sources":["../src/core/context.ts","../src/core/errors.ts","../src/utils/projectFiles.ts","../src/utils/versioning.ts","../src/core/planInit.ts","../src/core/executeInitPlan.ts","../src/utils/projectName.ts","../src/core/resolveInitRequest.ts","../src/utils/browserOpen.ts","../src/utils/http.ts","../src/utils/packageManager.ts","../src/utils/prompts.ts","../src/services/live.ts","../src/utils/renderTitle.ts","../src/index.ts"],"sourcesContent":["import { Context } from \"effect\";\nimport type { AppType, FileMakerEnvNames, FileMakerInputs, ProofKitSettings, UIType } from \"~/core/types.js\";\nimport type { PackageManager } from \"~/utils/packageManager.js\";\n\nexport interface CliContextValue {\n cwd: string;\n debug: boolean;\n nonInteractive: boolean;\n packageManager: PackageManager;\n resolvedProjectConfig?: {\n appType?: AppType;\n ui?: UIType;\n projectDir?: string;\n };\n}\n\nexport const CliContext = Context.GenericTag<CliContextValue>(\"@proofkit/cli/CliContext\");\n\nexport interface PromptService {\n readonly text: (options: {\n message: string;\n defaultValue?: string;\n validate?: (value: string) => string | undefined;\n }) => Promise<string>;\n readonly password: (options: {\n message: string;\n validate?: (value: string) => string | undefined;\n }) => Promise<string>;\n readonly select: <T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string; disabled?: boolean | string }>;\n }) => Promise<T>;\n readonly searchSelect: <T extends string>(options: {\n message: string;\n emptyMessage?: string;\n options: Array<{ value: T; label: string; hint?: string; keywords?: string[]; disabled?: boolean | string }>;\n }) => Promise<T>;\n readonly multiSearchSelect: <T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string; keywords?: string[]; disabled?: boolean | string }>;\n required?: boolean;\n }) => Promise<T[]>;\n readonly confirm: (options: { message: string; initialValue?: boolean }) => Promise<boolean>;\n}\n\nexport const PromptService = Context.GenericTag<PromptService>(\"@proofkit/cli/PromptService\");\n\nexport interface ConsoleService {\n readonly info: (message: string) => void;\n readonly warn: (message: string) => void;\n readonly error: (message: string) => void;\n readonly success: (message: string) => void;\n readonly note: (message: string, title?: string) => void;\n}\n\nexport const ConsoleService = Context.GenericTag<ConsoleService>(\"@proofkit/cli/ConsoleService\");\n\nexport interface FileSystemService {\n readonly exists: (path: string) => Promise<boolean>;\n readonly readdir: (path: string) => Promise<string[]>;\n readonly emptyDir: (path: string) => Promise<void>;\n readonly copyDir: (from: string, to: string, options?: { overwrite?: boolean }) => Promise<void>;\n readonly rename: (from: string, to: string) => Promise<void>;\n readonly remove: (path: string) => Promise<void>;\n readonly readJson: <T>(path: string) => Promise<T>;\n readonly writeJson: (path: string, value: unknown) => Promise<void>;\n readonly writeFile: (path: string, content: string) => Promise<void>;\n readonly readFile: (path: string) => Promise<string>;\n}\n\nexport const FileSystemService = Context.GenericTag<FileSystemService>(\"@proofkit/cli/FileSystemService\");\n\nexport interface TemplateService {\n readonly getTemplateDir: (appType: AppType, ui: UIType) => string;\n}\n\nexport const TemplateService = Context.GenericTag<TemplateService>(\"@proofkit/cli/TemplateService\");\n\nexport interface PackageManagerService {\n readonly getVersion: (packageManager: PackageManager, cwd: string) => Promise<string | undefined>;\n}\n\nexport const PackageManagerService = Context.GenericTag<PackageManagerService>(\"@proofkit/cli/PackageManagerService\");\n\nexport interface ProcessService {\n readonly run: (\n command: string,\n args: string[],\n options: {\n cwd: string;\n stdout?: \"pipe\" | \"inherit\" | \"ignore\";\n stderr?: \"pipe\" | \"inherit\" | \"ignore\";\n },\n ) => Promise<{ stdout: string; stderr: string }>;\n}\n\nexport const ProcessService = Context.GenericTag<ProcessService>(\"@proofkit/cli/ProcessService\");\n\nexport interface GitService {\n readonly initialize: (projectDir: string) => Promise<void>;\n}\n\nexport const GitService = Context.GenericTag<GitService>(\"@proofkit/cli/GitService\");\n\nexport interface SettingsService {\n readonly writeSettings: (projectDir: string, settings: ProofKitSettings) => Promise<void>;\n readonly appendEnvVars: (projectDir: string, vars: Record<string, string>) => Promise<void>;\n readonly ensureTypegenConfig: (\n projectDir: string,\n options: { appType: AppType; fileMaker?: FileMakerInputs },\n ) => Promise<void>;\n}\n\nexport const SettingsService = Context.GenericTag<SettingsService>(\"@proofkit/cli/SettingsService\");\n\nexport interface FmMcpStatus {\n baseUrl: string;\n healthy: boolean;\n connectedFiles: string[];\n}\n\nexport interface FileMakerServerVersions {\n fmsVersion: string;\n ottoVersion: string | null;\n}\n\nexport interface OttoFileInfo {\n filename: string;\n status: string;\n}\n\nexport interface OttoApiKeyInfo {\n key: string;\n user: string;\n database: string;\n label: string;\n}\n\nexport interface FileMakerDataSourceEntry {\n type: \"fm\";\n name: string;\n envNames: FileMakerEnvNames;\n}\n\nexport interface FileMakerBootstrapArtifacts {\n settings: ProofKitSettings;\n envVars: Record<string, string>;\n envSchemaEntries: Array<{\n name: string;\n zodSchema: string;\n defaultValue: string;\n }>;\n typegenConfig: {\n mode: FileMakerInputs[\"mode\"];\n dataSourceName: string;\n envNames?: FileMakerEnvNames;\n fmMcpBaseUrl?: string;\n connectedFileName?: string;\n layoutName?: string;\n schemaName?: string;\n appType: AppType;\n };\n}\n\nexport interface FileMakerService {\n readonly detectLocalFmMcp: (baseUrl?: string) => Promise<FmMcpStatus>;\n readonly validateHostedServerUrl: (\n serverUrl: string,\n ottoPort?: number | null,\n ) => Promise<{\n normalizedUrl: string;\n versions: FileMakerServerVersions;\n }>;\n readonly getOttoFMSToken: (options: { url: URL }) => Promise<{ token: string }>;\n readonly listFiles: (options: { url: URL; token: string }) => Promise<OttoFileInfo[]>;\n readonly listAPIKeys: (options: { url: URL; token: string }) => Promise<OttoApiKeyInfo[]>;\n readonly createDataAPIKeyWithCredentials: (options: {\n url: URL;\n filename: string;\n username: string;\n password: string;\n }) => Promise<{ apiKey: string }>;\n readonly deployDemoFile: (options: {\n url: URL;\n token: string;\n operation: \"install\" | \"replace\";\n }) => Promise<{ apiKey: string; filename: string }>;\n readonly listLayouts: (options: { dataApiKey: string; fmFile: string; server: string }) => Promise<string[]>;\n readonly createFileMakerBootstrapArtifacts: (\n settings: ProofKitSettings,\n inputs: FileMakerInputs,\n appType: AppType,\n ) => Promise<FileMakerBootstrapArtifacts>;\n readonly bootstrap: (\n projectDir: string,\n settings: ProofKitSettings,\n inputs: FileMakerInputs,\n appType: AppType,\n ) => Promise<ProofKitSettings>;\n}\n\nexport const FileMakerService = Context.GenericTag<FileMakerService>(\"@proofkit/cli/FileMakerService\");\n\nexport interface CodegenService {\n readonly runInitial: (projectDir: string, packageManager: PackageManager) => Promise<void>;\n}\n\nexport const CodegenService = Context.GenericTag<CodegenService>(\"@proofkit/cli/CodegenService\");\n","export class UserAbortedError extends Error {\n constructor(message = \"User aborted the operation\") {\n super(message);\n this.name = \"UserAbortedError\";\n }\n}\n","import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { applyEdits, modify, parse as parseJsonc } from \"jsonc-parser\";\nimport { PKG_ROOT } from \"~/consts.js\";\nimport type { FileMakerEnvNames } from \"~/core/types.js\";\nimport type { PackageManager } from \"~/utils/packageManager.js\";\n\nconst commonFileMakerLayoutPrefixes = [\"API_\", \"API \", \"dapi_\", \"dapi\"];\nconst TRAILING_SLASH_REGEX = /[^/]$/;\nconst textFileExtensions = new Set([\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \".json\",\n \".jsonc\",\n \".md\",\n \".css\",\n \".scss\",\n \".html\",\n \".mjs\",\n \".cjs\",\n]);\n\nexport function getDefaultSchemaName(layoutName: string) {\n let schemaName = layoutName.replace(/[-\\s]/g, \"_\");\n for (const prefix of commonFileMakerLayoutPrefixes) {\n if (schemaName.startsWith(prefix)) {\n schemaName = schemaName.replace(prefix, \"\");\n }\n }\n return schemaName;\n}\n\nexport function createDataSourceEnvNames(dataSourceName: string): FileMakerEnvNames {\n if (dataSourceName === \"filemaker\") {\n return {\n database: \"FM_DATABASE\",\n server: \"FM_SERVER\",\n apiKey: \"OTTO_API_KEY\",\n };\n }\n\n const upperName = dataSourceName.toUpperCase();\n return {\n database: `${upperName}_FM_DATABASE`,\n server: `${upperName}_FM_SERVER`,\n apiKey: `${upperName}_OTTO_API_KEY`,\n };\n}\n\nexport function formatPackageManagerCommand(packageManager: PackageManager, command: string) {\n return [\"npm\", \"bun\"].includes(packageManager) ? `${packageManager} run ${command}` : `${packageManager} ${command}`;\n}\n\nexport function getTemplatePackageCommand(packageManager: PackageManager) {\n if (packageManager === \"npm\") {\n return \"npm run\";\n }\n return packageManager;\n}\n\nexport function normalizeImportAlias(importAlias: string) {\n return importAlias.replace(/\\*/g, \"\").replace(TRAILING_SLASH_REGEX, \"$&/\");\n}\n\nexport async function replaceTextInFiles(\n fs: {\n readdir: (path: string) => Promise<string[]>;\n readFile: (path: string) => Promise<string>;\n writeFile: (path: string, content: string) => Promise<void>;\n },\n rootDir: string,\n searchValue: string,\n replaceValue: string,\n) {\n const entries = await fs.readdir(rootDir);\n for (const entry of entries) {\n const fullPath = path.join(rootDir, entry);\n const childEntries = await fs.readdir(fullPath).catch((error: unknown) => {\n const code =\n typeof error === \"object\" && error !== null && \"code\" in error && typeof error.code === \"string\"\n ? error.code\n : undefined;\n\n if (code === \"ENOTDIR\") {\n return undefined;\n }\n\n throw error;\n });\n if (childEntries) {\n await replaceTextInFiles(fs, fullPath, searchValue, replaceValue);\n continue;\n }\n\n const extension = path.extname(entry);\n if (!textFileExtensions.has(extension)) {\n continue;\n }\n\n const content = await fs.readFile(fullPath).catch(() => undefined);\n if (!content?.includes(searchValue)) {\n continue;\n }\n\n await fs.writeFile(fullPath, content.replaceAll(searchValue, replaceValue));\n }\n}\n\nexport async function updateEnvSchemaFile(\n fs: {\n exists: (path: string) => Promise<boolean>;\n readFile: (path: string) => Promise<string>;\n writeFile: (path: string, content: string) => Promise<void>;\n },\n projectDir: string,\n envEntries: Array<{ name: string; zodSchema: string }>,\n) {\n const envFilePath = path.join(projectDir, \"src/lib/env.ts\");\n if (!(await fs.exists(envFilePath))) {\n return;\n }\n\n let content = await fs.readFile(envFilePath);\n const marker = \" server: {\";\n const markerIndex = content.indexOf(marker);\n if (markerIndex === -1) {\n return;\n }\n\n const insertIndex = content.indexOf(\" },\", markerIndex);\n if (insertIndex === -1) {\n return;\n }\n\n const additions = envEntries\n .filter((entry) => !content.includes(`${entry.name}:`))\n .map((entry) => ` ${entry.name}: ${entry.zodSchema},`)\n .join(\"\\n\");\n\n if (!additions) {\n return;\n }\n\n content = `${content.slice(0, insertIndex)}${additions}\\n${content.slice(insertIndex)}`;\n await fs.writeFile(envFilePath, content);\n}\n\ninterface TypegenFileContent {\n $schema?: string;\n config: Record<string, unknown>[] | Record<string, unknown>;\n}\n\nexport async function updateTypegenConfig(\n fs: {\n exists: (path: string) => Promise<boolean>;\n readFile: (path: string) => Promise<string>;\n writeFile: (path: string, content: string) => Promise<void>;\n },\n projectDir: string,\n options: {\n appType: \"browser\" | \"webviewer\";\n dataSourceName: string;\n envNames?: FileMakerEnvNames;\n fmMcpBaseUrl?: string;\n connectedFileName?: string;\n layoutName?: string;\n schemaName?: string;\n },\n) {\n const configPath = path.join(projectDir, \"proofkit-typegen.config.jsonc\");\n const dsPath = `./src/config/schemas/${options.dataSourceName}`;\n const nextDataSource: Record<string, unknown> = {\n type: \"fmdapi\",\n layouts: [],\n path: dsPath,\n clearOldFiles: true,\n clientSuffix: \"Layout\",\n };\n\n if (options.envNames) {\n nextDataSource.envNames = {\n server: options.envNames.server,\n db: options.envNames.database,\n auth: { apiKey: options.envNames.apiKey },\n };\n }\n\n if (options.appType === \"webviewer\") {\n nextDataSource.webviewerScriptName = \"ExecuteDataApi\";\n }\n\n if (options.fmMcpBaseUrl) {\n nextDataSource.fmMcp = {\n enabled: true,\n baseUrl: options.fmMcpBaseUrl,\n ...(options.connectedFileName ? { connectedFileName: options.connectedFileName } : {}),\n };\n }\n\n const layout =\n options.layoutName && options.schemaName\n ? {\n layoutName: options.layoutName,\n schemaName: options.schemaName,\n valueLists: \"allowEmpty\",\n }\n : undefined;\n\n if (layout) {\n nextDataSource.layouts = [layout];\n }\n\n if (!(await fs.exists(configPath))) {\n const nextContent: TypegenFileContent = {\n $schema: \"https://proofkit.dev/typegen-config-schema.json\",\n config: [nextDataSource],\n };\n await fs.writeFile(configPath, `${JSON.stringify(nextContent, null, 2)}\\n`);\n return;\n }\n\n const original = await fs.readFile(configPath);\n const parsed = parseJsonc(original) as TypegenFileContent;\n const configArray = Array.isArray(parsed.config) ? parsed.config : [parsed.config];\n const existingIndex = configArray.findIndex((entry) => entry.path === dsPath);\n\n if (existingIndex === -1) {\n configArray.push(nextDataSource);\n } else {\n const existing = (configArray[existingIndex] ?? {}) as Record<string, unknown>;\n const existingLayouts = Array.isArray(existing.layouts) ? existing.layouts : [];\n let nextLayouts = existingLayouts;\n if (layout && !existingLayouts.some((item) => item?.layoutName === layout.layoutName)) {\n nextLayouts = [...existingLayouts, layout];\n }\n configArray[existingIndex] = {\n ...existing,\n ...nextDataSource,\n layouts: nextLayouts,\n };\n }\n\n const nextConfig = Array.isArray(parsed.config) ? configArray : (configArray[0] ?? nextDataSource);\n const edits = modify(original, [\"config\"], nextConfig, {\n formattingOptions: {\n insertSpaces: true,\n tabSize: 2,\n eol: \"\\n\",\n },\n });\n await fs.writeFile(configPath, applyEdits(original, edits));\n}\n\nexport function getScaffoldVersion() {\n const candidates = [path.resolve(PKG_ROOT, \"package.json\"), path.resolve(PKG_ROOT, \"../cli/package.json\")];\n\n for (const candidate of candidates) {\n try {\n const packageJson = JSON.parse(readFileSync(candidate, \"utf8\")) as { version?: string };\n if (packageJson.version && packageJson.version !== \"0.0.0-private\") {\n return packageJson.version;\n }\n } catch {\n // ignore and continue searching\n }\n }\n\n return \"0.0.0-private\";\n}\n","export function getProofkitReleaseTag() {\n return \"beta\";\n}\n\nexport function getNodeMajorVersion() {\n return process.versions.node.split(\".\")[0] ?? \"22\";\n}\n","import path from \"node:path\";\nimport type { PackageJson } from \"type-fest\";\n\nimport type { InitPlan, InitRequest, ProofKitSettings } from \"~/core/types.js\";\nimport { formatPackageManagerCommand, getScaffoldVersion, getTemplatePackageCommand } from \"~/utils/projectFiles.js\";\nimport { getNodeMajorVersion, getProofkitReleaseTag } from \"~/utils/versioning.js\";\n\nfunction createDefaultSettings(request: InitRequest): ProofKitSettings {\n return {\n ui: request.ui,\n appType: request.appType,\n envFile: \".env\",\n dataSources: [],\n replacedMainPage: false,\n registryTemplates: [],\n };\n}\n\nfunction createEnvFileContent() {\n return [\"# When adding additional environment variables, update the schema alongside this file.\", \"\"].join(\"\\n\");\n}\n\nconst sharedUiDependencies = {\n \"@radix-ui/react-slot\": \"^1.2.3\",\n \"class-variance-authority\": \"^0.7.1\",\n clsx: \"^2.1.1\",\n \"lucide-react\": \"^0.577.0\",\n \"tailwind-merge\": \"^3.5.0\",\n tailwindcss: \"^4.1.10\",\n \"tw-animate-css\": \"^1.4.0\",\n} satisfies Record<string, string>;\n\nexport function planInit(\n request: InitRequest,\n options: { templateDir: string; packageManagerVersion?: string },\n): InitPlan {\n const targetDir = path.resolve(request.cwd, request.appDir);\n const releaseTag = getProofkitReleaseTag();\n const settings = createDefaultSettings(request);\n const packageManagerCommand = getTemplatePackageCommand(request.packageManager);\n\n const packageJson: InitPlan[\"packageJson\"] = {\n name: request.scopedAppName,\n packageManager: options.packageManagerVersion\n ? `${request.packageManager}@${options.packageManagerVersion}`\n : undefined,\n proofkitMetadata: {\n initVersion: getScaffoldVersion(),\n scaffoldPackage: \"@proofkit/cli\",\n },\n dependencies: {},\n devDependencies: {\n \"@proofkit/cli\": releaseTag,\n \"@types/node\": `^${getNodeMajorVersion()}`,\n },\n };\n\n if (request.appType === \"browser\") {\n Object.assign(packageJson.dependencies, sharedUiDependencies);\n packageJson.dependencies[\"@tailwindcss/postcss\"] = \"^4.1.10\";\n packageJson.dependencies[\"next-themes\"] = \"^0.4.6\";\n }\n\n if (request.appType === \"webviewer\") {\n Object.assign(packageJson.dependencies, sharedUiDependencies);\n packageJson.dependencies[\"@proofkit/fmdapi\"] = releaseTag;\n packageJson.dependencies[\"@proofkit/webviewer\"] = releaseTag;\n packageJson.dependencies[\"@tanstack/react-query\"] = \"^5.90.21\";\n packageJson.dependencies[\"@tanstack/react-router\"] = \"^1.167.4\";\n packageJson.dependencies.zod = \"^4\";\n packageJson.devDependencies[\"@proofkit/typegen\"] = releaseTag;\n packageJson.devDependencies[\"@tailwindcss/vite\"] = \"^4.2.1\";\n packageJson.devDependencies.ultracite = \"7.0.8\";\n }\n\n return {\n request,\n targetDir,\n templateDir: options.templateDir,\n packageManagerCommand,\n packageJson,\n settings,\n envFile: {\n path: path.join(targetDir, \".env\"),\n content: createEnvFileContent(),\n },\n writes: [],\n commands: [\n ...(request.noInstall ? [] : [{ type: \"install\" as const }]),\n ...(request.dataSource === \"filemaker\" &&\n !request.skipFileMakerSetup &&\n !(request.appType === \"webviewer\" && request.nonInteractive && !request.hasExplicitFileMakerInputs)\n ? [{ type: \"codegen\" as const }]\n : []),\n ...(request.noGit ? [] : [{ type: \"git-init\" as const }]),\n ],\n tasks: {\n bootstrapFileMaker: request.dataSource === \"filemaker\" && !request.skipFileMakerSetup,\n checkWebViewerAddon: request.appType === \"webviewer\",\n runInstall: !request.noInstall,\n runInitialCodegen:\n request.dataSource === \"filemaker\" &&\n !request.skipFileMakerSetup &&\n !(request.appType === \"webviewer\" && request.nonInteractive && !request.hasExplicitFileMakerInputs),\n initializeGit: !request.noGit,\n },\n nextSteps: [\n `cd ${request.appDir}`,\n ...(request.noInstall ? [request.packageManager === \"yarn\" ? \"yarn\" : `${request.packageManager} install`] : []),\n \"npx @tanstack/intent@latest install\",\n formatPackageManagerCommand(request.packageManager, \"dev\"),\n ...(request.appType === \"webviewer\"\n ? [\n formatPackageManagerCommand(request.packageManager, \"typegen\"),\n formatPackageManagerCommand(request.packageManager, \"launch-fm\"),\n ]\n : []),\n formatPackageManagerCommand(request.packageManager, \"proofkit\"),\n ],\n };\n}\n\nexport function applyPackageJsonMutations(\n packageJson: PackageJson,\n mutations: InitPlan[\"packageJson\"],\n overwriteDependencies = true,\n) {\n packageJson.name = mutations.name;\n packageJson.proofkitMetadata = mutations.proofkitMetadata as PackageJson[\"proofkitMetadata\"];\n if (mutations.packageManager) {\n packageJson.packageManager = mutations.packageManager;\n }\n\n if (!packageJson.dependencies) {\n packageJson.dependencies = {};\n }\n if (!packageJson.devDependencies) {\n packageJson.devDependencies = {};\n }\n\n const merge = (target: Record<string, string>, source: Record<string, string>) => {\n for (const [name, version] of Object.entries(source)) {\n if (overwriteDependencies || !(name in target)) {\n target[name] = version;\n }\n }\n };\n\n merge(packageJson.dependencies as Record<string, string>, mutations.dependencies);\n merge(packageJson.devDependencies as Record<string, string>, mutations.devDependencies);\n\n return packageJson;\n}\n","import path from \"node:path\";\nimport { Chalk } from \"chalk\";\nimport { Effect } from \"effect\";\nimport sortPackageJson from \"sort-package-json\";\n\nimport { AGENT_INSTRUCTIONS } from \"~/consts.js\";\nimport {\n CliContext,\n CodegenService,\n ConsoleService,\n FileMakerService,\n FileSystemService,\n GitService,\n PackageManagerService,\n ProcessService,\n PromptService,\n SettingsService,\n} from \"~/core/context.js\";\nimport { UserAbortedError } from \"~/core/errors.js\";\nimport { applyPackageJsonMutations } from \"~/core/planInit.js\";\nimport type { InitPlan } from \"~/core/types.js\";\nimport { normalizeImportAlias, replaceTextInFiles } from \"~/utils/projectFiles.js\";\n\nconst AGENT_METADATA_DIRS = new Set([\".agents\", \".claude\", \".clawed\", \".clinerules\", \".cursor\", \".windsurf\"]);\nconst IMPORT_ALIAS_WILDCARD_REGEX = /\\*/g;\nconst IMPORT_ALIAS_TRAILING_SLASH_REGEX = /\\/?$/;\nconst chalk = new Chalk({ level: 1 });\n\nconst formatCommand = (command: string) => chalk.cyan(command);\nconst formatHeading = (heading: string) => chalk.bold(heading);\nconst formatPath = (value: string) => chalk.yellow(value);\n\nfunction renderNextSteps(plan: InitPlan, additionalSteps: string[] = []) {\n const lines = [\n `${formatHeading(\"Project root:\")} ${formatCommand(`cd ${formatPath(plan.request.appDir)}`)}`,\n \"\",\n formatHeading(\"Agent setup:\"),\n \"Have your agent run this in the new project and complete the interactive prompt so it can load the right skills:\",\n ` ${formatCommand(\"npx @tanstack/intent@latest install\")}`,\n ];\n\n if (plan.request.noInstall) {\n lines.push(\n \"\",\n formatHeading(\"Install dependencies:\"),\n ` ${formatCommand(plan.request.packageManager === \"yarn\" ? \"yarn\" : `${plan.request.packageManager} install`)}`,\n );\n }\n\n lines.push(\"\", formatHeading(\"Start the app:\"), ` ${formatCommand(`${plan.packageManagerCommand} dev`)}`);\n\n if (plan.request.appType === \"webviewer\") {\n lines.push(\n \"\",\n formatHeading(\"When your FileMaker file is ready:\"),\n ` ${formatCommand(`${plan.packageManagerCommand} typegen`)}`,\n ` ${formatCommand(`${plan.packageManagerCommand} launch-fm`)}`,\n );\n\n if (additionalSteps.length > 0) {\n lines.push(...additionalSteps.map((step) => ` ${formatCommand(step)}`));\n }\n }\n\n lines.push(\n \"\",\n formatHeading(\"More ProofKit commands:\"),\n ` ${formatCommand(`${plan.packageManagerCommand} proofkit`)}`,\n );\n\n return lines.join(\"\\n\");\n}\n\nfunction getMeaningfulDirectoryEntries(entries: string[]) {\n return entries.filter((entry) => {\n if (AGENT_METADATA_DIRS.has(entry)) {\n return false;\n }\n if (entry === \".gitignore\") {\n return true;\n }\n if (entry.startsWith(\".\")) {\n return false;\n }\n return true;\n });\n}\n\nexport const prepareDirectory = (plan: InitPlan) =>\n Effect.gen(function* () {\n const fs = yield* FileSystemService;\n const consoleService = yield* ConsoleService;\n const cliContext = yield* CliContext;\n const prompts = yield* PromptService;\n\n const exists = yield* Effect.promise(() => fs.exists(plan.targetDir));\n if (!exists) {\n return;\n }\n\n const entries = yield* Effect.promise(() => fs.readdir(plan.targetDir));\n const meaningfulEntries = getMeaningfulDirectoryEntries(entries);\n if (meaningfulEntries.length === 0) {\n return;\n }\n\n if (plan.request.force) {\n yield* Effect.promise(() => fs.emptyDir(plan.targetDir));\n return;\n }\n\n if (cliContext.nonInteractive) {\n throw new Error(\n `${plan.request.appDir} already exists and isn't empty. Remove the existing files or choose a different directory.`,\n );\n }\n\n const overwriteMode = yield* Effect.promise(() =>\n prompts.select({\n message: `${plan.request.appDir} already exists and isn't empty. How would you like to proceed?`,\n options: [\n { value: \"abort\", label: \"Abort installation\" },\n { value: \"clear\", label: \"Clear the directory and continue\" },\n { value: \"overwrite\", label: \"Continue and overwrite conflicting files\" },\n ],\n }),\n );\n\n if (overwriteMode === \"abort\") {\n throw new UserAbortedError();\n }\n\n if (overwriteMode === \"clear\") {\n const confirmed = yield* Effect.promise(() =>\n prompts.confirm({\n message: \"Are you sure you want to clear the directory?\",\n initialValue: false,\n }),\n );\n if (!confirmed) {\n throw new UserAbortedError();\n }\n yield* Effect.promise(() => fs.emptyDir(plan.targetDir));\n return;\n }\n\n consoleService.warn(`Continuing in ${plan.request.appDir} and overwriting conflicting files when needed.`);\n });\n\nexport const executeInitPlan = (plan: InitPlan) =>\n Effect.gen(function* () {\n const cliContext = yield* CliContext;\n const fs = yield* FileSystemService;\n const consoleService = yield* ConsoleService;\n const settingsService = yield* SettingsService;\n const fileMakerService = yield* FileMakerService;\n const processService = yield* ProcessService;\n const gitService = yield* GitService;\n const codegenService = yield* CodegenService;\n const packageManagerService = yield* PackageManagerService;\n const additionalNextSteps: string[] = [];\n\n yield* prepareDirectory(plan);\n\n consoleService.info(`Scaffolding in ${plan.targetDir}`);\n yield* Effect.promise(() => fs.copyDir(plan.templateDir, plan.targetDir, { overwrite: true }));\n\n const stagedGitignore = path.join(plan.targetDir, \"_gitignore\");\n const finalGitignore = path.join(plan.targetDir, \".gitignore\");\n if (yield* Effect.promise(() => fs.exists(stagedGitignore))) {\n if (yield* Effect.promise(() => fs.exists(finalGitignore))) {\n yield* Effect.promise(() => fs.remove(stagedGitignore));\n } else {\n yield* Effect.promise(() => fs.rename(stagedGitignore, finalGitignore));\n }\n }\n\n const packageJsonPath = path.join(plan.targetDir, \"package.json\");\n const packageJson = yield* Effect.promise(() => fs.readJson<Record<string, unknown>>(packageJsonPath));\n const updatedPackageJson = sortPackageJson(\n applyPackageJsonMutations(packageJson as never, plan.packageJson) as never,\n );\n yield* Effect.promise(() => fs.writeJson(packageJsonPath, updatedPackageJson));\n\n yield* Effect.promise(() => settingsService.writeSettings(plan.targetDir, plan.settings));\n yield* Effect.promise(() => fs.writeFile(plan.envFile.path, plan.envFile.content));\n for (const write of plan.writes) {\n yield* Effect.promise(() => fs.writeFile(write.path, write.content));\n }\n\n yield* Effect.promise(() => replaceTextInFiles(fs, plan.targetDir, \"__PNPM_COMMAND__\", plan.packageManagerCommand));\n yield* Effect.promise(() =>\n replaceTextInFiles(fs, plan.targetDir, \"__PACKAGE_MANAGER__\", plan.request.packageManager),\n );\n yield* Effect.promise(() => replaceTextInFiles(fs, plan.targetDir, \"__AGENT_INSTRUCTIONS__\", AGENT_INSTRUCTIONS));\n if (plan.request.importAlias !== \"~/\") {\n yield* Effect.promise(() =>\n replaceTextInFiles(fs, plan.targetDir, \"~/\", normalizeImportAlias(plan.request.importAlias)),\n );\n yield* Effect.promise(() =>\n replaceTextInFiles(\n fs,\n plan.targetDir,\n \"@/\",\n plan.request.importAlias\n .replace(IMPORT_ALIAS_WILDCARD_REGEX, \"\")\n .replace(IMPORT_ALIAS_TRAILING_SLASH_REGEX, \"/\"),\n ),\n );\n }\n\n let nextSettings = plan.settings;\n if (plan.tasks.bootstrapFileMaker && plan.request.fileMaker) {\n const fileMakerInputs = plan.request.fileMaker;\n nextSettings = yield* Effect.promise(() =>\n fileMakerService.bootstrap(plan.targetDir, nextSettings, fileMakerInputs, plan.request.appType),\n );\n yield* Effect.promise(() => settingsService.writeSettings(plan.targetDir, nextSettings));\n }\n\n if (plan.tasks.checkWebViewerAddon) {\n yield* Effect.promise(async () => {\n try {\n const { checkForWebViewerLayouts, getWebViewerAddonMessages } = await import(\n \"~/installers/proofkit-webviewer.js\"\n );\n const status = await checkForWebViewerLayouts(plan.targetDir);\n const messages = getWebViewerAddonMessages(status);\n\n for (const message of messages.warn) {\n consoleService.warn(message);\n }\n for (const message of messages.info) {\n consoleService.info(message);\n }\n if (cliContext.nonInteractive) {\n additionalNextSteps.push(...messages.nextSteps);\n }\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n consoleService.warn(`Could not inspect the ProofKit WebViewer add-on (${message}).`);\n }\n });\n }\n\n if (plan.tasks.runInstall) {\n let installArgs: string[] = [\"install\"];\n if (plan.request.packageManager === \"yarn\") {\n installArgs = [];\n }\n yield* Effect.promise(() =>\n processService.run(plan.request.packageManager, installArgs, {\n cwd: plan.targetDir,\n stdout: \"pipe\",\n stderr: \"pipe\",\n }),\n );\n }\n\n if (plan.tasks.runInitialCodegen) {\n yield* Effect.promise(() => codegenService.runInitial(plan.targetDir, plan.request.packageManager));\n }\n\n if (plan.tasks.initializeGit) {\n yield* Effect.promise(() => gitService.initialize(plan.targetDir));\n }\n\n const packageManagerVersion = yield* Effect.promise(() =>\n packageManagerService.getVersion(plan.request.packageManager, plan.targetDir),\n );\n\n consoleService.success(\n `Created ${plan.request.scopedAppName} in ${plan.targetDir}${\n packageManagerVersion ? ` using ${plan.request.packageManager}@${packageManagerVersion}` : \"\"\n }`,\n );\n consoleService.info(chalk.bold(\"Next steps:\"));\n consoleService.info(renderNextSteps(plan, Array.from(new Set(additionalNextSteps))));\n return plan;\n });\n","import path from \"node:path\";\n\nconst TRAILING_SLASHES_REGEX = /\\/+$/;\nconst PATH_SEPARATOR_REGEX = /\\\\/g;\nconst VALID_APP_NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction normalizeProjectName(value: string) {\n return value.replace(PATH_SEPARATOR_REGEX, \"/\");\n}\n\nfunction trimTrailingSlashes(value: string) {\n return normalizeProjectName(value).replace(TRAILING_SLASHES_REGEX, \"\");\n}\n\nexport function parseNameAndPath(projectName: string): [scopedAppName: string, appDir: string] {\n const normalized = trimTrailingSlashes(projectName);\n const segments = normalized.split(\"/\");\n let scopedAppName = segments.at(-1) ?? \"\";\n\n if (scopedAppName === \".\") {\n scopedAppName = path.basename(path.resolve(process.cwd()));\n }\n\n const scopeIndex = segments.findIndex((segment) => segment.startsWith(\"@\"));\n if (scopeIndex !== -1) {\n scopedAppName = segments.slice(scopeIndex).join(\"/\");\n }\n\n const appDir = segments.filter((segment) => !segment.startsWith(\"@\")).join(\"/\");\n\n return [scopedAppName, appDir];\n}\n\nexport function validateAppName(projectName: string) {\n const normalized = trimTrailingSlashes(projectName);\n if (normalized === \".\") {\n const currentDirName = path.basename(path.resolve(process.cwd()));\n return VALID_APP_NAME_REGEX.test(currentDirName)\n ? undefined\n : \"Name must consist of only lowercase alphanumeric characters, '-', and '_'\";\n }\n\n const segments = normalized.split(\"/\");\n const scopeIndex = segments.findIndex((segment) => segment.startsWith(\"@\"));\n let scopedAppName = segments.at(-1);\n\n if (scopeIndex !== -1) {\n scopedAppName = segments.slice(scopeIndex).join(\"/\");\n }\n\n if (VALID_APP_NAME_REGEX.test(scopedAppName ?? \"\")) {\n return;\n }\n\n return \"Name must consist of only lowercase alphanumeric characters, '-', and '_'\";\n}\n","import { Effect } from \"effect\";\n\nimport { DEFAULT_APP_NAME } from \"~/consts.js\";\nimport { CliContext, FileMakerService, PromptService } from \"~/core/context.js\";\nimport type { AppType, CliFlags, DataSourceType, FileMakerInputs, InitRequest } from \"~/core/types.js\";\nimport { createDataSourceEnvNames, getDefaultSchemaName } from \"~/utils/projectFiles.js\";\nimport { parseNameAndPath, validateAppName } from \"~/utils/projectName.js\";\n\nconst defaultFlags: CliFlags = {\n noGit: false,\n noInstall: false,\n force: false,\n default: false,\n CI: false,\n importAlias: \"~/\",\n};\n\nfunction compareSemver(left: string, right: string) {\n const leftParts = left.split(\".\").map((part) => Number.parseInt(part, 10) || 0);\n const rightParts = right.split(\".\").map((part) => Number.parseInt(part, 10) || 0);\n\n for (let index = 0; index < Math.max(leftParts.length, rightParts.length); index += 1) {\n const leftValue = leftParts[index] ?? 0;\n const rightValue = rightParts[index] ?? 0;\n if (leftValue > rightValue) {\n return 1;\n }\n if (leftValue < rightValue) {\n return -1;\n }\n }\n\n return 0;\n}\n\nfunction validateLayoutInputs(flags: CliFlags) {\n const hasLayoutName = Boolean(flags.layoutName);\n const hasSchemaName = Boolean(flags.schemaName);\n\n if (hasLayoutName !== hasSchemaName) {\n throw new Error(\"Both --layout-name and --schema-name must be provided together.\");\n }\n}\n\nasync function resolveHostedFileMakerInputs({\n prompt,\n fileMakerService,\n flags,\n nonInteractive,\n}: {\n prompt: PromptService;\n fileMakerService: FileMakerService;\n flags: CliFlags;\n nonInteractive: boolean;\n}): Promise<FileMakerInputs> {\n validateLayoutInputs(flags);\n\n if (!flags.server && nonInteractive) {\n throw new Error(\n \"Missing required hosted FileMaker inputs in non-interactive mode: --server, --file-name, and --data-api-key.\",\n );\n }\n\n const rawServer =\n flags.server ??\n (await prompt.text({\n message: \"What is the URL of your FileMaker Server?\",\n validate: (value) => {\n try {\n const normalized = value.startsWith(\"http\") ? value : `https://${value}`;\n new URL(normalized);\n return;\n } catch {\n return \"Please enter a valid URL\";\n }\n },\n }));\n\n const { normalizedUrl, versions } = await fileMakerService.validateHostedServerUrl(rawServer);\n const hostedUrl = new URL(normalizedUrl);\n const demoFileName = \"ProofKitDemo.fmp12\";\n\n let selectedFile = flags.fileName;\n let dataApiKey = flags.dataApiKey;\n let layoutName = flags.layoutName;\n let schemaName = flags.schemaName;\n let token: string | undefined;\n let files: Awaited<ReturnType<FileMakerService[\"listFiles\"]>> = [];\n const requireHostedToken = () => {\n if (!token) {\n throw new Error(\"OttoFMS authentication is required for hosted setup.\");\n }\n return token;\n };\n\n if (!(selectedFile && dataApiKey)) {\n if (!(flags.adminApiKey || (versions.ottoVersion && compareSemver(versions.ottoVersion, \"4.7.0\") >= 0))) {\n throw new Error(\n \"OttoFMS 4.7.0 or later is required to auto-login. Upgrade OttoFMS or pass --admin-api-key for hosted setup.\",\n );\n }\n token = flags.adminApiKey ?? (await fileMakerService.getOttoFMSToken({ url: hostedUrl })).token;\n }\n\n if (!selectedFile) {\n if (nonInteractive) {\n throw new Error(\"Missing required FileMaker inputs in non-interactive mode: --file-name, --data-api-key.\");\n }\n\n files = await fileMakerService.listFiles({ url: hostedUrl, token: requireHostedToken() });\n selectedFile = await prompt.searchSelect({\n message: \"Which file would you like to connect to?\",\n options: [\n {\n value: \"$deploy-demo\",\n label: \"Deploy NEW ProofKit Demo File\",\n hint: \"Use OttoFMS to deploy a new file for testing\",\n keywords: [\"demo\", \"proofkit\"],\n },\n ...files\n .slice()\n .sort((left, right) => left.filename.localeCompare(right.filename))\n .map((file) => ({\n value: file.filename,\n label: file.filename,\n hint: file.status,\n keywords: [file.filename],\n })),\n ],\n });\n }\n\n if (!selectedFile) {\n throw new Error(\"No FileMaker file was selected.\");\n }\n\n if (selectedFile === \"$deploy-demo\") {\n if (files.length === 0) {\n files = await fileMakerService.listFiles({ url: hostedUrl, token: requireHostedToken() });\n }\n const demoExists = files.some((file) => file.filename === demoFileName);\n const replaceDemo =\n demoExists && !nonInteractive\n ? await prompt.confirm({\n message: \"The demo file already exists. Do you want to replace it with a fresh copy?\",\n initialValue: false,\n })\n : demoExists;\n const deployed = await fileMakerService.deployDemoFile({\n url: hostedUrl,\n token: requireHostedToken(),\n operation: replaceDemo ? \"replace\" : \"install\",\n });\n selectedFile = deployed.filename;\n dataApiKey = deployed.apiKey;\n layoutName ??= \"API_Contacts\";\n schemaName ??= \"Contacts\";\n }\n\n if (!dataApiKey && nonInteractive) {\n throw new Error(\"Missing required FileMaker inputs in non-interactive mode: --data-api-key.\");\n }\n\n if (!dataApiKey) {\n const apiKeys = (await fileMakerService.listAPIKeys({ url: hostedUrl, token: requireHostedToken() })).filter(\n (apiKey) => apiKey.database === selectedFile,\n );\n\n const selection =\n apiKeys.length === 0\n ? \"create\"\n : await prompt.searchSelect({\n message: \"Which OttoFMS Data API key would you like to use?\",\n options: [\n ...apiKeys.map((apiKey) => ({\n value: apiKey.key,\n label: `${apiKey.label} - ${apiKey.user}`,\n hint: `${apiKey.key.slice(0, 5)}...${apiKey.key.slice(-4)}`,\n keywords: [apiKey.label, apiKey.user, apiKey.database],\n })),\n {\n value: \"create\",\n label: \"Create a new API key\",\n hint: \"Requires FileMaker credentials for this file\",\n keywords: [\"create\", \"new\"],\n },\n ],\n });\n\n if (selection === \"create\") {\n const username = await prompt.text({\n message: `Enter the account name for ${selectedFile}`,\n validate: (value) => (value ? undefined : \"An account name is required\"),\n });\n const password = await prompt.password({\n message: `Enter the password for ${username}`,\n validate: (value) => (value ? undefined : \"A password is required\"),\n });\n dataApiKey = (\n await fileMakerService.createDataAPIKeyWithCredentials({\n url: hostedUrl,\n filename: selectedFile,\n username,\n password,\n })\n ).apiKey;\n } else {\n dataApiKey = selection;\n }\n }\n\n if (!dataApiKey) {\n throw new Error(\"No FileMaker Data API key was selected.\");\n }\n\n const layouts = await fileMakerService.listLayouts({\n dataApiKey,\n fmFile: selectedFile,\n server: hostedUrl.origin,\n });\n\n if (layoutName && !layouts.includes(layoutName)) {\n throw new Error(`Layout \"${layoutName}\" was not found in ${selectedFile}.`);\n }\n\n if (!(nonInteractive || layoutName || schemaName)) {\n const shouldConfigureLayout = await prompt.confirm({\n message: \"Do you want to configure an initial layout for type generation now?\",\n initialValue: false,\n });\n\n if (shouldConfigureLayout) {\n layoutName = await prompt.searchSelect({\n message: \"Select a layout to read data from\",\n options: layouts.map((layout) => ({\n value: layout,\n label: layout,\n keywords: [layout],\n })),\n });\n\n schemaName = await prompt.text({\n message: \"What should the generated schema be called?\",\n defaultValue: getDefaultSchemaName(layoutName),\n validate: (value) => (value ? undefined : \"A schema name is required\"),\n });\n }\n }\n\n return {\n mode: \"hosted-otto\",\n dataSourceName: \"filemaker\",\n envNames: createDataSourceEnvNames(\"filemaker\"),\n server: hostedUrl.origin,\n fileName: selectedFile,\n dataApiKey,\n layoutName,\n schemaName,\n adminApiKey: flags.adminApiKey,\n fmsVersion: versions.fmsVersion,\n ottoVersion: versions.ottoVersion,\n };\n}\n\nasync function resolveFileMakerInputs({\n prompt,\n fileMakerService,\n flags,\n appType,\n nonInteractive,\n}: {\n prompt: PromptService;\n fileMakerService: FileMakerService;\n flags: CliFlags;\n appType: AppType;\n nonInteractive: boolean;\n}) {\n if (flags.dataSource !== \"filemaker\") {\n return { fileMaker: undefined, skipFileMakerSetup: false };\n }\n\n validateLayoutInputs(flags);\n\n if (appType === \"webviewer\" && !flags.server) {\n while (true) {\n const localFmMcp = await fileMakerService.detectLocalFmMcp();\n if (localFmMcp.healthy && localFmMcp.connectedFiles[0]) {\n return {\n fileMaker: {\n mode: \"local-fm-mcp\",\n dataSourceName: \"filemaker\",\n envNames: createDataSourceEnvNames(\"filemaker\"),\n fmMcpBaseUrl: localFmMcp.baseUrl,\n fileName: localFmMcp.connectedFiles[0],\n layoutName: flags.layoutName,\n schemaName: flags.schemaName,\n } satisfies FileMakerInputs,\n skipFileMakerSetup: false,\n };\n }\n\n if (nonInteractive) {\n if (localFmMcp.healthy) {\n throw new Error(\n \"ProofKit MCP Server was detected, but no FileMaker files are open. Open a file in FileMaker and rerun, or pass --server.\",\n );\n }\n\n throw new Error(\n \"ProofKit MCP Server was not detected and no FileMaker server was provided. Start the ProofKit MCP Server locally or rerun with --server.\",\n );\n }\n\n const fallbackAction = await prompt.select({\n message: localFmMcp.healthy\n ? \"I noticed you have the ProofKit MCP Server installed, but no files are open. How would you like to continue?\"\n : \"ProofKit MCP Server was not detected. How would you like to continue?\",\n options: [\n {\n value: \"retry\",\n label: \"Try again\",\n hint: localFmMcp.healthy\n ? \"Open a FileMaker file, then retry detection\"\n : \"Retry ProofKit MCP Server detection\",\n },\n {\n value: \"hosted\",\n label: \"Continue with hosted setup\",\n hint: \"Use OttoFMS and a hosted FileMaker server\",\n },\n {\n value: \"skip\",\n label: \"Skip for now\",\n hint: \"Create the project and configure FileMaker later\",\n },\n ],\n });\n\n if (fallbackAction === \"retry\") {\n continue;\n }\n\n if (fallbackAction === \"skip\") {\n return {\n fileMaker: undefined,\n skipFileMakerSetup: true,\n };\n }\n\n break;\n }\n }\n\n return {\n fileMaker: await resolveHostedFileMakerInputs({\n prompt,\n fileMakerService,\n flags,\n nonInteractive,\n }),\n skipFileMakerSetup: false,\n };\n}\n\nexport const resolveInitRequest = (name?: string, rawFlags?: CliFlags) =>\n Effect.gen(function* () {\n const flags = { ...defaultFlags, ...rawFlags };\n const prompt = yield* PromptService;\n const fileMakerService = yield* FileMakerService;\n const cliContext = yield* CliContext;\n const nonInteractive = cliContext.nonInteractive || flags.CI || flags.nonInteractive === true;\n\n let projectName = name;\n if (!projectName) {\n if (nonInteractive) {\n return yield* Effect.fail(new Error(\"Project name is required in non-interactive mode.\"));\n }\n\n projectName = yield* Effect.promise(() =>\n prompt.text({\n message: \"What will your project be called?\",\n defaultValue: DEFAULT_APP_NAME,\n validate: validateAppName,\n }),\n );\n }\n\n if (!projectName) {\n return yield* Effect.fail(new Error(\"Project name is required.\"));\n }\n\n const validationError = validateAppName(projectName);\n if (validationError) {\n return yield* Effect.fail(new Error(validationError));\n }\n\n let appType: AppType = flags.appType ?? \"browser\";\n if (!(flags.appType || nonInteractive)) {\n appType = yield* Effect.promise(() =>\n prompt.select({\n message: \"What kind of app do you want to build?\",\n options: [\n {\n value: \"browser\",\n label: \"Web App for Browsers\",\n hint: \"Uses Next.js and hosted deployment\",\n },\n {\n value: \"webviewer\",\n label: \"FileMaker Web Viewer\",\n hint: \"Uses Vite for FileMaker web viewers\",\n },\n ],\n }),\n ).pipe(Effect.map((value) => value as AppType));\n }\n\n const hasExplicitFileMakerInputs = Boolean(\n flags.server || flags.adminApiKey || flags.dataApiKey || flags.fileName || flags.layoutName || flags.schemaName,\n );\n\n let dataSource: DataSourceType = \"none\";\n if (flags.dataSource) {\n dataSource = flags.dataSource;\n } else if (appType === \"webviewer\") {\n dataSource = hasExplicitFileMakerInputs || !(nonInteractive && !flags.server) ? \"filemaker\" : \"none\";\n }\n\n if (!(nonInteractive || flags.dataSource) && appType !== \"webviewer\") {\n dataSource = yield* Effect.promise(() =>\n prompt.select({\n message: \"Do you want to connect to a FileMaker Database now?\",\n options: [\n {\n value: \"filemaker\",\n label: \"Yes\",\n hint: \"Set up env, datasource config, and typegen now\",\n },\n {\n value: \"none\",\n label: \"No\",\n hint: \"You can add a data source later\",\n },\n ],\n }),\n ).pipe(Effect.map((value) => value as DataSourceType));\n }\n\n if (nonInteractive && !flags.dataSource && hasExplicitFileMakerInputs) {\n return yield* Effect.fail(new Error(\"FileMaker flags require --data-source filemaker in non-interactive mode.\"));\n }\n\n if (nonInteractive && dataSource !== \"filemaker\" && hasExplicitFileMakerInputs) {\n return yield* Effect.fail(new Error(\"FileMaker flags require --data-source filemaker in non-interactive mode.\"));\n }\n\n const { fileMaker, skipFileMakerSetup } = yield* Effect.promise(() =>\n resolveFileMakerInputs({\n prompt,\n fileMakerService,\n flags: { ...flags, dataSource },\n appType,\n nonInteractive,\n }),\n );\n\n const [scopedAppName, appDir] = parseNameAndPath(projectName);\n\n return {\n projectName,\n scopedAppName,\n appDir,\n appType,\n ui: flags.ui ?? \"shadcn\",\n dataSource,\n packageManager: cliContext.packageManager,\n noInstall: flags.noInstall,\n noGit: flags.noGit,\n force: flags.force,\n cwd: cliContext.cwd,\n importAlias: flags.importAlias,\n nonInteractive,\n debug: cliContext.debug,\n fileMaker,\n skipFileMakerSetup,\n hasExplicitFileMakerInputs,\n } satisfies InitRequest;\n });\n","import open from \"open\";\n\nexport async function openBrowser(url: string): Promise<void> {\n try {\n await open(url);\n } catch {\n // Ignore open failures and let the user copy the URL manually.\n }\n}\n\nexport const openExternal: (url: string) => Promise<void> = openBrowser;\n","import https from \"node:https\";\nimport axios from \"axios\";\n\nfunction createHttpsAgent() {\n return new https.Agent({\n rejectUnauthorized: process.env.PROOFKIT_ALLOW_INSECURE_TLS !== \"1\",\n });\n}\n\nexport async function getJson<T>(url: string, options?: { headers?: Record<string, string>; timeout?: number }) {\n const response = await axios.get<T>(url, {\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeout ?? 10_000,\n validateStatus: null,\n });\n return response;\n}\n\nexport async function postJson<T>(\n url: string,\n data: unknown,\n options?: { headers?: Record<string, string>; timeout?: number },\n) {\n const response = await axios.post<T>(url, data, {\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeout ?? 10_000,\n validateStatus: null,\n });\n return response;\n}\n\nexport async function deleteJson(url: string, options?: { headers?: Record<string, string>; timeout?: number }) {\n const response = await axios.delete(url, {\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeout ?? 10_000,\n validateStatus: null,\n });\n return response;\n}\n\nexport async function requestJson<T>(\n url: string | URL,\n options?: {\n method?: \"GET\" | \"POST\" | \"DELETE\";\n headers?: Record<string, string>;\n body?: Record<string, unknown>;\n timeoutMs?: number;\n },\n) {\n const response = await axios.request<T>({\n url: url.toString(),\n method: options?.method ?? \"GET\",\n data: options?.body,\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeoutMs ?? 10_000,\n });\n return response;\n}\n\nexport async function requestText(\n url: string | URL,\n options?: {\n method?: \"GET\" | \"POST\" | \"DELETE\";\n headers?: Record<string, string>;\n timeoutMs?: number;\n },\n) {\n const response = await axios.request<string>({\n url: url.toString(),\n method: options?.method ?? \"GET\",\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeoutMs ?? 10_000,\n responseType: \"text\",\n validateStatus: null,\n });\n return {\n status: response.status,\n data: response.data,\n };\n}\n","export type PackageManager = \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n\nexport function detectUserPackageManager(): PackageManager {\n const userAgent = process.env.npm_config_user_agent;\n\n if (userAgent) {\n if (userAgent.startsWith(\"yarn\")) {\n return \"yarn\";\n }\n if (userAgent.startsWith(\"pnpm\")) {\n return \"pnpm\";\n }\n if (userAgent.startsWith(\"bun\")) {\n return \"bun\";\n }\n return \"npm\";\n }\n\n return \"npm\";\n}\n","import {\n intro as clackIntro,\n isCancel as clackIsCancel,\n log as clackLog,\n note as clackNote,\n outro as clackOutro,\n spinner as clackSpinner,\n} from \"@clack/prompts\";\nimport {\n checkbox as inquirerCheckbox,\n confirm as inquirerConfirm,\n input as inquirerInput,\n password as inquirerPassword,\n search as inquirerSearch,\n select as inquirerSelect,\n} from \"@inquirer/prompts\";\n\nconst CANCEL_SYMBOL = Symbol.for(\"@proofkit/new/prompt-cancelled\");\n\nexport const intro = clackIntro;\nexport const log = clackLog;\nexport const note = clackNote;\nexport const outro = clackOutro;\nexport const spinner = clackSpinner;\n\nfunction isPromptCancel(error: unknown) {\n return error instanceof Error && error.name === \"ExitPromptError\";\n}\n\nfunction withCancelSentinel<T>(fn: () => Promise<T>): Promise<T | symbol> {\n return fn().catch((error: unknown) => {\n if (isPromptCancel(error)) {\n return CANCEL_SYMBOL;\n }\n throw error;\n });\n}\n\nexport function isCancel(value: unknown): value is symbol {\n return value === CANCEL_SYMBOL || clackIsCancel(value);\n}\n\nexport interface PromptOption<T extends string> {\n value: T;\n label: string;\n hint?: string;\n disabled?: boolean | string;\n}\n\nexport interface SearchPromptOption<T extends string> extends PromptOption<T> {\n keywords?: readonly string[];\n}\n\nfunction normalizeValidate(\n validate: ((value: string) => string | undefined) | undefined,\n): ((value: string) => string | boolean) | undefined {\n if (!validate) {\n return undefined;\n }\n\n return (value: string) => validate(value) ?? true;\n}\n\nfunction matchesSearch(option: SearchPromptOption<string>, query: string) {\n const haystack = [option.label, option.hint ?? \"\", ...(option.keywords ?? [])].join(\" \").toLowerCase();\n return haystack.includes(query.trim().toLowerCase());\n}\n\nfunction normalizeDisabledMessage(value: boolean | string | undefined) {\n if (typeof value === \"string\") {\n return value;\n }\n return value ? true : undefined;\n}\n\nexport function filterSearchOptions<T extends string>(\n options: readonly SearchPromptOption<T>[],\n query: string | undefined,\n) {\n const term = query?.trim();\n if (!term) {\n return options;\n }\n\n return options.filter((option) => matchesSearch(option, term));\n}\n\nexport function textPrompt(options: {\n message: string;\n defaultValue?: string;\n validate?: (value: string) => string | undefined;\n}) {\n return withCancelSentinel(() =>\n inquirerInput({\n message: options.message,\n default: options.defaultValue,\n validate: normalizeValidate(options.validate),\n }),\n );\n}\n\nexport function passwordPrompt(options: { message: string; validate?: (value: string) => string | undefined }) {\n return withCancelSentinel(() =>\n inquirerPassword({\n message: options.message,\n validate: normalizeValidate(options.validate),\n }),\n );\n}\n\nexport function confirmPrompt(options: { message: string; initialValue?: boolean }) {\n return withCancelSentinel(() =>\n inquirerConfirm({\n message: options.message,\n default: options.initialValue,\n }),\n );\n}\n\nexport function selectPrompt<T extends string>(options: { message: string; options: PromptOption<T>[] }) {\n return withCancelSentinel(() =>\n inquirerSelect<T>({\n message: options.message,\n pageSize: 10,\n choices: options.options.map((option) => ({\n value: option.value,\n name: option.label,\n description: option.hint,\n disabled: normalizeDisabledMessage(option.disabled),\n })),\n }),\n );\n}\n\nexport function searchSelectPrompt<T extends string>(options: {\n message: string;\n emptyMessage?: string;\n options: SearchPromptOption<T>[];\n}) {\n return withCancelSentinel(() =>\n inquirerSearch<T>({\n message: options.message,\n pageSize: 10,\n source: (input) => {\n const filtered = filterSearchOptions(options.options, input);\n if (filtered.length === 0) {\n return [\n {\n value: \"__no_matches__\" as T,\n name: options.emptyMessage ?? \"No matches found. Keep typing to refine your search.\",\n disabled: options.emptyMessage ?? \"No matches found\",\n },\n ];\n }\n\n return filtered.map((option) => ({\n value: option.value,\n name: option.label,\n description: option.hint,\n disabled: normalizeDisabledMessage(option.disabled),\n }));\n },\n }),\n );\n}\n\nexport function multiSearchSelectPrompt<T extends string>(options: {\n message: string;\n options: SearchPromptOption<T>[];\n required?: boolean;\n}) {\n return withCancelSentinel(() =>\n inquirerCheckbox<T>({\n message: options.message,\n pageSize: 10,\n required: options.required,\n choices: options.options.map((option) => ({\n value: option.value,\n name: option.label,\n description: option.hint,\n disabled: normalizeDisabledMessage(option.disabled),\n })),\n }),\n );\n}\n","import { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport { Effect, Layer } from \"effect\";\nimport { execa } from \"execa\";\nimport fs from \"fs-extra\";\nimport { TEMPLATE_ROOT } from \"~/consts.js\";\nimport {\n CliContext,\n type CliContextValue,\n CodegenService,\n ConsoleService,\n type FileMakerBootstrapArtifacts,\n FileMakerService,\n FileSystemService,\n GitService,\n type OttoApiKeyInfo,\n type OttoFileInfo,\n PackageManagerService,\n ProcessService,\n PromptService,\n SettingsService,\n TemplateService,\n} from \"~/core/context.js\";\nimport { UserAbortedError } from \"~/core/errors.js\";\nimport type { AppType, FileMakerInputs, ProofKitSettings, UIType } from \"~/core/types.js\";\nimport { openBrowser } from \"~/utils/browserOpen.js\";\nimport { deleteJson, getJson, postJson } from \"~/utils/http.js\";\nimport { detectUserPackageManager } from \"~/utils/packageManager.js\";\nimport { createDataSourceEnvNames, updateEnvSchemaFile, updateTypegenConfig } from \"~/utils/projectFiles.js\";\nimport {\n confirmPrompt,\n spinner as createSpinner,\n isCancel,\n log,\n multiSearchSelectPrompt,\n note,\n passwordPrompt,\n searchSelectPrompt,\n selectPrompt,\n textPrompt,\n} from \"~/utils/prompts.js\";\n\nfunction unwrap<T>(value: T | symbol): T {\n if (isCancel(value)) {\n throw new UserAbortedError();\n }\n return value as T;\n}\n\nfunction normalizeUrl(serverUrl: string) {\n if (serverUrl.startsWith(\"https://\")) {\n return serverUrl;\n }\n if (serverUrl.startsWith(\"http://\")) {\n return serverUrl.replace(\"http://\", \"https://\");\n }\n return `https://${serverUrl}`;\n}\n\ninterface LayoutFolder {\n isFolder?: boolean;\n name?: string;\n folderLayoutNames?: LayoutFolder[];\n}\n\nfunction transformLayoutList(layouts: LayoutFolder[]): string[] {\n const flatten = (layout: LayoutFolder): string[] => {\n if (layout.isFolder === true) {\n const folderLayouts = Array.isArray(layout.folderLayoutNames) ? layout.folderLayoutNames : [];\n return folderLayouts.flatMap((item) => flatten(item));\n }\n return typeof layout.name === \"string\" ? [layout.name] : [];\n };\n\n return layouts.flatMap(flatten).sort((left, right) => left.localeCompare(right));\n}\n\nconst promptService = {\n text: async (options: { message: string; defaultValue?: string; validate?: (value: string) => string | undefined }) =>\n unwrap(\n await textPrompt({\n message: options.message,\n defaultValue: options.defaultValue,\n validate: options.validate,\n }),\n ).toString(),\n password: async (options: { message: string; validate?: (value: string) => string | undefined }) =>\n unwrap(\n await passwordPrompt({\n message: options.message,\n validate: options.validate,\n }),\n ).toString(),\n select: async <T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n }) =>\n unwrap(\n await selectPrompt({\n message: options.message,\n options: options.options,\n }),\n ) as T,\n searchSelect: async <T extends string>(options: {\n message: string;\n emptyMessage?: string;\n options: Array<{ value: T; label: string; hint?: string; keywords?: string[]; disabled?: boolean | string }>;\n }) => unwrap(await searchSelectPrompt(options)) as T,\n multiSearchSelect: async <T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string; keywords?: string[]; disabled?: boolean | string }>;\n required?: boolean;\n }) => unwrap(await multiSearchSelectPrompt(options)),\n confirm: async (options: { message: string; initialValue?: boolean }) =>\n unwrap(\n await confirmPrompt({\n message: options.message,\n initialValue: options.initialValue,\n }),\n ) as boolean,\n};\n\nconst consoleService = {\n info: (message: string) => log.info(message),\n warn: (message: string) => log.warn(message),\n error: (message: string) => log.error(message),\n success: (message: string) => log.success(message),\n note: (message: string, title?: string) => note(message, title),\n};\n\nconst fileSystemService = {\n exists: async (targetPath: string) => fs.pathExists(targetPath),\n readdir: async (targetPath: string) => fs.readdir(targetPath),\n emptyDir: async (targetPath: string) => fs.emptyDir(targetPath),\n copyDir: async (from: string, to: string, options?: { overwrite?: boolean }) =>\n fs.copy(from, to, { overwrite: options?.overwrite ?? true }),\n rename: async (from: string, to: string) => fs.rename(from, to),\n remove: async (targetPath: string) => fs.remove(targetPath),\n readJson: async <T>(targetPath: string) => fs.readJson(targetPath) as Promise<T>,\n writeJson: async (targetPath: string, value: unknown) => fs.writeJson(targetPath, value, { spaces: 2 }),\n writeFile: async (targetPath: string, content: string) => fs.writeFile(targetPath, content, \"utf8\"),\n readFile: async (targetPath: string) => fs.readFile(targetPath, \"utf8\"),\n};\n\nconst templateService = {\n getTemplateDir: (appType: AppType, ui: UIType) => {\n if (appType === \"webviewer\") {\n return path.join(TEMPLATE_ROOT, \"vite-wv\");\n }\n if (ui === \"mantine\") {\n return path.join(TEMPLATE_ROOT, \"nextjs-mantine\");\n }\n return path.join(TEMPLATE_ROOT, \"nextjs-shadcn\");\n },\n};\n\nconst packageManagerService = {\n getVersion: async (packageManager: string, cwd: string) => {\n if (packageManager === \"bun\") {\n return undefined;\n }\n const { stdout } = await execa(packageManager, [\"-v\"], { cwd });\n return stdout.trim();\n },\n};\n\nconst processService = {\n run: async (\n command: string,\n args: string[],\n options: {\n cwd: string;\n stdout?: \"pipe\" | \"inherit\" | \"ignore\";\n stderr?: \"pipe\" | \"inherit\" | \"ignore\";\n },\n ) => {\n const result = await execa(command, args, {\n cwd: options.cwd,\n stdout: options.stdout ?? \"pipe\",\n stderr: options.stderr ?? \"pipe\",\n });\n return {\n stdout: result.stdout ?? \"\",\n stderr: result.stderr ?? \"\",\n };\n },\n};\n\nconst gitService = {\n initialize: async (projectDir: string) => {\n await execa(\"git\", [\"init\"], { cwd: projectDir });\n await execa(\"git\", [\"add\", \".\"], { cwd: projectDir });\n await execa(\"git\", [\"commit\", \"-m\", \"Initial commit\"], { cwd: projectDir });\n },\n};\n\nconst settingsService = {\n writeSettings: async (projectDir: string, settings: ProofKitSettings) =>\n fs.writeJson(path.join(projectDir, \"proofkit.json\"), settings, { spaces: 2 }),\n appendEnvVars: async (projectDir: string, vars: Record<string, string>) => {\n const envPath = path.join(projectDir, \".env\");\n const existing = (await fs.pathExists(envPath)) ? await fs.readFile(envPath, \"utf8\") : \"\";\n const additions = Object.entries(vars)\n .map(([name, value]) => `${name}=${value}`)\n .join(\"\\n\");\n const nextContent = [existing.trimEnd(), additions].filter(Boolean).join(\"\\n\").concat(\"\\n\");\n await fs.writeFile(envPath, nextContent, \"utf8\");\n },\n ensureTypegenConfig: async (_projectDir: string, _options: { appType: AppType; fileMaker?: FileMakerInputs }) =>\n undefined,\n};\n\nfunction createDataSourceEntry(dataSourceName: string) {\n return {\n type: \"fm\" as const,\n name: dataSourceName,\n envNames: createDataSourceEnvNames(dataSourceName),\n };\n}\n\nfunction createFileMakerBootstrapArtifacts(\n settings: ProofKitSettings,\n inputs: FileMakerInputs,\n appType: AppType,\n): Promise<FileMakerBootstrapArtifacts> {\n const dataSourceEntry = createDataSourceEntry(inputs.dataSourceName);\n const nextSettings: ProofKitSettings = {\n ...settings,\n dataSources: settings.dataSources.some((entry) => entry.name === dataSourceEntry.name)\n ? settings.dataSources\n : [...settings.dataSources, dataSourceEntry],\n };\n\n if (inputs.mode === \"local-fm-mcp\") {\n return Promise.resolve({\n settings: nextSettings,\n envVars: {},\n envSchemaEntries: [],\n typegenConfig: {\n mode: inputs.mode,\n dataSourceName: inputs.dataSourceName,\n fmMcpBaseUrl: inputs.fmMcpBaseUrl,\n connectedFileName: inputs.fileName,\n layoutName: inputs.layoutName,\n schemaName: inputs.schemaName,\n appType,\n },\n });\n }\n\n return Promise.resolve({\n settings: nextSettings,\n envVars: {\n [inputs.envNames.database]: inputs.fileName,\n [inputs.envNames.server]: inputs.server,\n [inputs.envNames.apiKey]: inputs.dataApiKey,\n },\n envSchemaEntries: [\n {\n name: inputs.envNames.database,\n zodSchema: 'z.string().endsWith(\".fmp12\")',\n defaultValue: inputs.fileName,\n },\n {\n name: inputs.envNames.server,\n zodSchema: \"z.string().url()\",\n defaultValue: inputs.server,\n },\n {\n name: inputs.envNames.apiKey,\n zodSchema: 'z.string().startsWith(\"dk_\")',\n defaultValue: inputs.dataApiKey,\n },\n ],\n typegenConfig: {\n mode: inputs.mode,\n dataSourceName: inputs.dataSourceName,\n envNames: inputs.envNames,\n layoutName: inputs.layoutName,\n schemaName: inputs.schemaName,\n appType,\n },\n });\n}\n\nconst fileMakerService = {\n detectLocalFmMcp: async (baseUrl = process.env.FM_MCP_BASE_URL ?? \"http://127.0.0.1:1365\") => {\n try {\n const health = await fetch(`${baseUrl}/health`, { signal: AbortSignal.timeout(3000) });\n if (!health.ok) {\n return { baseUrl, healthy: false, connectedFiles: [] };\n }\n const connectedFiles = await fetch(`${baseUrl}/connectedFiles`, { signal: AbortSignal.timeout(3000) })\n .then(async (response) => (response.ok ? ((await response.json()) as unknown) : []))\n .catch(() => []);\n return {\n baseUrl,\n healthy: true,\n connectedFiles: Array.isArray(connectedFiles)\n ? connectedFiles.filter((item): item is string => typeof item === \"string\")\n : [],\n };\n } catch {\n return { baseUrl, healthy: false, connectedFiles: [] };\n }\n },\n validateHostedServerUrl: async (serverUrl: string, ottoPort?: number | null) => {\n const normalizedUrl = normalizeUrl(serverUrl);\n const fmsUrl = new URL(\"/fmws/serverinfo\", normalizedUrl).toString();\n const fmsResponse = await getJson<{ data?: { ServerVersion?: string } }>(fmsUrl);\n const serverVersion = fmsResponse.data?.data?.ServerVersion?.split(\" \")[0];\n if (!serverVersion) {\n throw new Error(`Invalid FileMaker Server URL: ${normalizedUrl}`);\n }\n\n let ottoVersion: string | null = null;\n const otto4Response = await getJson<{ response?: { Otto?: { version?: string } } }>(\n new URL(\"/otto/api/info\", normalizedUrl).toString(),\n ).catch(() => undefined);\n ottoVersion = otto4Response?.data?.response?.Otto?.version ?? null;\n\n if (!ottoVersion) {\n const otto3Url = new URL(normalizedUrl);\n otto3Url.port = ottoPort ? String(ottoPort) : \"3030\";\n otto3Url.pathname = \"/api/otto/info\";\n const otto3Response = await getJson<{ Otto?: { version?: string } }>(otto3Url.toString()).catch(() => undefined);\n ottoVersion = otto3Response?.data?.Otto?.version ?? null;\n }\n\n return {\n normalizedUrl: new URL(normalizedUrl).origin,\n versions: {\n fmsVersion: serverVersion,\n ottoVersion,\n },\n };\n },\n getOttoFMSToken: async ({ url }: { url: URL }) => {\n const hash = randomUUID().replaceAll(\"-\", \"\").slice(0, 18);\n const loginUrl = new URL(`/otto/wizard/${hash}`, url.origin);\n log.info(`If the browser window didn't open automatically, use this Otto login URL:\\n${loginUrl.toString()}`);\n await openBrowser(loginUrl.toString());\n\n const spin = createSpinner();\n spin.start(\"Waiting for OttoFMS login\");\n\n const deadline = Date.now() + 180_000;\n while (Date.now() < deadline) {\n const response = await getJson<{ response?: { token?: string } }>(\n `${url.origin}/otto/api/cli/checkHash/${hash}`,\n { headers: { \"Accept-Encoding\": \"deflate\" }, timeout: 5000 },\n ).catch(() => undefined);\n const token = response?.data?.response?.token;\n if (token) {\n spin.stop(\"Login complete\");\n await deleteJson(`${url.origin}/otto/api/cli/checkHash/${hash}`, {\n headers: { \"Accept-Encoding\": \"deflate\" },\n }).catch(() => undefined);\n return { token };\n }\n await new Promise((resolve) => setTimeout(resolve, 500));\n }\n\n spin.stop(\"Login timed out\");\n throw new Error(\"OttoFMS login timed out after 3 minutes.\");\n },\n listFiles: async ({ url, token }: { url: URL; token: string }) => {\n const response = await getJson<{ response?: { databases?: Array<{ filename?: string; status?: string }> } }>(\n `${url.origin}/otto/fmi/admin/api/v2/databases`,\n {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n },\n );\n const databases = (response.data?.response?.databases ?? []) as Record<string, unknown>[];\n return databases\n .filter((database): database is { filename: string; status?: string } => typeof database.filename === \"string\")\n .map(\n (database) =>\n ({\n filename: database.filename,\n status: database.status ?? \"unknown\",\n }) satisfies OttoFileInfo,\n );\n },\n listAPIKeys: async ({ url, token }: { url: URL; token: string }) => {\n const response = await getJson<{ response?: { \"api-keys\"?: Record<string, unknown>[] } }>(\n `${url.origin}/otto/api/api-key`,\n {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n },\n );\n const apiKeys = (response.data?.response?.[\"api-keys\"] ?? []) as Record<string, unknown>[];\n return apiKeys\n .filter(\n (apiKey): apiKey is { key: string; user: string; database: string; label: string } =>\n typeof apiKey.key === \"string\" &&\n typeof apiKey.user === \"string\" &&\n typeof apiKey.database === \"string\" &&\n typeof apiKey.label === \"string\",\n )\n .map(\n (apiKey) =>\n ({\n key: apiKey.key,\n user: apiKey.user,\n database: apiKey.database,\n label: apiKey.label,\n }) satisfies OttoApiKeyInfo,\n );\n },\n createDataAPIKeyWithCredentials: async ({\n url,\n filename,\n username,\n password: userPassword,\n }: {\n url: URL;\n filename: string;\n username: string;\n password: string;\n }) => {\n const response = await postJson<{ response?: { key?: string } }>(`${url.origin}/otto/api/api-key/create-only`, {\n database: filename,\n label: \"For FM Web App\",\n user: username,\n pass: userPassword,\n });\n const apiKey = response.data?.response?.key;\n if (!apiKey) {\n throw new Error(`Failed to create a Data API key for ${filename}.`);\n }\n return { apiKey };\n },\n startDeployment: async ({ payload, url, token }: { payload: unknown; url: URL; token: string }) =>\n postJson<{ response?: { subDeploymentIds?: number[] } }>(`${url.origin}/otto/api/deployment`, payload, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n }),\n getDeploymentStatus: async ({ url, token, deploymentId }: { url: URL; token: string; deploymentId: number }) =>\n getJson<{ response?: { status?: string; running?: boolean } }>(\n `${url.origin}/otto/api/deployment/${deploymentId}`,\n {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n },\n ),\n deployDemoFile: async ({ url, token, operation }: { url: URL; token: string; operation: \"install\" | \"replace\" }) => {\n const demoFileName = \"ProofKitDemo.fmp12\";\n const spin = createSpinner();\n spin.start(\"Deploying ProofKit Demo file\");\n\n const deploymentPayload = {\n scheduled: false,\n label: \"Install ProofKit Demo\",\n deployments: [\n {\n name: \"Install ProofKit Demo\",\n source: {\n type: \"url\",\n url: \"https://proofkit.dev/proofkit-demo/manifest.json\",\n },\n fileOperations: [\n {\n target: {\n fileName: demoFileName,\n },\n operation,\n source: {\n fileName: demoFileName,\n },\n location: {\n folder: \"default\",\n subFolder: \"\",\n },\n },\n ],\n concurrency: 1,\n options: {\n closeFilesAfterBuild: false,\n keepFilesClosedAfterComplete: false,\n transferContainerData: false,\n },\n },\n ],\n abortRemaining: false,\n };\n\n const deployment = await fileMakerService.startDeployment({\n payload: deploymentPayload,\n url,\n token,\n });\n\n const deploymentId = deployment.data?.response?.subDeploymentIds?.[0];\n if (!deploymentId) {\n spin.stop(\"Demo deployment failed\");\n throw new Error(\"No deployment ID was returned when deploying the demo file.\");\n }\n\n const deploymentDeadline = Date.now() + 300_000;\n let deploymentCompleted = false;\n while (Date.now() < deploymentDeadline) {\n await new Promise((resolve) => setTimeout(resolve, 2500));\n const status = await fileMakerService.getDeploymentStatus({\n url,\n token,\n deploymentId,\n });\n\n if (!status.data?.response?.running) {\n if (status.data?.response?.status !== \"complete\") {\n spin.stop(\"Demo deployment failed\");\n throw new Error(\"ProofKit Demo deployment did not complete successfully.\");\n }\n deploymentCompleted = true;\n break;\n }\n }\n\n if (!deploymentCompleted) {\n spin.stop(\"Demo deployment timed out\");\n throw new Error(\"ProofKit Demo deployment timed out after 5 minutes.\");\n }\n\n const apiKey = await fileMakerService.createDataAPIKeyWithCredentials({\n url,\n filename: demoFileName,\n username: \"admin\",\n password: \"admin\",\n });\n spin.stop(\"Demo file deployed\");\n return { apiKey: apiKey.apiKey, filename: demoFileName };\n },\n listLayouts: async ({ dataApiKey, fmFile, server }: { dataApiKey: string; fmFile: string; server: string }) => {\n const response = await getJson<{ response?: { layouts?: LayoutFolder[] } }>(\n `${server}/otto/fmi/data/vLatest/databases/${encodeURIComponent(fmFile)}/layouts`,\n {\n headers: {\n Authorization: `Bearer ${dataApiKey}`,\n },\n },\n );\n return transformLayoutList(response.data?.response?.layouts ?? []);\n },\n createFileMakerBootstrapArtifacts,\n bootstrap: async (projectDir: string, settings: ProofKitSettings, inputs: FileMakerInputs, appType: AppType) => {\n const artifacts = await createFileMakerBootstrapArtifacts(settings, inputs, appType);\n if (Object.keys(artifacts.envVars).length > 0) {\n await settingsService.appendEnvVars(projectDir, artifacts.envVars);\n await updateEnvSchemaFile(fileSystemService, projectDir, artifacts.envSchemaEntries);\n }\n\n await updateTypegenConfig(fileSystemService, projectDir, {\n appType: artifacts.typegenConfig.appType,\n dataSourceName: artifacts.typegenConfig.dataSourceName,\n envNames: artifacts.typegenConfig.envNames,\n fmMcpBaseUrl: artifacts.typegenConfig.fmMcpBaseUrl,\n connectedFileName: artifacts.typegenConfig.connectedFileName,\n layoutName: artifacts.typegenConfig.layoutName,\n schemaName: artifacts.typegenConfig.schemaName,\n });\n\n return artifacts.settings;\n },\n};\n\nconst codegenService = {\n runInitial: async (projectDir: string, packageManager: CliContextValue[\"packageManager\"]) => {\n let commandParts: string[];\n if (packageManager === \"npm\") {\n commandParts = [\"npm\", \"run\", \"typegen\"];\n } else if (packageManager === \"bun\") {\n commandParts = [\"bun\", \"run\", \"typegen\"];\n } else {\n commandParts = [packageManager, \"typegen\"];\n }\n const command = commandParts[0];\n if (!command) {\n throw new Error(\"Unable to resolve the codegen command\");\n }\n const args = commandParts.slice(1);\n await execa(command, args, { cwd: projectDir });\n },\n};\n\nexport function makeLiveLayer(options: { cwd: string; debug: boolean; nonInteractive: boolean }) {\n const cliContext: CliContextValue = {\n cwd: options.cwd,\n debug: options.debug,\n nonInteractive: options.nonInteractive,\n packageManager: detectUserPackageManager(),\n };\n\n const layer = Layer.mergeAll(\n Layer.succeed(CliContext, cliContext),\n Layer.succeed(PromptService, promptService),\n Layer.succeed(ConsoleService, consoleService),\n Layer.succeed(FileSystemService, fileSystemService),\n Layer.succeed(TemplateService, templateService),\n Layer.succeed(PackageManagerService, packageManagerService),\n Layer.succeed(ProcessService, processService),\n Layer.succeed(GitService, gitService),\n Layer.succeed(SettingsService, settingsService),\n Layer.succeed(FileMakerService, fileMakerService),\n Layer.succeed(CodegenService, codegenService),\n );\n\n return <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.provide(effect, layer);\n}\n","import gradient from \"gradient-string\";\nimport { getTitleText } from \"~/consts.js\";\nimport { detectUserPackageManager } from \"~/utils/packageManager.js\";\n\nconst proofTheme = {\n purple: \"#89216B\",\n lightPurple: \"#D15ABB\",\n orange: \"#FF595E\",\n};\n\nexport const proofGradient = gradient(Object.values(proofTheme));\nexport function renderTitle(version = \"0.0.0-private\") {\n const pkgManager = detectUserPackageManager();\n if (pkgManager === \"yarn\" || pkgManager === \"pnpm\") {\n console.log(\"\");\n }\n console.log(proofGradient.multiline(getTitleText(version)));\n}\n","#!/usr/bin/env node\nimport { readFileSync, realpathSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { optional as optionalArg, text as textArg, withDescription as withArgDescription } from \"@effect/cli/Args\";\nimport {\n make as makeCommand,\n run,\n withDescription as withCommandDescription,\n withSubcommands,\n} from \"@effect/cli/Command\";\nimport {\n boolean as booleanOption,\n choice as choiceOption,\n optional as optionalOption,\n text as textOption,\n withAlias,\n withDescription as withOptionDescription,\n} from \"@effect/cli/Options\";\nimport { isValidationError } from \"@effect/cli/ValidationError\";\nimport { layer as nodeContextLayer } from \"@effect/platform-node/NodeContext\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { getOrUndefined } from \"effect/Option\";\nimport { cliName } from \"~/consts.js\";\nimport {\n CliContext,\n ConsoleService,\n FileSystemService,\n PackageManagerService,\n TemplateService,\n} from \"~/core/context.js\";\nimport { executeInitPlan } from \"~/core/executeInitPlan.js\";\nimport { planInit } from \"~/core/planInit.js\";\nimport { resolveInitRequest } from \"~/core/resolveInitRequest.js\";\nimport type { CliFlags } from \"~/core/types.js\";\nimport { makeLiveLayer } from \"~/services/live.js\";\nimport { intro } from \"~/utils/prompts.js\";\nimport { proofGradient, renderTitle } from \"~/utils/renderTitle.js\";\n\nconst defaultCliFlags: CliFlags = {\n noGit: false,\n noInstall: false,\n force: false,\n default: false,\n CI: false,\n importAlias: \"~/\",\n};\n\nfunction getCliVersion() {\n try {\n const packageJsonUrl = new URL(\"../package.json\", import.meta.url);\n const packageJson = JSON.parse(readFileSync(fileURLToPath(packageJsonUrl), \"utf8\")) as { version?: string };\n return packageJson.version ?? \"0.0.0-private\";\n } catch {\n return \"0.0.0-private\";\n }\n}\n\nexport const runInit = (name?: string, rawFlags?: Partial<CliFlags>) =>\n Effect.gen(function* () {\n const templateService = yield* TemplateService;\n const packageManagerService = yield* PackageManagerService;\n const request = yield* resolveInitRequest(name, { ...defaultCliFlags, ...rawFlags });\n const templateDir = templateService.getTemplateDir(request.appType, request.ui);\n const packageManagerVersion = yield* Effect.promise(() =>\n packageManagerService.getVersion(request.packageManager, request.cwd),\n );\n const plan = planInit(request, { templateDir, packageManagerVersion });\n yield* executeInitPlan(plan);\n return { request, plan };\n });\n\nexport const runDefaultCommand = (rawFlags?: Partial<CliFlags>) =>\n Effect.gen(function* () {\n const cliContext = yield* CliContext;\n const fsService = yield* FileSystemService;\n const consoleService = yield* ConsoleService;\n const flags = { ...defaultCliFlags, ...rawFlags };\n\n if (cliContext.nonInteractive || flags.CI || flags.nonInteractive) {\n throw new Error(\n \"The default command is interactive-only in non-interactive mode. Run an explicit command such as `proofkit init <name> --non-interactive`.\",\n );\n }\n\n const settingsPath = path.join(cliContext.cwd, \"proofkit.json\");\n const hasProofKitProject = yield* Effect.promise(() => fsService.exists(settingsPath));\n\n if (hasProofKitProject) {\n intro(`Found ${proofGradient(\"ProofKit\")} project`);\n consoleService.note(\n [\n \"Project command routing is being migrated into the Effect CLI surface.\",\n \"Use an explicit command such as `proofkit add`, `proofkit remove`, `proofkit typegen`, `proofkit deploy`, or `proofkit upgrade`.\",\n ].join(\"\\n\"),\n \"Project commands\",\n );\n return;\n }\n\n intro(`No ${proofGradient(\"ProofKit\")} project found, running \\`init\\``);\n yield* runInit(undefined, {\n ...flags,\n default: true,\n });\n });\n\nconst initDirectoryArg = optionalArg(textArg({ name: \"dir\" })).pipe(\n withArgDescription(\"The project name or target directory\"),\n);\n\nfunction optionalTextOption(name: string, description: string) {\n return optionalOption(textOption(name).pipe(withOptionDescription(description)));\n}\n\nfunction optionalChoiceOption<Choices extends readonly string[]>(name: string, choices: Choices, description: string) {\n return optionalOption(choiceOption(name, choices).pipe(withOptionDescription(description)));\n}\n\nfunction legacyEffect<T>(runLegacy: () => Promise<T>, options?: { nonInteractive?: boolean; debug?: boolean }) {\n return makeLiveLayer({\n cwd: process.cwd(),\n debug: options?.debug === true,\n nonInteractive: options?.nonInteractive === true,\n })(Effect.promise(runLegacy));\n}\n\nfunction makeInitCommand() {\n return makeCommand(\n \"init\",\n {\n dir: initDirectoryArg,\n appType: optionalChoiceOption(\"app-type\", [\"browser\", \"webviewer\"] as const, \"The type of app to create\"),\n ui: optionalChoiceOption(\"ui\", [\"shadcn\", \"mantine\"] as const, \"The UI scaffold to create\"),\n server: optionalTextOption(\"server\", \"The URL of your FileMaker Server\"),\n adminApiKey: optionalTextOption(\"admin-api-key\", \"Admin API key for OttoFMS\"),\n fileName: optionalTextOption(\"file-name\", \"The name of the FileMaker file\"),\n layoutName: optionalTextOption(\"layout-name\", \"The FileMaker layout name to scaffold\"),\n schemaName: optionalTextOption(\"schema-name\", \"The generated schema name\"),\n dataApiKey: optionalTextOption(\"data-api-key\", \"The Otto Data API key to use\"),\n dataSource: optionalChoiceOption(\"data-source\", [\"filemaker\", \"none\"] as const, \"The data source to use\"),\n noGit: booleanOption(\"no-git\").pipe(withOptionDescription(\"Skip git initialization\")),\n noInstall: booleanOption(\"no-install\").pipe(withOptionDescription(\"Skip package installation\")),\n force: booleanOption(\"force\").pipe(\n withAlias(\"f\"),\n withOptionDescription(\"Force overwrite target directory when it already contains files\"),\n ),\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ dir, ...options }) => {\n const flags: CliFlags = {\n ...defaultCliFlags,\n appType: getOrUndefined(options.appType),\n ui: getOrUndefined(options.ui),\n server: getOrUndefined(options.server),\n adminApiKey: getOrUndefined(options.adminApiKey),\n fileName: getOrUndefined(options.fileName),\n layoutName: getOrUndefined(options.layoutName),\n schemaName: getOrUndefined(options.schemaName),\n dataApiKey: getOrUndefined(options.dataApiKey),\n dataSource: getOrUndefined(options.dataSource),\n noGit: options.noGit,\n noInstall: options.noInstall,\n force: options.force,\n CI: options.CI,\n nonInteractive: options.nonInteractive,\n debug: options.debug,\n };\n\n return makeLiveLayer({\n cwd: process.cwd(),\n debug: flags.debug === true,\n nonInteractive: Boolean(flags.CI || flags.nonInteractive),\n })(runInit(getOrUndefined(dir), flags));\n },\n ).pipe(withCommandDescription(\"Create a new project with ProofKit\"));\n}\n\nfunction makeAddCommand() {\n return makeCommand(\n \"add\",\n {\n name: optionalArg(textArg({ name: \"name\" })).pipe(withArgDescription(\"Component or registry item to add\")),\n target: optionalArg(textArg({ name: \"target\" })).pipe(withArgDescription(\"Optional add target\")),\n noInstall: booleanOption(\"no-install\").pipe(withOptionDescription(\"Skip package installation\")),\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ name, target, noInstall, CI, nonInteractive, debug }) =>\n legacyEffect(\n async () => {\n const [{ runAdd }, { initProgramState, state }] = await Promise.all([\n import(\"~/cli/add/index.js\"),\n import(\"~/state.js\"),\n ]);\n initProgramState({\n noInstall,\n ci: CI,\n nonInteractive,\n debug,\n });\n state.baseCommand = \"add\";\n state.projectDir = process.cwd();\n await runAdd(getOrUndefined(name), { noInstall, target: getOrUndefined(target) });\n },\n { nonInteractive: CI || nonInteractive, debug },\n ),\n ).pipe(withCommandDescription(\"Add a new component to your project\"));\n}\n\nfunction makeRemoveCommand() {\n return makeCommand(\n \"remove\",\n {\n name: optionalArg(textArg({ name: \"name\" })).pipe(withArgDescription(\"Component type to remove\")),\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ name, CI, nonInteractive, debug }) =>\n legacyEffect(\n async () => {\n const [{ runRemove }, { initProgramState, state }] = await Promise.all([\n import(\"~/cli/remove/index.js\"),\n import(\"~/state.js\"),\n ]);\n initProgramState({\n ci: CI,\n nonInteractive,\n debug,\n });\n state.baseCommand = \"remove\";\n state.projectDir = process.cwd();\n await runRemove(getOrUndefined(name));\n },\n { nonInteractive: CI || nonInteractive, debug },\n ),\n ).pipe(withCommandDescription(\"Remove a component from your project\"));\n}\n\nfunction makeTypegenCommand() {\n return makeCommand(\n \"typegen\",\n {\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ debug }) =>\n legacyEffect(\n async () => {\n const [{ runTypegen }, { state }] = await Promise.all([\n import(\"~/cli/typegen/index.js\"),\n import(\"~/state.js\"),\n ]);\n state.projectDir = process.cwd();\n await runTypegen({\n settings: (await import(\"~/utils/parseSettings.js\")).getSettings(),\n });\n },\n { debug },\n ),\n ).pipe(withCommandDescription(\"Generate types for your project\"));\n}\n\nfunction makeDeployCommand() {\n return makeCommand(\n \"deploy\",\n {\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ debug }) =>\n legacyEffect(\n async () => {\n const [{ runDeploy }, { initProgramState, state }] = await Promise.all([\n import(\"~/cli/deploy/index.js\"),\n import(\"~/state.js\"),\n ]);\n initProgramState({ debug });\n state.baseCommand = \"deploy\";\n state.projectDir = process.cwd();\n await runDeploy();\n },\n { debug },\n ),\n ).pipe(withCommandDescription(\"Deploy your app\"));\n}\n\nfunction makeUpgradeCommand() {\n return makeCommand(\n \"upgrade\",\n {\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ CI, nonInteractive, debug }) =>\n legacyEffect(\n async () => {\n const [{ runUpgrade }, { initProgramState, state }] = await Promise.all([\n import(\"~/cli/update/index.js\"),\n import(\"~/state.js\"),\n ]);\n initProgramState({ ci: CI, nonInteractive, debug });\n state.baseCommand = \"upgrade\";\n state.projectDir = process.cwd();\n await runUpgrade();\n },\n { nonInteractive: CI || nonInteractive, debug },\n ),\n ).pipe(withCommandDescription(\"Upgrade ProofKit components in your project\"));\n}\n\nconst rootCommand = makeCommand(\n cliName,\n {\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n (options) =>\n makeLiveLayer({\n cwd: process.cwd(),\n debug: options.debug === true,\n nonInteractive: Boolean(options.CI || options.nonInteractive),\n })(\n runDefaultCommand({\n ...defaultCliFlags,\n CI: options.CI,\n nonInteractive: options.nonInteractive,\n debug: options.debug,\n }),\n ),\n).pipe(\n withCommandDescription(\"Interactive CLI to scaffold and manage ProofKit projects\"),\n withSubcommands([\n makeInitCommand(),\n makeAddCommand(),\n makeRemoveCommand(),\n makeTypegenCommand(),\n makeDeployCommand(),\n makeUpgradeCommand(),\n ]),\n);\n\nexport const cli = run(rootCommand, {\n name: \"ProofKit\",\n version: getCliVersion(),\n});\n\nfunction isMainEntrypoint(argvPath: string | undefined, moduleUrl: string) {\n if (!argvPath) {\n return false;\n }\n\n const resolvedModulePath = fileURLToPath(moduleUrl);\n\n try {\n return realpathSync(argvPath) === realpathSync(resolvedModulePath);\n } catch {\n return path.resolve(argvPath) === path.resolve(resolvedModulePath);\n }\n}\n\nconst isMainModule = isMainEntrypoint(process.argv[1], import.meta.url);\n\nconst debugFlagNames = new Set([\"--debug\"]);\n\nfunction shouldShowDebugDetails(argv: readonly string[]) {\n return argv.some((arg) => debugFlagNames.has(arg));\n}\n\nfunction renderFailure(cause: Cause.Cause<unknown>, showDebugDetails: boolean) {\n const failure = getOrUndefined(Cause.failureOption(cause));\n\n if (!(failure && isValidationError(failure))) {\n const error = Cause.squash(cause);\n console.error(error instanceof Error ? error.message : String(error));\n }\n\n if (showDebugDetails) {\n console.error(`\\n[debug] ${Cause.pretty(cause)}`);\n }\n}\n\nasync function main(argv: readonly string[]) {\n const showDebugDetails = shouldShowDebugDetails(argv);\n const exit = await Effect.runPromiseExit(cli(argv).pipe(Effect.provide(nodeContextLayer)));\n\n if (Exit.isFailure(exit)) {\n renderFailure(exit.cause, showDebugDetails);\n process.exitCode = 1;\n }\n}\n\nif (isMainModule) {\n renderTitle(getCliVersion());\n main(process.argv).catch((error) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n });\n}\n"],"mappings":";kvCAgBA,MAAa,EAAa,EAAQ,WAA4B,2BAA2B,CA6B5E,EAAgB,EAAQ,WAA0B,8BAA8B,CAUhF,EAAiB,EAAQ,WAA2B,+BAA+B,CAenF,EAAoB,EAAQ,WAA8B,kCAAkC,CAM5F,GAAkB,EAAQ,WAA4B,gCAAgC,CAMtF,EAAwB,EAAQ,WAAkC,sCAAsC,CAcxG,GAAiB,EAAQ,WAA2B,+BAA+B,CAMnF,GAAa,EAAQ,WAAuB,2BAA2B,CAWvE,GAAkB,EAAQ,WAA4B,gCAAgC,CAwFtF,EAAmB,EAAQ,WAA6B,iCAAiC,CAMzF,GAAiB,EAAQ,WAA2B,+BAA+B,CC/MhG,IAAa,EAAb,cAAsC,KAAM,CAC1C,YAAY,EAAU,6BAA8B,CAClD,MAAM,EAAQ,CACd,KAAK,KAAO,qBCIhB,MAAM,GAAgC,CAAC,OAAQ,OAAQ,QAAS,OAAO,CACjE,GAAuB,QACvB,GAAqB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,EAA6B,EAA2B,CAC7E,IAAM,EAAU,EAAe,EAAM,cAAc,EAAM,CAAC,CAE1D,GAAI,EAAE,GAAW,GAAkB,EAAQ,EAAG,CAC5C,IAAM,EAAQ,EAAM,OAAO,EAAM,CACjC,QAAQ,MAAM,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAAC,CAGnE,GACF,QAAQ,MAAM,aAAa,EAAM,OAAO,EAAM,GAAG,CAIrD,eAAe,GAAK,EAAyB,CAC3C,IAAM,EAAmB,GAAuB,EAAK,CAC/C,EAAO,MAAM,EAAO,eAAe,GAAI,EAAK,CAAC,KAAK,EAAO,QAAQC,GAAiB,CAAC,CAAC,CAEtF,GAAK,UAAU,EAAK,GACtB,GAAc,EAAK,MAAO,EAAiB,CAC3C,QAAQ,SAAW,GAInB,KACF,GAAY,IAAe,CAAC,CAC5B,GAAK,QAAQ,KAAK,CAAC,MAAO,GAAU,CAClC,QAAQ,MAAM,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAAC,CACrE,QAAQ,SAAW,GACnB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["parseJsonc","parseDotenv","parseJsonc","chalk","promptEffect","intro","clackIntro","log","clackLog","note","clackNote","spinner","clackSpinner","isCancel","clackIsCancel","inquirerInput","inquirerPassword","inquirerConfirm","inquirerSelect","inquirerSearch","inquirerCheckbox","isCancel","log","note","fs","createSpinner","optionalArg","textArg","withArgDescription","optionalOption","textOption","withOptionDescription","choiceOption","makeCommand","booleanOption","withCommandDescription","nodeContextLayer"],"sources":["../src/core/context.ts","../src/core/doctor.ts","../src/utils/projectFiles.ts","../src/utils/versioning.ts","../src/core/planInit.ts","../src/core/executeInitPlan.ts","../src/core/prompt.ts","../src/utils/projectName.ts","../src/core/resolveInitRequest.ts","../src/utils/browserOpen.ts","../src/utils/http.ts","../src/utils/packageManager.ts","../src/utils/prompts.ts","../src/services/live.ts","../src/utils/nonInteractive.ts","../src/utils/renderTitle.ts","../src/index.ts"],"sourcesContent":["import type { Effect as Fx } from \"effect\";\nimport { Context } from \"effect\";\nimport type { CliError } from \"~/core/errors.js\";\nimport type { AppType, FileMakerEnvNames, FileMakerInputs, ProofKitSettings, UIType } from \"~/core/types.js\";\nimport type { PackageManager } from \"~/utils/packageManager.js\";\n\ntype Eff<A, E = never, R = never> = Fx.Effect<A, E, R>;\n\nexport interface CliContextValue {\n cwd: string;\n debug: boolean;\n nonInteractive: boolean;\n packageManager: PackageManager;\n resolvedProjectConfig?: {\n appType?: AppType;\n ui?: UIType;\n projectDir?: string;\n };\n}\n\nexport const CliContext = Context.GenericTag<CliContextValue>(\"@proofkit/cli/CliContext\");\n\nexport interface PromptService {\n readonly text: (options: {\n message: string;\n defaultValue?: string;\n validate?: (value: string) => string | undefined;\n }) => Promise<string>;\n readonly password: (options: {\n message: string;\n validate?: (value: string) => string | undefined;\n }) => Promise<string>;\n readonly select: <T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string; disabled?: boolean | string }>;\n }) => Promise<T>;\n readonly searchSelect: <T extends string>(options: {\n message: string;\n emptyMessage?: string;\n options: Array<{ value: T; label: string; hint?: string; keywords?: string[]; disabled?: boolean | string }>;\n }) => Promise<T>;\n readonly multiSearchSelect: <T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string; keywords?: string[]; disabled?: boolean | string }>;\n required?: boolean;\n }) => Promise<T[]>;\n readonly confirm: (options: { message: string; initialValue?: boolean }) => Promise<boolean>;\n}\n\nexport const PromptService = Context.GenericTag<PromptService>(\"@proofkit/cli/PromptService\");\n\nexport interface ConsoleService {\n readonly info: (message: string) => void;\n readonly warn: (message: string) => void;\n readonly error: (message: string) => void;\n readonly success: (message: string) => void;\n readonly note: (message: string, title?: string) => void;\n}\n\nexport const ConsoleService = Context.GenericTag<ConsoleService>(\"@proofkit/cli/ConsoleService\");\n\nexport interface FileSystemService {\n readonly exists: (path: string) => Eff<boolean, CliError>;\n readonly readdir: (path: string) => Eff<string[], CliError>;\n readonly emptyDir: (path: string) => Eff<void, CliError>;\n readonly copyDir: (from: string, to: string, options?: { overwrite?: boolean }) => Eff<void, CliError>;\n readonly rename: (from: string, to: string) => Eff<void, CliError>;\n readonly remove: (path: string) => Eff<void, CliError>;\n readonly readJson: <T>(path: string) => Eff<T, CliError>;\n readonly writeJson: (path: string, value: unknown) => Eff<void, CliError>;\n readonly writeFile: (path: string, content: string) => Eff<void, CliError>;\n readonly readFile: (path: string) => Eff<string, CliError>;\n}\n\nexport const FileSystemService = Context.GenericTag<FileSystemService>(\"@proofkit/cli/FileSystemService\");\n\nexport interface TemplateService {\n readonly getTemplateDir: (appType: AppType, ui: UIType) => string;\n}\n\nexport const TemplateService = Context.GenericTag<TemplateService>(\"@proofkit/cli/TemplateService\");\n\nexport interface PackageManagerService {\n readonly getVersion: (packageManager: PackageManager, cwd: string) => Eff<string | undefined, CliError>;\n}\n\nexport const PackageManagerService = Context.GenericTag<PackageManagerService>(\"@proofkit/cli/PackageManagerService\");\n\nexport interface ProcessService {\n readonly run: (\n command: string,\n args: string[],\n options: {\n cwd: string;\n stdout?: \"pipe\" | \"inherit\" | \"ignore\";\n stderr?: \"pipe\" | \"inherit\" | \"ignore\";\n },\n ) => Eff<{ stdout: string; stderr: string }, CliError>;\n}\n\nexport const ProcessService = Context.GenericTag<ProcessService>(\"@proofkit/cli/ProcessService\");\n\nexport interface GitService {\n readonly initialize: (projectDir: string) => Eff<void, CliError>;\n}\n\nexport const GitService = Context.GenericTag<GitService>(\"@proofkit/cli/GitService\");\n\nexport interface SettingsService {\n readonly writeSettings: (projectDir: string, settings: ProofKitSettings) => Eff<void, CliError>;\n readonly appendEnvVars: (projectDir: string, vars: Record<string, string>) => Eff<void, CliError>;\n}\n\nexport const SettingsService = Context.GenericTag<SettingsService>(\"@proofkit/cli/SettingsService\");\n\nexport interface FmMcpStatus {\n baseUrl: string;\n healthy: boolean;\n connectedFiles: string[];\n}\n\nexport interface FileMakerServerVersions {\n fmsVersion: string;\n ottoVersion: string | null;\n}\n\nexport interface OttoFileInfo {\n filename: string;\n status: string;\n}\n\nexport interface OttoApiKeyInfo {\n key: string;\n user: string;\n database: string;\n label: string;\n}\n\nexport interface FileMakerDataSourceEntry {\n type: \"fm\";\n name: string;\n envNames: FileMakerEnvNames;\n}\n\nexport interface FileMakerBootstrapArtifacts {\n settings: ProofKitSettings;\n envVars: Record<string, string>;\n envSchemaEntries: Array<{\n name: string;\n zodSchema: string;\n defaultValue: string;\n }>;\n typegenConfig: {\n mode: FileMakerInputs[\"mode\"];\n dataSourceName: string;\n envNames?: FileMakerEnvNames;\n fmMcpBaseUrl?: string;\n connectedFileName?: string;\n layoutName?: string;\n schemaName?: string;\n appType: AppType;\n };\n}\n\nexport interface FileMakerService {\n readonly detectLocalFmMcp: (baseUrl?: string) => Eff<FmMcpStatus, CliError>;\n readonly validateHostedServerUrl: (\n serverUrl: string,\n ottoPort?: number | null,\n ) => Eff<\n {\n normalizedUrl: string;\n versions: FileMakerServerVersions;\n },\n CliError\n >;\n readonly getOttoFMSToken: (options: { url: URL }) => Eff<{ token: string }, CliError>;\n readonly listFiles: (options: { url: URL; token: string }) => Eff<OttoFileInfo[], CliError>;\n readonly listAPIKeys: (options: { url: URL; token: string }) => Eff<OttoApiKeyInfo[], CliError>;\n readonly createDataAPIKeyWithCredentials: (options: {\n url: URL;\n filename: string;\n username: string;\n password: string;\n }) => Eff<{ apiKey: string }, CliError>;\n readonly deployDemoFile: (options: {\n url: URL;\n token: string;\n operation: \"install\" | \"replace\";\n }) => Eff<{ apiKey: string; filename: string }, CliError>;\n readonly listLayouts: (options: { dataApiKey: string; fmFile: string; server: string }) => Eff<string[], CliError>;\n readonly createFileMakerBootstrapArtifacts: (\n settings: ProofKitSettings,\n inputs: FileMakerInputs,\n appType: AppType,\n ) => Eff<FileMakerBootstrapArtifacts, CliError>;\n readonly bootstrap: (\n projectDir: string,\n settings: ProofKitSettings,\n inputs: FileMakerInputs,\n appType: AppType,\n ) => Eff<ProofKitSettings, CliError>;\n}\n\nexport const FileMakerService = Context.GenericTag<FileMakerService>(\"@proofkit/cli/FileMakerService\");\n\nexport interface CodegenService {\n readonly runInitial: (projectDir: string, packageManager: PackageManager) => Eff<void, CliError>;\n}\n\nexport const CodegenService = Context.GenericTag<CodegenService>(\"@proofkit/cli/CodegenService\");\n","import path from \"node:path\";\nimport { parse as parseDotenv } from \"dotenv\";\nimport { Effect } from \"effect\";\nimport { parse as parseJsonc } from \"jsonc-parser\";\nimport { DOCS_URL } from \"~/consts.js\";\nimport { CliContext, ConsoleService, FileSystemService } from \"~/core/context.js\";\n\ninterface TypegenConfigEntry {\n type?: string;\n path?: string;\n fmMcp?: { enabled?: boolean; connectedFileName?: string };\n layouts?: unknown[];\n tables?: unknown[];\n envNames?: {\n server?: string;\n db?: string;\n auth?: {\n apiKey?: string;\n username?: string;\n password?: string;\n };\n };\n}\n\nfunction pushUnique(target: string[], value: string | undefined) {\n if (value && !target.includes(value)) {\n target.push(value);\n }\n}\n\nfunction isTypegenConfigLike(value: unknown): value is {\n config: TypegenConfigEntry | TypegenConfigEntry[];\n} {\n return value !== null && typeof value === \"object\" && \"config\" in value;\n}\n\nexport const runDoctor = Effect.gen(function* () {\n const cliContext = yield* CliContext;\n const fs = yield* FileSystemService;\n const consoleService = yield* ConsoleService;\n const cwd = cliContext.cwd;\n const readJsonSafe = <T>(targetPath: string) =>\n fs.readJson<T>(targetPath).pipe(\n Effect.match({\n onFailure: () => undefined,\n onSuccess: (value) => value,\n }),\n );\n const readFileSafe = (targetPath: string) =>\n fs.readFile(targetPath).pipe(\n Effect.match({\n onFailure: () => undefined,\n onSuccess: (value) => value,\n }),\n );\n\n const settingsPath = path.join(cwd, \"proofkit.json\");\n if (!(yield* fs.exists(settingsPath))) {\n consoleService.note(\n [\n \"No ProofKit project found in this directory.\",\n \"\",\n \"Next steps:\",\n \"- Run `proofkit init` to create a new project\",\n `- Docs: ${DOCS_URL}/docs/cli`,\n ].join(\"\\n\"),\n \"Doctor\",\n );\n return;\n }\n\n const findings: { level: \"ok\" | \"warn\" | \"error\"; message: string }[] = [];\n\n let settings:\n | {\n appType?: string;\n envFile?: string;\n dataSources?: {\n type?: string;\n envNames?: {\n database?: string;\n server?: string;\n apiKey?: string;\n };\n }[];\n }\n | undefined;\n\n settings = yield* readJsonSafe<typeof settings>(settingsPath);\n if (settings) {\n findings.push({ level: \"ok\", message: \"Found `proofkit.json`.\" });\n } else {\n findings.push({ level: \"error\", message: \"Could not read `proofkit.json`.\" });\n }\n\n const packageJsonPath = path.join(cwd, \"package.json\");\n let packageJson:\n | {\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n }\n | undefined;\n\n if (yield* fs.exists(packageJsonPath)) {\n const nextPackageJson = yield* readJsonSafe<NonNullable<typeof packageJson>>(packageJsonPath);\n if (nextPackageJson) {\n packageJson = nextPackageJson;\n const allDeps = {\n ...(nextPackageJson.dependencies ?? {}),\n ...(nextPackageJson.devDependencies ?? {}),\n };\n\n if (allDeps[\"@proofkit/typegen\"]) {\n findings.push({ level: \"ok\", message: \"Found `@proofkit/typegen`.\" });\n } else {\n findings.push({ level: \"warn\", message: \"Missing `@proofkit/typegen` dependency.\" });\n }\n\n if (nextPackageJson.scripts?.typegen) {\n findings.push({ level: \"ok\", message: \"Found `typegen` script.\" });\n } else {\n findings.push({ level: \"warn\", message: \"Missing `typegen` script in `package.json`.\" });\n }\n\n if (nextPackageJson.scripts?.[\"typegen:ui\"]) {\n findings.push({ level: \"ok\", message: \"Found `typegen:ui` script.\" });\n }\n } else {\n findings.push({ level: \"error\", message: \"Could not read `package.json`.\" });\n }\n } else {\n findings.push({ level: \"error\", message: \"Missing `package.json`.\" });\n }\n\n const typegenConfigPath = path.join(cwd, \"proofkit-typegen.config.jsonc\");\n let parsedTypegenConfig:\n | {\n config: TypegenConfigEntry | TypegenConfigEntry[];\n }\n | undefined;\n\n if (yield* fs.exists(typegenConfigPath)) {\n const raw = yield* readFileSafe(typegenConfigPath);\n if (raw) {\n const parsed = parseJsonc(raw);\n if (isTypegenConfigLike(parsed)) {\n parsedTypegenConfig = parsed;\n findings.push({ level: \"ok\", message: \"Typegen config is present and valid.\" });\n\n const configEntries = Array.isArray(parsed.config) ? parsed.config : [parsed.config];\n for (const entry of configEntries) {\n const outputPath = path.join(cwd, entry.path ?? \"schema\");\n if (yield* fs.exists(outputPath)) {\n findings.push({ level: \"ok\", message: `Generated path exists: \\`${entry.path ?? \"schema\"}\\`.` });\n } else {\n findings.push({\n level: \"warn\",\n message: `Generated path missing: \\`${entry.path ?? \"schema\"}\\`. Run \\`npx @proofkit/typegen\\`.`,\n });\n }\n\n if (entry.type === \"fmdapi\" && (entry.layouts?.length ?? 0) === 0) {\n findings.push({\n level: \"warn\",\n message: \"Typegen config has no layouts yet. Use `npx @proofkit/typegen ui`.\",\n });\n }\n\n if (entry.type === \"fmodata\" && (entry.tables?.length ?? 0) === 0) {\n findings.push({\n level: \"warn\",\n message: \"Typegen config has no tables yet. Use `npx @proofkit/typegen ui`.\",\n });\n }\n\n if (entry.type === \"fmdapi\" && entry.fmMcp?.enabled && !entry.fmMcp.connectedFileName) {\n findings.push({\n level: \"warn\",\n message: \"FM MCP is enabled but no connected file is pinned yet.\",\n });\n }\n }\n } else {\n findings.push({\n level: \"error\",\n message: \"Typegen config exists but is invalid. Open `npx @proofkit/typegen ui` or fix the JSONC file.\",\n });\n }\n } else {\n findings.push({ level: \"error\", message: \"Could not read `proofkit-typegen.config.jsonc`.\" });\n }\n } else {\n findings.push({\n level: \"warn\",\n message: \"Missing `proofkit-typegen.config.jsonc`. Run `npx @proofkit/typegen init`.\",\n });\n }\n\n const envCandidates = [\n settings?.envFile ? path.join(cwd, settings.envFile) : undefined,\n path.join(cwd, \".env.local\"),\n path.join(cwd, \".env\"),\n ].filter((value): value is string => Boolean(value));\n\n let resolvedEnvPath: string | undefined;\n for (const candidate of envCandidates) {\n if (yield* fs.exists(candidate)) {\n resolvedEnvPath = candidate;\n break;\n }\n }\n\n const expectedEnvNames: string[] = [];\n for (const source of settings?.dataSources ?? []) {\n if (source.type !== \"fm\") {\n continue;\n }\n pushUnique(expectedEnvNames, source.envNames?.server);\n pushUnique(expectedEnvNames, source.envNames?.database);\n pushUnique(expectedEnvNames, source.envNames?.apiKey);\n }\n\n let configEntries: TypegenConfigEntry[] = [];\n if (parsedTypegenConfig) {\n configEntries = Array.isArray(parsedTypegenConfig.config)\n ? parsedTypegenConfig.config\n : [parsedTypegenConfig.config];\n }\n\n for (const entry of configEntries) {\n pushUnique(expectedEnvNames, entry.envNames?.server);\n pushUnique(expectedEnvNames, entry.envNames?.db);\n pushUnique(expectedEnvNames, entry.envNames?.auth?.apiKey);\n pushUnique(expectedEnvNames, entry.envNames?.auth?.username);\n pushUnique(expectedEnvNames, entry.envNames?.auth?.password);\n }\n\n if (expectedEnvNames.length > 0) {\n if (resolvedEnvPath) {\n const envRaw = yield* readFileSafe(resolvedEnvPath);\n if (envRaw) {\n const env = parseDotenv(envRaw);\n const missing = expectedEnvNames.filter((name) => !(name in env));\n if (missing.length > 0) {\n findings.push({\n level: \"warn\",\n message: `Missing env vars in \\`${path.basename(resolvedEnvPath)}\\`: ${missing.join(\", \")}.`,\n });\n } else {\n findings.push({\n level: \"ok\",\n message: `Expected env vars found in \\`${path.basename(resolvedEnvPath)}\\`.`,\n });\n }\n } else {\n findings.push({ level: \"error\", message: `Could not read env file \\`${path.basename(resolvedEnvPath)}\\`.` });\n }\n } else {\n findings.push({\n level: \"warn\",\n message: `No env file found. Expected vars: ${expectedEnvNames.join(\", \")}.`,\n });\n }\n }\n\n const errors = findings.filter((finding) => finding.level === \"error\");\n const warnings = findings.filter((finding) => finding.level === \"warn\");\n const oks = findings.filter((finding) => finding.level === \"ok\");\n\n const lines = [\n `Checks: ${oks.length} ok, ${warnings.length} warn, ${errors.length} error`,\n \"\",\n ...findings.map((finding) => {\n let prefix = \"ERR\";\n if (finding.level === \"ok\") {\n prefix = \"OK\";\n } else if (finding.level === \"warn\") {\n prefix = \"WARN\";\n }\n return `- [${prefix}] ${finding.message}`;\n }),\n \"\",\n \"Next steps:\",\n \"- Run `npx @proofkit/typegen init` if typegen config is missing\",\n \"- Run `npx @proofkit/typegen ui` to edit typegen config\",\n \"- Run `npx @proofkit/typegen` to regenerate generated files\",\n `- Docs: ${DOCS_URL}/docs/typegen`,\n ];\n\n if (settings?.appType === \"webviewer\") {\n lines.splice(lines.length - 1, 0, \"- For webviewer projects, make sure local FM MCP is running before typegen\");\n }\n\n consoleService.note(lines.join(\"\\n\"), \"Doctor\");\n});\n","import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { applyEdits, modify, parse as parseJsonc } from \"jsonc-parser\";\nimport { PKG_ROOT } from \"~/consts.js\";\nimport type { FileMakerEnvNames } from \"~/core/types.js\";\nimport type { PackageManager } from \"~/utils/packageManager.js\";\n\nconst commonFileMakerLayoutPrefixes = [\"API_\", \"API \", \"dapi_\", \"dapi\"];\nconst TRAILING_SLASH_REGEX = /[^/]$/;\nconst textFileExtensions = new Set([\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \".json\",\n \".jsonc\",\n \".md\",\n \".css\",\n \".scss\",\n \".html\",\n \".mjs\",\n \".cjs\",\n]);\n\nexport function getDefaultSchemaName(layoutName: string) {\n let schemaName = layoutName.replace(/[-\\s]/g, \"_\");\n for (const prefix of commonFileMakerLayoutPrefixes) {\n if (schemaName.startsWith(prefix)) {\n schemaName = schemaName.replace(prefix, \"\");\n }\n }\n return schemaName;\n}\n\nexport function createDataSourceEnvNames(dataSourceName: string): FileMakerEnvNames {\n if (dataSourceName === \"filemaker\") {\n return {\n database: \"FM_DATABASE\",\n server: \"FM_SERVER\",\n apiKey: \"OTTO_API_KEY\",\n };\n }\n\n const upperName = dataSourceName.toUpperCase();\n return {\n database: `${upperName}_FM_DATABASE`,\n server: `${upperName}_FM_SERVER`,\n apiKey: `${upperName}_OTTO_API_KEY`,\n };\n}\n\nexport function formatPackageManagerCommand(packageManager: PackageManager, command: string) {\n return [\"npm\", \"bun\"].includes(packageManager) ? `${packageManager} run ${command}` : `${packageManager} ${command}`;\n}\n\nexport function getTemplatePackageCommand(packageManager: PackageManager) {\n if (packageManager === \"npm\") {\n return \"npm run\";\n }\n return packageManager;\n}\n\nexport function normalizeImportAlias(importAlias: string) {\n return importAlias.replace(/\\*/g, \"\").replace(TRAILING_SLASH_REGEX, \"$&/\");\n}\n\nexport async function replaceTextInFiles(\n fs: {\n readdir: (path: string) => Promise<string[]>;\n readFile: (path: string) => Promise<string>;\n writeFile: (path: string, content: string) => Promise<void>;\n },\n rootDir: string,\n searchValue: string,\n replaceValue: string,\n) {\n const entries = await fs.readdir(rootDir);\n for (const entry of entries) {\n const fullPath = path.join(rootDir, entry);\n const childEntries = await fs.readdir(fullPath).catch((error: unknown) => {\n const code =\n typeof error === \"object\" && error !== null && \"code\" in error && typeof error.code === \"string\"\n ? error.code\n : undefined;\n\n if (code === \"ENOTDIR\") {\n return undefined;\n }\n\n throw error;\n });\n if (childEntries) {\n await replaceTextInFiles(fs, fullPath, searchValue, replaceValue);\n continue;\n }\n\n const extension = path.extname(entry);\n if (!textFileExtensions.has(extension)) {\n continue;\n }\n\n const content = await fs.readFile(fullPath).catch(() => undefined);\n if (!content?.includes(searchValue)) {\n continue;\n }\n\n await fs.writeFile(fullPath, content.replaceAll(searchValue, replaceValue));\n }\n}\n\nexport async function updateEnvSchemaFile(\n fs: {\n exists: (path: string) => Promise<boolean>;\n readFile: (path: string) => Promise<string>;\n writeFile: (path: string, content: string) => Promise<void>;\n },\n projectDir: string,\n envEntries: Array<{ name: string; zodSchema: string }>,\n) {\n const envFilePath = path.join(projectDir, \"src/lib/env.ts\");\n if (!(await fs.exists(envFilePath))) {\n return;\n }\n\n let content = await fs.readFile(envFilePath);\n const marker = \" server: {\";\n const markerIndex = content.indexOf(marker);\n if (markerIndex === -1) {\n return;\n }\n\n const insertIndex = content.indexOf(\" },\", markerIndex);\n if (insertIndex === -1) {\n return;\n }\n\n const additions = envEntries\n .filter((entry) => !content.includes(`${entry.name}:`))\n .map((entry) => ` ${entry.name}: ${entry.zodSchema},`)\n .join(\"\\n\");\n\n if (!additions) {\n return;\n }\n\n content = `${content.slice(0, insertIndex)}${additions}\\n${content.slice(insertIndex)}`;\n await fs.writeFile(envFilePath, content);\n}\n\ninterface TypegenFileContent {\n $schema?: string;\n config: Record<string, unknown>[] | Record<string, unknown>;\n}\n\nexport async function updateTypegenConfig(\n fs: {\n exists: (path: string) => Promise<boolean>;\n readFile: (path: string) => Promise<string>;\n writeFile: (path: string, content: string) => Promise<void>;\n },\n projectDir: string,\n options: {\n appType: \"browser\" | \"webviewer\";\n dataSourceName: string;\n envNames?: FileMakerEnvNames;\n fmMcpBaseUrl?: string;\n connectedFileName?: string;\n layoutName?: string;\n schemaName?: string;\n },\n) {\n const configPath = path.join(projectDir, \"proofkit-typegen.config.jsonc\");\n const dsPath = `./src/config/schemas/${options.dataSourceName}`;\n const nextDataSource: Record<string, unknown> = {\n type: \"fmdapi\",\n layouts: [],\n path: dsPath,\n clearOldFiles: true,\n clientSuffix: \"Layout\",\n };\n\n if (options.envNames) {\n nextDataSource.envNames = {\n server: options.envNames.server,\n db: options.envNames.database,\n auth: { apiKey: options.envNames.apiKey },\n };\n }\n\n if (options.appType === \"webviewer\") {\n nextDataSource.webviewerScriptName = \"ExecuteDataApi\";\n }\n\n if (options.fmMcpBaseUrl) {\n nextDataSource.fmMcp = {\n enabled: true,\n baseUrl: options.fmMcpBaseUrl,\n ...(options.connectedFileName ? { connectedFileName: options.connectedFileName } : {}),\n };\n }\n\n const layout =\n options.layoutName && options.schemaName\n ? {\n layoutName: options.layoutName,\n schemaName: options.schemaName,\n valueLists: \"allowEmpty\",\n }\n : undefined;\n\n if (layout) {\n nextDataSource.layouts = [layout];\n }\n\n if (!(await fs.exists(configPath))) {\n const nextContent: TypegenFileContent = {\n $schema: \"https://proofkit.dev/typegen-config-schema.json\",\n config: [nextDataSource],\n };\n await fs.writeFile(configPath, `${JSON.stringify(nextContent, null, 2)}\\n`);\n return;\n }\n\n const original = await fs.readFile(configPath);\n const parsed = parseJsonc(original) as TypegenFileContent;\n const configArray = Array.isArray(parsed.config) ? parsed.config : [parsed.config];\n const existingIndex = configArray.findIndex((entry) => entry.path === dsPath);\n\n if (existingIndex === -1) {\n configArray.push(nextDataSource);\n } else {\n const existing = (configArray[existingIndex] ?? {}) as Record<string, unknown>;\n const existingLayouts = Array.isArray(existing.layouts) ? existing.layouts : [];\n let nextLayouts = existingLayouts;\n if (layout && !existingLayouts.some((item) => item?.layoutName === layout.layoutName)) {\n nextLayouts = [...existingLayouts, layout];\n }\n configArray[existingIndex] = {\n ...existing,\n ...nextDataSource,\n layouts: nextLayouts,\n };\n }\n\n const nextConfig = Array.isArray(parsed.config) ? configArray : (configArray[0] ?? nextDataSource);\n const edits = modify(original, [\"config\"], nextConfig, {\n formattingOptions: {\n insertSpaces: true,\n tabSize: 2,\n eol: \"\\n\",\n },\n });\n await fs.writeFile(configPath, applyEdits(original, edits));\n}\n\nexport function getScaffoldVersion() {\n const candidates = [path.resolve(PKG_ROOT, \"package.json\"), path.resolve(PKG_ROOT, \"../cli/package.json\")];\n\n for (const candidate of candidates) {\n try {\n const packageJson = JSON.parse(readFileSync(candidate, \"utf8\")) as { version?: string };\n if (packageJson.version && packageJson.version !== \"0.0.0-private\") {\n return packageJson.version;\n }\n } catch {\n // ignore and continue searching\n }\n }\n\n return \"0.0.0-private\";\n}\n","export function getProofkitReleaseTag() {\n return \"beta\";\n}\n\nexport function getNodeMajorVersion() {\n return process.versions.node.split(\".\")[0] ?? \"22\";\n}\n","import path from \"node:path\";\nimport type { PackageJson } from \"type-fest\";\n\nimport type { InitPlan, InitRequest, ProofKitSettings } from \"~/core/types.js\";\nimport { formatPackageManagerCommand, getScaffoldVersion, getTemplatePackageCommand } from \"~/utils/projectFiles.js\";\nimport { getNodeMajorVersion, getProofkitReleaseTag } from \"~/utils/versioning.js\";\n\nfunction createDefaultSettings(request: InitRequest): ProofKitSettings {\n return {\n ui: request.ui,\n appType: request.appType,\n envFile: \".env\",\n dataSources: [],\n replacedMainPage: false,\n registryTemplates: [],\n };\n}\n\nfunction createEnvFileContent() {\n return [\"# When adding additional environment variables, update the schema alongside this file.\", \"\"].join(\"\\n\");\n}\n\nconst sharedUiDependencies = {\n \"@radix-ui/react-slot\": \"^1.2.3\",\n \"class-variance-authority\": \"^0.7.1\",\n clsx: \"^2.1.1\",\n \"lucide-react\": \"^0.577.0\",\n \"tailwind-merge\": \"^3.5.0\",\n tailwindcss: \"^4.1.10\",\n \"tw-animate-css\": \"^1.4.0\",\n} satisfies Record<string, string>;\n\nexport function planInit(\n request: InitRequest,\n options: { templateDir: string; packageManagerVersion?: string },\n): InitPlan {\n const targetDir = path.resolve(request.cwd, request.appDir);\n const releaseTag = getProofkitReleaseTag();\n const settings = createDefaultSettings(request);\n const packageManagerCommand = getTemplatePackageCommand(request.packageManager);\n\n const packageJson: InitPlan[\"packageJson\"] = {\n name: request.scopedAppName,\n packageManager: options.packageManagerVersion\n ? `${request.packageManager}@${options.packageManagerVersion}`\n : undefined,\n proofkitMetadata: {\n initVersion: getScaffoldVersion(),\n scaffoldPackage: \"@proofkit/cli\",\n },\n dependencies: {},\n devDependencies: {\n \"@proofkit/cli\": releaseTag,\n \"@types/node\": `^${getNodeMajorVersion()}`,\n },\n };\n\n if (request.appType === \"browser\") {\n Object.assign(packageJson.dependencies, sharedUiDependencies);\n packageJson.dependencies[\"@tailwindcss/postcss\"] = \"^4.1.10\";\n packageJson.dependencies[\"next-themes\"] = \"^0.4.6\";\n }\n\n if (request.appType === \"webviewer\") {\n Object.assign(packageJson.dependencies, sharedUiDependencies);\n packageJson.dependencies[\"@proofkit/fmdapi\"] = releaseTag;\n packageJson.dependencies[\"@proofkit/webviewer\"] = releaseTag;\n packageJson.dependencies[\"@tanstack/react-query\"] = \"^5.90.21\";\n packageJson.dependencies[\"@tanstack/react-router\"] = \"^1.167.4\";\n packageJson.dependencies.zod = \"^4\";\n packageJson.devDependencies[\"@proofkit/typegen\"] = releaseTag;\n packageJson.devDependencies[\"@tailwindcss/vite\"] = \"^4.2.1\";\n packageJson.devDependencies.ultracite = \"7.0.8\";\n }\n\n return {\n request,\n targetDir,\n templateDir: options.templateDir,\n packageManagerCommand,\n packageJson,\n settings,\n envFile: {\n path: path.join(targetDir, \".env\"),\n content: createEnvFileContent(),\n },\n writes: [],\n commands: [\n ...(request.noInstall ? [] : [{ type: \"install\" as const }]),\n ...(request.dataSource === \"filemaker\" &&\n !request.skipFileMakerSetup &&\n !(request.appType === \"webviewer\" && request.nonInteractive && !request.hasExplicitFileMakerInputs)\n ? [{ type: \"codegen\" as const }]\n : []),\n ...(request.noGit ? [] : [{ type: \"git-init\" as const }]),\n ],\n tasks: {\n bootstrapFileMaker: request.dataSource === \"filemaker\" && !request.skipFileMakerSetup,\n checkWebViewerAddon: request.appType === \"webviewer\",\n runInstall: !request.noInstall,\n runInitialCodegen:\n request.dataSource === \"filemaker\" &&\n !request.skipFileMakerSetup &&\n !(request.appType === \"webviewer\" && request.nonInteractive && !request.hasExplicitFileMakerInputs),\n initializeGit: !request.noGit,\n },\n nextSteps: [\n `cd ${request.appDir}`,\n ...(request.noInstall ? [request.packageManager === \"yarn\" ? \"yarn\" : `${request.packageManager} install`] : []),\n \"npx @tanstack/intent@latest install\",\n formatPackageManagerCommand(request.packageManager, \"dev\"),\n ...(request.appType === \"webviewer\"\n ? [\n formatPackageManagerCommand(request.packageManager, \"typegen\"),\n formatPackageManagerCommand(request.packageManager, \"launch-fm\"),\n ]\n : []),\n formatPackageManagerCommand(request.packageManager, \"proofkit\"),\n ],\n };\n}\n\nexport function applyPackageJsonMutations(\n packageJson: PackageJson,\n mutations: InitPlan[\"packageJson\"],\n overwriteDependencies = true,\n) {\n packageJson.name = mutations.name;\n packageJson.proofkitMetadata = mutations.proofkitMetadata as PackageJson[\"proofkitMetadata\"];\n if (mutations.packageManager) {\n packageJson.packageManager = mutations.packageManager;\n }\n\n if (!packageJson.dependencies) {\n packageJson.dependencies = {};\n }\n if (!packageJson.devDependencies) {\n packageJson.devDependencies = {};\n }\n\n const merge = (target: Record<string, string>, source: Record<string, string>) => {\n for (const [name, version] of Object.entries(source)) {\n if (overwriteDependencies || !(name in target)) {\n target[name] = version;\n }\n }\n };\n\n merge(packageJson.dependencies as Record<string, string>, mutations.dependencies);\n merge(packageJson.devDependencies as Record<string, string>, mutations.devDependencies);\n\n return packageJson;\n}\n","import path from \"node:path\";\nimport { Chalk } from \"chalk\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { getOrUndefined } from \"effect/Option\";\nimport sortPackageJson from \"sort-package-json\";\n\nimport { AGENT_INSTRUCTIONS } from \"~/consts.js\";\nimport {\n CliContext,\n CodegenService,\n ConsoleService,\n FileMakerService,\n FileSystemService,\n GitService,\n PackageManagerService,\n ProcessService,\n PromptService,\n SettingsService,\n} from \"~/core/context.js\";\nimport { DirectoryConflictError, FileSystemError, isCliError, UserCancelledError } from \"~/core/errors.js\";\nimport { applyPackageJsonMutations } from \"~/core/planInit.js\";\nimport type { InitPlan } from \"~/core/types.js\";\nimport { normalizeImportAlias, replaceTextInFiles } from \"~/utils/projectFiles.js\";\n\nconst AGENT_METADATA_DIRS = new Set([\".agents\", \".claude\", \".clawed\", \".clinerules\", \".cursor\", \".windsurf\"]);\nconst IMPORT_ALIAS_WILDCARD_REGEX = /\\*/g;\nconst IMPORT_ALIAS_TRAILING_SLASH_REGEX = /\\/?$/;\nconst chalk = new Chalk({ level: 1 });\n\nconst formatCommand = (command: string) => chalk.cyan(command);\nconst formatHeading = (heading: string) => chalk.bold(heading);\nconst formatPath = (value: string) => chalk.yellow(value);\n\nfunction renderNextSteps(plan: InitPlan, additionalSteps: string[] = []) {\n const lines = [\n `${formatHeading(\"Project root:\")} ${formatCommand(`cd ${formatPath(plan.request.appDir)}`)}`,\n \"\",\n formatHeading(\"Agent setup:\"),\n \"Have your agent run this in the new project and complete the interactive prompt so it can load the right skills:\",\n ` ${formatCommand(\"npx @tanstack/intent@latest install\")}`,\n ];\n\n if (plan.request.noInstall) {\n lines.push(\n \"\",\n formatHeading(\"Install dependencies:\"),\n ` ${formatCommand(plan.request.packageManager === \"yarn\" ? \"yarn\" : `${plan.request.packageManager} install`)}`,\n );\n }\n\n lines.push(\"\", formatHeading(\"Start the app:\"), ` ${formatCommand(`${plan.packageManagerCommand} dev`)}`);\n\n if (plan.request.appType === \"webviewer\") {\n lines.push(\n \"\",\n formatHeading(\"When your FileMaker file is ready:\"),\n ` ${formatCommand(`${plan.packageManagerCommand} typegen`)}`,\n ` ${formatCommand(`${plan.packageManagerCommand} launch-fm`)}`,\n );\n\n if (additionalSteps.length > 0) {\n lines.push(...additionalSteps.map((step) => ` ${formatCommand(step)}`));\n }\n }\n\n lines.push(\n \"\",\n formatHeading(\"More ProofKit commands:\"),\n ` ${formatCommand(`${plan.packageManagerCommand} proofkit`)}`,\n );\n\n return lines.join(\"\\n\");\n}\n\nfunction getMeaningfulDirectoryEntries(entries: string[]) {\n return entries.filter((entry) => {\n if (AGENT_METADATA_DIRS.has(entry)) {\n return false;\n }\n if (entry === \".gitignore\") {\n return true;\n }\n if (entry.startsWith(\".\")) {\n return false;\n }\n return true;\n });\n}\n\nfunction promptEffect<A>(message: string, run: () => Promise<A>) {\n return Effect.tryPromise({\n try: run,\n catch: (cause) =>\n isCliError(cause)\n ? cause\n : new DirectoryConflictError({\n message,\n path: \"\",\n }),\n });\n}\n\nexport const prepareDirectory = (plan: InitPlan) =>\n Effect.gen(function* () {\n const fs = yield* FileSystemService;\n const consoleService = yield* ConsoleService;\n const cliContext = yield* CliContext;\n const prompts = yield* PromptService;\n\n const exists = yield* fs.exists(plan.targetDir);\n if (!exists) {\n return;\n }\n\n const entries = yield* fs.readdir(plan.targetDir);\n const meaningfulEntries = getMeaningfulDirectoryEntries(entries);\n if (meaningfulEntries.length === 0) {\n return;\n }\n\n if (plan.request.force) {\n yield* fs.emptyDir(plan.targetDir);\n return;\n }\n\n if (cliContext.nonInteractive) {\n return yield* Effect.fail(\n new DirectoryConflictError({\n message: `${plan.request.appDir} already exists and isn't empty. Remove the existing files or choose a different directory.`,\n path: plan.targetDir,\n }),\n );\n }\n\n const overwriteMode = yield* promptEffect(\"Unable to choose how to handle the existing directory.\", () =>\n prompts.select({\n message: `${plan.request.appDir} already exists and isn't empty. How would you like to proceed?`,\n options: [\n { value: \"abort\", label: \"Abort installation\" },\n { value: \"clear\", label: \"Clear the directory and continue\" },\n { value: \"overwrite\", label: \"Continue and overwrite conflicting files\" },\n ],\n }),\n );\n\n if (overwriteMode === \"abort\") {\n return yield* Effect.fail(\n new UserCancelledError({\n message: \"User aborted the operation\",\n }),\n );\n }\n\n if (overwriteMode === \"clear\") {\n const confirmed = yield* promptEffect(\"Unable to confirm directory clearing.\", () =>\n prompts.confirm({\n message: \"Are you sure you want to clear the directory?\",\n initialValue: false,\n }),\n );\n if (!confirmed) {\n return yield* Effect.fail(\n new UserCancelledError({\n message: \"User aborted the operation\",\n }),\n );\n }\n yield* fs.emptyDir(plan.targetDir);\n return;\n }\n\n consoleService.warn(`Continuing in ${plan.request.appDir} and overwriting conflicting files when needed.`);\n });\n\nexport const executeInitPlan = (plan: InitPlan) =>\n Effect.gen(function* () {\n const cliContext = yield* CliContext;\n const fs = yield* FileSystemService;\n const consoleService = yield* ConsoleService;\n const settingsService = yield* SettingsService;\n const fileMakerService = yield* FileMakerService;\n const processService = yield* ProcessService;\n const gitService = yield* GitService;\n const codegenService = yield* CodegenService;\n const packageManagerService = yield* PackageManagerService;\n const additionalNextSteps: string[] = [];\n const runFileSystemPromise = async <A>(effect: Effect.Effect<A, unknown>) => {\n const exit = await Effect.runPromiseExit(effect);\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n const failure = getOrUndefined(Cause.failureOption(exit.cause));\n if (failure && typeof failure === \"object\" && failure !== null && \"cause\" in failure) {\n throw failure.cause;\n }\n\n throw failure ?? Cause.squash(exit.cause);\n };\n const projectFilesFs = {\n readdir: (targetPath: string) => runFileSystemPromise(fs.readdir(targetPath)),\n readFile: (targetPath: string) => runFileSystemPromise(fs.readFile(targetPath)),\n writeFile: (targetPath: string, content: string) => runFileSystemPromise(fs.writeFile(targetPath, content)),\n };\n\n yield* prepareDirectory(plan);\n\n consoleService.info(`Scaffolding in ${plan.targetDir}`);\n yield* fs.copyDir(plan.templateDir, plan.targetDir, { overwrite: true });\n\n const stagedGitignore = path.join(plan.targetDir, \"_gitignore\");\n const finalGitignore = path.join(plan.targetDir, \".gitignore\");\n if (yield* fs.exists(stagedGitignore)) {\n if (yield* fs.exists(finalGitignore)) {\n yield* fs.remove(stagedGitignore);\n } else {\n yield* fs.rename(stagedGitignore, finalGitignore);\n }\n }\n\n const packageJsonPath = path.join(plan.targetDir, \"package.json\");\n const packageJson = yield* fs.readJson<Record<string, unknown>>(packageJsonPath);\n const updatedPackageJson = sortPackageJson(\n applyPackageJsonMutations(packageJson as never, plan.packageJson) as never,\n );\n yield* fs.writeJson(packageJsonPath, updatedPackageJson);\n\n yield* settingsService.writeSettings(plan.targetDir, plan.settings);\n yield* fs.writeFile(plan.envFile.path, plan.envFile.content);\n for (const write of plan.writes) {\n yield* fs.writeFile(write.path, write.content);\n }\n\n yield* Effect.tryPromise({\n try: () => replaceTextInFiles(projectFilesFs, plan.targetDir, \"__PNPM_COMMAND__\", plan.packageManagerCommand),\n catch: (cause) =>\n new FileSystemError({\n message: \"Unable to rewrite scaffold placeholders.\",\n operation: \"replaceTextInFiles\",\n path: plan.targetDir,\n cause,\n }),\n });\n yield* Effect.tryPromise({\n try: () => replaceTextInFiles(projectFilesFs, plan.targetDir, \"__PACKAGE_MANAGER__\", plan.request.packageManager),\n catch: (cause) =>\n new FileSystemError({\n message: \"Unable to rewrite scaffold placeholders.\",\n operation: \"replaceTextInFiles\",\n path: plan.targetDir,\n cause,\n }),\n });\n yield* Effect.tryPromise({\n try: () => replaceTextInFiles(projectFilesFs, plan.targetDir, \"__AGENT_INSTRUCTIONS__\", AGENT_INSTRUCTIONS),\n catch: (cause) =>\n new FileSystemError({\n message: \"Unable to rewrite scaffold placeholders.\",\n operation: \"replaceTextInFiles\",\n path: plan.targetDir,\n cause,\n }),\n });\n if (plan.request.importAlias !== \"~/\") {\n yield* Effect.tryPromise({\n try: () =>\n replaceTextInFiles(projectFilesFs, plan.targetDir, \"~/\", normalizeImportAlias(plan.request.importAlias)),\n catch: (cause) =>\n new FileSystemError({\n message: \"Unable to rewrite scaffold import aliases.\",\n operation: \"replaceTextInFiles\",\n path: plan.targetDir,\n cause,\n }),\n });\n yield* Effect.tryPromise({\n try: () =>\n replaceTextInFiles(\n projectFilesFs,\n plan.targetDir,\n \"@/\",\n plan.request.importAlias\n .replace(IMPORT_ALIAS_WILDCARD_REGEX, \"\")\n .replace(IMPORT_ALIAS_TRAILING_SLASH_REGEX, \"/\"),\n ),\n catch: (cause) =>\n new FileSystemError({\n message: \"Unable to rewrite scaffold import aliases.\",\n operation: \"replaceTextInFiles\",\n path: plan.targetDir,\n cause,\n }),\n });\n }\n\n let nextSettings = plan.settings;\n if (plan.tasks.bootstrapFileMaker && plan.request.fileMaker) {\n const fileMakerInputs = plan.request.fileMaker;\n nextSettings = yield* fileMakerService.bootstrap(\n plan.targetDir,\n nextSettings,\n fileMakerInputs,\n plan.request.appType,\n );\n yield* settingsService.writeSettings(plan.targetDir, nextSettings);\n }\n\n if (plan.tasks.checkWebViewerAddon) {\n yield* Effect.promise(async () => {\n try {\n const { checkForWebViewerLayouts, getWebViewerAddonMessages } = await import(\n \"~/installers/proofkit-webviewer.js\"\n );\n const status = await checkForWebViewerLayouts(plan.targetDir);\n const messages = getWebViewerAddonMessages(status);\n\n for (const message of messages.warn) {\n consoleService.warn(message);\n }\n for (const message of messages.info) {\n consoleService.info(message);\n }\n if (cliContext.nonInteractive) {\n additionalNextSteps.push(...messages.nextSteps);\n }\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n consoleService.warn(`Could not inspect the ProofKit WebViewer add-on (${message}).`);\n }\n });\n }\n\n if (plan.tasks.runInstall) {\n let installArgs: string[] = [\"install\"];\n if (plan.request.packageManager === \"yarn\") {\n installArgs = [];\n }\n yield* processService.run(plan.request.packageManager, installArgs, {\n cwd: plan.targetDir,\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n }\n\n if (plan.tasks.runInitialCodegen) {\n yield* codegenService.runInitial(plan.targetDir, plan.request.packageManager);\n }\n\n if (plan.tasks.initializeGit) {\n yield* gitService.initialize(plan.targetDir);\n }\n\n const packageManagerVersion = yield* packageManagerService.getVersion(plan.request.packageManager, plan.targetDir);\n\n consoleService.success(\n `Created ${plan.request.scopedAppName} in ${plan.targetDir}${\n packageManagerVersion ? ` using ${plan.request.packageManager}@${packageManagerVersion}` : \"\"\n }`,\n );\n consoleService.info(chalk.bold(\"Next steps:\"));\n consoleService.info(renderNextSteps(plan, Array.from(new Set(additionalNextSteps))));\n return plan;\n });\n","import { Effect } from \"effect\";\nimport { DOCS_URL } from \"~/consts.js\";\nimport { ConsoleService } from \"~/core/context.js\";\n\nexport const runPrompt = Effect.gen(function* () {\n const consoleService = yield* ConsoleService;\n\n consoleService.note(\n [\n \"Agent-ready prompts are coming soon.\",\n \"\",\n \"This command will become the stable entrypoint for docs-linked AI workflows.\",\n `For now, use package-native tools directly and check docs: ${DOCS_URL}/docs/cli`,\n ].join(\"\\n\"),\n \"Coming soon\",\n );\n});\n","import path from \"node:path\";\n\nconst TRAILING_SLASHES_REGEX = /\\/+$/;\nconst PATH_SEPARATOR_REGEX = /\\\\/g;\nconst VALID_APP_NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction normalizeProjectName(value: string) {\n return value.replace(PATH_SEPARATOR_REGEX, \"/\");\n}\n\nfunction trimTrailingSlashes(value: string) {\n return normalizeProjectName(value).replace(TRAILING_SLASHES_REGEX, \"\");\n}\n\nexport function parseNameAndPath(projectName: string): [scopedAppName: string, appDir: string] {\n const normalized = trimTrailingSlashes(projectName);\n const segments = normalized.split(\"/\");\n let scopedAppName = segments.at(-1) ?? \"\";\n\n if (scopedAppName === \".\") {\n scopedAppName = path.basename(path.resolve(process.cwd()));\n }\n\n const scopeIndex = segments.findIndex((segment) => segment.startsWith(\"@\"));\n if (scopeIndex !== -1) {\n scopedAppName = segments.slice(scopeIndex).join(\"/\");\n }\n\n const appDir = segments.filter((segment) => !segment.startsWith(\"@\")).join(\"/\");\n\n return [scopedAppName, appDir];\n}\n\nexport function validateAppName(projectName: string) {\n const normalized = trimTrailingSlashes(projectName);\n if (normalized === \".\") {\n const currentDirName = path.basename(path.resolve(process.cwd()));\n return VALID_APP_NAME_REGEX.test(currentDirName)\n ? undefined\n : \"Name must consist of only lowercase alphanumeric characters, '-', and '_'\";\n }\n\n const segments = normalized.split(\"/\");\n const scopeIndex = segments.findIndex((segment) => segment.startsWith(\"@\"));\n let scopedAppName = segments.at(-1);\n\n if (scopeIndex !== -1) {\n scopedAppName = segments.slice(scopeIndex).join(\"/\");\n }\n\n if (VALID_APP_NAME_REGEX.test(scopedAppName ?? \"\")) {\n return;\n }\n\n return \"Name must consist of only lowercase alphanumeric characters, '-', and '_'\";\n}\n","import { Effect } from \"effect\";\n\nimport { DEFAULT_APP_NAME } from \"~/consts.js\";\nimport { CliContext, ConsoleService, FileMakerService, PromptService } from \"~/core/context.js\";\nimport { CliValidationError, FileMakerSetupError, isCliError, NonInteractiveInputError } from \"~/core/errors.js\";\nimport type { AppType, CliFlags, DataSourceType, FileMakerInputs, InitRequest } from \"~/core/types.js\";\nimport { createDataSourceEnvNames, getDefaultSchemaName } from \"~/utils/projectFiles.js\";\nimport { parseNameAndPath, validateAppName } from \"~/utils/projectName.js\";\n\nconst defaultFlags: CliFlags = {\n noGit: false,\n noInstall: false,\n force: false,\n default: false,\n CI: false,\n importAlias: \"~/\",\n};\n\nfunction compareSemver(left: string, right: string) {\n const leftParts = left.split(\".\").map((part) => Number.parseInt(part, 10) || 0);\n const rightParts = right.split(\".\").map((part) => Number.parseInt(part, 10) || 0);\n\n for (let index = 0; index < Math.max(leftParts.length, rightParts.length); index += 1) {\n const leftValue = leftParts[index] ?? 0;\n const rightValue = rightParts[index] ?? 0;\n if (leftValue > rightValue) {\n return 1;\n }\n if (leftValue < rightValue) {\n return -1;\n }\n }\n\n return 0;\n}\n\nfunction validateLayoutInputs(flags: CliFlags) {\n const hasLayoutName = Boolean(flags.layoutName);\n const hasSchemaName = Boolean(flags.schemaName);\n\n if (hasLayoutName !== hasSchemaName) {\n return Effect.fail(\n new CliValidationError({\n message: \"Both --layout-name and --schema-name must be provided together.\",\n }),\n );\n }\n\n return Effect.void;\n}\n\nfunction promptEffect<A>(message: string, run: () => Promise<A>) {\n return Effect.tryPromise({\n try: run,\n catch: (cause) =>\n isCliError(cause)\n ? cause\n : new CliValidationError({\n message,\n cause,\n }),\n });\n}\n\nfunction getMissingFlags(values: [flag: string, value: unknown][]) {\n return values.filter(([, value]) => !value).map(([flag]) => flag);\n}\n\nfunction createMissingInputsMessage(scope: string, flags: string[]) {\n return `Missing required ${scope} inputs in non-interactive mode: ${flags.join(\", \")}.`;\n}\n\nfunction resolveHostedFileMakerInputs({\n prompt,\n fileMakerService,\n flags,\n nonInteractive,\n}: {\n prompt: PromptService;\n fileMakerService: FileMakerService;\n flags: CliFlags;\n nonInteractive: boolean;\n}) {\n return Effect.gen(function* () {\n yield* validateLayoutInputs(flags);\n\n if (!flags.server && nonInteractive) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message: createMissingInputsMessage(\n \"hosted FileMaker\",\n getMissingFlags([\n [\"--server\", flags.server],\n [\"--file-name\", flags.fileName],\n [\"--data-api-key\", flags.dataApiKey],\n ]),\n ),\n }),\n );\n }\n\n const rawServer =\n flags.server ??\n (yield* promptEffect(\"Unable to read FileMaker Server URL.\", () =>\n prompt.text({\n message: \"What is the URL of your FileMaker Server?\",\n validate: (value) => {\n try {\n const normalized = value.startsWith(\"http\") ? value : `https://${value}`;\n new URL(normalized);\n return;\n } catch {\n return \"Please enter a valid URL\";\n }\n },\n }),\n ));\n\n const { normalizedUrl, versions } = yield* fileMakerService.validateHostedServerUrl(rawServer);\n const hostedUrl = new URL(normalizedUrl);\n const demoFileName = \"ProofKitDemo.fmp12\";\n\n let selectedFile = flags.fileName;\n let dataApiKey = flags.dataApiKey;\n let layoutName = flags.layoutName;\n let schemaName = flags.schemaName;\n let token: string | undefined;\n let files: Array<{ filename: string; status: string }> = [];\n\n const requireHostedToken = () =>\n token\n ? Effect.succeed(token)\n : Effect.fail(\n new FileMakerSetupError({\n message: \"OttoFMS authentication is required for hosted setup.\",\n }),\n );\n\n if (!(selectedFile && dataApiKey)) {\n if (!(flags.adminApiKey || (versions.ottoVersion && compareSemver(versions.ottoVersion, \"4.7.0\") >= 0))) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message:\n \"OttoFMS 4.7.0 or later is required to auto-login. Upgrade OttoFMS or pass --admin-api-key for hosted setup.\",\n }),\n );\n }\n token = flags.adminApiKey ?? (yield* fileMakerService.getOttoFMSToken({ url: hostedUrl })).token;\n }\n\n if (!selectedFile) {\n if (nonInteractive) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message: createMissingInputsMessage(\n \"FileMaker\",\n getMissingFlags([\n [\"--file-name\", selectedFile],\n [\"--data-api-key\", dataApiKey],\n ]),\n ),\n }),\n );\n }\n\n files = yield* fileMakerService.listFiles({\n url: hostedUrl,\n token: yield* requireHostedToken(),\n });\n selectedFile = yield* promptEffect(\"Unable to choose a FileMaker file.\", () =>\n prompt.searchSelect({\n message: \"Which file would you like to connect to?\",\n options: [\n {\n value: \"$deploy-demo\",\n label: \"Deploy NEW ProofKit Demo File\",\n hint: \"Use OttoFMS to deploy a new file for testing\",\n keywords: [\"demo\", \"proofkit\"],\n },\n ...files\n .slice()\n .sort((left, right) => left.filename.localeCompare(right.filename))\n .map((file) => ({\n value: file.filename,\n label: file.filename,\n hint: file.status,\n keywords: [file.filename],\n })),\n ],\n }),\n );\n }\n\n if (!selectedFile) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"No FileMaker file was selected.\",\n }),\n );\n }\n\n if (selectedFile === \"$deploy-demo\") {\n if (files.length === 0) {\n files = yield* fileMakerService.listFiles({\n url: hostedUrl,\n token: yield* requireHostedToken(),\n });\n }\n const demoExists = files.some((file) => file.filename === demoFileName);\n const replaceDemo =\n demoExists && !nonInteractive\n ? yield* promptEffect(\"Unable to confirm ProofKit Demo replacement.\", () =>\n prompt.confirm({\n message: \"The demo file already exists. Do you want to replace it with a fresh copy?\",\n initialValue: false,\n }),\n )\n : demoExists;\n const deployed = yield* fileMakerService.deployDemoFile({\n url: hostedUrl,\n token: yield* requireHostedToken(),\n operation: replaceDemo ? \"replace\" : \"install\",\n });\n selectedFile = deployed.filename;\n dataApiKey = deployed.apiKey;\n layoutName ??= \"API_Contacts\";\n schemaName ??= \"Contacts\";\n }\n\n if (!dataApiKey && nonInteractive) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message: createMissingInputsMessage(\"FileMaker\", getMissingFlags([[\"--data-api-key\", dataApiKey]])),\n }),\n );\n }\n\n if (!dataApiKey) {\n const apiKeys = (yield* fileMakerService.listAPIKeys({\n url: hostedUrl,\n token: yield* requireHostedToken(),\n })).filter((apiKey: { database: string }) => apiKey.database === selectedFile);\n\n const selection =\n apiKeys.length === 0\n ? \"create\"\n : yield* promptEffect(\"Unable to choose an OttoFMS Data API key.\", () =>\n prompt.searchSelect({\n message: \"Which OttoFMS Data API key would you like to use?\",\n options: [\n ...apiKeys.map((apiKey: { key: string; label: string; user: string; database: string }) => ({\n value: apiKey.key,\n label: `${apiKey.label} - ${apiKey.user}`,\n hint: `${apiKey.key.slice(0, 5)}...${apiKey.key.slice(-4)}`,\n keywords: [apiKey.label, apiKey.user, apiKey.database],\n })),\n {\n value: \"create\",\n label: \"Create a new API key\",\n hint: \"Requires FileMaker credentials for this file\",\n keywords: [\"create\", \"new\"],\n },\n ],\n }),\n );\n\n if (selection === \"create\") {\n const username = yield* promptEffect(\"Unable to read FileMaker account name.\", () =>\n prompt.text({\n message: `Enter the account name for ${selectedFile}`,\n validate: (value) => (value ? undefined : \"An account name is required\"),\n }),\n );\n const password = yield* promptEffect(\"Unable to read FileMaker account password.\", () =>\n prompt.password({\n message: `Enter the password for ${username}`,\n validate: (value) => (value ? undefined : \"A password is required\"),\n }),\n );\n if (!selectedFile) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"No FileMaker file was selected.\",\n }),\n );\n }\n dataApiKey = (yield* fileMakerService.createDataAPIKeyWithCredentials({\n url: hostedUrl,\n filename: selectedFile,\n username,\n password,\n })).apiKey;\n } else {\n dataApiKey = selection;\n }\n }\n\n if (!dataApiKey) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"No FileMaker Data API key was selected.\",\n }),\n );\n }\n\n const resolvedFileName = selectedFile;\n if (!resolvedFileName) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"No FileMaker file was selected.\",\n }),\n );\n }\n\n const layouts = yield* fileMakerService.listLayouts({\n dataApiKey,\n fmFile: resolvedFileName,\n server: hostedUrl.origin,\n });\n\n if (layoutName && !layouts.includes(layoutName)) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: `Layout \"${layoutName}\" was not found in ${resolvedFileName}.`,\n }),\n );\n }\n\n if (!(nonInteractive || layoutName || schemaName)) {\n const shouldConfigureLayout = yield* promptEffect(\"Unable to confirm initial layout setup.\", () =>\n prompt.confirm({\n message: \"Do you want to configure an initial layout for type generation now?\",\n initialValue: false,\n }),\n );\n\n if (shouldConfigureLayout) {\n layoutName = yield* promptEffect(\"Unable to choose a FileMaker layout.\", () =>\n prompt.searchSelect({\n message: \"Select a layout to read data from\",\n options: layouts.map((layout: string) => ({\n value: layout,\n label: layout,\n keywords: [layout],\n })),\n }),\n );\n\n const resolvedLayoutName = layoutName;\n if (!resolvedLayoutName) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"No FileMaker layout was selected.\",\n }),\n );\n }\n schemaName = yield* promptEffect(\"Unable to read generated schema name.\", () =>\n prompt.text({\n message: \"What should the generated schema be called?\",\n defaultValue: getDefaultSchemaName(resolvedLayoutName),\n validate: (value) => (value ? undefined : \"A schema name is required\"),\n }),\n );\n }\n }\n\n if (!selectedFile) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"No FileMaker file was selected.\",\n }),\n );\n }\n if (!dataApiKey) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"No FileMaker Data API key was selected.\",\n }),\n );\n }\n\n return {\n mode: \"hosted-otto\",\n dataSourceName: \"filemaker\",\n envNames: createDataSourceEnvNames(\"filemaker\"),\n server: hostedUrl.origin,\n fileName: selectedFile,\n dataApiKey,\n layoutName,\n schemaName,\n adminApiKey: flags.adminApiKey,\n fmsVersion: versions.fmsVersion,\n ottoVersion: versions.ottoVersion,\n } satisfies FileMakerInputs;\n });\n}\n\nfunction resolveFileMakerInputs({\n prompt,\n console,\n fileMakerService,\n flags,\n appType,\n nonInteractive,\n}: {\n prompt: PromptService;\n console: ConsoleService;\n fileMakerService: FileMakerService;\n flags: CliFlags;\n appType: AppType;\n nonInteractive: boolean;\n}) {\n return Effect.gen(function* () {\n if (flags.dataSource !== \"filemaker\") {\n return { fileMaker: undefined, skipFileMakerSetup: false };\n }\n\n yield* validateLayoutInputs(flags);\n\n if (appType === \"webviewer\" && !flags.server) {\n const resolveLocalFmMcpFile = (connectedFiles: string[]) =>\n Effect.gen(function* () {\n const availableFiles = connectedFiles.filter(Boolean);\n if (availableFiles.length === 0) {\n return undefined;\n }\n\n if (flags.fileName) {\n if (availableFiles.includes(flags.fileName)) {\n return flags.fileName;\n }\n\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: `FileMaker file \"${flags.fileName}\" is not currently connected to the local ProofKit MCP Server. Connected files: ${availableFiles.join(\", \")}.`,\n }),\n );\n }\n\n if (availableFiles.length === 1) {\n return availableFiles[0];\n }\n\n if (nonInteractive) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message: `Multiple FileMaker files are connected to the local ProofKit MCP Server. Pass --file-name with one of: ${availableFiles.join(\", \")}.`,\n }),\n );\n }\n\n return yield* promptEffect(\"Unable to choose a local FileMaker file.\", () =>\n prompt.searchSelect({\n message: \"Multiple FileMaker files are open. Which file should ProofKit use?\",\n options: availableFiles.map((fileName) => ({\n value: fileName,\n label: fileName,\n hint: \"Connected via local ProofKit MCP Server\",\n keywords: [fileName],\n })),\n }),\n );\n });\n\n while (true) {\n const localFmMcp = yield* fileMakerService.detectLocalFmMcp();\n const selectedFile = localFmMcp.healthy ? yield* resolveLocalFmMcpFile(localFmMcp.connectedFiles) : undefined;\n if (localFmMcp.healthy && selectedFile) {\n console.info(`Using local ProofKit MCP file: ${selectedFile}`);\n return {\n fileMaker: {\n mode: \"local-fm-mcp\",\n dataSourceName: \"filemaker\",\n envNames: createDataSourceEnvNames(\"filemaker\"),\n fmMcpBaseUrl: localFmMcp.baseUrl,\n fileName: selectedFile,\n layoutName: flags.layoutName,\n schemaName: flags.schemaName,\n } satisfies FileMakerInputs,\n skipFileMakerSetup: false,\n };\n }\n\n if (nonInteractive) {\n if (localFmMcp.healthy) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message:\n \"ProofKit MCP Server was detected, but no FileMaker files are open. Open a file in FileMaker and rerun, or pass --server.\",\n }),\n );\n }\n\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message:\n \"ProofKit MCP Server was not detected and no FileMaker server was provided. Start the ProofKit MCP Server locally or rerun with --server.\",\n }),\n );\n }\n\n const fallbackAction = yield* promptEffect(\"Unable to choose FileMaker setup fallback.\", () =>\n prompt.select({\n message: localFmMcp.healthy\n ? \"ProofKit MCP Server is running, but no FileMaker file is open yet. Open one, then choose how to continue.\"\n : \"ProofKit MCP Server was not detected. How would you like to continue?\",\n options: [\n {\n value: \"retry\",\n label: \"Try again\",\n hint: localFmMcp.healthy\n ? \"Check again after opening a FileMaker file\"\n : \"Retry ProofKit MCP Server detection\",\n },\n {\n value: \"hosted\",\n label: \"Continue with hosted setup\",\n hint: \"Use OttoFMS and a hosted FileMaker server\",\n },\n {\n value: \"skip\",\n label: \"Skip for now\",\n hint: \"Create the project and configure FileMaker later\",\n },\n ],\n }),\n );\n\n if (fallbackAction === \"retry\") {\n continue;\n }\n\n if (fallbackAction === \"skip\") {\n return {\n fileMaker: undefined,\n skipFileMakerSetup: true,\n };\n }\n\n break;\n }\n }\n\n return {\n fileMaker: yield* resolveHostedFileMakerInputs({\n prompt,\n fileMakerService,\n flags,\n nonInteractive,\n }),\n skipFileMakerSetup: false,\n };\n });\n}\n\nexport const resolveInitRequest = (name?: string, rawFlags?: CliFlags) =>\n Effect.gen(function* () {\n const flags = { ...defaultFlags, ...rawFlags };\n const prompt = yield* PromptService;\n const console = yield* ConsoleService;\n const fileMakerService = yield* FileMakerService;\n const cliContext = yield* CliContext;\n const nonInteractive = cliContext.nonInteractive || flags.CI || flags.nonInteractive === true;\n\n let projectName = name;\n if (!projectName) {\n if (nonInteractive) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message: \"Project name is required in non-interactive mode.\",\n }),\n );\n }\n\n projectName = yield* promptEffect(\"Unable to read project name.\", () =>\n prompt.text({\n message: \"What will your project be called?\",\n defaultValue: DEFAULT_APP_NAME,\n validate: validateAppName,\n }),\n );\n }\n\n if (!projectName) {\n return yield* Effect.fail(\n new CliValidationError({\n message: \"Project name is required.\",\n }),\n );\n }\n\n const validationError = validateAppName(projectName);\n if (validationError) {\n return yield* Effect.fail(\n new CliValidationError({\n message: validationError,\n }),\n );\n }\n\n let appType: AppType = flags.appType ?? \"browser\";\n if (!(flags.appType || nonInteractive)) {\n appType = yield* promptEffect(\"Unable to choose app type.\", () =>\n prompt.select<AppType>({\n message: \"What kind of app do you want to build?\",\n options: [\n {\n value: \"browser\",\n label: \"Web App for Browsers\",\n hint: \"Uses Next.js and hosted deployment\",\n },\n {\n value: \"webviewer\",\n label: \"FileMaker Web Viewer\",\n hint: \"Uses Vite for FileMaker web viewers\",\n },\n ],\n }),\n );\n }\n\n const hasExplicitFileMakerInputs = Boolean(\n flags.server || flags.adminApiKey || flags.dataApiKey || flags.fileName || flags.layoutName || flags.schemaName,\n );\n\n let dataSource: DataSourceType = \"none\";\n if (flags.dataSource) {\n dataSource = flags.dataSource;\n } else if (appType === \"webviewer\") {\n dataSource = hasExplicitFileMakerInputs || !(nonInteractive && !flags.server) ? \"filemaker\" : \"none\";\n }\n\n if (!(nonInteractive || flags.dataSource) && appType !== \"webviewer\") {\n dataSource = yield* promptEffect(\"Unable to choose data source setup.\", () =>\n prompt.select<DataSourceType>({\n message: \"Do you want to connect to a FileMaker Database now?\",\n options: [\n {\n value: \"filemaker\",\n label: \"Yes\",\n hint: \"Set up env, datasource config, and typegen now\",\n },\n {\n value: \"none\",\n label: \"No\",\n hint: \"You can add a data source later\",\n },\n ],\n }),\n );\n }\n\n if (nonInteractive && !flags.dataSource && hasExplicitFileMakerInputs) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message: \"FileMaker flags require --data-source filemaker in non-interactive mode.\",\n }),\n );\n }\n\n if (nonInteractive && dataSource !== \"filemaker\" && hasExplicitFileMakerInputs) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message: \"FileMaker flags require --data-source filemaker in non-interactive mode.\",\n }),\n );\n }\n\n const { fileMaker, skipFileMakerSetup } = yield* resolveFileMakerInputs({\n prompt,\n console,\n fileMakerService,\n flags: { ...flags, dataSource },\n appType,\n nonInteractive,\n });\n\n const [scopedAppName, appDir] = parseNameAndPath(projectName);\n\n return {\n projectName,\n scopedAppName,\n appDir,\n appType,\n ui: flags.ui ?? \"shadcn\",\n dataSource,\n packageManager: cliContext.packageManager,\n noInstall: flags.noInstall,\n noGit: flags.noGit,\n force: flags.force,\n cwd: cliContext.cwd,\n importAlias: flags.importAlias,\n nonInteractive,\n debug: cliContext.debug,\n fileMaker,\n skipFileMakerSetup,\n hasExplicitFileMakerInputs,\n } satisfies InitRequest;\n });\n","import open from \"open\";\n\nexport async function openBrowser(url: string): Promise<void> {\n try {\n await open(url);\n } catch {\n // Ignore open failures and let the user copy the URL manually.\n }\n}\n\nexport const openExternal: (url: string) => Promise<void> = openBrowser;\n","import https from \"node:https\";\nimport axios from \"axios\";\n\nfunction createHttpsAgent() {\n return new https.Agent({\n rejectUnauthorized: process.env.PROOFKIT_ALLOW_INSECURE_TLS !== \"1\",\n });\n}\n\nexport async function getJson<T>(url: string, options?: { headers?: Record<string, string>; timeout?: number }) {\n const response = await axios.get<T>(url, {\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeout ?? 10_000,\n validateStatus: null,\n });\n return response;\n}\n\nexport async function postJson<T>(\n url: string,\n data: unknown,\n options?: { headers?: Record<string, string>; timeout?: number },\n) {\n const response = await axios.post<T>(url, data, {\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeout ?? 10_000,\n validateStatus: null,\n });\n return response;\n}\n\nexport async function deleteJson(url: string, options?: { headers?: Record<string, string>; timeout?: number }) {\n const response = await axios.delete(url, {\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeout ?? 10_000,\n validateStatus: null,\n });\n return response;\n}\n\nexport async function requestJson<T>(\n url: string | URL,\n options?: {\n method?: \"GET\" | \"POST\" | \"DELETE\";\n headers?: Record<string, string>;\n body?: Record<string, unknown>;\n timeoutMs?: number;\n },\n) {\n const response = await axios.request<T>({\n url: url.toString(),\n method: options?.method ?? \"GET\",\n data: options?.body,\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeoutMs ?? 10_000,\n });\n return response;\n}\n\nexport async function requestText(\n url: string | URL,\n options?: {\n method?: \"GET\" | \"POST\" | \"DELETE\";\n headers?: Record<string, string>;\n timeoutMs?: number;\n },\n) {\n const response = await axios.request<string>({\n url: url.toString(),\n method: options?.method ?? \"GET\",\n headers: options?.headers,\n httpsAgent: createHttpsAgent(),\n timeout: options?.timeoutMs ?? 10_000,\n responseType: \"text\",\n validateStatus: null,\n });\n return {\n status: response.status,\n data: response.data,\n };\n}\n","export type PackageManager = \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n\nexport function detectUserPackageManager(): PackageManager {\n const userAgent = process.env.npm_config_user_agent;\n\n if (userAgent) {\n if (userAgent.startsWith(\"yarn\")) {\n return \"yarn\";\n }\n if (userAgent.startsWith(\"pnpm\")) {\n return \"pnpm\";\n }\n if (userAgent.startsWith(\"bun\")) {\n return \"bun\";\n }\n return \"npm\";\n }\n\n return \"npm\";\n}\n","import {\n intro as clackIntro,\n isCancel as clackIsCancel,\n log as clackLog,\n note as clackNote,\n outro as clackOutro,\n spinner as clackSpinner,\n} from \"@clack/prompts\";\nimport {\n checkbox as inquirerCheckbox,\n confirm as inquirerConfirm,\n input as inquirerInput,\n password as inquirerPassword,\n search as inquirerSearch,\n select as inquirerSelect,\n} from \"@inquirer/prompts\";\n\nconst CANCEL_SYMBOL = Symbol.for(\"@proofkit/new/prompt-cancelled\");\n\nexport const intro = clackIntro;\nexport const log = clackLog;\nexport const note = clackNote;\nexport const outro = clackOutro;\nexport const spinner = clackSpinner;\n\nfunction isPromptCancel(error: unknown) {\n return error instanceof Error && error.name === \"ExitPromptError\";\n}\n\nfunction withCancelSentinel<T>(fn: () => Promise<T>): Promise<T | symbol> {\n return fn().catch((error: unknown) => {\n if (isPromptCancel(error)) {\n return CANCEL_SYMBOL;\n }\n throw error;\n });\n}\n\nexport function isCancel(value: unknown): value is symbol {\n return value === CANCEL_SYMBOL || clackIsCancel(value);\n}\n\nexport interface PromptOption<T extends string> {\n value: T;\n label: string;\n hint?: string;\n disabled?: boolean | string;\n}\n\nexport interface SearchPromptOption<T extends string> extends PromptOption<T> {\n keywords?: readonly string[];\n}\n\nfunction normalizeValidate(\n validate: ((value: string) => string | undefined) | undefined,\n): ((value: string) => string | boolean) | undefined {\n if (!validate) {\n return undefined;\n }\n\n return (value: string) => validate(value) ?? true;\n}\n\nfunction matchesSearch(option: SearchPromptOption<string>, query: string) {\n const haystack = [option.label, option.hint ?? \"\", ...(option.keywords ?? [])].join(\" \").toLowerCase();\n return haystack.includes(query.trim().toLowerCase());\n}\n\nfunction normalizeDisabledMessage(value: boolean | string | undefined) {\n if (typeof value === \"string\") {\n return value;\n }\n return value ? true : undefined;\n}\n\nexport function filterSearchOptions<T extends string>(\n options: readonly SearchPromptOption<T>[],\n query: string | undefined,\n) {\n const term = query?.trim();\n if (!term) {\n return options;\n }\n\n return options.filter((option) => matchesSearch(option, term));\n}\n\nexport function textPrompt(options: {\n message: string;\n defaultValue?: string;\n validate?: (value: string) => string | undefined;\n}) {\n return withCancelSentinel(() =>\n inquirerInput({\n message: options.message,\n default: options.defaultValue,\n validate: normalizeValidate(options.validate),\n }),\n );\n}\n\nexport function passwordPrompt(options: { message: string; validate?: (value: string) => string | undefined }) {\n return withCancelSentinel(() =>\n inquirerPassword({\n message: options.message,\n validate: normalizeValidate(options.validate),\n }),\n );\n}\n\nexport function confirmPrompt(options: { message: string; initialValue?: boolean }) {\n return withCancelSentinel(() =>\n inquirerConfirm({\n message: options.message,\n default: options.initialValue,\n }),\n );\n}\n\nexport function selectPrompt<T extends string>(options: { message: string; options: PromptOption<T>[] }) {\n return withCancelSentinel(() =>\n inquirerSelect<T>({\n message: options.message,\n pageSize: 10,\n choices: options.options.map((option) => ({\n value: option.value,\n name: option.label,\n description: option.hint,\n disabled: normalizeDisabledMessage(option.disabled),\n })),\n }),\n );\n}\n\nexport function searchSelectPrompt<T extends string>(options: {\n message: string;\n emptyMessage?: string;\n options: SearchPromptOption<T>[];\n}) {\n return withCancelSentinel(() =>\n inquirerSearch<T>({\n message: options.message,\n pageSize: 10,\n source: (input) => {\n const filtered = filterSearchOptions(options.options, input);\n if (filtered.length === 0) {\n return [\n {\n value: \"__no_matches__\" as T,\n name: options.emptyMessage ?? \"No matches found. Keep typing to refine your search.\",\n disabled: options.emptyMessage ?? \"No matches found\",\n },\n ];\n }\n\n return filtered.map((option) => ({\n value: option.value,\n name: option.label,\n description: option.hint,\n disabled: normalizeDisabledMessage(option.disabled),\n }));\n },\n }),\n );\n}\n\nexport function multiSearchSelectPrompt<T extends string>(options: {\n message: string;\n options: SearchPromptOption<T>[];\n required?: boolean;\n}) {\n return withCancelSentinel(() =>\n inquirerCheckbox<T>({\n message: options.message,\n pageSize: 10,\n required: options.required,\n choices: options.options.map((option) => ({\n value: option.value,\n name: option.label,\n description: option.hint,\n disabled: normalizeDisabledMessage(option.disabled),\n })),\n }),\n );\n}\n","import { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport type { Effect as Fx } from \"effect\";\nimport { Effect, Layer } from \"effect\";\nimport { execa } from \"execa\";\nimport fs from \"fs-extra\";\nimport { TEMPLATE_ROOT } from \"~/consts.js\";\nimport {\n CliContext,\n type CliContextValue,\n CodegenService,\n ConsoleService,\n type FileMakerBootstrapArtifacts,\n FileMakerService,\n FileSystemService,\n GitService,\n type OttoApiKeyInfo,\n type OttoFileInfo,\n PackageManagerService,\n ProcessService,\n PromptService,\n SettingsService,\n TemplateService,\n} from \"~/core/context.js\";\nimport { ExternalCommandError, FileMakerSetupError, FileSystemError, UserCancelledError } from \"~/core/errors.js\";\nimport type { AppType, FileMakerInputs, ProofKitSettings, UIType } from \"~/core/types.js\";\nimport { openBrowser } from \"~/utils/browserOpen.js\";\nimport { deleteJson, getJson, postJson } from \"~/utils/http.js\";\nimport { detectUserPackageManager } from \"~/utils/packageManager.js\";\nimport { createDataSourceEnvNames, updateEnvSchemaFile, updateTypegenConfig } from \"~/utils/projectFiles.js\";\nimport {\n confirmPrompt,\n spinner as createSpinner,\n isCancel,\n log,\n multiSearchSelectPrompt,\n note,\n passwordPrompt,\n searchSelectPrompt,\n selectPrompt,\n textPrompt,\n} from \"~/utils/prompts.js\";\n\nfunction unwrap<T>(value: T | symbol): T {\n if (isCancel(value)) {\n throw new UserCancelledError({ message: \"User aborted the operation\" });\n }\n return value as T;\n}\n\nfunction normalizeUrl(serverUrl: string) {\n if (serverUrl.startsWith(\"https://\")) {\n return serverUrl;\n }\n if (serverUrl.startsWith(\"http://\")) {\n return serverUrl.replace(\"http://\", \"https://\");\n }\n return `https://${serverUrl}`;\n}\n\ninterface LayoutFolder {\n isFolder?: boolean;\n name?: string;\n folderLayoutNames?: LayoutFolder[];\n}\n\nfunction transformLayoutList(layouts: LayoutFolder[]): string[] {\n const flatten = (layout: LayoutFolder): string[] => {\n if (layout.isFolder === true) {\n const folderLayouts = Array.isArray(layout.folderLayoutNames) ? layout.folderLayoutNames : [];\n return folderLayouts.flatMap((item) => flatten(item));\n }\n return typeof layout.name === \"string\" ? [layout.name] : [];\n };\n\n return layouts.flatMap(flatten).sort((left, right) => left.localeCompare(right));\n}\n\nfunction withFsError<A>(operation: string, targetPath: string, run: () => Promise<A>) {\n return Effect.tryPromise({\n try: run,\n catch: (cause) =>\n new FileSystemError({\n message: `File system ${operation} failed for ${targetPath}.`,\n operation,\n path: targetPath,\n cause,\n }),\n });\n}\n\nfunction withCommandError<A>(command: string, args: string[], cwd: string, run: () => Promise<A>, message?: string) {\n return Effect.tryPromise({\n try: run,\n catch: (cause) =>\n new ExternalCommandError({\n message: message ?? `Command failed: ${[command, ...args].join(\" \")}`,\n command,\n args,\n cwd,\n cause,\n }),\n });\n}\n\nfunction withFileMakerSetupError<A>(message: string, run: () => Promise<A>) {\n return Effect.tryPromise({\n try: run,\n catch: (cause) =>\n new FileMakerSetupError({\n message,\n cause,\n }),\n });\n}\n\nconst promptService = {\n text: async (options: { message: string; defaultValue?: string; validate?: (value: string) => string | undefined }) =>\n unwrap(\n await textPrompt({\n message: options.message,\n defaultValue: options.defaultValue,\n validate: options.validate,\n }),\n ).toString(),\n password: async (options: { message: string; validate?: (value: string) => string | undefined }) =>\n unwrap(\n await passwordPrompt({\n message: options.message,\n validate: options.validate,\n }),\n ).toString(),\n select: async <T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n }) =>\n unwrap(\n await selectPrompt({\n message: options.message,\n options: options.options,\n }),\n ) as T,\n searchSelect: async <T extends string>(options: {\n message: string;\n emptyMessage?: string;\n options: Array<{ value: T; label: string; hint?: string; keywords?: string[]; disabled?: boolean | string }>;\n }) => unwrap(await searchSelectPrompt(options)) as T,\n multiSearchSelect: async <T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string; keywords?: string[]; disabled?: boolean | string }>;\n required?: boolean;\n }) => unwrap(await multiSearchSelectPrompt(options)),\n confirm: async (options: { message: string; initialValue?: boolean }) =>\n unwrap(\n await confirmPrompt({\n message: options.message,\n initialValue: options.initialValue,\n }),\n ) as boolean,\n};\n\nconst consoleService = {\n info: (message: string) => log.info(message),\n warn: (message: string) => log.warn(message),\n error: (message: string) => log.error(message),\n success: (message: string) => log.success(message),\n note: (message: string, title?: string) => note(message, title),\n};\n\nconst fileSystemService = {\n exists: (targetPath: string) => withFsError(\"exists\", targetPath, () => fs.pathExists(targetPath)),\n readdir: (targetPath: string) => withFsError(\"readdir\", targetPath, () => fs.readdir(targetPath)),\n emptyDir: (targetPath: string) => withFsError(\"emptyDir\", targetPath, () => fs.emptyDir(targetPath)),\n copyDir: (from: string, to: string, options?: { overwrite?: boolean }) =>\n withFsError(\"copyDir\", `${from} -> ${to}`, () => fs.copy(from, to, { overwrite: options?.overwrite ?? true })),\n rename: (from: string, to: string) => withFsError(\"rename\", `${from} -> ${to}`, () => fs.rename(from, to)),\n remove: (targetPath: string) => withFsError(\"remove\", targetPath, () => fs.remove(targetPath)),\n readJson: <T>(targetPath: string) => withFsError(\"readJson\", targetPath, () => fs.readJson(targetPath) as Promise<T>),\n writeJson: (targetPath: string, value: unknown) =>\n withFsError(\"writeJson\", targetPath, () => fs.writeJson(targetPath, value, { spaces: 2 })),\n writeFile: (targetPath: string, content: string) =>\n withFsError(\"writeFile\", targetPath, () => fs.writeFile(targetPath, content, \"utf8\")),\n readFile: (targetPath: string) => withFsError(\"readFile\", targetPath, () => fs.readFile(targetPath, \"utf8\")),\n};\n\nconst templateService = {\n getTemplateDir: (appType: AppType, ui: UIType) => {\n if (appType === \"webviewer\") {\n return path.join(TEMPLATE_ROOT, \"vite-wv\");\n }\n if (ui === \"mantine\") {\n return path.join(TEMPLATE_ROOT, \"nextjs-mantine\");\n }\n return path.join(TEMPLATE_ROOT, \"nextjs-shadcn\");\n },\n};\n\nconst packageManagerService = {\n getVersion: (packageManager: string, cwd: string) => {\n if (packageManager === \"bun\") {\n return Effect.succeed(undefined);\n }\n return withCommandError(packageManager, [\"-v\"], cwd, async () => {\n const { stdout } = await execa(packageManager, [\"-v\"], { cwd });\n return stdout.trim();\n });\n },\n};\n\nconst processService = {\n run: (\n command: string,\n args: string[],\n options: {\n cwd: string;\n stdout?: \"pipe\" | \"inherit\" | \"ignore\";\n stderr?: \"pipe\" | \"inherit\" | \"ignore\";\n },\n ) =>\n withCommandError(command, args, options.cwd, async () => {\n const result = await execa(command, args, {\n cwd: options.cwd,\n stdout: options.stdout ?? \"pipe\",\n stderr: options.stderr ?? \"pipe\",\n });\n return {\n stdout: result.stdout ?? \"\",\n stderr: result.stderr ?? \"\",\n };\n }),\n};\n\nconst gitService = {\n initialize: (projectDir: string) =>\n Effect.gen(function* () {\n yield* withCommandError(\"git\", [\"init\"], projectDir, () => execa(\"git\", [\"init\"], { cwd: projectDir }));\n yield* withCommandError(\"git\", [\"add\", \".\"], projectDir, () => execa(\"git\", [\"add\", \".\"], { cwd: projectDir }));\n yield* withCommandError(\"git\", [\"commit\", \"-m\", \"Initial commit\"], projectDir, () =>\n execa(\"git\", [\"commit\", \"-m\", \"Initial commit\"], { cwd: projectDir }),\n );\n }),\n};\n\nconst settingsService = {\n writeSettings: (projectDir: string, settings: ProofKitSettings) =>\n withFsError(\"writeSettings\", path.join(projectDir, \"proofkit.json\"), () =>\n fs.writeJson(path.join(projectDir, \"proofkit.json\"), settings, { spaces: 2 }),\n ),\n appendEnvVars: (projectDir: string, vars: Record<string, string>) =>\n withFsError(\"appendEnvVars\", path.join(projectDir, \".env\"), async () => {\n const envPath = path.join(projectDir, \".env\");\n const existing = (await fs.pathExists(envPath)) ? await fs.readFile(envPath, \"utf8\") : \"\";\n const additions = Object.entries(vars)\n .map(([name, value]) => `${name}=${value}`)\n .join(\"\\n\");\n const nextContent = [existing.trimEnd(), additions].filter(Boolean).join(\"\\n\").concat(\"\\n\");\n await fs.writeFile(envPath, nextContent, \"utf8\");\n }),\n};\n\nfunction createDataSourceEntry(dataSourceName: string) {\n return {\n type: \"fm\" as const,\n name: dataSourceName,\n envNames: createDataSourceEnvNames(dataSourceName),\n };\n}\n\nfunction createFileMakerBootstrapArtifacts(\n settings: ProofKitSettings,\n inputs: FileMakerInputs,\n appType: AppType,\n): Promise<FileMakerBootstrapArtifacts> {\n const dataSourceEntry = createDataSourceEntry(inputs.dataSourceName);\n const nextSettings: ProofKitSettings = {\n ...settings,\n dataSources: settings.dataSources.some((entry) => entry.name === dataSourceEntry.name)\n ? settings.dataSources\n : [...settings.dataSources, dataSourceEntry],\n };\n\n if (inputs.mode === \"local-fm-mcp\") {\n return Promise.resolve({\n settings: nextSettings,\n envVars: {},\n envSchemaEntries: [],\n typegenConfig: {\n mode: inputs.mode,\n dataSourceName: inputs.dataSourceName,\n fmMcpBaseUrl: inputs.fmMcpBaseUrl,\n connectedFileName: inputs.fileName,\n layoutName: inputs.layoutName,\n schemaName: inputs.schemaName,\n appType,\n },\n });\n }\n\n return Promise.resolve({\n settings: nextSettings,\n envVars: {\n [inputs.envNames.database]: inputs.fileName,\n [inputs.envNames.server]: inputs.server,\n [inputs.envNames.apiKey]: inputs.dataApiKey,\n },\n envSchemaEntries: [\n {\n name: inputs.envNames.database,\n zodSchema: 'z.string().endsWith(\".fmp12\")',\n defaultValue: inputs.fileName,\n },\n {\n name: inputs.envNames.server,\n zodSchema: \"z.string().url()\",\n defaultValue: inputs.server,\n },\n {\n name: inputs.envNames.apiKey,\n zodSchema: 'z.string().startsWith(\"dk_\")',\n defaultValue: inputs.dataApiKey,\n },\n ],\n typegenConfig: {\n mode: inputs.mode,\n dataSourceName: inputs.dataSourceName,\n envNames: inputs.envNames,\n layoutName: inputs.layoutName,\n schemaName: inputs.schemaName,\n appType,\n },\n });\n}\n\nconst fileMakerService = {\n detectLocalFmMcp: (baseUrl = process.env.FM_MCP_BASE_URL ?? \"http://127.0.0.1:1365\") =>\n Effect.tryPromise({\n try: async () => {\n try {\n const health = await fetch(`${baseUrl}/health`, { signal: AbortSignal.timeout(3000) });\n if (!health.ok) {\n return { baseUrl, healthy: false, connectedFiles: [] };\n }\n const connectedFiles = await fetch(`${baseUrl}/connectedFiles`, { signal: AbortSignal.timeout(3000) })\n .then(async (response) => (response.ok ? ((await response.json()) as unknown) : []))\n .catch(() => []);\n return {\n baseUrl,\n healthy: true,\n connectedFiles: Array.isArray(connectedFiles)\n ? connectedFiles.filter((item): item is string => typeof item === \"string\")\n : [],\n };\n } catch {\n return { baseUrl, healthy: false, connectedFiles: [] };\n }\n },\n catch: (cause) =>\n new FileMakerSetupError({\n message: \"Unable to detect local ProofKit MCP Server.\",\n cause,\n }),\n }),\n validateHostedServerUrl: (serverUrl: string, ottoPort?: number | null) =>\n Effect.gen(function* () {\n const normalizedUrl = normalizeUrl(serverUrl);\n const fmsUrl = new URL(\"/fmws/serverinfo\", normalizedUrl).toString();\n const fmsResponse = yield* withFileMakerSetupError(\n `Unable to validate FileMaker Server URL: ${normalizedUrl}`,\n () => getJson<{ data?: { ServerVersion?: string } }>(fmsUrl),\n );\n const serverVersion = fmsResponse.data?.data?.ServerVersion?.split(\" \")[0];\n if (!serverVersion) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: `Invalid FileMaker Server URL: ${normalizedUrl}`,\n }),\n );\n }\n\n let ottoVersion: string | null = null;\n const otto4Response = yield* withFileMakerSetupError(\"Unable to query OttoFMS version.\", () =>\n getJson<{ response?: { Otto?: { version?: string } } }>(new URL(\"/otto/api/info\", normalizedUrl).toString()),\n ).pipe(Effect.catchAll(() => Effect.succeed(undefined)));\n ottoVersion = otto4Response?.data?.response?.Otto?.version ?? null;\n\n if (!ottoVersion) {\n const otto3Url = new URL(normalizedUrl);\n otto3Url.port = ottoPort ? String(ottoPort) : \"3030\";\n otto3Url.pathname = \"/api/otto/info\";\n const otto3Response = yield* withFileMakerSetupError(\"Unable to query OttoFMS v3 version.\", () =>\n getJson<{ Otto?: { version?: string } }>(otto3Url.toString()),\n ).pipe(Effect.catchAll(() => Effect.succeed(undefined)));\n ottoVersion = otto3Response?.data?.Otto?.version ?? null;\n }\n\n return {\n normalizedUrl: new URL(normalizedUrl).origin,\n versions: {\n fmsVersion: serverVersion,\n ottoVersion,\n },\n };\n }),\n getOttoFMSToken: ({ url }: { url: URL }) =>\n Effect.gen(function* () {\n const hash = randomUUID().replaceAll(\"-\", \"\").slice(0, 18);\n const loginUrl = new URL(`/otto/wizard/${hash}`, url.origin);\n log.info(`If the browser window didn't open automatically, use this Otto login URL:\\n${loginUrl.toString()}`);\n yield* withFileMakerSetupError(\"Unable to open OttoFMS login URL.\", () => openBrowser(loginUrl.toString()));\n\n const spin = createSpinner();\n spin.start(\"Waiting for OttoFMS login\");\n\n const deadline = Date.now() + 180_000;\n while (Date.now() < deadline) {\n const response = yield* withFileMakerSetupError(\"Unable to poll OttoFMS login status.\", () =>\n getJson<{ response?: { token?: string } }>(`${url.origin}/otto/api/cli/checkHash/${hash}`, {\n headers: { \"Accept-Encoding\": \"deflate\" },\n timeout: 5000,\n }),\n ).pipe(Effect.catchAll(() => Effect.succeed(undefined)));\n const token = response?.data?.response?.token;\n if (token) {\n spin.stop(\"Login complete\");\n yield* withFileMakerSetupError(\"Unable to clean up OttoFMS login state.\", () =>\n deleteJson(`${url.origin}/otto/api/cli/checkHash/${hash}`, {\n headers: { \"Accept-Encoding\": \"deflate\" },\n }),\n ).pipe(Effect.catchAll(() => Effect.void));\n return { token };\n }\n yield* Effect.promise(() => new Promise((resolve) => setTimeout(resolve, 500)));\n }\n\n spin.stop(\"Login timed out\");\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"OttoFMS login timed out after 3 minutes.\",\n }),\n );\n }),\n listFiles: ({ url, token }: { url: URL; token: string }) =>\n Effect.gen(function* () {\n const response = yield* withFileMakerSetupError(\"Unable to list FileMaker files from OttoFMS.\", () =>\n getJson<{ response?: { databases?: Array<{ filename?: string; status?: string }> } }>(\n `${url.origin}/otto/fmi/admin/api/v2/databases`,\n {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n },\n ),\n );\n const databases = Array.isArray(response.data?.response?.databases) ? response.data.response.databases : [];\n return databases\n .filter((database): database is { filename: string; status?: string } => typeof database.filename === \"string\")\n .map(\n (database) =>\n ({\n filename: database.filename,\n status: database.status ?? \"unknown\",\n }) satisfies OttoFileInfo,\n );\n }),\n listAPIKeys: ({ url, token }: { url: URL; token: string }) =>\n Effect.gen(function* () {\n const response = yield* withFileMakerSetupError(\"Unable to list OttoFMS Data API keys.\", () =>\n getJson<{ response?: { \"api-keys\"?: Record<string, unknown>[] } }>(`${url.origin}/otto/api/api-key`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n }),\n );\n const apiKeys = Array.isArray(response.data?.response?.[\"api-keys\"]) ? response.data.response[\"api-keys\"] : [];\n return apiKeys\n .filter(\n (apiKey): apiKey is { key: string; user: string; database: string; label: string } =>\n typeof apiKey.key === \"string\" &&\n typeof apiKey.user === \"string\" &&\n typeof apiKey.database === \"string\" &&\n typeof apiKey.label === \"string\",\n )\n .map(\n (apiKey) =>\n ({\n key: apiKey.key,\n user: apiKey.user,\n database: apiKey.database,\n label: apiKey.label,\n }) satisfies OttoApiKeyInfo,\n );\n }),\n createDataAPIKeyWithCredentials: ({\n url,\n filename,\n username,\n password: userPassword,\n }: {\n url: URL;\n filename: string;\n username: string;\n password: string;\n }) =>\n Effect.gen(function* () {\n const response = yield* withFileMakerSetupError(`Unable to create a Data API key for ${filename}.`, () =>\n postJson<{ response?: { key?: string } }>(`${url.origin}/otto/api/api-key/create-only`, {\n database: filename,\n label: \"For FM Web App\",\n user: username,\n pass: userPassword,\n }),\n );\n const apiKey = response.data?.response?.key;\n if (!apiKey) {\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: `Failed to create a Data API key for ${filename}.`,\n }),\n );\n }\n return { apiKey };\n }),\n startDeployment: ({ payload, url, token }: { payload: unknown; url: URL; token: string }) =>\n withFileMakerSetupError(\"Unable to start ProofKit Demo deployment.\", () =>\n postJson<{ response?: { subDeploymentIds?: number[] } }>(`${url.origin}/otto/api/deployment`, payload, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n }),\n ),\n getDeploymentStatus: ({ url, token, deploymentId }: { url: URL; token: string; deploymentId: number }) =>\n withFileMakerSetupError(`Unable to fetch deployment status for ${deploymentId}.`, () =>\n getJson<{ response?: { status?: string; running?: boolean } }>(\n `${url.origin}/otto/api/deployment/${deploymentId}`,\n {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n },\n ),\n ),\n deployDemoFile: ({ url, token, operation }: { url: URL; token: string; operation: \"install\" | \"replace\" }) =>\n Effect.gen(function* () {\n const demoFileName = \"ProofKitDemo.fmp12\";\n const spin = createSpinner();\n spin.start(\"Deploying ProofKit Demo file\");\n\n const deploymentPayload = {\n scheduled: false,\n label: \"Install ProofKit Demo\",\n deployments: [\n {\n name: \"Install ProofKit Demo\",\n source: {\n type: \"url\",\n url: \"https://proofkit.dev/proofkit-demo/manifest.json\",\n },\n fileOperations: [\n {\n target: {\n fileName: demoFileName,\n },\n operation,\n source: {\n fileName: demoFileName,\n },\n location: {\n folder: \"default\",\n subFolder: \"\",\n },\n },\n ],\n concurrency: 1,\n options: {\n closeFilesAfterBuild: false,\n keepFilesClosedAfterComplete: false,\n transferContainerData: false,\n },\n },\n ],\n abortRemaining: false,\n };\n\n const deployment = yield* fileMakerService.startDeployment({\n payload: deploymentPayload,\n url,\n token,\n });\n\n const deploymentId = deployment.data?.response?.subDeploymentIds?.[0];\n if (!deploymentId) {\n spin.stop(\"Demo deployment failed\");\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"No deployment ID was returned when deploying the demo file.\",\n }),\n );\n }\n\n const deploymentDeadline = Date.now() + 300_000;\n let deploymentCompleted = false;\n while (Date.now() < deploymentDeadline) {\n yield* Effect.promise(() => new Promise((resolve) => setTimeout(resolve, 2500)));\n const status = yield* fileMakerService.getDeploymentStatus({\n url,\n token,\n deploymentId,\n });\n\n if (!status.data?.response?.running) {\n if (status.data?.response?.status !== \"complete\") {\n spin.stop(\"Demo deployment failed\");\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"ProofKit Demo deployment did not complete successfully.\",\n }),\n );\n }\n deploymentCompleted = true;\n break;\n }\n }\n\n if (!deploymentCompleted) {\n spin.stop(\"Demo deployment timed out\");\n return yield* Effect.fail(\n new FileMakerSetupError({\n message: \"ProofKit Demo deployment timed out after 5 minutes.\",\n }),\n );\n }\n\n const apiKey = yield* fileMakerService.createDataAPIKeyWithCredentials({\n url,\n filename: demoFileName,\n username: \"admin\",\n password: \"admin\",\n });\n spin.stop(\"Demo file deployed\");\n return { apiKey: apiKey.apiKey, filename: demoFileName };\n }),\n listLayouts: ({ dataApiKey, fmFile, server }: { dataApiKey: string; fmFile: string; server: string }) =>\n Effect.gen(function* () {\n const response = yield* withFileMakerSetupError(`Unable to list layouts for ${fmFile}.`, () =>\n getJson<{ response?: { layouts?: LayoutFolder[] } }>(\n `${server}/otto/fmi/data/vLatest/databases/${encodeURIComponent(fmFile)}/layouts`,\n {\n headers: {\n Authorization: `Bearer ${dataApiKey}`,\n },\n },\n ),\n );\n const layouts = Array.isArray(response.data?.response?.layouts) ? response.data.response.layouts : [];\n return transformLayoutList(layouts);\n }),\n createFileMakerBootstrapArtifacts: (settings: ProofKitSettings, inputs: FileMakerInputs, appType: AppType) =>\n withFileMakerSetupError(\"Unable to prepare FileMaker bootstrap artifacts.\", () =>\n createFileMakerBootstrapArtifacts(settings, inputs, appType),\n ),\n bootstrap: (projectDir: string, settings: ProofKitSettings, inputs: FileMakerInputs, appType: AppType) =>\n Effect.gen(function* () {\n const artifacts = yield* fileMakerService.createFileMakerBootstrapArtifacts(settings, inputs, appType);\n const projectFilesFs = {\n exists: (targetPath: string) => Effect.runPromise(fileSystemService.exists(targetPath)),\n readFile: (targetPath: string) => Effect.runPromise(fileSystemService.readFile(targetPath)),\n writeFile: (targetPath: string, content: string) =>\n Effect.runPromise(fileSystemService.writeFile(targetPath, content)),\n };\n if (Object.keys(artifacts.envVars).length > 0) {\n yield* settingsService.appendEnvVars(projectDir, artifacts.envVars);\n yield* withFileMakerSetupError(\"Unable to update env schema for FileMaker bootstrap.\", () =>\n updateEnvSchemaFile(projectFilesFs, projectDir, artifacts.envSchemaEntries),\n );\n }\n\n yield* withFileMakerSetupError(\"Unable to update typegen config for FileMaker bootstrap.\", () =>\n updateTypegenConfig(projectFilesFs, projectDir, {\n appType: artifacts.typegenConfig.appType,\n dataSourceName: artifacts.typegenConfig.dataSourceName,\n envNames: artifacts.typegenConfig.envNames,\n fmMcpBaseUrl: artifacts.typegenConfig.fmMcpBaseUrl,\n connectedFileName: artifacts.typegenConfig.connectedFileName,\n layoutName: artifacts.typegenConfig.layoutName,\n schemaName: artifacts.typegenConfig.schemaName,\n }),\n );\n\n return artifacts.settings;\n }),\n};\n\nconst codegenService = {\n runInitial: (projectDir: string, packageManager: CliContextValue[\"packageManager\"]) => {\n let commandParts: string[];\n if (packageManager === \"npm\") {\n commandParts = [\"npm\", \"run\", \"typegen\"];\n } else if (packageManager === \"bun\") {\n commandParts = [\"bun\", \"run\", \"typegen\"];\n } else {\n commandParts = [packageManager, \"typegen\"];\n }\n const command = commandParts[0];\n if (!command) {\n return Effect.fail(\n new ExternalCommandError({\n message: \"Unable to resolve the codegen command\",\n command: packageManager,\n args: commandParts.slice(1),\n cwd: projectDir,\n }),\n );\n }\n const args = commandParts.slice(1);\n return withCommandError(\n command,\n args,\n projectDir,\n async () => {\n await execa(command, args, { cwd: projectDir });\n },\n \"Initial codegen failed\",\n );\n },\n};\n\nexport function makeLiveLayer(options: { cwd: string; debug: boolean; nonInteractive: boolean }) {\n const cliContext: CliContextValue = {\n cwd: options.cwd,\n debug: options.debug,\n nonInteractive: options.nonInteractive,\n packageManager: detectUserPackageManager(),\n };\n\n const layer = Layer.mergeAll(\n Layer.succeed(CliContext, cliContext),\n Layer.succeed(PromptService, promptService),\n Layer.succeed(ConsoleService, consoleService),\n Layer.succeed(FileSystemService, fileSystemService),\n Layer.succeed(TemplateService, templateService),\n Layer.succeed(PackageManagerService, packageManagerService),\n Layer.succeed(ProcessService, processService),\n Layer.succeed(GitService, gitService),\n Layer.succeed(SettingsService, settingsService),\n Layer.succeed(FileMakerService, fileMakerService),\n Layer.succeed(CodegenService, codegenService),\n );\n\n return <A, E, R>(effect: Fx.Effect<A, E, R>) => Effect.provide(effect, layer);\n}\n","const NON_INTERACTIVE_ENV_VARS = [\n \"CI\",\n \"GITHUB_ACTIONS\",\n \"CODEX\",\n \"OPENAI_CODEX\",\n \"CLAUDE_CODE\",\n \"JENKINS_URL\",\n \"BUILDKITE\",\n] as const;\n\nexport function detectNonInteractiveTerminal(options?: {\n stdinIsTTY?: boolean;\n stdoutIsTTY?: boolean;\n env?: NodeJS.ProcessEnv;\n}): boolean {\n const env = options?.env ?? process.env;\n const hasTTY = options?.stdinIsTTY === true && options?.stdoutIsTTY === true;\n const hasNonInteractiveEnv = NON_INTERACTIVE_ENV_VARS.some((name) => Boolean(env[name]));\n const hasDumbTerm = env.TERM === \"dumb\";\n return !hasTTY || hasNonInteractiveEnv || hasDumbTerm;\n}\n\nexport function resolveNonInteractiveMode(options?: {\n CI?: boolean;\n nonInteractive?: boolean;\n stdinIsTTY?: boolean;\n stdoutIsTTY?: boolean;\n env?: NodeJS.ProcessEnv;\n}) {\n if (options?.nonInteractive === true || options?.CI === true) {\n return true;\n }\n\n return detectNonInteractiveTerminal(options);\n}\n","import gradient from \"gradient-string\";\nimport { getTitleText } from \"~/consts.js\";\nimport { detectUserPackageManager } from \"~/utils/packageManager.js\";\n\nconst proofTheme = {\n purple: \"#89216B\",\n lightPurple: \"#D15ABB\",\n orange: \"#FF595E\",\n};\n\nexport const proofGradient = gradient(Object.values(proofTheme));\nexport function renderTitle(version = \"0.0.0-private\") {\n const pkgManager = detectUserPackageManager();\n if (pkgManager === \"yarn\" || pkgManager === \"pnpm\") {\n console.log(\"\");\n }\n console.log(proofGradient.multiline(getTitleText(version)));\n}\n","#!/usr/bin/env node\nimport { readFileSync, realpathSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { optional as optionalArg, text as textArg, withDescription as withArgDescription } from \"@effect/cli/Args\";\nimport {\n make as makeCommand,\n run,\n withDescription as withCommandDescription,\n withSubcommands,\n} from \"@effect/cli/Command\";\nimport {\n boolean as booleanOption,\n choice as choiceOption,\n optional as optionalOption,\n text as textOption,\n withAlias,\n withDescription as withOptionDescription,\n} from \"@effect/cli/Options\";\nimport { isValidationError } from \"@effect/cli/ValidationError\";\nimport { layer as nodeContextLayer } from \"@effect/platform-node/NodeContext\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { getOrUndefined } from \"effect/Option\";\nimport { cliName } from \"~/consts.js\";\nimport {\n CliContext,\n ConsoleService,\n FileSystemService,\n PackageManagerService,\n TemplateService,\n} from \"~/core/context.js\";\nimport { runDoctor } from \"~/core/doctor.js\";\nimport { getCliErrorMessage, isCliError, NonInteractiveInputError } from \"~/core/errors.js\";\nimport { executeInitPlan } from \"~/core/executeInitPlan.js\";\nimport { planInit } from \"~/core/planInit.js\";\nimport { runPrompt } from \"~/core/prompt.js\";\nimport { resolveInitRequest } from \"~/core/resolveInitRequest.js\";\nimport type { CliFlags } from \"~/core/types.js\";\nimport { makeLiveLayer } from \"~/services/live.js\";\nimport { resolveNonInteractiveMode } from \"~/utils/nonInteractive.js\";\nimport { intro } from \"~/utils/prompts.js\";\nimport { proofGradient, renderTitle } from \"~/utils/renderTitle.js\";\n\nconst defaultCliFlags: CliFlags = {\n noGit: false,\n noInstall: false,\n force: false,\n default: false,\n CI: false,\n importAlias: \"~/\",\n};\n\nfunction getCliVersion() {\n try {\n const packageJsonUrl = new URL(\"../package.json\", import.meta.url);\n const packageJson = JSON.parse(readFileSync(fileURLToPath(packageJsonUrl), \"utf8\")) as { version?: string };\n return packageJson.version ?? \"0.0.0-private\";\n } catch {\n return \"0.0.0-private\";\n }\n}\n\nexport const runInit = (name?: string, rawFlags?: Partial<CliFlags>) =>\n Effect.gen(function* () {\n const templateService = yield* TemplateService;\n const packageManagerService = yield* PackageManagerService;\n const request = yield* resolveInitRequest(name, { ...defaultCliFlags, ...rawFlags });\n const templateDir = templateService.getTemplateDir(request.appType, request.ui);\n const packageManagerVersion = yield* packageManagerService.getVersion(request.packageManager, request.cwd);\n const plan = planInit(request, { templateDir, packageManagerVersion });\n yield* executeInitPlan(plan);\n return { request, plan };\n });\n\nexport const runDefaultCommand = (rawFlags?: Partial<CliFlags>) =>\n Effect.gen(function* () {\n const cliContext = yield* CliContext;\n const fsService = yield* FileSystemService;\n const consoleService = yield* ConsoleService;\n const flags = { ...defaultCliFlags, ...rawFlags };\n const settingsPath = path.join(cliContext.cwd, \"proofkit.json\");\n const hasProofKitProject = yield* fsService.exists(settingsPath);\n\n if (hasProofKitProject) {\n intro(`Found ${proofGradient(\"ProofKit\")} project`);\n consoleService.note(\n [\n \"ProofKit now focuses on project bootstrap, diagnostics, and agent entrypoints.\",\n \"Use an explicit command such as `proofkit doctor`, `proofkit prompt`, or `proofkit init`.\",\n ].join(\"\\n\"),\n \"Project commands\",\n );\n return;\n }\n\n if (cliContext.nonInteractive || flags.CI || flags.nonInteractive) {\n return yield* Effect.fail(\n new NonInteractiveInputError({\n message:\n \"The default command is interactive-only in non-interactive mode. Run an explicit command such as `proofkit init <name> --non-interactive`.\",\n }),\n );\n }\n\n intro(`No ${proofGradient(\"ProofKit\")} project found, running \\`init\\``);\n yield* runInit(undefined, {\n ...flags,\n default: true,\n });\n });\n\nconst initDirectoryArg = optionalArg(textArg({ name: \"dir\" })).pipe(\n withArgDescription(\"The project name or target directory\"),\n);\n\nfunction optionalTextOption(name: string, description: string) {\n return optionalOption(textOption(name).pipe(withOptionDescription(description)));\n}\n\nfunction optionalChoiceOption<Choices extends readonly string[]>(name: string, choices: Choices, description: string) {\n return optionalOption(choiceOption(name, choices).pipe(withOptionDescription(description)));\n}\n\nfunction getCurrentTTYState() {\n return {\n stdinIsTTY: process.stdin?.isTTY,\n stdoutIsTTY: process.stdout?.isTTY,\n };\n}\n\nfunction legacyEffect<T>(runLegacy: () => Promise<T>, options?: { nonInteractive?: boolean; debug?: boolean }) {\n const nonInteractive = resolveNonInteractiveMode({\n nonInteractive: options?.nonInteractive,\n ...getCurrentTTYState(),\n });\n\n return makeLiveLayer({\n cwd: process.cwd(),\n debug: options?.debug === true,\n nonInteractive,\n })(Effect.promise(runLegacy));\n}\n\nfunction makeInitCommand() {\n return makeCommand(\n \"init\",\n {\n dir: initDirectoryArg,\n appType: optionalChoiceOption(\"app-type\", [\"browser\", \"webviewer\"] as const, \"The type of app to create\"),\n ui: optionalChoiceOption(\"ui\", [\"shadcn\", \"mantine\"] as const, \"The UI scaffold to create\"),\n server: optionalTextOption(\"server\", \"The URL of your FileMaker Server\"),\n adminApiKey: optionalTextOption(\"admin-api-key\", \"Admin API key for OttoFMS\"),\n fileName: optionalTextOption(\n \"file-name\",\n \"The FileMaker file name to use, including selecting a local connected file\",\n ),\n layoutName: optionalTextOption(\"layout-name\", \"The FileMaker layout name to scaffold\"),\n schemaName: optionalTextOption(\"schema-name\", \"The generated schema name\"),\n dataApiKey: optionalTextOption(\"data-api-key\", \"The Otto Data API key to use\"),\n dataSource: optionalChoiceOption(\"data-source\", [\"filemaker\", \"none\"] as const, \"The data source to use\"),\n noGit: booleanOption(\"no-git\").pipe(withOptionDescription(\"Skip git initialization\")),\n noInstall: booleanOption(\"no-install\").pipe(withOptionDescription(\"Skip package installation\")),\n force: booleanOption(\"force\").pipe(\n withAlias(\"f\"),\n withOptionDescription(\"Force overwrite target directory when it already contains files\"),\n ),\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ dir, ...options }) => {\n const nonInteractive = resolveNonInteractiveMode({\n CI: options.CI,\n nonInteractive: options.nonInteractive,\n ...getCurrentTTYState(),\n });\n\n const flags: CliFlags = {\n ...defaultCliFlags,\n appType: getOrUndefined(options.appType),\n ui: getOrUndefined(options.ui),\n server: getOrUndefined(options.server),\n adminApiKey: getOrUndefined(options.adminApiKey),\n fileName: getOrUndefined(options.fileName),\n layoutName: getOrUndefined(options.layoutName),\n schemaName: getOrUndefined(options.schemaName),\n dataApiKey: getOrUndefined(options.dataApiKey),\n dataSource: getOrUndefined(options.dataSource),\n noGit: options.noGit,\n noInstall: options.noInstall,\n force: options.force,\n CI: options.CI,\n nonInteractive: options.nonInteractive,\n debug: options.debug,\n };\n\n return makeLiveLayer({\n cwd: process.cwd(),\n debug: flags.debug === true,\n nonInteractive,\n })(runInit(getOrUndefined(dir), flags));\n },\n ).pipe(withCommandDescription(\"Create a new project with ProofKit\"));\n}\n\nfunction makeAddCommand() {\n return makeCommand(\n \"add\",\n {\n name: optionalArg(textArg({ name: \"name\" })).pipe(withArgDescription(\"Component or registry item to add\")),\n target: optionalArg(textArg({ name: \"target\" })).pipe(withArgDescription(\"Optional add target\")),\n noInstall: booleanOption(\"no-install\").pipe(withOptionDescription(\"Skip package installation\")),\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ name, target, noInstall, CI, nonInteractive, debug }) =>\n legacyEffect(\n async () => {\n const [{ runAdd }, { initProgramState, state }] = await Promise.all([\n import(\"~/cli/add/index.js\"),\n import(\"~/state.js\"),\n ]);\n initProgramState({\n noInstall,\n ci: CI,\n nonInteractive,\n debug,\n });\n state.baseCommand = \"add\";\n state.projectDir = process.cwd();\n await runAdd(getOrUndefined(name), { noInstall, target: getOrUndefined(target) });\n },\n { nonInteractive: CI || nonInteractive, debug },\n ),\n ).pipe(withCommandDescription(\"Legacy command. Prefer package-native tools, agents, or shadcn.\"));\n}\n\nfunction makeRemoveCommand() {\n return makeCommand(\n \"remove\",\n {\n name: optionalArg(textArg({ name: \"name\" })).pipe(withArgDescription(\"Component type to remove\")),\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ name, CI, nonInteractive, debug }) =>\n legacyEffect(\n async () => {\n const [{ runRemove }, { initProgramState, state }] = await Promise.all([\n import(\"~/cli/remove/index.js\"),\n import(\"~/state.js\"),\n ]);\n initProgramState({\n ci: CI,\n nonInteractive,\n debug,\n });\n state.baseCommand = \"remove\";\n state.projectDir = process.cwd();\n await runRemove(getOrUndefined(name));\n },\n { nonInteractive: CI || nonInteractive, debug },\n ),\n ).pipe(withCommandDescription(\"Legacy command. Prefer direct code edits or package-native tools.\"));\n}\n\nfunction makeTypegenCommand() {\n return makeCommand(\n \"typegen\",\n {\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ debug }) =>\n legacyEffect(\n async () => {\n const [{ runTypegen }, { state }] = await Promise.all([\n import(\"~/cli/typegen/index.js\"),\n import(\"~/state.js\"),\n ]);\n state.projectDir = process.cwd();\n await runTypegen({\n settings: (await import(\"~/utils/parseSettings.js\")).getSettings(),\n });\n },\n { debug },\n ),\n ).pipe(withCommandDescription(\"Legacy alias. Prefer `npx @proofkit/typegen`.\"));\n}\n\nfunction makeDeployCommand() {\n return makeCommand(\n \"deploy\",\n {\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ debug }) =>\n legacyEffect(\n async () => {\n const [{ runDeploy }, { initProgramState, state }] = await Promise.all([\n import(\"~/cli/deploy/index.js\"),\n import(\"~/state.js\"),\n ]);\n initProgramState({ debug });\n state.baseCommand = \"deploy\";\n state.projectDir = process.cwd();\n await runDeploy();\n },\n { debug },\n ),\n ).pipe(withCommandDescription(\"Deploy your app\"));\n}\n\nfunction makeUpgradeCommand() {\n return makeCommand(\n \"upgrade\",\n {\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ CI, nonInteractive, debug }) =>\n legacyEffect(\n async () => {\n const [{ runUpgrade }, { initProgramState, state }] = await Promise.all([\n import(\"~/cli/update/index.js\"),\n import(\"~/state.js\"),\n ]);\n initProgramState({ ci: CI, nonInteractive, debug });\n state.baseCommand = \"upgrade\";\n state.projectDir = process.cwd();\n await runUpgrade();\n },\n { nonInteractive: CI || nonInteractive, debug },\n ),\n ).pipe(withCommandDescription(\"Legacy command.\"));\n}\n\nfunction makeDoctorCommand() {\n return makeCommand(\n \"doctor\",\n {\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ debug }) =>\n makeLiveLayer({\n cwd: process.cwd(),\n debug: debug === true,\n nonInteractive: true,\n })(runDoctor),\n ).pipe(withCommandDescription(\"Inspect project health and suggest exact next steps\"));\n}\n\nfunction makePromptCommand() {\n return makeCommand(\n \"prompt\",\n {\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n ({ debug }) =>\n makeLiveLayer({\n cwd: process.cwd(),\n debug: debug === true,\n nonInteractive: true,\n })(runPrompt),\n ).pipe(withCommandDescription(\"Agent workflow entrypoint placeholder\"));\n}\n\nconst rootCommand = makeCommand(\n cliName,\n {\n CI: booleanOption(\"ci\").pipe(withOptionDescription(\"Deprecated alias for --non-interactive\")),\n nonInteractive: booleanOption(\"non-interactive\").pipe(\n withOptionDescription(\"Never prompt for input; fail when required values are missing\"),\n ),\n debug: booleanOption(\"debug\").pipe(withOptionDescription(\"Run in debug mode\")),\n },\n (options) =>\n makeLiveLayer({\n cwd: process.cwd(),\n debug: options.debug === true,\n nonInteractive: resolveNonInteractiveMode({\n CI: options.CI,\n nonInteractive: options.nonInteractive,\n ...getCurrentTTYState(),\n }),\n })(\n runDefaultCommand({\n ...defaultCliFlags,\n CI: options.CI,\n nonInteractive: options.nonInteractive,\n debug: options.debug,\n }),\n ),\n).pipe(\n withCommandDescription(\"Interactive CLI to scaffold and manage ProofKit projects\"),\n withSubcommands([\n makeInitCommand(),\n makeDoctorCommand(),\n makePromptCommand(),\n makeAddCommand(),\n makeRemoveCommand(),\n makeTypegenCommand(),\n makeDeployCommand(),\n makeUpgradeCommand(),\n ]),\n);\n\nexport const cli = run(rootCommand, {\n name: \"ProofKit\",\n version: getCliVersion(),\n});\n\nfunction isMainEntrypoint(argvPath: string | undefined, moduleUrl: string) {\n if (!argvPath) {\n return false;\n }\n\n const resolvedModulePath = fileURLToPath(moduleUrl);\n\n try {\n return realpathSync(argvPath) === realpathSync(resolvedModulePath);\n } catch {\n return path.resolve(argvPath) === path.resolve(resolvedModulePath);\n }\n}\n\nconst isMainModule = isMainEntrypoint(process.argv[1], import.meta.url);\n\nconst debugFlagNames = new Set([\"--debug\"]);\n\nfunction shouldShowDebugDetails(argv: readonly string[]) {\n return argv.some((arg) => debugFlagNames.has(arg));\n}\n\nexport function renderFailure(cause: Cause.Cause<unknown>, showDebugDetails: boolean) {\n const failure = getOrUndefined(Cause.failureOption(cause));\n\n if (failure && isValidationError(failure)) {\n if (showDebugDetails) {\n console.error(`\\n[debug] ${Cause.pretty(cause)}`);\n }\n return;\n }\n\n if (failure && isCliError(failure)) {\n console.error(getCliErrorMessage(failure));\n } else {\n const error = Cause.squash(cause);\n console.error(error instanceof Error ? error.message : String(error));\n }\n\n if (showDebugDetails) {\n console.error(`\\n[debug] ${Cause.pretty(cause)}`);\n }\n}\n\nasync function main(argv: readonly string[]) {\n const showDebugDetails = shouldShowDebugDetails(argv);\n const exit = await Effect.runPromiseExit(Effect.provide(cli(argv), nodeContextLayer));\n\n if (Exit.isFailure(exit)) {\n renderFailure(exit.cause, showDebugDetails);\n process.exitCode = 1;\n }\n}\n\nif (isMainModule) {\n renderTitle(getCliVersion());\n main(process.argv).catch((error) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n });\n}\n"],"mappings":";83CAoBA,MAAa,EAAa,EAAQ,WAA4B,2BAA2B,CA6B5E,GAAgB,EAAQ,WAA0B,8BAA8B,CAUhF,EAAiB,EAAQ,WAA2B,+BAA+B,CAenF,EAAoB,EAAQ,WAA8B,kCAAkC,CAM5F,GAAkB,EAAQ,WAA4B,gCAAgC,CAMtF,GAAwB,EAAQ,WAAkC,sCAAsC,CAcxG,GAAiB,EAAQ,WAA2B,+BAA+B,CAMnF,GAAa,EAAQ,WAAuB,2BAA2B,CAOvE,GAAkB,EAAQ,WAA4B,gCAAgC,CA2FtF,GAAmB,EAAQ,WAA6B,iCAAiC,CAMzF,GAAiB,EAAQ,WAA2B,+BAA+B,CC1LhG,SAAS,EAAW,EAAkB,EAA2B,CAC3D,GAAS,CAAC,EAAO,SAAS,EAAM,EAClC,EAAO,KAAK,EAAM,CAItB,SAAS,GAAoB,EAE3B,CACA,OAAyB,OAAO,GAAU,YAAnC,GAA+C,WAAY,EAGpE,MAAa,GAAY,E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