infra-kit 0.11.16 → 0.14.0

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,2 @@
1
+ import{a as b,b as k,d as w,n as C}from"./chunk-Y3RW74TE.js";import{a as g,e as h,j as x}from"./chunk-DW2SQ2XU.js";import{P as d,ca as v}from"./chunk-FRBNA6VH.js";import"./chunk-MFAFQVTW.js";import"./chunk-MFHYIQ7B.js";import{e as y}from"./chunk-QSTGO43H.js";import"./chunk-QWVLAZ6N.js";import B from"@inquirer/checkbox";import j from"@inquirer/confirm";import _,{Separator as U}from"@inquirer/select";import{loadDev as I,loadPackageConfig as K}from"@slip-stream-kit/config/internal";import R from"node:path";import m from"node:process";var W=e=>e.split("/")[0],D=e=>new Map(e.apps.map(r=>[r.name,r])),$=e=>e.localCapable&&e.cloudCapable,N=(e,r,a)=>$(r)?a[`${e} ${r.path}`]??(r.cloudCapable?"cloud":"local"):r.localCapable?"local":"cloud",O=(e,r,a)=>{let n=new Set,t=new Map;for(let o of e){let s=r.get(W(o));for(let i of s?.backends??[]){t.set(i.packageName,i.ownerApp);for(let l of i.routes)N(o,l,a)==="local"&&n.add(i.packageName)}}return{localPkgs:n,ownerByPkg:t}},E=(e,r)=>{let a={},n=!1;for(let t of e?.backends??[]){let o=r.has(t.packageName);for(let s of t.routes){let i=s.localCapable&&o?"local":"cloud";a[s.path]=i,i==="cloud"&&(n=!0)}}return{overrides:a,anyCloud:n}},M=(e,r)=>{let a=D(r),n=e.targets.filter(c=>c.endsWith("/ui")),t=e.targets.filter(c=>c.endsWith("/api")),{localPkgs:o,ownerByPkg:s}=O(n,a,e.sources),i={},l=!1;for(let c of n){let{overrides:f,anyCloud:p}=E(a.get(W(c)),o);p&&(l=!0),i[c]=Object.keys(f).length>0?{proxy:f}:{}}for(let c of t)i[c]??={};for(let c of o){let f=s.get(c);f!=null&&(i[`${f}/api`]??={})}return{presetDef:{apps:i,orca:e.orca},anyCloudRoute:l,targetKeys:Object.keys(i).sort()}},z=(e,r)=>{let a=[`--target=${e.targetKeys.join(",")}`];return r.watch||a.push("--no-watch"),r.orca&&a.push("--orca"),{flags:a.join(" ")}};var P={output:m.stderr,clearPromptOnDone:!0},V={select:e=>h(r=>_({message:e.message,choices:e.choices,default:e.default},r),{...P,whenHeadless:"refuse"}),checkbox:e=>h(r=>B({message:e.message,choices:e.choices},r),{...P,whenHeadless:"refuse"}),confirm:e=>h(r=>j({message:e.message,default:e.default},r),{...P,whenHeadless:"refuse"})},q=(e,r)=>{let a=new Map;for(let[n,t]of Object.entries(e)){let o={path:n,localCapable:t.from.includes("local"),cloudCapable:t.from.includes("cloud"),default:t.default},s=a.get(t.packageName);s?(s.routes.push(o),s.localCapable=s.localCapable||o.localCapable,s.cloudCapable=s.cloudCapable||o.cloudCapable):a.set(t.packageName,{packageName:t.packageName,routes:[o],localCapable:o.localCapable,cloudCapable:o.cloudCapable,ownerApp:r.get(t.packageName)})}return[...a.values()]},L=async(e,r,a)=>{try{let n=(await I(e))?.proxy?.routes;return n?q(n,a):[]}catch(n){return d.warn(`\u26A0\uFE0F Skipping ${r}: its dev config failed to load \u2014 ${n instanceof Error?n.message:String(n)}`),[]}},T=async e=>{let r=k(e),a=w(e),n=await v(),t=new Map(r.map(p=>[p.packageName,p.name])),o=new Map(r.map(p=>[p.name,p.packageName])),s=new Set(a.map(p=>p.name)),i=new Set(r.map(p=>p.name)),l=[...new Set([...i,...s])].sort(),c=await Promise.all(l.map(async p=>{let u=s.has(p);return{name:p,hasApi:i.has(p),hasUi:u,apiPackage:o.get(p),backends:u?await L(R.join(e,"apps",p,"ui"),p,t):[],deployedUrlEnv:u?(await K(R.join(e,"apps",p,"ui")).catch(()=>{}))?.deployedUrlEnv:void 0}})),f=await x();return{apps:c,presets:Object.keys(n.devServersPresets??{}),environments:Object.keys(f?.envs??{}).sort()}},F=e=>{let r=[];for(let a of e.apps){if(a.hasUi){let n=a.backends.flatMap(o=>o.routes.map(s=>s.path)),t=n.length>0?`frontend \u2014 proxies ${[...n].sort().join(", ")}`:"frontend";r.push({name:`${a.name}/ui`,value:`${a.name}/ui`,description:t})}a.hasApi&&!a.hasUi&&r.push({name:`${a.name}/api`,value:`${a.name}/api`,description:"backend"})}return r},H=e=>{let r={api:e.apps.filter(t=>t.hasApi).map(t=>t.name),ui:e.apps.filter(t=>t.hasUi).map(t=>t.name)},a={},n=new Map;for(let t of e.apps){t.apiPackage!=null&&(a[t.name]=t.apiPackage);for(let o of t.backends)for(let s of o.routes)n.set(`${t.name} ${s.path}`,o.packageName)}return{discovered:r,apiPkgByApp:a,routePkg:(t,o)=>n.get(`${t} ${o}`)}},Z=(e,r)=>C({__wizard__:e},H(r)).map(a=>a.message),G="INFRA_KIT_DEV_WIZARD_ORCA",J=()=>m.env[G]==="1",Q=async(e,r,a)=>{let n=new Map(r.apps.map(o=>[o.name,o])),t={};for(let o of a){let s=n.get(o.split("/")[0]);for(let i of s?.backends??[])for(let l of i.routes){if(!l.localCapable||!l.cloudCapable)continue;let c=await e.select({message:`\u{1F500} ${o} ${l.path} \u2192 local or cloud?`,choices:[{name:"local (this machine)",value:"local"},{name:"cloud",value:"cloud"}],default:l.default??"local"});t[`${o} ${l.path}`]=c}}return t},X=(e,r,a)=>e.apps.find(n=>n.name===r)?.backends.flatMap(n=>n.routes).find(n=>n.path===a),Y=(e,r)=>{let a=[];for(let[n,t]of Object.entries(e.presetDef.apps??{})){if(!n.endsWith("/ui")||!t.proxy)continue;let o=n.split("/")[0];for(let[s,i]of Object.entries(t.proxy)){let l=X(r,o,s),c=l&&l.localCapable&&l.cloudCapable?"":" (only option)";a.push(` ${n} ${s} \u2192 ${i}${c}`)}}if(a.length!==0){d.info("Resolved routes:");for(let n of[...a].sort())d.info(n)}},ee=async(e,r)=>{let{downloadEnvSecrets:a}=await import("./env-load-MF26WMDL.js"),n=await a(e);return new Map(r.flatMap(t=>{let o=n.get(t);return o===void 0?[]:[[t,o]]}))},re=async(e,r,a,n)=>{let t=r.flatMap(s=>{let i=a.apps.find(l=>`${l.name}/ui`===s);return i?.deployedUrlEnv?[i.deployedUrlEnv]:[]}),o=t.length>0?await n(e,t):new Map;m.env[y]=e;for(let s of t){let i=o.get(s);i?m.env[s]=i:(delete m.env[s],d.warn(`\u2601\uFE0F "${e}" holds no ${s}; routes that go to the deployed app will fail until it does.`))}},S=async(e,r,a)=>{if(r.apps.length===0)return d.warn("No apps discovered to run."),null;let n=await e.checkbox({message:"\u{1F4E6} Which packages?",choices:F(r)});if(n.length===0)return d.warn("No packages selected."),null;let t=n.filter(u=>u.endsWith("/ui")),o=await Q(e,r,t),s=await e.confirm({message:"\u{1F440} Rebuild & restart on save (watch)?",default:!0}),i=J()?await e.confirm({message:"\u{1F9E9} Run each app in its own Orca pane?",default:!1}):!1,l={targets:n,sources:o,watch:s,orca:i},c=M(l,r);if(c.anyCloudRoute){if(r.environments.length===0)return d.warn("\u2601\uFE0F This selection routes to a cloud environment, but no environment token is loaded."),d.warn(" Run `infra-kit env-load` to add one, then re-run the wizard."),null;l.env=await e.select({message:"\u2601\uFE0F Point cloud routes at which environment?",choices:r.environments.map(u=>({name:u,value:u}))}),await re(l.env,t,r,a)}let f=Z(c.presetDef,r);if(f.length>0){d.warn("\u26A0\uFE0F Proxy audit found issues with this selection:");for(let u of f)d.warn(` \u2022 ${u}`);return null}Y(c,r),ae(c,l);let p=c.targetKeys.filter(u=>u.endsWith("/api")).map(u=>u.split("/")[0]);return i&&p.length>0?{include:p,presetDef:c.presetDef,watch:s,orca:!0}:(i&&d.info("\u2139\uFE0F Orca needs at least one local backend (panes are backend-only) \u2014 running in-process instead."),{presetDef:c.presetDef,watch:s,orca:!1})},ae=(e,r)=>{g.setInteractive();let a=z(e,r);g.addOption(a.flags,!0),g.print(),d.info("\u2139\uFE0F Prefer a short name? Save this selection as a devPreset and run `infra-kit dev <name>`.")},te=async(e,r)=>{let a=await e.confirm({message:"\u{1F440} Rebuild & restart on save (watch)?",default:!0});return g.setInteractive(),g.addOption(r,!0),a||g.addOption("--no-watch",!0),g.print(),{preset:r,watch:a,orca:!1}},A=" manual",ne=async(e,r,a=ee)=>{if(r.presets.length===0)return S(e,r,a);let n=await e.select({message:"\u{1F680} Start from a preset, or configure manually?",choices:[...r.presets.map(t=>({name:t,value:t})),new U(" "),{name:"Manual (custom)\u2026",value:A}]});return n===A?S(e,r,a):te(e,n)},ke=async(e=V,r=b(m.cwd()))=>ne(e,await T(r));export{A as MANUAL_CHOICE,G as WIZARD_ORCA_VAR,Z as auditManualPlan,V as defaultPrompts,T as gatherWizardModel,L as loadBackends,ke as runDevWizard,ne as runWizardFlow};
2
+ //# sourceMappingURL=dev-wizard-run-3DNKOVPD.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/dev/dev-wizard-run.ts", "../src/dev/dev-wizard.ts"],
4
+ "sourcesContent": ["/**\n * Impure driver for the interactive `infra-kit dev` wizard: filesystem/config discovery, the inquirer\n * prompt flow (step-0 preset-or-manual, then the manual matrix), the pre-flight proxy audit, and the\n * `commandEcho` teaching line. The pure answer\u2192plan mapping lives in {@link file://./dev-wizard.ts}.\n *\n * Prompts are behind the injectable {@link WizardPrompts} seam so the flow is testable without a TTY.\n * This module is reached ONLY from the bare-invocation TTY branch of the entry point; every flagged /\n * non-TTY / `--json` / `--agent` invocation bypasses it entirely.\n */\nimport inquirerCheckbox from '@inquirer/checkbox'\nimport inquirerConfirm from '@inquirer/confirm'\nimport inquirerSelect, { Separator } from '@inquirer/select'\nimport { loadDev, loadPackageConfig } from '@slip-stream-kit/config/internal'\nimport path from 'node:path'\nimport process from 'node:process'\n\nimport { discoverApiApps, discoverUiApps, findMonorepoRoot } from 'src/dev/discovery'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { INFRA_KIT_ENV_VAR } from 'src/lib/constants'\nimport { readTokenStore } from 'src/lib/env-tokens'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport type { DevPreset, ProxySource } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { withEscape } from 'src/lib/prompts/escapable-context'\n\nimport { deriveManualPlan, equivalentCommand } from './dev-wizard.js'\nimport type { DerivedPlan, ManualSelection, ProxyBackend, RouteCap, WizardApp, WizardModel } from './dev-wizard.js'\nimport { validatePresetProxy } from './presets.js'\nimport type { DiscoveredParts, PresetProxyContext } from './presets.js'\n\n/** A wizard prompt choice \u2014 all values are strings, so the seam needs no generics. */\nexport interface WizardChoice {\n name: string\n value: string\n description?: string\n checked?: boolean\n disabled?: boolean | string\n}\n\n/**\n * Injectable prompt seam (a string-valued subset of `@inquirer/*`). The default implementation\n * ({@link defaultPrompts}) delegates to the real prompts, rendering to stderr so the dev-server's\n * stdout stays clean. Tests pass a scripted object.\n */\nexport interface WizardPrompts {\n select: (cfg: { message: string; choices: (WizardChoice | Separator)[]; default?: string }) => Promise<string>\n checkbox: (cfg: { message: string; choices: WizardChoice[] }) => Promise<string[]>\n confirm: (cfg: { message: string; default?: boolean }) => Promise<boolean>\n}\n\n/**\n * Shared `@inquirer/*` context. Rendered to stderr (mirrors the bare-`infra-kit` command palette).\n *\n * `clearPromptOnDone` erases each answered prompt instead of leaving a `\u2714 <question> <answer>` line\n * behind, so the wizard collapses to nothing once it finishes and the dev-server's ready header lands\n * at the top of a clean screen. The choices are not lost: {@link echoManual} / {@link runPresetBranch}\n * print the equivalent flag command, which is the durable record of what was picked.\n */\nconst promptContext = { output: process.stderr, clearPromptOnDone: true }\n\n/**\n * Real `@inquirer/*` prompts, rendered to stderr and erased once answered.\n *\n * Every one goes through {@link withEscape}, which binds Esc to cancellation. The wrap is here rather\n * than around the {@link WizardPrompts} seam so the scripted prompts the tests inject stay untouched:\n * the seam is the test boundary, `defaultPrompts` is the only implementation that talks to a terminal.\n *\n * Esc rejects with an `AbortPromptError`, which `entry/cli.ts` catches as a cancellation \u2192 exit 0. The\n * wizard therefore needs no cancel branch of its own: a cancelled prompt never returns here at all, so\n * no server is started.\n */\nexport const defaultPrompts: WizardPrompts = {\n select: (cfg) => {\n // The wizard is TTY-only by construction (`shouldRunWizard`); the declaration is for the sweep,\n // which roots `entry/dev-server.ts` and reads the policy off the literal.\n return withEscape(\n (context) => {\n return inquirerSelect({ message: cfg.message, choices: cfg.choices, default: cfg.default }, context)\n },\n { ...promptContext, whenHeadless: 'refuse' },\n )\n },\n checkbox: (cfg) => {\n return withEscape(\n (context) => {\n return inquirerCheckbox({ message: cfg.message, choices: cfg.choices }, context)\n },\n { ...promptContext, whenHeadless: 'refuse' },\n )\n },\n confirm: (cfg) => {\n return withEscape(\n (context) => {\n return inquirerConfirm({ message: cfg.message, default: cfg.default }, context)\n },\n { ...promptContext, whenHeadless: 'refuse' },\n )\n },\n}\n\n/** What the wizard hands back to the entry point (merged into `DevServerOptions`), or null on cancel. */\nexport interface WizardResult {\n /** Named preset (preset branch) \u2014 passed through as `options.preset`. */\n preset?: string\n /** In-memory preset (manual branch, non-Orca) \u2014 passed through as `options.presetDef`. */\n presetDef?: DevPreset\n /**\n * App-name include list for the Orca path only: which discovered API apps get a pane. Paired with\n * `presetDef`, which tells each pane the exact parts to run. An app selected UI-only gets no pane\n * (Orca panes are opened per API app). Unset for the non-Orca manual path.\n */\n include?: string[]\n watch: boolean\n orca: boolean\n}\n\n/** Group one frontend's `dev.proxy.routes` into {@link ProxyBackend}s keyed by backend package. */\nconst groupBackends = (\n routes: Record<string, { packageName: string; from: readonly string[]; default?: 'local' | 'cloud' }>,\n ownerByPkg: Map<string, string>,\n): ProxyBackend[] => {\n const byPkg = new Map<string, ProxyBackend>()\n\n for (const [route, def] of Object.entries(routes)) {\n const cap: RouteCap = {\n path: route,\n localCapable: def.from.includes('local'),\n cloudCapable: def.from.includes('cloud'),\n default: def.default,\n }\n const existing = byPkg.get(def.packageName)\n\n if (existing) {\n existing.routes.push(cap)\n existing.localCapable = existing.localCapable || cap.localCapable\n existing.cloudCapable = existing.cloudCapable || cap.cloudCapable\n } else {\n byPkg.set(def.packageName, {\n packageName: def.packageName,\n routes: [cap],\n localCapable: cap.localCapable,\n cloudCapable: cap.cloudCapable,\n ownerApp: ownerByPkg.get(def.packageName),\n })\n }\n }\n\n return [...byPkg.values()]\n}\n\n/**\n * Load one frontend's proxy routes and group them into backends. A config that throws \u2014 schema-invalid\n * or an import-time error \u2014 degrades THAT app to zero backends with a named warning instead of rejecting.\n * Without this, a single broken `apps/<x>/ui/infra-kit.config.ts` fails the whole `Promise.all` in\n * {@link gatherWizardModel} and takes the entire wizard down, so `infra-kit dev` becomes unusable for every\n * other app in the monorepo. Mirrors the audit path's per-app guard ({@link file://../commands/audit/preset-proxy-check.ts}).\n */\nexport const loadBackends = async (\n uiDir: string,\n name: string,\n ownerByPkg: Map<string, string>,\n): Promise<ProxyBackend[]> => {\n try {\n const routes = (await loadDev(uiDir))?.proxy?.routes\n\n return routes ? groupBackends(routes, ownerByPkg) : []\n } catch (error) {\n logger.warn(\n `\u26A0\uFE0F Skipping ${name}: its dev config failed to load \u2014 ${error instanceof Error ? error.message : String(error)}`,\n )\n\n return []\n }\n}\n\n/** Discover apps + configs and assemble the {@link WizardModel} (backends resolved per frontend). */\nexport const gatherWizardModel = async (root: string): Promise<WizardModel> => {\n const apiApps = discoverApiApps(root)\n const uiApps = discoverUiApps(root)\n const config = await getInfraKitConfig()\n\n const ownerByPkg = new Map(\n apiApps.map((a) => {\n return [a.packageName, a.name] as const\n }),\n )\n const apiPkgByName = new Map(\n apiApps.map((a) => {\n return [a.name, a.packageName] as const\n }),\n )\n const uiNames = new Set(\n uiApps.map((a) => {\n return a.name\n }),\n )\n const apiNames = new Set(\n apiApps.map((a) => {\n return a.name\n }),\n )\n const allNames = [...new Set([...apiNames, ...uiNames])].sort()\n\n const apps: WizardApp[] = await Promise.all(\n allNames.map(async (name): Promise<WizardApp> => {\n const hasUi = uiNames.has(name)\n\n return {\n name,\n hasApi: apiNames.has(name),\n hasUi,\n apiPackage: apiPkgByName.get(name),\n backends: hasUi ? await loadBackends(path.join(root, 'apps', name, 'ui'), name, ownerByPkg) : [],\n deployedUrlEnv: hasUi\n ? (\n await loadPackageConfig(path.join(root, 'apps', name, 'ui')).catch(() => {\n return undefined\n })\n )?.deployedUrlEnv\n : undefined,\n }\n }),\n )\n\n // The cloud-env choices are the envs we hold a token for \u2014 the same authority as `env-load`, because\n // it is the same question. Picking one loads that env's deployed URLs for the picked frontends, which\n // `@slip-stream-kit/config/vite` sends their cloud routes to \u2014 and the download needs the env's token. Sourcing it from the workflow options instead would put `prod` in the list\n // for everyone \u2014 including a developer holding no prod credential \u2014 and point a local UI at\n // production. No token, no entry.\n const store = await readTokenStore()\n\n return {\n apps,\n presets: Object.keys(config.devServersPresets ?? {}),\n environments: Object.keys(store?.envs ?? {}).sort(),\n }\n}\n\n/**\n * Build the checkbox choices: one `<app>/ui` per frontend, plus `<app>/api` ONLY for api-only apps\n * (an api with no ui). A full-stack `<app>/api` is deliberately NOT offered \u2014 a full-stack backend is\n * launched by choosing `local` for one of its frontend's routes (asked per-route afterwards), so the\n * checkbox stays a pick of frontends + standalone backends.\n *\n * Nothing starts checked: the manual branch is opt-in, so a run only ever launches what was explicitly\n * ticked. Pre-checking every part would make the fast path (accept the defaults) boot the whole monorepo\n * \u2014 the exact opposite of why someone reached for \"Manual\" over a preset.\n */\nconst buildPartChoices = (model: WizardModel): WizardChoice[] => {\n const choices: WizardChoice[] = []\n\n for (const app of model.apps) {\n if (app.hasUi) {\n const paths = app.backends.flatMap((b) => {\n return b.routes.map((r) => {\n return r.path\n })\n })\n const description = paths.length > 0 ? `frontend \u2014 proxies ${[...paths].sort().join(', ')}` : 'frontend'\n\n choices.push({ name: `${app.name}/ui`, value: `${app.name}/ui`, description })\n }\n if (app.hasApi && !app.hasUi) {\n choices.push({ name: `${app.name}/api`, value: `${app.name}/api`, description: 'backend' })\n }\n }\n\n return choices\n}\n\n/** Build the audit context from the gathered model (no re-reading of configs). */\nconst buildAuditContext = (model: WizardModel): PresetProxyContext => {\n const discovered: DiscoveredParts = {\n api: model.apps\n .filter((a) => {\n return a.hasApi\n })\n .map((a) => {\n return a.name\n }),\n ui: model.apps\n .filter((a) => {\n return a.hasUi\n })\n .map((a) => {\n return a.name\n }),\n }\n const apiPkgByApp: Record<string, string> = {}\n const routeToPkg = new Map<string, string>()\n\n for (const app of model.apps) {\n // Map EVERY discovered api app to its own api package \u2014 including api-only apps a frontend proxies\n // to cross-app \u2014 so `launchedPkgs` in validatePresetProxy is faithful (mirrors preset-proxy-check.ts).\n // Deriving this from proxy backends alone would miss api-only owners and false-positive the audit.\n if (app.apiPackage != null) apiPkgByApp[app.name] = app.apiPackage\n for (const b of app.backends) {\n for (const route of b.routes) {\n routeToPkg.set(`${app.name} ${route.path}`, b.packageName)\n }\n }\n }\n\n return {\n discovered,\n apiPkgByApp,\n routePkg: (app, route) => {\n return routeToPkg.get(`${app} ${route}`)\n },\n }\n}\n\n/**\n * Run the assembled plan through the SAME proxy-locality rule the root audit uses. Returns issue\n * messages (empty when clean). Catches a `local` override whose backend won't launch \u2014 the wizard's\n * derivation launches owners, so a hit means the backend has no discoverable owning app.\n */\nexport const auditManualPlan = (presetDef: DevPreset, model: WizardModel): string[] => {\n return validatePresetProxy({ __wizard__: presetDef }, buildAuditContext(model)).map((i) => {\n return i.message\n })\n}\n\n/**\n * Opt back into the Orca question: set to exactly `'1'`. The prompt is temporarily off \u2014 the manual\n * branch always runs in-process \u2014 but the derivation below is kept whole for when it returns. `--orca`\n * on the command line is a separate path and stays live either way.\n */\nexport const WIZARD_ORCA_VAR = 'INFRA_KIT_DEV_WIZARD_ORCA'\n\nconst asksOrca = (): boolean => {\n return process.env[WIZARD_ORCA_VAR] === '1'\n}\n\n/**\n * Ask, per selected frontend, an EXPLICIT local/cloud choice for every TWO-OPTION route (its `from`\n * lists both). Single-option routes are auto-picked in the pure mapping, so they are never prompted.\n * The answers are keyed `${app}/ui ${routePath}` to match {@link ManualSelection.sources}; the select's\n * default seeds from the route's declared `default` when it has one.\n */\nconst promptRouteSources = async (\n prompts: WizardPrompts,\n model: WizardModel,\n uiKeys: string[],\n): Promise<Record<string, ProxySource>> => {\n const apps = new Map(\n model.apps.map((a) => {\n return [a.name, a] as const\n }),\n )\n const sources: Record<string, ProxySource> = {}\n\n for (const key of uiKeys) {\n const app = apps.get(key.split('/')[0]!)\n\n for (const backend of app?.backends ?? []) {\n for (const route of backend.routes) {\n if (!route.localCapable || !route.cloudCapable) continue\n\n const answer = await prompts.select({\n message: `\uD83D\uDD00 ${key} ${route.path} \u2192 local or cloud?`,\n choices: [\n { name: 'local (this machine)', value: 'local' },\n { name: 'cloud', value: 'cloud' },\n ],\n default: route.default ?? 'local',\n })\n\n sources[`${key} ${route.path}`] = answer as ProxySource\n }\n }\n }\n\n return sources\n}\n\n/** Look up a frontend route's capability in the model (for the recap's \"only option\" annotation). */\nconst findRouteCap = (model: WizardModel, app: string, routePath: string): RouteCap | undefined => {\n return model.apps\n .find((a) => {\n return a.name === app\n })\n ?.backends.flatMap((b) => {\n return b.routes\n })\n .find((r) => {\n return r.path === routePath\n })\n}\n\n/**\n * Print a one-line-per-route recap of what each frontend route resolved to, so the chosen sources are\n * visible before launch. A single-option route is annotated `(only option)` \u2014 it was auto-picked, not\n * asked. This is in addition to {@link echoManual}'s pasteable `--target` command.\n */\nconst recapSources = (plan: DerivedPlan, model: WizardModel): void => {\n const lines: string[] = []\n\n for (const [key, cfg] of Object.entries(plan.presetDef.apps ?? {})) {\n if (!key.endsWith('/ui') || !cfg.proxy) continue\n\n const app = key.split('/')[0]!\n\n for (const [routePath, source] of Object.entries(cfg.proxy)) {\n const cap = findRouteCap(model, app, routePath)\n const suffix = cap && cap.localCapable && cap.cloudCapable ? '' : ' (only option)'\n\n lines.push(` ${key} ${routePath} \u2192 ${source}${suffix}`)\n }\n }\n\n if (lines.length === 0) return\n logger.info('Resolved routes:')\n for (const line of [...lines].sort()) {\n logger.info(line)\n }\n}\n\n/** The manual-branch flow: frontends + per-route source + env + watch + orca \u2192 audited plan \u2192 recap \u2192 echo. */\n/** Reads named variables of one environment (its Doppler config). A seam, so the flow runs without Doppler in tests. */\nexport type LoadEnvVars = (env: string, names: string[]) => Promise<Map<string, string>>\n\nconst loadEnvVarsFromDoppler: LoadEnvVars = async (env, names) => {\n const { downloadEnvSecrets } = await import('src/commands/env-load/env-load')\n const secrets = await downloadEnvSecrets(env)\n\n return new Map(\n names.flatMap((name) => {\n const value = secrets.get(name)\n\n return value === undefined ? [] : [[name, value] as const]\n }),\n )\n}\n\n/**\n * Point this session's cloud routes at the picked env: its name, and the deployed URL of every picked\n * frontend. The URLs are the picked env's own \u2014 the shell may hold another env's, and `INFRA_KIT_ENV` alone\n * no longer names a host. Backends keep the shell's env; only what the proxy reads changes.\n */\nconst applyCloudEnv = async (\n env: string,\n uiKeys: string[],\n model: WizardModel,\n loadEnvVars: LoadEnvVars,\n): Promise<void> => {\n const names = uiKeys.flatMap((key) => {\n const app = model.apps.find((candidate) => {\n return `${candidate.name}/ui` === key\n })\n\n return app?.deployedUrlEnv ? [app.deployedUrlEnv] : []\n })\n const values = names.length > 0 ? await loadEnvVars(env, names) : new Map<string, string>()\n\n process.env[INFRA_KIT_ENV_VAR] = env\n\n for (const name of names) {\n const value = values.get(name)\n\n if (value) {\n process.env[name] = value\n } else {\n // The shell's value names another env's host; keeping it would send this env's cloud routes there.\n delete process.env[name]\n logger.warn(`\u2601\uFE0F \"${env}\" holds no ${name}; routes that go to the deployed app will fail until it does.`)\n }\n }\n}\n\nconst runManualBranch = async (\n prompts: WizardPrompts,\n model: WizardModel,\n loadEnvVars: LoadEnvVars,\n): Promise<WizardResult | null> => {\n if (model.apps.length === 0) {\n logger.warn('No apps discovered to run.')\n\n return null\n }\n\n const selectedTargets = await prompts.checkbox({ message: '\uD83D\uDCE6 Which packages?', choices: buildPartChoices(model) })\n\n if (selectedTargets.length === 0) {\n logger.warn('No packages selected.')\n\n return null\n }\n\n const uiKeys = selectedTargets.filter((t) => {\n return t.endsWith('/ui')\n })\n const sources = await promptRouteSources(prompts, model, uiKeys)\n\n const watch = await prompts.confirm({ message: '\uD83D\uDC40 Rebuild & restart on save (watch)?', default: true })\n const orca = asksOrca()\n ? await prompts.confirm({ message: '\uD83E\uDDE9 Run each app in its own Orca pane?', default: false })\n : false\n\n const selection: ManualSelection = { targets: selectedTargets, sources, watch, orca }\n const plan = deriveManualPlan(selection, model)\n\n if (plan.anyCloudRoute) {\n // A cloud route needs an environment to point at, and the only environments we can offer are those we\n // hold a token for. With none loaded, the `select` below would be handed zero choices and `@inquirer/select`\n // throws `No selectable choices` \u2014 a raw stack on a realistic first-run path (fresh clone, no `env-load`).\n // Back out cleanly with guidance instead, and BEFORE mutating `process.env`, so a refused run leaks nothing.\n if (model.environments.length === 0) {\n logger.warn('\u2601\uFE0F This selection routes to a cloud environment, but no environment token is loaded.')\n logger.warn(' Run `infra-kit env-load` to add one, then re-run the wizard.')\n\n return null\n }\n\n selection.env = await prompts.select({\n message: '\u2601\uFE0F Point cloud routes at which environment?',\n choices: model.environments.map((e) => {\n return { name: e, value: e }\n }),\n })\n await applyCloudEnv(selection.env, uiKeys, model, loadEnvVars)\n }\n\n const issues = auditManualPlan(plan.presetDef, model)\n\n if (issues.length > 0) {\n logger.warn('\u26A0\uFE0F Proxy audit found issues with this selection:')\n for (const issue of issues) {\n logger.warn(` \u2022 ${issue}`)\n }\n\n return null\n }\n\n recapSources(plan, model)\n echoManual(plan, selection)\n\n // Orca opens one pane per selected API app. `include` picks WHICH apps get a pane; `presetDef` tells\n // each pane exactly which of its parts to run. Without the latter a pane runs `--app=<name>`, which\n // expands to every part the app has \u2014 silently starting a UI the user just unticked.\n const apiApps = plan.targetKeys\n .filter((k) => {\n return k.endsWith('/api')\n })\n .map((k) => {\n return k.split('/')[0]!\n })\n\n // An empty include would collapse to `null` in `normalizeAppInclude` and make Orca run EVERY api app,\n // so an Orca run with no selected backends (e.g. an all-frontend selection) falls back to in-process.\n if (orca && apiApps.length > 0) {\n return { include: apiApps, presetDef: plan.presetDef, watch, orca: true }\n }\n\n if (orca) {\n logger.info('\u2139\uFE0F Orca needs at least one local backend (panes are backend-only) \u2014 running in-process instead.')\n }\n\n return { presetDef: plan.presetDef, watch, orca: false }\n}\n\n/** Print the equivalent (`--target=\u2026`) flag command, plus a save-as-preset ergonomics hint. */\nconst echoManual = (plan: DerivedPlan, selection: ManualSelection): void => {\n commandEcho.setInteractive()\n\n const eq = equivalentCommand(plan, selection)\n\n commandEcho.addOption(eq.flags, true)\n commandEcho.print()\n\n // The `--target=\u2026` line reproduces the selection exactly; the preset is pure convenience \u2014 a short,\n // memorable name instead of retyping the target keys.\n logger.info('\u2139\uFE0F Prefer a short name? Save this selection as a devPreset and run `infra-kit dev <name>`.')\n}\n\n/** The preset-branch flow: run a named preset, asking only whether to watch (presets can't encode it). */\nconst runPresetBranch = async (prompts: WizardPrompts, preset: string): Promise<WizardResult> => {\n const watch = await prompts.confirm({ message: '\uD83D\uDC40 Rebuild & restart on save (watch)?', default: true })\n\n commandEcho.setInteractive()\n commandEcho.addOption(preset, true)\n if (!watch) commandEcho.addOption('--no-watch', true)\n commandEcho.print()\n\n return { preset, watch, orca: false }\n}\n\n/** Sentinel value for the \"Manual (custom)\" step-0 choice (a preset name can never be empty). */\nexport const MANUAL_CHOICE = ' manual'\n\n/**\n * Drive the wizard's branch flow over an ALREADY-gathered model (no disk/config access). Split from\n * {@link runDevWizard} so the flow is unit-testable with scripted prompts + a fixture model.\n */\nexport const runWizardFlow = async (\n prompts: WizardPrompts,\n model: WizardModel,\n loadEnvVars: LoadEnvVars = loadEnvVarsFromDoppler,\n): Promise<WizardResult | null> => {\n if (model.presets.length === 0) {\n return runManualBranch(prompts, model, loadEnvVars)\n }\n\n const choice = await prompts.select({\n message: '\uD83D\uDE80 Start from a preset, or configure manually?',\n choices: [\n ...model.presets.map((p) => {\n return { name: p, value: p }\n }),\n new Separator(' '),\n { name: 'Manual (custom)\u2026', value: MANUAL_CHOICE },\n ],\n })\n\n return choice === MANUAL_CHOICE ? runManualBranch(prompts, model, loadEnvVars) : runPresetBranch(prompts, choice)\n}\n\n/**\n * Gather the model from disk/config, then drive the wizard flow, returning the resolved run options (or\n * null on cancel / empty selection). The entry point calls this on a bare TTY `infra-kit dev`.\n */\nexport const runDevWizard = async (\n prompts: WizardPrompts = defaultPrompts,\n root: string = findMonorepoRoot(process.cwd()),\n): Promise<WizardResult | null> => {\n return runWizardFlow(prompts, await gatherWizardModel(root))\n}\n", "/**\n * Pure core of the interactive `infra-kit dev` wizard (the no-args, TTY path).\n *\n * The wizard is FRONTEND-CENTRIC: you pick which frontends to run, and for each frontend you choose,\n * every proxy route that has TWO real options (its `from` lists both `local` and `cloud`) is decided\n * EXPLICITLY \u2014 local (its backend is launched \u2192 the route resolves local) or cloud (the route proxies\n * to the `<env>` cloud target). Single-option routes are auto-picked. Because a backend runs local OR\n * cloud as a whole, routes that share one backend package RECONCILE: if any of them resolved local, the\n * backend runs local and all its local-capable routes follow. This module turns those answers into an\n * in-memory {@link DevPreset} the runner consumes verbatim (part-level targets the app-name-only `--app`\n * include cannot express) \u2014 and is side-effect-free so the mapping is fully unit-testable. The impure\n * I/O (discovery, inquirer prompts, audit, launch) lives in {@link file://./dev-wizard-run.ts}.\n */\nimport type { DevPreset, ProxySource } from 'src/lib/infra-kit-config'\n\n/**\n * One proxy route's per-route capability, carried through grouping so the wizard can decide whether it\n * even needs to ask about the route (only a `local`+`cloud` route is a real choice).\n */\nexport interface RouteCap {\n /** Route path (e.g. `/api`). */\n path: string\n /** `from` includes `local` \u2014 the route can resolve to a locally-launched backend. */\n localCapable: boolean\n /** `from` includes `cloud` \u2014 the route can resolve to the cloud target. */\n cloudCapable: boolean\n /** The route's declared `default` source when it has one (present iff `from` lists >1 source) \u2014 seeds the prompt's default. */\n default?: ProxySource\n}\n\n/**\n * One backend a frontend's proxy routes can be pointed at, grouped by the backend package. A frontend\n * that maps `/api` and `/media` to the same package yields ONE {@link ProxyBackend} with both routes \u2014\n * launching the package flips every one of its `local`-capable routes together (the reconcile in\n * {@link deriveManualPlan}).\n */\nexport interface ProxyBackend {\n /** Backend package name (a route's `packageName`). */\n packageName: string\n /** The routes that resolve to this package, each with its own local/cloud capability. */\n routes: RouteCap[]\n /** True when at least one of `routes` lists `local` in its `from` capabilities \u2014 i.e. it is launchable-local. */\n localCapable: boolean\n /** True when at least one of `routes` lists `cloud` \u2014 i.e. it can stay on the cloud target. */\n cloudCapable: boolean\n /** App folder whose `api` package is {@link packageName}, or undefined when no discovered app owns it (a `local` choice then has nothing to launch \u2014 the audit flags it). */\n ownerApp?: string\n}\n\n/** A discovered app as the wizard sees it: which parts exist + which backends its frontend proxies to. */\nexport interface WizardApp {\n /** App folder name (e.g. `client`). */\n name: string\n /** Has `apps/<app>/api` (a launchable backend). */\n hasApi: boolean\n /** Has `apps/<app>/ui` (a launchable frontend). */\n hasUi: boolean\n /**\n * This app's OWN `api` package name (from `apps/<app>/api`), or undefined when it has no api. Carried\n * so the audit can build a faithful `app \u2192 apiPackage` map for EVERY discovered api app \u2014 including\n * api-only apps a frontend proxies to cross-app \u2014 mirroring the root audit (`preset-proxy-check.ts`).\n */\n apiPackage?: string\n /** Backends this app's frontend proxies to (empty for api-only apps or a frontend with no `dev.proxy`). */\n backends: ProxyBackend[]\n /** The frontend's `deployedUrlEnv` \u2014 the variable its cloud routes are sent to. Absent when it declares none. */\n deployedUrlEnv?: string\n}\n\n/** Everything the wizard needs, gathered impurely by {@link file://./dev-wizard-run.ts}. */\nexport interface WizardModel {\n /** All discovered apps (api and/or ui), sorted by name. */\n apps: WizardApp[]\n /** `devServersPresets` names (drives the preset-or-manual step-0). */\n presets: string[]\n /** Configured `environments` (the cloud-env `select` options). */\n environments: string[]\n}\n\n/** The manual-branch answers collected from the prompts, fed to {@link deriveManualPlan}. */\nexport interface ManualSelection {\n /**\n * The target keys the user ticked directly: every selected `<app>/ui` frontend, plus any api-only\n * `<app>/api` backend (apps with an api but no ui). A full-stack backend is NOT ticked here \u2014 it is\n * launched by choosing `local` for one of its frontend's routes (recorded in {@link sources}).\n */\n targets: string[]\n /**\n * Explicit per-route choice for every TWO-OPTION route, keyed `${app}/ui ${routePath}` (e.g.\n * `client/ui /api`). Single-option routes are absent (auto-picked). Missing two-option answers fall\n * back to the route's cloud/local capability in {@link deriveManualPlan}.\n */\n sources: Record<string, ProxySource>\n /** Chosen cloud env for cloud routes (undefined when nothing resolves cloud). */\n env?: string\n /** Rebuild + restart on save. */\n watch: boolean\n /** One Orca pane per app. */\n orca: boolean\n}\n\n/** The resolved run plan derived from a {@link ManualSelection}. */\nexport interface DerivedPlan {\n /** In-memory preset handed to the runner (`options.presetDef`). */\n presetDef: DevPreset\n /** At least one route resolves to cloud \u2192 an env must be chosen (pre-flight gate). */\n anyCloudRoute: boolean\n /** Resolved `<app>/<part>` target keys, sorted \u2014 for the echo + audit display. */\n targetKeys: string[]\n}\n\n/** App folder name from an `<app>/<part>` target key. */\nconst appOf = (key: string): string => {\n return key.split('/')[0]!\n}\n\n/** Index a model's apps by folder name for O(1) lookup. */\nconst byName = (model: WizardModel): Map<string, WizardApp> => {\n return new Map(\n model.apps.map((a) => {\n return [a.name, a]\n }),\n )\n}\n\n/** Is this route a real choice (both local and cloud reachable)? */\nconst isTwoOption = (route: RouteCap): boolean => {\n return route.localCapable && route.cloudCapable\n}\n\n/**\n * The source a single route resolves to BEFORE per-backend reconciliation:\n * - two-option: the user's recorded answer, else 'cloud' when cloud-capable else 'local';\n * - single local-only: always 'local';\n * - single cloud-only: always 'cloud'.\n */\nconst rawSource = (uiKey: string, route: RouteCap, sources: Record<string, ProxySource>): ProxySource => {\n if (isTwoOption(route)) {\n return sources[`${uiKey} ${route.path}`] ?? (route.cloudCapable ? 'cloud' : 'local')\n }\n\n return route.localCapable ? 'local' : 'cloud'\n}\n\n/**\n * Pass 1: which backend packages resolve local (any of their routes did), plus each package's owner app.\n * A package's local verdict is shared across every frontend that proxies to it \u2014 that is the reconcile.\n */\nconst collectLocalPackages = (\n uiKeys: string[],\n apps: Map<string, WizardApp>,\n sources: Record<string, ProxySource>,\n): { localPkgs: Set<string>; ownerByPkg: Map<string, string | undefined> } => {\n const localPkgs = new Set<string>()\n const ownerByPkg = new Map<string, string | undefined>()\n\n for (const key of uiKeys) {\n const app = apps.get(appOf(key))\n\n for (const backend of app?.backends ?? []) {\n ownerByPkg.set(backend.packageName, backend.ownerApp)\n for (const route of backend.routes) {\n if (rawSource(key, route, sources) === 'local') localPkgs.add(backend.packageName)\n }\n }\n }\n\n return { localPkgs, ownerByPkg }\n}\n\n/**\n * Pass 2 for ONE frontend: its per-route overrides after the per-package verdict, and whether any route\n * went cloud. A local-capable route on a local package is `local` (reconciled up); everything else `cloud`.\n */\nconst frontendOverrides = (\n app: WizardApp | undefined,\n localPkgs: ReadonlySet<string>,\n): { overrides: Record<string, ProxySource>; anyCloud: boolean } => {\n const overrides: Record<string, ProxySource> = {}\n let anyCloud = false\n\n for (const backend of app?.backends ?? []) {\n const backendLocal = localPkgs.has(backend.packageName)\n\n for (const route of backend.routes) {\n const source: ProxySource = route.localCapable && backendLocal ? 'local' : 'cloud'\n\n overrides[route.path] = source\n if (source === 'cloud') anyCloud = true\n }\n }\n\n return { overrides, anyCloud }\n}\n\n/**\n * Turn the manual {@link ManualSelection} into an in-memory {@link DevPreset}. The frontend checkbox picks\n * which UIs (and standalone api-only backends) to run; the per-route answers in {@link ManualSelection.sources}\n * decide each two-option route. Resolution is two passes so same-backend routes stay coherent:\n *\n * 1. Resolve every route of every selected frontend to its raw source; a package is LOCAL iff any of its\n * routes resolved local.\n * 2. Re-resolve each route against that per-package verdict: a local-capable route on a local package is\n * `local` (reconciled up even if it was individually answered cloud); a cloud-only route stays `cloud`.\n *\n * Launched backends are the ticked api-only parts \u222A every package that resolved local (added as\n * `${ownerApp}/api` when the owner is discoverable \u2014 a local override on an owner-less package is still\n * emitted, and the audit flags it).\n *\n * @example\n * // client frontend, its /api answered local \u2192 launches client/api + client/ui, /api resolves local:\n * deriveManualPlan(\n * { targets: ['client/ui'], sources: { 'client/ui /api': 'local' }, watch: false, orca: false },\n * { apps: [{ name: 'client', hasApi: true, hasUi: true, backends: [{ packageName: 'client-api',\n * cloudCapable: true, localCapable: true, ownerApp: 'client',\n * routes: [{ path: '/api', localCapable: true, cloudCapable: true }] }] }],\n * presets: [], environments: ['dev'] },\n * ).targetKeys // => ['client/api', 'client/ui']\n */\nexport const deriveManualPlan = (selection: ManualSelection, model: WizardModel): DerivedPlan => {\n const apps = byName(model)\n const uiKeys = selection.targets.filter((t) => {\n return t.endsWith('/ui')\n })\n const apiOnlyKeys = selection.targets.filter((t) => {\n return t.endsWith('/api')\n })\n\n // Pass 1: a package is local iff any of its routes (across every selected frontend) resolved local.\n const { localPkgs, ownerByPkg } = collectLocalPackages(uiKeys, apps, selection.sources)\n\n // Pass 2: re-resolve each route against the per-package verdict + build per-frontend overrides.\n const presetApps: Record<string, { proxy?: Record<string, ProxySource> }> = {}\n let anyCloud = false\n\n for (const key of uiKeys) {\n const { overrides, anyCloud: cloud } = frontendOverrides(apps.get(appOf(key)), localPkgs)\n\n if (cloud) anyCloud = true\n presetApps[key] = Object.keys(overrides).length > 0 ? { proxy: overrides } : {}\n }\n\n // Launch: the ticked api-only backends, plus every package that resolved local (via its owner app).\n for (const key of apiOnlyKeys) {\n presetApps[key] ??= {}\n }\n for (const pkg of localPkgs) {\n const owner = ownerByPkg.get(pkg)\n\n if (owner != null) presetApps[`${owner}/api`] ??= {}\n }\n\n return {\n presetDef: { apps: presetApps, orca: selection.orca },\n anyCloudRoute: anyCloud,\n targetKeys: Object.keys(presetApps).sort(),\n }\n}\n\n/** The equivalent non-interactive command for a derived plan. */\nexport interface EquivalentCommand {\n /** The `--target=<app>/<part>,\u2026`-form flag string (no leading `infra-kit dev`). */\n flags: string\n}\n\n/**\n * Build the equivalent `infra-kit dev --target=\u2026 [--no-watch] [--orca]` flag string for a derived plan.\n * Always exact: `--target` names packages at `<app>/<part>` granularity \u2014 the same grammar the plan's\n * `targetKeys` already use \u2014 so every wizard selection, whole-app or part-level, round-trips into a\n * pasteable command. (`--app` is deliberately NOT used here: its app-name granularity over-launches a\n * part-level pick \u2014 `--app=client` starts `client/api` even when only `client/ui` was ticked.)\n */\nexport const equivalentCommand = (plan: DerivedPlan, selection: ManualSelection): EquivalentCommand => {\n const parts = [`--target=${plan.targetKeys.join(',')}`]\n\n if (!selection.watch) parts.push('--no-watch')\n if (selection.orca) parts.push('--orca')\n\n return { flags: parts.join(' ') }\n}\n"],
5
+ "mappings": "+RASA,OAAOA,MAAsB,qBAC7B,OAAOC,MAAqB,oBAC5B,OAAOC,GAAkB,aAAAC,MAAiB,mBAC1C,OAAS,WAAAC,EAAS,qBAAAC,MAAyB,mCAC3C,OAAOC,MAAU,YACjB,OAAOC,MAAa,eCkGpB,IAAMC,EAASC,GACNA,EAAI,MAAM,GAAG,EAAE,CAAC,EAInBC,EAAUC,GACP,IAAI,IACTA,EAAM,KAAK,IAAKC,GACP,CAACA,EAAE,KAAMA,CAAC,CAClB,CACH,EAIIC,EAAeC,GACZA,EAAM,cAAgBA,EAAM,aAS/BC,EAAY,CAACC,EAAeF,EAAiBG,IAC7CJ,EAAYC,CAAK,EACZG,EAAQ,GAAGD,CAAK,IAAIF,EAAM,IAAI,EAAE,IAAMA,EAAM,aAAe,QAAU,SAGvEA,EAAM,aAAe,QAAU,QAOlCI,EAAuB,CAC3BC,EACAC,EACAH,IAC4E,CAC5E,IAAMI,EAAY,IAAI,IAChBC,EAAa,IAAI,IAEvB,QAAWb,KAAOU,EAAQ,CACxB,IAAMI,EAAMH,EAAK,IAAIZ,EAAMC,CAAG,CAAC,EAE/B,QAAWe,KAAWD,GAAK,UAAY,CAAC,EAAG,CACzCD,EAAW,IAAIE,EAAQ,YAAaA,EAAQ,QAAQ,EACpD,QAAWV,KAASU,EAAQ,OACtBT,EAAUN,EAAKK,EAAOG,CAAO,IAAM,SAASI,EAAU,IAAIG,EAAQ,WAAW,CAErF,CACF,CAEA,MAAO,CA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,CAC/F,IAAMb,EAAQ,MAAM5B,EAAQ,QAAQ,CAAE,QAAS,+CAAyC,QAAS,EAAK,CAAC,EAEvG,OAAAqC,EAAY,eAAe,EAC3BA,EAAY,UAAUI,EAAQ,EAAI,EAC7Bb,GAAOS,EAAY,UAAU,aAAc,EAAI,EACpDA,EAAY,MAAM,EAEX,CAAE,OAAAI,EAAQ,MAAAb,EAAO,KAAM,EAAM,CACtC,EAGac,EAAgB,UAMhBC,GAAgB,MAC3B3C,EACAlB,EACAuC,EAA2BP,KACM,CACjC,GAAIhC,EAAM,QAAQ,SAAW,EAC3B,OAAO2C,EAAgBzB,EAASlB,EAAOuC,CAAW,EAGpD,IAAMuB,EAAS,MAAM5C,EAAQ,OAAO,CAClC,QAAS,wDACT,QAAS,CACP,GAAGlB,EAAM,QAAQ,IAAK+D,IACb,CAAE,KAAMA,EAAG,MAAOA,CAAE,EAC5B,EACD,IAAIC,EAAU,GAAG,EACjB,CAAE,KAAM,wBAAoB,MAAOJ,CAAc,CACnD,CACF,CAAC,EAED,OAAOE,IAAWF,EAAgBjB,EAAgBzB,EAASlB,EAAOuC,CAAW,EAAImB,GAAgBxC,EAAS4C,CAAM,CAClH,EAMaG,GAAe,MAC1B/C,EAAyB3D,EACzBsB,EAAeqF,EAAiB5G,EAAQ,IAAI,CAAC,IAEtCuG,GAAc3C,EAAS,MAAMtC,EAAkBC,CAAI,CAAC",
6
+ "names": ["inquirerCheckbox", "inquirerConfirm", "inquirerSelect", "Separator", "loadDev", "loadPackageConfig", "path", "process", "appOf", "key", "byName", "model", "a", "isTwoOption", "route", "rawSource", "uiKey", "sources", "collectLocalPackages", "uiKeys", "apps", "localPkgs", "ownerByPkg", "app", "backend", "frontendOverrides", "overrides", "anyCloud", "backendLocal", "source", "deriveManualPlan", "selection", "t", "apiOnlyKeys", "presetApps", "cloud", "pkg", "owner", "equivalentCommand", "plan", "parts", "promptContext", "process", "defaultPrompts", "cfg", "withEscape", "context", "inquirerSelect", "inquirerCheckbox", "inquirerConfirm", "groupBackends", "routes", "ownerByPkg", "byPkg", "route", "def", "cap", "existing", "loadBackends", "uiDir", "name", "loadDev", "error", "logger", "gatherWizardModel", "root", "apiApps", "discoverApiApps", "uiApps", "discoverUiApps", "config", "getInfraKitConfig", "a", "apiPkgByName", "uiNames", "apiNames", "allNames", "apps", "hasUi", "path", "loadPackageConfig", "store", "readTokenStore", "buildPartChoices", "model", "choices", "app", "paths", "b", "r", "description", "buildAuditContext", "discovered", "apiPkgByApp", "routeToPkg", "auditManualPlan", "presetDef", "validatePresetProxy", "i", "WIZARD_ORCA_VAR", "asksOrca", "promptRouteSources", "prompts", "uiKeys", "sources", "key", "backend", "answer", "findRouteCap", "routePath", "recapSources", "plan", "lines", "source", "suffix", "line", "loadEnvVarsFromDoppler", "env", "names", "downloadEnvSecrets", "secrets", "value", "applyCloudEnv", "loadEnvVars", "candidate", "values", "INFRA_KIT_ENV_VAR", "runManualBranch", "selectedTargets", "t", "watch", "orca", "selection", "deriveManualPlan", "e", "issues", "issue", "echoManual", "k", "commandEcho", "eq", "equivalentCommand", "runPresetBranch", "preset", "MANUAL_CHOICE", "runWizardFlow", "choice", "p", "Separator", "runDevWizard", "findMonorepoRoot"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{A as h,B as i,C as j,D as k,E as l,t as a,u as b,v as c,w as d,x as e,y as f,z as g}from"./chunk-UD6VVXUY.js";import"./chunk-DW2SQ2XU.js";import"./chunk-FRBNA6VH.js";import"./chunk-MFAFQVTW.js";import"./chunk-MFHYIQ7B.js";import"./chunk-QSTGO43H.js";import"./chunk-QWVLAZ6N.js";export{d as DOPPLER_MAX_OUTPUT_BYTES,i as assertDopplerOutputSize,g as assertTokenScope,e as buildDopplerChildEnv,a as buildEnvLoadFileLines,f as downloadEnvSecrets,c as envLoad,l as envLoadMcpTool,k as parseDopplerSecretsJson,j as shellSingleQuote,h as translateDopplerDownloadError,b as writeEnvLoadFile};
2
+ //# sourceMappingURL=env-load-MF26WMDL.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1,2 @@
1
- import{p as i}from"./chunk-BQPSXIH2.js";import"./chunk-AWFGP6GY.js";import{a as t}from"./chunk-6SLDCUNI.js";import"./chunk-QSTGO43H.js";import a from"node:fs";import o from"node:process";import{fileURLToPath as s}from"node:url";var m=r=>{let n=r.indexOf("--parent-pid");if(n===-1)return;let e=Number(r[n+1]);return Number.isInteger(e)&&e>0?e:void 0},p=()=>a.realpathSync(s(new URL("./cli.js",import.meta.url))),d=async()=>{await i(t.version,{selfRealPath:p(),parentPid:m(o.argv)})};d().catch(()=>{o.exitCode=0});
1
+ import{p as i}from"./chunk-BQPSXIH2.js";import"./chunk-AWFGP6GY.js";import{a as t}from"./chunk-MFHYIQ7B.js";import"./chunk-QSTGO43H.js";import a from"node:fs";import o from"node:process";import{fileURLToPath as s}from"node:url";var m=r=>{let n=r.indexOf("--parent-pid");if(n===-1)return;let e=Number(r[n+1]);return Number.isInteger(e)&&e>0?e:void 0},p=()=>a.realpathSync(s(new URL("./cli.js",import.meta.url))),d=async()=>{await i(t.version,{selfRealPath:p(),parentPid:m(o.argv)})};d().catch(()=>{o.exitCode=0});
2
2
  //# sourceMappingURL=update-check.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "infra-kit",
3
3
  "type": "module",
4
- "version": "0.11.16",
4
+ "version": "0.14.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ArthurSaenz/infra-kit.git",
@@ -26,7 +26,7 @@
26
26
  "@inquirer/input": "^5.1.6",
27
27
  "@inquirer/password": "^5.2.2",
28
28
  "@inquirer/select": "^5.2.5",
29
- "@slip-stream-kit/config": "^0.11.16",
29
+ "@slip-stream-kit/config": "^0.14.0",
30
30
  "chalk": "^6.0.0",
31
31
  "chokidar": "^5.0.0",
32
32
  "commander": "^15.0.0",
@@ -41,7 +41,7 @@
41
41
  "zx": "^8.8.5"
42
42
  },
