arkenv 1.0.0-alpha.11 → 1.0.0-alpha.13

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","names":["pc","NO_TRUNCATION","fastStringTruncatedWidth","stringWidth","h","C","z","Y","w","R","D","S","O","c","M","p","V","J","H","Q","#s","v","#n","#u","#t","#e","#i","#r","tt","U","$","F","st","et","#c","#a","#d","#f","#g","#o","#h","#l","#p","#m","it","ot","ut","at","ht","E","e","X","Bt","q","vt","_","k","A","Lt","O","Dt","Wt","Ft","Ht","Ut","Kt","wt","bt","Qt","Zt","St","Ct","qt","Jt","Yt","nt","Xt","pc","clackSpinner","pc","pc","pc","confirm","pc","isCancel","select","isCancel","select","isCancel","confirm","select","isCancel","confirm","isCancel","text","text","confirm","isCancel","clackConfirm","isCancel","clackSelect","pc"],"sources":["../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js","../src/shared/errors.ts","../src/adapters/reporters/json.reporter.ts","../src/adapters/reporters/silent.reporter.ts","../../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js","../../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js","../../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js","../../../node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js","../../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js","../../../node_modules/.pnpm/@clack+core@1.3.0/node_modules/@clack/core/dist/index.mjs","../../../node_modules/.pnpm/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs","../src/adapters/reporters/text.reporter.ts","../src/adapters/logger.adapter.ts","../../internal/log/dist/index.js","../src/adapters/injection.ts","../src/adapters/node-project-scanner/utils/detector.ts","../src/adapters/node-project-scanner/utils/env-scanner.ts","../src/adapters/node-project-scanner/utils/tsconfig.ts","../src/adapters/node-project-scanner/utils/requirements.ts","../src/adapters/node-project-scanner/node-project-scanner.adapter.ts","../src/shared/visuals.ts","../src/features/scaffold/frameworks/codegen-config.ts","../src/features/scaffold/frameworks/client-prefixes.ts","../src/features/scaffold/scaffold-context.ts","../src/features/scaffold/frameworks/shared.ts","../src/features/scaffold/frameworks/bun-fullstack.ts","../src/features/scaffold/frameworks/codegen-framework.ts","../src/features/scaffold/frameworks/nextjs.ts","../src/features/scaffold/frameworks/nuxt.ts","../src/features/scaffold/frameworks/vanilla.ts","../src/features/scaffold/frameworks/vite.ts","../src/features/scaffold/frameworks/index.ts","../src/features/scaffold/presets.ts","../src/features/scaffold/validators/dialects/types.ts","../src/features/scaffold/validators/dialects/arktype.ts","../src/features/scaffold/validators/dialects/valibot.ts","../src/features/scaffold/validators/dialects/zod.ts","../src/features/scaffold/validators/dialects/index.ts","../src/features/config-mutation/config-mutation.ts","../src/adapters/node-workspace/utils/bootstrappers.ts","../src/adapters/node-workspace/utils/tsconfig.ts","../src/adapters/node-workspace/node-workspace.ts","../src/cli/ui/prompts/steps/env-example.ts","../src/cli/ui/prompts/steps/example.ts","../src/cli/ui/prompts/steps/framework.ts","../src/cli/ui/prompts/steps/host-preset.ts","../src/cli/ui/prompts/steps/path.ts","../src/cli/ui/prompts/steps.ts","../src/cli/ui/prompts/wizard.ts","../src/adapters/prompt.adapter.ts","../src/cli/cli.ts","../package.json","../src/cli/commands/help.ts","../src/features/scaffold/cloner.ts","../src/features/scaffold/utils.ts","../src/features/scaffold/executor.ts","../src/features/scaffold/frameworks/example-env-defaults.ts","../src/features/scaffold/scaffold.ts","../src/features/scaffold/frameworks/layouts/codegen.ts","../src/features/scaffold/validators/assemble-simple.ts","../src/features/scaffold/validators/shared.ts","../src/features/scaffold/validators/assemble-strict.ts","../src/features/scaffold/validators/create-strategy.ts","../src/features/scaffold/validators/index.ts","../src/features/scaffold/planner.ts","../src/shared/clients/registry.client.ts","../src/cli/commands/init.ts","../src/cli/commands/preset.ts","../src/cli/composition.ts","../src/bin.ts"],"sourcesContent":["let p = process || {}, argv = p.argv || [], env = p.env || {}\nlet isColorSupported =\n\t!(!!env.NO_COLOR || argv.includes(\"--no-color\")) &&\n\t(!!env.FORCE_COLOR || argv.includes(\"--color\") || p.platform === \"win32\" || ((p.stdout || {}).isTTY && env.TERM !== \"dumb\") || !!env.CI)\n\nlet formatter = (open, close, replace = open) =>\n\tinput => {\n\t\tlet string = \"\" + input, index = string.indexOf(close, open.length)\n\t\treturn ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close\n\t}\n\nlet replaceClose = (string, close, replace, index) => {\n\tlet result = \"\", cursor = 0\n\tdo {\n\t\tresult += string.substring(cursor, index) + replace\n\t\tcursor = index + close.length\n\t\tindex = string.indexOf(close, cursor)\n\t} while (~index)\n\treturn result + string.substring(cursor)\n}\n\nlet createColors = (enabled = isColorSupported) => {\n\tlet f = enabled ? formatter : () => String\n\treturn {\n\t\tisColorSupported: enabled,\n\t\treset: f(\"\\x1b[0m\", \"\\x1b[0m\"),\n\t\tbold: f(\"\\x1b[1m\", \"\\x1b[22m\", \"\\x1b[22m\\x1b[1m\"),\n\t\tdim: f(\"\\x1b[2m\", \"\\x1b[22m\", \"\\x1b[22m\\x1b[2m\"),\n\t\titalic: f(\"\\x1b[3m\", \"\\x1b[23m\"),\n\t\tunderline: f(\"\\x1b[4m\", \"\\x1b[24m\"),\n\t\tinverse: f(\"\\x1b[7m\", \"\\x1b[27m\"),\n\t\thidden: f(\"\\x1b[8m\", \"\\x1b[28m\"),\n\t\tstrikethrough: f(\"\\x1b[9m\", \"\\x1b[29m\"),\n\n\t\tblack: f(\"\\x1b[30m\", \"\\x1b[39m\"),\n\t\tred: f(\"\\x1b[31m\", \"\\x1b[39m\"),\n\t\tgreen: f(\"\\x1b[32m\", \"\\x1b[39m\"),\n\t\tyellow: f(\"\\x1b[33m\", \"\\x1b[39m\"),\n\t\tblue: f(\"\\x1b[34m\", \"\\x1b[39m\"),\n\t\tmagenta: f(\"\\x1b[35m\", \"\\x1b[39m\"),\n\t\tcyan: f(\"\\x1b[36m\", \"\\x1b[39m\"),\n\t\twhite: f(\"\\x1b[37m\", \"\\x1b[39m\"),\n\t\tgray: f(\"\\x1b[90m\", \"\\x1b[39m\"),\n\n\t\tbgBlack: f(\"\\x1b[40m\", \"\\x1b[49m\"),\n\t\tbgRed: f(\"\\x1b[41m\", \"\\x1b[49m\"),\n\t\tbgGreen: f(\"\\x1b[42m\", \"\\x1b[49m\"),\n\t\tbgYellow: f(\"\\x1b[43m\", \"\\x1b[49m\"),\n\t\tbgBlue: f(\"\\x1b[44m\", \"\\x1b[49m\"),\n\t\tbgMagenta: f(\"\\x1b[45m\", \"\\x1b[49m\"),\n\t\tbgCyan: f(\"\\x1b[46m\", \"\\x1b[49m\"),\n\t\tbgWhite: f(\"\\x1b[47m\", \"\\x1b[49m\"),\n\n\t\tblackBright: f(\"\\x1b[90m\", \"\\x1b[39m\"),\n\t\tredBright: f(\"\\x1b[91m\", \"\\x1b[39m\"),\n\t\tgreenBright: f(\"\\x1b[92m\", \"\\x1b[39m\"),\n\t\tyellowBright: f(\"\\x1b[93m\", \"\\x1b[39m\"),\n\t\tblueBright: f(\"\\x1b[94m\", \"\\x1b[39m\"),\n\t\tmagentaBright: f(\"\\x1b[95m\", \"\\x1b[39m\"),\n\t\tcyanBright: f(\"\\x1b[96m\", \"\\x1b[39m\"),\n\t\twhiteBright: f(\"\\x1b[97m\", \"\\x1b[39m\"),\n\n\t\tbgBlackBright: f(\"\\x1b[100m\", \"\\x1b[49m\"),\n\t\tbgRedBright: f(\"\\x1b[101m\", \"\\x1b[49m\"),\n\t\tbgGreenBright: f(\"\\x1b[102m\", \"\\x1b[49m\"),\n\t\tbgYellowBright: f(\"\\x1b[103m\", \"\\x1b[49m\"),\n\t\tbgBlueBright: f(\"\\x1b[104m\", \"\\x1b[49m\"),\n\t\tbgMagentaBright: f(\"\\x1b[105m\", \"\\x1b[49m\"),\n\t\tbgCyanBright: f(\"\\x1b[106m\", \"\\x1b[49m\"),\n\t\tbgWhiteBright: f(\"\\x1b[107m\", \"\\x1b[49m\"),\n\t}\n}\n\nmodule.exports = createColors()\nmodule.exports.createColors = createColors\n","/**\n * Stable, machine-actionable error codes emitted in the CLI's JSON output\n * (`--json` / `--agent` mode).\n *\n * These codes are part of the CLI's **public contract**: consumers such as AI\n * agents and scripts may branch on them to decide how to escalate, so they must\n * never be renamed casually. Codes fall into two groups:\n *\n * - **Refusals** - deliberate safety-check refusals. When bypassable, the emitted\n * payload includes a `retryWith` array naming the flag(s) that would proceed\n * anyway (e.g. `[\"--force\"]`).\n * - **`INTERNAL`** - an unexpected failure (the CLI *broke* rather than *refused*).\n * This lets consumers distinguish a deliberate refusal from a crash.\n */\nexport const ERROR_CODES = {\n\t/**\n\t * Technical requirements (e.g. Node.js version) were not met. Bypassable with `--force`.\n\t */\n\tREQUIREMENTS_NOT_MET: \"REQUIREMENTS_NOT_MET\",\n\t/**\n\t * The git working tree is not clean. Bypassable with `--force`.\n\t */\n\tGIT_TREE_DIRTY: \"GIT_TREE_DIRTY\",\n\t/**\n\t * The target directory is not empty (and holds no `package.json`). Bypassable with `--force`.\n\t */\n\tNON_EMPTY_DIR: \"NON_EMPTY_DIR\",\n\t/**\n\t * An unexpected, internal failure. Not a deliberate refusal and not bypassable.\n\t */\n\tINTERNAL: \"INTERNAL\",\n} as const;\n\n/**\n * One of the stable {@link ERROR_CODES} string values.\n */\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/**\n * A deliberate, machine-readable refusal emitted when a safety check trips.\n *\n * Refusals are distinct from unexpected failures: they carry a stable {@link ErrorCode}\n * and a `retryWith` hint so a calling agent can decide whether (and how) to escalate\n * without pattern-matching on human-oriented prose.\n */\nexport type Refusal = {\n\t/**\n\t * Stable, documented code identifying the refusal reason.\n\t */\n\tcode: ErrorCode;\n\t/**\n\t * Human-readable summary of what was refused.\n\t */\n\tmessage: string;\n\t/**\n\t * Flags that would bypass the check when re-run (e.g. `[\"--force\"]`).\n\t * Empty when the refusal cannot be bypassed.\n\t */\n\tretryWith: string[];\n\t/**\n\t * Structured detail sufficient for a consumer to report the problem.\n\t */\n\tdetails?: Record<string, unknown>;\n};\n","import pc from \"picocolors\";\nimport { ERROR_CODES, type Refusal } from \"@/shared/errors\";\nimport type { Reporter, Spinner } from \"./types\";\n\n/**\n * Reporter implementation that outputs structured JSON logs.\n * Useful for machine-readable output or agent modes.\n */\nexport class JsonReporter implements Reporter {\n\tinfo(message: string) {\n\t\tprocess.stderr.write(`${pc.blue(`ℹ ${message}`)}\\n`);\n\t}\n\n\twarn(message: string) {\n\t\tprocess.stderr.write(`${pc.yellow(`⚠ ${message}`)}\\n`);\n\t}\n\n\terror(message: string) {\n\t\tprocess.stderr.write(`${pc.red(`✘ ${message}`)}\\n`);\n\t}\n\n\tsuccess(message: string) {\n\t\tprocess.stderr.write(`${pc.green(`✔ ${message}`)}\\n`);\n\t}\n\n\tstep(message: string) {\n\t\tprocess.stderr.write(`○ ${message}\\n`);\n\t}\n\n\tnote(message: string, title?: string) {\n\t\tprocess.stderr.write(\n\t\t\t`${pc.dim(`○ ${title ? `${title}: ` : \"\"}${message}`)}\\n`,\n\t\t);\n\t}\n\n\tlog(message: string) {\n\t\tprocess.stderr.write(`${message}\\n`);\n\t}\n\n\tspinner(): Spinner {\n\t\treturn {\n\t\t\tstart: (msg: string) =>\n\t\t\t\tprocess.stderr.write(`${pc.dim(`○ ${msg}...`)}\\n`),\n\t\t\tstop: (msg: string) => process.stderr.write(`${pc.green(`✔ ${msg}`)}\\n`),\n\t\t\tmessage: (msg: string) =>\n\t\t\t\tprocess.stderr.write(`${pc.dim(`○ ${msg}...`)}\\n`),\n\t\t};\n\t}\n\n\tjson(data: unknown) {\n\t\tprocess.stdout.write(`${JSON.stringify(data, null, 2)}\\n`);\n\t}\n\n\tcancel(message: string) {\n\t\tthis.json({\n\t\t\tstatus: \"cancelled\",\n\t\t\tmessage,\n\t\t});\n\t}\n\n\tfatal(message: string, error?: unknown): never {\n\t\tconst errorText =\n\t\t\terror instanceof Error\n\t\t\t\t? error.message\n\t\t\t\t: error\n\t\t\t\t\t? String(error)\n\t\t\t\t\t: undefined;\n\t\tthis.json({\n\t\t\tstatus: \"error\",\n\t\t\tcode: ERROR_CODES.INTERNAL,\n\t\t\tmessage,\n\t\t\tretryWith: [],\n\t\t\t...(errorText !== undefined ? { details: { error: errorText } } : {}),\n\t\t});\n\t\tthrow error instanceof Error ? error : new Error(message);\n\t}\n\n\trefuse(refusal: Refusal) {\n\t\tthis.json({\n\t\t\tstatus: \"error\",\n\t\t\tcode: refusal.code,\n\t\t\tmessage: refusal.message,\n\t\t\tretryWith: refusal.retryWith,\n\t\t\t...(refusal.details !== undefined ? { details: refusal.details } : {}),\n\t\t});\n\t}\n\n\tfinish(message: string, details?: Record<string, unknown>) {\n\t\tthis.json({\n\t\t\tstatus: \"success\",\n\t\t\tmessage,\n\t\t\tdetails,\n\t\t});\n\t}\n\n\tasync flush(): Promise<void> {\n\t\treturn new Promise((resolve) => {\n\t\t\tprocess.stdout.write(\"\", () => resolve());\n\t\t});\n\t}\n}\n","import type { Refusal } from \"@/shared/errors\";\nimport type { Reporter, Spinner } from \"./types\";\n\n/**\n * Reporter implementation that suppresses most output.\n * Useful for quiet/background execution modes.\n */\nexport class SilentReporter implements Reporter {\n\tprivate stripAnsi(message: string): string {\n\t\t// biome-ignore lint/suspicious/noControlCharactersInRegex: Standard ANSI escape code stripping\n\t\treturn message.replace(/\\x1B\\[[0-9;]*[JKmsu]/g, \"\");\n\t}\n\n\tinfo(_message: string) {}\n\twarn(_message: string) {}\n\terror(_message: string) {}\n\tsuccess(_message: string) {}\n\tstep(_message: string) {}\n\tnote(_message: string, _title?: string) {}\n\tlog(message: string) {\n\t\tprocess.stdout.write(`${this.stripAnsi(message)}\\n`);\n\t}\n\n\tspinner(): Spinner {\n\t\treturn {\n\t\t\tstart: (_msg: string) => {},\n\t\t\tstop: (_msg: string) => {},\n\t\t\tmessage: (_msg: string) => {},\n\t\t};\n\t}\n\n\tjson(data: unknown) {\n\t\tprocess.stdout.write(`${JSON.stringify(data, null, 2)}\\n`);\n\t}\n\n\tcancel(message: string) {\n\t\tprocess.stderr.write(`✘ Cancelled: ${message}\\n`);\n\t}\n\n\tfatal(message: string, error?: unknown): never {\n\t\tprocess.stderr.write(`✘ Fatal: ${message}\\n`);\n\t\tif (error) {\n\t\t\tprocess.stderr.write(\n\t\t\t\t`${error instanceof Error ? (error.stack ?? error.message) : String(error)}\\n`,\n\t\t\t);\n\t\t}\n\t\tthrow error instanceof Error ? error : new Error(message);\n\t}\n\n\trefuse(_refusal: Refusal) {}\n\n\tfinish(_message: string, _details?: Record<string, unknown>) {}\n\n\tasync flush(): Promise<void> {\n\t\treturn new Promise((resolve) => {\n\t\t\tprocess.stderr.write(\"\", () => resolve());\n\t\t});\n\t}\n}\n","/* MAIN */\nconst getCodePointsLength = (() => {\n const SURROGATE_PAIR_RE = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n return (input) => {\n let surrogatePairsNr = 0;\n SURROGATE_PAIR_RE.lastIndex = 0;\n while (SURROGATE_PAIR_RE.test(input)) {\n surrogatePairsNr += 1;\n }\n return input.length - surrogatePairsNr;\n };\n})();\nconst isFullWidth = (x) => {\n return x === 0x3000 || x >= 0xFF01 && x <= 0xFF60 || x >= 0xFFE0 && x <= 0xFFE6;\n};\nconst isWideNotCJKTNotEmoji = (x) => {\n return x === 0x231B || x === 0x2329 || x >= 0x2FF0 && x <= 0x2FFF || x >= 0x3001 && x <= 0x303E || x >= 0x3099 && x <= 0x30FF || x >= 0x3105 && x <= 0x312F || x >= 0x3131 && x <= 0x318E || x >= 0x3190 && x <= 0x31E3 || x >= 0x31EF && x <= 0x321E || x >= 0x3220 && x <= 0x3247 || x >= 0x3250 && x <= 0x4DBF || x >= 0xFE10 && x <= 0xFE19 || x >= 0xFE30 && x <= 0xFE52 || x >= 0xFE54 && x <= 0xFE66 || x >= 0xFE68 && x <= 0xFE6B || x >= 0x1F200 && x <= 0x1F202 || x >= 0x1F210 && x <= 0x1F23B || x >= 0x1F240 && x <= 0x1F248 || x >= 0x20000 && x <= 0x2FFFD || x >= 0x30000 && x <= 0x3FFFD;\n};\n/* EXPORT */\nexport { getCodePointsLength, isFullWidth, isWideNotCJKTNotEmoji };\n","/* IMPORT */\nimport { getCodePointsLength, isFullWidth, isWideNotCJKTNotEmoji } from './utils.js';\n/* HELPERS */\nconst ANSI_RE = /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\\u001b\\]8;[^;]*;.*?(?:\\u0007|\\u001b\\u005c)/y;\nconst CONTROL_RE = /[\\x00-\\x08\\x0A-\\x1F\\x7F-\\x9F]{1,1000}/y;\nconst CJKT_WIDE_RE = /(?:(?![\\uFF61-\\uFF9F\\uFF00-\\uFFEF])[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Hangul}\\p{Script=Tangut}]){1,1000}/yu;\nconst TAB_RE = /\\t{1,1000}/y;\nconst EMOJI_RE = /[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*/yu;\nconst LATIN_RE = /(?:[\\x20-\\x7E\\xA0-\\xFF](?!\\uFE0F)){1,1000}/y;\nconst MODIFIER_RE = /\\p{M}+/gu;\nconst NO_TRUNCATION = { limit: Infinity, ellipsis: '' };\n/* MAIN */\nconst getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {\n /* CONSTANTS */\n const LIMIT = truncationOptions.limit ?? Infinity;\n const ELLIPSIS = truncationOptions.ellipsis ?? '';\n const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);\n const ANSI_WIDTH = 0;\n const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;\n const TAB_WIDTH = widthOptions.tabWidth ?? 8;\n const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;\n const FULL_WIDTH_WIDTH = 2;\n const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;\n const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;\n const PARSE_BLOCKS = [\n [LATIN_RE, REGULAR_WIDTH],\n [ANSI_RE, ANSI_WIDTH],\n [CONTROL_RE, CONTROL_WIDTH],\n [TAB_RE, TAB_WIDTH],\n [EMOJI_RE, EMOJI_WIDTH],\n [CJKT_WIDE_RE, WIDE_WIDTH],\n ];\n /* STATE */\n let indexPrev = 0;\n let index = 0;\n let length = input.length;\n let lengthExtra = 0;\n let truncationEnabled = false;\n let truncationIndex = length;\n let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);\n let unmatchedStart = 0;\n let unmatchedEnd = 0;\n let width = 0;\n let widthExtra = 0;\n /* PARSE LOOP */\n outer: while (true) {\n /* UNMATCHED */\n if ((unmatchedEnd > unmatchedStart) || (index >= length && index > indexPrev)) {\n const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);\n lengthExtra = 0;\n for (const char of unmatched.replaceAll(MODIFIER_RE, '')) {\n const codePoint = char.codePointAt(0) || 0;\n if (isFullWidth(codePoint)) {\n widthExtra = FULL_WIDTH_WIDTH;\n }\n else if (isWideNotCJKTNotEmoji(codePoint)) {\n widthExtra = WIDE_WIDTH;\n }\n else {\n widthExtra = REGULAR_WIDTH;\n }\n if ((width + widthExtra) > truncationLimit) {\n truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);\n }\n if ((width + widthExtra) > LIMIT) {\n truncationEnabled = true;\n break outer;\n }\n lengthExtra += char.length;\n width += widthExtra;\n }\n unmatchedStart = unmatchedEnd = 0;\n }\n /* EXITING */\n if (index >= length) {\n break outer;\n }\n /* PARSE BLOCKS */\n for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {\n const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];\n BLOCK_RE.lastIndex = index;\n if (BLOCK_RE.test(input)) {\n lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;\n widthExtra = lengthExtra * BLOCK_WIDTH;\n if ((width + widthExtra) > truncationLimit) {\n truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));\n }\n if ((width + widthExtra) > LIMIT) {\n truncationEnabled = true;\n break outer;\n }\n width += widthExtra;\n unmatchedStart = indexPrev;\n unmatchedEnd = index;\n index = indexPrev = BLOCK_RE.lastIndex;\n continue outer;\n }\n }\n /* UNMATCHED INDEX */\n index += 1;\n }\n /* RETURN */\n return {\n width: truncationEnabled ? truncationLimit : width,\n index: truncationEnabled ? truncationIndex : length,\n truncated: truncationEnabled,\n ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH\n };\n};\n/* EXPORT */\nexport default getStringTruncatedWidth;\n","/* IMPORT */\nimport fastStringTruncatedWidth from 'fast-string-truncated-width';\n/* HELPERS */\nconst NO_TRUNCATION = {\n limit: Infinity,\n ellipsis: '',\n ellipsisWidth: 0,\n};\n/* MAIN */\nconst fastStringWidth = (input, options = {}) => {\n return fastStringTruncatedWidth(input, NO_TRUNCATION, options).width;\n};\n/* EXPORT */\nexport default fastStringWidth;\n","import stringWidth from 'fast-string-width';\nconst ESC = '\\x1B';\nconst CSI = '\\x9B';\nconst END_CODE = 39;\nconst ANSI_ESCAPE_BELL = '\\u0007';\nconst ANSI_CSI = '[';\nconst ANSI_OSC = ']';\nconst ANSI_SGR_TERMINATOR = 'm';\nconst ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;\nconst GROUP_REGEX = new RegExp(`(?:\\\\${ANSI_CSI}(?<code>\\\\d+)m|\\\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, 'y');\nconst getClosingCode = (openingCode) => {\n if (openingCode >= 30 && openingCode <= 37)\n return 39;\n if (openingCode >= 90 && openingCode <= 97)\n return 39;\n if (openingCode >= 40 && openingCode <= 47)\n return 49;\n if (openingCode >= 100 && openingCode <= 107)\n return 49;\n if (openingCode === 1 || openingCode === 2)\n return 22;\n if (openingCode === 3)\n return 23;\n if (openingCode === 4)\n return 24;\n if (openingCode === 7)\n return 27;\n if (openingCode === 8)\n return 28;\n if (openingCode === 9)\n return 29;\n if (openingCode === 0)\n return 0;\n return undefined;\n};\nconst wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;\nconst wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;\nconst wrapWord = (rows, word, columns) => {\n const characters = word[Symbol.iterator]();\n let isInsideEscape = false;\n let isInsideLinkEscape = false;\n let lastRow = rows.at(-1);\n let visible = lastRow === undefined ? 0 : stringWidth(lastRow);\n let currentCharacter = characters.next();\n let nextCharacter = characters.next();\n let rawCharacterIndex = 0;\n while (!currentCharacter.done) {\n const character = currentCharacter.value;\n const characterLength = stringWidth(character);\n if (visible + characterLength <= columns) {\n rows[rows.length - 1] += character;\n }\n else {\n rows.push(character);\n visible = 0;\n }\n if (character === ESC || character === CSI) {\n isInsideEscape = true;\n isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);\n }\n if (isInsideEscape) {\n if (isInsideLinkEscape) {\n if (character === ANSI_ESCAPE_BELL) {\n isInsideEscape = false;\n isInsideLinkEscape = false;\n }\n }\n else if (character === ANSI_SGR_TERMINATOR) {\n isInsideEscape = false;\n }\n }\n else {\n visible += characterLength;\n if (visible === columns && !nextCharacter.done) {\n rows.push('');\n visible = 0;\n }\n }\n currentCharacter = nextCharacter;\n nextCharacter = characters.next();\n rawCharacterIndex += character.length;\n }\n lastRow = rows.at(-1);\n if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {\n rows[rows.length - 2] += rows.pop();\n }\n};\nconst stringVisibleTrimSpacesRight = (string) => {\n const words = string.split(' ');\n let last = words.length;\n while (last) {\n if (stringWidth(words[last - 1])) {\n break;\n }\n last--;\n }\n if (last === words.length) {\n return string;\n }\n return words.slice(0, last).join(' ') + words.slice(last).join('');\n};\nconst exec = (string, columns, options = {}) => {\n if (options.trim !== false && string.trim() === '') {\n return '';\n }\n let returnValue = '';\n let escapeCode;\n let escapeUrl;\n const words = string.split(' ');\n let rows = [''];\n let rowLength = 0;\n for (let index = 0; index < words.length; index++) {\n const word = words[index];\n if (options.trim !== false) {\n const row = rows.at(-1) ?? '';\n const trimmed = row.trimStart();\n if (row.length !== trimmed.length) {\n rows[rows.length - 1] = trimmed;\n rowLength = stringWidth(trimmed);\n }\n }\n if (index !== 0) {\n if (rowLength >= columns &&\n (options.wordWrap === false || options.trim === false)) {\n rows.push('');\n rowLength = 0;\n }\n if (rowLength || options.trim === false) {\n rows[rows.length - 1] += ' ';\n rowLength++;\n }\n }\n const wordLength = stringWidth(word);\n if (options.hard && wordLength > columns) {\n const remainingColumns = columns - rowLength;\n const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);\n const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);\n if (breaksStartingNextLine < breaksStartingThisLine) {\n rows.push('');\n }\n wrapWord(rows, word, columns);\n rowLength = stringWidth(rows.at(-1) ?? '');\n continue;\n }\n if (rowLength + wordLength > columns && rowLength && wordLength) {\n if (options.wordWrap === false && rowLength < columns) {\n wrapWord(rows, word, columns);\n rowLength = stringWidth(rows.at(-1) ?? '');\n continue;\n }\n rows.push('');\n rowLength = 0;\n }\n if (rowLength + wordLength > columns && options.wordWrap === false) {\n wrapWord(rows, word, columns);\n rowLength = stringWidth(rows.at(-1) ?? '');\n continue;\n }\n rows[rows.length - 1] += word;\n rowLength += wordLength;\n }\n if (options.trim !== false) {\n rows = rows.map((row) => stringVisibleTrimSpacesRight(row));\n }\n const preString = rows.join('\\n');\n let inSurrogate = false;\n for (let i = 0; i < preString.length; i++) {\n const character = preString[i];\n returnValue += character;\n if (!inSurrogate) {\n inSurrogate = character >= '\\ud800' && character <= '\\udbff';\n if (inSurrogate) {\n continue;\n }\n }\n else {\n inSurrogate = false;\n }\n if (character === ESC || character === CSI) {\n GROUP_REGEX.lastIndex = i + 1;\n const groupsResult = GROUP_REGEX.exec(preString);\n const groups = groupsResult?.groups;\n if (groups?.code !== undefined) {\n const code = Number.parseFloat(groups.code);\n escapeCode = code === END_CODE ? undefined : code;\n }\n else if (groups?.uri !== undefined) {\n escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;\n }\n }\n if (preString[i + 1] === '\\n') {\n if (escapeUrl) {\n returnValue += wrapAnsiHyperlink('');\n }\n const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;\n if (escapeCode && closingCode) {\n returnValue += wrapAnsiCode(closingCode);\n }\n }\n else if (character === '\\n') {\n if (escapeCode && getClosingCode(escapeCode)) {\n returnValue += wrapAnsiCode(escapeCode);\n }\n if (escapeUrl) {\n returnValue += wrapAnsiHyperlink(escapeUrl);\n }\n }\n }\n return returnValue;\n};\nconst CRLF_OR_LF = /\\r?\\n/;\nexport function wrapAnsi(string, columns, options) {\n return String(string)\n .normalize()\n .split(CRLF_OR_LF)\n .map((line) => exec(line, columns, options))\n .join('\\n');\n}\n//# sourceMappingURL=main.js.map","'use strict';\n\nconst ESC = '\\x1B';\nconst CSI = `${ESC}[`;\nconst beep = '\\u0007';\n\nconst cursor = {\n to(x, y) {\n if (!y) return `${CSI}${x + 1}G`;\n return `${CSI}${y + 1};${x + 1}H`;\n },\n move(x, y) {\n let ret = '';\n\n if (x < 0) ret += `${CSI}${-x}D`;\n else if (x > 0) ret += `${CSI}${x}C`;\n\n if (y < 0) ret += `${CSI}${-y}A`;\n else if (y > 0) ret += `${CSI}${y}B`;\n\n return ret;\n },\n up: (count = 1) => `${CSI}${count}A`,\n down: (count = 1) => `${CSI}${count}B`,\n forward: (count = 1) => `${CSI}${count}C`,\n backward: (count = 1) => `${CSI}${count}D`,\n nextLine: (count = 1) => `${CSI}E`.repeat(count),\n prevLine: (count = 1) => `${CSI}F`.repeat(count),\n left: `${CSI}G`,\n hide: `${CSI}?25l`,\n show: `${CSI}?25h`,\n save: `${ESC}7`,\n restore: `${ESC}8`\n}\n\nconst scroll = {\n up: (count = 1) => `${CSI}S`.repeat(count),\n down: (count = 1) => `${CSI}T`.repeat(count)\n}\n\nconst erase = {\n screen: `${CSI}2J`,\n up: (count = 1) => `${CSI}1J`.repeat(count),\n down: (count = 1) => `${CSI}J`.repeat(count),\n line: `${CSI}2K`,\n lineEnd: `${CSI}K`,\n lineStart: `${CSI}1K`,\n lines(count) {\n let clear = '';\n for (let i = 0; i < count; i++)\n clear += this.line + (i < count - 1 ? cursor.up() : '');\n if (count)\n clear += cursor.left;\n return clear;\n }\n}\n\nmodule.exports = { cursor, scroll, erase, beep };\n","import{styleText as v}from\"node:util\";import{stdout as S,stdin as D}from\"node:process\";import*as b from\"node:readline\";import E from\"node:readline\";import{wrapAnsi as M}from\"fast-wrap-ansi\";import{cursor as c,erase as V}from\"sisteransi\";import{ReadStream as O}from\"node:tty\";function d(r,t,s){if(!s.some(o=>!o.disabled))return r;const e=r+t,i=Math.max(s.length-1,0),n=e<0?i:e>i?0:e;return s[n].disabled?d(n,t<0?-1:1,s):n}function I(r,t,s,e){const i=e.split(`\n`);let n=0,o=r;for(const a of i){if(o<=a.length)break;o-=a.length+1,n++}for(n=Math.max(0,Math.min(i.length-1,n+s)),o=Math.min(o,i[n].length)+t;o<0&&n>0;)n--,o+=i[n].length+1;for(;o>i[n].length&&n<i.length-1;)o-=i[n].length+1,n++;o=Math.max(0,Math.min(i[n].length,o));let u=0;for(let a=0;a<n;a++)u+=i[a].length+1;return u+o}const G=[\"up\",\"down\",\"left\",\"right\",\"space\",\"enter\",\"cancel\"],K=[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"],h={actions:new Set(G),aliases:new Map([[\"k\",\"up\"],[\"j\",\"down\"],[\"h\",\"left\"],[\"l\",\"right\"],[\"\u0003\",\"cancel\"],[\"escape\",\"cancel\"]]),messages:{cancel:\"Canceled\",error:\"Something went wrong\"},withGuide:!0,date:{monthNames:[...K],messages:{required:\"Please enter a valid date\",invalidMonth:\"There are only 12 months in a year\",invalidDay:(r,t)=>`There are only ${r} days in ${t}`,afterMin:r=>`Date must be on or after ${r.toISOString().slice(0,10)}`,beforeMax:r=>`Date must be on or before ${r.toISOString().slice(0,10)}`}}};function j(r){if(r.aliases!==void 0){const t=r.aliases;for(const s in t){if(!Object.hasOwn(t,s))continue;const e=t[s];h.actions.has(e)&&(h.aliases.has(s)||h.aliases.set(s,e))}}if(r.messages!==void 0){const t=r.messages;t.cancel!==void 0&&(h.messages.cancel=t.cancel),t.error!==void 0&&(h.messages.error=t.error)}if(r.withGuide!==void 0&&(h.withGuide=r.withGuide!==!1),r.date!==void 0){const t=r.date;t.monthNames!==void 0&&(h.date.monthNames=[...t.monthNames]),t.messages!==void 0&&(t.messages.required!==void 0&&(h.date.messages.required=t.messages.required),t.messages.invalidMonth!==void 0&&(h.date.messages.invalidMonth=t.messages.invalidMonth),t.messages.invalidDay!==void 0&&(h.date.messages.invalidDay=t.messages.invalidDay),t.messages.afterMin!==void 0&&(h.date.messages.afterMin=t.messages.afterMin),t.messages.beforeMax!==void 0&&(h.date.messages.beforeMax=t.messages.beforeMax))}}function C(r,t){if(typeof r==\"string\")return h.aliases.get(r)===t;for(const s of r)if(s!==void 0&&C(s,t))return!0;return!1}function z(r,t){if(r===t)return;const s=r.split(`\n`),e=t.split(`\n`),i=Math.max(s.length,e.length),n=[];for(let o=0;o<i;o++)s[o]!==e[o]&&n.push(o);return{lines:n,numLinesBefore:s.length,numLinesAfter:e.length,numLines:i}}const Y=globalThis.process.platform.startsWith(\"win\"),k=Symbol(\"clack:cancel\");function q(r){return r===k}function w(r,t){const s=r;s.isTTY&&s.setRawMode(t)}function R({input:r=D,output:t=S,overwrite:s=!0,hideCursor:e=!0}={}){const i=b.createInterface({input:r,output:t,prompt:\"\",tabSize:1});b.emitKeypressEvents(r,i),r instanceof O&&r.isTTY&&r.setRawMode(!0);const n=(o,{name:u,sequence:a})=>{const l=String(o);if(C([l,u,a],\"cancel\")){e&&t.write(c.show),process.exit(0);return}if(!s)return;const f=u===\"return\"?0:-1,y=u===\"return\"?-1:0;b.moveCursor(t,f,y,()=>{b.clearLine(t,1,()=>{r.once(\"keypress\",n)})})};return e&&t.write(c.hide),r.once(\"keypress\",n),()=>{r.off(\"keypress\",n),e&&t.write(c.show),r instanceof O&&r.isTTY&&!Y&&r.setRawMode(!1),i.terminal=!1,i.close()}}const A=r=>\"columns\"in r&&typeof r.columns==\"number\"?r.columns:80,L=r=>\"rows\"in r&&typeof r.rows==\"number\"?r.rows:20;function W(r,t,s,e=s,i){const n=A(r??S);return M(t,n-s.length,{hard:!0,trim:!1}).split(`\n`).map((o,u)=>{const a=i?i(o,u):o;return`${u===0?e:s}${a}`}).join(`\n`)}let p=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=\"\";_subscribers=new Map;_cursor=0;state=\"initial\";error=\"\";value;userInput=\"\";constructor(t,s=!0){const{input:e=D,output:i=S,render:n,signal:o,...u}=t;this.opts=u,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=s,this._abortSignal=o,this.input=e,this.output=i}unsubscribe(){this._subscribers.clear()}setSubscriber(t,s){const e=this._subscribers.get(t)??[];e.push(s),this._subscribers.set(t,e)}on(t,s){this.setSubscriber(t,{cb:s})}once(t,s){this.setSubscriber(t,{cb:s,once:!0})}emit(t,...s){const e=this._subscribers.get(t)??[],i=[];for(const n of e)n.cb(...s),n.once&&i.push(()=>e.splice(e.indexOf(n),1));for(const n of i)n()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=\"cancel\",this.close(),t(k);this._abortSignal.addEventListener(\"abort\",()=>{this.state=\"cancel\",this.close()},{once:!0})}this.rl=E.createInterface({input:this.input,tabSize:2,prompt:\"\",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(\"keypress\",this.onKeypress),w(this.input,!0),this.output.on(\"resize\",this.render),this.render(),this.once(\"submit\",()=>{this.output.write(c.show),this.output.off(\"resize\",this.render),w(this.input,!1),t(this.value)}),this.once(\"cancel\",()=>{this.output.write(c.show),this.output.off(\"resize\",this.render),w(this.input,!1),t(k)})})}_isActionKey(t,s){return t===\"\t\"}_shouldSubmit(t,s){return!0}_setValue(t){this.value=t,this.emit(\"value\",this.value)}_setUserInput(t,s){this.userInput=t??\"\",this.emit(\"userInput\",this.userInput),s&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:\"u\"}),this._setUserInput(\"\")}onKeypress(t,s){if(this._track&&s.name!==\"return\"&&(s.name&&this._isActionKey(t,s)&&this.rl?.write(null,{ctrl:!0,name:\"h\"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===\"error\"&&(this.state=\"active\"),s?.name&&(!this._track&&h.aliases.has(s.name)&&this.emit(\"cursor\",h.aliases.get(s.name)),h.actions.has(s.name)&&this.emit(\"cursor\",s.name)),t&&(t.toLowerCase()===\"y\"||t.toLowerCase()===\"n\")&&this.emit(\"confirm\",t.toLowerCase()===\"y\"),this.emit(\"key\",t?.toLowerCase(),s),s?.name===\"return\"&&this._shouldSubmit(t,s)){if(this.opts.validate){const e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=\"error\",this.rl?.write(this.userInput))}this.state!==\"error\"&&(this.state=\"submit\")}C([t,s?.name,s?.sequence],\"cancel\")&&(this.state=\"cancel\"),(this.state===\"submit\"||this.state===\"cancel\")&&this.emit(\"finalize\"),this.render(),(this.state===\"submit\"||this.state===\"cancel\")&&this.close()}close(){this.input.unpipe(),this.input.removeListener(\"keypress\",this.onKeypress),this.output.write(`\n`),w(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=M(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`\n`).length-1;this.output.write(c.move(-999,t*-1))}render(){const t=M(this._render(this)??\"\",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state===\"initial\")this.output.write(c.hide);else{const s=z(this._prevFrame,t),e=L(this.output);if(this.restoreCursor(),s){const i=Math.max(0,s.numLinesAfter-e),n=Math.max(0,s.numLinesBefore-e);let o=s.lines.find(u=>u>=i);if(o===void 0){this._prevFrame=t;return}if(s.lines.length===1){this.output.write(c.move(0,o-n)),this.output.write(V.lines(1));const u=t.split(`\n`);this.output.write(u[o]),this._prevFrame=t,this.output.write(c.move(0,u.length-o-1));return}else if(s.lines.length>1){if(i<n)o=i;else{const a=o-n;a>0&&this.output.write(c.move(0,a))}this.output.write(V.down());const u=t.split(`\n`).slice(o);this.output.write(u.join(`\n`)),this._prevFrame=t;return}}this.output.write(V.down())}this.output.write(t),this.state===\"initial\"&&(this.state=\"active\"),this._prevFrame=t}}};function B(r,t){if(r===void 0||t.length===0)return 0;const s=t.findIndex(e=>e.value===r);return s!==-1?s:0}function J(r,t){return(t.label??String(t.value)).toLowerCase().includes(r.toLowerCase())}function H(r,t){if(t)return r?t:t[0]}let Q=class extends p{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#s=0;#r=\"\";#t;#n;#u;get cursor(){return this.#s}get userInputWithCursor(){if(!this.userInput)return v([\"inverse\",\"hidden\"],\"_\");if(this._cursor>=this.userInput.length)return`${this.userInput}\\u2588`;const t=this.userInput.slice(0,this._cursor),[s,...e]=this.userInput.slice(this._cursor);return`${t}${v(\"inverse\",s)}${e.join(\"\")}`}get options(){return typeof this.#n==\"function\"?this.#n():this.#n}constructor(t){super(t),this.#n=t.options,this.#u=t.placeholder;const s=this.options;this.filteredOptions=[...s],this.multiple=t.multiple===!0,this.#t=typeof t.options==\"function\"?t.filter:t.filter??J;let e;if(t.initialValue&&Array.isArray(t.initialValue)?this.multiple?e=t.initialValue:e=t.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(e=[this.options[0].value]),e)for(const i of e){const n=s.findIndex(o=>o.value===i);n!==-1&&(this.toggleSelected(i),this.#s=n)}this.focusedValue=this.options[this.#s]?.value,this.on(\"key\",(i,n)=>this.#e(i,n)),this.on(\"userInput\",i=>this.#i(i))}_isActionKey(t,s){return t===\"\t\"||this.multiple&&this.isNavigating&&s.name===\"space\"&&t!==void 0&&t!==\"\"}#e(t,s){const e=s.name===\"up\",i=s.name===\"down\",n=s.name===\"return\",o=this.userInput===\"\"||this.userInput===\"\t\",u=this.#u,a=this.options,l=u!==void 0&&u!==\"\"&&a.some(f=>!f.disabled&&(this.#t?this.#t(u,f):!0));if(s.name===\"tab\"&&o&&l){this.userInput===\"\t\"&&this._clearUserInput(),this._setUserInput(u,!0),this.isNavigating=!1;return}e||i?(this.#s=d(this.#s,e?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#s]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):n?this.value=H(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(s.name===\"tab\"||this.isNavigating&&s.name===\"space\")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(t){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(t)?this.selectedValues=this.selectedValues.filter(s=>s!==t):this.selectedValues=[...this.selectedValues,t]:this.selectedValues=[t])}#i(t){if(t!==this.#r){this.#r=t;const s=this.options;t&&this.#t?this.filteredOptions=s.filter(n=>this.#t?.(t,n)):this.filteredOptions=[...s];const e=B(this.focusedValue,this.filteredOptions);this.#s=d(e,0,this.filteredOptions);const i=this.filteredOptions[this.#s];i&&!i.disabled?this.focusedValue=i.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class X extends p{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on(\"userInput\",()=>{this.value=this._value}),this.on(\"confirm\",s=>{this.output.write(c.move(0,-1)),this.value=s,this.state=\"submit\",this.close()}),this.on(\"cursor\",()=>{this.value=!this.value})}}const Z={Y:{type:\"year\",len:4},M:{type:\"month\",len:2},D:{type:\"day\",len:2}};function P(r){return[...r].map(t=>Z[t])}function tt(r){const t=new Intl.DateTimeFormat(r,{year:\"numeric\",month:\"2-digit\",day:\"2-digit\"}).formatToParts(new Date(2e3,0,15)),s=[];let e=\"/\";for(const i of t)i.type===\"literal\"?e=i.value.trim()||i.value:(i.type===\"year\"||i.type===\"month\"||i.type===\"day\")&&s.push({type:i.type,len:i.type===\"year\"?4:2});return{segments:s,separator:e}}function U(r){return Number.parseInt((r||\"0\").replace(/_/g,\"0\"),10)||0}function x(r){return{year:U(r.year),month:U(r.month),day:U(r.day)}}function $(r,t){return new Date(r||2001,t||1,0).getDate()}function F(r){const{year:t,month:s,day:e}=x(r);if(!t||t<0||t>9999||!s||s<1||s>12||!e||e<1)return;const i=new Date(Date.UTC(t,s-1,e));if(!(i.getUTCFullYear()!==t||i.getUTCMonth()!==s-1||i.getUTCDate()!==e))return{year:t,month:s,day:e}}function N(r){const t=F(r);return t?new Date(Date.UTC(t.year,t.month-1,t.day)):void 0}function st(r,t,s,e){const i=s?{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate()}:null,n=e?{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate()}:null;return r===\"year\"?{min:i?.year??1,max:n?.year??9999}:r===\"month\"?{min:i&&t.year===i.year?i.month:1,max:n&&t.year===n.year?n.month:12}:{min:i&&t.year===i.year&&t.month===i.month?i.day:1,max:n&&t.year===n.year&&t.month===n.month?n.day:$(t.year,t.month)}}class et extends p{#s;#r;#t;#n;#u;#e={segmentIndex:0,positionInSegment:0};#i=!0;#o=null;inlineError=\"\";get segmentCursor(){return{...this.#e}}get segmentValues(){return{...this.#t}}get segments(){return this.#s}get separator(){return this.#r}get formattedValue(){return this.#c(this.#t)}#c(t){return this.#s.map(s=>t[s.type]).join(this.#r)}#a(){this._setUserInput(this.#c(this.#t)),this._setValue(N(this.#t)??void 0)}constructor(t){const s=t.format?{segments:P(t.format),separator:t.separator??\"/\"}:tt(t.locale),e=t.separator??s.separator,i=t.format?P(t.format):s.segments,n=t.initialValue??t.defaultValue,o=n?{year:String(n.getUTCFullYear()).padStart(4,\"0\"),month:String(n.getUTCMonth()+1).padStart(2,\"0\"),day:String(n.getUTCDate()).padStart(2,\"0\")}:{year:\"____\",month:\"__\",day:\"__\"},u=i.map(a=>o[a.type]).join(e);super({...t,initialUserInput:u},!1),this.#s=i,this.#r=e,this.#t=o,this.#n=t.minDate,this.#u=t.maxDate,this.#a(),this.on(\"cursor\",a=>this.#d(a)),this.on(\"key\",(a,l)=>this.#f(a,l)),this.on(\"finalize\",()=>this.#g(t))}#h(){const t=Math.max(0,Math.min(this.#e.segmentIndex,this.#s.length-1)),s=this.#s[t];if(s)return this.#e.positionInSegment=Math.max(0,Math.min(this.#e.positionInSegment,s.len-1)),{segment:s,index:t}}#l(t){this.inlineError=\"\",this.#o=null;const s=this.#h();s&&(this.#e.segmentIndex=Math.max(0,Math.min(this.#s.length-1,s.index+t)),this.#e.positionInSegment=0,this.#i=!0)}#p(t){const s=this.#h();if(!s)return;const{segment:e}=s,i=this.#t[e.type],n=!i||i.replace(/_/g,\"\")===\"\",o=Number.parseInt((i||\"0\").replace(/_/g,\"0\"),10)||0,u=st(e.type,x(this.#t),this.#n,this.#u);let a;n?a=t===1?u.min:u.max:a=Math.max(Math.min(u.max,o+t),u.min),this.#t={...this.#t,[e.type]:a.toString().padStart(e.len,\"0\")},this.#i=!0,this.#o=null,this.#a()}#d(t){if(t)switch(t){case\"right\":return this.#l(1);case\"left\":return this.#l(-1);case\"up\":return this.#p(1);case\"down\":return this.#p(-1)}}#f(t,s){if(s?.name===\"backspace\"||s?.sequence===\"\\x7F\"||s?.sequence===\"\\b\"||t===\"\\x7F\"||t===\"\\b\"){this.inlineError=\"\";const e=this.#h();if(!e)return;if(!this.#t[e.segment.type].replace(/_/g,\"\")){this.#l(-1);return}this.#t[e.segment.type]=\"_\".repeat(e.segment.len),this.#i=!0,this.#e.positionInSegment=0,this.#a();return}if(s?.name===\"tab\"){this.inlineError=\"\";const e=this.#h();if(!e)return;const i=s.shift?-1:1,n=e.index+i;n>=0&&n<this.#s.length&&(this.#e.segmentIndex=n,this.#e.positionInSegment=0,this.#i=!0);return}if(t&&/^[0-9]$/.test(t)){const e=this.#h();if(!e)return;const{segment:i}=e,n=!this.#t[i.type].replace(/_/g,\"\");if(this.#i&&this.#o!==null&&!n){const m=this.#o+t,g={...this.#t,[i.type]:m},_=this.#m(g,i);if(_){this.inlineError=_,this.#o=null,this.#i=!1;return}this.inlineError=\"\",this.#t[i.type]=m,this.#o=null,this.#i=!1,this.#a(),e.index<this.#s.length-1&&(this.#e.segmentIndex=e.index+1,this.#e.positionInSegment=0,this.#i=!0);return}this.#i&&!n&&(this.#t[i.type]=\"_\".repeat(i.len),this.#e.positionInSegment=0),this.#i=!1,this.#o=null;const o=this.#t[i.type],u=o.indexOf(\"_\"),a=u>=0?u:Math.min(this.#e.positionInSegment,i.len-1);if(a<0||a>=i.len)return;let l=o.slice(0,a)+t+o.slice(a+1),f=!1;if(a===0&&o===\"__\"&&(i.type===\"month\"||i.type===\"day\")){const m=Number.parseInt(t,10);l=`0${t}`,f=m<=(i.type===\"month\"?1:2)}if(i.type===\"year\"&&(l=(o.replace(/_/g,\"\")+t).padStart(i.len,\"_\")),!l.includes(\"_\")){const m={...this.#t,[i.type]:l},g=this.#m(m,i);if(g){this.inlineError=g;return}}this.inlineError=\"\",this.#t[i.type]=l;const y=l.includes(\"_\")?void 0:F(this.#t);if(y){const{year:m,month:g}=y,_=$(m,g);this.#t={year:String(Math.max(0,Math.min(9999,m))).padStart(4,\"0\"),month:String(Math.max(1,Math.min(12,g))).padStart(2,\"0\"),day:String(Math.max(1,Math.min(_,y.day))).padStart(2,\"0\")}}this.#a();const T=l.indexOf(\"_\");f?(this.#i=!0,this.#o=t):T>=0?this.#e.positionInSegment=T:u>=0&&e.index<this.#s.length-1?(this.#e.segmentIndex=e.index+1,this.#e.positionInSegment=0,this.#i=!0):this.#e.positionInSegment=Math.min(a+1,i.len-1)}}#m(t,s){const{month:e,day:i}=x(t);if(s.type===\"month\"&&(e<0||e>12))return h.date.messages.invalidMonth;if(s.type===\"day\"&&(i<0||i>31))return h.date.messages.invalidDay(31,\"any month\")}#g(t){const{year:s,month:e,day:i}=x(this.#t);if(s&&e&&i){const n=$(s,e);this.#t={...this.#t,day:String(Math.min(i,n)).padStart(2,\"0\")}}this.value=N(this.#t)??t.defaultValue??void 0}}class it extends p{options;cursor=0;#s;getGroupItems(t){return this.options.filter(s=>s.group===t)}isGroupSelected(t){const s=this.getGroupItems(t),e=this.value;return e===void 0?!1:s.every(i=>e.includes(i.value))}toggleValue(){const t=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),t.group===!0){const s=t.value,e=this.getGroupItems(s);this.isGroupSelected(s)?this.value=this.value.filter(i=>e.findIndex(n=>n.value===i)===-1):this.value=[...this.value,...e.map(i=>i.value)],this.value=Array.from(new Set(this.value))}else{const s=this.value.includes(t.value);this.value=s?this.value.filter(e=>e!==t.value):[...this.value,t.value]}}constructor(t){super(t,!1);const{options:s}=t;this.#s=t.selectableGroups!==!1,this.options=Object.entries(s).flatMap(([e,i])=>[{value:e,group:!0,label:e},...i.map(n=>({...n,group:e}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===t.cursorAt),this.#s?0:1),this.on(\"cursor\",e=>{switch(e){case\"left\":case\"up\":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;const i=this.options[this.cursor]?.group===!0;!this.#s&&i&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case\"down\":case\"right\":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;const i=this.options[this.cursor]?.group===!0;!this.#s&&i&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case\"space\":this.toggleValue();break}})}}class rt extends p{#s=!1;#r;focused=\"editor\";get userInputWithCursor(){if(this.state===\"submit\")return this.userInput;const t=this.userInput;if(this.cursor>=t.length)return`${t}\\u2588`;const s=t.slice(0,this.cursor),e=t[this.cursor],i=t.slice(this.cursor+1);return e===`\n`?`${s}\\u2588\n${i}`:`${s}${v(\"inverse\",e)}${i}`}get cursor(){return this._cursor}#t(t){if(this.userInput.length===0){this._setUserInput(t);return}this._setUserInput(this.userInput.slice(0,this.cursor)+t+this.userInput.slice(this.cursor))}#n(t){const s=this.value??\"\";switch(t){case\"up\":this._cursor=I(this._cursor,0,-1,s);return;case\"down\":this._cursor=I(this._cursor,0,1,s);return;case\"left\":this._cursor=I(this._cursor,-1,0,s);return;case\"right\":this._cursor=I(this._cursor,1,0,s);return}}_shouldSubmit(t,s){if(this.#r)return this.focused===\"submit\"?!0:(this.#t(`\n`),this._cursor++,!1);const e=this.#s;return this.#s=!0,e?(this.userInput[this.cursor-1]===`\n`&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#t(`\n`),this._cursor++,!1)}constructor(t){super(t,!1),this.#r=t.showSubmit??!1,this.on(\"key\",(s,e)=>{if(e?.name&&h.actions.has(e.name)){this.#n(e.name);return}if(s===\"\t\"&&this.#r){this.focused=this.focused===\"editor\"?\"submit\":\"editor\";return}if(e?.name!==\"return\"){if(this.#s=!1,e?.name===\"backspace\"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(e?.name===\"delete\"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}s&&(this.#r&&this.focused===\"submit\"&&(this.focused=\"editor\"),this.#t(s??\"\"),this._cursor++)}}),this.on(\"userInput\",s=>{this._setValue(s)}),this.on(\"finalize\",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value=\"\")})}}let nt=class extends p{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(t=>t.disabled!==!0)}toggleAll(){const t=this._enabledOptions,s=this.value!==void 0&&this.value.length===t.length;this.value=s?[]:t.map(e=>e.value)}toggleInvert(){const t=this.value;if(!t)return;const s=this._enabledOptions.filter(e=>!t.includes(e.value));this.value=s.map(e=>e.value)}toggleValue(){this.value===void 0&&(this.value=[]);const t=this.value.includes(this._value);this.value=t?this.value.filter(s=>s!==this._value):[...this.value,this._value]}constructor(t){super(t,!1),this.options=t.options,this.value=[...t.initialValues??[]];const s=Math.max(this.options.findIndex(({value:e})=>e===t.cursorAt),0);this.cursor=this.options[s].disabled?d(s,1,this.options):s,this.on(\"key\",e=>{e===\"a\"&&this.toggleAll(),e===\"i\"&&this.toggleInvert()}),this.on(\"cursor\",e=>{switch(e){case\"left\":case\"up\":this.cursor=d(this.cursor,-1,this.options);break;case\"down\":case\"right\":this.cursor=d(this.cursor,1,this.options);break;case\"space\":this.toggleValue();break}})}};class ot extends p{_mask=\"\\u2022\";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state===\"submit\"||this.state===\"cancel\")return this.masked;const t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${v([\"inverse\",\"hidden\"],\"_\")}`;const s=this.masked,e=s.slice(0,this.cursor),i=s.slice(this.cursor);return`${e}${v(\"inverse\",i[0])}${i.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...s}){super(s),this._mask=t??\"\\u2022\",this.on(\"userInput\",e=>{this._setValue(e)})}}class ut extends p{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;const s=this.options.findIndex(({value:i})=>i===t.initialValue),e=s===-1?0:s;this.cursor=this.options[e].disabled?d(e,1,this.options):e,this.changeValue(),this.on(\"cursor\",i=>{switch(i){case\"left\":case\"up\":this.cursor=d(this.cursor,-1,this.options);break;case\"down\":case\"right\":this.cursor=d(this.cursor,1,this.options);break}this.changeValue()})}}class at extends p{options;cursor=0;constructor(t){super(t,!1),this.options=t.options;const s=t.caseSensitive===!0,e=this.options.map(({value:[i]})=>s?i:i?.toLowerCase());this.cursor=Math.max(e.indexOf(t.initialValue),0),this.on(\"key\",(i,n)=>{if(!i)return;const o=s&&n.shift?i.toUpperCase():i;if(!e.includes(o))return;const u=this.options.find(({value:[a]})=>s?a===o:a?.toLowerCase()===i);u&&(this.value=u.value,this.state=\"submit\",this.emit(\"submit\"))})}}class ht extends p{get userInputWithCursor(){if(this.state===\"submit\")return this.userInput;const t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\\u2588`;const s=t.slice(0,this.cursor),[e,...i]=t.slice(this.cursor);return`${s}${v(\"inverse\",e)}${i.join(\"\")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on(\"userInput\",s=>{this._setValue(s)}),this.on(\"finalize\",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value=\"\")})}}export{Q as AutocompletePrompt,X as ConfirmPrompt,et as DatePrompt,it as GroupMultiSelectPrompt,rt as MultiLinePrompt,nt as MultiSelectPrompt,ot as PasswordPrompt,p as Prompt,at as SelectKeyPrompt,ut as SelectPrompt,ht as TextPrompt,R as block,A as getColumns,L as getRows,q as isCancel,h as settings,j as updateSettings,W as wrapTextWithPrefix};\n//# sourceMappingURL=index.mjs.map\n","import{getColumns as X,getRows as Bt,AutocompletePrompt as vt,settings as _,ConfirmPrompt as Lt,wrapTextWithPrefix as O,DatePrompt as Dt,isCancel as Wt,GroupMultiSelectPrompt as Ft,MultiLinePrompt as Ht,MultiSelectPrompt as Ut,PasswordPrompt as Kt,block as qt,SelectPrompt as Jt,SelectKeyPrompt as Yt,TextPrompt as Xt}from\"@clack/core\";export{isCancel,settings,updateSettings}from\"@clack/core\";import{styleText as e,stripVTControlCharacters as nt}from\"node:util\";import j from\"node:process\";import{wrapAnsi as q}from\"fast-wrap-ansi\";import k from\"fast-string-width\";import{existsSync as zt,lstatSync as wt,readdirSync as Qt}from\"node:fs\";import{dirname as bt,join as Zt}from\"node:path\";import{cursor as St,erase as Ct}from\"sisteransi\";function te(){return j.platform!==\"win32\"?j.env.TERM!==\"linux\":!!j.env.CI||!!j.env.WT_SESSION||!!j.env.TERMINUS_SUBLIME||j.env.ConEmuTask===\"{cmd::Cmder}\"||j.env.TERM_PROGRAM===\"Terminus-Sublime\"||j.env.TERM_PROGRAM===\"vscode\"||j.env.TERM===\"xterm-256color\"||j.env.TERM===\"alacritty\"||j.env.TERMINAL_EMULATOR===\"JetBrains-JediTerm\"}const tt=te(),at=()=>process.env.CI===\"true\",Tt=t=>t.isTTY===!0,w=(t,r)=>tt?t:r,_t=w(\"\\u25C6\",\"*\"),ot=w(\"\\u25A0\",\"x\"),ut=w(\"\\u25B2\",\"x\"),F=w(\"\\u25C7\",\"o\"),lt=w(\"\\u250C\",\"T\"),$=w(\"\\u2502\",\"|\"),E=w(\"\\u2514\",\"\\u2014\"),It=w(\"\\u2510\",\"T\"),Et=w(\"\\u2518\",\"\\u2014\"),z=w(\"\\u25CF\",\">\"),H=w(\"\\u25CB\",\" \"),et=w(\"\\u25FB\",\"[\\u2022]\"),U=w(\"\\u25FC\",\"[+]\"),J=w(\"\\u25FB\",\"[ ]\"),Gt=w(\"\\u25AA\",\"\\u2022\"),st=w(\"\\u2500\",\"-\"),ct=w(\"\\u256E\",\"+\"),xt=w(\"\\u251C\",\"+\"),$t=w(\"\\u256F\",\"+\"),dt=w(\"\\u2570\",\"+\"),Ot=w(\"\\u256D\",\"+\"),ht=w(\"\\u25CF\",\"\\u2022\"),pt=w(\"\\u25C6\",\"*\"),mt=w(\"\\u25B2\",\"!\"),gt=w(\"\\u25A0\",\"x\"),M=t=>{switch(t){case\"initial\":case\"active\":return e(\"cyan\",_t);case\"cancel\":return e(\"red\",ot);case\"error\":return e(\"yellow\",ut);case\"submit\":return e(\"green\",F)}},yt=t=>{switch(t){case\"initial\":case\"active\":return e(\"cyan\",$);case\"cancel\":return e(\"red\",$);case\"error\":return e(\"yellow\",$);case\"submit\":return e(\"green\",$)}},ee=(t,r,s,i,u)=>{let n=r,o=0;for(let c=s;c<i;c++){const a=t[c];if(n=n-a.length,o++,n<=u)break}return{lineCount:n,removals:o}},Y=({cursor:t,options:r,style:s,output:i=process.stdout,maxItems:u=Number.POSITIVE_INFINITY,columnPadding:n=0,rowPadding:o=4})=>{const c=X(i)-n,a=Bt(i),l=e(\"dim\",\"...\"),d=Math.max(a-o,0),y=Math.max(Math.min(u,d),5);let p=0;t>=y-3&&(p=Math.max(Math.min(t-y+3,r.length-y),0));let m=y<r.length&&p>0,g=y<r.length&&p+y<r.length;const S=Math.min(p+y,r.length),h=[];let f=0;m&&f++,g&&f++;const v=p+(m?1:0),T=S-(g?1:0);for(let b=v;b<T;b++){const G=q(s(r[b],b===t),c,{hard:!0,trim:!1}).split(`\n`);h.push(G),f+=G.length}if(f>d){let b=0,G=0,x=f;const A=t-v,P=(N,D)=>ee(h,x,N,D,d);m?({lineCount:x,removals:b}=P(0,A),x>d&&({lineCount:x,removals:G}=P(A+1,h.length))):({lineCount:x,removals:G}=P(A+1,h.length),x>d&&({lineCount:x,removals:b}=P(0,A))),b>0&&(m=!0,h.splice(0,b)),G>0&&(g=!0,h.splice(h.length-G,G))}const C=[];m&&C.push(l);for(const b of h)for(const G of b)C.push(G);return g&&C.push(l),C};function Mt(t){return t.label??String(t.value??\"\")}function Rt(t,r){if(!t)return!0;const s=(r.label??String(r.value??\"\")).toLowerCase(),i=(r.hint??\"\").toLowerCase(),u=String(r.value).toLowerCase(),n=t.toLowerCase();return s.includes(n)||i.includes(n)||u.includes(n)}function se(t,r){const s=[];for(const i of r)t.includes(i.value)&&s.push(i);return s}const At=t=>new vt({options:t.options,initialValue:t.initialValue?[t.initialValue]:void 0,initialUserInput:t.initialUserInput,placeholder:t.placeholder,filter:t.filter??((r,s)=>Rt(r,s)),signal:t.signal,input:t.input,output:t.output,validate:t.validate,render(){const r=t.withGuide??_.withGuide,s=r?[`${e(\"gray\",$)}`,`${M(this.state)} ${t.message}`]:[`${M(this.state)} ${t.message}`],i=this.userInput,u=this.options,n=t.placeholder,o=i===\"\"&&n!==void 0,c=(a,l)=>{const d=Mt(a),y=a.hint&&a.value===this.focusedValue?e(\"dim\",` (${a.hint})`):\"\";switch(l){case\"active\":return`${e(\"green\",z)} ${d}${y}`;case\"inactive\":return`${e(\"dim\",H)} ${e(\"dim\",d)}`;case\"disabled\":return`${e(\"gray\",H)} ${e([\"strikethrough\",\"gray\"],d)}`}};switch(this.state){case\"submit\":{const a=se(this.selectedValues,u),l=a.length>0?` ${e(\"dim\",a.map(Mt).join(\", \"))}`:\"\",d=r?e(\"gray\",$):\"\";return`${s.join(`\n`)}\n${d}${l}`}case\"cancel\":{const a=i?` ${e([\"strikethrough\",\"dim\"],i)}`:\"\",l=r?e(\"gray\",$):\"\";return`${s.join(`\n`)}\n${l}${a}`}default:{const a=this.state===\"error\"?\"yellow\":\"cyan\",l=r?`${e(a,$)} `:\"\",d=r?e(a,E):\"\";let y=\"\";if(this.isNavigating||o){const v=o?n:i;y=v!==\"\"?` ${e(\"dim\",v)}`:\"\"}else y=` ${this.userInputWithCursor}`;const p=this.filteredOptions.length!==u.length?e(\"dim\",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?\"\":\"es\"})`):\"\",m=this.filteredOptions.length===0&&i?[`${l}${e(\"yellow\",\"No matches found\")}`]:[],g=this.state===\"error\"?[`${l}${e(\"yellow\",this.error)}`]:[];r&&s.push(`${l.trimEnd()}`),s.push(`${l}${e(\"dim\",\"Search:\")}${y}${p}`,...m,...g);const S=[`${e(\"dim\",\"\\u2191/\\u2193\")} to select`,`${e(\"dim\",\"Enter:\")} confirm`,`${e(\"dim\",\"Type:\")} to search`],h=[`${l}${S.join(\" \\u2022 \")}`,d],f=this.filteredOptions.length===0?[]:Y({cursor:this.cursor,options:this.filteredOptions,columnPadding:r?3:0,rowPadding:s.length+h.length,style:(v,T)=>c(v,v.disabled?\"disabled\":T?\"active\":\"inactive\"),maxItems:t.maxItems,output:t.output});return[...s,...f.map(v=>`${l}${v}`),...h].join(`\n`)}}}}).prompt(),ie=t=>{const r=(i,u,n,o)=>{const c=n.includes(i.value),a=i.label??String(i.value??\"\"),l=i.hint&&o!==void 0&&i.value===o?e(\"dim\",` (${i.hint})`):\"\",d=c?e(\"green\",U):e(\"dim\",J);return i.disabled?`${e(\"gray\",J)} ${e([\"strikethrough\",\"gray\"],a)}`:u?`${d} ${a}${l}`:`${d} ${e(\"dim\",a)}`},s=new vt({options:t.options,multiple:!0,placeholder:t.placeholder,filter:t.filter??((i,u)=>Rt(i,u)),validate:()=>{if(t.required&&s.selectedValues.length===0)return\"Please select at least one item\"},initialValue:t.initialValues,signal:t.signal,input:t.input,output:t.output,render(){const i=t.withGuide??_.withGuide,u=`${i?`${e(\"gray\",$)}\n`:\"\"}${M(this.state)} ${t.message}\n`,n=this.userInput,o=t.placeholder,c=n===\"\"&&o!==void 0,a=this.isNavigating||c?e(\"dim\",c?o:n):this.userInputWithCursor,l=this.options,d=this.filteredOptions.length!==l.length?e(\"dim\",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?\"\":\"es\"})`):\"\";switch(this.state){case\"submit\":return`${u}${i?`${e(\"gray\",$)} `:\"\"}${e(\"dim\",`${this.selectedValues.length} items selected`)}`;case\"cancel\":return`${u}${i?`${e(\"gray\",$)} `:\"\"}${e([\"strikethrough\",\"dim\"],n)}`;default:{const y=this.state===\"error\"?\"yellow\":\"cyan\",p=i?`${e(y,$)} `:\"\",m=i?e(y,E):\"\",g=[`${e(\"dim\",\"\\u2191/\\u2193\")} to navigate`,`${e(\"dim\",this.isNavigating?\"Space/Tab:\":\"Tab:\")} select`,`${e(\"dim\",\"Enter:\")} confirm`,`${e(\"dim\",\"Type:\")} to search`],S=this.filteredOptions.length===0&&n?[`${p}${e(\"yellow\",\"No matches found\")}`]:[],h=this.state===\"error\"?[`${p}${e(\"yellow\",this.error)}`]:[],f=[...`${u}${i?e(y,$):\"\"}`.split(`\n`),`${p}${e(\"dim\",\"Search:\")} ${a}${d}`,...S,...h],v=[`${p}${g.join(\" \\u2022 \")}`,m],T=Y({cursor:this.cursor,options:this.filteredOptions,style:(C,b)=>r(C,b,this.selectedValues,this.focusedValue),maxItems:t.maxItems,output:t.output,rowPadding:f.length+v.length});return[...f,...T.map(C=>`${p}${C}`),...v].join(`\n`)}}}});return s.prompt()},re=[Ot,ct,dt,$t],ne=[lt,It,E,Et];function Pt(t,r,s,i){let u=s,n=s;return i===\"center\"?u=Math.floor((r-t)/2):i===\"right\"&&(u=r-t-s),n=r-u-t,[u,n]}const ae=t=>t,oe=(t=\"\",r=\"\",s)=>{const i=s?.output??process.stdout,u=X(i),n=2,o=s?.titlePadding??1,c=s?.contentPadding??2,a=s?.width===void 0||s.width===\"auto\"?1:Math.min(1,s.width),l=s?.withGuide??_.withGuide?`${$} `:\"\",d=s?.formatBorder??ae,y=(s?.rounded?re:ne).map(d),p=d(st),m=d($),g=k(l),S=k(r),h=u-g;let f=Math.floor(u*a)-g;if(s?.width===\"auto\"){const P=t.split(`\n`);let N=S+o*2;for(const rt of P){const W=k(rt)+c*2;W>N&&(N=W)}const D=N+n;D<f&&(f=D)}f%2!==0&&(f<h?f++:f--);const v=f-n,T=v-o*2,C=S>T?`${r.slice(0,T-3)}...`:r,[b,G]=Pt(k(C),v,o,s?.titleAlign),x=q(t,v-c*2,{hard:!0,trim:!1});i.write(`${l}${y[0]}${p.repeat(b)}${C}${p.repeat(G)}${y[1]}\n`);const A=x.split(`\n`);for(const P of A){const[N,D]=Pt(k(P),v,c,s?.contentAlign);i.write(`${l}${m}${\" \".repeat(N)}${P}${\" \".repeat(D)}${m}\n`)}i.write(`${l}${y[2]}${p.repeat(v)}${y[3]}\n`)},ue=t=>{const r=t.active??\"Yes\",s=t.inactive??\"No\";return new Lt({active:r,inactive:s,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue??!0,render(){const i=t.withGuide??_.withGuide,u=`${M(this.state)} `,n=i?`${e(\"gray\",$)} `:\"\",o=O(t.output,t.message,n,u),c=`${i?`${e(\"gray\",$)}\n`:\"\"}${o}\n`,a=this.value?r:s;switch(this.state){case\"submit\":{const l=i?`${e(\"gray\",$)} `:\"\";return`${c}${l}${e(\"dim\",a)}`}case\"cancel\":{const l=i?`${e(\"gray\",$)} `:\"\";return`${c}${l}${e([\"strikethrough\",\"dim\"],a)}${i?`\n${e(\"gray\",$)}`:\"\"}`}default:{const l=i?`${e(\"cyan\",$)} `:\"\",d=i?e(\"cyan\",E):\"\";return`${c}${l}${this.value?`${e(\"green\",z)} ${r}`:`${e(\"dim\",H)} ${e(\"dim\",r)}`}${t.vertical?i?`\n${e(\"cyan\",$)} `:`\n`:` ${e(\"dim\",\"/\")} `}${this.value?`${e(\"dim\",H)} ${e(\"dim\",s)}`:`${e(\"green\",z)} ${s}`}\n${d}\n`}}}}).prompt()},le=t=>{const r=t.validate;return new Dt({...t,validate(s){if(s===void 0)return t.defaultValue!==void 0?void 0:r?r(s):_.date.messages.required;const i=u=>u.toISOString().slice(0,10);if(t.minDate&&i(s)<i(t.minDate))return _.date.messages.afterMin(t.minDate);if(t.maxDate&&i(s)>i(t.maxDate))return _.date.messages.beforeMax(t.maxDate);if(r)return r(s)},render(){const s=(t?.withGuide??_.withGuide)!==!1,i=`${`${s?`${e(\"gray\",$)}\n`:\"\"}${M(this.state)} `}${t.message}\n`,u=this.state!==\"initial\"?this.state:\"active\",n=ce(this,u),o=this.value instanceof Date?this.formattedValue:\"\";switch(this.state){case\"error\":{const c=this.error?` ${e(\"yellow\",this.error)}`:\"\",a=s?`${e(\"yellow\",$)} `:\"\",l=s?e(\"yellow\",E):\"\";return`${i.trim()}\n${a}${n}\n${l}${c}\n`}case\"submit\":{const c=o?` ${e(\"dim\",o)}`:\"\",a=s?e(\"gray\",$):\"\";return`${i}${a}${c}`}case\"cancel\":{const c=o?` ${e([\"strikethrough\",\"dim\"],o)}`:\"\",a=s?e(\"gray\",$):\"\";return`${i}${a}${c}${o.trim()?`\n${a}`:\"\"}`}default:{const c=s?`${e(\"cyan\",$)} `:\"\",a=s?e(\"cyan\",E):\"\",l=s?`${e(\"cyan\",$)} `:\"\",d=this.inlineError?`\n${l}${e(\"yellow\",this.inlineError)}`:\"\";return`${i}${c}${n}${d}\n${a}\n`}}}}).prompt()};function ce(t,r){const s=t.segmentValues,i=t.segmentCursor;if(r===\"submit\"||r===\"cancel\")return t.formattedValue;const u=e(\"gray\",t.separator);return t.segments.map((n,o)=>{const c=o===i.segmentIndex&&![\"submit\",\"cancel\"].includes(r),a=de[n.type];return $e(s[n.type],{isActive:c,label:a})}).join(u)}function $e(t,r){const s=!t||t.replace(/_/g,\"\")===\"\";return r.isActive?e(\"inverse\",s?r.label:t.replace(/_/g,\" \")):s?e(\"dim\",r.label):t.replace(/_/g,e(\"dim\",\" \"))}const de={year:\"yyyy\",month:\"mm\",day:\"dd\"},he=async(t,r)=>{const s={},i=Object.keys(t);for(const u of i){const n=t[u],o=await n({results:s})?.catch(c=>{throw c});if(typeof r?.onCancel==\"function\"&&Wt(o)){s[u]=\"canceled\",r.onCancel({results:s});continue}s[u]=o}return s},pe=t=>{const{selectableGroups:r=!0,groupSpacing:s=0}=t,i=(n,o,c=[])=>{const a=n.label??String(n.value),l=typeof n.group==\"string\",d=l&&(c[c.indexOf(n)+1]??{group:!0}),y=l&&d&&d.group===!0,p=l?r?`${y?E:$} `:\" \":\"\";let m=\"\";if(s>0&&!l){const S=`\n${e(\"cyan\",$)}`;m=`${S.repeat(s-1)}${S} `}if(o===\"active\")return`${m}${e(\"dim\",p)}${e(\"cyan\",et)} ${a}${n.hint?` ${e(\"dim\",`(${n.hint})`)}`:\"\"}`;if(o===\"group-active\")return`${m}${p}${e(\"cyan\",et)} ${e(\"dim\",a)}`;if(o===\"group-active-selected\")return`${m}${p}${e(\"green\",U)} ${e(\"dim\",a)}`;if(o===\"selected\"){const S=l||r?e(\"green\",U):\"\";return`${m}${e(\"dim\",p)}${S} ${e(\"dim\",a)}${n.hint?` ${e(\"dim\",`(${n.hint})`)}`:\"\"}`}if(o===\"cancelled\")return`${e([\"strikethrough\",\"dim\"],a)}`;if(o===\"active-selected\")return`${m}${e(\"dim\",p)}${e(\"green\",U)} ${a}${n.hint?` ${e(\"dim\",`(${n.hint})`)}`:\"\"}`;if(o===\"submitted\")return`${e(\"dim\",a)}`;const g=l||r?e(\"dim\",J):\"\";return`${m}${e(\"dim\",p)}${g} ${e(\"dim\",a)}`},u=t.required??!0;return new Ft({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValues:t.initialValues,required:u,cursorAt:t.cursorAt,selectableGroups:r,validate(n){if(u&&(n===void 0||n.length===0))return`Please select at least one option.\n${e(\"reset\",e(\"dim\",`Press ${e([\"gray\",\"bgWhite\",\"inverse\"],\" space \")} to select, ${e(\"gray\",e([\"bgWhite\",\"inverse\"],\" enter \"))} to submit`))}`},render(){const n=t.withGuide??_.withGuide,o=`${n?`${e(\"gray\",$)}\n`:\"\"}${M(this.state)} ${t.message}\n`,c=this.value??[];switch(this.state){case\"submit\":{const a=this.options.filter(({value:d})=>c.includes(d)).map(d=>i(d,\"submitted\")),l=a.length===0?\"\":` ${a.join(e(\"dim\",\", \"))}`;return`${o}${n?e(\"gray\",$):\"\"}${l}`}case\"cancel\":{const a=this.options.filter(({value:l})=>c.includes(l)).map(l=>i(l,\"cancelled\")).join(e(\"dim\",\", \"));return`${o}${n?`${e(\"gray\",$)} `:\"\"}${a.trim()?`${a}${n?`\n${e(\"gray\",$)}`:\"\"}`:\"\"}`}case\"error\":{const a=this.error.split(`\n`).map((l,d)=>d===0?`${n?`${e(\"yellow\",E)} `:\"\"}${e(\"yellow\",l)}`:` ${l}`).join(`\n`);return`${o}${n?`${e(\"yellow\",$)} `:\"\"}${this.options.map((l,d,y)=>{const p=c.includes(l.value)||l.group===!0&&this.isGroupSelected(`${l.value}`),m=d===this.cursor;return!m&&typeof l.group==\"string\"&&this.options[this.cursor].value===l.group?i(l,p?\"group-active-selected\":\"group-active\",y):m&&p?i(l,\"active-selected\",y):p?i(l,\"selected\",y):i(l,m?\"active\":\"inactive\",y)}).join(`\n${n?`${e(\"yellow\",$)} `:\"\"}`)}\n${a}\n`}default:{const a=this.options.map((d,y,p)=>{const m=c.includes(d.value)||d.group===!0&&this.isGroupSelected(`${d.value}`),g=y===this.cursor,S=!g&&typeof d.group==\"string\"&&this.options[this.cursor].value===d.group;let h=\"\";return S?h=i(d,m?\"group-active-selected\":\"group-active\",p):g&&m?h=i(d,\"active-selected\",p):m?h=i(d,\"selected\",p):h=i(d,g?\"active\":\"inactive\",p),`${y!==0&&!h.startsWith(`\n`)?\" \":\"\"}${h}`}).join(`\n${n?e(\"cyan\",$):\"\"}`),l=a.startsWith(`\n`)?\"\":\" \";return`${o}${n?e(\"cyan\",$):\"\"}${l}${a}\n${n?e(\"cyan\",E):\"\"}\n`}}}}).prompt()},R={message:(t=[],{symbol:r=e(\"gray\",$),secondarySymbol:s=e(\"gray\",$),output:i=process.stdout,spacing:u=1,withGuide:n}={})=>{const o=[],c=n??_.withGuide,a=c?s:\"\",l=c?`${r} `:\"\",d=c?`${s} `:\"\";for(let p=0;p<u;p++)o.push(a);const y=Array.isArray(t)?t:t.split(`\n`);if(y.length>0){const[p,...m]=y;p.length>0?o.push(`${l}${p}`):o.push(c?r:\"\");for(const g of m)g.length>0?o.push(`${d}${g}`):o.push(c?s:\"\")}i.write(`${o.join(`\n`)}\n`)},info:(t,r)=>{R.message(t,{...r,symbol:e(\"blue\",ht)})},success:(t,r)=>{R.message(t,{...r,symbol:e(\"green\",pt)})},step:(t,r)=>{R.message(t,{...r,symbol:e(\"green\",F)})},warn:(t,r)=>{R.message(t,{...r,symbol:e(\"yellow\",mt)})},warning:(t,r)=>{R.warn(t,r)},error:(t,r)=>{R.message(t,{...r,symbol:e(\"red\",gt)})}},me=(t=\"\",r)=>{const s=r?.output??process.stdout,i=r?.withGuide??_.withGuide?`${e(\"gray\",E)} `:\"\";s.write(`${i}${e(\"red\",t)}\n\n`)},ge=(t=\"\",r)=>{const s=r?.output??process.stdout,i=r?.withGuide??_.withGuide?`${e(\"gray\",lt)} `:\"\";s.write(`${i}${t}\n`)},ye=(t=\"\",r)=>{const s=r?.output??process.stdout,i=r?.withGuide??_.withGuide?`${e(\"gray\",$)}\n${e(\"gray\",E)} `:\"\";s.write(`${i}${t}\n\n`)},fe=t=>new Ht({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,showSubmit:t.showSubmit,output:t.output,signal:t.signal,input:t.input,render(){const r=t?.withGuide??_.withGuide,s=`${`${r?`${e(\"gray\",$)}\n`:\"\"}${M(this.state)} `}${t.message}\n`,i=t.placeholder?e(\"inverse\",t.placeholder[0])+e(\"dim\",t.placeholder.slice(1)):e([\"inverse\",\"hidden\"],\"_\"),u=this.userInput?this.userInputWithCursor:i,n=this.value??\"\",o=t.showSubmit?`\n ${e(this.focused===\"submit\"?\"cyan\":\"dim\",\"[ submit ]\")}`:\"\";switch(this.state){case\"error\":{const c=`${e(\"yellow\",$)} `,a=r?O(t.output,u,c,void 0):u,l=e(\"yellow\",E);return`${s}${a}\n${l} ${e(\"yellow\",this.error)}${o}\n`}case\"submit\":{const c=`${e(\"gray\",$)} `,a=r?O(t.output,n,c,void 0,l=>e(\"dim\",l)):n?e(\"dim\",n):\"\";return`${s}${a}`}case\"cancel\":{const c=`${e(\"gray\",$)} `,a=r?O(t.output,n,c,void 0,l=>e([\"strikethrough\",\"dim\"],l)):n?e([\"strikethrough\",\"dim\"],n):\"\";return`${s}${a}`}default:{const c=r?`${e(\"cyan\",$)} `:\"\",a=r?e(\"cyan\",E):\"\",l=r?O(t.output,u,c):u;return`${s}${l}\n${a}${o}\n`}}}}).prompt(),Q=(t,r)=>t.split(`\n`).map(s=>r(s)).join(`\n`),ve=t=>{const r=(i,u)=>{const n=i.label??String(i.value);return u===\"disabled\"?`${e(\"gray\",J)} ${Q(n,o=>e([\"strikethrough\",\"gray\"],o))}${i.hint?` ${e(\"dim\",`(${i.hint??\"disabled\"})`)}`:\"\"}`:u===\"active\"?`${e(\"cyan\",et)} ${n}${i.hint?` ${e(\"dim\",`(${i.hint})`)}`:\"\"}`:u===\"selected\"?`${e(\"green\",U)} ${Q(n,o=>e(\"dim\",o))}${i.hint?` ${e(\"dim\",`(${i.hint})`)}`:\"\"}`:u===\"cancelled\"?`${Q(n,o=>e([\"strikethrough\",\"dim\"],o))}`:u===\"active-selected\"?`${e(\"green\",U)} ${n}${i.hint?` ${e(\"dim\",`(${i.hint})`)}`:\"\"}`:u===\"submitted\"?`${Q(n,o=>e(\"dim\",o))}`:`${e(\"dim\",J)} ${Q(n,o=>e(\"dim\",o))}`},s=t.required??!0;return new Ut({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValues:t.initialValues,required:s,cursorAt:t.cursorAt,validate(i){if(s&&(i===void 0||i.length===0))return`Please select at least one option.\n${e(\"reset\",e(\"dim\",`Press ${e([\"gray\",\"bgWhite\",\"inverse\"],\" space \")} to select, ${e(\"gray\",e(\"bgWhite\",e(\"inverse\",\" enter \")))} to submit`))}`},render(){const i=t.withGuide??_.withGuide,u=O(t.output,t.message,i?`${yt(this.state)} `:\"\",`${M(this.state)} `),n=`${i?`${e(\"gray\",$)}\n`:\"\"}${u}\n`,o=this.value??[],c=(a,l)=>{if(a.disabled)return r(a,\"disabled\");const d=o.includes(a.value);return l&&d?r(a,\"active-selected\"):d?r(a,\"selected\"):r(a,l?\"active\":\"inactive\")};switch(this.state){case\"submit\":{const a=this.options.filter(({value:d})=>o.includes(d)).map(d=>r(d,\"submitted\")).join(e(\"dim\",\", \"))||e(\"dim\",\"none\"),l=O(t.output,a,i?`${e(\"gray\",$)} `:\"\");return`${n}${l}`}case\"cancel\":{const a=this.options.filter(({value:d})=>o.includes(d)).map(d=>r(d,\"cancelled\")).join(e(\"dim\",\", \"));if(a.trim()===\"\")return`${n}${e(\"gray\",$)}`;const l=O(t.output,a,i?`${e(\"gray\",$)} `:\"\");return`${n}${l}${i?`\n${e(\"gray\",$)}`:\"\"}`}case\"error\":{const a=i?`${e(\"yellow\",$)} `:\"\",l=this.error.split(`\n`).map((p,m)=>m===0?`${i?`${e(\"yellow\",E)} `:\"\"}${e(\"yellow\",p)}`:` ${p}`).join(`\n`),d=n.split(`\n`).length,y=l.split(`\n`).length+1;return`${n}${a}${Y({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:a.length,rowPadding:d+y,style:c}).join(`\n${a}`)}\n${l}\n`}default:{const a=i?`${e(\"cyan\",$)} `:\"\",l=n.split(`\n`).length,d=i?2:1;return`${n}${a}${Y({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:a.length,rowPadding:l+d,style:c}).join(`\n${a}`)}\n${i?e(\"cyan\",E):\"\"}\n`}}}}).prompt()},we=t=>e(\"dim\",t),be=(t,r,s)=>{const i={hard:!0,trim:!1},u=q(t,r,i).split(`\n`),n=u.reduce((a,l)=>Math.max(k(l),a),0),o=u.map(s).reduce((a,l)=>Math.max(k(l),a),0),c=r-(o-n);return q(t,c,i)},Se=(t=\"\",r=\"\",s)=>{const i=s?.output??j.stdout,u=s?.withGuide??_.withGuide,n=s?.format??we,o=[\"\",...be(t,X(i)-6,n).split(`\n`).map(n),\"\"],c=k(r),a=Math.max(o.reduce((p,m)=>{const g=k(m);return g>p?g:p},0),c)+2,l=o.map(p=>`${e(\"gray\",$)} ${p}${\" \".repeat(a-k(p))}${e(\"gray\",$)}`).join(`\n`),d=u?`${e(\"gray\",$)}\n`:\"\",y=u?xt:dt;i.write(`${d}${e(\"green\",F)} ${e(\"reset\",r)} ${e(\"gray\",st.repeat(Math.max(a-c-1,1))+ct)}\n${l}\n${e(\"gray\",y+st.repeat(a+2)+$t)}\n`)},Ce=t=>new Kt({validate:t.validate,mask:t.mask??Gt,signal:t.signal,input:t.input,output:t.output,render(){const r=t.withGuide??_.withGuide,s=`${r?`${e(\"gray\",$)}\n`:\"\"}${M(this.state)} ${t.message}\n`,i=this.userInputWithCursor,u=this.masked;switch(this.state){case\"error\":{const n=r?`${e(\"yellow\",$)} `:\"\",o=r?`${e(\"yellow\",E)} `:\"\",c=u??\"\";return t.clearOnError&&this.clear(),`${s.trim()}\n${n}${c}\n${o}${e(\"yellow\",this.error)}\n`}case\"submit\":{const n=r?`${e(\"gray\",$)} `:\"\",o=u?e(\"dim\",u):\"\";return`${s}${n}${o}`}case\"cancel\":{const n=r?`${e(\"gray\",$)} `:\"\",o=u?e([\"strikethrough\",\"dim\"],u):\"\";return`${s}${n}${o}${u&&r?`\n${e(\"gray\",$)}`:\"\"}`}default:{const n=r?`${e(\"cyan\",$)} `:\"\",o=r?e(\"cyan\",E):\"\";return`${s}${n}${i}\n${o}\n`}}}}).prompt(),Te=t=>{const r=t.validate;return At({...t,initialUserInput:t.initialValue??t.root??process.cwd(),maxItems:5,validate(s){if(!Array.isArray(s)){if(!s)return\"Please select a path\";if(r)return r(s)}},options(){const s=this.userInput;if(s===\"\")return[];try{let i;zt(s)?wt(s).isDirectory()&&(!t.directory||s.endsWith(\"/\"))?i=s:i=bt(s):i=bt(s);const u=s.length>1&&s.endsWith(\"/\")?s.slice(0,-1):s;return Qt(i).map(n=>{const o=Zt(i,n),c=wt(o);return{name:n,path:o,isDirectory:c.isDirectory()}}).filter(({path:n,isDirectory:o})=>n.startsWith(u)&&(o||!t.directory)).map(n=>({value:n.path}))}catch{return[]}}})},_e=t=>e(\"magenta\",t),ft=({indicator:t=\"dots\",onCancel:r,output:s=process.stdout,cancelMessage:i,errorMessage:u,frames:n=tt?[\"\\u25D2\",\"\\u25D0\",\"\\u25D3\",\"\\u25D1\"]:[\"\\u2022\",\"o\",\"O\",\"0\"],delay:o=tt?80:120,signal:c,...a}={})=>{const l=at();let d,y,p=!1,m=!1,g=\"\",S,h=performance.now();const f=X(s),v=a?.styleFrame??_e,T=I=>{const V=I>1?u??_.messages.error:i??_.messages.cancel;m=I===1,p&&(W(V,I),m&&typeof r==\"function\"&&r())},C=()=>T(2),b=()=>T(1),G=()=>{process.on(\"uncaughtExceptionMonitor\",C),process.on(\"unhandledRejection\",C),process.on(\"SIGINT\",b),process.on(\"SIGTERM\",b),process.on(\"exit\",T),c&&c.addEventListener(\"abort\",b)},x=()=>{process.removeListener(\"uncaughtExceptionMonitor\",C),process.removeListener(\"unhandledRejection\",C),process.removeListener(\"SIGINT\",b),process.removeListener(\"SIGTERM\",b),process.removeListener(\"exit\",T),c&&c.removeEventListener(\"abort\",b)},A=()=>{if(S===void 0)return;l&&s.write(`\n`);const I=q(S,f,{hard:!0,trim:!1}).split(`\n`);I.length>1&&s.write(St.up(I.length-1)),s.write(St.to(0)),s.write(Ct.down())},P=I=>I.replace(/\\.+$/,\"\"),N=I=>{const V=(performance.now()-I)/1e3,B=Math.floor(V/60),L=Math.floor(V%60);return B>0?`[${B}m ${L}s]`:`[${L}s]`},D=a.withGuide??_.withGuide,rt=(I=\"\")=>{p=!0,d=qt({output:s}),g=P(I),h=performance.now(),D&&s.write(`${e(\"gray\",$)}\n`);let V=0,B=0;G(),y=setInterval(()=>{if(l&&g===S)return;A(),S=g;const L=v(n[V]);let Z;if(l)Z=`${L} ${g}...`;else if(t===\"timer\")Z=`${L} ${g} ${N(h)}`;else{const kt=\".\".repeat(Math.floor(B)).slice(0,3);Z=`${L} ${g}${kt}`}const Nt=q(Z,f,{hard:!0,trim:!1});s.write(Nt),V=V+1<n.length?V+1:0,B=B<4?B+.125:0},o)},W=(I=\"\",V=0,B=!1)=>{if(!p)return;p=!1,clearInterval(y),A();const L=V===0?e(\"green\",F):V===1?e(\"red\",ot):e(\"red\",ut);g=I??g,B||(t===\"timer\"?s.write(`${L} ${g} ${N(h)}\n`):s.write(`${L} ${g}\n`)),x(),d()};return{start:rt,stop:(I=\"\")=>W(I,0),message:(I=\"\")=>{g=P(I??g)},cancel:(I=\"\")=>W(I,1),error:(I=\"\")=>W(I,2),clear:()=>W(\"\",0,!0),get isCancelled(){return m}}},Vt={light:w(\"\\u2500\",\"-\"),heavy:w(\"\\u2501\",\"=\"),block:w(\"\\u2588\",\"#\")};function Ie({style:t=\"heavy\",max:r=100,size:s=40,...i}={}){const u=ft(i);let n=0,o=\"\";const c=Math.max(1,r),a=Math.max(1,s),l=m=>{switch(m){case\"initial\":case\"active\":return g=>e(\"magenta\",g);case\"error\":case\"cancel\":return g=>e(\"red\",g);case\"submit\":return g=>e(\"green\",g);default:return g=>e(\"magenta\",g)}},d=(m,g)=>{const S=Math.floor(n/c*a);return`${l(m)(Vt[t].repeat(S))}${e(\"dim\",Vt[t].repeat(a-S))} ${g}`},y=(m=\"\")=>{o=m,u.start(d(\"initial\",m))},p=(m=1,g)=>{n=Math.min(c,m+n),u.message(d(\"active\",g??o)),o=g??o};return{start:y,stop:u.stop,cancel:u.cancel,error:u.error,clear:u.clear,advance:p,isCancelled:u.isCancelled,message:m=>p(0,m)}}const it=(t,r)=>t.includes(`\n`)?t.split(`\n`).map(s=>r(s)).join(`\n`):r(t),Ee=t=>{const r=(s,i)=>{const u=s.label??String(s.value);switch(i){case\"disabled\":return`${e(\"gray\",H)} ${it(u,n=>e(\"gray\",n))}${s.hint?` ${e(\"dim\",`(${s.hint??\"disabled\"})`)}`:\"\"}`;case\"selected\":return`${it(u,n=>e(\"dim\",n))}`;case\"active\":return`${e(\"green\",z)} ${u}${s.hint?` ${e(\"dim\",`(${s.hint})`)}`:\"\"}`;case\"cancelled\":return`${it(u,n=>e([\"strikethrough\",\"dim\"],n))}`;default:return`${e(\"dim\",H)} ${it(u,n=>e(\"dim\",n))}`}};return new Jt({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){const s=t.withGuide??_.withGuide,i=`${M(this.state)} `,u=`${yt(this.state)} `,n=O(t.output,t.message,u,i),o=`${s?`${e(\"gray\",$)}\n`:\"\"}${n}\n`;switch(this.state){case\"submit\":{const c=s?`${e(\"gray\",$)} `:\"\",a=O(t.output,r(this.options[this.cursor],\"selected\"),c);return`${o}${a}`}case\"cancel\":{const c=s?`${e(\"gray\",$)} `:\"\",a=O(t.output,r(this.options[this.cursor],\"cancelled\"),c);return`${o}${a}${s?`\n${e(\"gray\",$)}`:\"\"}`}default:{const c=s?`${e(\"cyan\",$)} `:\"\",a=s?e(\"cyan\",E):\"\",l=o.split(`\n`).length,d=s?2:1;return`${o}${c}${Y({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:c.length,rowPadding:l+d,style:(y,p)=>r(y,y.disabled?\"disabled\":p?\"active\":\"inactive\")}).join(`\n${c}`)}\n${a}\n`}}}}).prompt()},Ge=t=>{const r=(s,i=\"inactive\")=>{const u=s.label??String(s.value);return i===\"selected\"?`${e(\"dim\",u)}`:i===\"cancelled\"?`${e([\"strikethrough\",\"dim\"],u)}`:i===\"active\"?`${e([\"bgCyan\",\"gray\"],` ${s.value} `)} ${u}${s.hint?` ${e(\"dim\",`(${s.hint})`)}`:\"\"}`:`${e([\"gray\",\"bgWhite\",\"inverse\"],` ${s.value} `)} ${u}${s.hint?` ${e(\"dim\",`(${s.hint})`)}`:\"\"}`};return new Yt({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,caseSensitive:t.caseSensitive,render(){const s=t.withGuide??_.withGuide,i=`${s?`${e(\"gray\",$)}\n`:\"\"}${M(this.state)} ${t.message}\n`;switch(this.state){case\"submit\":{const u=s?`${e(\"gray\",$)} `:\"\",n=this.options.find(c=>c.value===this.value)??t.options[0],o=O(t.output,r(n,\"selected\"),u);return`${i}${o}`}case\"cancel\":{const u=s?`${e(\"gray\",$)} `:\"\",n=O(t.output,r(this.options[0],\"cancelled\"),u);return`${i}${n}${s?`\n${e(\"gray\",$)}`:\"\"}`}default:{const u=s?`${e(\"cyan\",$)} `:\"\",n=s?e(\"cyan\",E):\"\",o=this.options.map((c,a)=>O(t.output,r(c,a===this.cursor?\"active\":\"inactive\"),u)).join(`\n`);return`${i}${o}\n${n}\n`}}}}).prompt()},jt=`${e(\"gray\",$)} `,K={message:async(t,{symbol:r=e(\"gray\",$)}={})=>{process.stdout.write(`${e(\"gray\",$)}\n${r} `);let s=3;for await(let i of t){i=i.replace(/\\n/g,`\n${jt}`),i.includes(`\n`)&&(s=3+nt(i.slice(i.lastIndexOf(`\n`))).length);const u=nt(i).length;s+u<process.stdout.columns?(s+=u,process.stdout.write(i)):(process.stdout.write(`\n${jt}${i.trimStart()}`),s=3+nt(i.trimStart()).length)}process.stdout.write(`\n`)},info:t=>K.message(t,{symbol:e(\"blue\",ht)}),success:t=>K.message(t,{symbol:e(\"green\",pt)}),step:t=>K.message(t,{symbol:e(\"green\",F)}),warn:t=>K.message(t,{symbol:e(\"yellow\",mt)}),warning:t=>K.warn(t),error:t=>K.message(t,{symbol:e(\"red\",gt)})},xe=async(t,r)=>{for(const s of t){if(s.enabled===!1)continue;const i=ft(r);i.start(s.title);const u=await s.task(i.message);i.stop(u||s.title)}},Oe=t=>t.replace(/\\x1b\\[(?:\\d+;)*\\d*[ABCDEFGHfJKSTsu]|\\x1b\\[(s|u)/g,\"\"),Me=t=>{const r=t.output??process.stdout,s=X(r),i=e(\"gray\",$),u=t.spacing??1,n=3,o=t.retainLog===!0,c=!at()&&Tt(r);r.write(`${i}\n`),r.write(`${e(\"green\",F)} ${t.title}\n`);for(let h=0;h<u;h++)r.write(`${i}\n`);const a=[{value:\"\",full:\"\"}];let l=!1;const d=h=>{if(a.length===0)return;let f=0;h&&(f+=u+2);for(const v of a){const{value:T,result:C}=v;let b=C?.message??T;if(b.length===0)continue;C===void 0&&v.header!==void 0&&v.header!==\"\"&&(b+=`\n${v.header}`);const G=b.split(`\n`).reduce((x,A)=>A===\"\"?x+1:x+Math.ceil((A.length+n)/s),0);f+=G}f>0&&(f+=1,r.write(Ct.lines(f)))},y=(h,f,v)=>{const T=v?`${h.full}\n${h.value}`:h.value;h.header!==void 0&&h.header!==\"\"&&R.message(h.header.split(`\n`).map(C=>e(\"bold\",C)),{output:r,secondarySymbol:i,symbol:i,spacing:0}),R.message(T.split(`\n`).map(C=>e(\"dim\",C)),{output:r,secondarySymbol:i,symbol:i,spacing:f??u})},p=()=>{for(const h of a){const{header:f,value:v,full:T}=h;(f===void 0||f.length===0)&&v.length===0||y(h,void 0,o===!0&&T.length>0)}},m=(h,f,v)=>{if(d(!1),(v?.raw!==!0||!l)&&h.value!==\"\"&&(h.value+=`\n`),h.value+=Oe(f),l=v?.raw===!0,t.limit!==void 0){const T=h.value.split(`\n`),C=T.length-t.limit;if(C>0){const b=T.splice(0,C);o&&(h.full+=(h.full===\"\"?\"\":`\n`)+b.join(`\n`))}h.value=T.join(`\n`)}c&&g()},g=()=>{for(const h of a)h.result?h.result.status===\"error\"?R.error(h.result.message,{output:r,secondarySymbol:i,spacing:0}):R.success(h.result.message,{output:r,secondarySymbol:i,spacing:0}):h.value!==\"\"&&y(h,0)},S=(h,f)=>{d(!1),h.result=f,c&&g()};return{message(h,f){m(a[0],h,f)},group(h){const f={header:h,value:\"\",full:\"\"};return a.push(f),{message(v,T){m(f,v,T)},error(v){S(f,{status:\"error\",message:v})},success(v){S(f,{status:\"success\",message:v})}}},error(h,f){d(!0),R.error(h,{output:r,secondarySymbol:i,spacing:1}),f?.showLog!==!1&&p(),a.splice(1,a.length-1),a[0].value=\"\",a[0].full=\"\"},success(h,f){d(!0),R.success(h,{output:r,secondarySymbol:i,spacing:1}),f?.showLog===!0&&p(),a.splice(1,a.length-1),a[0].value=\"\",a[0].full=\"\"}}},Re=t=>new Xt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){const r=t?.withGuide??_.withGuide,s=`${`${r?`${e(\"gray\",$)}\n`:\"\"}${M(this.state)} `}${t.message}\n`,i=t.placeholder?e(\"inverse\",t.placeholder[0])+e(\"dim\",t.placeholder.slice(1)):e([\"inverse\",\"hidden\"],\"_\"),u=this.userInput?this.userInputWithCursor:i,n=this.value??\"\";switch(this.state){case\"error\":{const o=this.error?` ${e(\"yellow\",this.error)}`:\"\",c=r?`${e(\"yellow\",$)} `:\"\",a=r?e(\"yellow\",E):\"\";return`${s.trim()}\n${c}${u}\n${a}${o}\n`}case\"submit\":{const o=n?` ${e(\"dim\",n)}`:\"\",c=r?e(\"gray\",$):\"\";return`${s}${c}${o}`}case\"cancel\":{const o=n?` ${e([\"strikethrough\",\"dim\"],n)}`:\"\",c=r?e(\"gray\",$):\"\";return`${s}${c}${o}${n.trim()?`\n${c}`:\"\"}`}default:{const o=r?`${e(\"cyan\",$)} `:\"\",c=r?e(\"cyan\",E):\"\";return`${s}${o}${u}\n${c}\n`}}}}).prompt();export{$ as S_BAR,E as S_BAR_END,Et as S_BAR_END_RIGHT,st as S_BAR_H,lt as S_BAR_START,It as S_BAR_START_RIGHT,et as S_CHECKBOX_ACTIVE,J as S_CHECKBOX_INACTIVE,U as S_CHECKBOX_SELECTED,xt as S_CONNECT_LEFT,dt as S_CORNER_BOTTOM_LEFT,$t as S_CORNER_BOTTOM_RIGHT,Ot as S_CORNER_TOP_LEFT,ct as S_CORNER_TOP_RIGHT,gt as S_ERROR,ht as S_INFO,Gt as S_PASSWORD_MASK,z as S_RADIO_ACTIVE,H as S_RADIO_INACTIVE,_t as S_STEP_ACTIVE,ot as S_STEP_CANCEL,ut as S_STEP_ERROR,F as S_STEP_SUBMIT,pt as S_SUCCESS,mt as S_WARN,At as autocomplete,ie as autocompleteMultiselect,oe as box,me as cancel,ue as confirm,le as date,he as group,pe as groupMultiselect,ge as intro,at as isCI,Tt as isTTY,Y as limitOptions,R as log,fe as multiline,ve as multiselect,Se as note,ye as outro,Ce as password,Te as path,Ie as progress,Ee as select,Ge as selectKey,ft as spinner,K as stream,M as symbol,yt as symbolBar,Me as taskLog,xe as tasks,Re as text,tt as unicode,w as unicodeOr};\n//# sourceMappingURL=index.mjs.map\n","import { spinner as clackSpinner, note, outro } from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport type { Refusal } from \"@/shared/errors\";\nimport type { Reporter, Spinner } from \"./types\";\n\n/**\n * Reporter implementation that outputs styled text to the console.\n * The default reporter for human interaction.\n */\nexport class TextReporter implements Reporter {\n\tinfo(message: string) {\n\t\tprocess.stdout.write(`${pc.blue(`ℹ ${message}`)}\\n`);\n\t}\n\n\twarn(message: string) {\n\t\tprocess.stderr.write(`${pc.yellow(`⚠ ${message}`)}\\n`);\n\t}\n\n\terror(message: string) {\n\t\tprocess.stderr.write(`${pc.red(`✘ ${message}`)}\\n`);\n\t}\n\n\tsuccess(message: string) {\n\t\tprocess.stdout.write(`${pc.green(`✔ ${message}`)}\\n`);\n\t}\n\n\tstep(message: string) {\n\t\tprocess.stdout.write(`○ ${message}\\n`);\n\t}\n\n\tnote(message: string, title?: string) {\n\t\tnote(message, title);\n\t}\n\n\tlog(message: string) {\n\t\tprocess.stdout.write(`${message}\\n`);\n\t}\n\n\tspinner(): Spinner {\n\t\treturn clackSpinner();\n\t}\n\n\tjson(data: unknown) {\n\t\tprocess.stdout.write(`${JSON.stringify(data, null, 2)}\\n`);\n\t}\n\n\tcancel(message: string) {\n\t\tprocess.stderr.write(`${pc.red(`✘ ${message}`)}\\n`);\n\t}\n\n\tfatal(message: string, error?: unknown): never {\n\t\tprocess.stderr.write(`${pc.red(`✘ ${message}`)}\\n`);\n\t\tif (error) {\n\t\t\tconst detail = `${pc.red(error instanceof Error ? (error.stack ?? String(error)) : String(error))}\\n`;\n\t\t\tprocess.stderr.write(detail);\n\t\t}\n\t\tthrow error instanceof Error ? error : new Error(message);\n\t}\n\n\trefuse(_refusal: Refusal) {\n\t\t// Human-oriented refusal guidance is emitted via error()/info();\n\t\t// the structured payload is reserved for JSON output.\n\t}\n\n\tfinish(message: string, _details?: Record<string, unknown>) {\n\t\toutro(message);\n\t}\n\n\tasync flush(): Promise<void> {\n\t\treturn new Promise((resolve) => {\n\t\t\tprocess.stderr.write(\"\", () => resolve());\n\t\t});\n\t}\n}\n","import type { Refusal } from \"@/shared/errors\";\nimport type { LoggerPort } from \"@/shared/ports\";\nimport {\n\tJsonReporter,\n\ttype Reporter,\n\tSilentReporter,\n\ttype Spinner,\n\tTextReporter,\n} from \"./reporters\";\n\n/**\n * Options for configuring the CLI logger.\n */\nexport type LoggerOptions = {\n\tisQuiet: boolean;\n\tisJson: boolean;\n\tisYes?: boolean;\n};\n\n/**\n * Adapter implementation for the LoggerPort.\n * Handles different output formats (text, JSON, silent).\n */\nexport class Logger implements LoggerPort {\n\tprivate originalStdoutWrite = process.stdout.write;\n\tprivate reporter: Reporter;\n\n\tconstructor(private options: LoggerOptions) {\n\t\tif (options.isJson) {\n\t\t\tthis.reporter = new JsonReporter();\n\t\t} else if (options.isQuiet) {\n\t\t\tthis.reporter = new SilentReporter();\n\t\t} else {\n\t\t\tthis.reporter = new TextReporter();\n\t\t}\n\t}\n\n\tdebug(message: string) {\n\t\tthis.reporter.log(message);\n\t}\n\n\tinfo(message: string) {\n\t\tthis.reporter.info(message);\n\t}\n\n\twarn(message: string) {\n\t\tthis.reporter.warn(message);\n\t}\n\n\terror(message: string) {\n\t\tthis.reporter.error(message);\n\t}\n\n\tsuccess(message: string) {\n\t\tthis.reporter.success(message);\n\t}\n\n\tstep(message: string) {\n\t\tthis.reporter.step(message);\n\t}\n\n\tnote(message: string, title?: string) {\n\t\tthis.reporter.note(message, title);\n\t}\n\n\tlog(message: string) {\n\t\tthis.reporter.log(message);\n\t}\n\n\tspinner(): Spinner {\n\t\treturn this.reporter.spinner();\n\t}\n\n\tjson(data: unknown) {\n\t\tthis.reporter.json(data);\n\t}\n\n\tget stdio() {\n\t\treturn this.options.isJson\n\t\t\t? ([process.stdin, process.stderr, process.stderr] as const)\n\t\t\t: (\"inherit\" as const);\n\t}\n\n\tinteractiveStdout(enable: boolean) {\n\t\tif (!this.options.isJson || this.options.isYes) return;\n\n\t\tif (enable) {\n\t\t\tprocess.stdout.write = process.stderr.write.bind(process.stderr);\n\t\t} else {\n\t\t\tprocess.stdout.write = this.originalStdoutWrite;\n\t\t}\n\t}\n\n\tcancel(message: string) {\n\t\tthis.reporter.cancel(message);\n\t}\n\n\tfatal(message: string, error?: unknown): never {\n\t\tthis.reporter.fatal(message, error);\n\t}\n\n\trefuse(refusal: Refusal) {\n\t\tthis.reporter.refuse(refusal);\n\t}\n\n\tfinish(message: string, details?: Record<string, unknown>) {\n\t\tthis.reporter.finish(message, details);\n\t}\n\n\tasync flush() {\n\t\tawait this.reporter.flush();\n\t}\n}\n","function e(e){return e instanceof Error?e.stack??e.message:String(e)}function t(e,t,n){e(`${t}: ${n instanceof Error?n.message:String(n)}`),n instanceof Error&&n.stack&&e(n.stack)}const n={debug:0,info:1,warn:2,error:3},r=new Set([`debug`,`info`,`warn`,`error`,`silent`]);function i(e){if(!e)return;let t=e.trim().toLowerCase();if(r.has(t))return t}function a(){if(!(typeof process>`u`))return i(process.env?.ARKENV_LOG_LEVEL)}function o(e){return e?.level??a()??`info`}function s(e,t){return e===`silent`?!1:n[t]>=n[e]}function c(e,t,n){return(r,...i)=>{s(e,t)&&console[n](r,...i)}}function l(e){let t=o(e);return{debug:c(t,`debug`,`debug`),info:c(t,`info`,`info`),warn:c(t,`warn`,`warn`),error:c(t,`error`,`error`)}}let u=l();function d(e){u=e}const f=`[ArkEnv]`,p=`[ArkEnv Watcher]`;function m(e){return`${f} ${e}`}function h(t){return{logBuildWarning(e){t.warn(`⚠️ ${f} ${e}`)},logBuildError(e){t.error(`❌ ${f} ${e}`)},logBuildErrorDetail(e){t.error(e)},logBuildErrorBlankLine(){t.error(``)},logBuildErrorWithCause(n,r){t.error(`❌ ${f} ${n}`),t.error(e(r))},logWatcherError(e){t.error(`${p} ${e}`)},logWatcherErrorWithCause(n,r){t.error(`${p} ${n}`),t.error(e(r))}}}function g(e){return e??u}let _=h(u);function v(e){_=h(e)}function y(e){_.logBuildWarning(e)}function b(e){_.logBuildError(e)}function x(e){_.logBuildErrorDetail(e)}function S(){_.logBuildErrorBlankLine()}function C(e,t){_.logBuildErrorWithCause(e,t)}function w(e){_.logWatcherError(e)}function T(e,t){_.logWatcherErrorWithCause(e,t)}const E=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null;function D(){if(!E())return!0;let e=process.env;return e.FORCE_COLOR===`0`?!0:e.FORCE_COLOR!==void 0&&e.FORCE_COLOR!==`0`?!1:!!(e.NO_COLOR!==void 0||e.CI!==void 0||process.stdout&&!process.stdout.isTTY)}function O(e,t){let n=t??l(e);d(n),v(n)}function k(e){if(!e)return{pluginConfig:{},logOptions:{}};let{logger:t,logLevel:n,...r}=e,i={};return t!==void 0&&(i.logger=t),n!==void 0&&(i.logLevel=n),{pluginConfig:r,logOptions:i}}function A(e){return e?.logger?e.logger:e?.logLevel?l({level:e.logLevel}):g()}function j(e){return h(A(e))}export{f as BUILD_PREFIX,p as WATCHER_PREFIX,v as bindDefaultBuildLog,O as configureDefaultLogger,h as createBuildLogHelpers,l as createConsoleLogger,u as defaultLogger,m as formatBuildError,e as formatErrorCause,E as isNode,b as logBuildError,S as logBuildErrorBlankLine,x as logBuildErrorDetail,C as logBuildErrorWithCause,y as logBuildWarning,t as logErrorWithCauseVia,w as logWatcherError,T as logWatcherErrorWithCause,i as parseLogLevel,a as readEnvLogLevel,j as resolveBuildLog,o as resolveLogLevel,g as resolveLogger,A as resolveLoggerFromOptions,D as shouldDisableColors,s as shouldLog,k as splitPluginConfig};\n//# sourceMappingURL=index.js.map","import fsp from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { logBuildErrorWithCause, logErrorWithCauseVia } from \"@repo/log\";\nimport dedent from \"dedent\";\nimport type { LoggerPort } from \"@/shared/ports\";\n\nconst MARKER = \"// @arkenv-types\";\n\nexport async function safeAppend(\n\tdtsPath: string,\n\tschemaPath: string,\n\tframework: \"vite\" | \"bun-fullstack\",\n\tlogger?: Pick<LoggerPort, \"error\">,\n): Promise<boolean> {\n\ttry {\n\t\tconst content = await fsp.readFile(dtsPath, \"utf-8\");\n\t\tconst existingType =\n\t\t\tframework === \"vite\" ? \"ImportMetaEnvAugmented\" : \"ProcessEnvAugmented\";\n\n\t\tif (content.includes(MARKER) || content.includes(existingType)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst dtsDir = path.dirname(dtsPath);\n\t\tconst relativeSchemaPath = path\n\t\t\t.relative(dtsDir, schemaPath)\n\t\t\t.replace(/\\.(ts|js|tsx|jsx)$/, \"\")\n\t\t\t.split(path.sep)\n\t\t\t.join(\"/\");\n\n\t\t// Ensure it starts with ./ or ../\n\t\tconst importPath = relativeSchemaPath.startsWith(\".\")\n\t\t\t? relativeSchemaPath\n\t\t\t: `./${relativeSchemaPath}`;\n\n\t\tconst template =\n\t\t\tframework === \"vite\"\n\t\t\t\t? viteInjectionTemplate(importPath)\n\t\t\t\t: bunInjectionTemplate(importPath);\n\n\t\tconst separator = content.endsWith(\"\\n\") ? \"\" : \"\\n\";\n\t\tawait fsp.appendFile(\n\t\t\tdtsPath,\n\t\t\t`${separator}\\n${MARKER}\\n${template}\\n`,\n\t\t\t\"utf-8\",\n\t\t);\n\t\treturn true;\n\t} catch (e) {\n\t\tconst header = `Failed to append to ${dtsPath}`;\n\t\tif (logger) {\n\t\t\tlogErrorWithCauseVia(logger.error.bind(logger), header, e);\n\t\t} else {\n\t\t\tlogBuildErrorWithCause(header, e);\n\t\t}\n\t\treturn false;\n\t}\n}\n\nfunction viteInjectionTemplate(importPath: string) {\n\treturn dedent /* ts */`\n\t\ttype ImportMetaEnvAugmented = import(\"@arkenv/vite-plugin\").ImportMetaEnvAugmented<\n\t\t\ttypeof import(\"${importPath}\").Env\n\t\t>;\n\n\t\tinterface ImportMetaEnv extends ImportMetaEnvAugmented {}\n\n\t\tinterface ImportMeta {\n\t\t\treadonly env: ImportMetaEnv;\n\t\t}\n\t`;\n}\n\nfunction bunInjectionTemplate(importPath: string) {\n\treturn dedent /* ts */`\n\t\ttype ProcessEnvAugmented = import(\"@arkenv/bun-plugin\").ProcessEnvAugmented<\n\t\t\ttypeof import(\"${importPath}\").Env\n\t\t>;\n\n\t\tdeclare namespace NodeJS {\n\t\t\tinterface ProcessEnv extends ProcessEnvAugmented {}\n\t\t}\n\t`;\n}\n","import fsp from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { ParsedTsConfig } from \"@/shared/ports\";\n\nasync function hasConfig(cwd: string, files: string[]): Promise<boolean> {\n\tfor (const file of files) {\n\t\ttry {\n\t\t\tawait fsp.access(path.join(cwd, file));\n\t\t\treturn true;\n\t\t} catch {}\n\t}\n\treturn false;\n}\n\n/**\n * Detect the build or runtime framework used by the project at the target directory.\n *\n * @param cwd The target directory path\n * @param tsConfig The parsed tsconfig details\n * @returns The detected framework name\n */\nexport async function detectFramework(\n\tcwd = process.cwd(),\n\ttsConfig?: ParsedTsConfig | null,\n): Promise<\"vite\" | \"bun-fullstack\" | \"vanilla\" | \"nextjs\" | \"nuxt\"> {\n\tif (tsConfig?.compilerOptions?.types) {\n\t\tconst types = tsConfig.compilerOptions.types;\n\t\tif (types.includes(\"vite\") || types.includes(\"vite/client\")) return \"vite\";\n\t}\n\n\ttry {\n\t\tconst pkgJsonPath = path.join(cwd, \"package.json\");\n\t\tconst content = await fsp.readFile(pkgJsonPath, \"utf-8\");\n\t\tconst pkg = JSON.parse(content);\n\t\tconst allDeps = { ...pkg.dependencies, ...pkg.devDependencies };\n\n\t\tif (allDeps.vite) return \"vite\";\n\t\tif (allDeps.next) return \"nextjs\";\n\t\tif (allDeps.nuxt) return \"nuxt\";\n\t} catch {\n\t\t// ignore missing or invalid package.json\n\t}\n\n\t// Check for config files\n\tif (await hasConfig(cwd, [\"vite.config.ts\", \"vite.config.js\"])) {\n\t\treturn \"vite\";\n\t}\n\tif (\n\t\tawait hasConfig(cwd, [\n\t\t\t\"next.config.ts\",\n\t\t\t\"next.config.js\",\n\t\t\t\"next.config.mjs\",\n\t\t\t\"next.config.cjs\",\n\t\t])\n\t) {\n\t\treturn \"nextjs\";\n\t}\n\tif (\n\t\tawait hasConfig(cwd, [\n\t\t\t\"nuxt.config.ts\",\n\t\t\t\"nuxt.config.js\",\n\t\t\t\"nuxt.config.mts\",\n\t\t\t\"nuxt.config.mjs\",\n\t\t\t\"nuxt.config.cjs\",\n\t\t])\n\t) {\n\t\treturn \"nuxt\";\n\t}\n\n\t// Bun Detection\n\tconst features = await detectBunFeatures(cwd, tsConfig);\n\tif (features.length > 0) return \"bun-fullstack\";\n\n\treturn \"vanilla\";\n}\n\nexport async function detectBunFeatures(\n\tcwd = process.cwd(),\n\t_tsConfig?: ParsedTsConfig | null,\n): Promise<(\"serve\" | \"build\")[]> {\n\tconst features: (\"serve\" | \"build\")[] = [];\n\n\t// Check bunfig.toml first as it's a high-signal indicator\n\ttry {\n\t\tconst bunfigPath = path.join(cwd, \"bunfig.toml\");\n\t\tconst content = await fsp.readFile(bunfigPath, \"utf-8\");\n\t\tif (content.includes(\"[serve]\") || content.includes(\"[serve.static]\")) {\n\t\t\tfeatures.push(\"serve\");\n\t\t}\n\t\t// Bun doesn't have a standard [build] section in bunfig.toml yet,\n\t\t// but checking for it doesn't hurt.\n\t\tif (content.includes(\"[build]\")) {\n\t\t\tfeatures.push(\"build\");\n\t\t}\n\t} catch {\n\t\t// ignore missing or unreadable bunfig.toml\n\t}\n\n\tif (features.includes(\"serve\") && features.includes(\"build\")) return features;\n\n\tconst { walk } = await import(\"./env-scanner\");\n\tconst files = await walk(cwd);\n\tlet foundServe = features.includes(\"serve\");\n\tlet foundBuild = features.includes(\"build\");\n\n\tfor (const file of files) {\n\t\ttry {\n\t\t\tconst content = await fsp.readFile(file, \"utf-8\");\n\t\t\tif (\n\t\t\t\t!foundServe &&\n\t\t\t\t(content.includes(\"Bun.serve\") || content.includes(\"serve(\"))\n\t\t\t) {\n\t\t\t\t// Crude check for serve import from bun\n\t\t\t\tif (\n\t\t\t\t\t/from\\s+['\"]bun['\"]/.test(content) ||\n\t\t\t\t\tcontent.includes(\"Bun.serve\")\n\t\t\t\t) {\n\t\t\t\t\tfoundServe = true;\n\t\t\t\t\tfeatures.push(\"serve\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!foundBuild &&\n\t\t\t\t(content.includes(\"Bun.build\") || content.includes(\"build(\"))\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\t/from\\s+['\"]bun['\"]/.test(content) ||\n\t\t\t\t\tcontent.includes(\"Bun.build\")\n\t\t\t\t) {\n\t\t\t\t\tfoundBuild = true;\n\t\t\t\t\tfeatures.push(\"build\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (foundServe && foundBuild) break;\n\t\t} catch {\n\t\t\t// ignore unreadable files\n\t\t}\n\t}\n\n\treturn features;\n}\n\nexport async function detectPackageManager(\n\tcwd = process.cwd(),\n\ttsConfig?: ParsedTsConfig | null,\n): Promise<\"pnpm\" | \"yarn\" | \"npm\" | \"bun\"> {\n\tconst userAgent = process.env.npm_config_user_agent?.toString() || \"\";\n\tif (userAgent.includes(\"pnpm\")) return \"pnpm\";\n\tif (userAgent.includes(\"yarn\")) return \"yarn\";\n\tif (userAgent.includes(\"bun\")) return \"bun\";\n\tif (userAgent.includes(\"npm\")) return \"npm\";\n\n\tlet currentDir = tsConfig?.path ? path.dirname(tsConfig.path) : cwd;\n\n\twhile (currentDir !== path.parse(currentDir).root) {\n\t\ttry {\n\t\t\tconst pkgJsonPath = path.join(currentDir, \"package.json\");\n\t\t\tconst pkgJsonContent = await fsp.readFile(pkgJsonPath, \"utf-8\");\n\t\t\tconst pkgJson = JSON.parse(pkgJsonContent);\n\n\t\t\tif (pkgJson.packageManager) {\n\t\t\t\tif (pkgJson.packageManager.startsWith(\"pnpm\")) return \"pnpm\";\n\t\t\t\tif (pkgJson.packageManager.startsWith(\"yarn\")) return \"yarn\";\n\t\t\t\tif (pkgJson.packageManager.startsWith(\"bun\")) return \"bun\";\n\t\t\t}\n\t\t} catch {\n\t\t\t// ignore missing or invalid package.json in parent directories\n\t\t}\n\n\t\tlet files: string[] = [];\n\t\ttry {\n\t\t\tfiles = await fsp.readdir(currentDir);\n\t\t} catch {\n\t\t\t// ignore inaccessible directories\n\t\t}\n\n\t\tif (files.includes(\"pnpm-lock.yaml\")) return \"pnpm\";\n\t\tif (files.includes(\"yarn.lock\")) return \"yarn\";\n\t\tif (files.includes(\"bun.lockb\")) return \"bun\";\n\t\tif (files.includes(\"package-lock.json\")) return \"npm\";\n\n\t\tcurrentDir = path.dirname(currentDir);\n\t}\n\n\treturn \"npm\";\n}\n\nexport async function suggestDefaultEnvPath(\n\tcwd = process.cwd(),\n\ttsConfig?: ParsedTsConfig | null,\n): Promise<string> {\n\tlet currentTsConfig = tsConfig;\n\tif (!currentTsConfig) {\n\t\tconst { findTsConfig, loadTsConfig } = await import(\"./tsconfig\");\n\t\tconst tsConfigPath = await findTsConfig(cwd);\n\t\tif (tsConfigPath) {\n\t\t\tcurrentTsConfig = await loadTsConfig(tsConfigPath);\n\t\t}\n\t}\n\n\tif (currentTsConfig?.compilerOptions?.rootDir) {\n\t\tconst rootDir = currentTsConfig.compilerOptions.rootDir;\n\t\tconst rel = path.relative(cwd, rootDir);\n\t\tif (rel && rel !== \".\" && !rel.startsWith(\"..\") && !path.isAbsolute(rel)) {\n\t\t\treturn `./${rel}/env.ts`;\n\t\t}\n\t\treturn \"./env.ts\";\n\t}\n\n\ttry {\n\t\tawait fsp.access(path.join(cwd, \"src\"));\n\t\treturn \"./src/env.ts\";\n\t} catch {\n\t\treturn \"./env.ts\";\n\t}\n}\n","import fsp from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { ParsedTsConfig } from \"@/shared/ports\";\n\nexport async function walk(\n\tdir: string,\n\tfileList: string[] = [],\n): Promise<string[]> {\n\ttry {\n\t\tconst entries = await fsp.readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tconst name = entry.name;\n\t\t\t\tif (\n\t\t\t\t\tname === \"node_modules\" ||\n\t\t\t\t\tname === \"dist\" ||\n\t\t\t\t\tname === \"build\" ||\n\t\t\t\t\tname === \".git\" ||\n\t\t\t\t\tname === \".turbo\" ||\n\t\t\t\t\tname === \"scratch\"\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tawait walk(path.join(dir, name), fileList);\n\t\t\t} else if (entry.isFile()) {\n\t\t\t\tif (\n\t\t\t\t\t/\\.(ts|tsx|js|jsx)$/.test(entry.name) &&\n\t\t\t\t\t!entry.name.endsWith(\".d.ts\")\n\t\t\t\t) {\n\t\t\t\t\tfileList.push(path.join(dir, entry.name));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t// ignore inaccessible directories\n\t}\n\treturn fileList;\n}\n\nexport function parseEnvExample(content: string): string[] {\n\tconst keys: string[] = [];\n\tconst lines = content.split(/\\r?\\n/);\n\n\tfor (const line of lines) {\n\t\tconst trimmed = line.trim();\n\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\tconst match = trimmed.match(/^([A-Z_][A-Z0-9_]*)\\s*=/i);\n\t\tif (match?.[1]) {\n\t\t\tkeys.push(match[1]);\n\t\t}\n\t}\n\n\treturn Array.from(new Set(keys));\n}\n\nexport function resolveImportPaths(\n\timportSpecifier: string,\n\ttsConfig: ParsedTsConfig,\n\tcurrentFilePath: string,\n): string[] {\n\tif (importSpecifier.startsWith(\".\")) {\n\t\treturn [path.resolve(path.dirname(currentFilePath), importSpecifier)];\n\t}\n\tif (path.isAbsolute(importSpecifier)) {\n\t\treturn [importSpecifier];\n\t}\n\n\tconst compilerOptions = tsConfig.compilerOptions || {};\n\tconst baseUrl = compilerOptions.baseUrl || path.dirname(tsConfig.path);\n\tconst paths = compilerOptions.paths || {};\n\n\tconst matches: {\n\t\tcleanPattern: string;\n\t\ttargets: string[];\n\t\thadStar: boolean;\n\t}[] = [];\n\tfor (const [pattern, targets] of Object.entries(paths)) {\n\t\tconst hadStar = pattern.endsWith(\"*\");\n\t\tconst cleanPattern = pattern.replace(/\\*$/, \"\");\n\t\tmatches.push({\n\t\t\tcleanPattern,\n\t\t\ttargets: Array.isArray(targets) ? targets : [targets],\n\t\t\thadStar,\n\t\t});\n\t}\n\n\tmatches.sort((a, b) => b.cleanPattern.length - a.cleanPattern.length);\n\n\tfor (const { cleanPattern, targets, hadStar } of matches) {\n\t\tif (\n\t\t\t(hadStar && importSpecifier.startsWith(cleanPattern)) ||\n\t\t\t(!hadStar && importSpecifier === cleanPattern)\n\t\t) {\n\t\t\tconst subpath = importSpecifier.slice(cleanPattern.length);\n\t\t\treturn targets.map((target) => {\n\t\t\t\tconst cleanTarget = target.replace(/\\*$/, \"\");\n\t\t\t\tconst targetRel = `${cleanTarget}${subpath}`;\n\t\t\t\treturn path.resolve(baseUrl, targetRel);\n\t\t\t});\n\t\t}\n\t}\n\n\tif (compilerOptions.baseUrl) {\n\t\treturn [path.resolve(baseUrl, importSpecifier)];\n\t}\n\n\treturn [];\n}\n\nexport async function scanProjectEnvKeys(\n\tcwd: string,\n\ttsConfig?: ParsedTsConfig | null,\n\tenvConfigPath?: string,\n): Promise<string[]> {\n\tconst keys: string[] = [];\n\tconst files = await walk(cwd);\n\n\tconst cleanEnvConfigPath = envConfigPath\n\t\t? envConfigPath.replace(/\\.(ts|js|tsx|jsx)$/, \"\")\n\t\t: null;\n\n\tfor (const file of files) {\n\t\ttry {\n\t\t\tconst content = await fsp.readFile(file, \"utf-8\");\n\n\t\t\t// Match process.env.VAR\n\t\t\tconst processMatches = content.matchAll(\n\t\t\t\t/process\\.env\\.([A-Z_][A-Z0-9_]*)/g,\n\t\t\t);\n\t\t\tfor (const m of processMatches) {\n\t\t\t\tif (m[1]) keys.push(m[1]);\n\t\t\t}\n\n\t\t\t// Match import.meta.env.VAR\n\t\t\tconst metaMatches = content.matchAll(\n\t\t\t\t/import\\.meta\\.env\\.([A-Z_][A-Z0-9_]*)/g,\n\t\t\t);\n\t\t\tfor (const m of metaMatches) {\n\t\t\t\tif (m[1]) keys.push(m[1]);\n\t\t\t}\n\n\t\t\t// Check for alias or relative import of envConfigPath\n\t\t\tif (cleanEnvConfigPath) {\n\t\t\t\tconst importMatches = content.matchAll(\n\t\t\t\t\t/import\\s+[^;]*from\\s+['\"]([^'\"]+)['\"]/g,\n\t\t\t\t);\n\t\t\t\tfor (const m of importMatches) {\n\t\t\t\t\tconst importPath = m[1];\n\t\t\t\t\tlet resolvedPaths: string[] = [];\n\t\t\t\t\tif (tsConfig) {\n\t\t\t\t\t\tresolvedPaths = resolveImportPaths(importPath, tsConfig, file);\n\t\t\t\t\t} else if (importPath.startsWith(\".\")) {\n\t\t\t\t\t\tresolvedPaths = [path.resolve(path.dirname(file), importPath)];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tresolvedPaths.some(\n\t\t\t\t\t\t\t(p) => p.replace(/\\.(ts|js|tsx|jsx)$/, \"\") === cleanEnvConfigPath,\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// This file imports the env object, scan for env.VAR usages\n\t\t\t\t\t\tconst envMatches = content.matchAll(/\\benv\\.([A-Z_][A-Z0-9_]*)/g);\n\t\t\t\t\t\tfor (const em of envMatches) {\n\t\t\t\t\t\t\tif (em[1]) keys.push(em[1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// ignore unreadable files\n\t\t}\n\t}\n\n\treturn Array.from(new Set(keys));\n}\n\nexport async function getEnvExampleKeys(\n\tcwd = process.cwd(),\n\ttsConfig?: ParsedTsConfig | null,\n\tenvConfigPath?: string,\n): Promise<{ keys: string[]; source: \".env.example\" | \"project\" } | null> {\n\tconst filePath = path.join(cwd, \".env.example\");\n\ttry {\n\t\tconst content = await fsp.readFile(filePath, \"utf-8\");\n\t\tconst keys = parseEnvExample(content);\n\t\tif (keys.length > 0) {\n\t\t\treturn { keys, source: \".env.example\" };\n\t\t}\n\t} catch {\n\t\t// .env.example not found or unreadable\n\t}\n\n\t// Fallback to scanning project files\n\tconst projectKeys = await scanProjectEnvKeys(cwd, tsConfig, envConfigPath);\n\tif (projectKeys.length > 0) {\n\t\treturn { keys: projectKeys, source: \"project\" };\n\t}\n\n\treturn null;\n}\n","import fsp from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { parse } from \"jsonc-parser\";\nimport type { ParsedTsConfig } from \"@/shared/ports\";\n\nconst requireResolve = createRequire(import.meta.url).resolve;\n\nexport async function findTsConfig(\n\tstartDir = process.cwd(),\n): Promise<string | null> {\n\tconst filenames = [\n\t\t\"tsconfig.app.json\",\n\t\t\"tsconfig.json\",\n\t\t\"tsconfig.base.json\",\n\t\t\"tsconfig.node.json\",\n\t];\n\tlet currentDir = startDir;\n\n\twhile (currentDir !== path.parse(currentDir).root) {\n\t\tfor (const file of filenames) {\n\t\t\tconst fullPath = path.join(currentDir, file);\n\t\t\ttry {\n\t\t\t\tawait fsp.access(fullPath);\n\t\t\t\treturn fullPath;\n\t\t\t} catch {\n\t\t\t\t// intentionally ignore missing file\n\t\t\t}\n\t\t}\n\t\tcurrentDir = path.dirname(currentDir);\n\t}\n\treturn null;\n}\n\nexport async function loadTsConfig(\n\tconfigPath: string,\n\tvisited = new Set<string>(),\n): Promise<ParsedTsConfig> {\n\tconst absConfigPath = path.resolve(configPath);\n\tif (visited.has(absConfigPath)) {\n\t\tthrow new Error(\n\t\t\t`Circular extends dependency detected in tsconfig.json: ${absConfigPath}`,\n\t\t);\n\t}\n\tvisited.add(absConfigPath);\n\n\tlet content = \"\";\n\ttry {\n\t\tcontent = await fsp.readFile(configPath, \"utf-8\");\n\t} catch {\n\t\treturn { path: configPath, compilerOptions: {} };\n\t}\n\n\tconst parsed = parse(content) || {};\n\tconst compilerOptions = parsed.compilerOptions || {};\n\n\tlet mergedCompilerOptions: Record<string, any> = {};\n\n\tif (parsed.extends) {\n\t\tconst extendsArr = Array.isArray(parsed.extends)\n\t\t\t? parsed.extends\n\t\t\t: [parsed.extends];\n\t\tfor (const ext of extendsArr) {\n\t\t\tlet extPath: string;\n\t\t\tif (ext.startsWith(\".\") || path.isAbsolute(ext)) {\n\t\t\t\textPath = path.resolve(path.dirname(configPath), ext);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\textPath = requireResolve(ext, {\n\t\t\t\t\t\tpaths: [path.dirname(configPath)],\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\textPath = path.resolve(path.dirname(configPath), \"node_modules\", ext);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst baseConfig = await loadTsConfig(extPath, visited);\n\t\t\tconst baseOptions = { ...baseConfig.compilerOptions };\n\n\t\t\t// Resolve base baseUrl and rootDir relative to extPath\n\t\t\tif (baseOptions.baseUrl) {\n\t\t\t\tbaseOptions.baseUrl = path.resolve(\n\t\t\t\t\tpath.dirname(extPath),\n\t\t\t\t\tbaseOptions.baseUrl,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (baseOptions.rootDir) {\n\t\t\t\tbaseOptions.rootDir = path.resolve(\n\t\t\t\t\tpath.dirname(extPath),\n\t\t\t\t\tbaseOptions.rootDir,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tmergedCompilerOptions = { ...mergedCompilerOptions, ...baseOptions };\n\t\t}\n\t}\n\n\t// Resolve current baseUrl and rootDir relative to configPath\n\tconst currentOptions = { ...compilerOptions };\n\tif (currentOptions.baseUrl) {\n\t\tcurrentOptions.baseUrl = path.resolve(\n\t\t\tpath.dirname(configPath),\n\t\t\tcurrentOptions.baseUrl,\n\t\t);\n\t}\n\tif (currentOptions.rootDir) {\n\t\tcurrentOptions.rootDir = path.resolve(\n\t\t\tpath.dirname(configPath),\n\t\t\tcurrentOptions.rootDir,\n\t\t);\n\t}\n\n\tmergedCompilerOptions = { ...mergedCompilerOptions, ...currentOptions };\n\n\treturn {\n\t\t...parsed,\n\t\tpath: configPath,\n\t\tcompilerOptions: mergedCompilerOptions,\n\t};\n}\n\nexport async function checkTsConfig(cwd = process.cwd()): Promise<{\n\tstatus: \"strict\" | \"not_strict\" | \"not_found\";\n\tfile?: string;\n\tparsed?: ParsedTsConfig;\n}> {\n\tconst tsConfigPath = await findTsConfig(cwd);\n\tif (!tsConfigPath) return { status: \"not_found\" };\n\tconst fileName = path.basename(tsConfigPath);\n\n\ttry {\n\t\tconst parsed = await loadTsConfig(tsConfigPath);\n\t\tif (parsed?.compilerOptions?.strict === true) {\n\t\t\treturn { status: \"strict\", file: fileName, parsed };\n\t\t}\n\t\treturn { status: \"not_strict\", file: fileName, parsed };\n\t} catch {\n\t\treturn { status: \"not_found\" };\n\t}\n}\n","import fsp from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { RequirementCheckResult } from \"@/shared/ports\";\nimport { checkTsConfig } from \"./tsconfig\";\n\n/**\n * Simple semver comparison.\n * Returns 1 if v1 > v2, -1 if v1 < v2, 0 if equal.\n */\nfunction compareSemver(v1: string, v2: string): number {\n\tconst p1 = v1.replace(/^v/, \"\").split(\".\").map(Number);\n\tconst p2 = v2.replace(/^v/, \"\").split(\".\").map(Number);\n\tfor (let i = 0; i < 3; i++) {\n\t\tconst n1 = p1[i] || 0;\n\t\tconst n2 = p2[i] || 0;\n\t\tif (n1 > n2) return 1;\n\t\tif (n1 < n2) return -1;\n\t}\n\treturn 0;\n}\n\n/**\n * Normalizes a semver string by removing leading 'v' and ensuring it has 3 parts (major.minor.patch).\n * @param version The version string to normalize.\n * @returns The normalized version string, or null if it cannot be parsed.\n */\nfunction normalizeVersion(version: string): string | null {\n\tconst match = version.trim().match(/^v?(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?/);\n\tif (!match) return null;\n\treturn [match[1], match[2] ?? \"0\", match[3] ?? \"0\"].join(\".\");\n}\n\n/**\n * Checks if a given TypeScript version range is compatible with a minimum version.\n * @param range The version range string from package.json (e.g. \"^5.1.0\", \">=5.0.0\").\n * @param minVersion The minimum required TypeScript version.\n * @returns True if the range specifies a version that is compatible with the minimum version.\n */\nfunction isTypescriptRangeCompatible(\n\trange: string,\n\tminVersion: string,\n): boolean {\n\tconst trimmed = range.trim();\n\tconst shorthand = trimmed.match(/^[\\^~]?\\s*(v?\\d+(?:\\.\\d+){0,2})$/);\n\tif (shorthand) {\n\t\tconst version = normalizeVersion(shorthand[1]);\n\t\treturn version !== null && compareSemver(version, minVersion) >= 0;\n\t}\n\n\tconst comparators = trimmed.match(/(?:>=|>|<=|<|=)\\s*v?\\d+(?:\\.\\d+){0,2}/g);\n\tif (!comparators) return false;\n\tif (comparators.join(\" \") !== trimmed.replace(/\\s+/g, \" \")) return false;\n\n\treturn comparators.some((comparator) => {\n\t\tconst match = comparator.match(/^(>=|>|<=|<|=)\\s*(v?\\d+(?:\\.\\d+){0,2})$/);\n\t\tif (!match) return false;\n\n\t\tconst [, operator, rawVersion] = match;\n\t\tconst version = normalizeVersion(rawVersion);\n\t\tif (!version) return false;\n\n\t\tif (operator === \">=\") return compareSemver(version, minVersion) >= 0;\n\t\tif (operator === \">\") return compareSemver(version, minVersion) >= 0;\n\t\tif (operator === \"=\") return compareSemver(version, minVersion) >= 0;\n\t\treturn false;\n\t});\n}\n\n/**\n * Checks project requirements including Node.js version, package.json existence,\n * TypeScript version, and tsconfig.json settings.\n * @param cwd The current working directory to check. Defaults to process.cwd().\n * @returns A promise that resolves to an array of requirement check results.\n */\nexport async function checkRequirements(\n\tcwd = process.cwd(),\n): Promise<RequirementCheckResult[]> {\n\tconst results: RequirementCheckResult[] = [];\n\n\t// 1. Node.js version check\n\tconst nodeVersion = process.version;\n\tconst minNodeVersion = \"22.0.0\";\n\tif (compareSemver(nodeVersion, minNodeVersion) === -1) {\n\t\tresults.push({\n\t\t\tstatus: \"fail\",\n\t\t\trequirement: \"Node.js Version\",\n\t\t\tmessage: `Node.js version must be >= ${minNodeVersion}.`,\n\t\t\tcurrent: nodeVersion,\n\t\t\texpected: `>= ${minNodeVersion}`,\n\t\t});\n\t} else {\n\t\tresults.push({\n\t\t\tstatus: \"pass\",\n\t\t\trequirement: \"Node.js Version\",\n\t\t\tmessage: \"Node.js version is compatible.\",\n\t\t});\n\t}\n\n\t// 2. package.json check\n\tlet pkg: any = null;\n\ttry {\n\t\tconst pkgJsonPath = path.join(cwd, \"package.json\");\n\t\tconst content = await fsp.readFile(pkgJsonPath, \"utf-8\");\n\t\tpkg = JSON.parse(content);\n\t\tresults.push({\n\t\t\tstatus: \"pass\",\n\t\t\trequirement: \"package.json\",\n\t\t\tmessage: \"package.json found.\",\n\t\t});\n\t} catch {\n\t\tresults.push({\n\t\t\tstatus: \"warn\",\n\t\t\trequirement: \"package.json\",\n\t\t\tmessage: \"package.json not found in the current directory.\",\n\t\t});\n\t}\n\n\t// 3. TypeScript version check\n\tif (pkg) {\n\t\tconst allDeps = { ...pkg.dependencies, ...pkg.devDependencies };\n\t\tconst tsVersion = allDeps.typescript;\n\t\tconst minTsVersion = \"5.1.0\";\n\n\t\tif (tsVersion) {\n\t\t\tif (!isTypescriptRangeCompatible(tsVersion, minTsVersion)) {\n\t\t\t\tresults.push({\n\t\t\t\t\tstatus: \"fail\",\n\t\t\t\t\trequirement: \"TypeScript Version\",\n\t\t\t\t\tmessage: `TypeScript version should be >= ${minTsVersion}.`,\n\t\t\t\t\tcurrent: tsVersion,\n\t\t\t\t\texpected: `>= ${minTsVersion}`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresults.push({\n\t\t\t\t\tstatus: \"pass\",\n\t\t\t\t\trequirement: \"TypeScript Version\",\n\t\t\t\t\tmessage: \"TypeScript version is compatible.\",\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tresults.push({\n\t\t\t\tstatus: \"warn\",\n\t\t\t\trequirement: \"TypeScript Version\",\n\t\t\t\tmessage: \"TypeScript not found in package.json dependencies.\",\n\t\t\t});\n\t\t}\n\t}\n\n\t// 4. tsconfig.json checks\n\tconst tsConfigRes = await checkTsConfig(cwd);\n\tif (tsConfigRes.status === \"not_found\") {\n\t\tresults.push({\n\t\t\tstatus: \"warn\",\n\t\t\trequirement: \"tsconfig.json\",\n\t\t\tmessage: \"tsconfig.json not found.\",\n\t\t});\n\t} else {\n\t\tconst parsed = tsConfigRes.parsed!;\n\t\tconst compilerOptions = parsed.compilerOptions || {};\n\n\t\t// Strict mode\n\t\tif (compilerOptions.strict === true) {\n\t\t\tresults.push({\n\t\t\t\tstatus: \"pass\",\n\t\t\t\trequirement: \"TypeScript Strict Mode\",\n\t\t\t\tmessage: \"Strict mode is enabled.\",\n\t\t\t});\n\t\t} else {\n\t\t\tresults.push({\n\t\t\t\tstatus: \"fail\",\n\t\t\t\trequirement: \"TypeScript Strict Mode\",\n\t\t\t\tmessage: \"Strict mode must be enabled.\",\n\t\t\t\tcurrent: \"false\",\n\t\t\t\texpected: \"true\",\n\t\t\t});\n\t\t}\n\n\t\t// moduleResolution\n\t\tconst moduleRes = compilerOptions.moduleResolution?.toLowerCase();\n\t\tconst moduleType = compilerOptions.module?.toLowerCase();\n\n\t\tconst validResolutions = [\"bundler\", \"node16\", \"nodenext\"];\n\t\tconst isValidResolution = validResolutions.includes(moduleRes || \"\");\n\n\t\t// If module is node16 or nodenext, moduleResolution defaults to that if not specified\n\t\tconst isImplicitlyValid =\n\t\t\t!moduleRes && (moduleType === \"node16\" || moduleType === \"nodenext\");\n\n\t\tif (isValidResolution || isImplicitlyValid) {\n\t\t\tresults.push({\n\t\t\t\tstatus: \"pass\",\n\t\t\t\trequirement: \"TypeScript moduleResolution\",\n\t\t\t\tmessage: `moduleResolution is set to ${moduleRes || \"implicit\"}.`,\n\t\t\t});\n\t\t} else {\n\t\t\tresults.push({\n\t\t\t\tstatus: \"fail\",\n\t\t\t\trequirement: \"TypeScript moduleResolution\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"moduleResolution must be set to 'bundler', 'node16', or 'nodenext'.\",\n\t\t\t\tcurrent: moduleRes || \"default\",\n\t\t\t\texpected: \"bundler, node16, or nodenext\",\n\t\t\t});\n\t\t}\n\t}\n\n\treturn results;\n}\n","import { execSync } from \"node:child_process\";\nimport fsp from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type {\n\tLoggerPort,\n\tParsedTsConfig,\n\tProjectScannerPort,\n\tRequirementCheckResult,\n} from \"@/shared/ports\";\nimport {\n\tdetectBunFeatures,\n\tdetectFramework,\n\tdetectPackageManager,\n\tsuggestDefaultEnvPath,\n} from \"./utils/detector\";\nimport { getEnvExampleKeys } from \"./utils/env-scanner\";\nimport { checkRequirements } from \"./utils/requirements\";\nimport { checkTsConfig, findTsConfig, loadTsConfig } from \"./utils/tsconfig\";\n\n/**\n * Adapter implementation for ProjectScannerPort using Node.js APIs.\n */\nexport class NodeProjectScannerAdapter implements ProjectScannerPort {\n\tconstructor(private logger?: Pick<LoggerPort, \"log\">) {}\n\t/**\n\t * Reports whether a directory has no entries, treating unreadable directories as not empty.\n\t */\n\tasync isEmptyDirectory(dir = process.cwd()): Promise<boolean> {\n\t\ttry {\n\t\t\tconst files = await fsp.readdir(dir);\n\t\t\treturn files.length === 0;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Reports whether a directory contains a package manifest.\n\t */\n\tasync hasPackageJson(dir = process.cwd()): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fsp.access(path.join(dir, \"package.json\"));\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Finds the nearest TypeScript config starting from the provided directory.\n\t */\n\tasync findTsConfig(startDir = process.cwd()): Promise<string | null> {\n\t\treturn findTsConfig(startDir);\n\t}\n\n\t/**\n\t * Loads and parses a TypeScript config, including any inherited configs.\n\t */\n\tasync loadTsConfig(\n\t\tconfigPath: string,\n\t\tvisited = new Set<string>(),\n\t): Promise<ParsedTsConfig> {\n\t\treturn loadTsConfig(configPath, visited);\n\t}\n\n\t/**\n\t * Discovers environment keys from `.env.example` or existing project usage.\n\t */\n\tasync getEnvExampleKeys(\n\t\tcwd = process.cwd(),\n\t\ttsConfig?: ParsedTsConfig | null,\n\t\tenvConfigPath?: string,\n\t): Promise<{ keys: string[]; source: \".env.example\" | \"project\" } | null> {\n\t\treturn getEnvExampleKeys(cwd, tsConfig, envConfigPath);\n\t}\n\n\t/**\n\t * Suggests the most likely environment schema path for the project.\n\t */\n\tasync suggestDefaultEnvPath(\n\t\tcwd = process.cwd(),\n\t\ttsConfig?: ParsedTsConfig | null,\n\t): Promise<string> {\n\t\treturn suggestDefaultEnvPath(cwd, tsConfig);\n\t}\n\n\t/**\n\t * Checks whether the project TypeScript config already satisfies ArkEnv requirements.\n\t */\n\tasync checkTsConfig(cwd = process.cwd()): Promise<{\n\t\tstatus: \"strict\" | \"not_strict\" | \"not_found\";\n\t\tfile?: string;\n\t\tparsed?: ParsedTsConfig;\n\t}> {\n\t\treturn checkTsConfig(cwd);\n\t}\n\n\t/**\n\t * Checks technical requirements for the project.\n\t */\n\tasync checkRequirements(\n\t\tcwd = process.cwd(),\n\t): Promise<RequirementCheckResult[]> {\n\t\treturn checkRequirements(cwd);\n\t}\n\n\t/**\n\t * Detects the framework integration that best matches the project.\n\t */\n\tasync detectFramework(\n\t\tcwd = process.cwd(),\n\t\ttsConfig?: ParsedTsConfig | null,\n\t): Promise<\"vite\" | \"bun-fullstack\" | \"vanilla\" | \"nextjs\" | \"nuxt\"> {\n\t\treturn detectFramework(cwd, tsConfig);\n\t}\n\n\t/**\n\t * Detects which Bun browser bundling entry points are present.\n\t */\n\tasync detectBunFeatures(\n\t\tcwd = process.cwd(),\n\t\ttsConfig?: ParsedTsConfig | null,\n\t): Promise<(\"serve\" | \"build\")[]> {\n\t\treturn detectBunFeatures(cwd, tsConfig);\n\t}\n\n\t/**\n\t * Detects the package manager used by the project.\n\t */\n\tasync detectPackageManager(\n\t\tcwd = process.cwd(),\n\t\ttsConfig?: ParsedTsConfig | null,\n\t): Promise<\"pnpm\" | \"yarn\" | \"npm\" | \"bun\"> {\n\t\treturn detectPackageManager(cwd, tsConfig);\n\t}\n\n\t/**\n\t * Detects whether the arkenv skill is already installed.\n\t */\n\tasync hasSkill(cwd = process.cwd()): Promise<boolean> {\n\t\ttry {\n\t\t\tconst skillsLockPath = path.join(cwd, \"skills-lock.json\");\n\t\t\tconst content = await fsp.readFile(skillsLockPath, \"utf-8\");\n\t\t\tconst parsed = JSON.parse(content);\n\t\t\tif (\n\t\t\t\tparsed &&\n\t\t\t\ttypeof parsed === \"object\" &&\n\t\t\t\tparsed.skills &&\n\t\t\t\ttypeof parsed.skills === \"object\"\n\t\t\t) {\n\t\t\t\tif (\"arkenv\" in parsed.skills) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// ignore missing or malformed skills-lock.json\n\t\t}\n\n\t\tconst skillPaths = [\n\t\t\t\"skills/arkenv/SKILL.md\",\n\t\t\t\".agent/skills/arkenv/SKILL.md\",\n\t\t\t\".agents/skills/arkenv/SKILL.md\",\n\t\t];\n\t\tfor (const relativePath of skillPaths) {\n\t\t\ttry {\n\t\t\t\tawait fsp.access(path.join(cwd, relativePath));\n\t\t\t\treturn true;\n\t\t\t} catch {\n\t\t\t\t// ignore path not accessible\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check the Git working tree status in the target directory.\n\t *\n\t * @param cwd The directory to check for Git status\n\t * @returns An object indicating whether the working tree is clean, dirty, not a repo, or unknown\n\t */\n\tasync checkGitStatus(\n\t\tcwd = process.cwd(),\n\t): Promise<{ status: \"clean\" | \"dirty\" | \"not_a_repo\" | \"unknown\" }> {\n\t\ttry {\n\t\t\tconst stdout = execSync(\"git status --porcelain\", {\n\t\t\t\tcwd,\n\t\t\t\tencoding: \"utf-8\",\n\t\t\t});\n\t\t\treturn stdout.trim().length === 0\n\t\t\t\t? { status: \"clean\" }\n\t\t\t\t: { status: \"dirty\" };\n\t\t} catch (error) {\n\t\t\tconst err = error as { code?: string; stderr?: string };\n\t\t\tif (err.code === \"ENOENT\") {\n\t\t\t\tthis.logger?.log(\n\t\t\t\t\t\"Git is not installed on this system. Skipping git status check.\",\n\t\t\t\t);\n\t\t\t\treturn { status: \"not_a_repo\" };\n\t\t\t}\n\t\t\tif (\n\t\t\t\ttypeof err.stderr === \"string\" &&\n\t\t\t\terr.stderr.includes(\"not a git repository\")\n\t\t\t) {\n\t\t\t\treturn { status: \"not_a_repo\" };\n\t\t\t}\n\t\t\treturn { status: \"unknown\" };\n\t\t}\n\t}\n\n\t/**\n\t * Finds the nearest package.json starting from the given directory.\n\t */\n\tasync findPackageJson(startDir = process.cwd()): Promise<string | null> {\n\t\tlet current = path.resolve(startDir);\n\t\twhile (true) {\n\t\t\tconst candidate = path.join(current, \"package.json\");\n\t\t\ttry {\n\t\t\t\tawait fsp.access(candidate);\n\t\t\t\treturn candidate;\n\t\t\t} catch {\n\t\t\t\tconst parent = path.dirname(current);\n\t\t\t\tif (parent === current) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tcurrent = parent;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Reads and parses the arkenv configuration field from the nearest package.json.\n\t */\n\tasync readArkenvConfig(\n\t\tcwd = process.cwd(),\n\t): Promise<{ schema: string; layout: \"flat\" | \"strict\" } | null> {\n\t\tconst pkgPath = await this.findPackageJson(cwd);\n\t\tif (!pkgPath) return null;\n\n\t\ttry {\n\t\t\tconst content = await fsp.readFile(pkgPath, \"utf-8\");\n\t\t\tconst pkg = JSON.parse(content);\n\t\t\tif (!pkg.arkenv) return null;\n\n\t\t\tif (typeof pkg.arkenv === \"string\") {\n\t\t\t\treturn {\n\t\t\t\t\tschema: pkg.arkenv,\n\t\t\t\t\tlayout: \"flat\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\ttypeof pkg.arkenv === \"object\" &&\n\t\t\t\ttypeof pkg.arkenv.schema === \"string\"\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\tschema: pkg.arkenv.schema,\n\t\t\t\t\tlayout: pkg.arkenv.layout === \"strict\" ? \"strict\" : \"flat\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn null;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n","import pc from \"picocolors\";\n\n/**\n * Format the given string as a code section.\n */\nexport const code = (str: string) => pc.cyan(str);\n\n/**\n * The ArkEnv blue ⛯ symbol.\n */\nexport const symbol = pc.blue(\"⛯\");\n","import type { Framework } from \"@/features/scaffold/plan\";\n\n/**\n * Configuration for frameworks that emit codegen-aware env schemas\n * (Next.js and Nuxt).\n */\nexport type CodegenFrameworkConfig = {\n\tid: \"nextjs\" | \"nuxt\";\n\tpackageName: \"@arkenv/nextjs\" | \"@arkenv/nuxt\";\n\tclientPrefix: \"NEXT_PUBLIC_\" | \"NUXT_PUBLIC_\";\n\tdisplayName: \"Next.js\" | \"Nuxt\";\n\t/**\n\t * When true, bootstrap wraps next.config (Next.js only).\n\t */\n\tsupportsWrapNextjsConfig: boolean;\n};\n\n/**\n * Canonical Next.js / Nuxt package names, client prefixes, and display names.\n * All scaffold code that needs these values should read from here.\n */\nexport const CODEGEN_FRAMEWORK_CONFIGS = {\n\tnextjs: {\n\t\tid: \"nextjs\",\n\t\tpackageName: \"@arkenv/nextjs\",\n\t\tclientPrefix: \"NEXT_PUBLIC_\",\n\t\tdisplayName: \"Next.js\",\n\t\tsupportsWrapNextjsConfig: true,\n\t},\n\tnuxt: {\n\t\tid: \"nuxt\",\n\t\tpackageName: \"@arkenv/nuxt\",\n\t\tclientPrefix: \"NUXT_PUBLIC_\",\n\t\tdisplayName: \"Nuxt\",\n\t\tsupportsWrapNextjsConfig: false,\n\t},\n} as const satisfies Record<\"nextjs\" | \"nuxt\", CodegenFrameworkConfig>;\n\n/**\n * Resolve the codegen framework config for a framework id.\n *\n * @param framework The selected framework.\n * @returns Config when the framework is Next.js or Nuxt; otherwise undefined.\n */\nexport function getCodegenConfig(\n\tframework: Framework,\n): CodegenFrameworkConfig | undefined {\n\tif (framework === \"nextjs\" || framework === \"nuxt\") {\n\t\treturn CODEGEN_FRAMEWORK_CONFIGS[framework];\n\t}\n\treturn undefined;\n}\n\n/**\n * Whether the framework uses codegen-aware env schema packages.\n *\n * @param framework The selected framework.\n * @returns True for Next.js and Nuxt.\n */\nexport function isCodegenFramework(\n\tframework: Framework,\n): framework is \"nextjs\" | \"nuxt\" {\n\treturn framework === \"nextjs\" || framework === \"nuxt\";\n}\n","import type { Framework } from \"@/features/scaffold/plan\";\nimport { CODEGEN_FRAMEWORK_CONFIGS } from \"./codegen-config\";\n\n/**\n * Canonical client env prefixes per framework.\n *\n * Assigned to each framework strategy's `clientPrefix`. Context creation reads\n * from here rather than the FRAMEWORKS registry to avoid a circular import.\n */\nexport const FRAMEWORK_CLIENT_PREFIXES = {\n\tnextjs: CODEGEN_FRAMEWORK_CONFIGS.nextjs.clientPrefix,\n\tnuxt: CODEGEN_FRAMEWORK_CONFIGS.nuxt.clientPrefix,\n\tvite: \"VITE_\",\n\t\"bun-fullstack\": \"BUN_PUBLIC_\",\n\tvanilla: \"\",\n} as const satisfies Record<Framework, string>;\n","import { FRAMEWORK_CLIENT_PREFIXES } from \"@/features/scaffold/frameworks/client-prefixes\";\nimport { getCodegenConfig } from \"@/features/scaffold/frameworks/codegen-config\";\nimport type { Framework, ProjectOptions } from \"./plan\";\nimport type { HostPreset } from \"./presets\";\n\n/**\n * Shared context passed to validator strategies during template generation.\n */\nexport type ScaffoldContext = {\n\tframework: Framework;\n\t/**\n\t * Client env prefix from the active framework strategy (e.g. `NEXT_PUBLIC_`, `VITE_`).\n\t */\n\tclientPrefix: string;\n\t/**\n\t * Integration package name when the framework is codegen-aware.\n\t */\n\tpackageName?: string;\n\tdisableCodegen: boolean;\n\tlayout?: \"strict\" | \"simple\" | \"flat\";\n\tnextjsImportPath?: string;\n\t/**\n\t * Hosting provider preset for schema field enrichment.\n\t */\n\thostPreset?: HostPreset;\n};\n\n/**\n * Build a {@link ScaffoldContext} from project options and optional import path.\n *\n * Client prefix comes from {@link FRAMEWORK_CLIENT_PREFIXES}, the same source\n * each framework strategy exposes as `clientPrefix`. Package name still comes\n * from codegen framework config for Next/Nuxt.\n *\n * @param options The selected project options\n * @param nextjsImportPath The optional custom import path for generated env files\n * @returns A scaffold context for validator strategies\n */\nexport function createScaffoldContext(\n\toptions: ProjectOptions,\n\tnextjsImportPath?: string,\n): ScaffoldContext {\n\tconst codegen = getCodegenConfig(options.framework);\n\n\treturn {\n\t\tframework: options.framework,\n\t\tclientPrefix: FRAMEWORK_CLIENT_PREFIXES[options.framework],\n\t\t...(codegen?.packageName !== undefined && {\n\t\t\tpackageName: codegen.packageName,\n\t\t}),\n\t\tdisableCodegen: options.disableCodegen === true,\n\t\t...(options.layout !== undefined && { layout: options.layout }),\n\t\t...(nextjsImportPath !== undefined && { nextjsImportPath }),\n\t\t...(options.hostPreset !== undefined && {\n\t\t\thostPreset: options.hostPreset,\n\t\t}),\n\t};\n}\n","import path from \"node:path\";\nimport type { Framework, ProjectOptions } from \"@/features/scaffold/plan\";\nimport { createScaffoldContext } from \"@/features/scaffold/scaffold-context\";\nimport type { ValidatorStrategy } from \"@/features/scaffold/validators/types\";\nimport type { ParsedTsConfig } from \"@/shared/ports/project-scanner.port\";\nimport { isCodegenFramework } from \"./codegen-config\";\nimport type { FrameworkGetFilesParams } from \"./types\";\n\nconst ENV_KEY_DEFAULTS: Record<string, string> = {\n\tNODE_ENV: \"development\",\n\tPORT: \"3000\",\n\tDATABASE_URL: \"postgres://localhost:5432/mydb\",\n};\n\nconst TS_CONFIG_ALIAS_KEY = \"@/*\";\nconst PATH_ALIAS_PREFIX = \"@/\";\nconst GENERATED_ENV_DIR = \"generated\";\nconst GENERATED_ENV_MODULE = \"env.gen\";\n\nconst STRICT_INTERNAL_DIR = \"internal\";\nconst STRICT_SHARED_BASENAME = \"shared\";\nconst STRICT_CLIENT_BASENAME = \"client\";\nconst STRICT_SERVER_BASENAME = \"server\";\n\nconst SCHEMA_FILE_LABEL = \"environment schema\";\nconst SHARED_SCHEMA_FILE_LABEL = \"shared environment schema\";\nconst CLIENT_SCHEMA_FILE_LABEL = \"client environment schema\";\nconst SERVER_SCHEMA_FILE_LABEL = \"server environment schema\";\n\n/**\n * Build default env var values from explicit keys.\n *\n * @param keys Environment variable keys.\n * @returns A map of env var names to default values.\n */\nexport function getEnvDefaultsFromKeys(keys: string[]): Record<string, string> {\n\tconst defaults: Record<string, string> = {};\n\tfor (const key of keys) {\n\t\tdefaults[key] = ENV_KEY_DEFAULTS[key] ?? \"\";\n\t}\n\treturn defaults;\n}\n\n/**\n * Resolve the generated env import path from tsconfig path aliases.\n *\n * @param cwd The project root directory.\n * @param generatedDir Absolute path to the generated env directory.\n * @param tsConfig Parsed tsconfig data.\n * @returns An alias-based import path or undefined when no mapping matches.\n */\nexport function resolveAliasImportPath(\n\tcwd: string,\n\tgeneratedDir: string,\n\ttsConfig?: ParsedTsConfig,\n): string | undefined {\n\tif (!tsConfig) {\n\t\treturn undefined;\n\t}\n\n\tconst compilerOptions = tsConfig.compilerOptions || {};\n\tconst paths = compilerOptions.paths || {};\n\tconst aliasPatterns = paths[TS_CONFIG_ALIAS_KEY];\n\tif (!aliasPatterns) {\n\t\treturn undefined;\n\t}\n\n\tconst tsConfigDir = tsConfig.path ? path.dirname(tsConfig.path) : cwd;\n\tconst relGeneratedDir = path\n\t\t.relative(tsConfigDir, generatedDir)\n\t\t.replace(/\\\\/g, \"/\");\n\n\tfor (const pattern of aliasPatterns) {\n\t\tconst normalizedPattern = pattern.replace(/^\\.\\//, \"\").replace(/\\*$/, \"\");\n\t\tif (\n\t\t\tnormalizedPattern === \"\" ||\n\t\t\trelGeneratedDir.startsWith(normalizedPattern)\n\t\t) {\n\t\t\tlet subPath = relGeneratedDir;\n\t\t\tif (\n\t\t\t\tnormalizedPattern !== \"\" &&\n\t\t\t\trelGeneratedDir.startsWith(normalizedPattern)\n\t\t\t) {\n\t\t\t\tsubPath = relGeneratedDir.substring(normalizedPattern.length);\n\t\t\t}\n\t\t\tsubPath = subPath.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n\t\t\treturn `${PATH_ALIAS_PREFIX}${subPath}/${GENERATED_ENV_MODULE}`.replace(\n\t\t\t\t/\\/+/g,\n\t\t\t\t\"/\",\n\t\t\t);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction resolveCodegenImportPath(\n\tparams: FrameworkGetFilesParams,\n\tgeneratedDir: string,\n\toptions: { framework: Framework; disableCodegen?: boolean },\n): string | undefined {\n\tif (\n\t\t!isCodegenFramework(options.framework) ||\n\t\toptions.disableCodegen ||\n\t\t!params.tsConfig?.parsed\n\t) {\n\t\treturn undefined;\n\t}\n\n\treturn resolveAliasImportPath(\n\t\tparams.cwd,\n\t\tgeneratedDir,\n\t\tparams.tsConfig.parsed,\n\t);\n}\n\n/**\n * Resolve the Next.js/Nuxt generated env import path for simple layouts.\n *\n * @param params File planning parameters.\n * @param options Framework and codegen options.\n * @returns The resolved import path when codegen is enabled.\n */\nexport function resolveSimpleImportPath(\n\tparams: FrameworkGetFilesParams,\n\toptions: { framework: Framework; disableCodegen?: boolean },\n): string | undefined {\n\treturn resolveCodegenImportPath(\n\t\tparams,\n\t\tpath.join(params.targetDir, GENERATED_ENV_DIR),\n\t\toptions,\n\t);\n}\n\n/**\n * Resolve the Next.js/Nuxt generated env import path for strict layouts.\n *\n * @param params File planning parameters.\n * @param baseWithoutExt Absolute path to the env schema base without extension.\n * @param options Framework and codegen options.\n * @returns The resolved import path when codegen is enabled.\n */\nexport function resolveStrictImportPath(\n\tparams: FrameworkGetFilesParams,\n\tbaseWithoutExt: string,\n\toptions: { framework: Framework; disableCodegen?: boolean },\n): string | undefined {\n\treturn resolveCodegenImportPath(\n\t\tparams,\n\t\tpath.join(baseWithoutExt, GENERATED_ENV_DIR),\n\t\toptions,\n\t);\n}\n\n/**\n * Plan a single env schema file using the validator's simple template.\n *\n * @param validator The validator strategy providing template generation.\n * @param options The selected project options.\n * @param params File planning parameters.\n * @param importPath Optional generated env import path.\n * @returns Planned schema file actions.\n */\nexport function planSimpleSchemaFile(\n\tvalidator: ValidatorStrategy,\n\toptions: ProjectOptions,\n\tparams: FrameworkGetFilesParams,\n\timportPath?: string,\n) {\n\tconst context = createScaffoldContext(options, importPath);\n\tconst envContent = validator.getSimpleTemplate(\n\t\toptions.envKeys ?? [],\n\t\tcontext,\n\t);\n\tconst envFileExists = params.existingFiles.includes(params.targetPath);\n\n\tif (!envFileExists || options.overwriteEnvSchemaFile !== false) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tpath: params.targetPath,\n\t\t\t\tcontent: envContent,\n\t\t\t\taction: envFileExists ? (\"overwrite\" as const) : (\"create\" as const),\n\t\t\t\tlabel: SCHEMA_FILE_LABEL,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n}\n\n/**\n * Plan strict-layout env schema files using the validator's strict templates.\n *\n * @param validator The validator strategy providing template generation.\n * @param options The selected project options.\n * @param params File planning parameters.\n * @param importPath Optional generated env import path.\n * @returns Planned shared, client, and server schema file actions.\n */\nexport function planStrictSchemaFiles(\n\tvalidator: ValidatorStrategy,\n\toptions: ProjectOptions,\n\tparams: FrameworkGetFilesParams,\n\timportPath?: string,\n) {\n\tconst ext = path.extname(params.targetPath);\n\tconst baseWithoutExt = params.targetPath.slice(0, -ext.length);\n\tconst sharedPath = path.join(\n\t\tbaseWithoutExt,\n\t\tSTRICT_INTERNAL_DIR,\n\t\t`${STRICT_SHARED_BASENAME}${ext}`,\n\t);\n\tconst clientPath = path.join(\n\t\tbaseWithoutExt,\n\t\t`${STRICT_CLIENT_BASENAME}${ext}`,\n\t);\n\tconst serverPath = path.join(\n\t\tbaseWithoutExt,\n\t\t`${STRICT_SERVER_BASENAME}${ext}`,\n\t);\n\n\tconst context = createScaffoldContext(options, importPath);\n\tconst templates = validator.getStrictTemplates(\n\t\toptions.envKeys ?? [],\n\t\tcontext,\n\t);\n\n\tconst sharedExists = params.existingFiles.includes(sharedPath);\n\tconst clientExists = params.existingFiles.includes(clientPath);\n\tconst serverExists = params.existingFiles.includes(serverPath);\n\n\tconst files = [];\n\n\tif (!sharedExists || options.overwriteEnvSchemaFile !== false) {\n\t\tfiles.push({\n\t\t\tpath: sharedPath,\n\t\t\tcontent: templates.shared,\n\t\t\taction: sharedExists ? (\"overwrite\" as const) : (\"create\" as const),\n\t\t\tlabel: SHARED_SCHEMA_FILE_LABEL,\n\t\t});\n\t}\n\tif (!clientExists || options.overwriteEnvSchemaFile !== false) {\n\t\tfiles.push({\n\t\t\tpath: clientPath,\n\t\t\tcontent: templates.client,\n\t\t\taction: clientExists ? (\"overwrite\" as const) : (\"create\" as const),\n\t\t\tlabel: CLIENT_SCHEMA_FILE_LABEL,\n\t\t});\n\t}\n\tif (!serverExists || options.overwriteEnvSchemaFile !== false) {\n\t\tfiles.push({\n\t\t\tpath: serverPath,\n\t\t\tcontent: templates.server,\n\t\t\taction: serverExists ? (\"overwrite\" as const) : (\"create\" as const),\n\t\t\tlabel: SERVER_SCHEMA_FILE_LABEL,\n\t\t});\n\t}\n\n\treturn files;\n}\n","import { shake } from \"radashi\";\nimport { FRAMEWORK_CLIENT_PREFIXES } from \"./client-prefixes\";\nimport {\n\tgetEnvDefaultsFromKeys,\n\tplanSimpleSchemaFile,\n\tplanStrictSchemaFiles,\n} from \"./shared\";\nimport type { FrameworkStrategy } from \"./types\";\n\nexport const bunFullstackStrategy: FrameworkStrategy = {\n\tclientPrefix: FRAMEWORK_CLIENT_PREFIXES[\"bun-fullstack\"],\n\n\tgetEnvDefaults(keys) {\n\t\tif (keys && keys.length > 0) {\n\t\t\treturn getEnvDefaultsFromKeys(keys);\n\t\t}\n\t\treturn {\n\t\t\tDATABASE_URL: \"postgres://localhost:5432/mydb\",\n\t\t\tBUN_PUBLIC_API_URL: \"https://api.example.com\",\n\t\t\tNODE_ENV: \"development\",\n\t\t};\n\t},\n\n\tgetDependencies(options) {\n\t\treturn options.bunFeatures?.length ? [\"@arkenv/bun-plugin\"] : [];\n\t},\n\n\trequiresArktypePeer(options) {\n\t\treturn Boolean(options.bunFeatures?.length);\n\t},\n\n\tbootstrap(options) {\n\t\treturn shake({\n\t\t\tframework: \"bun-fullstack\" as const,\n\t\t\tbunFeatures: options.bunFeatures,\n\t\t});\n\t},\n\n\tgetSchemaFiles(validator, options, params) {\n\t\tif (options.layout === \"strict\") {\n\t\t\treturn planStrictSchemaFiles(validator, options, params);\n\t\t}\n\t\treturn planSimpleSchemaFile(validator, options, params);\n\t},\n\n\tgetTypeDefinitionFiles() {\n\t\treturn [];\n\t},\n};\n","import path from \"node:path\";\nimport { shake } from \"radashi\";\nimport type { CodegenFrameworkConfig } from \"./codegen-config\";\nimport {\n\tgetEnvDefaultsFromKeys,\n\tplanSimpleSchemaFile,\n\tplanStrictSchemaFiles,\n\tresolveSimpleImportPath,\n\tresolveStrictImportPath,\n} from \"./shared\";\nimport type { FrameworkStrategy } from \"./types\";\n\n/**\n * Create a Next.js or Nuxt framework strategy from shared codegen config.\n *\n * Collapses duplicated nextjs/nuxt strategy bodies: package name, client\n * prefix defaults, and Next-only `wrapNextjsConfig` bootstrap come from\n * {@link CodegenFrameworkConfig}.\n *\n * @param config Codegen framework configuration.\n * @returns Framework strategy for the registry.\n */\nexport function createCodegenFrameworkStrategy(\n\tconfig: CodegenFrameworkConfig,\n): FrameworkStrategy {\n\tconst { id, packageName, clientPrefix, supportsWrapNextjsConfig } = config;\n\tconst defaultApiUrlKey = `${clientPrefix}API_URL`;\n\n\treturn {\n\t\tclientPrefix,\n\n\t\tgetEnvDefaults(keys) {\n\t\t\tif (keys && keys.length > 0) {\n\t\t\t\treturn getEnvDefaultsFromKeys(keys);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tDATABASE_URL: \"postgres://localhost:5432/mydb\",\n\t\t\t\t[defaultApiUrlKey]: \"https://api.example.com\",\n\t\t\t\tNODE_ENV: \"development\",\n\t\t\t};\n\t\t},\n\n\t\tgetDependencies() {\n\t\t\treturn [packageName];\n\t\t},\n\n\t\trequiresArktypePeer() {\n\t\t\treturn true;\n\t\t},\n\n\t\tbootstrap(options) {\n\t\t\treturn shake({\n\t\t\t\tframework: id,\n\t\t\t\t...(supportsWrapNextjsConfig && {\n\t\t\t\t\twrapNextjsConfig: options.wrapNextjsConfig !== false,\n\t\t\t\t}),\n\t\t\t\tdisableCodegen: options.disableCodegen,\n\t\t\t});\n\t\t},\n\n\t\tgetSchemaFiles(validator, options, params) {\n\t\t\tif (options.layout === \"strict\") {\n\t\t\t\tconst ext = path.extname(params.targetPath);\n\t\t\t\tconst baseWithoutExt = params.targetPath.slice(0, -ext.length);\n\t\t\t\tconst importPath = resolveStrictImportPath(\n\t\t\t\t\tparams,\n\t\t\t\t\tbaseWithoutExt,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t\treturn planStrictSchemaFiles(validator, options, params, importPath);\n\t\t\t}\n\n\t\t\tconst importPath = resolveSimpleImportPath(params, options);\n\t\t\treturn planSimpleSchemaFile(validator, options, params, importPath);\n\t\t},\n\n\t\tgetTypeDefinitionFiles() {\n\t\t\treturn [];\n\t\t},\n\t};\n}\n","import { CODEGEN_FRAMEWORK_CONFIGS } from \"./codegen-config\";\nimport { createCodegenFrameworkStrategy } from \"./codegen-framework\";\n\nexport const nextjsStrategy = createCodegenFrameworkStrategy(\n\tCODEGEN_FRAMEWORK_CONFIGS.nextjs,\n);\n","import { CODEGEN_FRAMEWORK_CONFIGS } from \"./codegen-config\";\nimport { createCodegenFrameworkStrategy } from \"./codegen-framework\";\n\nexport const nuxtStrategy = createCodegenFrameworkStrategy(\n\tCODEGEN_FRAMEWORK_CONFIGS.nuxt,\n);\n","import { FRAMEWORK_CLIENT_PREFIXES } from \"./client-prefixes\";\nimport {\n\tgetEnvDefaultsFromKeys,\n\tplanSimpleSchemaFile,\n\tplanStrictSchemaFiles,\n} from \"./shared\";\nimport type { FrameworkStrategy } from \"./types\";\n\nexport const vanillaStrategy: FrameworkStrategy = {\n\tclientPrefix: FRAMEWORK_CLIENT_PREFIXES.vanilla,\n\n\tgetEnvDefaults(keys) {\n\t\tif (keys && keys.length > 0) {\n\t\t\treturn getEnvDefaultsFromKeys(keys);\n\t\t}\n\t\treturn {\n\t\t\tPORT: \"3000\",\n\t\t\tNODE_ENV: \"development\",\n\t\t};\n\t},\n\n\tgetDependencies() {\n\t\treturn [];\n\t},\n\n\trequiresArktypePeer() {\n\t\treturn false;\n\t},\n\n\tbootstrap() {\n\t\treturn undefined;\n\t},\n\n\tgetSchemaFiles(validator, options, params) {\n\t\tif (options.layout === \"strict\") {\n\t\t\treturn planStrictSchemaFiles(validator, options, params);\n\t\t}\n\t\treturn planSimpleSchemaFile(validator, options, params);\n\t},\n\n\tgetTypeDefinitionFiles() {\n\t\treturn [];\n\t},\n};\n","import { shake } from \"radashi\";\nimport { FRAMEWORK_CLIENT_PREFIXES } from \"./client-prefixes\";\nimport {\n\tgetEnvDefaultsFromKeys,\n\tplanSimpleSchemaFile,\n\tplanStrictSchemaFiles,\n} from \"./shared\";\nimport type { FrameworkStrategy } from \"./types\";\n\nexport const viteStrategy: FrameworkStrategy = {\n\tclientPrefix: FRAMEWORK_CLIENT_PREFIXES.vite,\n\n\tgetEnvDefaults(keys) {\n\t\tif (keys && keys.length > 0) {\n\t\t\treturn getEnvDefaultsFromKeys(keys);\n\t\t}\n\t\treturn {\n\t\t\tDATABASE_URL: \"postgres://localhost:5432/mydb\",\n\t\t\tVITE_API_URL: \"https://api.example.com\",\n\t\t\tNODE_ENV: \"development\",\n\t\t};\n\t},\n\n\tgetDependencies() {\n\t\treturn [\"@arkenv/vite-plugin\"];\n\t},\n\n\trequiresArktypePeer() {\n\t\treturn true;\n\t},\n\n\tbootstrap() {\n\t\treturn shake({ framework: \"vite\" as const });\n\t},\n\n\tgetSchemaFiles(validator, options, params) {\n\t\tif (options.layout === \"strict\") {\n\t\t\treturn planStrictSchemaFiles(validator, options, params);\n\t\t}\n\t\treturn planSimpleSchemaFile(validator, options, params);\n\t},\n\n\tgetTypeDefinitionFiles() {\n\t\treturn [];\n\t},\n};\n","import { bunFullstackStrategy } from \"./bun-fullstack\";\nimport { nextjsStrategy } from \"./nextjs\";\nimport { nuxtStrategy } from \"./nuxt\";\nimport type { FrameworkRegistry } from \"./types\";\nimport { vanillaStrategy } from \"./vanilla\";\nimport { viteStrategy } from \"./vite\";\n\n/**\n * Exhaustive registry of framework strategies.\n */\nexport const FRAMEWORKS = {\n\tvite: viteStrategy,\n\t\"bun-fullstack\": bunFullstackStrategy,\n\tnextjs: nextjsStrategy,\n\tnuxt: nuxtStrategy,\n\tvanilla: vanillaStrategy,\n} satisfies FrameworkRegistry;\n\nexport { FRAMEWORK_CLIENT_PREFIXES } from \"./client-prefixes\";\nexport type { CodegenFrameworkConfig } from \"./codegen-config\";\nexport {\n\tCODEGEN_FRAMEWORK_CONFIGS,\n\tgetCodegenConfig,\n\tisCodegenFramework,\n} from \"./codegen-config\";\nexport type { FrameworkStrategy } from \"./types\";\n","/**\n * Codegen IR for a single hosting-preset field.\n *\n * @remarks See `docs/adr/0018-cli-hosting-preset-field-metadata.md` (ADR 0018).\n * Do not grow this union without an explicit decision - prefer JSON Schema subset\n * or richer dialect rendering if more field kinds are needed.\n */\nexport type PresetField =\n\t| { readonly type: \"string\" }\n\t| { readonly type: \"enum\"; readonly values: readonly string[] };\n\n/**\n * Declarative metadata for a hosting-provider preset.\n */\nexport type PresetDefinition = {\n\treadonly label: string;\n\treadonly hint: string;\n\treadonly serverOnlyKeys: readonly string[];\n\treadonly clientExposedKeys: readonly string[];\n\treadonly fields: Readonly<Record<string, PresetField>>;\n};\n\n/**\n * Hosting preset registry. Adding a host is one place: entry + field metadata.\n */\nexport const PRESETS = {\n\tvercel: {\n\t\tlabel: \"Vercel\",\n\t\thint: \"Add VERCEL, VERCEL_ENV, VERCEL_URL, etc.\",\n\t\tserverOnlyKeys: [\"VERCEL\"],\n\t\tclientExposedKeys: [\"VERCEL_ENV\", \"VERCEL_URL\"],\n\t\tfields: {\n\t\t\tVERCEL: { type: \"string\" },\n\t\t\tVERCEL_ENV: {\n\t\t\t\ttype: \"enum\",\n\t\t\t\tvalues: [\"production\", \"preview\", \"development\"],\n\t\t\t},\n\t\t\tVERCEL_URL: { type: \"string\" },\n\t\t},\n\t},\n\tnetlify: {\n\t\tlabel: \"Netlify\",\n\t\thint: \"Add NETLIFY, CONTEXT, URL, DEPLOY_URL, etc.\",\n\t\tserverOnlyKeys: [\"NETLIFY\", \"DEPLOY_URL\"],\n\t\tclientExposedKeys: [\"CONTEXT\", \"URL\"],\n\t\tfields: {\n\t\t\tNETLIFY: { type: \"string\" },\n\t\t\tDEPLOY_URL: { type: \"string\" },\n\t\t\tCONTEXT: {\n\t\t\t\ttype: \"enum\",\n\t\t\t\tvalues: [\"production\", \"deploy-preview\", \"branch-deploy\"],\n\t\t\t},\n\t\t\tURL: { type: \"string\" },\n\t\t},\n\t},\n\tcloudflare: {\n\t\tlabel: \"Cloudflare Pages/Workers\",\n\t\thint: \"Add CF_PAGES, CF_PAGES_COMMIT_SHA, CF_PAGES_BRANCH, CF_PAGES_URL, etc.\",\n\t\tserverOnlyKeys: [\"CF_PAGES\", \"CF_PAGES_COMMIT_SHA\"],\n\t\tclientExposedKeys: [\"CF_PAGES_BRANCH\", \"CF_PAGES_URL\"],\n\t\tfields: {\n\t\t\tCF_PAGES: { type: \"string\" },\n\t\t\tCF_PAGES_COMMIT_SHA: { type: \"string\" },\n\t\t\tCF_PAGES_BRANCH: { type: \"string\" },\n\t\t\tCF_PAGES_URL: { type: \"string\" },\n\t\t},\n\t},\n\trailway: {\n\t\tlabel: \"Railway\",\n\t\thint: \"Add RAILWAY_ENVIRONMENT_NAME, RAILWAY_PUBLIC_DOMAIN, RAILWAY_GIT_COMMIT_SHA, etc.\",\n\t\tserverOnlyKeys: [\n\t\t\t\"RAILWAY_ENVIRONMENT_NAME\",\n\t\t\t\"RAILWAY_PUBLIC_DOMAIN\",\n\t\t\t\"RAILWAY_SERVICE_NAME\",\n\t\t\t\"RAILWAY_GIT_COMMIT_SHA\",\n\t\t],\n\t\tclientExposedKeys: [],\n\t\tfields: {\n\t\t\tRAILWAY_ENVIRONMENT_NAME: { type: \"string\" },\n\t\t\tRAILWAY_PUBLIC_DOMAIN: { type: \"string\" },\n\t\t\tRAILWAY_SERVICE_NAME: { type: \"string\" },\n\t\t\tRAILWAY_GIT_COMMIT_SHA: { type: \"string\" },\n\t\t},\n\t},\n\trender: {\n\t\tlabel: \"Render\",\n\t\thint: \"Add RENDER, RENDER_SERVICE_ID, RENDER_SERVICE_TYPE, RENDER_EXTERNAL_URL, etc.\",\n\t\tserverOnlyKeys: [\n\t\t\t\"RENDER\",\n\t\t\t\"RENDER_SERVICE_ID\",\n\t\t\t\"RENDER_SERVICE_TYPE\",\n\t\t\t\"RENDER_EXTERNAL_URL\",\n\t\t],\n\t\tclientExposedKeys: [],\n\t\tfields: {\n\t\t\tRENDER: { type: \"string\" },\n\t\t\tRENDER_SERVICE_ID: { type: \"string\" },\n\t\t\tRENDER_SERVICE_TYPE: { type: \"string\" },\n\t\t\tRENDER_EXTERNAL_URL: { type: \"string\" },\n\t\t},\n\t},\n\tfly: {\n\t\tlabel: \"Fly.io\",\n\t\thint: \"Add FLY_APP_NAME, FLY_REGION, FLY_ALLOC_ID, etc.\",\n\t\tserverOnlyKeys: [\"FLY_APP_NAME\", \"FLY_REGION\", \"FLY_ALLOC_ID\"],\n\t\tclientExposedKeys: [],\n\t\tfields: {\n\t\t\tFLY_APP_NAME: { type: \"string\" },\n\t\t\tFLY_REGION: { type: \"string\" },\n\t\t\tFLY_ALLOC_ID: { type: \"string\" },\n\t\t},\n\t},\n} as const satisfies Record<string, PresetDefinition>;\n\n/**\n * Hosting provider id (excludes the explicit opt-out `\"none\"`).\n *\n * Derived from {@link PRESETS} so adding a host stays a single registry edit.\n */\nexport type HostProvider = keyof typeof PRESETS;\n\n/**\n * Hosting preset id including the explicit opt-out (`\"none\"`).\n *\n * Derived from {@link PRESETS} so adding a host stays a single registry edit.\n */\nexport type HostPreset = \"none\" | HostProvider;\n\n/**\n * Type-guard for CLI / flag values against {@link HostPreset}.\n *\n * @param value Raw CLI string\n * @returns Whether `value` is a known host preset id\n */\nexport function isHostPreset(value: string): value is HostPreset {\n\t// Own-key check compatible with es2020 (no Object.hasOwn) and noPrototypeBuiltins.\n\treturn value === \"none\" || Object.keys(PRESETS).includes(value);\n}\n\n/**\n * Type-guard for preset provider values against {@link HostProvider}.\n *\n * @param value Raw CLI string\n * @returns Whether `value` is a known hosting provider id\n */\nexport function isHostProvider(value: string): value is HostProvider {\n\t// Own-key check compatible with es2020 (no Object.hasOwn) and noPrototypeBuiltins.\n\treturn Object.keys(PRESETS).includes(value);\n}\n\n/**\n * Collect environment keys for a hosting preset, including client-prefixed copies.\n *\n * @param preset Selected hosting preset (`\"none\"` yields an empty list)\n * @param clientPrefix Framework client prefix from the active strategy (e.g. `NEXT_PUBLIC_`)\n * @returns Deduplicated key list for schema and `.env` planning\n */\nexport function getPresetKeys(\n\tpreset: HostPreset,\n\tclientPrefix: string,\n): string[] {\n\tif (preset === \"none\") return [];\n\tconst def = PRESETS[preset];\n\tconst keys: string[] = [...def.serverOnlyKeys, ...def.clientExposedKeys];\n\tif (clientPrefix) {\n\t\tfor (const key of def.clientExposedKeys) {\n\t\t\tkeys.push(`${clientPrefix}${key}`);\n\t\t}\n\t}\n\treturn keys;\n}\n\n/**\n * Partitions hosting preset keys into client-facing (prefixed) vs server-only keys for strict layouts.\n *\n * @param preset Selected hosting preset (`\"none\"` yields empty lists)\n * @param clientPrefix Framework client prefix (e.g. `NEXT_PUBLIC_`); empty skips client keys\n * @returns Client-prefixed keys for `client.ts` and unprefixed keys for `server.ts`\n */\nexport function partitionPresetKeys(\n\tpreset: HostPreset,\n\tclientPrefix: string,\n): { clientKeys: string[]; serverKeys: string[] } {\n\tif (preset === \"none\") {\n\t\treturn { clientKeys: [], serverKeys: [] };\n\t}\n\tconst def = PRESETS[preset];\n\n\tconst serverKeys: string[] = [\n\t\t...def.serverOnlyKeys,\n\t\t...def.clientExposedKeys,\n\t];\n\tconst clientKeys: string[] = [];\n\n\tif (clientPrefix) {\n\t\tfor (const key of def.clientExposedKeys) {\n\t\t\tclientKeys.push(`${clientPrefix}${key}`);\n\t\t}\n\t}\n\n\treturn { clientKeys, serverKeys };\n}\n\n/**\n * Look up preset field metadata for a schema key, stripping the client prefix when present.\n *\n * Scoped to the active {@link hostPreset} so unrelated presets cannot influence\n * how user-provided env keys are rendered.\n *\n * @param key Environment variable name (possibly prefixed)\n * @param clientPrefix Framework client prefix used to recover the base key\n * @param hostPreset Active hosting preset; `\"none\"` / omitted yields no match\n * @returns Matching {@link PresetField}, or `undefined` when not a preset field\n */\nexport function lookupPresetField(\n\tkey: string,\n\tclientPrefix: string,\n\thostPreset?: HostPreset,\n): PresetField | undefined {\n\tif (!hostPreset || hostPreset === \"none\") {\n\t\treturn undefined;\n\t}\n\n\tconst baseKey =\n\t\tclientPrefix && key.startsWith(clientPrefix)\n\t\t\t? key.slice(clientPrefix.length)\n\t\t\t: key;\n\n\tconst fields = PRESETS[hostPreset].fields as Readonly<\n\t\tRecord<string, PresetField>\n\t>;\n\treturn baseKey in fields ? fields[baseKey] : undefined;\n}\n\n/**\n * Merge detected env keys with hosting-preset keys without dropping either set.\n *\n * @param envKeys Keys already chosen (e.g. from `.env.example`); may be undefined\n * @param hostPreset Selected hosting preset\n * @param clientPrefix Framework client prefix from the active strategy\n * @returns Combined unique keys, or `undefined` when both sources are empty\n */\nexport function mergeEnvKeysWithPreset(\n\tenvKeys: string[] | undefined,\n\thostPreset: HostPreset | undefined,\n\tclientPrefix: string,\n): string[] | undefined {\n\tconst presetKeys = getPresetKeys(hostPreset ?? \"none\", clientPrefix);\n\tif (!envKeys?.length && presetKeys.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn Array.from(new Set([...(envKeys ?? []), ...presetKeys]));\n}\n\n/**\n * Marker tags used to delimit machine-managed hosting preset blocks in schema files.\n */\nexport const PRESET_START_TAG = \"@arkenv-preset-start\";\nexport const PRESET_END_TAG = \"@arkenv-preset-end\";\n\n/**\n * Formats a start marker comment for a preset block.\n */\nexport function formatPresetStartMarker(markerId: string): string {\n\treturn `// ${PRESET_START_TAG} ${markerId}`;\n}\n\n/**\n * Formats an end marker comment for a preset block.\n */\nexport function formatPresetEndMarker(markerId: string): string {\n\treturn `// ${PRESET_END_TAG} ${markerId}`;\n}\n\n/**\n * Parses the marker ID string into base ID and optional role.\n */\nexport function parseMarkerId(markerId: string): {\n\tbaseId: string;\n\trole?: string;\n} {\n\tconst colonIndex = markerId.indexOf(\":\");\n\tif (colonIndex === -1) {\n\t\treturn { baseId: markerId };\n\t}\n\treturn {\n\t\tbaseId: markerId.slice(0, colonIndex),\n\t\trole: markerId.slice(colonIndex + 1),\n\t};\n}\n","import {\n\ttype HostPreset,\n\tlookupPresetField,\n\ttype PresetField,\n} from \"@/features/scaffold/presets\";\n\n/**\n * Dialect-owned field lines and wrappers for schema template generation.\n *\n * Dialects supply field formatting and import/wrapper differences.\n * Layout assemblers own framework structure (Vite/Bun comments, Next/Nuxt\n * flat/nested, vanilla arkenv calls).\n */\nexport type Dialect = {\n\t/**\n\t * Extra import for codegen layouts, e.g. `import { z } from \"zod\";`.\n\t */\n\textraImport?: string;\n\n\t/**\n\t * Format a schema field for strict (3-file) layouts.\n\t *\n\t * @param key Environment variable name\n\t * @param role Field scope within the strict layout\n\t * @param clientPrefix Framework client prefix for preset field lookup\n\t * @param hostPreset Active hosting preset for scoped field metadata lookup\n\t * @returns Field line without leading indentation (trailing comma)\n\t */\n\tformatStrictField(\n\t\tkey: string,\n\t\trole: \"client\" | \"server\" | \"shared\",\n\t\tclientPrefix?: string,\n\t\thostPreset?: HostPreset,\n\t): string;\n\n\t/**\n\t * Format a field for codegen flat/nested layouts (single-file Next/Nuxt).\n\t *\n\t * Unlike {@link formatStrictField}, PORT and similar keys stay as optional\n\t * strings - only `shared` (NODE_ENV) uses a richer type.\n\t *\n\t * @param key Environment variable name\n\t * @param role Field scope within the codegen layout\n\t * @param clientPrefix Framework client prefix for preset field lookup\n\t * @param hostPreset Active hosting preset for scoped field metadata lookup\n\t * @returns Field line without leading indentation (trailing comma)\n\t */\n\tformatCodegenField(\n\t\tkey: string,\n\t\trole: \"client\" | \"server\" | \"shared\",\n\t\tclientPrefix?: string,\n\t\thostPreset?: HostPreset,\n\t): string;\n\n\t/**\n\t * Default field lines for Env-only / vanilla simple schemas when no keys\n\t * are provided. Includes leading `\\t\\t` indentation.\n\t */\n\tdefaultSimpleSchemaFields: string;\n\n\t/**\n\t * Format simple-schema field lines from explicit keys (leading `\\t\\t`).\n\t *\n\t * @param keys Environment variable keys\n\t * @param clientPrefix Framework client prefix for preset field lookup\n\t * @param hostPreset Active hosting preset for scoped field metadata lookup\n\t * @returns Joined field lines\n\t */\n\tformatSimpleSchemaFields(\n\t\tkeys: string[],\n\t\tclientPrefix?: string,\n\t\thostPreset?: HostPreset,\n\t): string;\n\n\t/**\n\t * Render an optional string field value (no key, no trailing comma).\n\t *\n\t * Used when compiling {@link PresetField} `string` kinds.\n\t *\n\t * @returns Validator-specific optional string schema fragment\n\t */\n\tformatOptionalString(): string;\n\n\t/**\n\t * Render an optional enum field value (no key, no trailing comma).\n\t *\n\t * Used when compiling {@link PresetField} `enum` kinds.\n\t *\n\t * @param values Allowed enum members\n\t * @returns Validator-specific optional enum schema fragment\n\t */\n\tformatOptionalEnum(values: readonly string[]): string;\n\n\t/**\n\t * Default strict-layout fields when no env keys are provided.\n\t *\n\t * @param clientPrefix Framework client prefix (`NEXT_PUBLIC_` / `NUXT_PUBLIC_`)\n\t */\n\tgetDefaultStrictFields(clientPrefix: string): {\n\t\tserverFields: string[];\n\t\tclientFields: string[];\n\t\tsharedFields: string[];\n\t\truntimeEnvFields: string[];\n\t};\n\n\t/**\n\t * Default codegen-layout field lines (with `\\t\\t` indent) when no keys.\n\t *\n\t * @param clientPrefix Framework client prefix\n\t */\n\tgetDefaultCodegenFields(clientPrefix: string): {\n\t\tserverFields: string[];\n\t\tclientFields: string[];\n\t\tsharedFields: string[];\n\t};\n\n\t/**\n\t * Import block for the strict shared schema file.\n\t */\n\tsharedImports: string;\n\n\t/**\n\t * Wrap a formatted object literal as the SharedSchema value.\n\t *\n\t * @param schemaObject Object literal from {@link formatSchemaObject}\n\t */\n\twrapSharedSchema(schemaObject: string): string;\n\n\t/**\n\t * Extra imports for strict client/server files (after the arkenv import).\n\t * Empty for arktype; zod/valibot add their package import.\n\t */\n\tstrictExtraImports: string;\n\n\t/**\n\t * Assemble a vanilla (runtime arkenv) single-file template body.\n\t *\n\t * @param schemaFields Field lines with `\\t\\t` indentation\n\t * @returns Full file content without trailing newline\n\t */\n\tassembleVanilla(schemaFields: string): string;\n};\n\n/**\n * Compile a {@link PresetField} into a dialect-specific schema value fragment.\n *\n * @param dialect Dialect providing optional string/enum renderers\n * @param field Preset field metadata\n * @returns Schema value without key or trailing comma\n */\nexport function formatPresetFieldValue(\n\tdialect: Pick<Dialect, \"formatOptionalString\" | \"formatOptionalEnum\">,\n\tfield: PresetField,\n): string {\n\tif (field.type === \"string\") {\n\t\treturn dialect.formatOptionalString();\n\t}\n\treturn dialect.formatOptionalEnum(field.values);\n}\n\n/**\n * Resolve a key to a preset-backed schema value when metadata exists.\n *\n * @param dialect Dialect providing optional string/enum renderers\n * @param key Environment variable name\n * @param clientPrefix Framework client prefix\n * @param hostPreset Active hosting preset for scoped field metadata lookup\n * @returns Schema value fragment, or `undefined` when the key is not a preset field\n */\nexport function tryFormatPresetFieldValue(\n\tdialect: Pick<Dialect, \"formatOptionalString\" | \"formatOptionalEnum\">,\n\tkey: string,\n\tclientPrefix: string,\n\thostPreset?: HostPreset,\n): string | undefined {\n\tconst field = lookupPresetField(key, clientPrefix, hostPreset);\n\tif (!field) return undefined;\n\treturn formatPresetFieldValue(dialect, field);\n}\n\nexport type { HostPreset };\n","import dedent from \"dedent\";\nimport type { Dialect } from \"./types\";\nimport { tryFormatPresetFieldValue } from \"./types\";\n\nexport const arktypeDialect: Dialect = {\n\tformatOptionalString() {\n\t\treturn `\"string?\"`;\n\t},\n\n\tformatOptionalEnum(values) {\n\t\treturn `\"'${values.join(\"' | '\")}'?\"`;\n\t},\n\n\tformatStrictField(key, role, clientPrefix = \"\", hostPreset = undefined) {\n\t\tif (role === \"shared\") {\n\t\t\treturn `${key}: \"'development' | 'production' | 'test' = 'development'\",`;\n\t\t}\n\t\tif (role === \"server\" && key === \"PORT\") {\n\t\t\treturn `PORT: \"number.port = 3000\",`;\n\t\t}\n\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\tarktypeDialect,\n\t\t\tkey,\n\t\t\tclientPrefix,\n\t\t\thostPreset,\n\t\t);\n\t\tif (preset) return `${key}: ${preset},`;\n\t\treturn `${key}: \"string?\",`;\n\t},\n\n\tformatCodegenField(key, role, clientPrefix = \"\", hostPreset = undefined) {\n\t\tif (role === \"shared\") {\n\t\t\treturn `${key}: \"'development' | 'production' | 'test' = 'development'\",`;\n\t\t}\n\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\tarktypeDialect,\n\t\t\tkey,\n\t\t\tclientPrefix,\n\t\t\thostPreset,\n\t\t);\n\t\tif (preset) return `${key}: ${preset},`;\n\t\treturn `${key}: \"string?\",`;\n\t},\n\n\tdefaultSimpleSchemaFields: `\\t\\tNODE_ENV: \"'development' | 'production' | 'test' = 'development'\",\n\t\tPORT: \"number.port = 3000\",`,\n\n\tformatSimpleSchemaFields(keys, clientPrefix = \"\", hostPreset = undefined) {\n\t\treturn keys\n\t\t\t.map((key) => {\n\t\t\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\t\t\tarktypeDialect,\n\t\t\t\t\tkey,\n\t\t\t\t\tclientPrefix,\n\t\t\t\t\thostPreset,\n\t\t\t\t);\n\t\t\t\treturn `\\t\\t${key}: ${preset ?? `\"string?\"`},`;\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\t},\n\n\tgetDefaultStrictFields(clientPrefix) {\n\t\tconst defaultClientKey = `${clientPrefix}API_URL`;\n\t\treturn {\n\t\t\tserverFields: [\n\t\t\t\t`DATABASE_URL: \"string = 'postgres://localhost:5432/mydb'\",`,\n\t\t\t],\n\t\t\tclientFields: [\n\t\t\t\t`${defaultClientKey}: \"string = 'https://api.example.com'\",`,\n\t\t\t],\n\t\t\tsharedFields: [\n\t\t\t\t`NODE_ENV: \"'development' | 'production' | 'test' = 'development'\",`,\n\t\t\t],\n\t\t\truntimeEnvFields: [\n\t\t\t\t`${defaultClientKey}: process.env.${defaultClientKey},`,\n\t\t\t\t\"NODE_ENV: process.env.NODE_ENV,\",\n\t\t\t],\n\t\t};\n\t},\n\n\tgetDefaultCodegenFields(clientPrefix) {\n\t\treturn {\n\t\t\tserverFields: [\n\t\t\t\t`\\t\\tDATABASE_URL: \"string = 'postgres://localhost:5432/mydb'\",`,\n\t\t\t],\n\t\t\tclientFields: [\n\t\t\t\t`\\t\\t${clientPrefix}API_URL: \"string = 'https://api.example.com'\",`,\n\t\t\t],\n\t\t\tsharedFields: [\n\t\t\t\t`\\t\\tNODE_ENV: \"'development' | 'production' | 'test' = 'development'\",`,\n\t\t\t],\n\t\t};\n\t},\n\n\tsharedImports: `import { type } from \"@arkenv/core\";`,\n\n\twrapSharedSchema(schemaObject) {\n\t\treturn `type(${schemaObject})`;\n\t},\n\n\tstrictExtraImports: \"\",\n\n\tassembleVanilla(schemaFields) {\n\t\treturn dedent /* ts */`\n\timport arkenv, { type } from \"@arkenv/core\";\n\n\t/**\n\t * Environment variable schema for server-side or runtime-only validation.\n\t */\n\texport const env = arkenv({\n${schemaFields}\n\t});\n`;\n\t},\n};\n","import dedent from \"dedent\";\nimport type { Dialect } from \"./types\";\nimport { tryFormatPresetFieldValue } from \"./types\";\n\nexport const valibotDialect: Dialect = {\n\textraImport: `import * as v from \"valibot\";`,\n\n\tformatOptionalString() {\n\t\treturn \"v.optional(v.string())\";\n\t},\n\n\tformatOptionalEnum(values) {\n\t\treturn `v.optional(v.picklist([${values.map((v) => `\"${v}\"`).join(\", \")}]))`;\n\t},\n\n\tformatStrictField(key, role, clientPrefix = \"\", hostPreset = undefined) {\n\t\tif (role === \"shared\") {\n\t\t\treturn `${key}: v.optional(v.picklist([\"development\", \"production\", \"test\"]), \"development\"),`;\n\t\t}\n\t\tif (role === \"server\" && key === \"PORT\") {\n\t\t\treturn \"PORT: v.optional(v.pipe(v.string(), v.transform(Number), v.number(), v.integer(), v.minValue(1), v.maxValue(65535)), 3000),\";\n\t\t}\n\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\tvalibotDialect,\n\t\t\tkey,\n\t\t\tclientPrefix,\n\t\t\thostPreset,\n\t\t);\n\t\tif (preset) return `${key}: ${preset},`;\n\t\treturn `${key}: v.optional(v.string()),`;\n\t},\n\n\tformatCodegenField(key, role, clientPrefix = \"\", hostPreset = undefined) {\n\t\tif (role === \"shared\") {\n\t\t\treturn `${key}: v.optional(v.picklist([\"development\", \"production\", \"test\"]), \"development\"),`;\n\t\t}\n\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\tvalibotDialect,\n\t\t\tkey,\n\t\t\tclientPrefix,\n\t\t\thostPreset,\n\t\t);\n\t\tif (preset) return `${key}: ${preset},`;\n\t\treturn `${key}: v.optional(v.string()),`;\n\t},\n\n\tdefaultSimpleSchemaFields: `\\t\\tNODE_ENV: v.optional(v.picklist([\"development\", \"production\", \"test\"]), \"development\"),\n\t\tPORT: v.optional(v.pipe(v.string(), v.transform(Number), v.number(), v.integer(), v.minValue(1), v.maxValue(65535)), 3000),`,\n\n\tformatSimpleSchemaFields(keys, clientPrefix = \"\", hostPreset = undefined) {\n\t\treturn keys\n\t\t\t.map((key) => {\n\t\t\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\t\t\tvalibotDialect,\n\t\t\t\t\tkey,\n\t\t\t\t\tclientPrefix,\n\t\t\t\t\thostPreset,\n\t\t\t\t);\n\t\t\t\treturn `\\t\\t${key}: ${preset ?? \"v.optional(v.string())\"},`;\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\t},\n\n\tgetDefaultStrictFields(clientPrefix) {\n\t\tconst defaultClientKey = `${clientPrefix}API_URL`;\n\t\treturn {\n\t\t\tserverFields: [\n\t\t\t\t`DATABASE_URL: v.optional(v.pipe(v.string(), v.url()), \"postgres://localhost:5432/mydb\"),`,\n\t\t\t],\n\t\t\tclientFields: [\n\t\t\t\t`${defaultClientKey}: v.optional(v.pipe(v.string(), v.url()), \"https://api.example.com\"),`,\n\t\t\t],\n\t\t\tsharedFields: [\n\t\t\t\t`NODE_ENV: v.optional(v.picklist([\"development\", \"production\", \"test\"]), \"development\"),`,\n\t\t\t],\n\t\t\truntimeEnvFields: [\n\t\t\t\t`${defaultClientKey}: process.env.${defaultClientKey},`,\n\t\t\t\t\"NODE_ENV: process.env.NODE_ENV,\",\n\t\t\t],\n\t\t};\n\t},\n\n\tgetDefaultCodegenFields(clientPrefix) {\n\t\treturn {\n\t\t\tserverFields: [\n\t\t\t\t`\\t\\tDATABASE_URL: v.optional(v.pipe(v.string(), v.url()), \"postgres://localhost:5432/mydb\"),`,\n\t\t\t],\n\t\t\tclientFields: [\n\t\t\t\t`\\t\\t${clientPrefix}API_URL: v.optional(v.pipe(v.string(), v.url()), \"https://api.example.com\"),`,\n\t\t\t],\n\t\t\tsharedFields: [\n\t\t\t\t`\\t\\tNODE_ENV: v.optional(v.picklist([\"development\", \"production\", \"test\"]), \"development\"),`,\n\t\t\t],\n\t\t};\n\t},\n\n\tsharedImports: `import * as v from \"valibot\";`,\n\n\twrapSharedSchema(schemaObject) {\n\t\treturn `v.object(${schemaObject})`;\n\t},\n\n\tstrictExtraImports: `import * as v from \"valibot\";\\n`,\n\n\tassembleVanilla(schemaFields) {\n\t\treturn dedent /* ts */`\n\timport arkenv from \"@arkenv/standard\";\n\timport * as v from \"valibot\";\n\n\t/**\n\t * Environment variable schema for server-side or runtime-only validation.\n\t */\n\texport const env = arkenv({\n\t${schemaFields}\n\t});\n`;\n\t},\n};\n","import dedent from \"dedent\";\nimport type { Dialect } from \"./types\";\nimport { tryFormatPresetFieldValue } from \"./types\";\n\nexport const zodDialect: Dialect = {\n\textraImport: `import { z } from \"zod\";`,\n\n\tformatOptionalString() {\n\t\treturn \"z.string().optional()\";\n\t},\n\n\tformatOptionalEnum(values) {\n\t\treturn `z.enum([${values.map((v) => `\"${v}\"`).join(\", \")}]).optional()`;\n\t},\n\n\tformatStrictField(key, role, clientPrefix = \"\", hostPreset = undefined) {\n\t\tif (role === \"shared\") {\n\t\t\treturn `${key}: z.enum([\"development\", \"production\", \"test\"]).default(\"development\"),`;\n\t\t}\n\t\tif (role === \"server\" && key === \"PORT\") {\n\t\t\treturn \"PORT: z.coerce.number().int().min(1).max(65535).default(3000),\";\n\t\t}\n\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\tzodDialect,\n\t\t\tkey,\n\t\t\tclientPrefix,\n\t\t\thostPreset,\n\t\t);\n\t\tif (preset) return `${key}: ${preset},`;\n\t\treturn `${key}: z.string().optional(),`;\n\t},\n\n\tformatCodegenField(key, role, clientPrefix = \"\", hostPreset = undefined) {\n\t\tif (role === \"shared\") {\n\t\t\treturn `${key}: z.enum([\"development\", \"production\", \"test\"]).default(\"development\"),`;\n\t\t}\n\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\tzodDialect,\n\t\t\tkey,\n\t\t\tclientPrefix,\n\t\t\thostPreset,\n\t\t);\n\t\tif (preset) return `${key}: ${preset},`;\n\t\treturn `${key}: z.string().optional(),`;\n\t},\n\n\tdefaultSimpleSchemaFields: `\\t\\tNODE_ENV: z.enum([\"development\", \"production\", \"test\"]).default(\"development\"),\n\t\tPORT: z.coerce.number().int().min(1).max(65535).default(3000),`,\n\n\tformatSimpleSchemaFields(keys, clientPrefix = \"\", hostPreset = undefined) {\n\t\treturn keys\n\t\t\t.map((key) => {\n\t\t\t\tconst preset = tryFormatPresetFieldValue(\n\t\t\t\t\tzodDialect,\n\t\t\t\t\tkey,\n\t\t\t\t\tclientPrefix,\n\t\t\t\t\thostPreset,\n\t\t\t\t);\n\t\t\t\treturn `\\t\\t${key}: ${preset ?? \"z.string().optional()\"},`;\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\t},\n\n\tgetDefaultStrictFields(clientPrefix) {\n\t\tconst defaultClientKey = `${clientPrefix}API_URL`;\n\t\treturn {\n\t\t\tserverFields: [\n\t\t\t\t`DATABASE_URL: z.string().url().default(\"postgres://localhost:5432/mydb\"),`,\n\t\t\t],\n\t\t\tclientFields: [\n\t\t\t\t`${defaultClientKey}: z.string().url().default(\"https://api.example.com\"),`,\n\t\t\t],\n\t\t\tsharedFields: [\n\t\t\t\t`NODE_ENV: z.enum([\"development\", \"production\", \"test\"]).default(\"development\"),`,\n\t\t\t],\n\t\t\truntimeEnvFields: [\n\t\t\t\t`${defaultClientKey}: process.env.${defaultClientKey},`,\n\t\t\t\t\"NODE_ENV: process.env.NODE_ENV,\",\n\t\t\t],\n\t\t};\n\t},\n\n\tgetDefaultCodegenFields(clientPrefix) {\n\t\treturn {\n\t\t\tserverFields: [\n\t\t\t\t`\\t\\tDATABASE_URL: z.string().url().default(\"postgres://localhost:5432/mydb\"),`,\n\t\t\t],\n\t\t\tclientFields: [\n\t\t\t\t`\\t\\t${clientPrefix}API_URL: z.string().url().default(\"https://api.example.com\"),`,\n\t\t\t],\n\t\t\tsharedFields: [\n\t\t\t\t`\\t\\tNODE_ENV: z.enum([\"development\", \"production\", \"test\"]).default(\"development\"),`,\n\t\t\t],\n\t\t};\n\t},\n\n\tsharedImports: `import { z } from \"zod\";`,\n\n\twrapSharedSchema(schemaObject) {\n\t\treturn `z.object(${schemaObject})`;\n\t},\n\n\tstrictExtraImports: `import { z } from \"zod\";\\n`,\n\n\tassembleVanilla(schemaFields) {\n\t\treturn dedent /* ts */`\n\timport arkenv from \"@arkenv/standard\";\n\timport { z } from \"zod\";\n\n\t/**\n\t * Environment variable schema for server-side or runtime-only validation.\n\t */\n\texport const env = arkenv({\n\t${schemaFields}\n\t});\n`;\n\t},\n};\n","import type { Validator } from \"@/features/scaffold/plan\";\nimport { arktypeDialect } from \"./arktype\";\nimport type { Dialect } from \"./types\";\nimport { valibotDialect } from \"./valibot\";\nimport { zodDialect } from \"./zod\";\n\n/**\n * Exhaustive registry of validator dialects.\n */\nexport const DIALECTS = {\n\tarktype: arktypeDialect,\n\tzod: zodDialect,\n\tvalibot: valibotDialect,\n} as const satisfies Record<Validator, Dialect>;\n\nexport type { Dialect } from \"./types\";\nexport {\n\tformatPresetFieldValue,\n\ttryFormatPresetFieldValue,\n} from \"./types\";\n","import {\n\tbuilders,\n\tdetectCodeFormat,\n\tgenerateCode,\n\tparseModule,\n} from \"magicast\";\nimport { FRAMEWORK_CLIENT_PREFIXES } from \"@/features/scaffold/frameworks\";\nimport type { Framework, Validator } from \"@/features/scaffold/plan\";\nimport { getPresetKeys, type HostPreset } from \"@/features/scaffold/presets\";\nimport {\n\tDIALECTS,\n\ttryFormatPresetFieldValue,\n} from \"@/features/scaffold/validators/dialects\";\nimport type { BootstrapResult } from \"@/shared/ports\";\n\n/**\n * Input for transforming a configuration file.\n */\nexport type MutationInput = {\n\tcode: string;\n\tenvImportPath?: string;\n\tdisableCodegen?: boolean | undefined;\n};\n\n/**\n * Normalizes named import spacing in generated code.\n * magicast produces `import {Foo}`; this ensures `import { Foo }`.\n */\nfunction normalizeImportSpacing(code: string): string {\n\treturn code.replace(\n\t\t/import\\s*\\{([^\\n}]*)\\}\\s*from/g,\n\t\t(_match, p1) => `import { ${p1.trim()} } from`,\n\t);\n}\n\n/**\n * Preserves the trailing newline of the original file if present.\n * magicast strips trailing newlines; this restores them.\n */\nfunction preserveTrailingNewline(code: string, originalCode: string): string {\n\treturn originalCode.endsWith(\"\\n\") && !code.endsWith(\"\\n\")\n\t\t? `${code}\\n`\n\t\t: code;\n}\n\n/**\n * Transforms a Vite configuration file by injecting the ArkEnv Vite plugin.\n *\n * @param input The configuration code and optional import path.\n * @returns The result of the bootstrap operation, potentially including the updated code.\n */\nexport function transformViteConfig(\n\tinput: MutationInput,\n): BootstrapResult & { code?: string } {\n\ttry {\n\t\tconst mod = parseModule(input.code);\n\t\tconst initialCode = input.code;\n\n\t\t// 1. Find the plugins array\n\t\tlet config = mod.exports.default;\n\n\t\t// Handle defineConfig({...}) wrapper\n\t\tif (\n\t\t\tconfig &&\n\t\t\ttypeof config === \"object\" &&\n\t\t\t\"$type\" in config &&\n\t\t\tconfig.$type === \"function-call\"\n\t\t) {\n\t\t\tconst call = config as { $callee?: string; $args?: any[] };\n\t\t\tconst callee = call.$callee || JSON.stringify(config);\n\t\t\tif (callee === \"defineConfig\" && call.$args) {\n\t\t\t\tconst arg = call.$args[0];\n\t\t\t\t// Guard against defineConfig((env) => ({...})) callback form\n\t\t\t\tif (\n\t\t\t\t\targ &&\n\t\t\t\t\ttypeof arg === \"object\" &&\n\t\t\t\t\t\"$type\" in arg &&\n\t\t\t\t\t(arg.$type === \"arrow-function-expression\" ||\n\t\t\t\t\t\targ.$type === \"function-expression\")\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tupdated: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\"The 'defineConfig' callback form is currently not supported for automatic mutation. Please add the plugin manually.\",\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconfig = arg;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t!config ||\n\t\t\ttypeof config !== \"object\" ||\n\t\t\t(typeof config === \"object\" && \"$type\" in config)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tupdated: false,\n\t\t\t\terror: \"Could not find default export object in Vite config\",\n\t\t\t};\n\t\t}\n\n\t\tif (!config.plugins) {\n\t\t\tconfig.plugins = [];\n\t\t}\n\n\t\tif (Array.isArray(config.plugins)) {\n\t\t\t// Check if already exists using a word-boundary regex to avoid false positives\n\t\t\tconst hasPlugin = /\\barkenv(?:Vite)?Plugin\\b/.test(initialCode);\n\n\t\t\tif (!hasPlugin) {\n\t\t\t\t// Add imports\n\t\t\t\tmod.imports.$add({\n\t\t\t\t\tfrom: \"@arkenv/vite-plugin\",\n\t\t\t\t\tlocal: \"arkenvVitePlugin\",\n\t\t\t\t\timported: \"default\",\n\t\t\t\t});\n\n\t\t\t\tconfig.plugins.push(\"__ARK_PLUGIN_PLACEHOLDER__\");\n\t\t\t} else {\n\t\t\t\t// Already has plugin, nothing to do\n\t\t\t\treturn { success: true, updated: false };\n\t\t\t}\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tupdated: false,\n\t\t\t\terror: \"The 'plugins' property in your Vite config is not an array.\",\n\t\t\t};\n\t\t}\n\n\t\tlet code = generateCode(mod, {\n\t\t\tformat: detectCodeFormat(initialCode),\n\t\t}).code;\n\t\tconst pluginCall = \"arkenvVitePlugin()\";\n\t\tcode = code.replace(/['\"]__ARK_PLUGIN_PLACEHOLDER__['\"]/g, pluginCall);\n\t\tcode = normalizeImportSpacing(code);\n\t\tcode = preserveTrailingNewline(code, initialCode);\n\n\t\treturn { success: true, updated: true, code };\n\t} catch (e: unknown) {\n\t\tconst error = e instanceof Error ? e.message : String(e);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tupdated: false,\n\t\t\terror: `Failed to parse Vite config: ${error}`,\n\t\t};\n\t}\n}\n\n/**\n * Transform a Next.js configuration file by wrapping the default export with `withArkEnv`.\n *\n * @param input The configuration code and optional import path\n * @returns The result of the bootstrap operation, potentially including the updated code\n */\nexport function transformNextjsConfig(\n\tinput: MutationInput,\n): BootstrapResult & { code?: string } {\n\ttry {\n\t\tconst initialCode = input.code;\n\n\t\t// Check for CommonJS - can't auto-mutate\n\t\tif (/module\\.exports\\b/.test(initialCode)) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tupdated: false,\n\t\t\t\terror:\n\t\t\t\t\t\"CommonJS is not supported for automatic mutation. Please wrap your config with `withArkEnv` manually.\",\n\t\t\t};\n\t\t}\n\n\t\tconst mod = parseModule(initialCode);\n\n\t\t// Verify there's a default export\n\t\tif (!mod.exports.default) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tupdated: false,\n\t\t\t\terror: \"Could not find default export in Next.js config\",\n\t\t\t};\n\t\t}\n\n\t\t// Check if already wrapped with withArkEnv using the AST\n\t\tif (\n\t\t\ttypeof mod.exports.default === \"object\" &&\n\t\t\t\"$type\" in (mod.exports.default as object) &&\n\t\t\t(mod.exports.default as { $type?: string }).$type === \"function-call\" &&\n\t\t\t(mod.exports.default as { $callee?: string }).$callee === \"withArkEnv\"\n\t\t) {\n\t\t\treturn { success: true, updated: false };\n\t\t}\n\n\t\t// Also check via regex for cases where withArkEnv is used inline\n\t\tif (/\\bwithArkEnv\\b/.test(initialCode)) {\n\t\t\treturn { success: true, updated: false };\n\t\t}\n\n\t\t// Add import\n\t\tmod.imports.$add({\n\t\t\tfrom: \"@arkenv/nextjs/config\",\n\t\t\timported: \"withArkEnv\",\n\t\t});\n\n\t\t// Wrap the default export with withArkEnv(...) using the AST\n\t\tif (input.disableCodegen) {\n\t\t\tmod.exports.default = builders.functionCall(\n\t\t\t\t\"withArkEnv\",\n\t\t\t\tmod.exports.default,\n\t\t\t\t{ codegen: false },\n\t\t\t);\n\t\t} else {\n\t\t\tmod.exports.default = builders.functionCall(\n\t\t\t\t\"withArkEnv\",\n\t\t\t\tmod.exports.default,\n\t\t\t);\n\t\t}\n\n\t\tlet code = generateCode(mod, {\n\t\t\tformat: detectCodeFormat(initialCode),\n\t\t}).code;\n\t\tcode = normalizeImportSpacing(code);\n\t\tcode = preserveTrailingNewline(code, initialCode);\n\n\t\treturn { success: true, updated: true, code };\n\t} catch (e: unknown) {\n\t\tconst error = e instanceof Error ? e.message : String(e);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tupdated: false,\n\t\t\terror: `Failed to parse Next.js config: ${error}`,\n\t\t};\n\t}\n}\n\n/**\n * Transform a Nuxt configuration file by adding `@arkenv/nuxt/module` to its modules.\n *\n * @param input The configuration code and optional import path\n * @returns The result of the bootstrap operation, potentially including the updated code\n */\nexport function transformNuxtConfig(\n\tinput: MutationInput,\n): BootstrapResult & { code?: string } {\n\ttry {\n\t\tconst initialCode = input.code;\n\t\tconst mod = parseModule(initialCode);\n\n\t\tlet config = mod.exports.default;\n\n\t\t// Handle defineNuxtConfig({...}) wrapper\n\t\tif (\n\t\t\tconfig &&\n\t\t\ttypeof config === \"object\" &&\n\t\t\t\"$type\" in config &&\n\t\t\tconfig.$type === \"function-call\"\n\t\t) {\n\t\t\tconst call = config as { $callee?: string; $args?: any[] };\n\t\t\tconst callee = call.$callee || JSON.stringify(config);\n\t\t\tif (callee === \"defineNuxtConfig\" && call.$args) {\n\t\t\t\tconfig = call.$args[0];\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t!config ||\n\t\t\ttypeof config !== \"object\" ||\n\t\t\t(typeof config === \"object\" && \"$type\" in config)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tupdated: false,\n\t\t\t\terror: \"Could not find default export object in Nuxt config\",\n\t\t\t};\n\t\t}\n\n\t\tif (!config.modules) {\n\t\t\tconfig.modules = [];\n\t\t}\n\n\t\tif (Array.isArray(config.modules)) {\n\t\t\tconst hasModule = config.modules.includes(\"@arkenv/nuxt/module\");\n\n\t\t\tif (!hasModule) {\n\t\t\t\tconfig.modules.push(\"@arkenv/nuxt/module\");\n\t\t\t} else {\n\t\t\t\treturn { success: true, updated: false };\n\t\t\t}\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tupdated: false,\n\t\t\t\terror: \"The 'modules' property in your Nuxt config is not an array.\",\n\t\t\t};\n\t\t}\n\n\t\tlet code = generateCode(mod, {\n\t\t\tformat: detectCodeFormat(initialCode),\n\t\t}).code;\n\t\tcode = normalizeImportSpacing(code);\n\t\tcode = preserveTrailingNewline(code, initialCode);\n\n\t\treturn { success: true, updated: true, code };\n\t} catch (e: unknown) {\n\t\tconst error = e instanceof Error ? e.message : String(e);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tupdated: false,\n\t\t\terror: `Failed to parse Nuxt config: ${error}`,\n\t\t};\n\t}\n}\n\n/**\n * Resolve a hosting-preset key to a validator-specific schema fragment.\n *\n * Uses v1 dialect renderers (same as scaffold codegen) so add-host and\n * mutateEnvConfig output stay aligned with `arkenv init` field syntax.\n */\nexport function getFieldDefinition(\n\tkey: string,\n\tvalidator: Validator,\n\tprefix: string,\n\tpreset: HostPreset,\n): string {\n\tconst dialect = DIALECTS[validator];\n\treturn (\n\t\ttryFormatPresetFieldValue(dialect, key, prefix, preset) ??\n\t\tdialect.formatOptionalString()\n\t);\n}\n\n/**\n * Represents a parsed managed preset comment block.\n */\nexport type PresetBlock = {\n\tmarkerId: string;\n\tbaseId: string;\n\trole?: string;\n\tstartLineIndex: number;\n\tendLineIndex: number;\n\trawContent: string;\n\tinnerContent: string;\n\tkeys: string[];\n};\n\n/**\n * Validates and finds all managed preset comment blocks in the given source code.\n * Fails closed on any malformed or unbalanced start/end markers.\n *\n * @param code The source code to inspect.\n * @returns Result object with blocks on success or error message on failure.\n */\nexport function validateAndFindPresetBlocks(\n\tcode: string,\n):\n\t| { success: true; blocks: PresetBlock[] }\n\t| { success: false; error: string } {\n\tconst lines = code.split(/\\r?\\n/);\n\tconst blocks: PresetBlock[] = [];\n\tlet activeStart: {\n\t\tmarkerId: string;\n\t\tstartLineIndex: number;\n\t} | null = null;\n\n\tconst anyStartRegex = /^\\s*\\/\\/\\s*@arkenv-preset-start(?:\\s+(.*))?$/;\n\tconst anyEndRegex = /^\\s*\\/\\/\\s*@arkenv-preset-end(?:\\s+(.*))?$/;\n\tconst validIdRegex = /^[a-zA-Z0-9_:-]+$/;\n\tconst inlineKeyRegex =\n\t\t/(?:^|[,{\\s])([A-Za-z_][A-Za-z0-9_]*|'[^']+'|\"[^\"]+\")\\s*:/g;\n\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i];\n\t\tconst startMatch = line.match(anyStartRegex);\n\t\tif (startMatch) {\n\t\t\tconst rawMarkerId = startMatch[1]?.trim();\n\t\t\tif (!rawMarkerId || !validIdRegex.test(rawMarkerId)) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Malformed preset markers: missing or invalid preset id in \"@arkenv-preset-start\" at line ${i + 1}.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (activeStart) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Malformed preset markers: nested or unclosed \"@arkenv-preset-start ${activeStart.markerId}\" before line ${i + 1}.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tactiveStart = {\n\t\t\t\tmarkerId: rawMarkerId,\n\t\t\t\tstartLineIndex: i,\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst endMatch = line.match(anyEndRegex);\n\t\tif (endMatch) {\n\t\t\tconst endMarkerId = endMatch[1]?.trim();\n\t\t\tif (!endMarkerId || !validIdRegex.test(endMarkerId)) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Malformed preset markers: missing or invalid preset id in \"@arkenv-preset-end\" at line ${i + 1}.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (!activeStart) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Malformed preset markers: unexpected \"@arkenv-preset-end ${endMarkerId}\" without matching start marker at line ${i + 1}.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (activeStart.markerId !== endMarkerId) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Malformed preset markers: mismatched start \"${activeStart.markerId}\" (line ${activeStart.startLineIndex + 1}) and end \"${endMarkerId}\" (line ${i + 1}).`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst blockLines = lines.slice(activeStart.startLineIndex, i + 1);\n\t\t\tconst innerLines = lines.slice(activeStart.startLineIndex + 1, i);\n\t\t\tconst keys: string[] = [];\n\n\t\t\tfor (const innerLine of innerLines) {\n\t\t\t\tfor (const match of innerLine.matchAll(inlineKeyRegex)) {\n\t\t\t\t\tconst rawKey = match[1];\n\t\t\t\t\tconst cleanKey =\n\t\t\t\t\t\trawKey.startsWith(\"'\") || rawKey.startsWith('\"')\n\t\t\t\t\t\t\t? rawKey.slice(1, -1)\n\t\t\t\t\t\t\t: rawKey;\n\t\t\t\t\tkeys.push(cleanKey);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst parsedId = parseMarkerId(activeStart.markerId);\n\t\t\tblocks.push({\n\t\t\t\tmarkerId: activeStart.markerId,\n\t\t\t\tbaseId: parsedId.baseId,\n\t\t\t\t...(parsedId.role !== undefined ? { role: parsedId.role } : {}),\n\t\t\t\tstartLineIndex: activeStart.startLineIndex,\n\t\t\t\tendLineIndex: i,\n\t\t\t\trawContent: blockLines.join(\"\\n\"),\n\t\t\t\tinnerContent: innerLines.join(\"\\n\"),\n\t\t\t\tkeys,\n\t\t\t});\n\n\t\t\tactiveStart = null;\n\t\t}\n\t}\n\n\tif (activeStart) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: `Malformed preset markers: unclosed \"@arkenv-preset-start ${activeStart.markerId}\" starting at line ${activeStart.startLineIndex + 1}.`,\n\t\t};\n\t}\n\n\treturn { success: true, blocks };\n}\n\n/**\n * Parses the marker ID string into base ID and optional role.\n */\nfunction parseMarkerId(markerId: string): { baseId: string; role?: string } {\n\tconst colonIndex = markerId.indexOf(\":\");\n\tif (colonIndex === -1) {\n\t\treturn { baseId: markerId };\n\t}\n\treturn {\n\t\tbaseId: markerId.slice(0, colonIndex),\n\t\trole: markerId.slice(colonIndex + 1),\n\t};\n}\n\n/**\n * Options for applying a preset to a schema source string.\n */\nexport type ApplyPresetOptions = {\n\tpreset: HostPreset;\n\tframework: Framework;\n\tvalidator: Validator;\n\ttargetKeys?: string[];\n\tmarkerId?: string;\n};\n\n/**\n * Scans for the matching closing brace '}' starting from a given '{' position,\n * correctly ignoring braces inside single-quoted strings, double-quoted strings,\n * template literals, single-line comments, and multi-line comments.\n */\nfunction scanMatchingBrace(\n\tlines: string[],\n\tstartLine: number,\n\tstartChar: number,\n): { endLine: number; endChar: number } | null {\n\tlet depth = 0;\n\tlet inSingleQuote = false;\n\tlet inDoubleQuote = false;\n\tlet inTemplate = false;\n\tconst templateStack: number[] = [];\n\tlet inBlockComment = false;\n\n\tfor (let i = startLine; i < lines.length; i++) {\n\t\tconst line = lines[i];\n\t\tconst startCol = i === startLine ? startChar : 0;\n\t\tlet inLineComment = false;\n\n\t\tfor (let c = startCol; c < line.length; c++) {\n\t\t\tconst ch = line[c];\n\t\t\tconst nextCh = c + 1 < line.length ? line[c + 1] : \"\";\n\t\t\tconst prevCh = c > 0 ? line[c - 1] : \"\";\n\n\t\t\tif (inLineComment) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (inBlockComment) {\n\t\t\t\tif (ch === \"*\" && nextCh === \"/\") {\n\t\t\t\t\tinBlockComment = false;\n\t\t\t\t\tc++;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (inSingleQuote) {\n\t\t\t\tif (ch === \"'\" && prevCh !== \"\\\\\") {\n\t\t\t\t\tinSingleQuote = false;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (inDoubleQuote) {\n\t\t\t\tif (ch === '\"' && prevCh !== \"\\\\\") {\n\t\t\t\t\tinDoubleQuote = false;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (inTemplate) {\n\t\t\t\tif (ch === \"`\" && prevCh !== \"\\\\\") {\n\t\t\t\t\tinTemplate = false;\n\t\t\t\t} else if (ch === \"$\" && nextCh === \"{\" && prevCh !== \"\\\\\") {\n\t\t\t\t\ttemplateStack.push(depth);\n\t\t\t\t\tinTemplate = false;\n\t\t\t\t\tdepth++;\n\t\t\t\t\tc++;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Not inside any string or comment:\n\t\t\tif (ch === \"/\" && nextCh === \"/\") {\n\t\t\t\tinLineComment = true;\n\t\t\t\tc++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ch === \"/\" && nextCh === \"*\") {\n\t\t\t\tinBlockComment = true;\n\t\t\t\tc++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ch === \"'\") {\n\t\t\t\tinSingleQuote = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ch === '\"') {\n\t\t\t\tinDoubleQuote = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ch === \"`\") {\n\t\t\t\tinTemplate = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ch === \"{\") {\n\t\t\t\tdepth++;\n\t\t\t} else if (ch === \"}\") {\n\t\t\t\tdepth--;\n\t\t\t\tif (depth === 0) {\n\t\t\t\t\treturn { endLine: i, endChar: c };\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\ttemplateStack.length > 0 &&\n\t\t\t\t\tdepth === templateStack[templateStack.length - 1]\n\t\t\t\t) {\n\t\t\t\t\ttemplateStack.pop();\n\t\t\t\t\tinTemplate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Locates the opening brace '{' of the schema object literal, correctly handling\n * multiline calls where '{' is placed on subsequent lines (e.g. arkenv(\\n { ... })).\n */\nfunction findSchemaOpeningBrace(\n\tlines: string[],\n): { line: number; char: number } | null {\n\tconst schemaCallRegex = /\\b(?:arkenv|type|z\\.object|v\\.object)\\s*\\(/;\n\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst match = lines[i].match(schemaCallRegex);\n\t\tif (match && match.index !== undefined) {\n\t\t\tlet inSingleQuote = false;\n\t\t\tlet inDoubleQuote = false;\n\t\t\tlet inTemplate = false;\n\t\t\tlet inBlockComment = false;\n\n\t\t\tfor (let lineIdx = i; lineIdx < lines.length; lineIdx++) {\n\t\t\t\tconst line = lines[lineIdx];\n\t\t\t\tconst colStart = lineIdx === i ? match.index + match[0].length : 0;\n\t\t\t\tlet inLineComment = false;\n\n\t\t\t\tfor (let c = colStart; c < line.length; c++) {\n\t\t\t\t\tconst ch = line[c];\n\t\t\t\t\tconst nextCh = c + 1 < line.length ? line[c + 1] : \"\";\n\t\t\t\t\tconst prevCh = c > 0 ? line[c - 1] : \"\";\n\n\t\t\t\t\tif (inLineComment) break;\n\n\t\t\t\t\tif (inBlockComment) {\n\t\t\t\t\t\tif (ch === \"*\" && nextCh === \"/\") {\n\t\t\t\t\t\t\tinBlockComment = false;\n\t\t\t\t\t\t\tc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (inSingleQuote) {\n\t\t\t\t\t\tif (ch === \"'\" && prevCh !== \"\\\\\") inSingleQuote = false;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (inDoubleQuote) {\n\t\t\t\t\t\tif (ch === '\"' && prevCh !== \"\\\\\") inDoubleQuote = false;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (inTemplate) {\n\t\t\t\t\t\tif (ch === \"`\" && prevCh !== \"\\\\\") inTemplate = false;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"/\" && nextCh === \"/\") {\n\t\t\t\t\t\tinLineComment = true;\n\t\t\t\t\t\tc++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"/\" && nextCh === \"*\") {\n\t\t\t\t\t\tinBlockComment = true;\n\t\t\t\t\t\tc++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"'\") {\n\t\t\t\t\t\tinSingleQuote = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === '\"') {\n\t\t\t\t\t\tinDoubleQuote = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"`\") {\n\t\t\t\t\t\tinTemplate = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"{\") {\n\t\t\t\t\t\treturn { line: lineIdx, char: c };\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \";\" && lineIdx > i) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Fallback: search after `export const ... =`\n\tconst exportConstRegex = /\\bexport\\s+const\\s+[\\w$]+\\s*=\\s*/;\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst match = lines[i].match(exportConstRegex);\n\t\tif (match && match.index !== undefined) {\n\t\t\tlet inSingleQuote = false;\n\t\t\tlet inDoubleQuote = false;\n\t\t\tlet inTemplate = false;\n\t\t\tlet inBlockComment = false;\n\n\t\t\tfor (let lineIdx = i; lineIdx < lines.length; lineIdx++) {\n\t\t\t\tconst line = lines[lineIdx];\n\t\t\t\tconst colStart = lineIdx === i ? match.index + match[0].length : 0;\n\t\t\t\tlet inLineComment = false;\n\n\t\t\t\tfor (let c = colStart; c < line.length; c++) {\n\t\t\t\t\tconst ch = line[c];\n\t\t\t\t\tconst nextCh = c + 1 < line.length ? line[c + 1] : \"\";\n\t\t\t\t\tconst prevCh = c > 0 ? line[c - 1] : \"\";\n\n\t\t\t\t\tif (inLineComment) break;\n\n\t\t\t\t\tif (inBlockComment) {\n\t\t\t\t\t\tif (ch === \"*\" && nextCh === \"/\") {\n\t\t\t\t\t\t\tinBlockComment = false;\n\t\t\t\t\t\t\tc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (inSingleQuote) {\n\t\t\t\t\t\tif (ch === \"'\" && prevCh !== \"\\\\\") inSingleQuote = false;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (inDoubleQuote) {\n\t\t\t\t\t\tif (ch === '\"' && prevCh !== \"\\\\\") inDoubleQuote = false;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (inTemplate) {\n\t\t\t\t\t\tif (ch === \"`\" && prevCh !== \"\\\\\") inTemplate = false;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"/\" && nextCh === \"/\") {\n\t\t\t\t\t\tinLineComment = true;\n\t\t\t\t\t\tc++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"/\" && nextCh === \"*\") {\n\t\t\t\t\t\tinBlockComment = true;\n\t\t\t\t\t\tc++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"'\") {\n\t\t\t\t\t\tinSingleQuote = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === '\"') {\n\t\t\t\t\t\tinDoubleQuote = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"`\") {\n\t\t\t\t\t\tinTemplate = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \"{\") {\n\t\t\t\t\t\treturn { line: lineIdx, char: c };\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ch === \";\" && lineIdx > i) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Finds the schema object literal boundaries in source code.\n */\nfunction findSchemaObjectRange(lines: string[]): {\n\tstartLineIndex: number;\n\tendLineIndex: number;\n\tstartCharIndex: number;\n\tendCharIndex: number;\n\tisSingleLine: boolean;\n\tindent: string;\n} | null {\n\tconst opening = findSchemaOpeningBrace(lines);\n\tif (!opening) return null;\n\n\tconst match = scanMatchingBrace(lines, opening.line, opening.char);\n\tif (!match) return null;\n\n\tconst startLineIndex = opening.line;\n\tconst endLineIndex = match.endLine;\n\tconst startCharIndex = opening.char;\n\tconst endCharIndex = match.endChar;\n\tconst isSingleLine = startLineIndex === endLineIndex;\n\n\t// Determine indent from lines inside the object, or default to standard indent\n\tlet indent = \"\\t\";\n\tif (!isSingleLine) {\n\t\tfor (let i = startLineIndex + 1; i < endLineIndex; i++) {\n\t\t\tconst m = lines[i].match(/^(\\s+)\\S/);\n\t\t\tif (m) {\n\t\t\t\tindent = m[1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (indent === \"\\t\" && lines[startLineIndex].match(/^\\s+/)) {\n\t\t\tconst baseIndent = lines[startLineIndex].match(/^(\\s+)/)?.[1] || \"\";\n\t\t\tindent = baseIndent.includes(\" \")\n\t\t\t\t? `${baseIndent} `\n\t\t\t\t: `${baseIndent}\\t`;\n\t\t}\n\t} else {\n\t\tconst baseIndent = lines[startLineIndex].match(/^(\\s*)/)?.[1] || \"\";\n\t\tindent = baseIndent.includes(\" \") ? `${baseIndent} ` : `${baseIndent}\\t`;\n\t\tif (!indent.trim().length && !baseIndent) {\n\t\t\tindent = \"\\t\";\n\t\t}\n\t}\n\n\treturn {\n\t\tstartLineIndex,\n\t\tendLineIndex,\n\t\tstartCharIndex,\n\t\tendCharIndex,\n\t\tisSingleLine,\n\t\tindent,\n\t};\n}\n\n/**\n * Applies a preset to an env schema file by inserting or refreshing managed comment blocks.\n * Fails closed on any key collisions with user-owned/unmarked keys or other presets,\n * or on malformed markers.\n *\n * @param code The environment configuration code.\n * @param options Preset options.\n * @returns The mutation result.\n */\nexport function applyPresetToSchema(\n\tcode: string,\n\toptions: ApplyPresetOptions,\n): {\n\tsuccess: boolean;\n\tupdated: boolean;\n\tcode?: string;\n\terror?: string;\n\tproposedFields: Record<string, string>;\n} {\n\tconst { preset, framework, validator, targetKeys } = options;\n\tconst prefix = FRAMEWORK_CLIENT_PREFIXES[framework] || \"\";\n\tconst keysToMutate = targetKeys ?? getPresetKeys(preset, prefix);\n\tconst proposedFields: Record<string, string> = {};\n\n\tfor (const key of keysToMutate) {\n\t\tproposedFields[key] = getFieldDefinition(key, validator, prefix, preset);\n\t}\n\n\t// 1. Validate markers in the file\n\tconst validation = validateAndFindPresetBlocks(code);\n\tif (!validation.success) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tupdated: false,\n\t\t\terror: validation.error,\n\t\t\tproposedFields,\n\t\t};\n\t}\n\n\tconst blocks = validation.blocks;\n\tconst lines = code.split(/\\r?\\n/);\n\tconst schemaRange = findSchemaObjectRange(lines);\n\n\tif (!schemaRange) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tupdated: false,\n\t\t\terror: \"Could not find schema object literal in schema file.\",\n\t\t\tproposedFields,\n\t\t};\n\t}\n\n\tconst markerId = options.markerId || preset;\n\n\t// 2. Extract keys outside managed blocks and in other presets\n\tconst unmarkedKeys = new Set<string>();\n\tconst otherPresetKeys = new Map<string, string>(); // key -> otherPresetId\n\tconst inlineKeyRegex =\n\t\t/(?:^|[,{\\s])([A-Za-z_][A-Za-z0-9_]*|'[^']+'|\"[^\"]+\")\\s*:/g;\n\n\tif (schemaRange.isSingleLine) {\n\t\tconst line = lines[schemaRange.startLineIndex];\n\t\tconst inside = line.slice(\n\t\t\tschemaRange.startCharIndex + 1,\n\t\t\tschemaRange.endCharIndex,\n\t\t);\n\t\t// Parse any inline keys inside { ... }\n\t\tfor (const match of inside.matchAll(inlineKeyRegex)) {\n\t\t\tconst rawKey = match[1];\n\t\t\tconst cleanKey =\n\t\t\t\trawKey.startsWith(\"'\") || rawKey.startsWith('\"')\n\t\t\t\t\t? rawKey.slice(1, -1)\n\t\t\t\t\t: rawKey;\n\t\t\tunmarkedKeys.add(cleanKey);\n\t\t}\n\t} else {\n\t\tfor (\n\t\t\tlet i = schemaRange.startLineIndex;\n\t\t\ti <= schemaRange.endLineIndex;\n\t\t\ti++\n\t\t) {\n\t\t\tconst containingBlock = blocks.find(\n\t\t\t\t(b) => i >= b.startLineIndex && i <= b.endLineIndex,\n\t\t\t);\n\n\t\t\tlet textToScan = lines[i];\n\t\t\tif (i === schemaRange.startLineIndex) {\n\t\t\t\ttextToScan = textToScan.slice(schemaRange.startCharIndex + 1);\n\t\t\t} else if (i === schemaRange.endLineIndex) {\n\t\t\t\ttextToScan = textToScan.slice(0, schemaRange.endCharIndex);\n\t\t\t}\n\n\t\t\tif (!textToScan.trim()) continue;\n\n\t\t\tif (!containingBlock) {\n\t\t\t\tfor (const match of textToScan.matchAll(inlineKeyRegex)) {\n\t\t\t\t\tconst rawKey = match[1];\n\t\t\t\t\tconst cleanKey =\n\t\t\t\t\t\trawKey.startsWith(\"'\") || rawKey.startsWith('\"')\n\t\t\t\t\t\t\t? rawKey.slice(1, -1)\n\t\t\t\t\t\t\t: rawKey;\n\t\t\t\t\tunmarkedKeys.add(cleanKey);\n\t\t\t\t}\n\t\t\t} else if (containingBlock.baseId !== preset) {\n\t\t\t\tfor (const match of textToScan.matchAll(inlineKeyRegex)) {\n\t\t\t\t\tconst rawKey = match[1];\n\t\t\t\t\tconst cleanKey =\n\t\t\t\t\t\trawKey.startsWith(\"'\") || rawKey.startsWith('\"')\n\t\t\t\t\t\t\t? rawKey.slice(1, -1)\n\t\t\t\t\t\t\t: rawKey;\n\t\t\t\t\totherPresetKeys.set(cleanKey, containingBlock.baseId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// 3. Collision Checks (Fail Closed)\n\tfor (const key of keysToMutate) {\n\t\tif (unmarkedKeys.has(key)) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tupdated: false,\n\t\t\t\terror: `Collision detected: Key \"${key}\" already exists outside managed preset blocks (user-owned or legacy unmarked). Remove or migrate it before applying preset \"${preset}\".`,\n\t\t\t\tproposedFields,\n\t\t\t};\n\t\t}\n\t\tif (otherPresetKeys.has(key)) {\n\t\t\tconst conflictingPreset = otherPresetKeys.get(key);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tupdated: false,\n\t\t\t\terror: `Collision detected: Key \"${key}\" conflicts with existing managed preset \"${conflictingPreset}\".`,\n\t\t\t\tproposedFields,\n\t\t\t};\n\t\t}\n\t}\n\n\tconst indent = schemaRange.indent;\n\tconst blockLines: string[] = [\n\t\t`${indent}// @arkenv-preset-start ${markerId}`,\n\t\t...keysToMutate.map((key) => `${indent}${key}: ${proposedFields[key]},`),\n\t\t`${indent}// @arkenv-preset-end ${markerId}`,\n\t];\n\n\t// 4. Refresh existing block or Insert new block\n\tconst existingBlock = blocks.find((b) => b.markerId === markerId);\n\n\tif (existingBlock) {\n\t\t// Check if identical\n\t\tconst currentRaw = lines\n\t\t\t.slice(existingBlock.startLineIndex, existingBlock.endLineIndex + 1)\n\t\t\t.join(\"\\n\");\n\t\tconst newRaw = blockLines.join(\"\\n\");\n\n\t\tif (currentRaw === newRaw) {\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tupdated: false,\n\t\t\t\tcode,\n\t\t\t\tproposedFields,\n\t\t\t};\n\t\t}\n\n\t\t// Nuke-and-pave\n\t\tlines.splice(\n\t\t\texistingBlock.startLineIndex,\n\t\t\texistingBlock.endLineIndex - existingBlock.startLineIndex + 1,\n\t\t\t...blockLines,\n\t\t);\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tupdated: true,\n\t\t\tcode: lines.join(\"\\n\"),\n\t\t\tproposedFields,\n\t\t};\n\t}\n\n\t// Insert into schema object\n\tif (schemaRange.isSingleLine) {\n\t\tconst line = lines[schemaRange.startLineIndex];\n\t\tconst beforeBrace = line.slice(0, schemaRange.startCharIndex + 1);\n\t\tconst insideContent = line\n\t\t\t.slice(schemaRange.startCharIndex + 1, schemaRange.endCharIndex)\n\t\t\t.trim();\n\t\tconst afterBrace = line.slice(schemaRange.endCharIndex);\n\t\tconst baseIndent = line.match(/^(\\s*)/)?.[1] || \"\";\n\n\t\tif (insideContent) {\n\t\t\tconst commentIdx = findTrailingCommentIndex(insideContent);\n\t\t\tlet formattedInside = insideContent;\n\t\t\tif (commentIdx !== -1) {\n\t\t\t\tconst codePart = insideContent.slice(0, commentIdx);\n\t\t\t\tconst commentPart = insideContent.slice(commentIdx);\n\t\t\t\tif (codePart.trim() && !codePart.trimEnd().endsWith(\",\")) {\n\t\t\t\t\tconst trimmedCode = codePart.trimEnd();\n\t\t\t\t\tconst trailingWs = codePart.slice(trimmedCode.length);\n\t\t\t\t\tformattedInside = `${trimmedCode},${trailingWs}${commentPart}`;\n\t\t\t\t}\n\t\t\t} else if (!insideContent.endsWith(\",\")) {\n\t\t\t\tformattedInside = `${insideContent},`;\n\t\t\t}\n\t\t\tlines.splice(\n\t\t\t\tschemaRange.startLineIndex,\n\t\t\t\t1,\n\t\t\t\tbeforeBrace,\n\t\t\t\t`${indent}${formattedInside}`,\n\t\t\t\t...blockLines,\n\t\t\t\t`${baseIndent}${afterBrace.trimStart()}`,\n\t\t\t);\n\t\t} else {\n\t\t\tlines.splice(\n\t\t\t\tschemaRange.startLineIndex,\n\t\t\t\t1,\n\t\t\t\tbeforeBrace,\n\t\t\t\t...blockLines,\n\t\t\t\t`${baseIndent}${afterBrace.trimStart()}`,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tupdated: true,\n\t\t\tcode: lines.join(\"\\n\"),\n\t\t\tproposedFields,\n\t\t};\n\t}\n\n\t// Multi-line: Insert before the closing brace\n\t// Ensure the line before has a trailing comma if it's a field\n\taddTrailingCommaToLastField(\n\t\tlines,\n\t\tschemaRange.startLineIndex,\n\t\tschemaRange.endLineIndex,\n\t\tschemaRange.startCharIndex,\n\t);\n\n\tlines.splice(schemaRange.endLineIndex, 0, ...blockLines);\n\n\treturn {\n\t\tsuccess: true,\n\t\tupdated: true,\n\t\tcode: lines.join(\"\\n\"),\n\t\tproposedFields,\n\t};\n}\n\n/**\n * Scans a line and returns the starting index of a trailing `//` or `/*` comment,\n * correctly ignoring slashes inside string literals or template literals.\n * Returns -1 if no trailing comment is present.\n */\nfunction findTrailingCommentIndex(line: string): number {\n\tlet inSingle = false;\n\tlet inDouble = false;\n\tlet inBacktick = false;\n\tlet isEscaped = false;\n\n\tfor (let i = 0; i < line.length; i++) {\n\t\tconst char = line[i];\n\n\t\tif (isEscaped) {\n\t\t\tisEscaped = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"\\\\\") {\n\t\t\tisEscaped = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"'\" && !inDouble && !inBacktick) {\n\t\t\tinSingle = !inSingle;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\"' && !inSingle && !inBacktick) {\n\t\t\tinDouble = !inDouble;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"`\" && !inSingle && !inDouble) {\n\t\t\tinBacktick = !inBacktick;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!inSingle && !inDouble && !inBacktick) {\n\t\t\tif (char === \"/\" && i + 1 < line.length) {\n\t\t\t\tif (line[i + 1] === \"/\" || line[i + 1] === \"*\") {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn -1;\n}\n\n/**\n * Ensures the last field preceding the closing brace has a trailing comma,\n * inserting the comma before any trailing comment rather than inside it.\n */\nfunction addTrailingCommaToLastField(\n\tlines: string[],\n\tstartLineIndex: number,\n\tendLineIndex: number,\n\tstartCharIndex: number,\n): void {\n\tfor (let i = endLineIndex - 1; i >= startLineIndex; i--) {\n\t\tconst rawLine = lines[i];\n\t\tlet lineText = rawLine;\n\t\tif (i === startLineIndex) {\n\t\t\tlineText = lineText.slice(startCharIndex + 1);\n\t\t}\n\n\t\tconst trimmed = lineText.trim();\n\t\tif (!trimmed) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Skip pure comment lines\n\t\tif (\n\t\t\ttrimmed.startsWith(\"//\") ||\n\t\t\ttrimmed.startsWith(\"/*\") ||\n\t\t\ttrimmed.startsWith(\"*\")\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst commentIdx = findTrailingCommentIndex(rawLine);\n\t\tconst codePart = commentIdx !== -1 ? rawLine.slice(0, commentIdx) : rawLine;\n\t\tconst commentPart = commentIdx !== -1 ? rawLine.slice(commentIdx) : \"\";\n\n\t\tif (codePart.trim().length > 0) {\n\t\t\tif (!codePart.trimEnd().endsWith(\",\")) {\n\t\t\t\tconst trimmedCode = codePart.trimEnd();\n\t\t\t\tconst trailingWs = codePart.slice(trimmedCode.length);\n\t\t\t\tlines[i] = `${trimmedCode},${trailingWs}${commentPart}`;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/**\n * Options for removing a preset from a schema file.\n */\nexport type RemovePresetOptions = {\n\tpreset: HostPreset;\n};\n\n/**\n * Removes all managed blocks belonging to a base preset ID from an env schema file.\n * Fails closed on malformed markers.\n *\n * @param code The schema file code.\n * @param options Removal options.\n * @returns The mutation result.\n */\nexport function removePresetFromSchema(\n\tcode: string,\n\toptions: RemovePresetOptions,\n): {\n\tsuccess: boolean;\n\tupdated: boolean;\n\tcode?: string;\n\terror?: string;\n\tremovedKeys?: string[];\n} {\n\tconst { preset } = options;\n\n\t// 1. Validate markers\n\tconst validation = validateAndFindPresetBlocks(code);\n\tif (!validation.success) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tupdated: false,\n\t\t\terror: validation.error,\n\t\t};\n\t}\n\n\tconst matchingBlocks = validation.blocks.filter((b) => b.baseId === preset);\n\tif (matchingBlocks.length === 0) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tupdated: false,\n\t\t\tcode,\n\t\t\tremovedKeys: [],\n\t\t};\n\t}\n\n\tconst removedKeys = matchingBlocks.flatMap((b) => b.keys);\n\tconst lines = code.split(/\\r?\\n/);\n\n\t// Remove blocks in reverse order of line indices\n\tconst sortedBlocks = [...matchingBlocks].sort(\n\t\t(a, b) => b.startLineIndex - a.startLineIndex,\n\t);\n\n\tfor (const block of sortedBlocks) {\n\t\tlines.splice(\n\t\t\tblock.startLineIndex,\n\t\t\tblock.endLineIndex - block.startLineIndex + 1,\n\t\t);\n\t}\n\n\treturn {\n\t\tsuccess: true,\n\t\tupdated: true,\n\t\tcode: lines.join(\"\\n\"),\n\t\tremovedKeys,\n\t};\n}\n\n/**\n * Transform an env.ts schema file by merging host preset keys.\n * Kept for backwards-compatibility; delegates to managed preset blocks.\n *\n * @param code The environment configuration code.\n * @param preset The selected hosting provider preset.\n * @param framework The active framework.\n * @param validator The active validator.\n * @param targetKeys Optional specific keys to mutate (defaults to all preset keys).\n * @returns The result of the mutation operation.\n */\nexport function mutateEnvConfig(\n\tcode: string,\n\tpreset: HostPreset,\n\tframework: Framework,\n\tvalidator: Validator,\n\ttargetKeys?: string[],\n): {\n\tsuccess: boolean;\n\tupdated: boolean;\n\tcode?: string;\n\terror?: string;\n\tproposedFields?: Record<string, string>;\n} {\n\treturn applyPresetToSchema(code, {\n\t\tpreset,\n\t\tframework,\n\t\tvalidator,\n\t\t...(targetKeys !== undefined ? { targetKeys } : {}),\n\t});\n}\n","import fsp from \"node:fs/promises\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport pc from \"picocolors\";\nimport { code } from \"@/cli/ui/visuals\";\nimport {\n\ttransformNextjsConfig,\n\ttransformNuxtConfig,\n\ttransformViteConfig,\n} from \"@/features/config-mutation\";\nimport type { BootstrapResult } from \"@/shared/ports\";\n\nexport async function findViteConfig(\n\tcwd = process.cwd(),\n): Promise<string | null> {\n\tconst filenames = [\n\t\t\"vite.config.ts\",\n\t\t\"vite.config.js\",\n\t\t\"vite.config.mts\",\n\t\t\"vite.config.mjs\",\n\t];\n\tfor (const file of filenames) {\n\t\tconst fullPath = path.resolve(cwd, file);\n\t\ttry {\n\t\t\tawait fsp.access(fullPath);\n\t\t\treturn fullPath;\n\t\t} catch {\n\t\t\t// ignore missing file\n\t\t}\n\t}\n\treturn null;\n}\n\nexport async function findBunConfig(\n\tcwd = process.cwd(),\n): Promise<string | null> {\n\tconst filenames = [\"bunfig.toml\", \"bun.setup.ts\", \"bun.setup.js\"];\n\tfor (const file of filenames) {\n\t\tconst fullPath = path.resolve(cwd, file);\n\t\ttry {\n\t\t\tawait fsp.access(fullPath);\n\t\t\treturn fullPath;\n\t\t} catch {\n\t\t\t// ignore missing file\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Search for a Next.js configuration file in the given directory.\n *\n * @param cwd The directory to search in (defaults to `process.cwd()`)\n * @returns The full path to the found config file, or `null` if none exists\n */\nexport async function findNextjsConfig(\n\tcwd = process.cwd(),\n): Promise<string | null> {\n\tconst filenames = [\n\t\t\"next.config.ts\",\n\t\t\"next.config.js\",\n\t\t\"next.config.mts\",\n\t\t\"next.config.mjs\",\n\t];\n\tfor (const file of filenames) {\n\t\tconst fullPath = path.resolve(cwd, file);\n\t\ttry {\n\t\t\tawait fsp.access(fullPath);\n\t\t\treturn fullPath;\n\t\t} catch {\n\t\t\t// ignore missing file\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Bootstrap a Next.js config file by wrapping its default export with `withArkEnv`.\n *\n * @param workspace An object providing `readFile` and `writeFile` for the target file\n * @param filePath The path to the Next.js config file\n * @returns The result of the bootstrap operation\n */\nexport async function bootstrapNextjsConfig(\n\tworkspace: {\n\t\treadFile(path: string): Promise<string>;\n\t\twriteFile(path: string, content: string): Promise<void>;\n\t},\n\tfilePath: string,\n\tdisableCodegen?: boolean,\n): Promise<BootstrapResult> {\n\ttry {\n\t\tconst configCode = await workspace.readFile(filePath);\n\t\tconst result = transformNextjsConfig({\n\t\t\tcode: configCode,\n\t\t\tdisableCodegen,\n\t\t});\n\n\t\tif (result.success && result.updated && result.code) {\n\t\t\tawait workspace.writeFile(filePath, result.code);\n\t\t}\n\n\t\tif (result.success) {\n\t\t\treturn result.updated !== undefined\n\t\t\t\t? { success: true, updated: result.updated }\n\t\t\t\t: { success: true };\n\t\t}\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: result.error!,\n\t\t};\n\t} catch (e: unknown) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: e instanceof Error ? e.message : String(e),\n\t\t};\n\t}\n}\n\n/**\n * Search for a Nuxt configuration file in the given directory.\n */\nexport async function findNuxtConfig(\n\tcwd = process.cwd(),\n): Promise<string | null> {\n\tconst filenames = [\n\t\t\"nuxt.config.ts\",\n\t\t\"nuxt.config.js\",\n\t\t\"nuxt.config.mts\",\n\t\t\"nuxt.config.mjs\",\n\t\t\"nuxt.config.cjs\",\n\t];\n\tfor (const file of filenames) {\n\t\tconst fullPath = path.resolve(cwd, file);\n\t\ttry {\n\t\t\tawait fsp.access(fullPath);\n\t\t\treturn fullPath;\n\t\t} catch {\n\t\t\t// ignore missing file\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Bootstrap a Nuxt config file by adding '@arkenv/nuxt/module' to its modules.\n */\nexport async function bootstrapNuxtConfig(\n\tworkspace: {\n\t\treadFile(path: string): Promise<string>;\n\t\twriteFile(path: string, content: string): Promise<void>;\n\t},\n\tfilePath: string,\n): Promise<BootstrapResult> {\n\ttry {\n\t\tconst configCode = await workspace.readFile(filePath);\n\t\tconst result = transformNuxtConfig({\n\t\t\tcode: configCode,\n\t\t});\n\n\t\tif (result.success && result.updated && result.code) {\n\t\t\tawait workspace.writeFile(filePath, result.code);\n\t\t}\n\n\t\tif (result.success) {\n\t\t\treturn result.updated !== undefined\n\t\t\t\t? { success: true, updated: result.updated }\n\t\t\t\t: { success: true };\n\t\t}\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: result.error!,\n\t\t};\n\t} catch (e: unknown) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: e instanceof Error ? e.message : String(e),\n\t\t};\n\t}\n}\n\nexport async function bootstrapViteConfig(\n\tworkspace: {\n\t\treadFile(path: string): Promise<string>;\n\t\twriteFile(path: string, content: string): Promise<void>;\n\t},\n\tfilePath: string,\n\timportPath: string,\n): Promise<BootstrapResult> {\n\ttry {\n\t\tconst configCode = await workspace.readFile(filePath);\n\t\tconst result = transformViteConfig({\n\t\t\tcode: configCode,\n\t\t\tenvImportPath: importPath,\n\t\t});\n\n\t\tif (result.success && result.updated && result.code) {\n\t\t\tawait workspace.writeFile(filePath, result.code);\n\t\t}\n\n\t\tif (result.success) {\n\t\t\treturn result.updated !== undefined\n\t\t\t\t? { success: true, updated: result.updated }\n\t\t\t\t: { success: true };\n\t\t}\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: result.error!,\n\t\t};\n\t} catch (e: unknown) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: e instanceof Error ? e.message : String(e),\n\t\t};\n\t}\n}\n\nexport async function bootstrapBunConfig(\n\t_configPath?: string | null,\n\tfeatures?: (\"serve\" | \"build\")[],\n): Promise<BootstrapResult> {\n\tif (!features || features.length === 0) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tinstructions: dedent`\n\t\t\t\t${pc.green(\"✔\")} Use ${pc.bold(\"Vanilla\")} Bun runtime integration.\n\t\t\t\tAccess validated variables via your ${code(\"env\")} object for typesafety.\n\t\t\t\tPrimarily used for ${pc.cyan(\"server-side\")} or runtime-only validation.\n\t\t\t\tNo plugins are required.\n\t\t\t`,\n\t\t};\n\t}\n\n\tconst hasServe = features.includes(\"serve\");\n\tconst hasBuild = features.includes(\"build\");\n\n\tlet instructions = \"\";\n\n\tif (hasServe) {\n\t\tinstructions += dedent`\n\t\t\t${pc.bold(\"Bun Fullstack (Bun.serve) Integration:\")}\n\t\t\tTo inline environment variables (e.g. ${code(\"PUBLIC_*\")}) in your ${pc.cyan(\"client-side\")} code, add the plugin to ${code(\"bunfig.toml\")}:\n\n\t\t\t[serve.static]\n\t\t\tplugins = [\"@arkenv/bun-plugin\"]\n\n\t\t`;\n\t}\n\n\tif (hasBuild) {\n\t\tif (instructions) instructions += \"\\n\";\n\t\tinstructions += dedent`\n\t\t\t${pc.bold(\"Bun Fullstack programmatic bundling (Bun.build):\")}\n\t\t\tTo inline environment variables (e.g. ${code(\"PUBLIC_*\")}) in your custom ${pc.cyan(\"client-side\")} build script, add the plugin to your ${code(\"Bun.build\")} call:\n\n\t\t\t${code('import arkenvPlugin from \"@arkenv/bun-plugin\";')}\n\n\t\t\tawait Bun.build({\n\t\t\t entrypoints: [\"./index.ts\"],\n\t\t\t outdir: \"./dist\",\n\t\t\t ${pc.green(\"plugins: [arkenvPlugin]\")}\n\t\t\t});\n\t\t`;\n\t}\n\n\treturn { success: true, instructions: instructions.trim() };\n}\n","import path from \"node:path\";\nimport { applyEdits, modify, parse } from \"jsonc-parser\";\nimport { findTsConfig } from \"@/adapters/node-project-scanner/utils/tsconfig\";\n\nexport async function updateTsConfigToStrict(\n\tworkspace: {\n\t\treadFile(path: string): Promise<string>;\n\t\twriteFile(path: string, content: string): Promise<void>;\n\t},\n\tfilePath?: string,\n) {\n\tconst tsConfigPath = filePath || (await findTsConfig());\n\tif (!tsConfigPath) return { status: \"not_found\" as const };\n\tconst fileName = path.basename(tsConfigPath);\n\n\ttry {\n\t\tconst content = await workspace.readFile(tsConfigPath);\n\t\tconst parsed = parse(content);\n\n\t\tif (parsed?.compilerOptions?.strict === true) {\n\t\t\treturn { status: \"already_strict\" as const, file: fileName };\n\t\t}\n\n\t\tconst edits = modify(content, [\"compilerOptions\", \"strict\"], true, {\n\t\t\tformattingOptions: { insertSpaces: true, tabSize: 2 },\n\t\t});\n\t\tconst updated = applyEdits(content, edits);\n\n\t\tawait workspace.writeFile(tsConfigPath, updated);\n\t\treturn { status: \"updated\" as const, file: fileName };\n\t} catch {\n\t\treturn { status: \"error\" as const, file: fileName };\n\t}\n}\n","import { type StdioOptions, spawn } from \"node:child_process\";\nimport fsp from \"node:fs/promises\";\nimport path from \"node:path\";\nimport pc from \"picocolors\";\nimport type {\n\tBootstrapResult,\n\tLoggerPort,\n\tWorkspacePort,\n} from \"@/shared/ports\";\nimport {\n\tbootstrapBunConfig,\n\tbootstrapNextjsConfig,\n\tbootstrapNuxtConfig,\n\tbootstrapViteConfig,\n\tfindBunConfig,\n\tfindNextjsConfig,\n\tfindNuxtConfig,\n\tfindViteConfig,\n} from \"./utils/bootstrappers\";\nimport { updateTsConfigToStrict } from \"./utils/tsconfig\";\n\n/**\n * Adapter implementation for WorkspacePort using Node.js APIs.\n */\nexport class NodeWorkspace implements WorkspacePort {\n\tconstructor(\n\t\tprivate isQuiet: boolean,\n\t\tprivate stdio:\n\t\t\t| \"inherit\"\n\t\t\t| \"ignore\"\n\t\t\t| \"pipe\"\n\t\t\t| readonly (object | number | string | null | undefined)[],\n\t\tprivate logger?: Pick<LoggerPort, \"error\">,\n\t) {}\n\n\tasync exists(filePath: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fsp.access(filePath);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync readFile(filePath: string): Promise<string> {\n\t\treturn fsp.readFile(filePath, \"utf-8\");\n\t}\n\n\tasync writeFile(filePath: string, content: string): Promise<void> {\n\t\tawait fsp.writeFile(filePath, content, \"utf-8\");\n\t}\n\n\tasync mkdir(dirPath: string, recursive?: boolean): Promise<void> {\n\t\tawait fsp.mkdir(dirPath, { recursive });\n\t}\n\n\tasync execute(\n\t\tcommand: string,\n\t\targs: string[] = [],\n\t\tcwd?: string,\n\t): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\tconst child = spawn(command, args, {\n\t\t\t\tcwd,\n\t\t\t\tstdio: (this.isQuiet ? \"pipe\" : this.stdio) as StdioOptions,\n\t\t\t\tshell: false,\n\t\t\t});\n\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tconst MAX_BUFFER = 10_000;\n\n\t\t\tif (this.isQuiet) {\n\t\t\t\tchild.stdout?.on(\"data\", (data: Buffer) => {\n\t\t\t\t\tstdout = (stdout + data.toString()).slice(-MAX_BUFFER);\n\t\t\t\t});\n\t\t\t\tchild.stderr?.on(\"data\", (data: Buffer) => {\n\t\t\t\t\tstderr = (stderr + data.toString()).slice(-MAX_BUFFER);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tchild.on(\"close\", (code: number | null, signal: string | null) => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\tlet message =\n\t\t\t\t\t\tcode === null\n\t\t\t\t\t\t\t? `Command terminated by signal ${signal}`\n\t\t\t\t\t\t\t: `Command failed with code ${code}`;\n\t\t\t\t\tif (this.isQuiet) {\n\t\t\t\t\t\tif (stdout) message += `\\n${pc.dim(\"STDOUT:\")}\\n${stdout}`;\n\t\t\t\t\t\tif (stderr) message += `\\n${pc.red(\"STDERR:\")}\\n${stderr}`;\n\t\t\t\t\t}\n\t\t\t\t\treject(new Error(message));\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchild.on(\"error\", reject);\n\t\t});\n\t}\n\n\tasync updateTsConfigToStrict(filePath?: string) {\n\t\treturn updateTsConfigToStrict(this, filePath);\n\t}\n\n\tasync findViteConfig(cwd?: string): Promise<string | null> {\n\t\treturn findViteConfig(cwd);\n\t}\n\n\tasync findBunConfig(cwd?: string): Promise<string | null> {\n\t\treturn findBunConfig(cwd);\n\t}\n\n\tasync findNextjsConfig(cwd?: string): Promise<string | null> {\n\t\treturn findNextjsConfig(cwd);\n\t}\n\n\tasync findNuxtConfig(cwd?: string): Promise<string | null> {\n\t\treturn findNuxtConfig(cwd);\n\t}\n\n\tasync bootstrapViteConfig(\n\t\tfilePath: string,\n\t\timportPath: string,\n\t): Promise<BootstrapResult> {\n\t\treturn bootstrapViteConfig(this, filePath, importPath);\n\t}\n\n\tasync bootstrapBunConfig(\n\t\tconfigPath?: string | null,\n\t\tfeatures?: (\"serve\" | \"build\")[],\n\t): Promise<BootstrapResult> {\n\t\treturn bootstrapBunConfig(configPath, features);\n\t}\n\n\tasync bootstrapNextjsConfig(\n\t\tfilePath: string,\n\t\tdisableCodegen?: boolean,\n\t): Promise<BootstrapResult> {\n\t\treturn bootstrapNextjsConfig(this, filePath, disableCodegen);\n\t}\n\n\tasync bootstrapNuxtConfig(filePath: string): Promise<BootstrapResult> {\n\t\treturn bootstrapNuxtConfig(this, filePath);\n\t}\n\n\tasync safeAppend(\n\t\tfilePath: string,\n\t\tschemaPath: string,\n\t\tframework: \"vite\" | \"bun-fullstack\",\n\t) {\n\t\tconst { safeAppend } = await import(\"../injection\");\n\t\treturn safeAppend(filePath, schemaPath, framework, this.logger);\n\t}\n\n\tasync appendMissingEnvExampleKeys(\n\t\tcwd: string,\n\t\tkeys: string[],\n\t): Promise<boolean> {\n\t\tconst envExamplePath = path.join(cwd, \".env.example\");\n\t\tif (!(await this.exists(envExamplePath))) {\n\t\t\treturn false;\n\t\t}\n\t\tconst content = await this.readFile(envExamplePath);\n\t\tconst existingKeys = new Set<string>();\n\t\tfor (const line of content.split(/\\r?\\n/)) {\n\t\t\tconst m = line.match(/^\\s*(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=/);\n\t\t\tif (m) {\n\t\t\t\texistingKeys.add(m[1]);\n\t\t\t}\n\t\t}\n\t\tconst missingKeys = keys.filter((k) => !existingKeys.has(k));\n\t\tif (missingKeys.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tconst appendLines = missingKeys.map((k) => `${k}=`).join(\"\\n\") + \"\\n\";\n\t\tconst newContent =\n\t\t\tcontent.endsWith(\"\\n\") || content.length === 0\n\t\t\t\t? `${content}${appendLines}`\n\t\t\t\t: `${content}\\n${appendLines}`;\n\t\tawait this.writeFile(envExamplePath, newContent);\n\t\treturn true;\n\t}\n\n\tasync removeEnvExampleKeys(\n\t\tcwd: string,\n\t\tkeysToRemove: string[],\n\t\tremainingKeys: string[] = [],\n\t): Promise<boolean> {\n\t\tconst envExamplePath = path.join(cwd, \".env.example\");\n\t\tif (!(await this.exists(envExamplePath))) {\n\t\t\treturn false;\n\t\t}\n\t\tconst safeKeysToRemove = new Set(\n\t\t\tkeysToRemove.filter((k) => !remainingKeys.includes(k)),\n\t\t);\n\t\tif (safeKeysToRemove.size === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tconst content = await this.readFile(envExamplePath);\n\t\tconst lines = content.split(/\\r?\\n/);\n\t\tconst newLines = lines.filter((line) => {\n\t\t\tconst m = line.match(/^\\s*(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=/);\n\t\t\tif (m && safeKeysToRemove.has(m[1])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\t\tlet newContent = newLines.join(\"\\n\");\n\t\tif (content.endsWith(\"\\n\") && !newContent.endsWith(\"\\n\")) {\n\t\t\tnewContent += \"\\n\";\n\t\t}\n\t\tif (newContent !== content) {\n\t\t\tawait this.writeFile(envExamplePath, newContent);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n","import { confirm, isCancel } from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport { code } from \"@/cli/ui/visuals\";\n\nexport async function overwriteEnvSchemaFileStep(options: {\n\thasEnvSchemaFile: boolean;\n\tdefaultPath?: string | undefined;\n}): Promise<boolean | null> {\n\tconst defaultPath = options.defaultPath || \"./src/env.ts\";\n\tif (options.hasEnvSchemaFile) {\n\t\tconst answer = await confirm({\n\t\t\tmessage: pc.yellow(\n\t\t\t\t`An existing ArkEnv configuration was found at ${code(defaultPath)}. Do you want to overwrite it?`,\n\t\t\t),\n\t\t\tinitialValue: false,\n\t\t\tactive: \"Yes (override my configuration)\",\n\t\t\tinactive: \"No (abort)\",\n\t\t});\n\t\tif (isCancel(answer) || !answer) {\n\t\t\treturn null;\n\t\t}\n\t\treturn answer;\n\t}\n\treturn true;\n}\n\nexport async function useEnvExampleStep(options: {\n\tdetectedKeys: string[] | null;\n\tkeysSource?: \".env.example\" | \"project\" | undefined;\n}): Promise<boolean | null> {\n\tconst detectedKeys = options.detectedKeys;\n\tconst source = options.keysSource || \".env.example\";\n\tif (detectedKeys && detectedKeys.length > 0) {\n\t\tconst count = detectedKeys.length;\n\t\tconst isSingular = count === 1;\n\t\tconst message =\n\t\t\tsource === \".env.example\"\n\t\t\t\t? `Detected ${code(\".env.example\")} with ${count} ${isSingular ? \"key\" : \"keys\"}. Use ${isSingular ? \"it\" : \"them\"} for your schema?`\n\t\t\t\t: `Detected ${count} environment variable${isSingular ? \"\" : \"s\"} used in your project. Use ${isSingular ? \"it\" : \"them\"} for your schema?`;\n\n\t\tconst answer = await confirm({\n\t\t\tmessage,\n\t\t\tactive: \"Yes (Recommended)\",\n\t\t\tinitialValue: true,\n\t\t});\n\t\treturn isCancel(answer) ? null : (answer as boolean);\n\t}\n\treturn false;\n}\n","import { isCancel, select } from \"@clack/prompts\";\nimport type { Example } from \"@/shared/clients\";\n\n/**\n * Builds the example selection prompt from the registry examples.\n */\nexport async function exampleStep(options: {\n\texamples: Example[];\n}): Promise<string | null> {\n\tconst answer = await select({\n\t\tmessage: \"Select an example:\",\n\t\toptions: options.examples.map((t) => ({\n\t\t\tvalue: t.id,\n\t\t\tlabel: t.name,\n\t\t\t...(t.description ? { hint: t.description } : {}),\n\t\t})),\n\t});\n\treturn isCancel(answer) ? null : answer;\n}\n","import { confirm, isCancel, select } from \"@clack/prompts\";\nimport type { ProjectOptions } from \"@/features/scaffold\";\n\n/**\n * Prompt the user to select their framework or build tool.\n *\n * @param options Default framework option to pre-select\n * @returns The selected framework or null if cancelled\n */\nexport async function frameworkStep(options: {\n\tframework?: ProjectOptions[\"framework\"] | undefined;\n}): Promise<ProjectOptions[\"framework\"] | null> {\n\tconst answer = await select({\n\t\tmessage: \"Select your framework or build tool:\",\n\t\tinitialValue: options.framework,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tvalue: \"vanilla\",\n\t\t\t\tlabel: `Vanilla${options.framework === \"vanilla\" ? \" (Detected)\" : \"\"}`,\n\t\t\t\thint: \"Node.js, Bun, server-side or runtime-only validation\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: \"vite\",\n\t\t\t\tlabel: `Vite${options.framework === \"vite\" ? \" (Detected)\" : \"\"}`,\n\t\t\t\thint: \"Client-side and static inlining validation\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: \"bun-fullstack\",\n\t\t\t\tlabel: `Bun fullstack dev server${options.framework === \"bun-fullstack\" ? \" (Detected)\" : \"\"}`,\n\t\t\t\thint: \"Client-side bundling and Bun.serve integration\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: \"nextjs\",\n\t\t\t\tlabel: `Next.js${options.framework === \"nextjs\" ? \" (Detected)\" : \"\"}`,\n\t\t\t\thint: \"Next.js App or Pages Router with build and runtime validation\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: \"nuxt\",\n\t\t\t\tlabel: `Nuxt${options.framework === \"nuxt\" ? \" (Detected)\" : \"\"}`,\n\t\t\t\thint: \"Nuxt with build and runtime validation\",\n\t\t\t},\n\t\t],\n\t});\n\treturn isCancel(answer) ? null : (answer as ProjectOptions[\"framework\"]);\n}\n\n/**\n * Prompt the user to bootstrap a custom Bun.build script.\n *\n * @param options Options including default/initial value for the prompt\n * @returns Whether the user confirmed or null if cancelled\n */\nexport async function bunBuildStep(options: {\n\tinitialValue?: boolean | undefined;\n}): Promise<boolean | null> {\n\tconst answer = await confirm({\n\t\tmessage:\n\t\t\t\"Optional: Would you also like to bootstrap a custom Bun.build script for programmatic bundling?\",\n\t\tinitialValue: options.initialValue ?? false,\n\t});\n\treturn isCancel(answer) ? null : answer;\n}\n\n/**\n * Prompt the user to select their preferred validator library.\n *\n * @returns The selected validator or null if cancelled\n */\nexport async function validatorStep(): Promise<\n\tProjectOptions[\"validator\"] | null\n> {\n\tconst answer = await select({\n\t\tmessage: \"Select your preferred validator library:\",\n\t\toptions: [\n\t\t\t{\n\t\t\t\tvalue: \"arktype\",\n\t\t\t\tlabel: \"ArkType (Recommended)\",\n\t\t\t\thint: \"TypeScript's 1:1 validator, optimized from editor to runtime\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: \"zod\",\n\t\t\t\tlabel: \"Zod\",\n\t\t\t\thint: \"TypeScript-first schema validation with static type inference\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: \"valibot\",\n\t\t\t\tlabel: \"Valibot\",\n\t\t\t\thint: \"The modular and type safe schema library\",\n\t\t\t},\n\t\t],\n\t});\n\treturn isCancel(answer) ? null : (answer as ProjectOptions[\"validator\"]);\n}\n\n/**\n * Prompt the user to select their Next.js/Nuxt structure layout (Strict vs Simple/Flat).\n *\n * @param options Optional options specifying the active framework\n * @returns The selected layout or null if cancelled\n */\nexport async function layoutStep(options?: {\n\tframework?: string;\n}): Promise<\"strict\" | \"simple\" | \"flat\" | null> {\n\tconst layoutOptions =\n\t\toptions?.framework === \"nextjs\"\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: \"flat\",\n\t\t\t\t\t\tlabel: \"Flat (Recommended)\",\n\t\t\t\t\t\thint: \"A single flat env.ts file for the best DX\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: \"strict\",\n\t\t\t\t\t\tlabel: \"Strict\",\n\t\t\t\t\t\thint: \"Separate shared, client, and server files for hard bundle boundaries.\",\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: \"flat\",\n\t\t\t\t\t\tlabel: \"Flat (Recommended)\",\n\t\t\t\t\t\thint: \"A single flat env.ts file for the best DX\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: \"strict\",\n\t\t\t\t\t\tlabel: \"Strict\",\n\t\t\t\t\t\thint: \"Separate shared, client, and server files for hard bundle boundaries.\",\n\t\t\t\t\t},\n\t\t\t\t];\n\n\tconst answer = await select({\n\t\tmessage: \"How would you like to structure your environment variables?\",\n\t\toptions: layoutOptions,\n\t});\n\treturn isCancel(answer) ? null : (answer as \"strict\" | \"simple\" | \"flat\");\n}\n\n/**\n * Prompt the user to enable Next.js automatic environment variable codegen.\n *\n * @param options Options including default/initial value for the prompt\n * @returns Whether the user confirmed (enabled) or null if cancelled\n */\nexport async function nextjsCodegenStep(options: {\n\tinitialValue?: boolean | undefined;\n\tframework?: string;\n}): Promise<boolean | null> {\n\tconst frameworkName = options.framework === \"nuxt\" ? \"Nuxt\" : \"Next.js\";\n\tconst answer = await confirm({\n\t\tmessage: `Enable automated ${frameworkName} code generation for environment variables?`,\n\t\tinitialValue: options.initialValue ?? true,\n\t\tactive: \"Yes (Recommended)\",\n\t\tinactive: \"No\",\n\t});\n\treturn isCancel(answer) ? null : answer;\n}\n","import { isCancel, select } from \"@clack/prompts\";\nimport type { ProjectOptions } from \"@/features/scaffold\";\nimport { PRESETS } from \"@/features/scaffold/presets\";\n\n/**\n * Prompt for an optional hosting provider preset.\n *\n * @param options Optional initial selection\n * @returns Selected host preset, or `null` when cancelled\n */\nexport async function hostPresetStep(options?: {\n\tinitialValue?: ProjectOptions[\"hostPreset\"] | undefined;\n}): Promise<ProjectOptions[\"hostPreset\"] | null> {\n\tconst selectOptions = [\n\t\t{\n\t\t\tvalue: \"none\" as const,\n\t\t\tlabel: \"None\",\n\t\t\thint: \"Do not add any hosting-specific environment variables\",\n\t\t},\n\t\t...Object.entries(PRESETS).map(([value, def]) => ({\n\t\t\tvalue,\n\t\t\tlabel: def.label,\n\t\t\thint: def.hint,\n\t\t})),\n\t];\n\n\tconst answer = await select({\n\t\tmessage: \"Select a hosting provider preset (optional):\",\n\t\tinitialValue: options?.initialValue ?? \"none\",\n\t\toptions: selectOptions,\n\t});\n\treturn isCancel(answer) ? null : (answer as ProjectOptions[\"hostPreset\"]);\n}\n","import { confirm, isCancel, text } from \"@clack/prompts\";\nimport { code } from \"@/cli/ui/visuals\";\n\nexport async function useDefaultPathStep(options: {\n\tdefaultEnvPath?: string | undefined;\n}): Promise<boolean | null> {\n\tconst defaultEnvPath = options.defaultEnvPath || \"./src/env.ts\";\n\tconst answer = await confirm({\n\t\tmessage: `Use default config path (${code(defaultEnvPath)})?`,\n\t\tinitialValue: true,\n\t\tactive: \"Yes (Recommended)\",\n\t\tinactive: \"No, let me customize it\",\n\t});\n\treturn isCancel(answer) ? null : (answer as boolean);\n}\n\nexport async function pathStep(options: {\n\tuseDefaultPath: boolean;\n\tdefaultEnvPath?: string | undefined;\n}): Promise<string | null> {\n\tconst defaultEnvPath = options.defaultEnvPath || \"./src/env.ts\";\n\tif (!options.useDefaultPath) {\n\t\tconst answer = await text({\n\t\t\tmessage: \"Where should we create the ArkEnv config?\",\n\t\t\tplaceholder: defaultEnvPath,\n\t\t\tinitialValue: defaultEnvPath,\n\t\t\tdefaultValue: defaultEnvPath,\n\t\t});\n\t\tif (isCancel(answer)) return null;\n\t\tconst trimmed = typeof answer === \"string\" ? answer.trim() : \"\";\n\t\treturn trimmed === \"\" ? defaultEnvPath : trimmed;\n\t}\n\treturn defaultEnvPath;\n}\n","import {\n\toverwriteEnvSchemaFileStep,\n\tuseEnvExampleStep,\n} from \"./steps/env-example\";\nimport { exampleStep } from \"./steps/example\";\nimport {\n\tbunBuildStep,\n\tframeworkStep,\n\tlayoutStep,\n\tnextjsCodegenStep,\n\tvalidatorStep,\n} from \"./steps/framework\";\nimport { hostPresetStep } from \"./steps/host-preset\";\nimport { pathStep, useDefaultPathStep } from \"./steps/path\";\n\n/**\n * A collection of interactive CLI prompt steps used during initialization.\n */\nexport const steps = {\n\texample: exampleStep,\n\toverwriteEnvSchemaFile: overwriteEnvSchemaFileStep,\n\tframework: frameworkStep,\n\tbunBuild: bunBuildStep,\n\tlayout: layoutStep,\n\tnextjsCodegen: nextjsCodegenStep,\n\tuseDefaultPath: useDefaultPathStep,\n\tpath: pathStep,\n\tvalidator: validatorStep,\n\thostPreset: hostPresetStep,\n\tuseEnvExample: useEnvExampleStep,\n};\n","import path from \"node:path\";\nimport { cancel, confirm, isCancel, text } from \"@clack/prompts\";\nimport { shake } from \"radashi\";\nimport type { ProjectOptions } from \"@/features/scaffold\";\nimport type { Example } from \"@/shared/clients\";\nimport type { ParsedTsConfig } from \"@/shared/ports\";\nimport { code } from \"@/shared/visuals\";\nimport { steps } from \"./steps\";\n\ntype ExistingProjectDefaults = Partial<\n\tPick<\n\t\tProjectOptions,\n\t\t\"framework\" | \"bunFeatures\" | \"disableCodegen\" | \"hostPreset\"\n\t>\n> & {\n\tdefaultEnvPath?: string;\n\ttsConfig?: ParsedTsConfig | null;\n\tenvKeys?: string[];\n\tenvKeysSource?: \".env.example\" | \"project\";\n\thasEnvSchemaFile?: boolean;\n\tisStrict?: boolean;\n\tisSimple?: boolean;\n\tisFlat?: boolean;\n};\n\n/**\n * Run the appropriate init prompt flow for a new or existing project.\n *\n * @param defaults Optional default values and configuration for the wizard\n * @param isYes Whether to run in non-interactive/auto-confirm mode\n * @returns The project options or null if cancelled\n */\nexport async function runPromptWizard(\n\tdefaults?: Partial<\n\t\tPick<\n\t\t\tProjectOptions,\n\t\t\t| \"mode\"\n\t\t\t| \"example\"\n\t\t\t| \"name\"\n\t\t\t| \"framework\"\n\t\t\t| \"bunFeatures\"\n\t\t\t| \"disableCodegen\"\n\t\t\t| \"hostPreset\"\n\t\t>\n\t> & {\n\t\texamples?: Example[];\n\t\tdefaultEnvPath?: string;\n\t\ttsConfig?: ParsedTsConfig | null;\n\t\tenvKeys?: string[];\n\t\tenvKeysSource?: \".env.example\" | \"project\";\n\t\thasEnvSchemaFile?: boolean;\n\t},\n\tisYes = false,\n): Promise<ProjectOptions | null> {\n\tconst mode = defaults?.mode || \"existing\";\n\n\tif (mode === \"new\") {\n\t\treturn runNewProjectWizard(defaults, isYes);\n\t}\n\n\treturn runExistingProjectWizard(defaults, isYes);\n}\n\n/**\n * Collect option for scaffolding a new project from an example.\n *\n * @param defaults Optional default values for the new project\n * @param isYes Whether to run in non-interactive/auto-confirm mode\n * @returns The project options or null if cancelled\n * @throws An error if an unknown example ID is specified\n */\nasync function runNewProjectWizard(\n\tdefaults?: Partial<Pick<ProjectOptions, \"example\" | \"name\">> & {\n\t\texamples?: Example[];\n\t},\n\tisYes = false,\n): Promise<ProjectOptions | null> {\n\tconst examples = defaults?.examples || [];\n\tconst defaultProjectName = \"arkenv-project\";\n\n\ttry {\n\t\tlet projectName: string;\n\t\tif (defaults?.name) {\n\t\t\tconst trimmed = defaults.name.trim();\n\t\t\tif (\n\t\t\t\ttrimmed === \".\" ||\n\t\t\t\ttrimmed === \"./\" ||\n\t\t\t\tpath.resolve(process.cwd(), trimmed) === process.cwd()\n\t\t\t) {\n\t\t\t\tprojectName = \".\";\n\t\t\t} else {\n\t\t\t\tprojectName = trimmed;\n\t\t\t}\n\t\t} else if (!isYes) {\n\t\t\tconst name = await text({\n\t\t\t\tmessage: \"Project name:\",\n\t\t\t\tplaceholder: defaultProjectName,\n\t\t\t\tdefaultValue: defaultProjectName,\n\t\t\t});\n\n\t\t\tconst nameResult = unwrapPrompt(name);\n\t\t\tconst trimmed = (nameResult || defaultProjectName).trim();\n\t\t\tif (\n\t\t\t\ttrimmed === \".\" ||\n\t\t\t\ttrimmed === \"./\" ||\n\t\t\t\tpath.resolve(process.cwd(), trimmed) === process.cwd()\n\t\t\t) {\n\t\t\t\tprojectName = \".\";\n\t\t\t} else {\n\t\t\t\tprojectName = trimmed;\n\t\t\t}\n\t\t} else {\n\t\t\tprojectName = defaultProjectName;\n\t\t}\n\n\t\tlet exampleId = defaults?.example;\n\n\t\tif (!exampleId && !isYes) {\n\t\t\tconst selected = await steps.example({ examples });\n\t\t\texampleId = unwrapPrompt(selected);\n\t\t} else if (!exampleId && isYes) {\n\t\t\texampleId = \"basic\";\n\t\t}\n\n\t\tconst example = examples.find((t) => t.id === exampleId);\n\t\tif (!example) {\n\t\t\tconst availableExamples = examples.map((t) => t.id).join(\", \");\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown example ${exampleId}. Available examples: ${availableExamples}`,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tmode: \"new\",\n\t\t\texample: example.id,\n\t\t\tname: projectName,\n\t\t\tpath: \"./src/env.ts\",\n\t\t\tvalidator: \"arktype\",\n\t\t\tframework: example.framework,\n\t\t\tlanguage: \"ts\",\n\t\t\tinstallSkill: false,\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof CancelError) {\n\t\t\treturn null;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Collect option for adding ArkEnv to a project that already has `package.json`.\n *\n * @param defaults Optional default values for the existing project\n * @param isYes Whether to run in non-interactive/auto-confirm mode\n * @returns The project options or null if cancelled\n */\nasync function runExistingProjectWizard(\n\tdefaults?: ExistingProjectDefaults,\n\tisYes = false,\n): Promise<ProjectOptions | null> {\n\tconst defaultEnvPath = defaults?.defaultEnvPath || \"./src/env.ts\";\n\tconst detectedKeys = defaults?.envKeys || null;\n\tconst keysSource = defaults?.envKeysSource || \".env.example\";\n\n\tif (isYes) {\n\t\tconst framework = defaults?.framework || \"vanilla\";\n\t\tlet layout: \"strict\" | \"simple\" | \"flat\" | undefined;\n\t\tif (framework === \"nextjs\" || framework === \"nuxt\") {\n\t\t\tif (defaults?.isStrict) {\n\t\t\t\tlayout = \"strict\";\n\t\t\t} else if (defaults?.isSimple) {\n\t\t\t\tlayout = \"simple\";\n\t\t\t} else if (defaults?.isFlat) {\n\t\t\t\tlayout = \"flat\";\n\t\t\t} else {\n\t\t\t\tlayout = \"flat\";\n\t\t\t}\n\t\t}\n\n\t\treturn shake({\n\t\t\tmode: \"existing\",\n\t\t\tpath: defaultEnvPath,\n\t\t\tvalidator: \"arktype\",\n\t\t\tframework,\n\t\t\tlayout,\n\t\t\tbunFeatures:\n\t\t\t\tframework === \"bun-fullstack\"\n\t\t\t\t\t? (defaults?.bunFeatures ?? [\"serve\"])\n\t\t\t\t\t: undefined,\n\t\t\tlanguage: \"ts\",\n\t\t\toverwriteEnvSchemaFile: true,\n\t\t\tinstallSkill: false,\n\t\t\tenvKeys: detectedKeys ?? undefined,\n\t\t\tdisableCodegen: defaults?.disableCodegen ?? false,\n\t\t\twrapNextjsConfig: framework === \"nextjs\" ? true : undefined,\n\t\t\thostPreset: defaults?.hostPreset || \"none\",\n\t\t});\n\t}\n\n\ttry {\n\t\t// 1. overwriteEnvSchemaFile\n\t\tconst overwriteEnvSchemaFile = unwrapPrompt(\n\t\t\tawait steps.overwriteEnvSchemaFile({\n\t\t\t\thasEnvSchemaFile: defaults?.hasEnvSchemaFile ?? false,\n\t\t\t\tdefaultPath: defaultEnvPath,\n\t\t\t}),\n\t\t);\n\n\t\t// 2. framework\n\t\tconst framework = unwrapPrompt(\n\t\t\tawait steps.framework({\n\t\t\t\tframework: defaults?.framework,\n\t\t\t}),\n\t\t);\n\n\t\t// Next.js & Nuxt layout prompt\n\t\tlet layout: \"strict\" | \"simple\" | \"flat\" | undefined;\n\t\tif (framework === \"nextjs\" || framework === \"nuxt\") {\n\t\t\tif (defaults?.isStrict) {\n\t\t\t\tlayout = \"strict\";\n\t\t\t} else if (defaults?.isSimple) {\n\t\t\t\tlayout = \"simple\";\n\t\t\t} else if (defaults?.isFlat) {\n\t\t\t\tlayout = \"flat\";\n\t\t\t} else {\n\t\t\t\tlayout = unwrapPrompt(await steps.layout({ framework }));\n\t\t\t}\n\t\t}\n\n\t\t// 3. bunBuild\n\t\tlet bunBuild: boolean | undefined;\n\t\tif (framework === \"bun-fullstack\") {\n\t\t\tconst defaultBunBuild = Boolean(defaults?.bunFeatures?.includes(\"build\"));\n\t\t\tbunBuild = unwrapPrompt(\n\t\t\t\tawait steps.bunBuild({\n\t\t\t\t\tinitialValue: defaultBunBuild,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Next.js & Nuxt codegen prompt\n\t\tlet disableCodegen: boolean | undefined = defaults?.disableCodegen;\n\t\tif (framework === \"nuxt\") {\n\t\t\tdisableCodegen = true;\n\t\t} else if (framework === \"nextjs\" && disableCodegen === undefined) {\n\t\t\tconst useCodegen = unwrapPrompt(\n\t\t\t\tawait steps.nextjsCodegen({\n\t\t\t\t\tinitialValue: true,\n\t\t\t\t\tframework,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tdisableCodegen = !useCodegen;\n\t\t}\n\n\t\t// Next.js config wrapping prompt\n\t\tlet wrapNextjsConfig: boolean | undefined;\n\t\tif (framework === \"nextjs\" && !disableCodegen) {\n\t\t\tconst answer = await confirm({\n\t\t\t\tmessage: `Would you like to wrap your Next.js config with ${code(\"withArkEnv\")}?`,\n\t\t\t\tinitialValue: true,\n\t\t\t\tactive: \"Yes (Recommended)\",\n\t\t\t\tinactive: \"No\",\n\t\t\t});\n\t\t\tif (isCancel(answer)) {\n\t\t\t\tcancel(\"Operation cancelled\");\n\t\t\t\tthrow new CancelError();\n\t\t\t}\n\t\t\twrapNextjsConfig = answer;\n\t\t}\n\n\t\t// 4. useDefaultPath\n\t\tconst useDefaultPath = unwrapPrompt(\n\t\t\tawait steps.useDefaultPath({\n\t\t\t\tdefaultEnvPath,\n\t\t\t}),\n\t\t);\n\n\t\t// 5. path\n\t\tconst envPath = unwrapPrompt(\n\t\t\tawait steps.path({\n\t\t\t\tuseDefaultPath,\n\t\t\t\tdefaultEnvPath,\n\t\t\t}),\n\t\t);\n\n\t\t// 6. validator\n\t\tconst validator = unwrapPrompt(await steps.validator());\n\n\t\t// 7. hostPreset\n\t\tconst hostPreset =\n\t\t\tdefaults?.hostPreset !== undefined\n\t\t\t\t? defaults.hostPreset\n\t\t\t\t: unwrapPrompt(\n\t\t\t\t\t\tawait steps.hostPreset({\n\t\t\t\t\t\t\tinitialValue: defaults?.hostPreset,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t// 8. useEnvExample\n\t\tconst useEnvExample = unwrapPrompt(\n\t\t\tawait steps.useEnvExample({\n\t\t\t\tdetectedKeys,\n\t\t\t\tkeysSource,\n\t\t\t}),\n\t\t);\n\n\t\tconst bunFeatures: ProjectOptions[\"bunFeatures\"] =\n\t\t\tframework === \"bun-fullstack\"\n\t\t\t\t? bunBuild\n\t\t\t\t\t? [\"serve\", \"build\"]\n\t\t\t\t\t: [\"serve\"]\n\t\t\t\t: undefined;\n\n\t\treturn shake({\n\t\t\tmode: \"existing\",\n\t\t\toverwriteEnvSchemaFile,\n\t\t\tframework,\n\t\t\tlayout,\n\t\t\tpath: envPath,\n\t\t\tvalidator,\n\t\t\thostPreset,\n\t\t\tbunFeatures,\n\t\t\tlanguage: \"ts\",\n\t\t\tinstallSkill: false,\n\t\t\tenvKeys: useEnvExample ? (detectedKeys ?? undefined) : undefined,\n\t\t\tdisableCodegen,\n\t\t\twrapNextjsConfig,\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof CancelError) {\n\t\t\treturn null;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Represent an error thrown when a user cancels a CLI prompt.\n */\nclass CancelError extends Error {\n\tconstructor() {\n\t\tsuper(\"Operation cancelled\");\n\t}\n}\n\n/**\n * Unwrap a prompt result, throwing a CancelError if the user cancelled the prompt.\n *\n * @param value The prompt result that may be cancelled or null\n * @returns The unwrapped prompt value\n * @throws CancelError If the user cancelled the prompt or if the result is null\n */\nfunction unwrapPrompt<T>(value: T | symbol | null): T {\n\tif (value === null || isCancel(value)) {\n\t\tcancel(\"Operation cancelled\");\n\t\tthrow new CancelError();\n\t}\n\treturn value as T;\n}\n","import {\n\tconfirm as clackConfirm,\n\tselect as clackSelect,\n\tisCancel,\n} from \"@clack/prompts\";\nimport { shake } from \"radashi\";\nimport { runPromptWizard } from \"@/cli/ui\";\nimport type { ProjectOptions } from \"@/features/scaffold\";\nimport type { Example } from \"@/shared/clients\";\nimport type { ParsedTsConfig, PromptPort } from \"@/shared/ports\";\n\n/**\n * Adapter implementation for the PromptPort using @clack/prompts.\n */\nexport class ClackPromptAdapter implements PromptPort {\n\t/**\n\t * Prompts the user for a boolean confirmation and returns `null` on cancel.\n\t */\n\tasync confirm(\n\t\tmessage: string,\n\t\tinitialValue = true,\n\t\tactive?: string,\n\t\tinactive?: string,\n\t): Promise<boolean | null> {\n\t\tconst result = await clackConfirm(\n\t\t\tshake({\n\t\t\t\tmessage,\n\t\t\t\tinitialValue,\n\t\t\t\tactive,\n\t\t\t\tinactive,\n\t\t\t}),\n\t\t);\n\t\tif (isCancel(result)) return null;\n\t\treturn result;\n\t}\n\n\t/**\n\t * Runs the init wizard with prefilled defaults from project detection or flags.\n\t */\n\tasync runWizard(\n\t\tdefaults?: Partial<\n\t\t\tPick<\n\t\t\t\tProjectOptions,\n\t\t\t\t\"mode\" | \"example\" | \"name\" | \"framework\" | \"bunFeatures\" | \"hostPreset\"\n\t\t\t>\n\t\t> & {\n\t\t\texamples?: Example[];\n\t\t\tdefaultEnvPath?: string;\n\t\t\ttsConfig?: ParsedTsConfig | null;\n\t\t\tenvKeys?: string[];\n\t\t\tenvKeysSource?: \".env.example\" | \"project\";\n\t\t\thasTypeFileAtPath?: (options: {\n\t\t\t\tframework: ProjectOptions[\"framework\"];\n\t\t\t\tenvPath: string;\n\t\t\t}) => boolean | Promise<boolean>;\n\t\t\thasTypeFile?: boolean;\n\t\t\thasEnvSchemaFile?: boolean;\n\t\t\tisStrict?: boolean;\n\t\t\tisSimple?: boolean;\n\t\t},\n\t\tisYes = false,\n\t): Promise<ProjectOptions | null> {\n\t\treturn runPromptWizard(defaults, isYes);\n\t}\n\n\t/**\n\t * Prompt the user to select one option from a list.\n\t */\n\tasync select<T extends string>(\n\t\tmessage: string,\n\t\toptions: { value: T; label: string; hint?: string }[],\n\t\tinitialValue?: T,\n\t): Promise<T | null> {\n\t\tconst result = await clackSelect({\n\t\t\tmessage,\n\t\t\t// Clack's Option<T> is a conditional type incompatible with our port\n\t\t\t// shape under exactOptionalPropertyTypes; cast via unknown.\n\t\t\toptions: options as unknown as Parameters<\n\t\t\t\ttypeof clackSelect\n\t\t\t>[0][\"options\"],\n\t\t\tinitialValue,\n\t\t});\n\t\tif (isCancel(result)) return null;\n\t\treturn result as T;\n\t}\n}\n","import { Logger } from \"@/adapters\";\nimport {\n\ttype HostPreset,\n\tisHostPreset,\n\tisHostProvider,\n} from \"@/features/scaffold/presets\";\nimport type { InitInput } from \"./commands/init\";\nimport type { PresetInput } from \"./commands/preset\";\n\nconst FLAG_CONFIG = {\n\tisYes: { long: \"--yes\", short: \"-y\", kind: \"boolean\" },\n\tisForce: { long: \"--force\", short: \"-f\", kind: \"boolean\" },\n\tisQuiet: { long: \"--quiet\", short: \"-q\", kind: \"boolean\" },\n\tisJson: { long: \"--json\", short: \"-j\", kind: \"boolean\" },\n\tisAgent: { long: \"--agent\", short: \"\", kind: \"boolean\" },\n\thelpRequested: { long: \"--help\", short: \"-h\", kind: \"boolean\" },\n\t// `-e` is intentionally reserved: it universally means `--env`/`--environment`\n\t// elsewhere, so it must never be aliased to `--example` (or any other flag).\n\t// Keeping it unassigned makes `-e` fail fast as an unknown argument.\n\texample: { long: \"--example\", short: \"\", kind: \"value\" },\n\tisStrict: { long: \"--strict\", short: \"\", kind: \"boolean\" },\n\tisSimple: { long: \"--simple\", short: \"\", kind: \"boolean\" },\n\tisFlat: { long: \"--flat\", short: \"\", kind: \"boolean\" },\n\tnoCodegen: { long: \"--no-codegen\", short: \"\", kind: \"boolean\" },\n\tpreset: { long: \"--preset\", short: \"-P\", kind: \"value\" },\n\thostPreset: { long: \"--host-preset\", short: \"-H\", kind: \"value\" },\n\tfile: { long: \"--file\", short: \"\", kind: \"value\" },\n} as const;\n\nconst knownFlags = new Set<string>(\n\tObject.values(FLAG_CONFIG).flatMap((f) => [f.long, f.short].filter(Boolean)),\n);\n\nconst valuedFlags = new Set<string>(\n\tObject.values(FLAG_CONFIG)\n\t\t.filter((f) => f.kind === \"value\")\n\t\t.flatMap((f) => [f.long, f.short].filter(Boolean)),\n);\n\n/**\n * Main CLI class that parses arguments and sets up the global execution context.\n */\nexport class CLI {\n\tpublic args: string[];\n\tpublic command: string;\n\tpublic name: string | undefined;\n\tpublic validationError: string | undefined;\n\tpublic logger: Logger;\n\tpublic positionalArgs: string[];\n\n\t/**\n\t * Creates a CLI context from process arguments and optional adapters.\n\t */\n\tconstructor(argv: string[], options: { logger?: Logger } = {}) {\n\t\tconst rawArgs = argv.slice(2);\n\t\tconst expandedArgs: string[] = [];\n\t\tlet skipNext = false;\n\n\t\tfor (const arg of rawArgs) {\n\t\t\tif (skipNext) {\n\t\t\t\texpandedArgs.push(arg);\n\t\t\t\tskipNext = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (valuedFlags.has(arg)) {\n\t\t\t\texpandedArgs.push(arg);\n\t\t\t\tskipNext = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (/^-[a-zA-Z]{2,}$/.test(arg)) {\n\t\t\t\tconst chars = arg.slice(1).split(\"\");\n\t\t\t\tfor (const char of chars) {\n\t\t\t\t\texpandedArgs.push(`-${char}`);\n\t\t\t\t}\n\t\t\t\tif (valuedFlags.has(`-${chars[chars.length - 1]}`)) {\n\t\t\t\t\tskipNext = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\texpandedArgs.push(arg);\n\t\t\t}\n\t\t}\n\n\t\tthis.args = expandedArgs;\n\t\tthis.command = this.args[0];\n\n\t\tlet i = 1;\n\t\tconst positionalArgs: string[] = [];\n\t\tthis.validationError = undefined;\n\n\t\twhile (i < this.args.length) {\n\t\t\tconst arg = this.args[i];\n\t\t\tif (arg.startsWith(\"-\")) {\n\t\t\t\tif (!knownFlags.has(arg)) {\n\t\t\t\t\tthis.validationError = `Unknown argument: ${arg}`;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (valuedFlags.has(arg)) {\n\t\t\t\t\tif (i + 1 < this.args.length && !this.args[i + 1].startsWith(\"-\")) {\n\t\t\t\t\t\ti += 2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.validationError = `Missing value for option: ${arg}`;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ti += 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpositionalArgs.push(arg);\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t}\n\n\t\tif (!this.validationError) {\n\t\t\tconst rawPresetVal =\n\t\t\t\tthis.getFlagValue(FLAG_CONFIG.preset.long, FLAG_CONFIG.preset.short) ??\n\t\t\t\tthis.getFlagValue(\n\t\t\t\t\tFLAG_CONFIG.hostPreset.long,\n\t\t\t\t\tFLAG_CONFIG.hostPreset.short,\n\t\t\t\t);\n\t\t\tif (rawPresetVal !== undefined && !isHostPreset(rawPresetVal)) {\n\t\t\t\tthis.validationError = `Invalid host preset: ${rawPresetVal}`;\n\t\t\t}\n\t\t}\n\n\t\tthis.positionalArgs = positionalArgs;\n\n\t\tif (!this.validationError) {\n\t\t\tif (this.command === \"preset\") {\n\t\t\t\tif (positionalArgs.length === 0) {\n\t\t\t\t\tthis.validationError = \"Missing subcommand\";\n\t\t\t\t} else {\n\t\t\t\t\tconst action = positionalArgs[0];\n\t\t\t\t\tif (\n\t\t\t\t\t\taction !== \"apply\" &&\n\t\t\t\t\t\taction !== \"remove\" &&\n\t\t\t\t\t\taction !== \"rm\" &&\n\t\t\t\t\t\taction !== \"add\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.validationError = `Unknown preset action: ${action}`;\n\t\t\t\t\t} else if (positionalArgs.length > 2) {\n\t\t\t\t\t\tthis.validationError = `Unknown argument: ${positionalArgs[2]}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst provider = positionalArgs[1];\n\t\t\t\t\t\tif (provider !== undefined && !isHostProvider(provider)) {\n\t\t\t\t\t\t\tthis.validationError = `Invalid host preset: ${provider}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (positionalArgs.length > 1) {\n\t\t\t\t\tthis.validationError = `Unknown argument: ${positionalArgs[1]}`;\n\t\t\t\t} else {\n\t\t\t\t\tthis.name = positionalArgs[0];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.logger =\n\t\t\toptions.logger ||\n\t\t\tnew Logger({\n\t\t\t\tisQuiet: this.isQuiet,\n\t\t\t\tisJson: this.isJson,\n\t\t\t\tisYes: this.isYes,\n\t\t\t});\n\t}\n\n\tget isAgent(): boolean {\n\t\treturn this.hasFlag(\"isAgent\");\n\t}\n\n\tget isYes(): boolean {\n\t\treturn this.isAgent || this.hasFlag(\"isYes\");\n\t}\n\n\tget isQuiet(): boolean {\n\t\treturn this.isAgent || this.hasFlag(\"isQuiet\");\n\t}\n\n\tget isJson(): boolean {\n\t\treturn this.isAgent || this.hasFlag(\"isJson\");\n\t}\n\n\tget isForce(): boolean {\n\t\treturn this.hasFlag(\"isForce\");\n\t}\n\n\tget helpRequested(): boolean {\n\t\treturn this.hasFlag(\"helpRequested\");\n\t}\n\n\tget example(): string | undefined {\n\t\tconst flag = FLAG_CONFIG.example;\n\t\treturn this.getFlagValue(flag.long, flag.short);\n\t}\n\n\tget isStrict(): boolean {\n\t\treturn this.hasFlag(\"isStrict\");\n\t}\n\n\tget isSimple(): boolean {\n\t\treturn this.hasFlag(\"isSimple\");\n\t}\n\n\tget isFlat(): boolean {\n\t\treturn this.hasFlag(\"isFlat\");\n\t}\n\n\tget noCodegen(): boolean {\n\t\treturn this.hasFlag(\"noCodegen\");\n\t}\n\n\tget file(): string | undefined {\n\t\tconst flag = FLAG_CONFIG.file;\n\t\treturn this.getFlagValue(flag.long, flag.short);\n\t}\n\n\tget hostPreset(): HostPreset | undefined {\n\t\tconst val =\n\t\t\tthis.getFlagValue(FLAG_CONFIG.preset.long, FLAG_CONFIG.preset.short) ??\n\t\t\tthis.getFlagValue(\n\t\t\t\tFLAG_CONFIG.hostPreset.long,\n\t\t\t\tFLAG_CONFIG.hostPreset.short,\n\t\t\t);\n\t\tif (val && isHostPreset(val)) {\n\t\t\treturn val;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate hasFlag(prop: keyof typeof FLAG_CONFIG): boolean {\n\t\tconst flag = FLAG_CONFIG[prop];\n\t\treturn (\n\t\t\tthis.args.includes(flag.long) ||\n\t\t\t(!!flag.short && this.args.includes(flag.short))\n\t\t);\n\t}\n\n\t/**\n\t * Returns the parsed input consumed by the init command.\n\t */\n\tget initInput(): InitInput {\n\t\tconst input: InitInput = {\n\t\t\tisYes: this.isYes,\n\t\t\tisForce: this.isForce,\n\t\t\tisQuiet: this.isQuiet,\n\t\t\tisAgent: this.isAgent,\n\t\t\tisStrict: this.isStrict,\n\t\t\tisSimple: this.isSimple,\n\t\t\tisFlat: this.isFlat,\n\t\t};\n\t\tif (this.example !== undefined) {\n\t\t\tinput.example = this.example;\n\t\t}\n\t\tif (this.name !== undefined) {\n\t\t\tinput.name = this.name;\n\t\t}\n\t\tif (this.noCodegen) {\n\t\t\tinput.noCodegen = true;\n\t\t}\n\t\tif (this.hostPreset !== undefined) {\n\t\t\tinput.hostPreset = this.hostPreset;\n\t\t}\n\t\treturn input;\n\t}\n\n\tget presetInput(): PresetInput {\n\t\tconst rawAction = this.positionalArgs[0];\n\t\tconst action =\n\t\t\trawAction === \"remove\" || rawAction === \"rm\" ? \"remove\" : \"apply\";\n\t\tconst provider = this.positionalArgs[1];\n\t\tconst file = this.file;\n\t\treturn {\n\t\t\taction,\n\t\t\t...(provider && isHostProvider(provider) ? { provider } : {}),\n\t\t\t...(file !== undefined ? { file } : {}),\n\t\t\tisForce: this.isForce,\n\t\t\tisYes: this.isYes,\n\t\t};\n\t}\n\n\t/**\n\t * Returns the value passed to a long or short CLI flag.\n\t */\n\tprivate getFlagValue(long: string, short: string): string | undefined {\n\t\tconst index = this.args.findIndex((a) => a === long || a === short);\n\t\tif (\n\t\t\tindex !== -1 &&\n\t\t\tthis.args[index + 1] &&\n\t\t\t!this.args[index + 1].startsWith(\"-\")\n\t\t) {\n\t\t\treturn this.args[index + 1];\n\t\t}\n\t\treturn undefined;\n\t}\n}\n","","import pc from \"picocolors\";\nimport type { LoggerPort } from \"@/shared/ports\";\nimport { version } from \"../../../package.json\";\n\ntype HelpItem = {\n\tleft: string;\n\tright: string;\n};\n\n/**\n * Formats a list of key-value pairs (like options or commands) into columns,\n * aligning the right column based on the longest left column value.\n */\nfunction formatColumns(items: HelpItem[], leftPad = 2, colGap = 4): string[] {\n\tconst maxLeftLen = Math.max(...items.map((item) => item.left.length), 0);\n\tconst pad = \" \".repeat(leftPad);\n\treturn items.map((item) => {\n\t\tconst rightPad = \" \".repeat(maxLeftLen - item.left.length + colGap);\n\t\treturn `${pad}${item.left}${rightPad}${item.right}`;\n\t});\n}\n\n/**\n * Use case for displaying the CLI help message.\n */\nexport class HelpUseCase {\n\t/**\n\t * Creates the help use case with the logger used for CLI output.\n\t */\n\tconstructor(private readonly logger: LoggerPort) {}\n\n\t/**\n\t * Writes the CLI help text to the configured logger.\n\t */\n\tasync execute() {\n\t\tconst commands: HelpItem[] = [\n\t\t\t{\n\t\t\t\tleft: \"arkenv init [project-name]\",\n\t\t\t\tright: \"Set up ArkEnv in your project\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"arkenv preset apply [provider]\",\n\t\t\t\tright:\n\t\t\t\t\t\"Apply or refresh hosting provider preset (vercel, netlify, cloudflare, railway, render, fly)\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"arkenv preset remove [provider]\",\n\t\t\t\tright: \"Remove hosting provider preset from schema\",\n\t\t\t},\n\t\t];\n\n\t\tconst globalOptions: HelpItem[] = [\n\t\t\t{\n\t\t\t\tleft: \"--yes, -y\",\n\t\t\t\tright: \"Skip prompts and use defaults (also passed to subprocesses)\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"--quiet, -q\",\n\t\t\t\tright: \"Quiet mode: Suppress output, capture logs on failure\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"--json, -j\",\n\t\t\t\tright: \"Output structured JSON to stdout\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"--agent\",\n\t\t\t\tright:\n\t\t\t\t\t\"Enable non-interactive, machine-readable mode for AI agents. Bypasses all prompts and outputs structured JSON. Macro for --yes --quiet --json\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"--help, -h\",\n\t\t\t\tright: \"Show this help message\",\n\t\t\t},\n\t\t];\n\n\t\tconst initOptions: HelpItem[] = [\n\t\t\t{\n\t\t\t\tleft: \"--example\",\n\t\t\t\tright: \"Specify an example name when creating a new project\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"--force, -f\",\n\t\t\t\tright:\n\t\t\t\t\t\"Bypass technical requirement checks and dirty git working tree check, then force scaffolding\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"--no-codegen\",\n\t\t\t\tright: \"Disable automatic env.gen.ts code generation for Next.js\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"--preset, -P <preset>\",\n\t\t\t\tright:\n\t\t\t\t\t\"Specify a hosting provider preset (none, vercel, netlify, cloudflare, railway, render, fly)\",\n\t\t\t},\n\t\t];\n\n\t\tconst presetOptions: HelpItem[] = [\n\t\t\t{\n\t\t\t\tleft: \"--file <path>\",\n\t\t\t\tright: \"Path to schema file (overrides package.json arkenv pointer)\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tleft: \"--force, -f\",\n\t\t\t\tright: \"Bypass dirty git working tree check\",\n\t\t\t},\n\t\t];\n\n\t\tthis.logger.log(`ArkEnv CLI v${version}`);\n\t\tthis.logger.log(`\\n${pc.bold(\"Usage:\")}`);\n\t\tfor (const line of formatColumns(commands)) {\n\t\t\tthis.logger.log(line);\n\t\t}\n\t\tthis.logger.log(`\\n${pc.bold(\"Global options:\")}`);\n\t\tfor (const line of formatColumns(globalOptions)) {\n\t\t\tthis.logger.log(line);\n\t\t}\n\t\tthis.logger.log(`\\n${pc.bold(\"init options:\")}`);\n\t\tfor (const line of formatColumns(initOptions)) {\n\t\t\tthis.logger.log(line);\n\t\t}\n\t\tthis.logger.log(`\\n${pc.bold(\"preset options:\")}`);\n\t\tfor (const line of formatColumns(presetOptions)) {\n\t\t\tthis.logger.log(line);\n\t\t}\n\t}\n}\n","import fsp from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { Workspace } from \"./plan\";\n\n/**\n * Clones a example example into the target directory and rewrites its package name.\n * When `cloneInfo.targetDir` is set the files are placed there; otherwise they\n * land in the current working directory (the `name: \".\"` case).\n */\nexport async function cloneExample(\n\tworkspace: Workspace,\n\tcloneInfo: {\n\t\trepository: string;\n\t\texample: string;\n\t\ttargetName: string;\n\t\ttargetDir?: string;\n\t},\n): Promise<void> {\n\tconst destDir = cloneInfo.targetDir ?? process.cwd();\n\tconst tempDir = path.join(process.cwd(), \".arkenv-temp\");\n\tawait workspace.mkdir(tempDir, true);\n\n\t// Ensure destination directory exists (a no-op when targeting cwd).\n\tif (cloneInfo.targetDir) {\n\t\tawait workspace.mkdir(destDir, true);\n\t}\n\n\ttry {\n\t\t// Clone sparsely\n\t\tawait workspace.execute(\"git\", [\n\t\t\t\"clone\",\n\t\t\t\"--filter=blob:none\",\n\t\t\t\"--sparse\",\n\t\t\tcloneInfo.repository,\n\t\t\ttempDir,\n\t\t]);\n\n\t\t// Checkout the specific example\n\t\tconst examplePath = `examples/${cloneInfo.example}`;\n\t\tawait workspace.execute(\"git\", [\n\t\t\t\"-C\",\n\t\t\ttempDir,\n\t\t\t\"sparse-checkout\",\n\t\t\t\"set\",\n\t\t\texamplePath,\n\t\t]);\n\n\t\t// Move files to destination directory\n\t\tconst fullExamplePath = path.join(tempDir, examplePath);\n\n\t\t// Preflight check: check if any files/directories from the example collide with existing ones in the destination\n\t\tconst entries = await fsp.readdir(fullExamplePath);\n\t\tconst collisions: string[] = [];\n\t\tfor (const entry of entries) {\n\t\t\tconst destPath = path.join(destDir, entry);\n\t\t\tif (await workspace.exists(destPath)) {\n\t\t\t\tcollisions.push(entry);\n\t\t\t}\n\t\t}\n\t\tif (collisions.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Scaffolding into a non-empty directory failed. The following paths already exist: ${collisions.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tawait copyDirectoryContents(fullExamplePath, destDir);\n\n\t\t// Remove any copied lockfiles to ensure clean install with target package manager\n\t\tconst lockfiles = [\n\t\t\t\"package-lock.json\",\n\t\t\t\"pnpm-lock.yaml\",\n\t\t\t\"yarn.lock\",\n\t\t\t\"bun.lockb\",\n\t\t\t\"bun.lock\",\n\t\t];\n\t\tfor (const lockfile of lockfiles) {\n\t\t\tawait fsp.rm(path.join(destDir, lockfile), { force: true });\n\t\t}\n\n\t\t// Update package.json name\n\t\tconst pkgPath = path.join(destDir, \"package.json\");\n\t\tif (await workspace.exists(pkgPath)) {\n\t\t\tconst pkgContent = await workspace.readFile(pkgPath);\n\t\t\tconst pkg = JSON.parse(pkgContent);\n\t\t\tpkg.name = cloneInfo.targetName;\n\t\t\tdelete pkg.packageManager;\n\t\t\tawait workspace.writeFile(pkgPath, JSON.stringify(pkg, null, 2));\n\t\t}\n\t} finally {\n\t\t// Cleanup temp dir\n\t\tawait fsp.rm(tempDir, { recursive: true, force: true });\n\t}\n}\n\n/**\n * Copies the direct contents of a source directory into a destination directory.\n */\nasync function copyDirectoryContents(source: string, destination: string) {\n\tconst entries = await fsp.readdir(source);\n\tawait Promise.all(\n\t\tentries.map((entry) =>\n\t\t\tfsp.cp(path.join(source, entry), path.join(destination, entry), {\n\t\t\t\trecursive: true,\n\t\t\t\tforce: false,\n\t\t\t}),\n\t\t),\n\t);\n}\n","import dedent from \"dedent\";\nimport { code } from \"@/shared/visuals\";\nimport type { ScaffoldingPlan } from \"./plan\";\n\n/**\n * Build the package manager command used to install dependencies or run a bare install.\n *\n * @param pm The package manager name (e.g. `\"pnpm\"`, `\"yarn\"`, `\"bun\"`, or npm fallback)\n * @param deps The dependency names to add; pass an empty array to run a bare install\n * @returns A tuple of `[executable, args]` ready to pass to a child-process spawn call\n */\nexport function getInstallCommand(\n\tpm: string,\n\tdeps: string[],\n): [string, string[]] {\n\tconst isAdding = deps.length > 0;\n\tswitch (pm) {\n\t\tcase \"pnpm\":\n\t\t\treturn [\"pnpm\", [isAdding ? \"add\" : \"install\", ...deps]];\n\t\tcase \"yarn\":\n\t\t\treturn [\"yarn\", [isAdding ? \"add\" : \"install\", ...deps]];\n\t\tcase \"bun\":\n\t\t\treturn [\"bun\", [isAdding ? \"add\" : \"install\", ...deps]];\n\t\tdefault:\n\t\t\treturn [\"npm\", [\"install\", ...deps]];\n\t}\n}\n\n/**\n * Build the final next-steps note shown after a scaffolding run.\n *\n * When the AI skill is already installed, returns a short prompt to use the\n * `/arkenv` slash command. Otherwise constructs a numbered checklist tailored\n * to the project's framework, layout, and codegen settings.\n *\n * @param plan The scaffolding plan produced by the planner\n * @param skillInstalled Whether the ArkEnv AI skill was installed during this run\n * @param nextjsConfigBootstrapped Whether the Next.js config was already wrapped with `withArkEnv`\n * @returns An object with a `title` and a multi-line `message` string\n */\nexport function getNextStepsNote(\n\tplan: ScaffoldingPlan,\n\tskillInstalled: boolean,\n\tnextjsConfigBootstrapped?: boolean,\n): { message: string; title: string } {\n\tif (skillInstalled || plan.metadata.skillDetected) {\n\t\tconst isNextjsWithCodegen =\n\t\t\tplan.metadata.framework === \"nextjs\" && !plan.metadata.disableCodegen;\n\t\tconst isNuxtWithCodegen =\n\t\t\tplan.metadata.framework === \"nuxt\" && !plan.metadata.disableCodegen;\n\t\tconst needsManualConfig = isNextjsWithCodegen && !nextjsConfigBootstrapped;\n\n\t\tlet message = dedent`\n\t\t\t\tInside your AI assistant (e.g. Claude Code), use:\n\t\t\t\t${code(\"/arkenv\")} - automatically refine your schema and configure integrations.\n\t\t\t`;\n\n\t\tif (needsManualConfig) {\n\t\t\tmessage += \"\\n\\n\";\n\t\t\tmessage += `Also, wrap your Next.js config with ${code(\"withArkEnv\")}:\\n`;\n\t\t\tmessage += ` ${code('import { withArkEnv } from \"@arkenv/nextjs/config\";')}\\n`;\n\t\t\tif (plan.metadata.layout === \"strict\") {\n\t\t\t\tmessage += ` ${code(\"export default withArkEnv(nextConfig);\")}\\n`;\n\t\t\t\tmessage += `Import and use: ${code(`import { env } from \"${plan.metadata.importPath}/client\"`)} (client) or ${code(`import { env } from \"${plan.metadata.importPath}/server\"`)} (server)\\n`;\n\t\t\t} else {\n\t\t\t\tmessage += ` ${code(\"export default withArkEnv(nextConfig);\")}\\n`;\n\t\t\t\tmessage += `Import and use: ${code(`import { env } from \"${plan.metadata.importPath}\"`)}\\n`;\n\t\t\t}\n\t\t} else if (isNuxtWithCodegen) {\n\t\t\tmessage += \"\\n\\n\";\n\t\t\tif (plan.metadata.layout === \"strict\") {\n\t\t\t\tmessage += `Import and use: ${code(`import { env } from \"${plan.metadata.importPath}/client\"`)} (client) or ${code(`import { env } from \"${plan.metadata.importPath}/server\"`)} (server)\\n`;\n\t\t\t} else {\n\t\t\t\tmessage += `Import and use: ${code(`import { env } from \"${plan.metadata.importPath}\"`)}\\n`;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\ttitle: \"Next steps\",\n\t\t};\n\t}\n\n\tconst dlx = plan.skill?.dlxCommand.join(\" \") || \"npx\";\n\tconst packageName = plan.skill?.packageName || \"yamcodes/arkenv\";\n\n\tlet message = \"\";\n\tlet step = 1;\n\n\tlet displayLocation = plan.metadata.displayPath;\n\tif (plan.metadata.layout === \"strict\") {\n\t\tconst lastDot = displayLocation.lastIndexOf(\".\");\n\t\tconst base =\n\t\t\tlastDot !== -1 ? displayLocation.slice(0, lastDot) : displayLocation;\n\t\tdisplayLocation = `${base}/client.ts, ${base}/server.ts, and ${base}/internal/shared.ts`;\n\t}\n\n\tmessage += `${step++}. Check ${code(displayLocation)} and refine your environment schema.\\n`;\n\n\tconst isNextjsWithCodegen =\n\t\tplan.metadata.framework === \"nextjs\" && !plan.metadata.disableCodegen;\n\tconst needsManualConfig = isNextjsWithCodegen && !nextjsConfigBootstrapped;\n\n\tif (plan.metadata.framework === \"nextjs\") {\n\t\tif (plan.metadata.layout === \"strict\") {\n\t\t\tif (plan.metadata.disableCodegen) {\n\t\t\t\tmessage += `${step++}. Import and use: ${code(`import { env } from \"${plan.metadata.importPath}/client\"`)} (client) or ${code(`import { env } from \"${plan.metadata.importPath}/server\"`)} (server)\\n`;\n\t\t\t} else {\n\t\t\t\tif (needsManualConfig) {\n\t\t\t\t\tmessage += `${step++}. Wrap your Next.js config with ${code(\"withArkEnv\")} inside ${code(\"next.config.ts\")}:\\n`;\n\t\t\t\t\tmessage += ` ${code('import { withArkEnv } from \"@arkenv/nextjs/config\";')}\\n`;\n\t\t\t\t\tmessage += ` ${code(\"export default withArkEnv(nextConfig);\")}\\n`;\n\t\t\t\t}\n\t\t\t\tmessage += `${step++}. Import and use: ${code(`import { env } from \"${plan.metadata.importPath}/client\"`)} (client) or ${code(`import { env } from \"${plan.metadata.importPath}/server\"`)} (server)\\n`;\n\t\t\t}\n\t\t} else if (plan.metadata.disableCodegen) {\n\t\t\tmessage += `${step++}. Import and use: ${code(`import { env } from \"${plan.metadata.importPath}\"`)}\\n`;\n\t\t} else {\n\t\t\tif (needsManualConfig) {\n\t\t\t\tmessage += `${step++}. Wrap your Next.js config with ${code(\"withArkEnv\")} inside ${code(\"next.config.ts\")}:\\n`;\n\t\t\t\tmessage += ` ${code('import { withArkEnv } from \"@arkenv/nextjs/config\";')}\\n`;\n\t\t\t\tmessage += ` ${code(\"export default withArkEnv(nextConfig);\")}\\n`;\n\t\t\t}\n\t\t\tmessage += `${step++}. Import and use: ${code(`import { env } from \"${plan.metadata.importPath}\"`)}\\n`;\n\t\t}\n\t} else if (plan.metadata.layout === \"strict\") {\n\t\tmessage += `${step++}. Import and use: ${code(`import { env } from \"${plan.metadata.importPath}/client\"`)} (client) or ${code(`import { env } from \"${plan.metadata.importPath}/server\"`)} (server)\\n`;\n\t} else {\n\t\tmessage += `${step++}. Import and use: ${code(`import { env } from \"${plan.metadata.importPath}\"`)}\\n`;\n\t}\n\n\tmessage += `${step++}. (Recommended) Install the AI skill: ${code(`${dlx} skills add ${packageName}`)}\\n`;\n\tmessage += ` Then run ${code(\"/arkenv\")} inside your AI assistant to finish.`;\n\n\treturn {\n\t\tmessage,\n\t\ttitle: \"Next steps\",\n\t};\n}\n","import path from \"node:path\";\nimport { isMap, parseDocument } from \"yaml\";\nimport { code, symbol } from \"@/shared/visuals\";\nimport { cloneExample } from \"./cloner\";\nimport type { Reporter, ScaffoldingPlan, Workspace } from \"./plan\";\nimport { getInstallCommand, getNextStepsNote } from \"./utils\";\n\nconst APPROVED_PNPM_BUILDS = [\"esbuild\"];\n\n/**\n * Executes a ScaffoldingPlan by performing workspace modifications,\n * installing dependencies, and bootstrapping framework configurations.\n */\nexport class Executor {\n\t/**\n\t * Creates an executor with workspace operations and reporting for CLI users.\n\t */\n\tconstructor(\n\t\tprivate workspace: Workspace,\n\t\tprivate reporter: Reporter,\n\t) {}\n\n\t/**\n\t * Applies a scaffolding plan to the workspace and reports next steps for CLI users.\n\t */\n\tasync execute(plan: ScaffoldingPlan) {\n\t\tconst s = this.reporter.spinner();\n\t\ts.start(\"Scaffolding ArkEnv configuration...\");\n\n\t\ttry {\n\t\t\t// 0. Handle project cloning for New Project Flow\n\t\t\tif (plan.clone) {\n\t\t\t\ts.stop(\"Starting new project scaffolding...\");\n\t\t\t\tthis.reporter.step(`Cloning example ${code(plan.clone.example)}...`);\n\n\t\t\t\tawait cloneExample(this.workspace, plan.clone);\n\n\t\t\t\ts.start(\"Scaffolding complete, finalizing...\");\n\t\t\t}\n\n\t\t\t// 1. Create directories and write files\n\t\t\tfor (const file of plan.files) {\n\t\t\t\tif (file.action === \"append\") {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!plan.bootstrap ||\n\t\t\t\t\t\t(plan.bootstrap.framework !== \"vite\" &&\n\t\t\t\t\t\t\tplan.bootstrap.framework !== \"bun-fullstack\")\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t\t\t`Skipping safe-append for ${code(path.basename(file.path))}: unsupported framework.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst success = await this.workspace.safeAppend(\n\t\t\t\t\t\tfile.path,\n\t\t\t\t\t\tfile.content,\n\t\t\t\t\t\tplan.bootstrap.framework,\n\t\t\t\t\t);\n\t\t\t\t\tif (success) {\n\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t`Appended ArkEnv types to ${code(path.basename(file.path))}.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t`${code(path.basename(file.path))} already contains ArkEnv types.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tfile.action === \"create\" &&\n\t\t\t\t\t(await this.workspace.exists(file.path))\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tawait this.workspace.mkdir(path.dirname(file.path), true);\n\t\t\t\tawait this.workspace.writeFile(file.path, file.content);\n\n\t\t\t\tif (file.label === \"environment schema\") {\n\t\t\t\t\t// We'll report this at the end or as we go\n\t\t\t\t} else if (file.label?.includes(\"types\")) {\n\t\t\t\t\tconst actionLabel =\n\t\t\t\t\t\tfile.action === \"overwrite\" ? \"Updated\" : \"Created\";\n\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t`${actionLabel} ${code(path.basename(file.path))} for typesafe environment variables.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ts.stop(\"Configuration scaffolded!\");\n\n\t\t\t// 1b. Write arkenv schema pointer to package.json\n\t\t\tawait this.configurePackageJsonArkenv(\n\t\t\t\tplan.install?.cwd ?? plan.cwd,\n\t\t\t\tplan.metadata,\n\t\t\t);\n\n\t\t\t// 2. Install dependencies\n\t\t\tif (plan.install && process.env.SKIP_INSTALL !== \"true\") {\n\t\t\t\tif (plan.install.packageManager === \"pnpm\") {\n\t\t\t\t\tawait this.configurePnpmBuilds(plan.install.cwd ?? plan.cwd);\n\t\t\t\t}\n\t\t\t\tthis.reporter.step(\n\t\t\t\t\t`Installing dependencies with ${code(plan.install.packageManager)}...`,\n\t\t\t\t);\n\t\t\t\tconst [cmd, args] = getInstallCommand(\n\t\t\t\t\tplan.install.packageManager,\n\t\t\t\t\tplan.install.dependencies,\n\t\t\t\t);\n\t\t\t\tawait this.workspace.execute(cmd, args, plan.install.cwd ?? plan.cwd);\n\t\t\t}\n\n\t\t\t// 3. TS Config\n\t\t\tlet tsConfigUpdated = false;\n\t\t\tif (plan.tsConfig) {\n\t\t\t\tconst tsResult = await this.workspace.updateTsConfigToStrict(\n\t\t\t\t\tplan.tsConfig.path,\n\t\t\t\t);\n\t\t\t\tif (tsResult.status === \"updated\") {\n\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t`Enforced strict: true in your ${code(tsResult.file!)}`,\n\t\t\t\t\t);\n\t\t\t\t\ttsConfigUpdated = true;\n\t\t\t\t} else if (tsResult.status === \"error\") {\n\t\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t\t`Could not automatically update ${code(tsResult.file || \"tsconfig.json\")}. Please ensure 'strict: true' is set manually.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 4. Framework bootstrapping\n\t\t\tlet frameworkConfigBootstrapped = false;\n\t\t\tif (plan.bootstrap) {\n\t\t\t\tif (plan.bootstrap.framework === \"vite\") {\n\t\t\t\t\tconst viteConfigPath = await this.workspace.findViteConfig(plan.cwd);\n\t\t\t\t\tif (viteConfigPath) {\n\t\t\t\t\t\tthis.reporter.step(\"Bootstrapping Vite plugin...\");\n\t\t\t\t\t\tconst result = await this.workspace.bootstrapViteConfig(\n\t\t\t\t\t\t\tviteConfigPath,\n\t\t\t\t\t\t\tplan.bootstrap.importPath || \"./src/env\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (result.success) {\n\t\t\t\t\t\t\tif (result.updated) {\n\t\t\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t\t\t`Updated ${code(path.basename(viteConfigPath))}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t\t\t\t`Could not automatically update ${code(path.basename(viteConfigPath))}: ${result.error}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t\t`Please add ${code(\"@arkenv/vite-plugin\")} manually.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t`No Vite config found - please add ${code(\"@arkenv/vite-plugin\")} to your Vite config manually.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (plan.bootstrap.framework === \"bun-fullstack\") {\n\t\t\t\t\tconst bunConfigPath = await this.workspace.findBunConfig(plan.cwd);\n\t\t\t\t\tconst result = await this.workspace.bootstrapBunConfig(\n\t\t\t\t\t\tbunConfigPath,\n\t\t\t\t\t\tplan.bootstrap.bunFeatures,\n\t\t\t\t\t);\n\t\t\t\t\tif (result.success && result.instructions) {\n\t\t\t\t\t\tthis.reporter.info(result.instructions);\n\t\t\t\t\t} else if (!result.success) {\n\t\t\t\t\t\tthis.reporter.error(result.error || \"Bun bootstrap failed\");\n\t\t\t\t\t}\n\t\t\t\t} else if (plan.bootstrap.framework === \"nextjs\") {\n\t\t\t\t\t// Only generate env.gen.ts when codegen is enabled\n\t\t\t\t\tif (!plan.bootstrap.disableCodegen) {\n\t\t\t\t\t\tthis.reporter.step(\"Generating Next.js environment bindings...\");\n\t\t\t\t\t\tconst script = `import('@arkenv/nextjs/config').then(({ runCodegen }) => { const path = require('path'); const schemaPath = path.resolve(process.cwd(), '${plan.metadata.displayPath}'); const outputPath = path.join(path.dirname(schemaPath), 'generated', 'env.gen.ts'); runCodegen(schemaPath, outputPath); }).catch(err => { console.error(err); process.exit(1); });`;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait this.workspace.execute(\"node\", [\"-e\", script], plan.cwd);\n\t\t\t\t\t\t\tthis.reporter.info(`Generated ${code(\"env.gen.ts\")} for Next.js`);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t\t\t\t`Failed to automatically generate ${code(\"env.gen.ts\")}. It will be generated when you start your dev server.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Bootstrap Next.js config wrapper\n\t\t\t\t\tif (plan.bootstrap.wrapNextjsConfig !== false) {\n\t\t\t\t\t\tthis.reporter.step(\"Bootstrapping Next.js config...\");\n\t\t\t\t\t\tconst nextjsConfigPath = await this.workspace.findNextjsConfig(\n\t\t\t\t\t\t\tplan.cwd,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (nextjsConfigPath) {\n\t\t\t\t\t\t\tconst result = await this.workspace.bootstrapNextjsConfig(\n\t\t\t\t\t\t\t\tnextjsConfigPath,\n\t\t\t\t\t\t\t\tplan.bootstrap.disableCodegen,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (result.success) {\n\t\t\t\t\t\t\t\tif (result.updated) {\n\t\t\t\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t\t\t\t`Updated ${code(path.basename(nextjsConfigPath))}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tframeworkConfigBootstrapped = true;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t\t\t\t`${code(path.basename(nextjsConfigPath))} already uses withArkEnv`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tframeworkConfigBootstrapped = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t\t\t\t\t`Could not automatically update ${code(path.basename(nextjsConfigPath))}: ${result.error}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t\t`No Next.js config found. Please wrap your config with ${code(\"withArkEnv\")} manually.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (plan.bootstrap.framework === \"nuxt\") {\n\t\t\t\t\t// Bootstrap Nuxt config wrapper\n\t\t\t\t\tthis.reporter.step(\"Bootstrapping Nuxt config...\");\n\t\t\t\t\tconst nuxtConfigPath = await this.workspace.findNuxtConfig(plan.cwd);\n\t\t\t\t\tif (nuxtConfigPath) {\n\t\t\t\t\t\tconst result =\n\t\t\t\t\t\t\tawait this.workspace.bootstrapNuxtConfig(nuxtConfigPath);\n\t\t\t\t\t\tif (result.success) {\n\t\t\t\t\t\t\tif (result.updated) {\n\t\t\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t\t\t`Updated ${code(path.basename(nuxtConfigPath))}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t\t\t`${code(path.basename(nuxtConfigPath))} already registers @arkenv/nuxt/module`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tframeworkConfigBootstrapped = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t\t\t\t`Could not automatically update ${code(path.basename(nuxtConfigPath))}: ${result.error}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.reporter.info(\n\t\t\t\t\t\t\t`No Nuxt config found. Please register ${code(\"@arkenv/nuxt/module\")} manually.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 5. Skill\n\t\t\tlet skillInstalled = false;\n\t\t\tif (plan.skill && process.env.SKIP_INSTALL !== \"true\") {\n\t\t\t\tthis.reporter.step(\"Installing ArkEnv agent skill...\");\n\t\t\t\ttry {\n\t\t\t\t\tconst [cmd, ...baseArgs] = plan.skill.dlxCommand;\n\t\t\t\t\tconst args = [...baseArgs, \"skills\", \"add\", plan.skill.packageName];\n\t\t\t\t\tif (plan.skill.isYes) {\n\t\t\t\t\t\targs.push(\"--yes\");\n\t\t\t\t\t}\n\t\t\t\t\tawait this.workspace.execute(cmd, args, plan.cwd);\n\t\t\t\t\tskillInstalled = true;\n\t\t\t\t} catch (err: unknown) {\n\t\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\t\tthis.reporter.warn(`Failed to install ArkEnv AI skill: ${message}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 6. Final reporting\n\t\t\tconst note = getNextStepsNote(\n\t\t\t\tplan,\n\t\t\t\tskillInstalled,\n\t\t\t\tframeworkConfigBootstrapped,\n\t\t\t);\n\t\t\tthis.reporter.note(note.message, note.title);\n\n\t\t\tif (plan.metadata.layout === \"strict\") {\n\t\t\t\tconst oldEnvPath = path.resolve(plan.cwd, plan.metadata.displayPath);\n\t\t\t\tif (await this.workspace.exists(oldEnvPath)) {\n\t\t\t\t\tconst displayFile = plan.metadata.displayPath;\n\t\t\t\t\tconst baseName = path.basename(\n\t\t\t\t\t\tdisplayFile,\n\t\t\t\t\t\tpath.extname(displayFile),\n\t\t\t\t\t);\n\t\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t\t`Found existing single-file schema at ${code(displayFile)}. You can delete it after updating your imports to point to your new ${code(`${baseName}/client`)} and ${code(`${baseName}/server`)}.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.reporter.finish(\n\t\t\t\t`${symbol} ArkEnv scaffolding complete. Happy coding!`,\n\t\t\t\t{\n\t\t\t\t\tpath: plan.metadata.displayPath,\n\t\t\t\t\tframework: plan.metadata.framework,\n\t\t\t\t\tvalidator: plan.metadata.validator,\n\t\t\t\t\tpackageManager: plan.metadata.packageManager,\n\t\t\t\t\ttsConfigUpdated,\n\t\t\t\t\tskillInstalled,\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (error) {\n\t\t\ts.stop(\"Scaffolding failed.\");\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Configure pnpm-specific whitelisting for esbuild and other native build dependencies.\n\t *\n\t * @param installCwd The directory where the installation will run\n\t */\n\tprivate async configurePnpmBuilds(installCwd: string): Promise<void> {\n\t\tconst packageJsonPath = path.join(installCwd, \"package.json\");\n\t\tif (await this.workspace.exists(packageJsonPath)) {\n\t\t\ttry {\n\t\t\t\tconst pkgContent = await this.workspace.readFile(packageJsonPath);\n\t\t\t\tconst pkg = JSON.parse(pkgContent);\n\t\t\t\tpkg.pnpm = pkg.pnpm || {};\n\t\t\t\tpkg.pnpm.onlyBuiltDependencies = pkg.pnpm.onlyBuiltDependencies || [];\n\t\t\t\tfor (const dep of APPROVED_PNPM_BUILDS) {\n\t\t\t\t\tif (!pkg.pnpm.onlyBuiltDependencies.includes(dep)) {\n\t\t\t\t\t\tpkg.pnpm.onlyBuiltDependencies.push(dep);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait this.workspace.writeFile(\n\t\t\t\t\tpackageJsonPath,\n\t\t\t\t\tJSON.stringify(pkg, null, 2) + \"\\n\",\n\t\t\t\t);\n\t\t\t} catch (e) {\n\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t`Could not update package.json with pnpm whitelisting: ${e}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst pnpmWorkspacePath = path.join(installCwd, \"pnpm-workspace.yaml\");\n\t\tlet workspaceContent = \"\";\n\t\tif (await this.workspace.exists(pnpmWorkspacePath)) {\n\t\t\ttry {\n\t\t\t\tworkspaceContent = await this.workspace.readFile(pnpmWorkspacePath);\n\t\t\t} catch {\n\t\t\t\t// Ignore and treat as empty/non-existent\n\t\t\t}\n\t\t}\n\n\t\tconst updatedContent = this.updatePnpmWorkspaceYaml(workspaceContent);\n\t\ttry {\n\t\t\tawait this.workspace.writeFile(pnpmWorkspacePath, updatedContent);\n\t\t} catch (e) {\n\t\t\tthis.reporter.warn(`Could not write pnpm-workspace.yaml: ${e}`);\n\t\t}\n\t}\n\n\t/**\n\t * Update the content of a pnpm-workspace.yaml file to allow approved builds.\n\t *\n\t * @param content The original content of the pnpm-workspace.yaml file\n\t * @returns The updated content with allowBuilds populated\n\t */\n\tprivate updatePnpmWorkspaceYaml(content: string): string {\n\t\tconst doc = parseDocument(content || \"\");\n\n\t\tif (!doc.has(\"allowBuilds\")) {\n\t\t\tdoc.set(\"allowBuilds\", doc.createNode({}));\n\t\t}\n\n\t\tlet allowBuilds = doc.get(\"allowBuilds\");\n\n\t\tif (!isMap(allowBuilds)) {\n\t\t\tdoc.set(\"allowBuilds\", doc.createNode({}));\n\t\t\tallowBuilds = doc.get(\"allowBuilds\");\n\t\t}\n\n\t\tif (isMap(allowBuilds)) {\n\t\t\tfor (const dep of APPROVED_PNPM_BUILDS) {\n\t\t\t\tif (allowBuilds.get(dep) !== true) {\n\t\t\t\t\tallowBuilds.set(dep, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn String(doc);\n\t}\n\n\t/**\n\t * Persist the arkenv schema entry and layout strategy to package.json.\n\t *\n\t * @param installCwd The directory containing package.json.\n\t * @param metadata The scaffolding plan metadata.\n\t */\n\tprivate async configurePackageJsonArkenv(\n\t\tinstallCwd: string,\n\t\tmetadata: ScaffoldingPlan[\"metadata\"],\n\t): Promise<void> {\n\t\tconst packageJsonPath = path.join(installCwd, \"package.json\");\n\t\tif (await this.workspace.exists(packageJsonPath)) {\n\t\t\ttry {\n\t\t\t\tconst pkgContent = await this.workspace.readFile(packageJsonPath);\n\t\t\t\tconst pkg = JSON.parse(pkgContent);\n\t\t\t\tpkg.arkenv = {\n\t\t\t\t\tschema: metadata.displayPath,\n\t\t\t\t\tlayout: metadata.layout === \"strict\" ? \"strict\" : \"flat\",\n\t\t\t\t};\n\t\t\t\tawait this.workspace.writeFile(\n\t\t\t\t\tpackageJsonPath,\n\t\t\t\t\tJSON.stringify(pkg, null, 2) + \"\\n\",\n\t\t\t\t);\n\t\t\t} catch (e) {\n\t\t\t\tthis.reporter.warn(\n\t\t\t\t\t`Could not update package.json with arkenv schema entry: ${e}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Per-example `.env` defaults used when scaffolding a new project from a\n * repository example. Falls back to the framework strategy when an example\n * is not listed here.\n */\nexport const exampleEnvDefaults: Record<string, Record<string, string>> = {\n\tbasic: {\n\t\tHOST: \"localhost\",\n\t\tPORT: \"3000\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"basic-js\": {\n\t\tHOST: \"localhost\",\n\t\tPORT: \"3000\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"with-bun\": {\n\t\tHOST: \"localhost\",\n\t\tPORT: \"3000\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"with-nextjs\": {\n\t\tDATABASE_URL: \"postgres://localhost:5432/mydb\",\n\t\tNEXT_PUBLIC_API_URL: \"https://api.example.com\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"with-nextjs-strict\": {\n\t\tDATABASE_URL: \"postgres://localhost:5432/mydb\",\n\t\tNEXT_PUBLIC_API_URL: \"https://api.example.com\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"with-nextjs-zod\": {\n\t\tDATABASE_URL: \"postgres://localhost:5432/mydb\",\n\t\tNEXT_PUBLIC_API_URL: \"https://api.example.com\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"with-nuxt\": {\n\t\tDATABASE_URL: \"postgres://localhost:5432/mydb\",\n\t\tNUXT_PUBLIC_API_URL: \"https://api.example.com\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"with-vite-react\": {\n\t\tPORT: \"3000\",\n\t\tVITE_MY_VAR: \"hello\",\n\t\tVITE_MY_NUMBER: \"42\",\n\t\tVITE_MY_BOOLEAN: \"true\",\n\t},\n\t\"with-vite-react-zod\": {\n\t\tPORT: \"3000\",\n\t\tVITE_MY_VAR: \"hello\",\n\t\tVITE_MY_NUMBER: \"42\",\n\t\tVITE_MY_BOOLEAN: \"true\",\n\t},\n\t\"with-bun-react\": {\n\t\tBUN_PUBLIC_API_URL: \"https://api.example.com\",\n\t\tBUN_PUBLIC_DEBUG: \"true\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"with-zod\": {\n\t\tHOST: \"localhost\",\n\t\tPORT: \"3000\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"with-valibot\": {\n\t\tHOST: \"localhost\",\n\t\tPORT: \"3000\",\n\t\tNODE_ENV: \"development\",\n\t},\n\t\"mix-and-match\": {\n\t\tDATABASE_URL: \"https://postgres.example.com/db\",\n\t\tAPI_KEY: \"12345678901234567890123456789012\",\n\t\tNODE_ENV: \"development\",\n\t\tPORT: \"3000\",\n\t\tDEBUG: \"false\",\n\t},\n};\n\n/**\n * Resolve example-specific env defaults for new project scaffolding.\n *\n * @param example The example template name.\n * @param frameworkFallback Defaults from the framework strategy when the\n * example has no dedicated entry.\n * @returns Env var defaults for the example.\n */\nexport function getEnvDefaultsForExample(\n\texample: string,\n\tframeworkFallback: () => Record<string, string>,\n): Record<string, string> {\n\treturn exampleEnvDefaults[example] ?? frameworkFallback();\n}\n","/**\n * Returns the appropriate 'dlx' or 'exec' command for the given package manager.\n *\n * @param pm The package manager name (e.g., \"pnpm\", \"bun\").\n * @returns The dlx command array.\n */\nexport function getDlxCommand(pm: string): string[] {\n\tswitch (pm) {\n\t\tcase \"pnpm\":\n\t\t\treturn [\"pnpm\", \"dlx\"];\n\t\tcase \"yarn\":\n\t\t\treturn [\"yarn\", \"dlx\"];\n\t\tcase \"bun\":\n\t\t\treturn [\"bunx\"];\n\t\tdefault:\n\t\t\treturn [\"npx\"];\n\t}\n}\n","import type { CodegenFrameworkConfig } from \"@/features/scaffold/frameworks/codegen-config\";\nimport {\n\tformatPresetEndMarker,\n\tformatPresetStartMarker,\n\tgetPresetKeys,\n\ttype HostPreset,\n} from \"@/features/scaffold/presets\";\nimport type { Dialect } from \"@/features/scaffold/validators/dialects\";\n\n/**\n * Options for assembling a Next.js / Nuxt single-file (flat or nested) template.\n */\nexport type CodegenLayoutOptions = {\n\tenvKeys?: string[] | undefined;\n\tdialect: Dialect;\n\tconfig: CodegenFrameworkConfig;\n\t/**\n\t * Generated env import path when codegen is enabled (Next.js).\n\t */\n\timportPath?: string | undefined;\n\tdisableCodegen?: boolean | undefined;\n\t/**\n\t * Layout selection. `\"simple\"` is a quarantined nested (server/client/shared)\n\t * path kept for test parity; primary codegen path is flat when unset/flat.\n\t */\n\tlayout?: \"strict\" | \"simple\" | \"flat\" | undefined;\n\t/**\n\t * Hosting provider preset - appended to defaults when `envKeys` is empty.\n\t */\n\thostPreset?: HostPreset | undefined;\n};\n\n/**\n * Append hosting-preset field lines onto codegen field buckets.\n *\n * @param buckets Mutable server/client/shared field lines\n * @param dialect Validator dialect\n * @param clientPrefix Framework client prefix\n * @param hostPreset Selected hosting preset\n */\nfunction appendPresetCodegenFields(\n\tbuckets: {\n\t\tserverFields: string[];\n\t\tclientFields: string[];\n\t},\n\tdialect: Dialect,\n\tclientPrefix: string,\n\thostPreset: HostPreset | undefined,\n): void {\n\tif (!hostPreset || hostPreset === \"none\") return;\n\tconst presetKeys = getPresetKeys(hostPreset, clientPrefix);\n\tfor (const key of presetKeys) {\n\t\tif (clientPrefix && key.startsWith(clientPrefix)) {\n\t\t\tbuckets.clientFields.push(\n\t\t\t\t`\\t\\t${dialect.formatCodegenField(key, \"client\", clientPrefix, hostPreset)}`,\n\t\t\t);\n\t\t} else {\n\t\t\tbuckets.serverFields.push(\n\t\t\t\t`\\t\\t${dialect.formatCodegenField(key, \"server\", clientPrefix, hostPreset)}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Extract env key names from dialect field lines (`KEY: ...`).\n *\n * @param fields Schema field source lines\n * @returns Key names in declaration order\n */\nfunction extractFieldKeyNames(fields: string[]): string[] {\n\tconst keys: string[] = [];\n\tfor (const field of fields) {\n\t\tconst match = field.trim().match(/^([a-zA-Z0-9_]+)\\s*:/);\n\t\tif (match) {\n\t\t\tkeys.push(match[1]);\n\t\t}\n\t}\n\treturn keys;\n}\n\n/**\n * Build `runtimeEnv` field lines for `--no-codegen` Next.js / Nuxt templates.\n *\n * When explicit `envKeys` are absent, includes default client/`NODE_ENV` entries\n * plus any client-prefixed keys present in {@link clientFields} (e.g. hosting\n * preset keys appended after defaults).\n *\n * @param envKeys Explicit env keys when provided\n * @param clientPrefix Framework client prefix\n * @param clientFields Populated client schema field lines\n * @param extraKeys Additional keys to include (e.g. flat-layout exposed shared keys)\n * @returns Indented `key: process.env.key,` lines\n */\nfunction buildNoCodegenRuntimeEnvFields(\n\tenvKeys: string[] | undefined,\n\tclientPrefix: string,\n\tclientFields: string[],\n\textraKeys: string[] = [],\n): string[] {\n\tconst runtimeEnvFields: string[] = [];\n\tconst seen = new Set<string>();\n\n\tconst push = (key: string) => {\n\t\tif (seen.has(key)) return;\n\t\tseen.add(key);\n\t\truntimeEnvFields.push(`\\t\\t${key}: process.env.${key},`);\n\t};\n\n\tif (envKeys && envKeys.length > 0) {\n\t\tfor (const key of envKeys) {\n\t\t\tif (\n\t\t\t\tkey.startsWith(clientPrefix) ||\n\t\t\t\tkey === \"NODE_ENV\" ||\n\t\t\t\textraKeys.includes(key)\n\t\t\t) {\n\t\t\t\tpush(key);\n\t\t\t}\n\t\t}\n\t\treturn runtimeEnvFields;\n\t}\n\n\tpush(`${clientPrefix}API_URL`);\n\tpush(\"NODE_ENV\");\n\tfor (const key of extractFieldKeyNames(clientFields)) {\n\t\tpush(key);\n\t}\n\tfor (const key of extraKeys) {\n\t\tpush(key);\n\t}\n\treturn runtimeEnvFields;\n}\n\n/**\n * Assemble a Next.js / Nuxt env schema template (flat or nested).\n *\n * Owns structural assembly - key categorisation, imports, JSDoc, flat vs nested\n * (`layout === \"simple\"`), and runtimeEnv injection. The dialect supplies only\n * field lines and extra imports.\n *\n * @param options Layout and dialect inputs\n * @returns Generated TypeScript source\n */\nexport function assembleCodegenTemplate(options: CodegenLayoutOptions): string {\n\tconst {\n\t\tenvKeys,\n\t\tdialect,\n\t\tconfig,\n\t\timportPath: nextjsImportPath,\n\t\tdisableCodegen,\n\t\tlayout,\n\t\thostPreset,\n\t} = options;\n\n\tconst { clientPrefix } = config;\n\n\tconst serverFields: string[] = [];\n\tconst clientFields: string[] = [];\n\tconst sharedFields: string[] = [];\n\n\tif (envKeys && envKeys.length > 0) {\n\t\tfor (const key of envKeys) {\n\t\t\tif (key.startsWith(clientPrefix)) {\n\t\t\t\tclientFields.push(\n\t\t\t\t\t`\\t\\t${dialect.formatCodegenField(key, \"client\", clientPrefix, hostPreset)}`,\n\t\t\t\t);\n\t\t\t} else if (key === \"NODE_ENV\") {\n\t\t\t\tsharedFields.push(\n\t\t\t\t\t`\\t\\t${dialect.formatCodegenField(key, \"shared\", clientPrefix, hostPreset)}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tserverFields.push(\n\t\t\t\t\t`\\t\\t${dialect.formatCodegenField(key, \"server\", clientPrefix, hostPreset)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst defaults = dialect.getDefaultCodegenFields(clientPrefix);\n\t\tserverFields.push(...defaults.serverFields);\n\t\tclientFields.push(...defaults.clientFields);\n\t\tsharedFields.push(...defaults.sharedFields);\n\t\tappendPresetCodegenFields(\n\t\t\t{ serverFields, clientFields },\n\t\t\tdialect,\n\t\t\tclientPrefix,\n\t\t\thostPreset,\n\t\t);\n\t}\n\n\tconst useFlatLayout = layout !== \"simple\" && layout !== \"strict\";\n\n\tif (useFlatLayout) {\n\t\treturn assembleFlatLayout({\n\t\t\tserverFields,\n\t\t\tclientFields,\n\t\t\tsharedFields,\n\t\t\tenvKeys,\n\t\t\tdialect,\n\t\t\tconfig,\n\t\t\tnextjsImportPath,\n\t\t\tdisableCodegen,\n\t\t\thostPreset,\n\t\t});\n\t}\n\n\treturn assembleNestedLayout({\n\t\tserverFields,\n\t\tclientFields,\n\t\tsharedFields,\n\t\tenvKeys,\n\t\tdialect,\n\t\tconfig,\n\t\tnextjsImportPath,\n\t\tdisableCodegen,\n\t\tlayout,\n\t\thostPreset,\n\t});\n}\n\ntype FieldBuckets = {\n\tserverFields: string[];\n\tclientFields: string[];\n\tsharedFields: string[];\n\tenvKeys?: string[] | undefined;\n\tdialect: Dialect;\n\tconfig: CodegenFrameworkConfig;\n\tnextjsImportPath?: string | undefined;\n\tdisableCodegen?: boolean | undefined;\n\tlayout?: \"strict\" | \"simple\" | \"flat\" | undefined;\n\thostPreset?: HostPreset | undefined;\n};\n\nfunction assembleFlatLayout(params: FieldBuckets): string {\n\tconst {\n\t\tserverFields,\n\t\tclientFields,\n\t\tsharedFields,\n\t\tenvKeys,\n\t\tdialect,\n\t\tconfig,\n\t\tnextjsImportPath,\n\t\tdisableCodegen,\n\t\thostPreset,\n\t} = params;\n\tconst {\n\t\tclientPrefix,\n\t\tpackageName: pkgName,\n\t\tdisplayName: frameworkName,\n\t} = config;\n\tconst framework = config.id;\n\tconst extraImports = dialect.extraImport;\n\tconst presetKeys = getPresetKeys(hostPreset ?? \"none\", clientPrefix);\n\n\tlet flatFields: string[];\n\tif (hostPreset && hostPreset !== \"none\" && presetKeys.length > 0) {\n\t\tconst rawFields = [...serverFields, ...clientFields, ...sharedFields];\n\t\tconst userFields = rawFields\n\t\t\t.filter((f) => {\n\t\t\t\tconst key = f.trim().match(/^([a-zA-Z0-9_]+)\\s*:/)?.[1];\n\t\t\t\treturn key && !presetKeys.includes(key);\n\t\t\t})\n\t\t\t.map((field) => field.replace(/^\\t\\t/, \"\\t\"));\n\n\t\tconst presetFieldLines: string[] = [];\n\t\tfor (const key of presetKeys) {\n\t\t\tconst role =\n\t\t\t\tclientPrefix && key.startsWith(clientPrefix)\n\t\t\t\t\t? \"client\"\n\t\t\t\t\t: key === \"NODE_ENV\"\n\t\t\t\t\t\t? \"shared\"\n\t\t\t\t\t\t: \"server\";\n\t\t\tpresetFieldLines.push(\n\t\t\t\t`\\t${dialect.formatCodegenField(key, role, clientPrefix, hostPreset)}`,\n\t\t\t);\n\t\t}\n\n\t\tflatFields = [\n\t\t\t...userFields,\n\t\t\t...(userFields.length > 0 ? [\"\"] : []),\n\t\t\t`\\t${formatPresetStartMarker(hostPreset)}`,\n\t\t\t...presetFieldLines,\n\t\t\t`\\t${formatPresetEndMarker(hostPreset)}`,\n\t\t];\n\t} else {\n\t\tconst allFields = [...serverFields, ...clientFields, ...sharedFields];\n\t\tflatFields = allFields.map((field) => field.replace(/^\\t\\t/, \"\\t\"));\n\t}\n\n\tconst exposedKeyNames: string[] = [];\n\tfor (const field of sharedFields) {\n\t\tconst match = field.trim().match(/^([a-zA-Z0-9_]+)\\s*:/);\n\t\tif (match) {\n\t\t\tconst key = match[1];\n\t\t\tif (key !== \"NODE_ENV\") {\n\t\t\t\texposedKeyNames.push(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst optionParts: string[] = [];\n\tif (exposedKeyNames.length > 0) {\n\t\toptionParts.push(\n\t\t\t`\\texposeToClient: [${exposedKeyNames.map((k) => `\"${k}\"`).join(\", \")}]`,\n\t\t);\n\t}\n\n\tif (disableCodegen && framework === \"nextjs\") {\n\t\tconst runtimeEnvFields = buildNoCodegenRuntimeEnvFields(\n\t\t\tenvKeys,\n\t\t\tclientPrefix,\n\t\t\tclientFields,\n\t\t\texposedKeyNames,\n\t\t);\n\t\toptionParts.push(`\\truntimeEnv: {\\n${runtimeEnvFields.join(\"\\n\")}\\n\\t}`);\n\t}\n\n\tconst optionsStr =\n\t\toptionParts.length > 0 ? `, {\\n${optionParts.join(\",\\n\")}\\n}` : \"\";\n\n\tconst flatImportPath =\n\t\tframework === \"nuxt\"\n\t\t\t? pkgName\n\t\t\t: disableCodegen\n\t\t\t\t? pkgName\n\t\t\t\t: nextjsImportPath || \"./generated/env.gen\";\n\n\tconst imports = [\n\t\t`import arkenv from \"${flatImportPath}\";`,\n\t\t...(extraImports ? [extraImports] : []),\n\t].join(\"\\n\");\n\n\tconst flatDocsHint =\n\t\tframework === \"nuxt\"\n\t\t\t? `In ${frameworkName}, use \\`${pkgName}\\` to validate variables at build-time and runtime.`\n\t\t\t: `In ${frameworkName}, use the generated \\`arkenv\\` from \\`env.gen.ts\\` to validate variables.`;\n\n\treturn `${imports}\n\n/**\n * Environment variable schema.\n * ${flatDocsHint}\n * Enforces client/server separation and prevents secret leaks.\n */\nexport const env = arkenv({\n${flatFields.join(\"\\n\")}\n}${optionsStr});\n`;\n}\n\nfunction assembleNestedLayout(params: FieldBuckets): string {\n\tconst {\n\t\tserverFields,\n\t\tclientFields,\n\t\tsharedFields,\n\t\tenvKeys,\n\t\tdialect,\n\t\tconfig,\n\t\tnextjsImportPath,\n\t\tdisableCodegen,\n\t\tlayout,\n\t} = params;\n\tconst {\n\t\tclientPrefix,\n\t\tpackageName: pkgName,\n\t\tdisplayName: frameworkName,\n\t} = config;\n\tconst framework = config.id;\n\tconst extraImports = dialect.extraImport;\n\n\tconst sections: string[] = [];\n\tif (serverFields.length > 0) {\n\t\tsections.push(`\\tserver: {\\n${serverFields.join(\"\\n\")}\\n\\t}`);\n\t}\n\tif (clientFields.length > 0) {\n\t\tsections.push(`\\tclient: {\\n${clientFields.join(\"\\n\")}\\n\\t}`);\n\t}\n\tif (sharedFields.length > 0) {\n\t\tsections.push(`\\tshared: {\\n${sharedFields.join(\"\\n\")}\\n\\t}`);\n\t}\n\n\tif (disableCodegen || (framework === \"nuxt\" && layout === \"simple\")) {\n\t\tconst runtimeEnvFields = buildNoCodegenRuntimeEnvFields(\n\t\t\tenvKeys,\n\t\t\tclientPrefix,\n\t\t\tclientFields,\n\t\t);\n\t\tif (framework !== \"nuxt\") {\n\t\t\tsections.push(`\\truntimeEnv: {\\n${runtimeEnvFields.join(\"\\n\")}\\n\\t}`);\n\t\t}\n\n\t\tconst imports = [\n\t\t\t`import arkenv from \"${pkgName}\";`,\n\t\t\t...(extraImports ? [extraImports] : []),\n\t\t].join(\"\\n\");\n\n\t\treturn `${imports}\n\n/**\n * Environment variable schema.\n * In ${frameworkName}, use \\`${pkgName}\\` to validate variables at build-time and runtime.\n * Enforces client/server separation and prevents secret leaks.\n */\nexport const env = arkenv({\n${sections.join(\",\\n\")},\n});\n`;\n\t}\n\n\tconst imports = [\n\t\t`import arkenv from \"${nextjsImportPath || \"./generated/env.gen\"}\";`,\n\t\t...(extraImports ? [extraImports] : []),\n\t].join(\"\\n\");\n\n\treturn `${imports}\n\n/**\n * Environment variable schema.\n * In ${frameworkName}, use the generated \\`arkenv\\` from \\`env.gen.ts\\` to validate variables.\n * Enforces client/server separation and prevents secret leaks.\n */\nexport const env = arkenv({\n${sections.join(\",\\n\")},\n});\n`;\n}\n","import { getCodegenConfig } from \"@/features/scaffold/frameworks/codegen-config\";\nimport { assembleCodegenTemplate } from \"@/features/scaffold/frameworks/layouts\";\nimport {\n\tformatPresetEndMarker,\n\tformatPresetStartMarker,\n\tgetPresetKeys,\n} from \"@/features/scaffold/presets\";\nimport type { ScaffoldContext } from \"@/features/scaffold/scaffold-context\";\nimport type { Dialect } from \"./dialects\";\n\n/**\n * Assemble a single-file env schema template for the active framework.\n *\n * Frameworks/layout assemblers own structure; the dialect supplies field lines\n * and imports only. Hosting-preset keys are merged in without replacing\n * framework defaults when no explicit env keys were provided.\n *\n * @param dialect Validator dialect\n * @param keys Environment variable keys (empty uses dialect defaults)\n * @param context Shared scaffold context\n * @returns Template source with trailing newline\n */\nexport function assembleSimpleFromDialect(\n\tdialect: Dialect,\n\tkeys: string[],\n\tcontext: ScaffoldContext,\n): string {\n\tconst presetKeys = getPresetKeys(\n\t\tcontext.hostPreset ?? \"none\",\n\t\tcontext.clientPrefix,\n\t);\n\n\tconst codegenConfig = getCodegenConfig(context.framework);\n\tif (codegenConfig) {\n\t\tconst combinedKeys =\n\t\t\tkeys.length > 0\n\t\t\t\t? Array.from(new Set([...keys, ...presetKeys]))\n\t\t\t\t: undefined;\n\t\treturn `${assembleCodegenTemplate({\n\t\t\t...(combinedKeys !== undefined ? { envKeys: combinedKeys } : {}),\n\t\t\tdialect,\n\t\t\tconfig: codegenConfig,\n\t\t\t...(context.nextjsImportPath !== undefined && {\n\t\t\t\timportPath: context.nextjsImportPath,\n\t\t\t}),\n\t\t\tdisableCodegen: context.disableCodegen,\n\t\t\t...(context.layout !== undefined && { layout: context.layout }),\n\t\t\t...(context.hostPreset !== undefined && {\n\t\t\t\thostPreset: context.hostPreset,\n\t\t\t}),\n\t\t})}\\n`;\n\t}\n\n\tlet schemaFields: string;\n\tif (\n\t\tcontext.hostPreset &&\n\t\tcontext.hostPreset !== \"none\" &&\n\t\tpresetKeys.length > 0\n\t) {\n\t\tconst startMarker = `\\t\\t${formatPresetStartMarker(context.hostPreset)}`;\n\t\tconst endMarker = `\\t\\t${formatPresetEndMarker(context.hostPreset)}`;\n\t\tconst presetFields = dialect.formatSimpleSchemaFields(\n\t\t\tpresetKeys,\n\t\t\tcontext.clientPrefix,\n\t\t\tcontext.hostPreset,\n\t\t);\n\t\tconst userKeys = keys.filter((k) => !presetKeys.includes(k));\n\t\tif (userKeys.length > 0) {\n\t\t\tconst userFields = dialect.formatSimpleSchemaFields(\n\t\t\t\tuserKeys,\n\t\t\t\tcontext.clientPrefix,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tschemaFields = `${userFields}\\n\\n${startMarker}\\n${presetFields}\\n${endMarker}`;\n\t\t} else {\n\t\t\tschemaFields = `${dialect.defaultSimpleSchemaFields}\\n\\n${startMarker}\\n${presetFields}\\n${endMarker}`;\n\t\t}\n\t} else if (keys.length > 0) {\n\t\tschemaFields = dialect.formatSimpleSchemaFields(\n\t\t\tkeys,\n\t\t\tcontext.clientPrefix,\n\t\t\tcontext.hostPreset,\n\t\t);\n\t} else {\n\t\tschemaFields = dialect.defaultSimpleSchemaFields;\n\t}\n\n\treturn `${dialect.assembleVanilla(schemaFields)}\\n`;\n}\n","import { getCodegenConfig } from \"@/features/scaffold/frameworks/codegen-config\";\nimport type { ScaffoldContext } from \"@/features/scaffold/scaffold-context\";\nimport type { StrictEnvTemplates, ValidatorStrategy } from \"./types\";\n\n/**\n * Format an array of schema field strings as a braced object literal.\n *\n * Returns `\"{}\"` for an empty field list. Non-empty fields are each trimmed\n * and joined with newlines at the given indentation level.\n *\n * @param fields The schema field strings to format.\n * @param indent The indentation prefix to use for inner lines.\n * @returns A formatted object literal string.\n */\nexport function formatSchemaObject(fields: string[], indent = \"\\t\\t\"): string {\n\tif (fields.length === 0) {\n\t\treturn \"{}\";\n\t}\n\treturn `{\\n${indent}${fields.map((f) => f.trim()).join(`\\n${indent}`)}\\n${indent.slice(1)}}`;\n}\n\ntype CategorizedFields = {\n\tserverFields: string[];\n\tclientFields: string[];\n\tsharedFields: string[];\n\truntimeEnvFields: string[];\n};\n\n/**\n * Categorize env keys into server, client, shared, and runtime fields.\n *\n * @param keys Environment variable keys to categorize.\n * @param context Shared scaffold context.\n * @param formatField Validator-specific field formatter.\n * @returns Categorized schema and runtime env fields.\n */\nexport function categorizeEnvKeys(\n\tkeys: string[],\n\tcontext: ScaffoldContext,\n\tformatField: ValidatorStrategy[\"formatField\"],\n): CategorizedFields {\n\tconst serverFields: string[] = [];\n\tconst clientFields: string[] = [];\n\tconst sharedFields: string[] = [];\n\tconst runtimeEnvFields: string[] = [];\n\n\tfor (const key of keys) {\n\t\tif (key.startsWith(context.clientPrefix)) {\n\t\t\tclientFields.push(formatField(key, \"client\", context));\n\t\t\truntimeEnvFields.push(`${key}: process.env.${key},`);\n\t\t} else if (key === \"NODE_ENV\") {\n\t\t\tsharedFields.push(formatField(key, \"shared\", context));\n\t\t\truntimeEnvFields.push(`${key}: process.env.${key},`);\n\t\t} else {\n\t\t\tserverFields.push(formatField(key, \"server\", context));\n\t\t}\n\t}\n\n\treturn { serverFields, clientFields, sharedFields, runtimeEnvFields };\n}\n\ntype StrictTemplateConfig = {\n\tshared: string;\n\tclientCodegen: string;\n\tclientNoCodegen: string;\n\tserver: string;\n};\n\n/**\n * Assemble strict-layout templates from pre-built file bodies.\n *\n * @param config Validator-specific template bodies for each strict file.\n * @param context Shared scaffold context.\n * @returns Shared, client, and server templates with trailing newlines.\n */\nexport function assembleStrictTemplates(\n\tconfig: StrictTemplateConfig,\n\tcontext: ScaffoldContext,\n): StrictEnvTemplates {\n\treturn {\n\t\tshared: `${config.shared}\\n`,\n\t\tclient: `${isStrictCodegenDisabled(context) ? config.clientNoCodegen : config.clientCodegen}\\n`,\n\t\tserver: `${config.server}\\n`,\n\t};\n}\n\n/**\n * Resolve the framework package name used in strict-layout imports.\n *\n * @param context Shared scaffold context.\n * @returns The package import path for the active framework integration.\n */\nexport function getFrameworkPackageName(context: ScaffoldContext): string {\n\treturn (\n\t\tcontext.packageName ??\n\t\tgetCodegenConfig(context.framework)?.packageName ??\n\t\t\"@arkenv/nextjs\"\n\t);\n}\n\n/**\n * Build runtime env options for strict client templates when codegen is disabled.\n *\n * @param runtimeEnvFields Runtime env mapping field strings.\n * @param context Shared scaffold context.\n * @returns A runtimeEnv options block or an empty string for Nuxt.\n */\nexport function buildRuntimeEnvOptions(\n\truntimeEnvFields: string[],\n\tcontext: ScaffoldContext,\n): string {\n\tif (context.framework === \"nuxt\") {\n\t\treturn \"\";\n\t}\n\treturn `,\\n\\t\\truntimeEnv: {\\n\\t\\t\\t${runtimeEnvFields.map((f) => f.trim()).join(\"\\n\\t\\t\\t\")}\\n\\t\\t}`;\n}\n\n/**\n * Determine whether strict-layout templates should disable codegen.\n *\n * @param context Shared scaffold context.\n * @returns True when codegen should be disabled for strict templates.\n */\nexport function isStrictCodegenDisabled(context: ScaffoldContext): boolean {\n\treturn context.disableCodegen || context.framework === \"nuxt\";\n}\n\n/**\n * Select the client template import path based on codegen settings.\n *\n * @param context Shared scaffold context.\n * @returns The import path for the generated or integration client entry.\n */\nexport function getClientImportPath(context: ScaffoldContext): string {\n\tif (isStrictCodegenDisabled(context)) {\n\t\treturn `${getFrameworkPackageName(context)}/client`;\n\t}\n\treturn context.nextjsImportPath || \"./generated/env.gen\";\n}\n","import {\n\tformatPresetEndMarker,\n\tformatPresetStartMarker,\n\tgetPresetKeys,\n} from \"@/features/scaffold/presets\";\nimport type { ScaffoldContext } from \"@/features/scaffold/scaffold-context\";\nimport type { Dialect } from \"./dialects\";\nimport {\n\tassembleStrictTemplates,\n\tbuildRuntimeEnvOptions,\n\tcategorizeEnvKeys,\n\tformatSchemaObject,\n\tgetClientImportPath,\n\tgetFrameworkPackageName,\n} from \"./shared\";\nimport type { StrictEnvTemplates } from \"./types\";\n\n/**\n * Append hosting-preset keys onto an existing strict field bucket set.\n *\n * @param fields Mutable field buckets from defaults or key categorisation\n * @param dialect Validator dialect\n * @param context Shared scaffold context\n */\nfunction appendPresetStrictFields(\n\tfields: {\n\t\tserverFields: string[];\n\t\tclientFields: string[];\n\t\tsharedFields: string[];\n\t\truntimeEnvFields: string[];\n\t},\n\tdialect: Dialect,\n\tcontext: ScaffoldContext,\n): void {\n\tif (!context.hostPreset || context.hostPreset === \"none\") return;\n\tconst presetKeys = getPresetKeys(context.hostPreset, context.clientPrefix);\n\tconst clientPresetFields: string[] = [];\n\tconst serverPresetFields: string[] = [];\n\n\tfor (const key of presetKeys) {\n\t\tif (context.clientPrefix && key.startsWith(context.clientPrefix)) {\n\t\t\tclientPresetFields.push(\n\t\t\t\tdialect.formatStrictField(\n\t\t\t\t\tkey,\n\t\t\t\t\t\"client\",\n\t\t\t\t\tcontext.clientPrefix,\n\t\t\t\t\tcontext.hostPreset,\n\t\t\t\t),\n\t\t\t);\n\t\t\tfields.runtimeEnvFields.push(`${key}: process.env.${key},`);\n\t\t} else {\n\t\t\tserverPresetFields.push(\n\t\t\t\tdialect.formatStrictField(\n\t\t\t\t\tkey,\n\t\t\t\t\t\"server\",\n\t\t\t\t\tcontext.clientPrefix,\n\t\t\t\t\tcontext.hostPreset,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tif (clientPresetFields.length > 0) {\n\t\tfields.clientFields.push(\n\t\t\tformatPresetStartMarker(`${context.hostPreset}:client`),\n\t\t\t...clientPresetFields,\n\t\t\tformatPresetEndMarker(`${context.hostPreset}:client`),\n\t\t);\n\t}\n\tif (serverPresetFields.length > 0) {\n\t\tfields.serverFields.push(\n\t\t\tformatPresetStartMarker(`${context.hostPreset}:server`),\n\t\t\t...serverPresetFields,\n\t\t\tformatPresetEndMarker(`${context.hostPreset}:server`),\n\t\t);\n\t}\n}\n\n/**\n * Build strict-layout templates from a validator dialect and scaffold context.\n *\n * Shared assembler for all dialects - only field formatting and import/wrapper\n * differences come from the dialect. Preset keys merge with defaults rather\n * than replacing them.\n *\n * @param dialect Validator dialect\n * @param keys Environment variable keys (empty uses dialect defaults)\n * @param context Shared scaffold context\n * @returns Shared, client, and server templates\n */\nexport function assembleStrictFromDialect(\n\tdialect: Dialect,\n\tkeys: string[],\n\tcontext: ScaffoldContext,\n): StrictEnvTemplates {\n\tconst pkgName = getFrameworkPackageName(context);\n\tconst clientImportPath = getClientImportPath(context);\n\tconst presetKeys = getPresetKeys(\n\t\tcontext.hostPreset ?? \"none\",\n\t\tcontext.clientPrefix,\n\t);\n\n\tconst fields =\n\t\tkeys.length > 0\n\t\t\t? categorizeEnvKeys(\n\t\t\t\t\tArray.from(new Set([...keys, ...presetKeys])),\n\t\t\t\t\tcontext,\n\t\t\t\t\t(key, role) =>\n\t\t\t\t\t\tdialect.formatStrictField(\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\trole,\n\t\t\t\t\t\t\tcontext.clientPrefix,\n\t\t\t\t\t\t\tcontext.hostPreset,\n\t\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t: (() => {\n\t\t\t\t\tconst defaults = dialect.getDefaultStrictFields(context.clientPrefix);\n\t\t\t\t\tappendPresetStrictFields(defaults, dialect, context);\n\t\t\t\t\treturn defaults;\n\t\t\t\t})();\n\n\tconst { serverFields, clientFields, sharedFields, runtimeEnvFields } = fields;\n\n\tconst runtimeEnvOptions = buildRuntimeEnvOptions(runtimeEnvFields, context);\n\tconst sharedObject = formatSchemaObject(sharedFields, \"\\t\");\n\tconst clientObject = formatSchemaObject(clientFields, \"\\t\\t\");\n\tconst serverObject = formatSchemaObject(serverFields, \"\\t\\t\");\n\tconst extra = dialect.strictExtraImports;\n\n\tconst autoExtendServerFrameworks = new Set([\"nuxt\", \"nextjs\"]);\n\tconst usesServerAutoExtend = autoExtendServerFrameworks.has(\n\t\tcontext.framework,\n\t);\n\n\tconst nuxtClientTemplate = `import arkenv from \"${clientImportPath}\";\n${extra}\nexport const env = arkenv(\n\t${clientObject},\n);`;\n\n\tconst manualClientCodegen = `import arkenv from \"${clientImportPath}\";\n${extra}import { SharedSchema } from \"./internal/shared\";\n\nexport const env = arkenv(\n\t${clientObject},\n\t{\n\t\textends: [SharedSchema],\n\t},\n);`;\n\n\tconst manualClientNoCodegen = `import arkenv from \"${clientImportPath}\";\n${extra}import { SharedSchema } from \"./internal/shared\";\n\nexport const env = arkenv(\n\t${clientObject},\n\t{\n\t\textends: [SharedSchema]${runtimeEnvOptions}\n\t},\n);`;\n\n\tconst sharedDocComment =\n\t\tcontext.framework === \"nuxt\"\n\t\t\t? `/**\n * @internal 🛑 INTERNAL SCHEMA ONLY.\n * Do not import this directly. Import \\`env\\` from \\`./client\\` or \\`./server\\` instead.\n * Automatically picked up by \\`@arkenv/nuxt/client\\` when \\`extends\\` is omitted;\n * \\`@arkenv/nuxt/server\\` includes it through the composed client env.\n */`\n\t\t\t: `/**\n * @internal 🛑 INTERNAL SCHEMA ONLY.\n * Do not import this directly. Import \\`env\\` from \\`./client\\` or \\`./server\\` instead.\n */`;\n\n\treturn assembleStrictTemplates(\n\t\t{\n\t\t\tshared: `${dialect.sharedImports}\n\n${sharedDocComment}\nexport const SharedSchema = ${dialect.wrapSharedSchema(sharedObject)};`,\n\n\t\t\tclientCodegen:\n\t\t\t\tcontext.framework === \"nuxt\" ? nuxtClientTemplate : manualClientCodegen,\n\n\t\t\tclientNoCodegen:\n\t\t\t\tcontext.framework === \"nuxt\"\n\t\t\t\t\t? nuxtClientTemplate\n\t\t\t\t\t: manualClientNoCodegen,\n\n\t\t\tserver: usesServerAutoExtend\n\t\t\t\t? `import arkenv from \"${pkgName}/server\";\n${extra}\nexport const env = arkenv(\n\t${serverObject},\n);`\n\t\t\t\t: `import arkenv from \"${pkgName}/server\";\n${extra}import { env as clientEnv } from \"./client\";\n\nexport const env = arkenv(\n\t${serverObject},\n\t{\n\t\textends: [clientEnv],\n\t},\n);`,\n\t\t},\n\t\tcontext,\n\t);\n}\n","import { assembleSimpleFromDialect } from \"./assemble-simple\";\nimport { assembleStrictFromDialect } from \"./assemble-strict\";\nimport type { Dialect } from \"./dialects\";\nimport { DIALECTS } from \"./dialects\";\nimport type { ValidatorStrategy } from \"./types\";\n\n/**\n * Build a {@link ValidatorStrategy} from a dialect.\n *\n * @param dialect Validator dialect supplying field formatting and wrappers.\n * @returns Strategy implementing simple and strict template generation.\n */\nexport function createValidatorStrategy(dialect: Dialect): ValidatorStrategy {\n\treturn {\n\t\tformatField(key, role, context) {\n\t\t\treturn dialect.formatStrictField(\n\t\t\t\tkey,\n\t\t\t\trole,\n\t\t\t\tcontext.clientPrefix,\n\t\t\t\tcontext.hostPreset,\n\t\t\t);\n\t\t},\n\n\t\tgetSimpleTemplate(keys, context) {\n\t\t\treturn assembleSimpleFromDialect(dialect, keys, context);\n\t\t},\n\n\t\tgetStrictTemplates(keys, context) {\n\t\t\treturn assembleStrictFromDialect(dialect, keys, context);\n\t\t},\n\t};\n}\n\nexport const arktypeStrategy = createValidatorStrategy(DIALECTS.arktype);\nexport const zodStrategy = createValidatorStrategy(DIALECTS.zod);\nexport const valibotStrategy = createValidatorStrategy(DIALECTS.valibot);\n","import {\n\tarktypeStrategy,\n\tvalibotStrategy,\n\tzodStrategy,\n} from \"./create-strategy\";\nimport type { ValidatorRegistry } from \"./types\";\n\n/**\n * Exhaustive registry of validator strategies.\n */\nexport const VALIDATORS = {\n\tarktype: arktypeStrategy,\n\tzod: zodStrategy,\n\tvalibot: valibotStrategy,\n} satisfies ValidatorRegistry;\n\nexport type { Dialect } from \"./dialects\";\nexport { DIALECTS } from \"./dialects\";\nexport type { StrictEnvTemplates, ValidatorStrategy } from \"./types\";\n","import path from \"node:path\";\nimport { shake } from \"radashi\";\nimport { FRAMEWORKS } from \"./frameworks\";\nimport { getEnvDefaultsForExample } from \"./frameworks/example-env-defaults\";\nimport type { CollectedState, ScaffoldingPlan } from \"./plan\";\nimport { mergeEnvKeysWithPreset } from \"./presets\";\nimport { getDlxCommand } from \"./scaffold\";\nimport { VALIDATORS } from \"./validators\";\n\n/**\n * Create a ScaffoldingPlan based on the collected workspace state.\n *\n * @param state The collected state of the workspace.\n * @returns The resulting scaffolding plan.\n */\nexport function createPlan(state: CollectedState): ScaffoldingPlan {\n\tif (state.mode === \"new\") {\n\t\treturn createNewProjectPlan(state);\n\t}\n\treturn createExistingProjectPlan(state);\n}\n\nfunction isIgnored(lines: string[], target: string): boolean {\n\treturn lines.some((line) => {\n\t\tconst commentIndex = line.indexOf(\"#\");\n\t\tconst clean = (\n\t\t\tcommentIndex !== -1 ? line.slice(0, commentIndex) : line\n\t\t).trim();\n\t\tif (!clean) return false;\n\n\t\tif (clean === target || clean === `/${target}`) return true;\n\n\t\tif (clean.includes(\"*\")) {\n\t\t\tconst regexStr = `^${clean.replace(/\\./g, \"\\\\.\").replace(/\\*/g, \".*\").replace(/^\\//, \"/?\")}$`;\n\t\t\ttry {\n\t\t\t\tconst regex = new RegExp(regexStr);\n\t\t\t\treturn regex.test(target) || regex.test(`/${target}`);\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\n/**\n * Format env defaults as key=value lines.\n *\n * @param defaults Env var name to value map.\n * @returns Serialized .env content with trailing newline.\n */\nexport function formatEnvContent(defaults: Record<string, string>): string {\n\treturn (\n\t\tObject.entries(defaults)\n\t\t\t.map(([k, v]) => `${k}=${v}`)\n\t\t\t.join(\"\\n\") + \"\\n\"\n\t);\n}\n\n/**\n * Plan .env and .env.example files for existing projects.\n *\n * @param state Collected workspace state.\n * @param plan The scaffolding plan being built.\n */\nexport function planEnvFiles(\n\tstate: CollectedState,\n\tplan: ScaffoldingPlan,\n): void {\n\tconst { cwd, options, existingFiles } = state;\n\tconst frameworkStrategy = FRAMEWORKS[options.framework];\n\tconst envPath = path.join(cwd, \".env\");\n\tconst envExamplePath = path.join(cwd, \".env.example\");\n\tconst hasEnv = existingFiles.includes(envPath);\n\tconst hasEnvExample = existingFiles.includes(envExamplePath);\n\n\tconst combinedEnvKeys = mergeEnvKeysWithPreset(\n\t\toptions.envKeys,\n\t\toptions.hostPreset,\n\t\tframeworkStrategy.clientPrefix,\n\t);\n\n\tif (!hasEnv) {\n\t\tconst content =\n\t\t\toptions.envExampleContent !== undefined\n\t\t\t\t? options.envExampleContent\n\t\t\t\t: formatEnvContent(frameworkStrategy.getEnvDefaults(combinedEnvKeys));\n\t\tplan.files.push({\n\t\t\tpath: envPath,\n\t\t\tcontent,\n\t\t\taction: \"create\",\n\t\t\tlabel: \"local environment variables\",\n\t\t});\n\t}\n\n\tif (!hasEnvExample) {\n\t\tplan.files.push({\n\t\t\tpath: envExamplePath,\n\t\t\tcontent: formatEnvContent(\n\t\t\t\tframeworkStrategy.getEnvDefaults(combinedEnvKeys),\n\t\t\t),\n\t\t\taction: \"create\",\n\t\t\tlabel: \"environment variables template\",\n\t\t});\n\t}\n}\n\n/**\n * Plan .gitignore updates for existing projects.\n *\n * @param state Collected workspace state.\n * @param plan The scaffolding plan being built.\n */\nexport function planGitignoreFiles(\n\tstate: CollectedState,\n\tplan: ScaffoldingPlan,\n): void {\n\tconst { cwd, options, existingFiles } = state;\n\tconst gitignorePath = path.join(cwd, \".gitignore\");\n\tconst hasGitignore = existingFiles.includes(gitignorePath);\n\n\tif (hasGitignore && options.gitignoreContent !== undefined) {\n\t\tconst lines = options.gitignoreContent.split(/\\r?\\n/);\n\t\tconst hasEnv = isIgnored(lines, \".env\");\n\t\tconst hasEnvLocal = isIgnored(lines, \".env.local\");\n\n\t\tif (!hasEnv || !hasEnvLocal) {\n\t\t\tlet suffix = \"\\n# Environment variables\\n\";\n\t\t\tif (!hasEnv) suffix += \".env\\n\";\n\t\t\tif (!hasEnvLocal) suffix += \".env.local\\n\";\n\n\t\t\tconst newContent = options.gitignoreContent.endsWith(\"\\n\")\n\t\t\t\t? `${options.gitignoreContent}${suffix.trim()}\\n`\n\t\t\t\t: `${options.gitignoreContent}\\n${suffix.trim()}\\n`;\n\t\t\tplan.files.push({\n\t\t\t\tpath: gitignorePath,\n\t\t\t\tcontent: newContent,\n\t\t\t\taction: \"overwrite\",\n\t\t\t\tlabel: \".gitignore update\",\n\t\t\t});\n\t\t}\n\t} else if (!hasGitignore) {\n\t\tplan.files.push({\n\t\t\tpath: gitignorePath,\n\t\t\tcontent: \"# Environment variables\\n.env\\n.env.local\\n\",\n\t\t\taction: \"create\",\n\t\t\tlabel: \".gitignore file\",\n\t\t});\n\t}\n}\n\nfunction createBaseMetadata(\n\tstate: CollectedState,\n): ScaffoldingPlan[\"metadata\"] {\n\tconst { mode, options, packageManager } = state;\n\tconst projectName =\n\t\toptions.name && options.name !== \".\"\n\t\t\t? path.basename(options.name)\n\t\t\t: undefined;\n\n\treturn shake({\n\t\tdisplayPath: \"\",\n\t\tframework: options.framework,\n\t\tvalidator: options.validator,\n\t\tpackageManager,\n\t\timportPath: \"\",\n\t\tmode,\n\t\texample: options.example,\n\t\tname: projectName,\n\t\tlayout: options.layout,\n\t\tskillDetected: options.skillDetected,\n\t\tdisableCodegen: options.disableCodegen,\n\t}) as ScaffoldingPlan[\"metadata\"];\n}\n\nfunction planSkillInstall(state: CollectedState, plan: ScaffoldingPlan): void {\n\tif (!state.options.installSkill) {\n\t\treturn;\n\t}\n\n\tplan.skill = {\n\t\tdlxCommand: getDlxCommand(state.packageManager),\n\t\tpackageName: \"yamcodes/arkenv\",\n\t\tisYes: state.isYes,\n\t};\n}\n\n/**\n * Build a scaffolding plan for a new project cloned from an example.\n *\n * @param state Collected workspace state.\n * @returns The new-project scaffolding plan.\n */\nexport function createNewProjectPlan(state: CollectedState): ScaffoldingPlan {\n\tconst { options, packageManager, cwd } = state;\n\n\tif (!options.example) {\n\t\tthrow new Error(\"New project scaffolding requires an example.\");\n\t}\n\n\tconst targetDir =\n\t\toptions.name && options.name !== \".\"\n\t\t\t? path.join(cwd, options.name)\n\t\t\t: undefined;\n\tconst targetName =\n\t\toptions.name && options.name !== \".\"\n\t\t\t? path.basename(options.name)\n\t\t\t: path.basename(cwd);\n\n\tconst plan: ScaffoldingPlan = {\n\t\tfiles: [],\n\t\tcwd,\n\t\tmetadata: createBaseMetadata(state),\n\t\tclone: {\n\t\t\trepository: \"https://github.com/yamcodes/arkenv.git\",\n\t\t\texample: options.example,\n\t\t\ttargetName,\n\t\t\t...(targetDir !== undefined && { targetDir }),\n\t\t},\n\t\tinstall: {\n\t\t\tpackageManager,\n\t\t\tdependencies: [],\n\t\t\t...(targetDir !== undefined && { cwd: targetDir }),\n\t\t},\n\t};\n\n\tplanSkillInstall(state, plan);\n\n\tconst envContent = formatEnvContent(\n\t\tgetEnvDefaultsForExample(options.example, () =>\n\t\t\tFRAMEWORKS[options.framework].getEnvDefaults(),\n\t\t),\n\t);\n\tconst targetDirResolved = targetDir ?? cwd;\n\n\tplan.files.push(\n\t\t{\n\t\t\tpath: path.join(targetDirResolved, \".env\"),\n\t\t\tcontent: envContent,\n\t\t\taction: \"create\",\n\t\t\tlabel: \"local environment variables\",\n\t\t},\n\t\t{\n\t\t\tpath: path.join(targetDirResolved, \".env.example\"),\n\t\t\tcontent: envContent,\n\t\t\taction: \"create\",\n\t\t\tlabel: \"environment variables template\",\n\t\t},\n\t);\n\n\tplan.metadata.displayPath = \"./src/env.ts\";\n\tplan.metadata.importPath = \"./src/env\";\n\n\treturn plan;\n}\n\n/**\n * Build a scaffolding plan for an existing project.\n *\n * @param state Collected workspace state.\n * @returns The existing-project scaffolding plan.\n */\nexport function createExistingProjectPlan(\n\tstate: CollectedState,\n): ScaffoldingPlan {\n\tconst {\n\t\toptions,\n\t\tpackageManager,\n\t\ttsConfig,\n\t\tshouldUpdateTsConfig,\n\t\tcwd,\n\t\texistingFiles,\n\t} = state;\n\n\tconst frameworkStrategy = FRAMEWORKS[options.framework];\n\tconst validatorStrategy = VALIDATORS[options.validator];\n\tconst targetPath = path.resolve(cwd, options.path);\n\tconst targetDir = path.dirname(targetPath);\n\n\tconst plan: ScaffoldingPlan = {\n\t\tfiles: [],\n\t\tcwd,\n\t\tmetadata: createBaseMetadata(state),\n\t};\n\n\tconst fileParams = {\n\t\ttargetPath,\n\t\ttargetDir,\n\t\tcwd,\n\t\texistingFiles,\n\t\toverwriteEnvSchemaFile: options.overwriteEnvSchemaFile,\n\t\tpath: options.path,\n\t\ttsConfig,\n\t};\n\n\tplan.files.push(\n\t\t...frameworkStrategy.getSchemaFiles(validatorStrategy, options, fileParams),\n\t);\n\n\tplanEnvFiles(state, plan);\n\tplanGitignoreFiles(state, plan);\n\n\tconst basePkg =\n\t\toptions.framework === \"nextjs\" || options.framework === \"nuxt\"\n\t\t\t? undefined\n\t\t\t: options.validator === \"arktype\"\n\t\t\t\t? \"@arkenv/core\"\n\t\t\t\t: \"@arkenv/standard\";\n\n\tconst deps = [\n\t\t...(basePkg ? [basePkg] : []),\n\t\toptions.validator,\n\t\t...frameworkStrategy.getDependencies(options),\n\t];\n\tif (\n\t\tframeworkStrategy.requiresArktypePeer(options) &&\n\t\t!deps.includes(\"arktype\")\n\t) {\n\t\tdeps.push(\"arktype\");\n\t}\n\n\tplan.install = {\n\t\tpackageManager,\n\t\tdependencies: Array.from(new Set(deps)),\n\t};\n\n\tif (shouldUpdateTsConfig && tsConfig.file) {\n\t\tplan.tsConfig = {\n\t\t\tpath: path.resolve(cwd, tsConfig.file),\n\t\t\taction: \"strict\",\n\t\t};\n\t}\n\n\tplan.files.push(\n\t\t...frameworkStrategy.getTypeDefinitionFiles(options, fileParams),\n\t);\n\n\tconst bootstrap = frameworkStrategy.bootstrap(options);\n\tif (bootstrap) {\n\t\tplan.bootstrap = bootstrap;\n\t}\n\n\tplanSkillInstall(state, plan);\n\n\tconst relPath = path.relative(cwd, targetPath).replace(/\\\\/g, \"/\");\n\tconst displayPath = relPath.startsWith(\".\") ? relPath : `./${relPath}`;\n\tconst importPath = displayPath.replace(/\\.(ts|js|tsx|jsx)$/, \"\");\n\n\tplan.metadata.displayPath = displayPath;\n\tplan.metadata.importPath = importPath;\n\tif (plan.bootstrap) {\n\t\tplan.bootstrap.importPath = importPath;\n\t}\n\n\treturn plan;\n}\n","export type Example = {\n\tid: string;\n\tname: string;\n\tdescription?: string;\n\tframework: \"vite\" | \"bun-fullstack\" | \"vanilla\" | \"nextjs\";\n};\n\nexport type ExampleRegistry = {\n\texamples: Example[];\n};\n\nconst REGISTRY_URL =\n\t\"https://raw.githubusercontent.com/yamcodes/arkenv/main/examples/registry.json\";\n\nexport class RegistryClient {\n\t/**\n\t * Fetches the published example example registry, falling back to bundled defaults offline.\n\t */\n\tasync fetchRegistry(): Promise<ExampleRegistry> {\n\t\ttry {\n\t\t\tconst response = await fetch(REGISTRY_URL);\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Failed to fetch registry: ${response.statusText}`);\n\t\t\t}\n\t\t\treturn (await response.json()) as ExampleRegistry;\n\t\t} catch {\n\t\t\t// Fallback to a minimal registry if fetch fails or for offline use\n\t\t\treturn {\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"basic\",\n\t\t\t\t\t\tname: \"Basic\",\n\t\t\t\t\t\tdescription: \"A minimal ArkEnv setup in Node.js\",\n\t\t\t\t\t\tframework: \"vanilla\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"with-nextjs\",\n\t\t\t\t\t\tname: \"Next.js\",\n\t\t\t\t\t\tdescription: \"Minimal Next.js project with ArkType\",\n\t\t\t\t\t\tframework: \"nextjs\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"with-nextjs-zod\",\n\t\t\t\t\t\tname: \"Next.js (Zod)\",\n\t\t\t\t\t\tdescription: \"Next.js with @arkenv/nextjs/standard and Zod\",\n\t\t\t\t\t\tframework: \"nextjs\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"with-vite-react\",\n\t\t\t\t\t\tname: \"React + Vite\",\n\t\t\t\t\t\tframework: \"vite\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"with-vite-react-zod\",\n\t\t\t\t\t\tname: \"React + Vite (Zod)\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"React + Vite with @arkenv/vite-plugin/standard and Zod\",\n\t\t\t\t\t\tframework: \"vite\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"with-bun\",\n\t\t\t\t\t\tname: \"Bun (Vanilla)\",\n\t\t\t\t\t\tdescription: \"Minimal Bun project with ArkType\",\n\t\t\t\t\t\tframework: \"vanilla\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"with-bun-react\",\n\t\t\t\t\t\tname: \"React + Bun fullstack dev server\",\n\t\t\t\t\t\tframework: \"bun-fullstack\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"with-zod\",\n\t\t\t\t\t\tname: \"Zod\",\n\t\t\t\t\t\tdescription: \"ArkEnv with Zod in Node.js\",\n\t\t\t\t\t\tframework: \"vanilla\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"with-valibot\",\n\t\t\t\t\t\tname: \"Valibot\",\n\t\t\t\t\t\tdescription: \"ArkEnv with Valibot in Node.js\",\n\t\t\t\t\t\tframework: \"vanilla\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"mix-and-match\",\n\t\t\t\t\t\tname: \"Mix and Match\",\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"ArkEnv with mixed ArkType, Zod, and Valibot in Node.js\",\n\t\t\t\t\t\tframework: \"vanilla\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n}\n","import path from \"node:path\";\nimport { shake } from \"radashi\";\nimport { code } from \"@/cli/ui\";\nimport { type CollectedState, createPlan, Executor } from \"@/features/scaffold\";\nimport type { HostPreset } from \"@/features/scaffold/presets\";\nimport { RegistryClient } from \"@/shared/clients\";\nimport { ERROR_CODES } from \"@/shared/errors\";\nimport type {\n\tLoggerPort,\n\tProjectScannerPort,\n\tPromptPort,\n\tWorkspacePort,\n} from \"@/shared/ports\";\n\n/**\n * Input parameters for the 'init' command.\n */\nexport type InitInput = {\n\tisYes: boolean;\n\tisForce: boolean;\n\tisQuiet: boolean;\n\tisAgent: boolean;\n\tisStrict?: boolean;\n\tisSimple?: boolean;\n\tisFlat?: boolean;\n\texample?: string;\n\tname?: string;\n\tnoCodegen?: boolean;\n\thostPreset?: HostPreset;\n};\n\n/**\n * Use case for initializing ArkEnv in a new or existing project.\n */\nexport class InitUseCase {\n\t/**\n\t * Creates the init use case with adapters for prompting, scanning, and filesystem work.\n\t */\n\tconstructor(\n\t\tprivate readonly logger: LoggerPort,\n\t\tprivate readonly workspace: WorkspacePort,\n\t\tprivate readonly prompt: PromptPort,\n\t\tprivate readonly scanner: ProjectScannerPort,\n\t\tprivate readonly registry = new RegistryClient(),\n\t) {}\n\n\t/**\n\t * Collects init options, creates a scaffolding plan, and executes it.\n\t */\n\tasync execute(input: InitInput): Promise<boolean> {\n\t\tconst state = await this.collect(input);\n\t\tif (!state) return false;\n\n\t\tconst plan = createPlan(state);\n\t\tconst executor = new Executor(this.workspace, this.logger);\n\n\t\ttry {\n\t\t\tawait executor.execute(plan);\n\t\t} catch (error) {\n\t\t\tthis.logger.fatal(\"Scaffolding failed.\", error);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Chooses the existing project or new project collection flow for the current directory.\n\t */\n\tprivate async collect(input: InitInput): Promise<CollectedState | null> {\n\t\tthis.logger.interactiveStdout(true);\n\n\t\ttry {\n\t\t\tlet name = input.name;\n\t\t\tif (name) {\n\t\t\t\tconst resolved = path.resolve(process.cwd(), name);\n\t\t\t\tif (resolved === process.cwd()) {\n\t\t\t\t\tname = \".\";\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst normalizedInput: InitInput = {\n\t\t\t\t...input,\n\t\t\t\t...(name !== undefined && { name }),\n\t\t\t};\n\n\t\t\tconst targetDir =\n\t\t\t\tname && name !== \".\"\n\t\t\t\t\t? path.resolve(process.cwd(), name)\n\t\t\t\t\t: process.cwd();\n\n\t\t\tconst dirExists = await this.workspace.exists(targetDir);\n\t\t\tconst hasPackageJson = dirExists\n\t\t\t\t? await this.scanner.hasPackageJson(targetDir)\n\t\t\t\t: false;\n\t\t\tconst isEmpty = dirExists\n\t\t\t\t? await this.scanner.isEmptyDirectory(targetDir)\n\t\t\t\t: true;\n\n\t\t\t// --example always forces the new-project flow, even in non-empty or\n\t\t\t// existing-project directories.\n\t\t\tif (normalizedInput.example !== undefined) {\n\t\t\t\treturn await this.collectNewProject(normalizedInput, isEmpty);\n\t\t\t}\n\n\t\t\tif (hasPackageJson) {\n\t\t\t\treturn await this.collectExistingProject(normalizedInput, targetDir);\n\t\t\t}\n\n\t\t\tif (isEmpty || normalizedInput.isForce) {\n\t\t\t\treturn await this.collectNewProject(normalizedInput, isEmpty);\n\t\t\t}\n\n\t\t\tthis.logger.error(\n\t\t\t\t`Directory is not empty and no ${code(\"package.json\")} was found.`,\n\t\t\t);\n\t\t\tthis.logger.info(\n\t\t\t\t`To scaffold a new project, run ${code(\"arkenv init\")} in an empty directory or use ${code(\"--force\")} to proceed anyway.`,\n\t\t\t);\n\t\t\tthis.logger.refuse({\n\t\t\t\tcode: ERROR_CODES.NON_EMPTY_DIR,\n\t\t\t\tmessage: \"Directory is not empty and no package.json was found.\",\n\t\t\t\tretryWith: [\"--force\"],\n\t\t\t});\n\t\t\treturn null;\n\t\t} finally {\n\t\t\tthis.logger.interactiveStdout(false);\n\t\t}\n\t}\n\n\t/**\n\t * Collects configuration for installing ArkEnv into a project with `package.json`.\n\t */\n\tprivate async collectExistingProject(\n\t\tinput: InitInput,\n\t\ttargetDir: string,\n\t): Promise<CollectedState | null> {\n\t\tconst { isYes, isForce, isQuiet, isAgent } = input;\n\n\t\tconst requirements = await this.scanner.checkRequirements(targetDir);\n\t\tconst failures = requirements.filter((r) => r.status === \"fail\");\n\t\tconst warnings = requirements.filter((r) => r.status === \"warn\");\n\n\t\tfor (const warn of warnings) {\n\t\t\tthis.logger.warn(`${warn.requirement}: ${warn.message}`);\n\t\t}\n\n\t\tif (failures.length > 0) {\n\t\t\tif (isForce) {\n\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\"Technical requirements not met, but continuing due to --force flag.\",\n\t\t\t\t);\n\t\t\t\tfor (const fail of failures) {\n\t\t\t\t\tthis.logger.warn(`${fail.requirement}: ${fail.message}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.logger.error(\"Technical requirements not met:\");\n\t\t\t\tfor (const fail of failures) {\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t`- ${fail.requirement}: ${fail.message}${fail.current ? ` (Current: ${fail.current}, Expected: ${fail.expected})` : \"\"}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.logger.info(\"Use --force to bypass these checks.\");\n\t\t\t\tthis.logger.refuse({\n\t\t\t\t\tcode: ERROR_CODES.REQUIREMENTS_NOT_MET,\n\t\t\t\t\tmessage: \"Technical requirements not met.\",\n\t\t\t\t\tretryWith: [\"--force\"],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\trequirements: failures.map((fail) =>\n\t\t\t\t\t\t\tshake({\n\t\t\t\t\t\t\t\trequirement: fail.requirement,\n\t\t\t\t\t\t\t\tmessage: fail.message,\n\t\t\t\t\t\t\t\tcurrent: fail.current,\n\t\t\t\t\t\t\t\texpected: fail.expected,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst gitStatus = await this.scanner.checkGitStatus(targetDir);\n\t\tif (gitStatus.status === \"dirty\") {\n\t\t\tif (isForce) {\n\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\"Git working tree is not clean, but continuing due to --force flag.\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.logger.error(\n\t\t\t\t\t\"Git working tree is not clean. Commit or stash your changes (use 'git stash -u' for untracked files) before running arkenv init.\",\n\t\t\t\t);\n\t\t\t\tthis.logger.info(\"Use --force to bypass this check.\");\n\t\t\t\tthis.logger.refuse({\n\t\t\t\t\tcode: ERROR_CODES.GIT_TREE_DIRTY,\n\t\t\t\t\tmessage: \"Git working tree is not clean.\",\n\t\t\t\t\tretryWith: [\"--force\"],\n\t\t\t\t});\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tif (gitStatus.status === \"unknown\") {\n\t\t\tthis.logger.warn(\n\t\t\t\t\"Git working tree status could not be determined. Proceeding with caution.\",\n\t\t\t);\n\t\t}\n\n\t\tlet shouldUpdateTsConfig = false;\n\t\tconst tsConfig = await this.scanner.checkTsConfig(targetDir);\n\n\t\tif (tsConfig.status === \"not_strict\") {\n\t\t\tif (isYes) {\n\t\t\t\tshouldUpdateTsConfig = true;\n\t\t\t} else {\n\t\t\t\tthis.logger.warn(\n\t\t\t\t\t`TypeScript strict mode is not enabled in your ${code(tsConfig.file!)}.`,\n\t\t\t\t);\n\n\t\t\t\tconst confirmStrict = await this.prompt.confirm(\n\t\t\t\t\t`ArkEnv requires ${code(\"strict\")} mode in your ${code(tsConfig.file!)}. Would you like to enable it now?`,\n\t\t\t\t\ttrue,\n\t\t\t\t\t\"Yes (Recommended)\",\n\t\t\t\t);\n\n\t\t\t\tif (confirmStrict === null) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif (!confirmStrict) {\n\t\t\t\t\tthis.logger.cancel(\"Operation cancelled.\");\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tshouldUpdateTsConfig = true;\n\t\t\t}\n\t\t}\n\n\t\tconst detectedFramework = await this.scanner.detectFramework(\n\t\t\ttargetDir,\n\t\t\ttsConfig.parsed,\n\t\t);\n\t\tif (input.isSimple && detectedFramework === \"nextjs\") {\n\t\t\tthis.logger.error(\n\t\t\t\t\"❌ Error: The --simple layout is deprecated and no longer supported by the CLI. Arkenv now exclusively uses the Flat Layout. Run npx arkenv init without this flag.\",\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t\tconst detectedBunFeatures =\n\t\t\tdetectedFramework === \"bun-fullstack\"\n\t\t\t\t? await this.scanner.detectBunFeatures(targetDir, tsConfig.parsed)\n\t\t\t\t: undefined;\n\t\tconst defaultEnvPath = await this.scanner.suggestDefaultEnvPath(\n\t\t\ttargetDir,\n\t\t\ttsConfig.parsed,\n\t\t);\n\n\t\tconst targetPath = path.resolve(targetDir, defaultEnvPath);\n\t\tconst envRes = await this.scanner.getEnvExampleKeys(\n\t\t\ttargetDir,\n\t\t\ttsConfig.parsed,\n\t\t\ttargetPath,\n\t\t);\n\n\t\tconst hasEnvSchemaFile = await (async () => {\n\t\t\t// For strict layout, we need to check the variant paths, not the base path.\n\t\t\t// When isStrict is requested via flag, peek at those paths before the wizard runs.\n\t\t\tif (input.isStrict) {\n\t\t\t\tconst ext = path.extname(targetPath);\n\t\t\t\tconst baseWithoutExt = targetPath.slice(0, -ext.length);\n\t\t\t\tconst strictPaths = [\n\t\t\t\t\tpath.join(baseWithoutExt, \"internal\", `shared${ext}`),\n\t\t\t\t\tpath.join(baseWithoutExt, `client${ext}`),\n\t\t\t\t\tpath.join(baseWithoutExt, `server${ext}`),\n\t\t\t\t];\n\t\t\t\tconst checks = await Promise.all(\n\t\t\t\t\tstrictPaths.map((p) => this.workspace.exists(p)),\n\t\t\t\t);\n\t\t\t\tif (checks.some(Boolean)) return true;\n\t\t\t}\n\t\t\treturn this.workspace.exists(targetPath);\n\t\t})();\n\n\t\tconst options = await this.prompt.runWizard(\n\t\t\tshake({\n\t\t\t\tmode: \"existing\" as const,\n\t\t\t\tframework: detectedFramework,\n\t\t\t\tbunFeatures: detectedBunFeatures,\n\t\t\t\tdefaultEnvPath,\n\t\t\t\ttsConfig: tsConfig.parsed ?? null,\n\t\t\t\tenvKeys: envRes?.keys,\n\t\t\t\tenvKeysSource: envRes?.source,\n\t\t\t\thasEnvSchemaFile,\n\t\t\t\tisStrict: input.isStrict,\n\t\t\t\tisSimple: input.isSimple,\n\t\t\t\tisFlat: input.isFlat,\n\t\t\t\tdisableCodegen: input.noCodegen,\n\t\t\t\thostPreset: input.hostPreset,\n\t\t\t}),\n\t\t\tisYes,\n\t\t);\n\n\t\tif (options === null) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst hasSkill = await this.scanner.hasSkill(targetDir);\n\t\tif (hasSkill) {\n\t\t\toptions.skillDetected = true;\n\t\t\tif (!isQuiet && !isAgent) {\n\t\t\t\tthis.logger.info(\"ArkEnv agent skill detected.\");\n\t\t\t}\n\t\t}\n\n\t\t// Handle installSkill logic\n\t\tif (hasSkill) {\n\t\t\toptions.installSkill = false;\n\t\t} else if (isAgent) {\n\t\t\toptions.installSkill = false;\n\t\t} else if (isYes) {\n\t\t\toptions.installSkill = true;\n\t\t} else {\n\t\t\tconst confirmInstall = await this.prompt.confirm(\n\t\t\t\t\"Would you like to install the ArkEnv agent skill?\",\n\t\t\t\ttrue,\n\t\t\t\t\"Yes (Recommended)\",\n\t\t\t);\n\t\t\tif (confirmInstall === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\toptions.installSkill = confirmInstall;\n\t\t}\n\n\t\t// Handle existing env file prompt\n\t\tconst finalTargetPath = path.resolve(targetDir, options.path);\n\n\t\tif (options.overwriteEnvSchemaFile === undefined) {\n\t\t\t// For strict layout, check whether any of the three variant files already exist\n\t\t\tconst existsCheck =\n\t\t\t\toptions.layout === \"strict\"\n\t\t\t\t\t? await (async () => {\n\t\t\t\t\t\t\tconst ext = path.extname(finalTargetPath);\n\t\t\t\t\t\t\tconst baseWithoutExt = finalTargetPath.slice(0, -ext.length);\n\t\t\t\t\t\t\tconst checks = await Promise.all([\n\t\t\t\t\t\t\t\tthis.workspace.exists(\n\t\t\t\t\t\t\t\t\tpath.join(baseWithoutExt, \"internal\", `shared${ext}`),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tthis.workspace.exists(\n\t\t\t\t\t\t\t\t\tpath.join(baseWithoutExt, `client${ext}`),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tthis.workspace.exists(\n\t\t\t\t\t\t\t\t\tpath.join(baseWithoutExt, `server${ext}`),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\treturn checks.some(Boolean);\n\t\t\t\t\t\t})()\n\t\t\t\t\t: await this.workspace.exists(finalTargetPath);\n\n\t\t\tif (existsCheck) {\n\t\t\t\tconst label =\n\t\t\t\t\toptions.layout === \"strict\"\n\t\t\t\t\t\t? \"Strict layout files (client, server, internal/shared)\"\n\t\t\t\t\t\t: path.basename(finalTargetPath);\n\t\t\t\tconst confirmOverwrite = await this.prompt.confirm(\n\t\t\t\t\t`${label} already exist. Overwrite?`,\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\n\t\t\t\tif (confirmOverwrite === null) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif (!confirmOverwrite) {\n\t\t\t\t\tthis.logger.cancel(\"Operation cancelled.\");\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\toptions.overwriteEnvSchemaFile = confirmOverwrite;\n\t\t\t}\n\t\t}\n\n\t\tconst packageManager = await this.scanner.detectPackageManager(\n\t\t\ttargetDir,\n\t\t\ttsConfig.parsed,\n\t\t);\n\n\t\tconst ext = path.extname(finalTargetPath);\n\t\tconst baseWithoutExt = finalTargetPath.slice(0, -ext.length);\n\n\t\t// Determine which paths we actually care about based on the resolved layout\n\t\tconst pathsToCheck =\n\t\t\toptions.layout === \"strict\"\n\t\t\t\t? [\n\t\t\t\t\t\tpath.join(baseWithoutExt, \"internal\", `shared${ext}`),\n\t\t\t\t\t\tpath.join(baseWithoutExt, `client${ext}`),\n\t\t\t\t\t\tpath.join(baseWithoutExt, `server${ext}`),\n\t\t\t\t\t]\n\t\t\t\t: [finalTargetPath];\n\n\t\tconst existingFiles: string[] = [];\n\t\tfor (const p of pathsToCheck) {\n\t\t\tif (await this.workspace.exists(p)) existingFiles.push(p);\n\t\t}\n\n\t\tconst envPath = path.join(targetDir, \".env\");\n\t\tconst envExamplePath = path.join(targetDir, \".env.example\");\n\n\t\t// Never read `.env` contents. Existence is enough to skip creating it.\n\t\tif (await this.workspace.exists(envPath)) {\n\t\t\texistingFiles.push(envPath);\n\t\t}\n\t\tif (await this.workspace.exists(envExamplePath)) {\n\t\t\texistingFiles.push(envExamplePath);\n\t\t\toptions.envExampleContent = await this.workspace.readFile(envExamplePath);\n\t\t}\n\n\t\tconst gitignorePath = path.join(targetDir, \".gitignore\");\n\t\tif (await this.workspace.exists(gitignorePath)) {\n\t\t\texistingFiles.push(gitignorePath);\n\t\t\toptions.gitignoreContent = await this.workspace.readFile(gitignorePath);\n\t\t}\n\n\t\treturn shake({\n\t\t\tmode: \"existing\" as const,\n\t\t\tcwd: targetDir,\n\t\t\toptions,\n\t\t\tdetectedFramework,\n\t\t\tdetectedBunFeatures,\n\t\t\tpackageManager,\n\t\t\ttsConfig,\n\t\t\tshouldUpdateTsConfig,\n\t\t\texistingFiles,\n\t\t\tisYes,\n\t\t});\n\t}\n\n\t/**\n\t * Collects configuration for scaffolding a project from an example example.\n\t */\n\tprivate async collectNewProject(\n\t\tinput: InitInput,\n\t\tisEmpty = true,\n\t): Promise<CollectedState | null> {\n\t\tconst { isYes, example, name, isForce } = input;\n\n\t\tconst registry = await this.registry.fetchRegistry();\n\n\t\tconst options = await this.prompt.runWizard(\n\t\t\tshake({\n\t\t\t\tmode: \"new\" as const,\n\t\t\t\texamples: registry.examples,\n\t\t\t\texample,\n\t\t\t\tname,\n\t\t\t}),\n\t\t\tisYes,\n\t\t);\n\n\t\tif (options === null) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// When the resolved project name is \".\" (current dir) and the directory is\n\t\t// not empty, abort to avoid clobbering the existing contents.\n\t\tif (options.name === \".\" && !isEmpty && !isForce) {\n\t\t\tthis.logger.error(\n\t\t\t\t`Cannot scaffold into ${code(\".\")} because the current directory is not empty.`,\n\t\t\t);\n\t\t\tthis.logger.info(\n\t\t\t\t`Run ${code(\"arkenv init\")} in an empty directory or choose a sub-directory name instead.`,\n\t\t\t);\n\t\t\tthis.logger.refuse({\n\t\t\t\tcode: ERROR_CODES.NON_EMPTY_DIR,\n\t\t\t\tmessage:\n\t\t\t\t\t\"Cannot scaffold into the current directory because it is not empty.\",\n\t\t\t\tretryWith: [\"--force\"],\n\t\t\t});\n\t\t\treturn null;\n\t\t}\n\n\t\tconst packageManager = this.detectPackageManager();\n\n\t\treturn shake({\n\t\t\tmode: \"new\" as const,\n\t\t\tcwd: process.cwd(),\n\t\t\toptions,\n\t\t\tdetectedFramework: options.framework,\n\t\t\tpackageManager,\n\t\t\ttsConfig: { status: \"not_found\" },\n\t\t\tshouldUpdateTsConfig: false,\n\t\t\texistingFiles: [],\n\t\t\tisYes,\n\t\t});\n\t}\n\n\t/**\n\t * Infers the active package manager from the current npm user agent.\n\t */\n\tprivate detectPackageManager(): \"pnpm\" | \"yarn\" | \"npm\" | \"bun\" {\n\t\tconst userAgent = process.env.npm_config_user_agent || \"\";\n\t\tif (userAgent.includes(\"pnpm\")) return \"pnpm\";\n\t\tif (userAgent.includes(\"yarn\")) return \"yarn\";\n\t\tif (userAgent.includes(\"bun\")) return \"bun\";\n\t\treturn \"npm\";\n\t}\n}\n","import path from \"node:path\";\nimport {\n\tapplyPresetToSchema,\n\tremovePresetFromSchema,\n\tvalidateAndFindPresetBlocks,\n} from \"@/features/config-mutation\";\nimport { FRAMEWORK_CLIENT_PREFIXES } from \"@/features/scaffold/frameworks\";\nimport {\n\tgetPresetKeys,\n\ttype HostPreset,\n\ttype HostProvider,\n\tPRESETS,\n\tpartitionPresetKeys,\n} from \"@/features/scaffold/presets\";\nimport { ERROR_CODES } from \"@/shared/errors\";\nimport type {\n\tLoggerPort,\n\tProjectScannerPort,\n\tPromptPort,\n\tWorkspacePort,\n} from \"@/shared/ports\";\n\n/**\n * Detects the validator engine (Zod, Valibot, or ArkType) used in an env.ts schema file.\n * Strips single-line and multi-line comments to avoid misclassifying commented-out code or string literals.\n *\n * @param code The source code of env.ts.\n * @returns The detected validator engine.\n */\nexport function detectValidator(code: string): \"zod\" | \"valibot\" | \"arktype\" {\n\tconst cleanedCode = code\n\t\t.replace(/\\/\\/.*/g, \"\")\n\t\t.replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\");\n\n\tif (/(?:^|\\n)\\s*import\\s+[\\s\\S]*?from\\s+['\"]zod['\"]/.test(cleanedCode)) {\n\t\treturn \"zod\";\n\t}\n\tif (/(?:^|\\n)\\s*import\\s+[\\s\\S]*?from\\s+['\"]valibot['\"]/.test(cleanedCode)) {\n\t\treturn \"valibot\";\n\t}\n\treturn \"arktype\";\n}\n\n/**\n * Input for the preset command.\n */\nexport type PresetInput = {\n\taction: \"apply\" | \"remove\";\n\tprovider?: HostProvider;\n\tfile?: string;\n\tisForce?: boolean;\n\tisYes?: boolean;\n};\n\n/**\n * Use case for managing hosting presets (apply / remove / refresh).\n */\nexport class PresetUseCase {\n\tconstructor(\n\t\tprivate readonly logger: LoggerPort,\n\t\tprivate readonly workspace: WorkspacePort,\n\t\tprivate readonly prompt: PromptPort,\n\t\tprivate readonly scanner: ProjectScannerPort,\n\t) {}\n\n\t/**\n\t * Executes the preset apply or remove command.\n\t */\n\tasync execute(input: PresetInput): Promise<boolean> {\n\t\tthis.logger.interactiveStdout(true);\n\n\t\ttry {\n\t\t\tconst cwd = process.cwd();\n\n\t\t\t// 1. Git working tree check\n\t\t\tconst gitStatus = await this.scanner.checkGitStatus(cwd);\n\t\t\tif (gitStatus.status === \"dirty\") {\n\t\t\t\tif (input.isForce) {\n\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\"Git working tree is not clean, but continuing due to --force flag.\",\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\"Git working tree is not clean. Commit or stash your changes before running arkenv preset.\",\n\t\t\t\t\t);\n\t\t\t\t\tthis.logger.info(\"Use --force to bypass this check.\");\n\t\t\t\t\tthis.logger.refuse({\n\t\t\t\t\t\tcode: ERROR_CODES.GIT_TREE_DIRTY,\n\t\t\t\t\t\tmessage: \"Git working tree is not clean.\",\n\t\t\t\t\t\tretryWith: [\"--force\"],\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} else if (gitStatus.status === \"unknown\") {\n\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\"Git working tree status could not be determined. Proceeding with caution.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// 2. Resolve Provider\n\t\t\tlet provider = input.provider;\n\t\t\tif (!provider) {\n\t\t\t\tif (input.isYes) {\n\t\t\t\t\tprovider = \"vercel\";\n\t\t\t\t} else {\n\t\t\t\t\tconst actionLabel = input.action === \"remove\" ? \"remove\" : \"apply\";\n\t\t\t\t\tconst selected = (await this.prompt.select(\n\t\t\t\t\t\t`Select a hosting provider preset to ${actionLabel}:`,\n\t\t\t\t\t\tObject.entries(PRESETS).map(([value, def]) => ({\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\tlabel: def.label,\n\t\t\t\t\t\t\thint: def.hint,\n\t\t\t\t\t\t})),\n\t\t\t\t\t\t\"vercel\",\n\t\t\t\t\t)) as HostPreset;\n\t\t\t\t\tif (selected && selected !== \"none\") {\n\t\t\t\t\t\tprovider = selected;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst providerName = PRESETS[provider]?.label || provider;\n\n\t\t\t// 3. Discover schema file(s) and layout\n\t\t\tconst discovery = await this.discoverSchema(cwd, input.file);\n\t\t\tif (!discovery) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst tsConfigResult = await this.scanner.checkTsConfig(cwd);\n\t\t\tconst tsConfig = tsConfigResult.parsed || null;\n\t\t\tconst framework = await this.scanner.detectFramework(cwd, tsConfig);\n\t\t\tconst prefix = FRAMEWORK_CLIENT_PREFIXES[framework] || \"\";\n\n\t\t\tconst allPresetKeys = getPresetKeys(provider, prefix);\n\n\t\t\tif (input.action === \"apply\") {\n\t\t\t\tif (discovery.layout === \"strict\") {\n\t\t\t\t\tconst clientPath = path.join(discovery.dir, \"client.ts\");\n\t\t\t\t\tconst serverPath = path.join(discovery.dir, \"server.ts\");\n\t\t\t\t\tconst relClientPath = path.relative(cwd, clientPath);\n\t\t\t\t\tconst relServerPath = path.relative(cwd, serverPath);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(await this.workspace.exists(clientPath)) ||\n\t\t\t\t\t\t!(await this.workspace.exists(serverPath))\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\t`Strict layout files not found in ${path.relative(cwd, discovery.dir)}.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientCode = await this.workspace.readFile(clientPath);\n\t\t\t\t\tconst serverCode = await this.workspace.readFile(serverPath);\n\n\t\t\t\t\tconst clientValidator = detectValidator(clientCode);\n\t\t\t\t\tconst serverValidator = detectValidator(serverCode);\n\n\t\t\t\t\tconst { clientKeys, serverKeys } = partitionPresetKeys(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst clientResult = applyPresetToSchema(clientCode, {\n\t\t\t\t\t\tpreset: provider,\n\t\t\t\t\t\tframework,\n\t\t\t\t\t\tvalidator: clientValidator,\n\t\t\t\t\t\tmarkerId: `${provider}:client`,\n\t\t\t\t\t\ttargetKeys: clientKeys,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst serverResult = applyPresetToSchema(serverCode, {\n\t\t\t\t\t\tpreset: provider,\n\t\t\t\t\t\tframework,\n\t\t\t\t\t\tvalidator: serverValidator,\n\t\t\t\t\t\tmarkerId: `${provider}:server`,\n\t\t\t\t\t\ttargetKeys: serverKeys,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!clientResult.success || !clientResult.code) {\n\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\tclientResult.error ||\n\t\t\t\t\t\t\t\t`Failed to apply preset to ${relClientPath}.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!serverResult.success || !serverResult.code) {\n\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\tserverResult.error ||\n\t\t\t\t\t\t\t\t`Failed to apply preset to ${relServerPath}.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet anyUpdated = false;\n\t\t\t\t\tif (clientResult.updated) {\n\t\t\t\t\t\tawait this.workspace.writeFile(clientPath, clientResult.code);\n\t\t\t\t\t\tanyUpdated = true;\n\t\t\t\t\t}\n\t\t\t\t\tif (serverResult.updated) {\n\t\t\t\t\t\tawait this.workspace.writeFile(serverPath, serverResult.code);\n\t\t\t\t\t\tanyUpdated = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof this.workspace.appendMissingEnvExampleKeys === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this.workspace.appendMissingEnvExampleKeys(\n\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\tallPresetKeys,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (anyUpdated) {\n\t\t\t\t\t\tthis.logger.success(\n\t\t\t\t\t\t\t`Applied ${providerName} preset to ${relClientPath} and ${relServerPath}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.logger.info(\n\t\t\t\t\t\t\t`${providerName} preset is already up-to-date in ${relClientPath} and ${relServerPath}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\t// Flat layout\n\t\t\t\tconst envPath = discovery.filePath;\n\t\t\t\tconst relEnvPath = path.relative(cwd, envPath);\n\n\t\t\t\tif (!(await this.workspace.exists(envPath))) {\n\t\t\t\t\tthis.logger.error(`Schema file not found at ${relEnvPath}.`);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst code = await this.workspace.readFile(envPath);\n\t\t\t\tconst validator = detectValidator(code);\n\n\t\t\t\tconst result = applyPresetToSchema(code, {\n\t\t\t\t\tpreset: provider,\n\t\t\t\t\tframework,\n\t\t\t\t\tvalidator,\n\t\t\t\t});\n\n\t\t\t\tif (!result.success || !result.code) {\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\tresult.error || `Failed to apply preset to ${relEnvPath}.`,\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (result.updated) {\n\t\t\t\t\tawait this.workspace.writeFile(envPath, result.code);\n\t\t\t\t\tthis.logger.success(\n\t\t\t\t\t\t`Applied ${providerName} preset to ${relEnvPath}`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.info(\n\t\t\t\t\t\t`${providerName} preset is already up-to-date in ${relEnvPath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (typeof this.workspace.appendMissingEnvExampleKeys === \"function\") {\n\t\t\t\t\tawait this.workspace.appendMissingEnvExampleKeys(cwd, allPresetKeys);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// input.action === \"remove\"\n\t\t\tif (discovery.layout === \"strict\") {\n\t\t\t\tconst clientPath = path.join(discovery.dir, \"client.ts\");\n\t\t\t\tconst serverPath = path.join(discovery.dir, \"server.ts\");\n\t\t\t\tconst relClientPath = path.relative(cwd, clientPath);\n\t\t\t\tconst relServerPath = path.relative(cwd, serverPath);\n\n\t\t\t\tif (\n\t\t\t\t\t!(await this.workspace.exists(clientPath)) ||\n\t\t\t\t\t!(await this.workspace.exists(serverPath))\n\t\t\t\t) {\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t`Strict layout files not found in ${path.relative(cwd, discovery.dir)}.`,\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst clientCode = await this.workspace.readFile(clientPath);\n\t\t\t\tconst serverCode = await this.workspace.readFile(serverPath);\n\n\t\t\t\tconst clientResult = removePresetFromSchema(clientCode, {\n\t\t\t\t\tpreset: provider,\n\t\t\t\t});\n\t\t\t\tconst serverResult = removePresetFromSchema(serverCode, {\n\t\t\t\t\tpreset: provider,\n\t\t\t\t});\n\n\t\t\t\tif (!clientResult.success || !clientResult.code) {\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\tclientResult.error ||\n\t\t\t\t\t\t\t`Failed to remove preset from ${relClientPath}.`,\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (!serverResult.success || !serverResult.code) {\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\tserverResult.error ||\n\t\t\t\t\t\t\t`Failed to remove preset from ${relServerPath}.`,\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tlet anyUpdated = false;\n\t\t\t\tconst removedKeys: string[] = [];\n\t\t\t\tif (clientResult.updated) {\n\t\t\t\t\tawait this.workspace.writeFile(clientPath, clientResult.code);\n\t\t\t\t\tanyUpdated = true;\n\t\t\t\t\tif (clientResult.removedKeys) {\n\t\t\t\t\t\tremovedKeys.push(...clientResult.removedKeys);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (serverResult.updated) {\n\t\t\t\t\tawait this.workspace.writeFile(serverPath, serverResult.code);\n\t\t\t\t\tanyUpdated = true;\n\t\t\t\t\tif (serverResult.removedKeys) {\n\t\t\t\t\t\tremovedKeys.push(...serverResult.removedKeys);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (anyUpdated) {\n\t\t\t\t\t// Find remaining preset keys across both files\n\t\t\t\t\tconst validationClient = validateAndFindPresetBlocks(\n\t\t\t\t\t\tclientResult.code || clientCode,\n\t\t\t\t\t);\n\t\t\t\t\tconst remainingBlocksClient = validationClient.success\n\t\t\t\t\t\t? validationClient.blocks\n\t\t\t\t\t\t: [];\n\t\t\t\t\tconst validationServer = validateAndFindPresetBlocks(\n\t\t\t\t\t\tserverResult.code || serverCode,\n\t\t\t\t\t);\n\t\t\t\t\tconst remainingBlocksServer = validationServer.success\n\t\t\t\t\t\t? validationServer.blocks\n\t\t\t\t\t\t: [];\n\t\t\t\t\tconst remainingKeys = [\n\t\t\t\t\t\t...remainingBlocksClient.flatMap((b) => b.keys),\n\t\t\t\t\t\t...remainingBlocksServer.flatMap((b) => b.keys),\n\t\t\t\t\t];\n\n\t\t\t\t\tif (typeof this.workspace.removeEnvExampleKeys === \"function\") {\n\t\t\t\t\t\tawait this.workspace.removeEnvExampleKeys(\n\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\tremovedKeys,\n\t\t\t\t\t\t\tremainingKeys,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.logger.success(\n\t\t\t\t\t\t`Removed ${providerName} preset from ${relClientPath} and ${relServerPath}`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.info(\n\t\t\t\t\t\t`${providerName} preset was not present in ${relClientPath} and ${relServerPath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Flat layout remove\n\t\t\tconst envPath = discovery.filePath;\n\t\t\tconst relEnvPath = path.relative(cwd, envPath);\n\n\t\t\tif (!(await this.workspace.exists(envPath))) {\n\t\t\t\tthis.logger.error(`Schema file not found at ${relEnvPath}.`);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst code = await this.workspace.readFile(envPath);\n\t\t\tconst result = removePresetFromSchema(code, {\n\t\t\t\tpreset: provider,\n\t\t\t});\n\n\t\t\tif (!result.success || !result.code) {\n\t\t\t\tthis.logger.error(\n\t\t\t\t\tresult.error || `Failed to remove preset from ${relEnvPath}.`,\n\t\t\t\t);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (result.updated) {\n\t\t\t\tawait this.workspace.writeFile(envPath, result.code);\n\n\t\t\t\tconst validation = validateAndFindPresetBlocks(result.code);\n\t\t\t\tconst remainingBlocks = validation.success ? validation.blocks : [];\n\t\t\t\tconst remainingKeys = remainingBlocks.flatMap((b) => b.keys);\n\n\t\t\t\tif (typeof this.workspace.removeEnvExampleKeys === \"function\") {\n\t\t\t\t\tawait this.workspace.removeEnvExampleKeys(\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tresult.removedKeys || [],\n\t\t\t\t\t\tremainingKeys,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.logger.success(\n\t\t\t\t\t`Removed ${providerName} preset from ${relEnvPath}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.logger.info(\n\t\t\t\t\t`${providerName} preset was not present in ${relEnvPath}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} finally {\n\t\t\tthis.logger.interactiveStdout(false);\n\t\t}\n\t}\n\n\t/**\n\t * Discovers the schema target file or directory and layout strategy.\n\t */\n\tprivate async discoverSchema(\n\t\tcwd: string,\n\t\tfileOverride?: string,\n\t): Promise<\n\t\t| { layout: \"strict\"; dir: string }\n\t\t| { layout: \"flat\"; filePath: string }\n\t\t| null\n\t> {\n\t\tif (fileOverride) {\n\t\t\tconst resolved = path.resolve(cwd, fileOverride);\n\t\t\t// Check if it's a directory with client.ts and server.ts\n\t\t\tconst clientFile = path.join(resolved, \"client.ts\");\n\t\t\tconst serverFile = path.join(resolved, \"server.ts\");\n\t\t\tif (\n\t\t\t\t(await this.workspace.exists(clientFile)) &&\n\t\t\t\t(await this.workspace.exists(serverFile))\n\t\t\t) {\n\t\t\t\treturn { layout: \"strict\", dir: resolved };\n\t\t\t}\n\t\t\treturn { layout: \"flat\", filePath: resolved };\n\t\t}\n\n\t\t// Read pointer from nearest package.json\n\t\tif (typeof this.scanner.readArkenvConfig === \"function\") {\n\t\t\tconst arkenvConfig = await this.scanner.readArkenvConfig(cwd);\n\t\t\tif (arkenvConfig) {\n\t\t\t\tconst resolved = path.resolve(cwd, arkenvConfig.schema);\n\t\t\t\tif (arkenvConfig.layout === \"strict\") {\n\t\t\t\t\treturn { layout: \"strict\", dir: resolved };\n\t\t\t\t}\n\t\t\t\treturn { layout: \"flat\", filePath: resolved };\n\t\t\t}\n\t\t}\n\n\t\t// Fallback: check convention locations\n\t\tconst strictCandidates = [\n\t\t\tpath.resolve(cwd, \"env\"),\n\t\t\tpath.resolve(cwd, \"src/env\"),\n\t\t];\n\t\tfor (const dir of strictCandidates) {\n\t\t\tif (\n\t\t\t\t(await this.workspace.exists(path.join(dir, \"client.ts\"))) &&\n\t\t\t\t(await this.workspace.exists(path.join(dir, \"server.ts\")))\n\t\t\t) {\n\t\t\t\treturn { layout: \"strict\", dir };\n\t\t\t}\n\t\t}\n\n\t\tconst flatCandidates = [\n\t\t\tpath.resolve(cwd, \"env.ts\"),\n\t\t\tpath.resolve(cwd, \"src/env.ts\"),\n\t\t];\n\t\tfor (const file of flatCandidates) {\n\t\t\tif (await this.workspace.exists(file)) {\n\t\t\t\treturn { layout: \"flat\", filePath: file };\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.error(\n\t\t\t\"Could not locate your schema file. Add an 'arkenv' entry to package.json or specify --file <path>.\",\n\t\t);\n\t\treturn null;\n\t}\n}\n","import {\n\tClackPromptAdapter,\n\tNodeProjectScannerAdapter,\n\tNodeWorkspace,\n} from \"@/adapters\";\nimport { CLI } from \"./cli\";\nimport { HelpUseCase, InitUseCase, PresetUseCase } from \"./commands\";\n\n/**\n * Bootstraps the application's dependency graph by composing\n * the core CLI instance with its adapters and use cases.\n *\n * @param argv Command line arguments.\n * @returns The composed instances.\n */\nexport function compose(argv: string[]) {\n\tconst cli = new CLI(argv);\n\tconst logger = cli.logger; // CLI currently creates the logger, which is fine for now\n\tconst workspace = new NodeWorkspace(cli.isQuiet, logger.stdio, logger);\n\tconst prompt = new ClackPromptAdapter();\n\tconst scanner = new NodeProjectScannerAdapter(logger);\n\n\tconst initUseCase = new InitUseCase(logger, workspace, prompt, scanner);\n\tconst presetUseCase = new PresetUseCase(logger, workspace, prompt, scanner);\n\tconst helpUseCase = new HelpUseCase(logger);\n\n\treturn {\n\t\tcli,\n\t\tlogger,\n\t\tworkspace,\n\t\tprompt,\n\t\tinitUseCase,\n\t\tpresetUseCase,\n\t\thelpUseCase,\n\t};\n}\n","#!/usr/bin/env node\nimport { shake } from \"radashi\";\nimport { Logger } from \"./adapters/logger.adapter\";\nimport { compose } from \"./cli/composition\";\n\nconst fallbackLogger = new Logger({ isQuiet: false, isJson: false });\n\nlet globalLogger: Logger | undefined;\nlet isShuttingDown = false;\n\n/**\n * Compose the CLI, dispatch the requested command, and handle fatal failures.\n */\nasync function main() {\n\tif (process.env.INIT_CWD) {\n\t\ttry {\n\t\t\tprocess.chdir(process.env.INIT_CWD);\n\t\t} catch {\n\t\t\t// Fallback to process.cwd() if directory change fails\n\t\t}\n\t}\n\n\tconst { cli, logger, initUseCase, presetUseCase, helpUseCase } = compose(\n\t\tprocess.argv,\n\t);\n\tglobalLogger = logger;\n\n\tsetupGracefulShutdown(logger);\n\n\tif (cli.validationError) {\n\t\tlogger.error(cli.validationError);\n\t\tawait helpUseCase.execute();\n\t\tawait logger.flush();\n\t\tprocess.exit(1);\n\t}\n\n\tif (cli.helpRequested) {\n\t\tawait helpUseCase.execute();\n\t\tawait logger.flush();\n\t\tprocess.exit(0);\n\t}\n\n\tconst commands = {\n\t\tinit: () => initUseCase.execute(shake(cli.initInput)),\n\t\tpreset: () => presetUseCase.execute(cli.presetInput),\n\t} as const;\n\n\tconst handler = cli.command\n\t\t? commands[cli.command as keyof typeof commands]\n\t\t: undefined;\n\n\tif (!handler) {\n\t\tif (cli.command) {\n\t\t\tlogger.error(`Unknown command: ${cli.command}`);\n\t\t} else {\n\t\t\tlogger.error(\"Missing command.\");\n\t\t}\n\t\tawait helpUseCase.execute();\n\t\tawait logger.flush();\n\t\tprocess.exit(1);\n\t}\n\n\ttry {\n\t\tconst success = await handler();\n\t\tif (!success) {\n\t\t\tawait logger.flush();\n\t\t\tprocess.exit(1);\n\t\t}\n\t} catch (error) {\n\t\ttry {\n\t\t\tlogger.fatal(\"An unexpected error occurred\", error);\n\t\t} catch {\n\t\t\t// Ignore throw from fatal as we are already handling the error\n\t\t}\n\t\tawait logger.flush();\n\t\tprocess.exit(1);\n\t}\n}\n\n/**\n * Install signal handlers that cancel prompts and flush logs before exiting.\n *\n * @param logger The active logger instance to flush on shutdown\n */\nfunction setupGracefulShutdown(logger: any) {\n\t/**\n\t * Flush the current prompt and logger state before exiting with a signal code.\n\t *\n\t * @param code The process exit code\n\t */\n\tconst shutdown = async (code: number) => {\n\t\tif (isShuttingDown) {\n\t\t\tprocess.exit(code);\n\t\t}\n\t\tisShuttingDown = true;\n\n\t\t// Force exit after 2 seconds if graceful shutdown hangs\n\t\tconst timeout = setTimeout(() => {\n\t\t\tprocess.exit(code);\n\t\t}, 2000);\n\t\ttimeout.unref();\n\n\t\tif (logger.interactiveStdout) {\n\t\t\tlogger.interactiveStdout(false);\n\t\t}\n\n\t\ttry {\n\t\t\tlogger.cancel(\"Operation cancelled.\");\n\t\t\tawait logger.flush();\n\t\t} catch (err) {\n\t\t\t// Best-effort logging on shutdown failure\n\t\t\tif (logger.error) {\n\t\t\t\tlogger.error(\"Logger failed during shutdown\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tprocess.exit(code);\n\t\t}\n\t};\n\n\tprocess.on(\"SIGINT\", () => shutdown(130));\n\tprocess.on(\"SIGTERM\", () => shutdown(143));\n}\n\nmain();\n\n// Defense-in-depth for unforeseen async rejections\nprocess.on(\"unhandledRejection\", async (err) => {\n\tconst logger = globalLogger ?? fallbackLogger;\n\ttry {\n\t\tlogger.fatal(\"Unhandled rejection\", err);\n\t} catch {\n\t\t// Already logged\n\t}\n\tawait logger.flush();\n\tprocess.exit(1);\n});\n\nprocess.on(\"uncaughtException\", async (err) => {\n\tconst logger = globalLogger ?? fallbackLogger;\n\ttry {\n\t\tlogger.fatal(\"Uncaught exception\", err);\n\t} catch {\n\t\t// Already logged\n\t}\n\tawait logger.flush();\n\tprocess.exit(1);\n});\n"],"x_google_ignoreList":[0,4,5,6,7,8,9,10],"mappings":";2zCAAA,IAAI,EAAI,SAAW,EAAE,CAAE,EAAO,EAAE,MAAQ,EAAE,CAAE,EAAM,EAAE,KAAO,EAAE,CACzD,EACH,EAAI,EAAI,UAAY,EAAK,SAAS,aAAa,IAC9C,CAAC,CAAC,EAAI,aAAe,EAAK,SAAS,UAAU,EAAI,EAAE,WAAa,UAAa,EAAE,QAAU,EAAE,EAAE,OAAS,EAAI,OAAS,QAAW,CAAC,CAAC,EAAI,IAElI,GAAa,EAAM,EAAO,EAAU,IACvC,GAAS,CACR,IAAI,EAAS,GAAK,EAAO,EAAQ,EAAO,QAAQ,EAAO,EAAK,OAAO,CACnE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