infra-kit 0.24.0 → 0.28.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.
@@ -1,4 +1,4 @@
1
- import{a as N,b as j,c as Je,d as ze,e as W,f as qe,g as L,h as Ye,i as Xe,j as Qe,k as Ze,l as et}from"./chunk-SAHE3MZJ.js";import{a as C,b as M,c as Be,d as H,f as I,g as Me,k as He,m as je,q as We,r as Ge,s as Ve,t as oe,u as Ke}from"./chunk-SUOJZQHW.js";import{d as ne,l as ie,o as Ce,p as Ie,v as Ne}from"./chunk-XES5EOEE.js";import"./chunk-AWFGP6GY.js";import{P as T,Z as Ue,d as Le,ga as Fe,i as se,x as _e}from"./chunk-T462KY3S.js";import"./chunk-MFAFQVTW.js";import"./chunk-XOJ6LLBA.js";import{d as Te,f as $e,n as Oe}from"./chunk-I23MDR4X.js";import{a as _,b as tt}from"./chunk-DVXTZPQ5.js";import{Command as Zn}from"commander";import k from"node:process";import{pathToFileURL as ei}from"node:url";import ae from"node:process";var le=n=>{try{ae.stderr.write(n)}catch{}},U=(n,e,t=!0)=>{let r=e instanceof Error?`${e.message}
1
+ import{a as N,b as j,c as Je,d as ze,e as W,f as qe,g as L,h as Ye,i as Xe,j as Qe,k as Ze,l as et}from"./chunk-SAHE3MZJ.js";import{a as C,b as M,c as Be,d as H,f as I,g as Me,k as He,m as je,q as We,r as Ge,s as Ve,t as oe,u as Ke}from"./chunk-QJCOLFRN.js";import{d as ne,l as ie,o as Ce,p as Ie,v as Ne}from"./chunk-XES5EOEE.js";import"./chunk-AWFGP6GY.js";import{P as T,_ as Ue,d as Le,ha as Fe,i as se,x as _e}from"./chunk-MDZSYRGS.js";import"./chunk-MFAFQVTW.js";import"./chunk-WTS3O3LM.js";import{d as Te,f as $e,n as Oe}from"./chunk-I23MDR4X.js";import{a as _,b as tt}from"./chunk-DVXTZPQ5.js";import{Command as Zn}from"commander";import k from"node:process";import{pathToFileURL as ei}from"node:url";import ae from"node:process";var le=n=>{try{ae.stderr.write(n)}catch{}},U=(n,e,t=!0)=>{let r=e instanceof Error?`${e.message}
2
2
  ${e.stack??"(no stack)"}`:String(e);return`
3
3
  \u26A0\uFE0F ${n}: ${r}
4
4
  ${t?` dev-server kept alive (likely a bug in a handler's async path); restart if it misbehaves.
@@ -35,5 +35,5 @@ Received ${t}, closing Orca tab "${e}"...`),await nr(n)}})},ir=async n=>{let e=N
35
35
  `);let l=r(()=>{e(),t(Re)},i);a.shutdown().finally(()=>{l(),t(Re)}).catch(()=>{})}},oi=["SIGINT","SIGTERM"],ai=({forceReap:n=C,exit:e=i=>{k.exit(i)},register:t=(i,s)=>{k.on(i,s)},unregister:r=(i,s)=>{k.off(i,s)}}={})=>{let i=new Map;for(let s of oi){let o=()=>{lr(n,e,Be(s))};i.set(s,o),t(s,o)}return{remove:()=>{for(let[s,o]of i)r(s,o)}}},Ee=async n=>{let e=ni(n);if(e.orca){let l=await ir(e);if(l==="ran")return;k.stdout.write(`Orca: ${l.fallback}; falling back to single-terminal dev
36
36
  `)}let t=null,r=ii(),i=si({getRunner:()=>t,setTimer:r}),s=yt({onDeath:(l,u)=>{i(`stdio unwritable: ${l} ${u.code}`)}}),o=ai();try{t=await tr({...e,onExitRequest:l=>{k.exit(l)}})}finally{o.remove()}let a=t;rt({onFault:(l,u)=>{a.reportFault(U(l,u))},isTerminalDead:s.isDead,fileFault:(l,u)=>{a.fileFault(U(l,u,!1))},onFatal:i}),H({onSignal:async l=>{ce(`
37
37
  Received ${l}, shutting down dev-server...
38
- `),await a.shutdown()},describeStall:()=>a.shutdownStage,fileReport:l=>{a.fileFault(l)},setTimer:r})},li=(n,e,t)=>!n.appName&&!n.app&&!n.self&&!n.orca&&n.watch==null&&!n.verbose&&!n.routes&&!n.reuse&&e&&!t,ui=(n,e)=>({watch:n.watch,orca:n.orca,include:n.include??null,presetDef:n.presetDef,self:!1,verbose:!1,routes:!1,uiHealth:e.uiHealth??!0}),oo=async(n,e,t)=>{if(li(n,e,t)){let{runDevWizard:r}=await import("./dev-wizard-run-LUMKX7YN.js"),i=Promise.all([import("./persistent-ink-dev-ui-ZSOS3CF4.js"),import("./safe-stderr-ECYA6DRR.js")]).catch(()=>{}),s;try{s=await r()}catch(o){if(Ke(o))return;throw o}if(s==null)return;await i,await Ee({...ui(s,n),tty:e,json:t});return}await Ee({...or(n),tty:e,json:t})},di=async n=>{let e=new Zn;e.name("infra-kit-dev-server").description("Run local dev servers for an app (or all apps)").argument("[app]","An app \u2014 its api/ui plus the backends its routes can run locally (omit to run every app)").option("-w, --watch","Rebuild and restart on file save (the default)").option("--no-watch","Build once and never restart on save").option("--app <names>","Further narrow to these app folder names (comma-separated)").option("--orca","Run each app in its own Orca pane (one tab, N panes; falls back to single terminal when Orca is not running)").option("--self","Run only the app of the current directory (infer from cwd; use inside apps/<app>/\u2026)").option("-V, --verbose","Print full boot narration (default: quiet; full detail always in the session log)").option("--routes","Print each app\u2019s registered METHOD /path routes at startup (default: off)"),e.parse(n),await Ee(or({...e.opts(),appName:e.args[0]}))};import.meta.url===ei(k.argv[1]??"").href&&di(k.argv).catch(n=>{console.error(n instanceof Error?n.message:String(n)),k.exit(1)});export{si as createFatalHandler,ii as createSharedDeadlineTimer,ai as installBootSignalGuard,Ee as runDevServer,oo as runDevServerCli,li as shouldRunWizard,or as toDevServerOptions};
38
+ `),await a.shutdown()},describeStall:()=>a.shutdownStage,fileReport:l=>{a.fileFault(l)},setTimer:r})},li=(n,e,t)=>!n.appName&&!n.app&&!n.self&&!n.orca&&n.watch==null&&!n.verbose&&!n.routes&&!n.reuse&&e&&!t,ui=(n,e)=>({watch:n.watch,orca:n.orca,include:n.include??null,presetDef:n.presetDef,self:!1,verbose:!1,routes:!1,uiHealth:e.uiHealth??!0}),oo=async(n,e,t)=>{if(li(n,e,t)){let{runDevWizard:r}=await import("./dev-wizard-run-ALE5IJB6.js"),i=Promise.all([import("./persistent-ink-dev-ui-ZSOS3CF4.js"),import("./safe-stderr-ECYA6DRR.js")]).catch(()=>{}),s;try{s=await r()}catch(o){if(Ke(o))return;throw o}if(s==null)return;await i,await Ee({...ui(s,n),tty:e,json:t});return}await Ee({...or(n),tty:e,json:t})},di=async n=>{let e=new Zn;e.name("infra-kit-dev-server").description("Run local dev servers for an app (or all apps)").argument("[app]","An app \u2014 its api/ui plus the backends its routes can run locally (omit to run every app)").option("-w, --watch","Rebuild and restart on file save (the default)").option("--no-watch","Build once and never restart on save").option("--app <names>","Further narrow to these app folder names (comma-separated)").option("--orca","Run each app in its own Orca pane (one tab, N panes; falls back to single terminal when Orca is not running)").option("--self","Run only the app of the current directory (infer from cwd; use inside apps/<app>/\u2026)").option("-V, --verbose","Print full boot narration (default: quiet; full detail always in the session log)").option("--routes","Print each app\u2019s registered METHOD /path routes at startup (default: off)"),e.parse(n),await Ee(or({...e.opts(),appName:e.args[0]}))};import.meta.url===ei(k.argv[1]??"").href&&di(k.argv).catch(n=>{console.error(n instanceof Error?n.message:String(n)),k.exit(1)});export{si as createFatalHandler,ii as createSharedDeadlineTimer,ai as installBootSignalGuard,Ee as runDevServer,oo as runDevServerCli,li as shouldRunWizard,or as toDevServerOptions};
39
39
  //# sourceMappingURL=dev-server.js.map