43
43
  "devDependencies": {
44
- "@slip-stream-kit/eslint-plugin": "0.11.16",
44
+ "@slip-stream-kit/eslint-plugin": "0.14.0",
45
45
  "@types/aws-lambda": "^8.10.163",
46
46
  "@types/react": "19.3.0",
47
47
  "@wl/eslint-config": "0.1.0",
package/readme.md CHANGED
@@ -42,11 +42,13 @@ Code loads is self-contained and needs no config reader at session start.
42
42
 
43
43
  ## Configuration
44
44
 
45
- **infra-kit.json** (runtime)
46
- Defines dev server ports, environment providers (e.g., Doppler), and preset proxy templates. Consumed by `infra-kit dev` and the MCP server.
45
+ The split is by level: one `infra-kit.json` per repo, one `infra-kit.config.ts` per workspace package. The repo root has no `infra-kit.config.ts`.
47
46
 
48
- **infra-kit.config.ts** (audit)
49
- Strict schema file that declares audit rules (`requiredScripts`, `requiredFiles`) and an optional `type` override (`frontend` | `backend` | `lib` | `e2e` | `mobile`) used by the `agent-guidance` check. Validated by `infra-kit audit`. No runtime behavior.
47
+ **infra-kit.json** (repo)
48
+ Repo-wide settings: environment providers (e.g., Doppler), dev server ports and presets, worktrees, MCP proxies, and the `audit` block `infra-kit audit --root` checks the root against. Layered with personal overrides from `~/.infra-kit/infra-kit.json` and `~/.infra-kit/projects/<repo>/infra-kit.json`; `mcp`, `vendorSource` and `audit` are accepted only in the committed file. A leftover root `infra-kit.config.ts` fails `audit --root`; `infra-kit audit --fix --root` moves its rules into `audit` and deletes it.
49
+
50
+ **infra-kit.config.ts** (package)
51
+ Strict schema file that declares the package's audit rules (`requiredScripts`, `requiredFiles`), an optional `type` override (`frontend` | `backend` | `lib` | `e2e` | `mobile`) used by the `agent-guidance` check, and the `dev.proxy` / `e2e` blocks read by the Vite plugin, `infra-kit dev` and the Playwright helper.
50
52
 
51
53
  An `e2e` package (declared, or inferred from `apps/<app>/tests` / a `@playwright/test` dependency) is additionally held to the shared Playwright convention, which no config key can switch off: the `e2e-test*` / `playwright-install` scripts must carry their canonical values (`e2e-script:*` checks), and `playwright.config.ts` must read `E2E_SLOW_MO`, pass it to `launchOptions.slowMo`, add it to `timeout`, and keep traces on local failures (`e2e-config:*` checks). Each failure prints the expected line.
52
54
 
@@ -1,2 +0,0 @@
1
- var i={name:"infra-kit",type:"module",version:"0.11.16",repository:{type:"git",url:"git+https://github.com/ArthurSaenz/infra-kit.git",directory:"apps/infra-kit/cli"},files:["dist"],description:"infra-kit",bin:{"infra-kit":"dist/cli.js",ik:"dist/cli.js","ik-mcp":"dist/mcp-proxy.js"},engines:{node:">=24.x"},scripts:{build:"pnpm run clean-artifacts && node ./scripts/build.js",prepack:"pnpm run build","infra-kit-check":"pnpm exec infra-kit audit","clean-artifacts":"rm -rf dist","clean-cache":"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc","prettier-fix":"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","prettier-check":"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","eslint-check":"pnpm exec eslint --cache --report-unused-disable-directives ./src","eslint-fix":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix","ts-check":"tsc --noEmit",test:"pnpm exec vitest run --reporter=minimal","test-watch":"pnpm exec vitest --watch --silent passed-only","test-ui":"pnpm exec vitest --ui --silent passed-only","test-report":"pnpm exec vitest run --coverage --silent passed-only","qa:pty":"INFRA_KIT_REQUIRE_PTY=1 pnpm exec vitest run --reporter=minimal src/tui/__tests__/stdin-pause-pty.test.ts src/entry/__tests__/quit-keys-pty.test.ts src/entry/__tests__/post-run-pause-pty.test.ts",qa:"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success",fix:"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa"},dependencies:{"@aws-lambda-powertools/logger":"^2.35.0","@inquirer/checkbox":"^5.2.5","@inquirer/confirm":"^6.3.2","@inquirer/input":"^5.1.6","@inquirer/password":"^5.2.2","@inquirer/select":"^5.2.5","@slip-stream-kit/config":"workspace:^",chalk:"^6.0.0",chokidar:"^5.0.0",commander:"^15.0.0",fastify:"^5.12.5",ink:"^7.1.1",pino:"^10.3.1","pino-pretty":"^13.1.3",portless:"^0.15.6",react:"19.3.0",yaml:"^2.9.1",zod:"^4.6.5",zx:"^8.8.5"},devDependencies:{"@slip-stream-kit/eslint-plugin":"workspace:*","@types/aws-lambda":"catalog:","@types/react":"catalog:","@wl/eslint-config":"workspace:*","@wl/vitest-config":"workspace:*",esbuild:"^0.28.2","ink-testing-library":"^4.0.0",typescript:"^6.0.3"}};export{i as a};
2
- //# sourceMappingURL=chunk-6SLDCUNI.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../package.json"],
4
- "sourcesContent": ["{\n \"name\": \"infra-kit\",\n \"type\": \"module\",\n \"version\": \"0.11.16\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/ArthurSaenz/infra-kit.git\",\n \"directory\": \"apps/infra-kit/cli\"\n },\n \"files\": [\n \"dist\"\n ],\n \"description\": \"infra-kit\",\n \"bin\": {\n \"infra-kit\": \"dist/cli.js\",\n \"ik\": \"dist/cli.js\",\n \"ik-mcp\": \"dist/mcp-proxy.js\"\n },\n \"engines\": {\n \"node\": \">=24.x\"\n },\n \"scripts\": {\n \"build\": \"pnpm run clean-artifacts && node ./scripts/build.js\",\n \"prepack\": \"pnpm run build\",\n \"infra-kit-check\": \"pnpm exec infra-kit audit\",\n \"clean-artifacts\": \"rm -rf dist\",\n \"clean-cache\": \"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc\",\n \"prettier-fix\": \"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore\",\n \"prettier-check\": \"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore\",\n \"eslint-check\": \"pnpm exec eslint --cache --report-unused-disable-directives ./src\",\n \"eslint-fix\": \"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix\",\n \"ts-check\": \"tsc --noEmit\",\n \"test\": \"pnpm exec vitest run --reporter=minimal\",\n \"test-watch\": \"pnpm exec vitest --watch --silent passed-only\",\n \"test-ui\": \"pnpm exec vitest --ui --silent passed-only\",\n \"test-report\": \"pnpm exec vitest run --coverage --silent passed-only\",\n \"qa:pty\": \"INFRA_KIT_REQUIRE_PTY=1 pnpm exec vitest run --reporter=minimal src/tui/__tests__/stdin-pause-pty.test.ts src/entry/__tests__/quit-keys-pty.test.ts src/entry/__tests__/post-run-pause-pty.test.ts\",\n \"qa\": \"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success\",\n \"fix\": \"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa\"\n },\n \"dependencies\": {\n \"@aws-lambda-powertools/logger\": \"^2.35.0\",\n \"@inquirer/checkbox\": \"^5.2.5\",\n \"@inquirer/confirm\": \"^6.3.2\",\n \"@inquirer/input\": \"^5.1.6\",\n \"@inquirer/password\": \"^5.2.2\",\n \"@inquirer/select\": \"^5.2.5\",\n \"@slip-stream-kit/config\": \"workspace:^\",\n \"chalk\": \"^6.0.0\",\n \"chokidar\": \"^5.0.0\",\n \"commander\": \"^15.0.0\",\n \"fastify\": \"^5.12.5\",\n \"ink\": \"^7.1.1\",\n \"pino\": \"^10.3.1\",\n \"pino-pretty\": \"^13.1.3\",\n \"portless\": \"^0.15.6\",\n \"react\": \"19.3.0\",\n \"yaml\": \"^2.9.1\",\n \"zod\": \"^4.6.5\",\n \"zx\": \"^8.8.5\"\n },\n \"devDependencies\": {\n \"@slip-stream-kit/eslint-plugin\": \"workspace:*\",\n \"@types/aws-lambda\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"@wl/eslint-config\": \"workspace:*\",\n \"@wl/vitest-config\": \"workspace:*\",\n \"esbuild\": \"^0.28.2\",\n \"ink-testing-library\": \"^4.0.0\",\n \"typescript\": \"^6.0.3\"\n }\n}\n"],
5
- "mappings": "AAAA,IAAAA,EAAA,CACE,KAAQ,YACR,KAAQ,SACR,QAAW,UACX,WAAc,CACZ,KAAQ,MACR,IAAO,mDACP,UAAa,oBACf,EACA,MAAS,CACP,MACF,EACA,YAAe,YACf,IAAO,CACL,YAAa,cACb,GAAM,cACN,SAAU,mBACZ,EACA,QAAW,CACT,KAAQ,QACV,EACA,QAAW,CACT,MAAS,sDACT,QAAW,iBACX,kBAAmB,4BACnB,kBAAmB,cACnB,cAAe,2EACf,eAAgB,4HAChB,iBAAkB,4HAClB,eAAgB,oEAChB,aAAc,kFACd,WAAY,eACZ,KAAQ,0CACR,aAAc,gDACd,UAAW,6CACX,cAAe,uDACf,SAAU,qMACV,GAAM,gHACN,IAAO,6DACT,EACA,aAAgB,CACd,gCAAiC,UACjC,qBAAsB,SACtB,oBAAqB,SACrB,kBAAmB,SACnB,qBAAsB,SACtB,mBAAoB,SACpB,0BAA2B,cAC3B,MAAS,SACT,SAAY,SACZ,UAAa,UACb,QAAW,UACX,IAAO,SACP,KAAQ,UACR,cAAe,UACf,SAAY,UACZ,MAAS,SACT,KAAQ,SACR,IAAO,SACP,GAAM,QACR,EACA,gBAAmB,CACjB,iCAAkC,cAClC,oBAAqB,WACrB,eAAgB,WAChB,oBAAqB,cACrB,oBAAqB,cACrB,QAAW,UACX,sBAAuB,SACvB,WAAc,QAChB,CACF",
6
- "names": ["package_default"]
7
- }
@@ -1,12 +0,0 @@
1
- import{a as ce}from"./chunk-MFAFQVTW.js";import{a as ae}from"./chunk-6SLDCUNI.js";import{d as _,p as ie,q as se}from"./chunk-QSTGO43H.js";import Ue from"node:process";import qe from"pino";import He from"pino-pretty";var Je=["token","*.token","serviceToken","*.serviceToken","DOPPLER_TOKEN","*.DOPPLER_TOKEN","INFRA_KIT_ENV_TOKEN","*.INFRA_KIT_ENV_TOKEN"],Xe=()=>{let e=Ue.argv.includes("--debug")?"debug":"info",t=["time","pid","hostname"];return e==="debug"&&t.push("level"),qe({level:e,redact:Je},He({destination:2,ignore:t.join(","),colorize:!0,sync:!0}))},L=Xe();import re from"node:fs/promises";import $e from"node:os";import A from"node:path";import Bt from"node:process";import{z as i}from"zod";import Qe from"node:process";import Ye from"node:process";var $={enabled:!1},Ze=(e,t=r=>{Ye.stdout.write(r)})=>($.enabled&&e&&e.structuredContent!=null&&t(`${JSON.stringify(e.structuredContent,null,2)}
2
- `),e),pe=e=>{e.options.some(r=>r.long==="--json")||e.option("--json","Output the structured result as JSON on stdout (human logs stay on stderr)"),e.commands.forEach(pe)};var ue={source:null},P=()=>ue.source!==null,et=()=>P()||$.enabled,K=()=>!!Qe.env.CI,tt=({env:e,stdinIsTTY:t,flag:r})=>{if(r)return"flag";let n=e.INFRA_KIT_AGENT;return n==="1"||e.CLAUDECODE!==void 0&&!t&&n!=="0"?"env":null};var F=e=>{throw new Error(`Unexpected value: ${JSON.stringify(e)}`)};var w=(e,t)=>Object.fromEntries(Object.entries(e).filter(([r])=>r!==t));var S=({key:e,id:t,note:r})=>({id:t,note:r,apply:n=>e in n?{changed:!0,result:w(n,e)}:{changed:!1,result:n}});var le=S({key:"devProxy",id:"drop-dev-proxy-key",note:'the retired "devProxy" key (dev URLs are port-free https://<release>.<package>.localhost)'});var de=S({key:"envAutoLoad",id:"drop-env-auto-load-key",note:'the retired "envAutoLoad" key (env auto-load is gone \u2014 run `env-load -c <config>` in the terminal)'});var me=S({key:"environments",id:"drop-environments-key",note:`the retired "environments" key (deploy targets now come from each workflow's workflow_dispatch options, auth from the token store)`});var rt=e=>{let t=e.ide;if(t===null||typeof t!="object")return{changed:!1,result:e};let r=!1,n=s=>{if(s===null||typeof s!="object"||!("config"in s))return s;let a=s.config;return a===null||typeof a!="object"||!("mode"in a)?s:(r=!0,{...s,config:w(a,"mode")})},o=Array.isArray(t)?t.map(n):n(t);return r?{changed:!0,result:{...e,ide:o}}:{changed:!1,result:e}},ge={id:"strip-legacy-ide-mode",note:'legacy "mode"',apply:rt};var nt="zed",fe=e=>e!==null&&typeof e=="object"&&e.provider===nt,ot=e=>{let t=e.ide;if(Array.isArray(t)){let r=t.filter(n=>!fe(n));return r.length===t.length?{changed:!1,result:e}:{changed:!0,result:r.length>0?{...e,ide:r}:w(e,"ide")}}return fe(t)?{changed:!0,result:w(e,"ide")}:{changed:!1,result:e}},he={id:"strip-retired-zed-ide",note:'the retired "zed" provider',apply:ot};var W=[ge,he,me,le,de];var C=e=>W.reduce((t,r)=>{let n=r.apply(t.result);return n.changed?{changed:!0,result:n.result,notes:[...t.notes,r.note]}:t},{changed:!1,result:e,notes:[]});import it from"node:fs/promises";import st from"node:os";var at=async e=>{try{return await it.access(e),!0}catch{return!1}},G=e=>{let t=st.homedir();return e.startsWith(t)?`~${e.slice(t.length)}`:e};import{randomBytes as ct}from"node:crypto";import v from"node:fs/promises";import B from"node:path";import pt from"node:process";var D=class extends Error{constructor(t){super(`${t} changed on disk since it was read`),this.name="ConfigFileChangedError"}},ut=2,lt=e=>/^([ \t]+)\S/m.exec(e)?.[1]??ut,dt=4095,O=async({path:e,raw:t,migrated:r,expectedMtimeMs:n})=>{let o=await v.realpath(e),s=B.dirname(o),a=B.basename(o),p=B.join(s,`.${a}.${pt.pid}.${ct(4).toString("hex")}.tmp`),l=`${JSON.stringify(r,null,lt(t))}
3
- `;try{await v.writeFile(p,l,"utf8");let d=await v.stat(o);if(d.mtimeMs!==n)throw new D(e);await v.chmod(p,d.mode&dt),await v.rename(p,o)}catch(d){throw await v.rm(p,{force:!0}),d}},mt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),gt=async e=>{let t=await v.stat(e),r=await v.readFile(e,"utf8");if(r.trim()==="")return{changed:!1,result:{},notes:[],path:e};let n=JSON.parse(r);if(!mt(n))return{changed:!1,result:{},notes:[],path:e};let o=C(n);return o.changed&&await O({path:e,raw:r,migrated:o.result,expectedMtimeMs:t.mtimeMs}),{...o,path:e}};var V=async(e,t,r,{schema:n})=>{if(e.autoMigrate==="off")return{kind:"not-applicable"};let o=C(t);if(!o.changed)return{kind:"not-applicable"};let s=n.safeParse(o.result);if(!s.success)return{kind:"not-applicable"};if(e.required&&K())return{kind:"ci-gated"};try{await O({path:e.path,raw:r,migrated:o.result,expectedMtimeMs:e.mtimeMs})}catch(a){return L.debug(a,`auto-migration could not rewrite ${e.path}`),{kind:"not-applicable"}}return L.warn(`Migrated ${G(e.path)}: removed ${o.notes.join(" and ")} (retired by infra-kit ${ae.version})`),{kind:"migrated",data:s.data}};import E from"node:path";import be from"node:process";import{$ as m}from"zx";var I=e=>{let t=new Set,r=e;for(;r!==null&&typeof r=="object"&&!t.has(r);){t.add(r);let{stderr:n,stderrExcerpt:o}=r;if(typeof n=="string"&&n.length>0)return n;if(typeof o=="string"&&o.length>0)return o;r=r.cause}},ft=(e,t)=>{let r=t.stderrExcerpt??I(e),n=[`failed to ${t.operation}`];return r&&n.push(`stderr: ${r.slice(0,200).trim()}`),t.remediation&&n.push(`try: ${t.remediation}`),n.join(" \u2014 ")},g=class extends Error{operation;remediation;stderrExcerpt;constructor(t,r){super(ft(t,r),{cause:t}),this.name="OperationError",this.operation=r.operation,this.remediation=r.remediation,this.stderrExcerpt=r.stderrExcerpt??I(t)}};var ht=/^v?(\d+)\.(\d+)\.(\d+)$/,yt=/^(\d+)\.(\d+)\.(\d+)$/,vt=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,T="release/",z="release/v",ye="refs/heads/",kt="next";var ve=new Set(["dev","main","next","hotfix","regular","release"]),x=class extends Error{constructor(t){super(t),this.name="InvalidReleaseNameError"}},b=class extends Error{constructor(t){super(t),this.name="InvalidReleaseRefError"}},we=e=>e.startsWith(ye)?e.slice(ye.length):e,xe=(e,t,r)=>({kind:"version",semver:{major:e,minor:t,patch:r},raw:`${e}.${t}.${r}`}),U=e=>{if(e.length===0)throw new x('Release name is empty. Provide a kebab-case name like "checkout-redesign".');if(e.length>50)throw new x(`Release name "${e}" is ${e.length} characters; the maximum is 50.`);if(!vt.test(e))throw new x(`Release name "${e}" is not kebab-case. Use lowercase letters, digits, and single hyphens, e.g. "checkout-redesign".`);if(ve.has(e))throw new x(`Release name "${e}" is reserved. Reserved names: ${[...ve].join(", ")}.`)},q=e=>{let t=we(e.trim());if(!t.startsWith(T))return null;if(t.startsWith(z)){let n=t.slice(z.length),o=yt.exec(n);if(o)return xe(Number(o[1]),Number(o[2]),Number(o[3]))}let r=t.slice(T.length);try{U(r)}catch{return null}return{kind:"name",name:r,raw:r}},wt=e=>{let t=e.trim();if(we(t).startsWith(T)){let o=q(t);if(!o)throw new b(`"${e}" looks like a release branch but is not a valid release/v<semver> or release/<name> ref.`);return o}let n=ht.exec(t);if(n)return xe(Number(n[1]),Number(n[2]),Number(n[3]));if(t.toLowerCase()===kt)throw new b('The "next" token must be resolved to a concrete version (via computeNextVersion) before parsing a release ref.');if(t.includes("@"))throw new b(`Cannot parse "${e}" as a release ref: the \`@date\` suffix belongs to \`release create\`; pass the version alone here and use \`--release-date\` on \`release edit\``);try{U(t)}catch(o){let s=o instanceof Error?o.message:String(o);throw new b(`Cannot parse "${e}" as a release ref: ${s}`)}return{kind:"name",name:t,raw:t}},xt=e=>e.kind==="version"?`${z}${e.raw}`:`${T}${e.name}`,bt=(e,t)=>{let r=t==="hotfix"?"Hotfix":"Release";return e.kind==="version"?`${r} v${e.raw}`:`${r} ${e.name}`},Rt=e=>e.kind==="version"?`Release v${e.raw} (RC)`:`Release ${e.name} (RC)`,Pt=e=>e.kind==="version"?`v${e.raw}`:e.name,St=e=>e.raw,H=e=>e==null?!1:q(e)!==null,ke=e=>{if(e===void 0)return null;let t=e instanceof Date?e.getTime():new Date(e).getTime();return Number.isNaN(t)?null:t},Et=(e,t,r)=>{if(e.kind==="version"&&t.kind==="version")return e.semver.major!==t.semver.major?e.semver.major-t.semver.major:e.semver.minor!==t.semver.minor?e.semver.minor-t.semver.minor:e.semver.patch-t.semver.patch;if(e.kind==="version")return-1;if(t.kind==="version")return 1;let n=ke(r?.a),o=ke(r?.b);return n!==null&&o!==null&&n!==o?n-o:e.name<t.name?-1:e.name>t.name?1:0};var Re=async e=>{let t=await m({cwd:e})`git worktree list --porcelain`,r=[],n=null;for(let o of t.stdout.split(`
4
- `)){if(o.startsWith("worktree ")){n&&r.push(n),n={path:o.slice(9),branch:null,detached:!1,bare:!1,prunable:!1,locked:!1};continue}n&&(o.startsWith("branch ")?n.branch=o.slice(7).replace(/^refs\/heads\//,""):o==="detached"?n.detached=!0:o==="bare"?n.bare=!0:o==="locked"||o.startsWith("locked ")?n.locked=!0:(o==="prunable"||o.startsWith("prunable "))&&(n.prunable=!0))}return n&&r.push(n),r},Ct=async e=>{let t=await Re(be.cwd()),r=n=>e==="release"?H(n):n.startsWith("feature/");return t.map(n=>n.branch).filter(n=>n!==null&&r(n))},It=e=>{let t=I(e);return t&&/not a git repository/i.test(t)?"not a git repository":void 0},Mt=({hasStderr:e})=>{if(P())return"infra-kit resolves its project from the working directory; run it from inside an infra-kit project repo (or one of its git worktrees), or pass `-C <dir>` naming one";let t="run infra-kit from inside an infra-kit project repo (or one of its git worktrees)";return e?`${t}; if you are already in one, the stderr in this message is the real cause`:t},M=async()=>{try{return(await m({quiet:!0})`git rev-parse --show-toplevel`).stdout.trim()}catch(e){let t=It(e)??I(e);throw new g(e,{operation:`resolve the project root from ${be.cwd()}`,stderrExcerpt:t,remediation:Mt({hasStderr:t!==void 0})})}},J=async e=>{let t=e??await M(),r=(await m({cwd:t,quiet:!0})`git rev-parse --git-common-dir`).stdout.trim(),n=E.resolve(t,r);return n.includes(`${E.sep}.git${E.sep}modules${E.sep}`)?t:E.dirname(n)},Pe=async()=>(await m`git rev-parse --abbrev-ref HEAD`).stdout.trim(),Se=async()=>(await m`git status --porcelain`).stdout.split(`
5
- `).map(t=>t.trimEnd()).filter(t=>t.trim().length>0),jt=async()=>(await Se()).length===0,At=async()=>{let e=await M(),[t,r]=await Promise.all([m({cwd:e})`git rev-parse --absolute-git-dir`,m({cwd:e})`git rev-parse --git-common-dir`]),n=t.stdout.trim(),o=E.resolve(e,r.stdout.trim());return n!==o};var $t=async e=>(await m`git branch --list ${e}`).stdout.trim().length>0,Dt=async e=>{(await m`git branch --list ${e}`).stdout.trim().length!==0&&await Pe()!==e&&await m`git branch -D ${e}`},Ot=async e=>{(await m`git ls-remote --heads origin ${e}`).stdout.trim().length!==0&&await m`git push origin --delete ${e}`};import{$ as N}from"zx";var Tt=async(e,t)=>{let r=`${t}^{commit}`;try{return(await N({cwd:e,quiet:!0})`git rev-parse --verify --quiet ${r}`).stdout.trim()||null}catch{return null}},Nt=async(e,t,r)=>{try{return await N({cwd:e,quiet:!0})`git merge-base --is-ancestor ${t} ${r}`,!0}catch(n){if(n.exitCode===1)return!1;throw new g(n,{operation:`test whether ${t} is contained in ${r}`,remediation:"both refs must exist \u2014 verify them with rev-parse first"})}},_t=async(e,t)=>{let n=(await N({cwd:e,quiet:!0})`git ls-remote --heads origin ${t}`).stdout.trim().split(`
6
- `)[0];return n?n.split(/\s+/)[0]??null:null},Lt=async(e,t)=>{let r=t.map(n=>`${n.sha}:refs/heads/${n.branch}`);if(r.length===0)return{refspecs:r,pushed:!1};try{return await N({cwd:e,quiet:!0})`git push --atomic origin ${r}`,{refspecs:r,pushed:!0}}catch(n){return{refspecs:r,pushed:!1,stderr:n.stderr}}};import Y from"node:path";import X from"node:process";import{$ as h}from"zx";var Ee=async e=>{let t=e??X.cwd(),r=(await h({cwd:t,quiet:!0})`git rev-parse --git-common-dir`).stdout.trim(),n=X.env.INFRA_KIT_SESSION||String(X.pid);return Y.join(Y.resolve(t,r),"infra-kit",`merge-dev-${n}`)},Ce=e=>e.replace(/[^\w-]+/g,"-"),Kt=(e,t)=>Y.join(`${e}${ie}`,se.mergeDev,Ce(t)),Z=async e=>{try{return await h({cwd:e,quiet:!0})`git rev-parse -q --verify MERGE_HEAD`,!0}catch{return!1}},Ft=async e=>{if(await Z(e))throw new g(void 0,{operation:"reuse the scratch worktree",stderrExcerpt:"a merge is still in progress in the scratch worktree",remediation:"this is an infra-kit bug \u2014 the previous branch iteration did not clean up"});let t=(await h({cwd:e,quiet:!0})`git status --porcelain`).stdout.trim();if(t.length>0)throw new g(void 0,{operation:"reuse the scratch worktree",stderrExcerpt:`scratch worktree is dirty: ${t.split(`
7
- `)[0]}`,remediation:"this is an infra-kit bug \u2014 the previous branch iteration did not clean up"})},Wt=async e=>{let t=async r=>{try{await r()}catch{}};await Z(e)&&await t(()=>h({cwd:e,quiet:!0})`git merge --abort`),await t(()=>h({cwd:e,quiet:!0})`git reset --hard`),await t(()=>h({cwd:e,quiet:!0})`git clean -fd`)},Gt=async(e,t)=>{let{cwd:r,anchor:n="origin/dev"}=e,o=await Ee(r),s=async()=>{await h({cwd:r,quiet:!0})`git worktree add --detach ${o} ${n}`};try{await s()}catch(p){try{await h({cwd:r,quiet:!0})`git worktree prune`,await s()}catch{throw new g(p,{operation:"create the scratch worktree for the merge",remediation:`remove any stale checkout at ${o}, then retry`})}}let a={path:o,remove:async()=>{try{await h({cwd:r,quiet:!0})`git worktree remove --force ${o}`}catch{}}};try{return await t(a)}finally{await a.remove()}};var Ie="infra-kit.json";var Vt="infra-kit.json",zt="projects",Ut=i.object({provider:i.literal("doppler"),config:i.object({name:i.string().min(1)})}),qt=i.discriminatedUnion("provider",[Ut]),Ht=i.object({workspaceConfigPath:i.string().min(1)}).strict(),Jt=i.object({provider:i.literal("cursor"),config:Ht}).strict(),Me=i.discriminatedUnion("provider",[Jt]),Xt=i.union([Me,i.array(Me).min(1)]),Yt=i.object({provider:i.literal("jira"),config:i.object({baseUrl:i.string().url(),projectId:i.number().int().positive()})}),Zt=i.discriminatedUnion("provider",[Yt]),Qt=["two-columns","three-pane"],er=i.object({layout:i.enum(Qt).optional()}).strict(),tr=i.object({openInGithubDesktop:i.boolean().optional(),openInOrca:i.boolean().optional(),orca:er.optional()}).strict(),rr=i.object({port:i.number().int().positive().optional(),prefixUrl:i.string().min(1).optional()}).strict(),nr=i.record(i.string().min(1),rr),or=i.enum(["local","cloud"]),ir=i.object({watchDeps:i.boolean().optional(),proxy:i.record(i.string().min(1),or).optional()}).strict(),sr=i.object({apps:i.record(i.string().min(1),ir).optional(),orca:i.boolean().optional()}).strict(),ar=i.record(i.string().min(1),sr),cr=i.enum(["disallow","allow","cli-only"]),je=i.string().regex(/^[A-Z_]\w*$/i,"must be a POSIX environment-variable name"),pr=i.object({command:i.string().min(1),args:i.array(i.string()).default([]),env:i.array(je).min(1),unset:i.array(je).default([])}).strict().superRefine((e,t)=>{for(let r of e.env)ce.has(r)&&t.addIssue({code:"custom",path:["env"],message:`"${r}" is process plumbing the proxy never strips or injects \u2014 it cannot be a credential name`})}),ur=i.record(i.string().regex(/^[a-z][a-z0-9-]*$/,"must be lowercase letters, digits and hyphens, starting with a letter").refine(e=>!e.includes("infra-kit"),{message:'"infra-kit" is reserved: it is the .mcp.json key of the retired infra-kit MCP server \u2014 pick another name'}),pr),Ae=i.string().min(1).superRefine((e,t)=>{if(e.startsWith("/")||e.startsWith("\\")||/^[a-z]:/i.test(e)){t.addIssue({code:"custom",message:`"${e}" must be relative to the repository root`});return}let r=e.split(/[/\\]/).filter(o=>o!==""&&o!==".");r.includes("..")&&t.addIssue({code:"custom",message:`"${e}" must not contain a ".." segment`}),r[0]===".git"&&t.addIssue({code:"custom",message:`"${e}" must not be .git or a path inside it`}),e.includes("\\")&&t.addIssue({code:"custom",message:`"${e}" must use "/" as the separator, not "\\"`});let n=e.split("/");n.includes("")&&t.addIssue({code:"custom",message:`"${e}" must not have a trailing or doubled "/"`}),n.includes(".")&&t.addIssue({code:"custom",message:`"${e}" must not contain a "." segment; write it from the repository root, e.g. "vendor/configs"`})}),lr=i.object({path:Ae,target:Ae.optional()}).strict(),De=i.object({copy:i.array(lr).min(1),exclude:i.array(i.string().regex(/^[^/\\]+$/,'must be a single path segment, without "/"')).optional()}).strict(),ne=i.object({envManagement:qt,ide:Xt.optional(),taskManager:Zt.optional(),worktrees:tr.optional(),dev:nr.optional(),devServersPresets:ar.optional(),protectedEnvs:cr.optional(),mcp:ur.optional(),vendorSource:De.nullable().optional()}).strict(),dr=443,Oe=ne.superRefine((e,t)=>{if(!Array.isArray(e.ide))return;let r=new Set;for(let n of e.ide){if(r.has(n.provider)){t.addIssue({code:"custom",message:"each IDE provider may appear at most once",path:["ide"]});return}r.add(n.provider)}}),te=ne.partial(),mr=e=>{let t=e.ide;return t?Array.isArray(t)?t:[t]:[]},Te="two-columns",gr=e=>e.worktrees?.orca?.layout??Te,k=null,j=null,Ne=()=>`${Bt.cwd()} ${$e.homedir()}`,_e=()=>A.join($e.homedir(),_),Le=()=>A.join(_e(),Vt),Ke=async()=>{let e=Ne();if(j&&j.key===e)return j.value;let t=await M(),r=await J(t),n=A.basename(r),o={main:A.join(t,Ie),userGlobal:Le(),userProject:A.join(_e(),zt,n,Ie),projectName:n};return j={key:e,value:o},o},fr=async(e={})=>{let t=e.autoMigrate??"write",r=Ne(),n=await Ke(),o;try{o=await re.stat(n.main)}catch{k=null;let y=n.main.replace(/\.json$/,".yml");throw await Q(y)?new Error(`infra-kit.json not found at ${n.main}. A legacy infra-kit.yml exists \u2014 run \`infra-kit setup --skip-tools\` to convert it.`):new Error(P()?`infra-kit.json not found at ${n.main} \u2014 the working directory is not an infra-kit project. Run infra-kit from inside an infra-kit project repo, or pass \`-C <dir>\` naming one.`:`infra-kit.json not found at ${n.main} \u2014 this git repo is not an infra-kit project. Run \`infra-kit setup --skip-tools\` here to create it, cd into an infra-kit project repo, or check out a branch that has infra-kit.json.`)}let[s,a]=await Promise.all([Q(n.userGlobal),Q(n.userProject)]),p={main:Number(o.mtimeMs),userGlobal:s?Number(s.mtimeMs):null,userProject:a?Number(a.mtimeMs):null};if(k&&k.key===r&&kr(k.mtimes,p))return k.value;let l=[{label:"infra-kit.json",path:n.main,required:!0,autoMigrate:t,mtimeMs:p.main},{label:"~/.infra-kit/infra-kit.json",path:n.userGlobal,required:!1,autoMigrate:t,mtimeMs:p.userGlobal},{label:`~/.infra-kit/projects/${n.projectName}/infra-kit.json`,path:n.userProject,required:!1,autoMigrate:t,mtimeMs:p.userProject}],d={};for(let y of l){let R=await wr(y);R!==null&&(d={...d,...R})}let f=Oe.safeParse(d);if(!f.success)throw new Error(`Invalid merged infra-kit config: ${i.prettifyError(f.error)}`);return k={key:r,mtimes:p,value:f.data},f.data},hr=()=>{k=null},yr=()=>{k=null,j=null},Q=async e=>{try{return await re.stat(e)}catch{return null}},vr=async e=>{try{return await re.readFile(e,"utf-8")}catch{return null}},kr=(e,t)=>{let r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(n=>e[n]===t[n])},Fe=e=>new Error(`${e.message}
8
- A retired key on this branch \u2014 run \`infra-kit setup --skip-tools\` in this checkout and commit infra-kit.json.`),wr=async e=>{let t=await vr(e.path);if(t===null){if(e.required)throw new Error(`${e.label} not found at ${e.path}`);return null}let r;try{r=t.trim()===""?{}:JSON.parse(t)}catch(a){throw new Error(`Invalid JSON in ${e.label} at ${e.path}: ${a.message}`)}if(ee(r)&&"envTokens"in r)throw new Error(Sr(e));!e.required&&ee(r)&&Pr(e,r);let n=te.safeParse(r);if(n.success)return n.data;let o=new Error(`Invalid ${e.label} at ${e.path}: ${i.prettifyError(n.error)}`);if(!ee(r)||e.mtimeMs===null)throw o;let s=await V({...e,mtimeMs:e.mtimeMs},r,t,{schema:te});switch(s.kind){case"migrated":return s.data;case"ci-gated":throw Fe(o);case"not-applicable":throw o;default:return F(s)}},xr=e=>[`"mcp" is not allowed in ${e.label} (${e.path}): it feeds the committed .mcp.json, so a per-machine copy would replace the project's servers for everyone.`,"Move the block to the project infra-kit.json and run `infra-kit setup`.","For a machine-only override of one server (e.g. a local fork), use Claude Code directly:"," claude mcp add --scope local <name> -- ik-mcp --name <name> --env <VAR> ... -- <command> <args>","(local scope shadows the project entry by name; `claude mcp list` will show a same-name conflict warning, which is expected)."].join(`
9
- `),br=e=>[`"vendorSource" is not allowed in ${e.label} (${e.path}): only the committed project file may mark a repository as the \`vendor sync\` source. In the machine-wide file it would make every repository on this machine a source; in a per-project override it would make this machine disagree with every other clone.`,"Move the block to the source repository's own infra-kit.json and commit it there."].join(`
10
- `),Rr={mcp:xr,vendorSource:br},Pr=(e,t)=>{for(let[r,n]of Object.entries(Rr))if(r in t)throw new Error(n(e))},ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Sr=e=>[`Refusing to load ${e.label} \u2014 \`envTokens\` is not a config key.`,"A service token in a config file can be committed, backed up by your editor, or shared."," 1. REVOKE the token in Doppler now \u2014 treat it as compromised.",` 2. Remove the \`envTokens\` key from ${e.path}.`," 3. Re-add it privately: `infra-kit env-token-set <env>`"," (it is written to ~/.infra-kit/projects/<repo>/tokens.json, mode 0600, never to the repo)."].join(`
11
- `);import*as u from"node:fs";import*as c from"node:path";function Er(e){let t=e;for(let r=0;r<10;r++){let n=c.join(t,"pnpm-workspace.yaml");if(u.existsSync(n))return t;t=c.dirname(t)}throw new Error("Could not find monorepo root (pnpm-workspace.yaml)")}function Ge(e,t){let r=c.join(e,"package.json");if(!u.existsSync(r))return t;try{let n=JSON.parse(u.readFileSync(r,"utf-8"));return typeof n.name=="string"?n.name:t}catch{return t}}function Oo(e){let t=c.join(e,"apps"),r=[];if(!u.existsSync(t))throw new Error(`Apps directory not found: ${t}`);let n=u.readdirSync(t,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);for(let o of n){let s=c.join(t,o,"api"),a=c.join(s,"serverless.yml");u.existsSync(a)&&r.push({name:o,packageName:Ge(s,o),path:s})}return r}var Be=["vite.config.ts","vite.config.mts","vite.config.cts","vite.config.js","vite.config.mjs","vite.config.cjs"],Cr=["@slip-stream-kit/vite","@slip-stream-kit/config/vite","infra-kit/vite"];function Ir(e){for(let t of Be){let r=c.join(e,t);if(u.existsSync(r))try{let n=u.readFileSync(r,"utf-8");return Cr.some(o=>n.includes(o))}catch{return!1}}return!1}function To(e){for(let t of Be){let r=c.join(e,t);if(u.existsSync(r))try{return u.readFileSync(r,"utf-8").includes("infraKit(")}catch{return!1}}return!1}function Mr(e){let t=c.join(e,"package.json");if(!u.existsSync(t))return!1;try{let r=JSON.parse(u.readFileSync(t,"utf-8"));return typeof r.scripts?.dev=="string"&&r.scripts.dev.length>0}catch{return!1}}function No(e){let t=c.join(e,"apps"),r=[];if(!u.existsSync(t))return r;let n=u.readdirSync(t,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);for(let o of n){let s=c.join(t,o,"ui");u.existsSync(s)&&Mr(s)&&r.push({name:o,packageName:Ge(s,o),path:s,managedPort:Ir(s)})}return r}function _o(e){let t=e?.filter(Boolean)??[];return t.length>0?t:null}function Lo(e){let t=Er(e),r=c.relative(c.join(t,"apps"),e),n=r.split(c.sep)[0];if(r===""||r.startsWith("..")||c.isAbsolute(r)||!n)throw new Error(`--self: not inside an apps/<app> directory (cwd: ${e}). Run from an app folder or use --app=<name>.`);return n}var jr=new Set(["api","ui"]),We=e=>{let t=c.join(e,"dist");return u.existsSync(t)&&u.statSync(t).isDirectory()?t:void 0},oe=e=>u.existsSync(e)?u.readdirSync(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name):[];function Ko(e){let t=[];for(let n of oe(c.join(e,"packages"))){let o=We(c.join(e,"packages",n));o!==void 0&&t.push(o)}let r=c.join(e,"apps");for(let n of oe(r))for(let o of oe(c.join(r,n))){if(jr.has(o))continue;let s=c.join(r,n,o);if(!u.existsSync(c.join(s,"package.json")))continue;let a=We(s);a!==void 0&&t.push(a)}return t}function Fo(e){return e.map(t=>c.join(t.path,"dist")).filter(t=>u.existsSync(t))}function Wo(e,t,r){let n=c.normalize(e),o=p=>{let l=c.normalize(p);return n===l||n.startsWith(l+c.sep)},s=r.find(o);return s?{kind:"package",packageDir:s}:{kind:"app",app:t.find(o)}}var Ar={"*/api":{},"*/ui":{}},ze=e=>{let t=e.split("/"),[r,n]=t;return t.length!==2||!r?`devServersPresets: invalid target "${e}" (expected "<app>/api" or "<app>/ui")`:n!=="api"&&n!=="ui"?`devServersPresets: invalid target part "${n}" in "${e}" (expected "api" or "ui")`:null},$r=e=>{let t=ze(e);if(t)throw new Error(t);let[r,n]=e.split("/");return{appGlob:r,part:n}},Bo=e=>{let t=[];for(let[r,n]of Object.entries(e))for(let o of Object.keys(n.apps??{})){let s=ze(o);s&&t.push({preset:r,key:o,message:`preset "${r}": ${s}`})}return t},Dr=(e,t)=>t==="api"?e.api:e.ui,Or=e=>[...new Set([...e.api,...e.ui])].sort(),Ve=(e,t)=>`${e}/${t}`,Tr=e=>e?0:1,Nr=(e,t)=>t.watchDeps===void 0?e??{watchDeps:!0,rank:t.rank,explicitValue:!1}:!e||!e.explicitValue?{watchDeps:t.watchDeps,rank:t.rank,explicitValue:!0}:t.rank>e.rank?{watchDeps:t.watchDeps,rank:t.rank,explicitValue:!0}:e,_r=(e,t,r)=>{let{app:n,part:o,watchDeps:s,isGlob:a}=r;if(!Dr(t,o).includes(n)){a||e.unmatched.push(Ve(n,o));return}let p=Ve(n,o),l=Nr(e.targets.get(p),{watchDeps:s,rank:Tr(a)});e.targets.set(p,{app:n,part:o,...l})},Lr=(e,t)=>{let r=Object.entries(e.apps??Ar),n={targets:new Map,proxy:{},unmatched:[]};for(let[a,p]of r){let{appGlob:l,part:d}=$r(a),f=l==="*",y=f?Or(t):[l];for(let R of y)_r(n,t,{app:R,part:d,watchDeps:p.watchDeps,isGlob:f}),p.proxy&&(n.proxy[R]={...n.proxy[R]??{},...p.proxy})}let o=[...n.targets.values()].map(({app:a,part:p,watchDeps:l})=>({app:a,part:p,watchDeps:l})),s=[...new Set(o.filter(a=>a.part==="api").map(a=>a.app))];return{targets:o,orca:e.orca??!1,proxy:n.proxy,localApps:s,unmatched:n.unmatched}},Vo=e=>{if(e.preset!=null)return e.preset;if(e.running.length===0)return"nothing";let t=new Set(e.running);return e.discovered.every(n=>t.has(n))?"*":[...t].sort().join(" + ")},Kr=(e,t)=>Object.keys(e).find(r=>e[r]===t),Fr=({preset:e,app:t,route:r,launchedPkgs:n,ctx:o})=>{let s=o.routePkg(t,r);if(s===void 0)return{preset:e,app:t,route:r,kind:"unknown-route",message:`preset "${e}": proxy override "${r}" on "${t}" names a route not declared in ${t}'s infra-kit.config.ts dev.proxy.routes`};if(n.has(s))return null;let a=Kr(o.apiPkgByApp,s),p=a?`add "${a}/api" to the preset`:`launch the api whose package is "${s}"`;return{preset:e,app:t,route:r,pkg:s,kind:"backend-not-launched",message:`preset "${e}": proxy override "${r}" \u2192 "local" requires backend "${s}" to run locally, but the preset does not launch it \u2014 ${p}, or set "${r}" to "cloud"`}},zo=(e,t)=>{let r=[];for(let[n,o]of Object.entries(e)){let s=Lr(o,t.discovered),a=new Set(s.localApps.map(p=>t.apiPkgByApp[p]).filter(p=>p!==void 0));for(let[p,l]of Object.entries(s.proxy))for(let[d,f]of Object.entries(l)){if(f!=="local")continue;let y=Fr({preset:n,app:p,route:d,launchedPkgs:a,ctx:t});y&&r.push(y)}}return r};export{$ as a,Ze as b,pe as c,ue as d,P as e,et as f,tt as g,I as h,g as i,x as j,U as k,q as l,wt as m,xt as n,bt as o,Rt as p,Pt as q,St as r,H as s,Et as t,Re as u,Ct as v,M as w,J as x,Pe as y,Se as z,jt as A,At as B,$t as C,Dt as D,Ot as E,Tt as F,Nt as G,_t as H,Lt as I,Ce as J,Kt as K,Z as L,Ft as M,Wt as N,Gt as O,L as P,F as Q,at as R,G as S,D as T,gt as U,De as V,dr as W,Oe as X,te as Y,mr as Z,gr as _,Le as $,Ke as aa,fr as ba,hr as ca,yr as da,Er as ea,Oo as fa,To as ga,No as ha,_o as ia,Lo as ja,Ko as ka,Fo as la,Wo as ma,ze as na,Bo as oa,Lr as pa,Vo as qa,zo as ra};
12
- //# sourceMappingURL=chunk-J7KIXQRB.js.map