@@ -1,2 +1,2 @@
1
- import{a as v,b as k,d as w,m as x}from"./chunk-SAHE3MZJ.js";import{a as m,e as h,j as b}from"./chunk-AHEFQJVD.js";import{P as u}from"./chunk-T462KY3S.js";import"./chunk-MFAFQVTW.js";import"./chunk-XOJ6LLBA.js";import{f as P}from"./chunk-I23MDR4X.js";import"./chunk-QWVLAZ6N.js";import N from"@inquirer/checkbox";import E from"@inquirer/confirm";import O from"@inquirer/select";import{loadDev as B,loadPackageConfig as j}from"@slip-stream-kit/config/internal";import z from"node:path";import g from"node:process";var C=e=>e.split("/")[0],R=e=>new Map(e.apps.map(r=>[r.name,r])),S=e=>e.localCapable&&e.cloudCapable,A=(e,r,a)=>S(r)?a[`${e} ${r.path}`]??(r.cloudCapable?"cloud":"local"):r.localCapable?"local":"cloud",D=(e,r,a)=>{let o=new Set,t=new Map;for(let n of e){let s=r.get(C(n));for(let i of s?.backends??[]){t.set(i.packageName,i.ownerApp);for(let p of i.routes)A(n,p,a)==="local"&&o.add(i.packageName)}}return{localPkgs:o,ownerByPkg:t}},$=(e,r)=>{let a={},o=!1;for(let t of e?.backends??[]){let n=r.has(t.packageName);for(let s of t.routes){let i=s.localCapable&&n?"local":"cloud";a[s.path]=i,i==="cloud"&&(o=!0)}}return{overrides:a,anyCloud:o}},W=(e,r)=>{let a=R(r),o=e.targets.filter(l=>l.endsWith("/ui")),t=e.targets.filter(l=>l.endsWith("/api")),{localPkgs:n,ownerByPkg:s}=D(o,a,e.sources),i={},p=!1;for(let l of o){let{overrides:c,anyCloud:f}=$(a.get(C(l)),n);f&&(p=!0),i[l]=Object.keys(c).length>0?{proxy:c}:{}}for(let l of t)i[l]??={};for(let l of n){let c=s.get(l);c!=null&&(i[`${c}/api`]??={})}return{presetDef:{apps:i},anyCloudRoute:p,targetKeys:Object.keys(i).sort()}},M=(e,r)=>{let a=[`--target=${e.targetKeys.join(",")}`];return r.watch||a.push("--no-watch"),r.orca&&a.push("--orca"),{flags:a.join(" ")}};var y={output:g.stderr,clearPromptOnDone:!0},U={select:e=>h(r=>O({message:e.message,choices:e.choices,default:e.default},r),{...y,whenHeadless:"refuse"}),checkbox:e=>h(r=>N({message:e.message,choices:e.choices},r),{...y,whenHeadless:"refuse"}),confirm:e=>h(r=>E({message:e.message,default:e.default},r),{...y,whenHeadless:"refuse"})},V=(e,r)=>{let a=new Map;for(let[o,t]of Object.entries(e)){let n={path:o,localCapable:t.from.includes("local"),cloudCapable:t.from.includes("cloud"),default:t.default},s=a.get(t.packageName);s?(s.routes.push(n),s.localCapable=s.localCapable||n.localCapable,s.cloudCapable=s.cloudCapable||n.cloudCapable):a.set(t.packageName,{packageName:t.packageName,routes:[n],localCapable:n.localCapable,cloudCapable:n.cloudCapable,ownerApp:r.get(t.packageName)})}return[...a.values()]},K=async(e,r,a)=>{try{let o=(await B(e))?.proxy?.routes;return o?V(o,a):[]}catch(o){return u.warn(`\u26A0\uFE0F Skipping ${r}: its dev config failed to load \u2014 ${o instanceof Error?o.message:String(o)}`),[]}},_=async e=>{let r=k(e),a=w(e),o=new Map(r.map(c=>[c.packageName,c.name])),t=new Map(r.map(c=>[c.name,c.packageName])),n=new Set(a.map(c=>c.name)),s=new Set(r.map(c=>c.name)),i=[...new Set([...s,...n])].sort(),p=await Promise.all(i.map(async c=>{let f=n.has(c);return{name:c,hasApi:s.has(c),hasUi:f,apiPackage:t.get(c),backends:f?await K(z.join(e,"apps",c,"ui"),c,o):[],deployedUrlEnv:f?(await j(z.join(e,"apps",c,"ui")).catch(()=>{}))?.deployedUrlEnv:void 0}})),l=await b();return{apps:p,environments:Object.keys(l?.envs??{}).sort()}},q=e=>{let r=[];for(let a of e.apps){if(a.hasUi){let o=a.backends.flatMap(n=>n.routes.map(s=>s.path)),t=o.length>0?`frontend \u2014 proxies ${[...o].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},I=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={},o=new Map;for(let t of e.apps){t.apiPackage!=null&&(a[t.name]=t.apiPackage);for(let n of t.backends)for(let s of n.routes)o.set(`${t.name} ${s.path}`,n.packageName)}return{discovered:r,apiPkgByApp:a,routePkg:(t,n)=>o.get(`${t} ${n}`)}},L=(e,r)=>x(e,I(r)).map(a=>a.message),T="INFRA_KIT_DEV_WIZARD_ORCA",F=()=>g.env[T]==="1",H=async(e,r,a)=>{let o=new Map(r.apps.map(n=>[n.name,n])),t={};for(let n of a){let s=o.get(n.split("/")[0]);for(let i of s?.backends??[])for(let p of i.routes){if(!p.localCapable||!p.cloudCapable)continue;let l=await e.select({message:`\u{1F500} ${n} ${p.path} \u2192 local or cloud?`,choices:[{name:"local (this machine)",value:"local"},{name:"cloud",value:"cloud"}],default:p.default??"local"});t[`${n} ${p.path}`]=l}}return t},Z=(e,r,a)=>e.apps.find(o=>o.name===r)?.backends.flatMap(o=>o.routes).find(o=>o.path===a),G=(e,r)=>{let a=[];for(let[o,t]of Object.entries(e.presetDef.apps??{})){if(!o.endsWith("/ui")||!t.proxy)continue;let n=o.split("/")[0];for(let[s,i]of Object.entries(t.proxy)){let p=Z(r,n,s),l=p&&p.localCapable&&p.cloudCapable?"":" (only option)";a.push(` ${o} ${s} \u2192 ${i}${l}`)}}if(a.length!==0){u.info("Resolved routes:");for(let o of[...a].sort())u.info(o)}},J=async(e,r)=>{let{downloadEnvSecrets:a}=await import("./env-load-BK6ZI4RR.js"),o=await a(e);return new Map(r.flatMap(t=>{let n=o.get(t);return n===void 0?[]:[[t,n]]}))},Q=async(e,r,a,o)=>{let t=r.flatMap(s=>{let i=a.apps.find(p=>`${p.name}/ui`===s);return i?.deployedUrlEnv?[i.deployedUrlEnv]:[]}),n=t.length>0?await o(e,t):new Map;g.env[P]=e;for(let s of t){let i=n.get(s);i?g.env[s]=i:(delete g.env[s],u.warn(`\u2601\uFE0F "${e}" holds no ${s}; routes that go to the deployed app will fail until it does.`))}},X=async(e,r,a)=>{if(r.apps.length===0)return u.warn("No apps discovered to run."),null;let o=await e.checkbox({message:"\u{1F4E6} Which packages?",choices:q(r)});if(o.length===0)return u.warn("No packages selected."),null;let t=o.filter(d=>d.endsWith("/ui")),n=await H(e,r,t),s=await e.confirm({message:"\u{1F440} Rebuild & restart on save (watch)?",default:!0}),i=F()?await e.confirm({message:"\u{1F9E9} Run each app in its own Orca pane?",default:!1}):!1,p={targets:o,sources:n,watch:s,orca:i},l=W(p,r);if(l.anyCloudRoute){if(r.environments.length===0)return u.warn("\u2601\uFE0F This selection routes to a cloud environment, but no environment token is loaded."),u.warn(" Run `infra-kit env-load` to add one, then re-run the wizard."),null;p.env=await e.select({message:"\u2601\uFE0F Point cloud routes at which environment?",choices:r.environments.map(d=>({name:d,value:d}))}),await Q(p.env,t,r,a)}let c=L(l.presetDef,r);if(c.length>0){u.warn("\u26A0\uFE0F Proxy audit found issues with this selection:");for(let d of c)u.warn(` \u2022 ${d}`);return null}G(l,r),Y(l,p);let f=l.targetKeys.filter(d=>d.endsWith("/api")).map(d=>d.split("/")[0]);return i&&f.length>0?{include:f,presetDef:l.presetDef,watch:s,orca:!0}:(i&&u.info("\u2139\uFE0F Orca needs at least one local backend (panes are backend-only) \u2014 running in-process instead."),{presetDef:l.presetDef,watch:s,orca:!1})},Y=(e,r)=>{m.setInteractive();let a=M(e,r);m.addOption(a.flags,!0),m.print()},ee=async(e,r,a=J)=>X(e,r,a),he=async(e=U,r=v(g.cwd()))=>ee(e,await _(r));export{T as WIZARD_ORCA_VAR,L as auditManualPlan,U as defaultPrompts,_ as gatherWizardModel,K as loadBackends,he as runDevWizard,ee as runWizardFlow};
2
- //# sourceMappingURL=dev-wizard-run-LUMKX7YN.js.map
1
+ import{a as v,b as k,d as w,m as x}from"./chunk-SAHE3MZJ.js";import{a as m,e as h,j as b}from"./chunk-STVQOKMC.js";import{P as u}from"./chunk-MDZSYRGS.js";import"./chunk-MFAFQVTW.js";import"./chunk-WTS3O3LM.js";import{f as P}from"./chunk-I23MDR4X.js";import"./chunk-QWVLAZ6N.js";import N from"@inquirer/checkbox";import E from"@inquirer/confirm";import O from"@inquirer/select";import{loadDev as B,loadPackageConfig as j}from"@slip-stream-kit/config/internal";import z from"node:path";import g from"node:process";var C=e=>e.split("/")[0],R=e=>new Map(e.apps.map(r=>[r.name,r])),S=e=>e.localCapable&&e.cloudCapable,A=(e,r,a)=>S(r)?a[`${e} ${r.path}`]??(r.cloudCapable?"cloud":"local"):r.localCapable?"local":"cloud",D=(e,r,a)=>{let o=new Set,t=new Map;for(let n of e){let s=r.get(C(n));for(let i of s?.backends??[]){t.set(i.packageName,i.ownerApp);for(let p of i.routes)A(n,p,a)==="local"&&o.add(i.packageName)}}return{localPkgs:o,ownerByPkg:t}},$=(e,r)=>{let a={},o=!1;for(let t of e?.backends??[]){let n=r.has(t.packageName);for(let s of t.routes){let i=s.localCapable&&n?"local":"cloud";a[s.path]=i,i==="cloud"&&(o=!0)}}return{overrides:a,anyCloud:o}},W=(e,r)=>{let a=R(r),o=e.targets.filter(l=>l.endsWith("/ui")),t=e.targets.filter(l=>l.endsWith("/api")),{localPkgs:n,ownerByPkg:s}=D(o,a,e.sources),i={},p=!1;for(let l of o){let{overrides:c,anyCloud:f}=$(a.get(C(l)),n);f&&(p=!0),i[l]=Object.keys(c).length>0?{proxy:c}:{}}for(let l of t)i[l]??={};for(let l of n){let c=s.get(l);c!=null&&(i[`${c}/api`]??={})}return{presetDef:{apps:i},anyCloudRoute:p,targetKeys:Object.keys(i).sort()}},M=(e,r)=>{let a=[`--target=${e.targetKeys.join(",")}`];return r.watch||a.push("--no-watch"),r.orca&&a.push("--orca"),{flags:a.join(" ")}};var y={output:g.stderr,clearPromptOnDone:!0},U={select:e=>h(r=>O({message:e.message,choices:e.choices,default:e.default},r),{...y,whenHeadless:"refuse"}),checkbox:e=>h(r=>N({message:e.message,choices:e.choices},r),{...y,whenHeadless:"refuse"}),confirm:e=>h(r=>E({message:e.message,default:e.default},r),{...y,whenHeadless:"refuse"})},V=(e,r)=>{let a=new Map;for(let[o,t]of Object.entries(e)){let n={path:o,localCapable:t.from.includes("local"),cloudCapable:t.from.includes("cloud"),default:t.default},s=a.get(t.packageName);s?(s.routes.push(n),s.localCapable=s.localCapable||n.localCapable,s.cloudCapable=s.cloudCapable||n.cloudCapable):a.set(t.packageName,{packageName:t.packageName,routes:[n],localCapable:n.localCapable,cloudCapable:n.cloudCapable,ownerApp:r.get(t.packageName)})}return[...a.values()]},K=async(e,r,a)=>{try{let o=(await B(e))?.proxy?.routes;return o?V(o,a):[]}catch(o){return u.warn(`\u26A0\uFE0F Skipping ${r}: its dev config failed to load \u2014 ${o instanceof Error?o.message:String(o)}`),[]}},_=async e=>{let r=k(e),a=w(e),o=new Map(r.map(c=>[c.packageName,c.name])),t=new Map(r.map(c=>[c.name,c.packageName])),n=new Set(a.map(c=>c.name)),s=new Set(r.map(c=>c.name)),i=[...new Set([...s,...n])].sort(),p=await Promise.all(i.map(async c=>{let f=n.has(c);return{name:c,hasApi:s.has(c),hasUi:f,apiPackage:t.get(c),backends:f?await K(z.join(e,"apps",c,"ui"),c,o):[],deployedUrlEnv:f?(await j(z.join(e,"apps",c,"ui")).catch(()=>{}))?.deployedUrlEnv:void 0}})),l=await b();return{apps:p,environments:Object.keys(l?.envs??{}).sort()}},q=e=>{let r=[];for(let a of e.apps){if(a.hasUi){let o=a.backends.flatMap(n=>n.routes.map(s=>s.path)),t=o.length>0?`frontend \u2014 proxies ${[...o].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},I=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={},o=new Map;for(let t of e.apps){t.apiPackage!=null&&(a[t.name]=t.apiPackage);for(let n of t.backends)for(let s of n.routes)o.set(`${t.name} ${s.path}`,n.packageName)}return{discovered:r,apiPkgByApp:a,routePkg:(t,n)=>o.get(`${t} ${n}`)}},L=(e,r)=>x(e,I(r)).map(a=>a.message),T="INFRA_KIT_DEV_WIZARD_ORCA",F=()=>g.env[T]==="1",H=async(e,r,a)=>{let o=new Map(r.apps.map(n=>[n.name,n])),t={};for(let n of a){let s=o.get(n.split("/")[0]);for(let i of s?.backends??[])for(let p of i.routes){if(!p.localCapable||!p.cloudCapable)continue;let l=await e.select({message:`\u{1F500} ${n} ${p.path} \u2192 local or cloud?`,choices:[{name:"local (this machine)",value:"local"},{name:"cloud",value:"cloud"}],default:p.default??"local"});t[`${n} ${p.path}`]=l}}return t},Z=(e,r,a)=>e.apps.find(o=>o.name===r)?.backends.flatMap(o=>o.routes).find(o=>o.path===a),G=(e,r)=>{let a=[];for(let[o,t]of Object.entries(e.presetDef.apps??{})){if(!o.endsWith("/ui")||!t.proxy)continue;let n=o.split("/")[0];for(let[s,i]of Object.entries(t.proxy)){let p=Z(r,n,s),l=p&&p.localCapable&&p.cloudCapable?"":" (only option)";a.push(` ${o} ${s} \u2192 ${i}${l}`)}}if(a.length!==0){u.info("Resolved routes:");for(let o of[...a].sort())u.info(o)}},J=async(e,r)=>{let{downloadEnvSecrets:a}=await import("./env-load-HNJGRHKJ.js"),o=await a(e);return new Map(r.flatMap(t=>{let n=o.get(t);return n===void 0?[]:[[t,n]]}))},Q=async(e,r,a,o)=>{let t=r.flatMap(s=>{let i=a.apps.find(p=>`${p.name}/ui`===s);return i?.deployedUrlEnv?[i.deployedUrlEnv]:[]}),n=t.length>0?await o(e,t):new Map;g.env[P]=e;for(let s of t){let i=n.get(s);i?g.env[s]=i:(delete g.env[s],u.warn(`\u2601\uFE0F "${e}" holds no ${s}; routes that go to the deployed app will fail until it does.`))}},X=async(e,r,a)=>{if(r.apps.length===0)return u.warn("No apps discovered to run."),null;let o=await e.checkbox({message:"\u{1F4E6} Which packages?",choices:q(r)});if(o.length===0)return u.warn("No packages selected."),null;let t=o.filter(d=>d.endsWith("/ui")),n=await H(e,r,t),s=await e.confirm({message:"\u{1F440} Rebuild & restart on save (watch)?",default:!0}),i=F()?await e.confirm({message:"\u{1F9E9} Run each app in its own Orca pane?",default:!1}):!1,p={targets:o,sources:n,watch:s,orca:i},l=W(p,r);if(l.anyCloudRoute){if(r.environments.length===0)return u.warn("\u2601\uFE0F This selection routes to a cloud environment, but no environment token is loaded."),u.warn(" Run `infra-kit env-load` to add one, then re-run the wizard."),null;p.env=await e.select({message:"\u2601\uFE0F Point cloud routes at which environment?",choices:r.environments.map(d=>({name:d,value:d}))}),await Q(p.env,t,r,a)}let c=L(l.presetDef,r);if(c.length>0){u.warn("\u26A0\uFE0F Proxy audit found issues with this selection:");for(let d of c)u.warn(` \u2022 ${d}`);return null}G(l,r),Y(l,p);let f=l.targetKeys.filter(d=>d.endsWith("/api")).map(d=>d.split("/")[0]);return i&&f.length>0?{include:f,presetDef:l.presetDef,watch:s,orca:!0}:(i&&u.info("\u2139\uFE0F Orca needs at least one local backend (panes are backend-only) \u2014 running in-process instead."),{presetDef:l.presetDef,watch:s,orca:!1})},Y=(e,r)=>{m.setInteractive();let a=M(e,r);m.addOption(a.flags,!0),m.print()},ee=async(e,r,a=J)=>X(e,r,a),he=async(e=U,r=v(g.cwd()))=>ee(e,await _(r));export{T as WIZARD_ORCA_VAR,L as auditManualPlan,U as defaultPrompts,_ as gatherWizardModel,K as loadBackends,he as runDevWizard,ee as runWizardFlow};
2
+ //# sourceMappingURL=dev-wizard-run-ALE5IJB6.js.map
@@ -1,2 +1,2 @@
1
- import{A as g,B as h,C as i,D as j,E as k,F as l,G as m,H as n,u as a,v as b,w as c,x as d,y as e,z as f}from"./chunk-ZMIA2K3H.js";import"./chunk-AHEFQJVD.js";import"./chunk-T462KY3S.js";import"./chunk-MFAFQVTW.js";import"./chunk-XOJ6LLBA.js";import"./chunk-I23MDR4X.js";import"./chunk-QWVLAZ6N.js";export{f as DOPPLER_MAX_OUTPUT_BYTES,k as assertDopplerOutputSize,i as assertTokenScope,g as buildDopplerChildEnv,a as buildEnvLoadFileLines,e as buildPickerChoices,h as downloadEnvSecrets,d as envLoad,n as envLoadMcpTool,m as parseDopplerSecretsJson,b as resolveEnvLoadRoots,l as shellSingleQuote,j as translateDopplerDownloadError,c as writeEnvLoadFile};
2
- //# sourceMappingURL=env-load-BK6ZI4RR.js.map
1
+ import{A as g,B as h,C as i,D as j,E as k,F as l,G as m,H as n,u as a,v as b,w as c,x as d,y as e,z as f}from"./chunk-W4CZUPXZ.js";import"./chunk-STVQOKMC.js";import"./chunk-MDZSYRGS.js";import"./chunk-MFAFQVTW.js";import"./chunk-WTS3O3LM.js";import"./chunk-I23MDR4X.js";import"./chunk-QWVLAZ6N.js";export{f as DOPPLER_MAX_OUTPUT_BYTES,k as assertDopplerOutputSize,i as assertTokenScope,g as buildDopplerChildEnv,a as buildEnvLoadFileLines,e as buildPickerChoices,h as downloadEnvSecrets,d as envLoad,n as envLoadMcpTool,m as parseDopplerSecretsJson,b as resolveEnvLoadRoots,l as shellSingleQuote,j as translateDopplerDownloadError,c as writeEnvLoadFile};
2
+ //# sourceMappingURL=env-load-HNJGRHKJ.js.map
@@ -1,2 +1,2 @@
1
- import{t as i}from"./chunk-7A4LVTRJ.js";import"./chunk-AWFGP6GY.js";import{a as t}from"./chunk-XOJ6LLBA.js";import"./chunk-I23MDR4X.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{t as i}from"./chunk-7A4LVTRJ.js";import"./chunk-AWFGP6GY.js";import{a as t}from"./chunk-WTS3O3LM.js";import"./chunk-I23MDR4X.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.24.0",
4
+ "version": "0.28.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.7",
27
27
  "@inquirer/password": "^5.2.3",
28
28
  "@inquirer/select": "^5.2.6",
29
- "@slip-stream-kit/config": "^0.24.0",
29
+ "@slip-stream-kit/config": "^0.28.0",
30
30
  "chalk": "^6.0.1",
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.24.0",
44
+ "@slip-stream-kit/eslint-plugin": "0.28.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
@@ -45,7 +45,7 @@ Code loads is self-contained and needs no config reader at session start.
45
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`.
46
46
 
47
47
  **infra-kit.json** (repo)
48
- Repo-wide settings: environment providers (e.g., Doppler), 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`; `aliasRepo`, `mcp`, `vendorSource` and `audit` are accepted only in the committed file. `aliasRepo` (a DNS label, e.g. `"trvl"`) replaces the main checkout's directory name in the dev host `<release>.<package>.<repo>.localhost`. A leftover root `infra-kit.config.ts` fails `audit --root`; `infra-kit audit --fix --root` moves its rules into `audit` and deletes it.
48
+ Repo-wide settings: environment providers (e.g., Doppler), 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`; `aliasRepo`, `mcp`, `vendorSource`, `vendorTarget` and `audit` are accepted only in the committed file. A `vendorSource.copy` entry with a `module` name reaches only the targets whose `vendorTarget.modules` lists it (no `vendorTarget` block: every module); dropping a module deletes its files under `vendor/` and leaves a path outside it to the target, and `vendor sync` fails the target while one of its `package.json` files still depends on a package the drop would delete. `aliasRepo` (a DNS label, e.g. `"trvl"`) replaces the main checkout's directory name in the dev host `<release>.<package>.<repo>.localhost`. A leftover root `infra-kit.config.ts` fails `audit --root`; `infra-kit audit --fix --root` moves its rules into `audit` and deletes it.
49
49
 
50
50
  **infra-kit.config.ts** (package)
51
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.
@@ -1,14 +0,0 @@
1
- import{a as ie}from"./chunk-MFAFQVTW.js";import{a as ne}from"./chunk-XOJ6LLBA.js";import{e as T,q as N,s as _}from"./chunk-I23MDR4X.js";import Ge from"node:process";import Fe from"node:process";var C={enabled:!1},qe=(e,t=r=>{Fe.stdout.write(r)})=>(C.enabled&&e&&e.structuredContent!=null&&t(`${JSON.stringify(e.structuredContent,null,2)}
2
- `),e),se=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(se)};var ae={source:null},w=()=>ae.source!==null,Be=()=>w()||C.enabled,L=()=>!!Ge.env.CI,He=({env:e,stdinIsTTY:t,flag:r})=>{if(r)return"flag";let o=e.INFRA_KIT_AGENT;return o==="1"||e.CLAUDECODE!==void 0&&!t&&o!=="0"?"env":null};var v=e=>{let t=new Set,r=e;for(;r!==null&&typeof r=="object"&&!t.has(r);){t.add(r);let{stderr:o,stderrExcerpt:n}=r;if(typeof o=="string"&&o.length>0)return o;if(typeof n=="string"&&n.length>0)return n;r=r.cause}},Ue=(e,t)=>{let r=t.stderrExcerpt??v(e),o=[`failed to ${t.operation}`];return r&&o.push(`stderr: ${r.slice(0,200).trim()}`),t.remediation&&o.push(`try: ${t.remediation}`),o.join(" \u2014 ")},u=class extends Error{operation;remediation;stderrExcerpt;constructor(t,r){super(Ue(t,r),{cause:t}),this.name="OperationError",this.operation=r.operation,this.remediation=r.remediation,this.stderrExcerpt=r.stderrExcerpt??v(t)}};import k from"node:path";import de from"node:process";import{$ as m}from"zx";var ze=/^v?(\d+)\.(\d+)\.(\d+)$/,Je=/^(\d+)\.(\d+)\.(\d+)$/,Ve=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,P="release/",K="release/v",ce="refs/heads/",Xe="next";var ue=new Set(["dev","main","next","hotfix","regular","release"]),h=class extends Error{constructor(t){super(t),this.name="InvalidReleaseNameError"}},y=class extends Error{constructor(t){super(t),this.name="InvalidReleaseRefError"}},pe=e=>e.startsWith(ce)?e.slice(ce.length):e,le=(e,t,r)=>({kind:"version",semver:{major:e,minor:t,patch:r},raw:`${e}.${t}.${r}`}),W=e=>{if(e.length===0)throw new h('Release name is empty. Provide a kebab-case name like "checkout-redesign".');if(e.length>50)throw new h(`Release name "${e}" is ${e.length} characters; the maximum is 50.`);if(!Ve.test(e))throw new h(`Release name "${e}" is not kebab-case. Use lowercase letters, digits, and single hyphens, e.g. "checkout-redesign".`);if(ue.has(e))throw new h(`Release name "${e}" is reserved. Reserved names: ${[...ue].join(", ")}.`)},D=e=>{let t=pe(e.trim());if(!t.startsWith(P))return null;if(t.startsWith(K)){let o=t.slice(K.length),n=Je.exec(o);if(n)return le(Number(n[1]),Number(n[2]),Number(n[3]))}let r=t.slice(P.length);try{W(r)}catch{return null}return{kind:"name",name:r,raw:r}},Ye=e=>{let t=e.trim();if(pe(t).startsWith(P)){let n=D(t);if(!n)throw new y(`"${e}" looks like a release branch but is not a valid release/v<semver> or release/<name> ref.`);return n}let o=ze.exec(t);if(o)return le(Number(o[1]),Number(o[2]),Number(o[3]));if(t.toLowerCase()===Xe)throw new y('The "next" token must be resolved to a concrete version (via computeNextVersion) before parsing a release ref.');if(t.includes("@"))throw new y(`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{W(t)}catch(n){let s=n instanceof Error?n.message:String(n);throw new y(`Cannot parse "${e}" as a release ref: ${s}`)}return{kind:"name",name:t,raw:t}},Ze=e=>e.kind==="version"?`${K}${e.raw}`:`${P}${e.name}`,Qe=(e,t)=>{let r=t==="hotfix"?"Hotfix":"Release";return e.kind==="version"?`${r} v${e.raw}`:`${r} ${e.name}`},et=e=>e.kind==="version"?`Release v${e.raw} (RC)`:`Release ${e.name} (RC)`,tt=e=>e.kind==="version"?`v${e.raw}`:e.name,rt=e=>e.raw,F=e=>e==null?!1:D(e)!==null,me=e=>{if(e===void 0)return null;let t=e instanceof Date?e.getTime():new Date(e).getTime();return Number.isNaN(t)?null:t},ot=(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 o=me(r?.a),n=me(r?.b);return o!==null&&n!==null&&o!==n?o-n:e.name<t.name?-1:e.name>t.name?1:0};var ge=async e=>{let t=await m({cwd:e})`git worktree list --porcelain`,r=[],o=null;for(let n of t.stdout.split(`
3
- `)){if(n.startsWith("worktree ")){o&&r.push(o),o={path:n.slice(9),branch:null,detached:!1,bare:!1,prunable:!1,locked:!1};continue}o&&(n.startsWith("branch ")?o.branch=n.slice(7).replace(/^refs\/heads\//,""):n==="detached"?o.detached=!0:n==="bare"?o.bare=!0:n==="locked"||n.startsWith("locked ")?o.locked=!0:(n==="prunable"||n.startsWith("prunable "))&&(o.prunable=!0))}return o&&r.push(o),r},nt=async e=>{let t=await ge(de.cwd()),r=o=>e==="release"?F(o):o.startsWith("feature/");return t.map(o=>o.branch).filter(o=>o!==null&&r(o))},it=e=>{let t=v(e);return t&&/not a git repository/i.test(t)?"not a git repository":void 0},st=({hasStderr:e})=>{if(w())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},R=async()=>{try{return(await m({quiet:!0})`git rev-parse --show-toplevel`).stdout.trim()}catch(e){let t=it(e)??v(e);throw new u(e,{operation:`resolve the project root from ${de.cwd()}`,stderrExcerpt:t,remediation:st({hasStderr:t!==void 0})})}},q=async e=>{let t=e??await R(),r=(await m({cwd:t,quiet:!0})`git rev-parse --git-common-dir`).stdout.trim(),o=k.resolve(t,r);return o.includes(`${k.sep}.git${k.sep}modules${k.sep}`)?t:k.dirname(o)},fe=async()=>(await m`git rev-parse --abbrev-ref HEAD`).stdout.trim(),he=async()=>(await m`git status --porcelain`).stdout.split(`
4
- `).map(t=>t.trimEnd()).filter(t=>t.trim().length>0),at=async()=>(await he()).length===0,ct=async()=>{let e=await R(),[t,r]=await Promise.all([m({cwd:e})`git rev-parse --absolute-git-dir`,m({cwd:e})`git rev-parse --git-common-dir`]),o=t.stdout.trim(),n=k.resolve(e,r.stdout.trim());return o!==n};var ut=async e=>(await m`git branch --list ${e}`).stdout.trim().length>0,mt=async e=>{(await m`git branch --list ${e}`).stdout.trim().length!==0&&await fe()!==e&&await m`git branch -D ${e}`},pt=async e=>{(await m`git ls-remote --heads origin ${e}`).stdout.trim().length!==0&&await m`git push origin --delete ${e}`};import{$ as S}from"zx";var lt=async(e,t)=>{let r=`${t}^{commit}`;try{return(await S({cwd:e,quiet:!0})`git rev-parse --verify --quiet ${r}`).stdout.trim()||null}catch{return null}},dt=async(e,t,r)=>{try{return await S({cwd:e,quiet:!0})`git merge-base --is-ancestor ${t} ${r}`,!0}catch(o){if(o.exitCode===1)return!1;throw new u(o,{operation:`test whether ${t} is contained in ${r}`,remediation:"both refs must exist \u2014 verify them with rev-parse first"})}},gt=async(e,t)=>{let o=(await S({cwd:e,quiet:!0})`git ls-remote --heads origin ${t}`).stdout.trim().split(`
5
- `)[0];return o?o.split(/\s+/)[0]??null:null},ft=async(e,t)=>{let r=t.map(o=>`${o.sha}:refs/heads/${o.branch}`);if(r.length===0)return{refspecs:r,pushed:!1};try{return await S({cwd:e,quiet:!0})`git push --atomic origin ${r}`,{refspecs:r,pushed:!0}}catch(o){return{refspecs:r,pushed:!1,stderr:o.stderr}}};import I from"node:path";import G from"node:process";import{$ as l}from"zx";var ye=async e=>{let t=e??G.cwd(),r=(await l({cwd:t,quiet:!0})`git rev-parse --git-common-dir`).stdout.trim(),o=I.dirname(I.resolve(t,r)),n=G.env.INFRA_KIT_SESSION||String(G.pid);return I.join(`${o}${N}`,_.mergeDev,`.scratch-${n}`)},we=e=>e.replace(/[^\w-]+/g,"-"),ht=(e,t)=>I.join(`${e}${N}`,_.mergeDev,we(t)),B=async e=>{try{return await l({cwd:e,quiet:!0})`git rev-parse -q --verify MERGE_HEAD`,!0}catch{return!1}},yt=async e=>{if(await B(e))throw new u(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 l({cwd:e,quiet:!0})`git status --porcelain`).stdout.trim();if(t.length>0)throw new u(void 0,{operation:"reuse the scratch worktree",stderrExcerpt:`scratch worktree is dirty: ${t.split(`
6
- `)[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 B(e)&&await t(()=>l({cwd:e,quiet:!0})`git merge --abort`),await t(()=>l({cwd:e,quiet:!0})`git reset --hard`),await t(()=>l({cwd:e,quiet:!0})`git clean -fdx -e node_modules`)},kt=async(e,t)=>{let{cwd:r,anchor:o="origin/dev"}=e,n=await ye(r),s=async()=>{await l({cwd:r,quiet:!0})`git worktree add --detach ${n} ${o}`};try{await s()}catch(c){try{await l({cwd:r,quiet:!0})`git worktree prune`,await s()}catch{throw new u(c,{operation:"create the scratch worktree for the merge",remediation:`remove any stale checkout at ${n}, then retry`})}}let p={path:n,remove:async()=>{try{await l({cwd:r,quiet:!0})`git worktree remove --force ${n}`}catch{}}};try{return await t(p)}finally{await p.remove()}};import vt from"node:process";import Rt from"pino";import xt from"pino-pretty";var bt=["token","*.token","serviceToken","*.serviceToken","DOPPLER_TOKEN","*.DOPPLER_TOKEN","INFRA_KIT_ENV_TOKEN","*.INFRA_KIT_ENV_TOKEN"],Et=()=>{let e=vt.argv.includes("--debug")?"debug":"info",t=["time","pid","hostname"];return e==="debug"&&t.push("level"),Rt({level:e,redact:bt},xt({destination:2,ignore:t.join(","),colorize:!0,sync:!0}))},H=Et();var ke=class extends u{structuredContent;exitCode;constructor(t,r,o){super(void 0,o),this.name="StructuredRefusalError",this.structuredContent=t,this.exitCode=r}};import Mt from"node:fs/promises";import Ct from"node:os";var Pt=async e=>{try{return await Mt.access(e),!0}catch{return!1}},U=e=>{let t=Ct.homedir();return e.startsWith(t)?`~${e.slice(t.length)}`:e};import te from"node:fs/promises";import Ae from"node:os";import E from"node:path";import Nt from"node:process";import{z as i}from"zod";var z=e=>{throw new Error(`Unexpected value: ${JSON.stringify(e)}`)};var ve=(e,t)=>Object.fromEntries(Object.entries(e).filter(([r])=>r!==t));var a=({key:e,id:t,note:r})=>({id:t,note:r,apply:o=>e in o?{changed:!0,result:ve(o,e)}:{changed:!1,result:o}});var Re=a({key:"dev",id:"drop-dev-key",note:'the unused "dev" key (a dev server port comes from <APP>_PORT / PORT, else the built-in default)'});var xe=a({key:"devServersPresets",id:"drop-dev-presets-key",note:'the unused "devServersPresets" key (run `infra-kit dev <app>` instead of a preset name)'});var be=a({key:"devProxy",id:"drop-dev-proxy-key",note:'the retired "devProxy" key (dev URLs are port-free https://<release>.<package>.localhost)'});var Ee=a({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=a({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 Ce=a({key:"ide",id:"drop-ide-key",note:'the unused "ide" key (worktrees add/remove no longer edit a Cursor .code-workspace)'});var Pe=a({key:"taskManager",id:"drop-task-manager-key",note:'the unused "taskManager" key (Jira is configured by the JIRA_BASE_URL / JIRA_PROJECT_ID env vars in Doppler)'});var J=[Ce,Me,be,Ee,Pe,xe,Re];var x=e=>J.reduce((t,r)=>{let o=r.apply(t.result);return o.changed?{changed:!0,result:o.result,notes:[...t.notes,r.note]}:t},{changed:!1,result:e,notes:[]});var Se={withheld:!1},V=()=>Se.withheld||L();import{randomBytes as St}from"node:crypto";import g from"node:fs/promises";import X from"node:path";import It from"node:process";var $=class extends Error{constructor(t){super(`${t} changed on disk since it was read`),this.name="ConfigFileChangedError"}},$t=2,jt=e=>/^([ \t]+)\S/m.exec(e)?.[1]??$t,At=4095,j=async({path:e,raw:t,migrated:r,expectedMtimeMs:o})=>{let n=await g.realpath(e),s=X.dirname(n),p=X.basename(n),c=X.join(s,`.${p}.${It.pid}.${St(4).toString("hex")}.tmp`),A=`${JSON.stringify(r,null,jt(t))}
7
- `;try{await g.writeFile(c,A,"utf8");let d=await g.stat(n);if(d.mtimeMs!==o)throw new $(e);await g.chmod(c,d.mode&At),await g.rename(c,n)}catch(d){throw await g.rm(c,{force:!0}),d}},Ot=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Tt=async e=>{let t=await g.stat(e),r=await g.readFile(e,"utf8");if(r.trim()==="")return{changed:!1,result:{},notes:[],path:e};let o=JSON.parse(r);if(!Ot(o))return{changed:!1,result:{},notes:[],path:e};let n=x(o);return n.changed&&await j({path:e,raw:r,migrated:n.result,expectedMtimeMs:t.mtimeMs}),{...n,path:e}};var Y=async(e,t,r,{schema:o})=>{if(e.autoMigrate==="off")return{kind:"not-applicable"};let n=x(t);if(!n.changed)return{kind:"not-applicable"};let s=o.safeParse(n.result);if(!s.success)return{kind:"not-applicable"};if(e.required&&V())return{kind:"ci-gated"};try{await j({path:e.path,raw:r,migrated:n.result,expectedMtimeMs:e.mtimeMs})}catch(p){return H.debug(p,`auto-migration could not rewrite ${e.path}`),{kind:"not-applicable"}}return H.warn(`Migrated ${U(e.path)}: removed ${n.notes.join(" and ")} (retired by infra-kit ${ne.version})`),{kind:"migrated",data:s.data}};var Ie="infra-kit.json";var _t="infra-kit.json",Lt="projects",Kt=i.object({provider:i.literal("doppler"),config:i.object({name:i.string().min(1)})}),Wt=i.discriminatedUnion("provider",[Kt]),Dt=["two-columns","three-pane"],Ft=i.object({layout:i.enum(Dt).optional()}).strict(),qt=i.object({openInGithubDesktop:i.boolean().optional(),openInOrca:i.boolean().optional(),orca:Ft.optional()}).strict(),Gt=i.enum(["disallow","allow","cli-only"]),$e=i.string().regex(/^[A-Z_]\w*$/i,"must be a POSIX environment-variable name"),Bt=i.object({command:i.string().min(1),args:i.array(i.string()).default([]),env:i.array($e).min(1),unset:i.array($e).default([])}).strict().superRefine((e,t)=>{for(let r of e.env)ie.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`})}),Ht=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'}),Bt),je=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(n=>n!==""&&n!==".");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 o=e.split("/");o.includes("")&&t.addIssue({code:"custom",message:`"${e}" must not have a trailing or doubled "/"`}),o.includes(".")&&t.addIssue({code:"custom",message:`"${e}" must not contain a "." segment; write it from the repository root, e.g. "vendor/configs"`})}),Ut=i.object({path:je,target:je.optional()}).strict(),Oe=i.object({copy:i.array(Ut).min(1),exclude:i.array(i.string().regex(/^[^/\\]+$/,'must be a single path segment, without "/"')).optional()}).strict(),zt=i.object({requiredScripts:i.array(i.string().min(1)).optional(),requiredFiles:i.array(i.string().min(1)).optional(),turbo:i.object({requiredTasks:i.array(i.string().min(1)).optional()}).strict().optional()}).strict(),Jt=i.string().regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/,'must be a DNS label: a-z, 0-9 and inner "-", at most 63 characters'),Vt=i.string().min(1),re=i.object({envManagement:Wt,defaultEnv:Vt.optional(),worktrees:qt.optional(),protectedEnvs:Gt.optional(),mcp:Ht.optional(),vendorSource:Oe.nullable().optional(),audit:zt.optional(),aliasRepo:Jt.optional()}).strict(),Xt=443,Te=re,ee=re.partial(),Ne="two-columns",Yt=e=>e.worktrees?.orca?.layout??Ne,f=null,b=null,_e=()=>`${Nt.cwd()} ${Ae.homedir()}`,Le=()=>E.join(Ae.homedir(),T),Ke=()=>E.join(Le(),_t),We=async()=>{let e=_e();if(b&&b.key===e)return b.value;let t=await R(),r=await q(t),o=E.basename(r),n={main:E.join(t,Ie),userGlobal:Ke(),userProject:E.join(Le(),Lt,o,Ie),projectName:o};return b={key:e,value:n},n},Zt=async(e={})=>{let t=e.autoMigrate??"write",r=_e(),o=await We(),n;try{n=await te.stat(o.main)}catch{f=null;let O=o.main.replace(/\.json$/,".yml");throw await Z(O)?new Error(`infra-kit.json not found at ${o.main}. A legacy infra-kit.yml exists \u2014 run \`infra-kit setup --skip-tools\` to convert it.`):new Error(w()?`infra-kit.json not found at ${o.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 ${o.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,p]=await Promise.all([Z(o.userGlobal),Z(o.userProject)]),c={main:Number(n.mtimeMs),userGlobal:s?Number(s.mtimeMs):null,userProject:p?Number(p.mtimeMs):null};if(f&&f.key===r&&rr(f.mtimes,c))return f.value;let A=[{label:"infra-kit.json",path:o.main,required:!0,autoMigrate:t,mtimeMs:c.main},{label:"~/.infra-kit/infra-kit.json",path:o.userGlobal,required:!1,autoMigrate:t,mtimeMs:c.userGlobal},{label:`~/.infra-kit/projects/${o.projectName}/infra-kit.json`,path:o.userProject,required:!1,autoMigrate:t,mtimeMs:c.userProject}],d={};for(let O of A){let oe=await or(O);oe!==null&&(d={...d,...oe})}let M=Te.safeParse(d);if(!M.success)throw new Error(`Invalid merged infra-kit config: ${i.prettifyError(M.error)}`);return f={key:r,mtimes:c,value:M.data},M.data},Qt=()=>{f=null},er=()=>{f=null,b=null},Z=async e=>{try{return await te.stat(e)}catch{return null}},tr=async e=>{try{return await te.readFile(e,"utf-8")}catch{return null}},rr=(e,t)=>{let r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(o=>e[o]===t[o])},De=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.`),or=async e=>{let t=await tr(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(p){throw new Error(`Invalid JSON in ${e.label} at ${e.path}: ${p.message}`)}if(Q(r)&&"envTokens"in r)throw new Error(mr(e));!e.required&&Q(r)&&ur(e,r);let o=ee.safeParse(r);if(o.success)return o.data;let n=new Error(`Invalid ${e.label} at ${e.path}: ${i.prettifyError(o.error)}`);if(!Q(r)||e.mtimeMs===null)throw n;let s=await Y({...e,mtimeMs:e.mtimeMs},r,t,{schema:ee});switch(s.kind){case"migrated":return s.data;case"ci-gated":throw De(n);case"not-applicable":throw n;default:return z(s)}},nr=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
- `),ir=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
- `),sr=e=>[`"audit" is not allowed in ${e.label} (${e.path}): the root audit gates CI, so a per-machine copy would make this machine pass or fail a different check list than CI.`,"Move the block to the project infra-kit.json and commit it there."].join(`
11
- `),ar=e=>[`"aliasRepo" is not allowed in ${e.label} (${e.path}): the vite and Playwright helpers read it from the project infra-kit.json only, so a per-machine copy would register a dev host they never aim at.`,"Move it to the project infra-kit.json and commit it there."].join(`
12
- `),cr={aliasRepo:ar,mcp:nr,vendorSource:ir,audit:sr},ur=(e,t)=>{for(let[r,o]of Object.entries(cr))if(r in t)throw new Error(o(e))},Q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),mr=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(`
13
- `);export{C as a,qe as b,se as c,ae as d,w as e,Be as f,He as g,v as h,u as i,h as j,W as k,D as l,Ye as m,Ze as n,Qe as o,et as p,tt as q,rt as r,F as s,ot as t,ge as u,nt as v,R as w,q as x,fe as y,he as z,at as A,ct as B,ut as C,mt as D,pt as E,lt as F,dt as G,gt as H,ft as I,we as J,ht as K,B as L,yt as M,wt as N,kt as O,H as P,z as Q,Pt as R,U as S,Se as T,$ as U,j as V,Tt as W,Oe as X,re as Y,Xt as Z,Te as _,ee as $,Yt as aa,Ke as ba,We as ca,Zt as da,Qt as ea,er as fa,ke as ga};
14
- //# sourceMappingURL=chunk-T462KY3S.js.map