rapidkit 0.17.0 → 0.18.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.
package/dist/index.js CHANGED
@@ -1,21 +1,27 @@
1
1
  #!/usr/bin/env node
2
- import w from'path';import {fileURLToPath,pathToFileURL}from'url';import m from'chalk';import {execa}from'execa';import {createRequire}from'module';import*as z from'os';import z__default from'os';import*as k from'fs-extra';import k__default from'fs-extra';import F,{promises}from'fs';import kt from'ora';import {Command,Option}from'commander';import Jt from'inquirer';import {spawn}from'child_process';import Xe from'validate-npm-package-name';import _i from'nunjucks';import Ii from'crypto';var Le=Object.defineProperty;var st=(t,i)=>()=>(t&&(i=t(t=0)),i);var Nt=(t,i)=>{for(var e in i)Le(t,e,{get:i[e],enumerable:true});};var R=st(()=>{});var Dt,f,ct=st(()=>{R();Dt=class{debugEnabled=false;setDebug(i){this.debugEnabled=i;}debug(i,...e){this.debugEnabled&&console.log(m.gray(`[DEBUG] ${i}`),...e);}info(i,...e){console.log(m.blue(i),...e);}success(i,...e){console.log(m.green(i),...e);}warn(i,...e){console.log(m.yellow(i),...e);}error(i,...e){console.error(m.red(i),...e);}step(i,e,o){console.log(m.cyan(`
3
- [${i}/${e}]`),m.white(o));}},f=new Dt;});async function ee(){try{f.debug("Checking for updates...");let{stdout:t}=await execa("npm",["view",He,"version"],{timeout:3e3}),i=t.trim();i&&i!==Tt?(console.log(m.yellow(`
4
- \u26A0\uFE0F Update available: ${Tt} \u2192 ${i}`)),console.log(m.cyan(`Run: npm install -g rapidkit@latest
5
- `))):f.debug("You are using the latest version");}catch{f.debug("Could not check for updates");}}function H(){return Tt}var He,Be,Je,Tt,gt=st(()=>{R();ct();He="rapidkit",Be=createRequire(import.meta.url),Je=Be("../package.json"),Tt=Je?.version??"0.0.0";});var Lt={};Nt(Lt,{__test__:()=>li,checkRapidkitCoreAvailable:()=>fe,getCachedCoreTopLevelCommands:()=>Vt,getCoreTopLevelCommands:()=>ci,resolveRapidkitPython:()=>ut,runCoreRapidkit:()=>B,runCoreRapidkitCapture:()=>Wt});function Kt(t){return t instanceof dt?t.code==="PYTHON_NOT_FOUND"?"RapidKit (npm) could not find Python (python3/python) on your PATH.\nInstall Python 3.10+ and ensure `python3` is available, then retry.\nTip: if you are inside a RapidKit project, use the local ./rapidkit launcher.":`RapidKit (npm) bridge error: ${t.message}`:`RapidKit (npm) failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function oi(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function pe(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:w.join(z__default.homedir(),".cache")}function Ft(){return w.join(pe(),"rapidkit","npm-bridge","venv")}function se(t){return process.platform==="win32"?w.join(t,"Scripts","python.exe"):w.join(t,"bin","python")}function ce(t){return process.platform==="win32"?w.join(t,"Scripts","rapidkit.exe"):w.join(t,"bin","rapidkit")}function de(){return w.join(pe(),"rapidkit","npm-bridge","core-commands.json")}async function ue(t){let i=!!process.env.RAPIDKIT_DEBUG,e=o=>{i&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${o}
6
- `);};try{e("probing interpreter-specific rapidkit script");let r=((await execa(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(e(`script path: ${r}`),r)try{if(await k.pathExists(r)){e(`found script at ${r}; invoking --version --json`);let n=await execa(r,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(e(`script exitCode=${n.exitCode}`),n.exitCode===0){let a=(n.stdout??"").toString().trim();try{let s=JSON.parse(a),c=!!s&&typeof s=="object"&&s!==null&&"version"in s;if(e(`script JSON parse ok=${c}`),c)return !0}catch{e("script output not valid JSON");}}}}catch(n){e(`interpreter-specific script probe failed: ${String(n)}`);}}catch(o){e(`interpreter-specific script probe error: ${String(o)}`);}try{e('probing importlib.find_spec("rapidkit")');let o=await execa(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:!1,stdio:"pipe",timeout:2e3});if(e(`import probe exitCode=${o.exitCode} stdout=${(o.stdout??"").toString().trim()}`),o.exitCode===0&&(o.stdout??"").toString().trim()==="1")return !0}catch(o){e(`import probe error: ${String(o)}`);}try{e("probing python -m rapidkit");let o=await execa(t,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:8e3});if(e(`-m probe exitCode=${o.exitCode}`),o.exitCode===0)return !0}catch(o){e(`-m probe error: ${String(o)}`);}try{e("probing PATH for rapidkit executables");let o=(process.env.PATH??"").split(w.delimiter).filter(Boolean);for(let r of o){let n=w.join(r,process.platform==="win32"?"rapidkit.exe":"rapidkit");try{if(await k.pathExists(n)){e(`found candidate on PATH: ${n}; invoking --version --json`);let a=await execa(n,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(e(`candidate exitCode=${a.exitCode}`),a.exitCode===0){let s=(a.stdout??"").toString().trim();try{let c=JSON.parse(s);if(c&&typeof c=="object"&&c!==null&&"version"in c)return !0}catch{e("candidate output not valid JSON, skipping");}}}}catch(a){e(`error probing candidate ${n}: ${String(a)}`);}}return e("no valid rapidkit found on PATH"),!1}catch(o){return e(`PATH probe error: ${String(o)}`),false}}async function Ot(t){let i=(t??"").toString().trim();if(!i)return false;try{let e=JSON.parse(i);return !!e&&typeof e=="object"&&e!==null&&"version"in e}catch{return false}}async function ni(t){let i=process.platform==="win32",e=i?w.join(".venv","Scripts","rapidkit.exe"):w.join(".venv","bin","rapidkit"),o=i?w.join(".venv","Scripts","python.exe"):w.join(".venv","bin","python"),r=t;for(let n=0;n<25;n+=1){let a=w.join(r,e);if(await k.pathExists(a)){let l=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:r});if(l.exitCode===0&&await Ot(l.stdout))return {cmd:a,baseArgs:[]}}let s=w.join(r,o);if(await k.pathExists(s)){let l=await execa(s,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:r});if(l.exitCode===0&&await Ot(l.stdout))return {cmd:s,baseArgs:["-m","rapidkit"]}}let c=w.dirname(r);if(c===r)break;r=c;}return null}async function ri(t){try{let i=w.join(t,".python-version");if(await k.pathExists(i)){let o=(await k.readFile(i,"utf-8")).trim();if(o)return o}}catch{}try{let i=w.join(t,".rapidkit-workspace");if(await k.pathExists(i)){let e=await k.readFile(i,"utf-8"),o=JSON.parse(e);if(o.pythonVersion)return o.pythonVersion}}catch{}return null}async function me(t){if(t&&t.trim())try{let n=await ni(t);if(n){let a=w.dirname(n.cmd).includes(".venv")?w.dirname(w.dirname(w.dirname(n.cmd))):w.dirname(n.cmd),s=await ri(a);return s&&(process.env.PYENV_VERSION=s),n}}catch{}let i=await ut();if(i.kind==="venv"){let n=Ft(),a=ce(n);return await k.pathExists(a)?{cmd:a,baseArgs:[]}:{cmd:i.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(i.cmd,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:i.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let a=((await execa(i.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(a&&await k.pathExists(a))try{let s=await execa(a,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(s.exitCode===0&&await Ot(s.stdout))return {cmd:a,baseArgs:[]}}catch{}}catch{}let e=Ft(),o=await $t(i.cmd),r=ce(e);return await k.pathExists(r)?{cmd:r,baseArgs:[]}:{cmd:o,baseArgs:["-m","rapidkit"]}}async function Mt(){for(let t of ["python3","python"])try{return await execa(t,["--version"],{reject:!1,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function fe(){let t=!!process.env.RAPIDKIT_DEBUG,i=e=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${e}
2
+ import k from'path';import {fileURLToPath,pathToFileURL}from'url';import m from'chalk';import {execa}from'execa';import {createRequire}from'module';import mi from'crypto';import*as Q from'os';import Q__default from'os';import*as v from'fs-extra';import v__default from'fs-extra';import O,{promises}from'fs';import xt from'ora';import {Command,Option}from'commander';import qt from'inquirer';import {spawn}from'child_process';import si from'validate-npm-package-name';import Vi from'nunjucks';var qe=Object.defineProperty;var ot=(t,i)=>()=>(t&&(i=t(t=0)),i);var Ot=(t,i)=>{for(var e in i)qe(t,e,{get:i[e],enumerable:true});};var E=ot(()=>{});var Mt,y,lt=ot(()=>{E();Mt=class{debugEnabled=false;setDebug(i){this.debugEnabled=i;}debug(i,...e){this.debugEnabled&&console.log(m.gray(`[DEBUG] ${i}`),...e);}info(i,...e){console.log(m.blue(i),...e);}success(i,...e){console.log(m.green(i),...e);}warn(i,...e){console.log(m.yellow(i),...e);}error(i,...e){console.error(m.red(i),...e);}step(i,e,o){console.log(m.cyan(`
3
+ [${i}/${e}]`),m.white(o));}},y=new Mt;});function ne(t){let e=t.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!e)return null;let o=e[4]?e[4].split(".").map(r=>r.match(/^\d+$/)?Number(r):r):[];return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:o}}function ii(t,i){let e=ne(t),o=ne(i);if(!e||!o)return 0;if(e.major!==o.major)return e.major>o.major?1:-1;if(e.minor!==o.minor)return e.minor>o.minor?1:-1;if(e.patch!==o.patch)return e.patch>o.patch?1:-1;if(e.prerelease.length===0&&o.prerelease.length===0)return 0;if(e.prerelease.length===0)return 1;if(o.prerelease.length===0)return -1;let r=Math.max(e.prerelease.length,o.prerelease.length);for(let n=0;n<r;n+=1){let a=e.prerelease[n],s=o.prerelease[n];if(a===void 0)return -1;if(s===void 0)return 1;if(a===s)continue;let c=typeof a=="number",l=typeof s=="number";return c&&l?a>s?1:-1:c?-1:l||String(a)>String(s)?1:-1}return 0}async function re(){try{y.debug("Checking for updates...");let{stdout:t}=await execa("npm",["view",Ze,"version"],{timeout:3e3}),i=t.trim();i&&ii(i,Kt)>0?(console.log(m.yellow(`
4
+ \u26A0\uFE0F Update available: ${Kt} \u2192 ${i}`)),console.log(m.cyan(`Run: npm install -g rapidkit@latest
5
+ `))):y.debug("You are using the latest version");}catch{y.debug("Could not check for updates");}}function H(){return Kt}var Ze,ti,ei,Kt,ht=ot(()=>{E();lt();Ze="rapidkit",ti=createRequire(import.meta.url),ei=ti("../package.json"),Kt=ei?.version??"0.0.0";});var ui,vt,Lt=ot(()=>{E();ui=["version","project","create","init","dev","start","build","test","lint","format","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],vt=new Set(ui);});var Bt={};Ot(Bt,{__test__:()=>Pi,checkRapidkitCoreAvailable:()=>be,getCachedCoreTopLevelCommands:()=>Ut,getCoreTopLevelCommands:()=>bi,getModulesCatalog:()=>$i,resolveRapidkitPython:()=>mt,runCoreRapidkit:()=>Y,runCoreRapidkitCapture:()=>ut});function ye(t){if(t instanceof J)switch(t.code){case "PYTHON_NOT_FOUND":return "RapidKit (npm) could not find Python (python3/python) on your PATH.\nInstall Python 3.10+ and ensure `python3` is available, then retry.\nTip: if you are inside a RapidKit project, use the local ./rapidkit launcher.";case "BRIDGE_VENV_CREATE_FAILED":return `RapidKit (npm) failed to create its bridge virtual environment.
6
+ Ensure Python venv support is installed (e.g., python3-venv).
7
+ Details: ${t.message}`;case "BRIDGE_PIP_BOOTSTRAP_FAILED":return `RapidKit (npm) could not bootstrap pip inside the bridge virtual environment.
8
+ Install python3-venv/python3-pip and retry.
9
+ Details: ${t.message}`;case "BRIDGE_PIP_UPGRADE_FAILED":return `RapidKit (npm) could not upgrade pip in the bridge virtual environment.
10
+ Check your network/proxy or disable RAPIDKIT_BRIDGE_UPGRADE_PIP.
11
+ Details: ${t.message}`;case "BRIDGE_PIP_INSTALL_FAILED":return `RapidKit (npm) could not install rapidkit-core in the bridge virtual environment.
12
+ Check your network/proxy, or install manually with: pipx install rapidkit-core.
13
+ Details: ${t.message}`;default:return `RapidKit (npm) bridge error: ${t.message}`}return `RapidKit (npm) failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function Gt(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function fi(){let t=Gt(),i=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,e=i&&i.trim()?`${t}|${i.trim()}`:t;return mi.createHash("sha256").update(e).digest("hex").slice(0,12)}function Rt(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:k.join(Q__default.homedir(),".cache")}function gi(){return k.join(Rt(),"rapidkit","npm-bridge","venv")}function we(){let t=fi();return k.join(Rt(),"rapidkit","npm-bridge",`venv-${t}`)}function de(t){return process.platform==="win32"?k.join(t,"Scripts","python.exe"):k.join(t,"bin","python")}function ue(t){return process.platform==="win32"?k.join(t,"Scripts","rapidkit.exe"):k.join(t,"bin","rapidkit")}function hi(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function yi(t){return k.dirname(k.dirname(t))}function ke(){return k.join(Rt(),"rapidkit","npm-bridge","core-commands.json")}async function ve(t){let i=!!process.env.RAPIDKIT_DEBUG,e=o=>{i&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${o}
14
+ `);};try{e("probing interpreter-specific rapidkit script");let r=((await execa(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(e(`script path: ${r}`),r)try{if(await v.pathExists(r)){e(`found script at ${r}; invoking --version --json`);let n=await execa(r,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(e(`script exitCode=${n.exitCode}`),n.exitCode===0){let a=(n.stdout??"").toString().trim();try{let s=JSON.parse(a),c=!!s&&typeof s=="object"&&s!==null&&"version"in s;if(e(`script JSON parse ok=${c}`),c)return !0}catch{e("script output not valid JSON");}}}}catch(n){e(`interpreter-specific script probe failed: ${String(n)}`);}}catch(o){e(`interpreter-specific script probe error: ${String(o)}`);}try{e('probing importlib.find_spec("rapidkit")');let o=await execa(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:!1,stdio:"pipe",timeout:2e3});if(e(`import probe exitCode=${o.exitCode} stdout=${(o.stdout??"").toString().trim()}`),o.exitCode===0&&(o.stdout??"").toString().trim()==="1")return !0}catch(o){e(`import probe error: ${String(o)}`);}try{e("probing python -m rapidkit");let o=await execa(t,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:8e3});if(e(`-m probe exitCode=${o.exitCode}`),o.exitCode===0)return !0}catch(o){e(`-m probe error: ${String(o)}`);}try{e("probing PATH for rapidkit executables");let o=(process.env.PATH??"").split(k.delimiter).filter(Boolean);for(let r of o){let n=k.join(r,process.platform==="win32"?"rapidkit.exe":"rapidkit");try{if(await v.pathExists(n)){e(`found candidate on PATH: ${n}; invoking --version --json`);let a=await execa(n,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(e(`candidate exitCode=${a.exitCode}`),a.exitCode===0){let s=(a.stdout??"").toString().trim();try{let c=JSON.parse(s);if(c&&typeof c=="object"&&c!==null&&"version"in c)return !0}catch{e("candidate output not valid JSON, skipping");}}}}catch(a){e(`error probing candidate ${n}: ${String(a)}`);}}return e("no valid rapidkit found on PATH"),!1}catch(o){return e(`PATH probe error: ${String(o)}`),false}}async function Wt(t){let i=(t??"").toString().trim();if(!i)return false;try{let e=JSON.parse(i);return !!e&&typeof e=="object"&&e!==null&&"version"in e}catch{return false}}async function wi(t){let i=process.platform==="win32",e=i?k.join(".venv","Scripts","rapidkit.exe"):k.join(".venv","bin","rapidkit"),o=i?k.join(".venv","Scripts","python.exe"):k.join(".venv","bin","python"),r=t;for(let n=0;n<25;n+=1){let a=k.join(r,e);if(await v.pathExists(a)){let l=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:r});if(l.exitCode===0&&await Wt(l.stdout))return {cmd:a,baseArgs:[]}}let s=k.join(r,o);if(await v.pathExists(s)){let l=await execa(s,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:r});if(l.exitCode===0&&await Wt(l.stdout))return {cmd:s,baseArgs:["-m","rapidkit"]}}let c=k.dirname(r);if(c===r)break;r=c;}return null}async function ki(t){try{let i=k.join(t,".python-version");if(await v.pathExists(i)){let o=(await v.readFile(i,"utf-8")).trim();if(o)return o}}catch{}try{let i=k.join(t,".rapidkit-workspace");if(await v.pathExists(i)){let e=await v.readFile(i,"utf-8"),o=JSON.parse(e);if(o.pythonVersion)return o.pythonVersion}}catch{}return null}async function xe(t){if(t&&t.trim())try{let n=await wi(t);if(n){let a=k.dirname(n.cmd).includes(".venv")?k.dirname(k.dirname(k.dirname(n.cmd))):k.dirname(n.cmd),s=await ki(a);return s&&(process.env.PYENV_VERSION=s),n}}catch{}let i=await mt();if(i.kind==="venv"){let n=yi(i.pythonPath),a=ue(n);return await v.pathExists(a)?{cmd:a,baseArgs:[]}:{cmd:i.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(i.cmd,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:i.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let a=((await execa(i.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(a&&await v.pathExists(a))try{let s=await execa(a,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(s.exitCode===0&&await Wt(s.stdout))return {cmd:a,baseArgs:[]}}catch{}}catch{}let e=we(),o=await _t(i.cmd),r=ue(e);return await v.pathExists(r)?{cmd:r,baseArgs:[]}:{cmd:o,baseArgs:["-m","rapidkit"]}}async function Vt(){for(let t of ["python3","python"])try{return await execa(t,["--version"],{reject:!1,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function be(){let t=!!process.env.RAPIDKIT_DEBUG,i=e=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${e}
7
15
  `);};for(let e of ["python3","python","python3.10","python3.11","python3.12"])try{i(`Method 1: trying ${e} import`);let o=await execa(e,["-c","import rapidkit_core; print(1)"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.trim()==="1")return i(`\u2713 Found via ${e} import`),!0}catch{continue}for(let e of ["python3","python"])try{i(`Method 2: trying ${e} -m pip show`);let o=await execa(e,["-m","pip","show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return i(`\u2713 Found via ${e} -m pip show`),!0}catch{continue}for(let e of ["pip","pip3"])try{i(`Method 3: trying ${e} show`);let o=await execa(e,["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return i(`\u2713 Found via ${e} show`),!0}catch{continue}try{i("Method 4: checking pyenv versions");let e=await execa("pyenv",["versions","--bare"],{reject:!1,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout){let o=e.stdout.split(`
8
- `).filter(r=>r.trim());i(`Found pyenv versions: ${o.join(", ")}`);for(let r of o){let n=process.env.PYENV_ROOT||w.join(z__default.homedir(),".pyenv"),a=w.join(n,"versions",r.trim(),"bin","pip");try{let s=await execa(a,["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(s.exitCode===0&&s.stdout?.includes("Name: rapidkit-core"))return i(`\u2713 Found in pyenv ${r}`),!0}catch{try{let s=await execa("bash",["-c",`PYENV_VERSION=${r.trim()} pyenv exec pip show rapidkit-core`],{reject:!1,stdio:"pipe",timeout:3e3});if(s.exitCode===0&&s.stdout?.includes("Name: rapidkit-core"))return i(`\u2713 Found in pyenv ${r} via PYENV_VERSION`),!0}catch{continue}}}}}catch{i("pyenv not available");}for(let e of ["python3","python"])try{i(`Method 5: checking ${e} user site`);let o=await execa(e,["-m","site","--user-site"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout){let r=o.stdout.trim(),n=w.join(r,"rapidkit_core");if(await k.pathExists(n))return i("\u2713 Found in user site-packages"),!0}}catch{continue}try{i("Method 6: checking pipx");let e=await execa("pipx",["list"],{reject:!1,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return i("\u2713 Found via pipx"),!0}catch{i("pipx not available");}try{if(i("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3})).exitCode===0)return i("\u2713 Found via poetry"),!0}catch{i("poetry check failed");}try{i("Method 8: checking conda");let e=await execa("conda",["list","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return i("\u2713 Found via conda"),!0}catch{i("conda not available");}return i("\u2717 Not found in any environment"),false}async function $t(t){let i=Ft(),e=se(i);if(await k.pathExists(e))try{let n=await execa(e,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:!1,stdio:"pipe",timeout:2e3});if(n.exitCode===0&&(n.stdout??"").toString().trim()==="1")return e;await k.remove(i);}catch{await k.remove(i);}let o={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},r=async(n,a)=>{let s=await execa(n,a,{reject:false,stdio:["ignore","pipe","inherit"],env:o});if(s.exitCode===0)return;let c=(s.stdout??"").toString(),l=(s.stderr??"").toString(),p=[c,l].filter(Boolean).join(`
9
- `),d=p?`${n} ${a.join(" ")}
10
- ${p}`:`${n} ${a.join(" ")}`;throw new Error(d)};try{await k.ensureDir(w.dirname(i)),await r(t,["-m","venv",i]);let n=se(i);if((await execa(n,["-m","pip","--version"],{reject:!1,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(n,["-m","ensurepip","--default-pip"],{reject:!1,stdio:["ignore","pipe","inherit"],env:o})).exitCode!==0)throw new Error(`Failed to install pip in virtual environment.
11
- Your Python installation may be missing the ensurepip module.
12
- On Debian/Ubuntu, install: sudo apt install python3-venv python3-pip`);return process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1"&&await r(n,["-m","pip","install","-U","pip"]),await r(n,["-m","pip","install","-U",oi()]),n}catch(n){throw new dt("BRIDGE_VENV_BOOTSTRAP_FAILED",Kt(n))}}async function ut(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let e=await Mt();if(!e)throw new dt("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await $t(e)}}for(let e of ["python3","python"])if(await ue(e))return {kind:"system",cmd:e};let t=await Mt();if(!t)throw new dt("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await $t(t)}}async function B(t,i){try{let e=await me(i?.cwd),o=e.cmd,r=[...e.baseArgs,...t],n=await execa(o,r,{cwd:i?.cwd,env:{...process.env,...i?.env},reject:!1,stdio:"inherit"});return typeof n.exitCode=="number"?n.exitCode:1}catch(e){return process.stderr.write(`${Kt(e)}
13
- `),1}}async function Wt(t,i){try{let e=await me(i?.cwd),o=e.cmd,r=[...e.baseArgs,...t],n=await execa(o,r,{cwd:i?.cwd,env:{...process.env,...i?.env},reject:!1,stdio:"pipe"});return {exitCode:typeof n.exitCode=="number"?n.exitCode:1,stdout:(n.stdout??"").toString(),stderr:(n.stderr??"").toString()}}catch(e){return {exitCode:1,stdout:"",stderr:`${Kt(e)}
14
- `}}}function ge(t){let i=new Set,e=t.split(`
15
- `),o=false;for(let r of e){let n=r.replace(/\r$/,"");if(!o){/^\s*Commands:\s*$/i.test(n)&&(o=true);let c=n.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let l=c[1].trim();l&&!l.startsWith("-")&&i.add(l);}continue}if(!n.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(n))continue;let a=n.match(/^\s*([a-z0-9][a-z0-9_-]*)\b/i);if(!a)continue;let s=a[1].trim();s&&!s.startsWith("-")&&i.add(s);}return i}async function he(){let t=de();if(!await k.pathExists(t))return null;try{let i=await k.readJson(t);if(i&&i.schema_version===1&&Array.isArray(i.commands))return i}catch{}return null}async function ai(t){let i=de();await k.ensureDir(w.dirname(i)),await k.writeJson(i,t,{spaces:2});}async function si(){let t=await Wt(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let e=JSON.parse(t.stdout)?.version;return typeof e=="string"?e:void 0}catch{return}}async function ci(){let i=Date.now(),e=await he(),o=await si(),r=!!e?.commands?.length;if(r&&i-e.fetched_at<864e5&&(!o||!e.rapidkit_version||e.rapidkit_version===o))return new Set(e.commands);let n=await Wt(["--help"],{cwd:process.cwd()});if(n.exitCode!==0)return r&&e?.commands?new Set(e.commands):new Set;let a=ge(n.stdout);if(a.size===0)return new Set;let s=Array.from(a).sort();return await ai({schema_version:1,fetched_at:i,rapidkit_version:o,commands:s}),a}async function Vt(){let i=Date.now(),e=await he();return !e||i-e.fetched_at>=864e5||!e.commands?.length?null:new Set(e.commands)}var dt,li,Pt=st(()=>{R();dt=class extends Error{code;constructor(i,e){super(e),this.code=i;}};li={pickSystemPython:Mt,ensureBridgeVenv:$t,parseCoreCommandsFromHelp:ge,tryRapidkit:ue,checkRapidkitCoreAvailable:fe};});var ke={};Nt(ke,{createNpmWorkspaceMarker:()=>Ut,isValidWorkspaceMarker:()=>ui,readWorkspaceMarker:()=>Gt,updateWorkspaceMetadata:()=>di,writeWorkspaceMarker:()=>Ct});async function Gt(t){let i=w.join(t,".rapidkit-workspace");try{if(await k.pathExists(i))return await k.readJson(i)}catch{return null}return null}async function Ct(t,i){let e=w.join(t,".rapidkit-workspace"),o=await Gt(t);o?.metadata&&(i.metadata={...o.metadata,...i.metadata}),await k.outputFile(e,JSON.stringify(i,null,2)+`
16
- `,"utf-8");}async function di(t,i){let e=await Gt(t);return e?(e.metadata={...e.metadata,...i,vscode:i.vscode?{...e.metadata?.vscode,...i.vscode}:e.metadata?.vscode,npm:i.npm?{...e.metadata?.npm,...i.npm}:e.metadata?.npm,python:i.python?{...e.metadata?.python,...i.python}:e.metadata?.python},await Ct(t,e),true):false}function Ut(t,i,e){return {signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:i,createdAt:new Date().toISOString(),name:t,metadata:{npm:{packageVersion:i,installMethod:e,lastUsedAt:new Date().toISOString()}}}}function ui(t){if(!t||typeof t!="object")return false;let i=t;return i.signature==="RAPIDKIT_WORKSPACE"&&typeof i.createdBy=="string"&&typeof i.version=="string"&&typeof i.createdAt=="string"&&typeof i.name=="string"}var Ht=st(()=>{R();});var q={};Nt(q,{createProject:()=>ki,createWorkspace:()=>gi,listWorkspaces:()=>xi,registerProjectInWorkspace:()=>fi,registerWorkspace:()=>ve,syncWorkspaceProjects:()=>mi});async function ve(t,i){try{let e=process.env.XDG_CONFIG_HOME||process.env.APPDATA||w.join(z__default.homedir(),".config"),o=process.platform==="win32"?w.join(e,"rapidkit"):w.join(z__default.homedir(),".rapidkit"),r=w.join(o,"workspaces.json");await promises.mkdir(o,{recursive:!0});let n={workspaces:[]};try{let s=await promises.readFile(r,"utf8"),c=JSON.parse(s);c&&Array.isArray(c.workspaces)&&(n=c);}catch{}n.workspaces.some(s=>s.path===t)||(n.workspaces.push({name:i,path:t,mode:"full",projects:[]}),await promises.writeFile(r,JSON.stringify(n,null,2)));}catch{console.warn(m.gray("Note: Could not register workspace in shared registry"));}}async function mi(t,i=false){try{let e=process.env.XDG_CONFIG_HOME||process.env.APPDATA||w.join(z__default.homedir(),".config"),o=process.platform==="win32"?w.join(e,"rapidkit"):w.join(z__default.homedir(),".rapidkit"),r=w.join(o,"workspaces.json"),n={workspaces:[]};try{let p=await promises.readFile(r,"utf8"),d=JSON.parse(p);d&&Array.isArray(d.workspaces)&&(n=d);}catch{i||console.log("\u26A0\uFE0F Workspace registry not found");return}let a=n.workspaces.find(p=>p.path===t);if(!a){i||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(a.projects)||(a.projects=[]);let s=await promises.readdir(t,{withFileTypes:!0}),c=0,l=0;for(let p of s)if(p.isDirectory()&&!p.name.startsWith(".")){let d=w.join(t,p.name),u=w.join(d,".rapidkit","context.json"),h=w.join(d,".rapidkit","project.json");try{let y=!1;try{await promises.access(u),y=!0;}catch{await promises.access(h),y=!0;}y&&(a.projects.some(A=>A.path===d||A.name===p.name)?l++:(a.projects.push({name:p.name,path:d}),c++,i||console.log(`\u2714 Added: ${p.name}`)));}catch{}}c>0?(await promises.writeFile(r,JSON.stringify(n,null,2)),i||console.log(`
16
+ `).filter(r=>r.trim());i(`Found pyenv versions: ${o.join(", ")}`);for(let r of o){let n=process.env.PYENV_ROOT||k.join(Q__default.homedir(),".pyenv"),a=k.join(n,"versions",r.trim(),"bin","pip");try{let s=await execa(a,["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(s.exitCode===0&&s.stdout?.includes("Name: rapidkit-core"))return i(`\u2713 Found in pyenv ${r}`),!0}catch{try{let s=await execa("bash",["-c",`PYENV_VERSION=${r.trim()} pyenv exec pip show rapidkit-core`],{reject:!1,stdio:"pipe",timeout:3e3});if(s.exitCode===0&&s.stdout?.includes("Name: rapidkit-core"))return i(`\u2713 Found in pyenv ${r} via PYENV_VERSION`),!0}catch{continue}}}}}catch{i("pyenv not available");}for(let e of ["python3","python"])try{i(`Method 5: checking ${e} user site`);let o=await execa(e,["-m","site","--user-site"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout){let r=o.stdout.trim(),n=k.join(r,"rapidkit_core");if(await v.pathExists(n))return i("\u2713 Found in user site-packages"),!0}}catch{continue}try{i("Method 6: checking pipx");let e=await execa("pipx",["list"],{reject:!1,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return i("\u2713 Found via pipx"),!0}catch{i("pipx not available");}try{if(i("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3})).exitCode===0)return i("\u2713 Found via poetry"),!0}catch{i("poetry check failed");}try{i("Method 8: checking conda");let e=await execa("conda",["list","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return i("\u2713 Found via conda"),!0}catch{i("conda not available");}return i("\u2717 Not found in any environment"),false}async function _t(t){let i=we(),e=gi(),o=Gt(),r=[i];!hi(o)&&!await v.pathExists(i)&&await v.pathExists(e)&&r.push(e);for(let f of r){let g=de(f);if(await v.pathExists(g))try{let h=await execa(g,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:!1,stdio:"pipe",timeout:2e3});if(h.exitCode===0&&(h.stdout??"").toString().trim()==="1")return g;await v.remove(f);}catch{await v.remove(f);}}let n=i,a={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},s=Math.max(0,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY??"2")),c=Math.max(200,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY_DELAY_MS??"800")),l=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),p=f=>new Promise(g=>setTimeout(g,f)),d=async(f,g,h)=>{let j=await execa(f,g,{reject:false,stdio:["ignore","pipe","inherit"],env:a,timeout:h});if(j.exitCode===0)return;let N=(j.stdout??"").toString(),T=(j.stderr??"").toString(),V=[N,T].filter(Boolean).join(`
17
+ `),Ft=V?`${f} ${g.join(" ")}
18
+ ${V}`:`${f} ${g.join(" ")}`;throw new Error(Ft)},u=async(f,g,h)=>{let j=0;for(;;)try{await d(f,g,h);return}catch(N){if(j>=s)throw N;let T=Math.floor(Math.random()*200),V=c*Math.pow(2,j)+T;j+=1,await p(V);}};try{await v.ensureDir(k.dirname(n));try{await d(t,["-m","venv",n],6e4);}catch(h){let j=h instanceof Error?h.message:String(h);throw new J("BRIDGE_VENV_CREATE_FAILED",j)}let f=de(n);if((await execa(f,["-m","pip","--version"],{reject:!1,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(f,["-m","ensurepip","--default-pip"],{reject:!1,stdio:["ignore","pipe","inherit"],env:a,timeout:6e4})).exitCode!==0)throw new J("BRIDGE_PIP_BOOTSTRAP_FAILED","ensurepip failed; install python3-venv/python3-pip and retry.");if(process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1")try{await u(f,["-m","pip","install","-U","pip"],l);}catch(h){let j=h instanceof Error?h.message:String(h);throw new J("BRIDGE_PIP_UPGRADE_FAILED",j)}try{await u(f,["-m","pip","install","-U",Gt()],l);}catch(h){let j=h instanceof Error?h.message:String(h);throw new J("BRIDGE_PIP_INSTALL_FAILED",j)}return f}catch(f){if(f instanceof J)throw f;let g=f instanceof Error?f.message:String(f);throw new J("BRIDGE_VENV_BOOTSTRAP_FAILED",g)}}async function mt(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let e=await Vt();if(!e)throw new J("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await _t(e)}}for(let e of ["python3","python"])if(await ve(e))return {kind:"system",cmd:e};let t=await Vt();if(!t)throw new J("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await _t(t)}}async function Y(t,i){try{let e=await xe(i?.cwd),o=e.cmd,r=[...e.baseArgs,...t],n=await execa(o,r,{cwd:i?.cwd,env:{...process.env,...i?.env},reject:!1,stdio:"inherit"});return typeof n.exitCode=="number"?n.exitCode:1}catch(e){return process.stderr.write(`${ye(e)}
19
+ `),1}}async function ut(t,i){try{let e=await xe(i?.cwd),o=e.cmd,r=[...e.baseArgs,...t],n=await execa(o,r,{cwd:i?.cwd,env:{...process.env,...i?.env},reject:!1,stdio:"pipe"});return {exitCode:typeof n.exitCode=="number"?n.exitCode:1,stdout:(n.stdout??"").toString(),stderr:(n.stderr??"").toString()}}catch(e){return {exitCode:1,stdout:"",stderr:`${ye(e)}
20
+ `}}}function je(t){let i=new Set,e=t.split(`
21
+ `),o=false;for(let r of e){let n=r.replace(/\r$/,"");if(!o){/^\s*Commands:\s*$/i.test(n)&&(o=true);let c=n.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let l=c[1].trim();l&&!l.startsWith("-")&&i.add(l);}continue}if(!n.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(n))continue;let a=n.match(/^\s*([a-z0-9][a-z0-9_-]*)\b/i);if(!a)continue;let s=a[1].trim();s&&!s.startsWith("-")&&i.add(s);}return i}async function $e(){let t=ke();if(!await v.pathExists(t))return null;try{let i=await v.readJson(t);if(i&&i.schema_version===1&&Array.isArray(i.commands))return i}catch{}return null}async function me(t){let i=ke();await v.ensureDir(k.dirname(i)),await v.writeJson(i,t,{spaces:2});}async function vi(){let t=await ut(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let e=JSON.parse(t.stdout)?.version;return typeof e=="string"?e:void 0}catch{return}}async function xi(){let t=await ut(["commands","--json"],{cwd:process.cwd()});if(t.exitCode!==0)return null;try{let i=JSON.parse(t.stdout);if(i?.schema_version!==1||!Array.isArray(i.commands))return null;let e=i.commands.filter(o=>typeof o=="string");return e.length?e:null}catch{return null}}async function bi(){let i=Date.now(),e=await $e(),o=await vi(),r=!!e?.commands?.length;if(r&&i-e.fetched_at<864e5&&(!o||!e.rapidkit_version||e.rapidkit_version===o))return new Set(e.commands);let n=await xi();if(n?.length){let l=Array.from(new Set(n)).sort();return await me({schema_version:1,fetched_at:i,rapidkit_version:o,commands:l}),new Set(l)}let a=await ut(["--help"],{cwd:process.cwd()});if(a.exitCode!==0)return r&&e?.commands?new Set(e.commands):new Set(vt);let s=je(a.stdout);if(s.size===0)return new Set(vt);let c=Array.from(s).sort();return await me({schema_version:1,fetched_at:i,rapidkit_version:o,commands:c}),s}async function Ut(){let i=Date.now(),e=await $e();return !e||i-e.fetched_at>=864e5||!e.commands?.length?null:new Set(e.commands)}function Pe(){return k.join(Rt(),"rapidkit","npm-bridge","modules-catalog.json")}async function ji(){let t=Pe();if(!await v.pathExists(t))return null;try{let i=await v.readJson(t);if(i&&i.schema_version===1&&Array.isArray(i.modules))return i}catch{}return null}async function fe(t){let i=Pe();await v.ensureDir(k.dirname(i)),await v.writeJson(i,t,{spaces:2});}function ge(t){try{return JSON.parse(t)}catch{return null}}async function $i(t={}){let i=typeof t.ttlMs=="number"?t.ttlMs:18e5,e=Date.now(),o=await ji();if(o?.fetched_at&&e-o.fetched_at<i)return o;let r=["modules","list","--json-schema","1"];t.category&&r.push("--category",t.category),t.tag&&r.push("--tag",t.tag),t.detailed&&r.push("--detailed");let n=await ut(r,{cwd:t.cwd,env:t.env});if(n.exitCode===0){let s=ge(n.stdout);if(s&&s.schema_version===1&&Array.isArray(s.modules)){let c={...s,fetched_at:e};return await fe(c),c}}let a=await ut(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(a.exitCode===0){let s=ge(a.stdout);if(Array.isArray(s)){let c={schema_version:1,generated_at:new Date().toISOString(),filters:{category:t.category??null,tag:t.tag??null,detailed:!!t.detailed},stats:{total:s.length,returned:s.length,invalid:0},modules:s,source:"legacy-json",fetched_at:e};return await fe(c),c}}return o||null}var J,Pi,Ct=ot(()=>{E();Lt();J=class extends Error{code;constructor(i,e){super(e),this.code=i;}};Pi={pickSystemPython:Vt,ensureBridgeVenv:_t,parseCoreCommandsFromHelp:je,tryRapidkit:ve,checkRapidkitCoreAvailable:be};});var Re={};Ot(Re,{createNpmWorkspaceMarker:()=>Jt,isValidWorkspaceMarker:()=>Ri,readWorkspaceMarker:()=>Ht,updateWorkspaceMetadata:()=>_i,writeWorkspaceMarker:()=>It});async function Ht(t){let i=k.join(t,".rapidkit-workspace");try{if(await v.pathExists(i))return await v.readJson(i)}catch{return null}return null}async function It(t,i){let e=k.join(t,".rapidkit-workspace"),o=await Ht(t);o?.metadata&&(i.metadata={...o.metadata,...i.metadata}),await v.outputFile(e,JSON.stringify(i,null,2)+`
22
+ `,"utf-8");}async function _i(t,i){let e=await Ht(t);return e?(e.metadata={...e.metadata,...i,vscode:i.vscode?{...e.metadata?.vscode,...i.vscode}:e.metadata?.vscode,npm:i.npm?{...e.metadata?.npm,...i.npm}:e.metadata?.npm,python:i.python?{...e.metadata?.python,...i.python}:e.metadata?.python},await It(t,e),true):false}function Jt(t,i,e){return {signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:i,createdAt:new Date().toISOString(),name:t,metadata:{npm:{packageVersion:i,installMethod:e,lastUsedAt:new Date().toISOString()}}}}function Ri(t){if(!t||typeof t!="object")return false;let i=t;return i.signature==="RAPIDKIT_WORKSPACE"&&typeof i.createdBy=="string"&&typeof i.version=="string"&&typeof i.createdAt=="string"&&typeof i.name=="string"}var Yt=ot(()=>{E();});var X={};Ot(X,{createProject:()=>Ni,createWorkspace:()=>Ii,listWorkspaces:()=>Fi,registerProjectInWorkspace:()=>Ei,registerWorkspace:()=>Ce,syncWorkspaceProjects:()=>Ci});async function Ce(t,i){try{let e=process.env.XDG_CONFIG_HOME||process.env.APPDATA||k.join(Q__default.homedir(),".config"),o=process.platform==="win32"?k.join(e,"rapidkit"):k.join(Q__default.homedir(),".rapidkit"),r=k.join(o,"workspaces.json");await promises.mkdir(o,{recursive:!0});let n={workspaces:[]};try{let s=await promises.readFile(r,"utf8"),c=JSON.parse(s);c&&Array.isArray(c.workspaces)&&(n=c);}catch{}n.workspaces.some(s=>s.path===t)||(n.workspaces.push({name:i,path:t,mode:"full",projects:[]}),await promises.writeFile(r,JSON.stringify(n,null,2)));}catch{console.warn(m.gray("Note: Could not register workspace in shared registry"));}}async function Ci(t,i=false){try{let e=process.env.XDG_CONFIG_HOME||process.env.APPDATA||k.join(Q__default.homedir(),".config"),o=process.platform==="win32"?k.join(e,"rapidkit"):k.join(Q__default.homedir(),".rapidkit"),r=k.join(o,"workspaces.json"),n={workspaces:[]};try{let p=await promises.readFile(r,"utf8"),d=JSON.parse(p);d&&Array.isArray(d.workspaces)&&(n=d);}catch{i||console.log("\u26A0\uFE0F Workspace registry not found");return}let a=n.workspaces.find(p=>p.path===t);if(!a){i||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(a.projects)||(a.projects=[]);let s=await promises.readdir(t,{withFileTypes:!0}),c=0,l=0;for(let p of s)if(p.isDirectory()&&!p.name.startsWith(".")){let d=k.join(t,p.name),u=k.join(d,".rapidkit","context.json"),f=k.join(d,".rapidkit","project.json");try{let g=!1;try{await promises.access(u),g=!0;}catch{await promises.access(f),g=!0;}g&&(a.projects.some(j=>j.path===d||j.name===p.name)?l++:(a.projects.push({name:p.name,path:d}),c++,i||console.log(`\u2714 Added: ${p.name}`)));}catch{}}c>0?(await promises.writeFile(r,JSON.stringify(n,null,2)),i||console.log(`
17
23
  \u2705 Synced ${c} project(s) to registry`)):i||console.log(`
18
- \u2705 All projects already registered (${l} found)`);}catch(e){i||console.error("\u274C Failed to sync projects:",e.message);}}async function fi(t,i,e){try{let o=process.env.XDG_CONFIG_HOME||process.env.APPDATA||w.join(z__default.homedir(),".config"),r=process.platform==="win32"?w.join(o,"rapidkit"):w.join(z__default.homedir(),".rapidkit"),n=w.join(r,"workspaces.json");console.log(`[REGISTRY DEBUG] Registry file: ${n}`);let a={workspaces:[]};try{let l=await promises.readFile(n,"utf8"),p=JSON.parse(l);p&&Array.isArray(p.workspaces)&&(a=p),console.log(`[REGISTRY DEBUG] Registry loaded, ${a.workspaces.length} workspaces`);}catch{console.log("[REGISTRY DEBUG] Registry doesn't exist, returning");return}let s=a.workspaces.find(l=>l.path===t);if(!s){console.log("[REGISTRY DEBUG] Workspace not found in registry, returning");return}console.log(`[REGISTRY DEBUG] Workspace found: ${s.name}`),Array.isArray(s.projects)||(s.projects=[]),s.projects.some(l=>l.path===e||l.name===i)?console.log("[REGISTRY DEBUG] Project already exists in registry"):(console.log("[REGISTRY DEBUG] Adding project to registry"),s.projects.push({name:i,path:e}),await promises.writeFile(n,JSON.stringify(a,null,2)),console.log("[REGISTRY DEBUG] Registry updated successfully"));}catch(o){console.log(`[REGISTRY DEBUG] Error: ${o}`);}}async function gi(t,i){let e=kt("Creating RapidKit workspace...").start();try{await promises.mkdir(t,{recursive:!0}),await promises.mkdir(w.join(t,".rapidkit"),{recursive:!0});let o={workspace_name:i.name,author:i.author,rapidkit_version:H(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(w.join(t,".rapidkit","config.json"),JSON.stringify(o,null,2));let r=hi();await promises.writeFile(w.join(t,"rapidkit"),r),await promises.chmod(w.join(t,"rapidkit"),493);let n=yi(i.name);if(await promises.writeFile(w.join(t,"README.md"),n),await promises.writeFile(w.join(t,".gitignore"),`# RapidKit workspace
24
+ \u2705 All projects already registered (${l} found)`);}catch(e){i||console.error("\u274C Failed to sync projects:",e.message);}}async function Ei(t,i,e){try{let o=process.env.XDG_CONFIG_HOME||process.env.APPDATA||k.join(Q__default.homedir(),".config"),r=process.platform==="win32"?k.join(o,"rapidkit"):k.join(Q__default.homedir(),".rapidkit"),n=k.join(r,"workspaces.json");console.log(`[REGISTRY DEBUG] Registry file: ${n}`);let a={workspaces:[]};try{let l=await promises.readFile(n,"utf8"),p=JSON.parse(l);p&&Array.isArray(p.workspaces)&&(a=p),console.log(`[REGISTRY DEBUG] Registry loaded, ${a.workspaces.length} workspaces`);}catch{console.log("[REGISTRY DEBUG] Registry doesn't exist, returning");return}let s=a.workspaces.find(l=>l.path===t);if(!s){console.log("[REGISTRY DEBUG] Workspace not found in registry, returning");return}console.log(`[REGISTRY DEBUG] Workspace found: ${s.name}`),Array.isArray(s.projects)||(s.projects=[]),s.projects.some(l=>l.path===e||l.name===i)?console.log("[REGISTRY DEBUG] Project already exists in registry"):(console.log("[REGISTRY DEBUG] Adding project to registry"),s.projects.push({name:i,path:e}),await promises.writeFile(n,JSON.stringify(a,null,2)),console.log("[REGISTRY DEBUG] Registry updated successfully"));}catch(o){console.log(`[REGISTRY DEBUG] Error: ${o}`);}}async function Ii(t,i){let e=xt("Creating RapidKit workspace...").start();try{await promises.mkdir(t,{recursive:!0}),await promises.mkdir(k.join(t,".rapidkit"),{recursive:!0});let o={workspace_name:i.name,author:i.author,rapidkit_version:H(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(k.join(t,".rapidkit","config.json"),JSON.stringify(o,null,2));let r=Si();await promises.writeFile(k.join(t,"rapidkit"),r),await promises.chmod(k.join(t,"rapidkit"),493);let n=Ai(i.name);if(await promises.writeFile(k.join(t,"README.md"),n),await promises.writeFile(k.join(t,".gitignore"),`# RapidKit workspace
19
25
  .env
20
26
  .env.*
21
27
  !.env.example
@@ -30,7 +36,7 @@ Thumbs.db
30
36
 
31
37
  # Logs
32
38
  *.log
33
- `),await promises.writeFile(w.join(t,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:H(),createdAt:new Date().toISOString(),name:i.name},null,2)),await wi(t),e.succeed("Workspace created!"),!i.skipGit){let s=kt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:t}),s.succeed("Git repository initialized");}catch{s.warn("Could not initialize git repository");}}await ve(t,i.name),console.log(`
39
+ `),await promises.writeFile(k.join(t,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:H(),createdAt:new Date().toISOString(),name:i.name},null,2)),await Di(t),e.succeed("Workspace created!"),!i.skipGit){let s=xt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:t}),s.succeed("Git repository initialized");}catch{s.warn("Could not initialize git repository");}}await Ce(t,i.name),console.log(`
34
40
  ${m.green("\u2728 RapidKit workspace created successfully!")}
35
41
 
36
42
  ${m.bold("\u{1F4C2} Workspace structure:")}
@@ -60,7 +66,7 @@ ${m.bold("\u{1F4DA} Commands:")}
60
66
 
61
67
  ${m.gray("Alternative: ./rapidkit dev, make dev")}
62
68
  ${m.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
63
- `);}catch(o){throw e.fail("Failed to create workspace"),o}}function hi(){return `#!/usr/bin/env bash
69
+ `);}catch(o){throw e.fail("Failed to create workspace"),o}}function Si(){return `#!/usr/bin/env bash
64
70
  #
65
71
  # RapidKit CLI - Local workspace commands
66
72
  # This script provides rapidkit commands within the workspace
@@ -408,7 +414,7 @@ main() {
408
414
  }
409
415
 
410
416
  main "$@"
411
- `}function yi(t){return `# ${t}
417
+ `}function Ai(t){return `# ${t}
412
418
 
413
419
  RapidKit workspace for building API projects.
414
420
 
@@ -456,7 +462,7 @@ npx rapidkit dev # Start dev server
456
462
 
457
463
  - [RapidKit Documentation](https://rapidkit.dev)
458
464
  - [GitHub Repository](https://github.com/Baziar/rapidkit)
459
- `}async function wi(t){let{fileURLToPath:i}=await import('url'),e=i(import.meta.url),o=w.dirname(e),r=w.resolve(o,".."),n=w.join(r,"templates","kits"),a=w.join(t,".rapidkit","templates"),{default:s}=await import('fs-extra');await s.copy(n,a);let c=w.join(r,"templates","generator.js"),l=w.join(t,".rapidkit","generator.js");await s.copy(c,l);}async function ki(t,i){let e=i.template==="fastapi",o=e?"FastAPI":"NestJS",r=kt(`Creating ${o} project...`).start();try{let{fileURLToPath:n}=await import('url'),a=n(import.meta.url),s=w.dirname(a),c=w.resolve(s,".."),l=e?"fastapi-standard":"nestjs-standard",p=w.join(c,"templates","kits",l);await promises.mkdir(t,{recursive:!0});let d={project_name:e?i.name.replace(/-/g,"_").toLowerCase():i.name.replace(/_/g,"-").toLowerCase(),author:i.author,description:i.description||`${o} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:i.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:H()};await xe(p,t,d);let u=e?`# Python
465
+ `}async function Di(t){let{fileURLToPath:i}=await import('url'),e=i(import.meta.url),o=k.dirname(e),r=k.resolve(o,".."),n=k.join(r,"templates","kits"),a=k.join(t,".rapidkit","templates"),{default:s}=await import('fs-extra');await s.copy(n,a);let c=k.join(r,"templates","generator.js"),l=k.join(t,".rapidkit","generator.js");await s.copy(c,l);}async function Ni(t,i){let e=i.template==="fastapi",o=e?"FastAPI":"NestJS",r=xt(`Creating ${o} project...`).start();try{let{fileURLToPath:n}=await import('url'),a=n(import.meta.url),s=k.dirname(a),c=k.resolve(s,".."),l=e?"fastapi-standard":"nestjs-standard",p=k.join(c,"templates","kits",l);await promises.mkdir(t,{recursive:!0});let d={project_name:e?i.name.replace(/-/g,"_").toLowerCase():i.name.replace(/_/g,"-").toLowerCase(),author:i.author,description:i.description||`${o} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:i.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:H()};await Ee(p,t,d);let u=e?`# Python
460
466
  __pycache__/
461
467
  *.py[cod]
462
468
  *$py.class
@@ -524,7 +530,7 @@ Thumbs.db
524
530
 
525
531
  # Coverage
526
532
  coverage/
527
- `;if(await promises.writeFile(w.join(t,".gitignore"),u),r.succeed(`${o} project created!`),!i.skipGit){let y=kt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m",`Initial commit: ${o} project via RapidKit`],{cwd:t}),y.succeed("Git repository initialized");}catch{y.warn("Could not initialize git repository");}}if(!i.skipInstall&&!e){let y=i.package_manager||"npm",x=kt(`Installing dependencies with ${y}...`).start();try{await execa(y,["install"],{cwd:t}),x.succeed("Dependencies installed");}catch{x.warn(`Could not install dependencies. Run '${y} install' manually.`);}}let h=w.basename(t);console.log(e?`
533
+ `;if(await promises.writeFile(k.join(t,".gitignore"),u),r.succeed(`${o} project created!`),!i.skipGit){let g=xt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m",`Initial commit: ${o} project via RapidKit`],{cwd:t}),g.succeed("Git repository initialized");}catch{g.warn("Could not initialize git repository");}}if(!i.skipInstall&&!e){let g=i.package_manager||"npm",h=xt(`Installing dependencies with ${g}...`).start();try{await execa(g,["install"],{cwd:t}),h.succeed("Dependencies installed");}catch{h.warn(`Could not install dependencies. Run '${g} install' manually.`);}}let f=k.basename(t);console.log(e?`
528
534
  ${m.green("\u2728 FastAPI project created successfully!")}
529
535
 
530
536
  ${m.bold("\u{1F4C2} Project structure:")}
@@ -540,7 +546,7 @@ ${t}/
540
546
  \u2514\u2500\u2500 README.md
541
547
 
542
548
  ${m.bold("\u{1F680} Get started:")}
543
- ${m.cyan(`cd ${h}`)}
549
+ ${m.cyan(`cd ${f}`)}
544
550
  ${m.cyan("npx rapidkit init")} ${m.gray("# Install dependencies")}
545
551
  ${m.cyan("npx rapidkit dev")} ${m.gray("# Start dev server")}
546
552
 
@@ -570,7 +576,7 @@ ${t}/
570
576
  \u2514\u2500\u2500 README.md
571
577
 
572
578
  ${m.bold("\u{1F680} Get started:")}
573
- ${m.cyan(`cd ${h}`)}
579
+ ${m.cyan(`cd ${f}`)}
574
580
  ${i.skipInstall?m.cyan("npx rapidkit init")+m.gray(" # npm install")+`
575
581
  `:""}${m.cyan("cp .env.example .env")}
576
582
  ${m.cyan("npx rapidkit dev")} ${m.gray("# Start dev server")}
@@ -590,7 +596,7 @@ ${m.bold("\u{1F310} API endpoints:")}
590
596
  http://localhost:8000/examples/notes # Example API
591
597
 
592
598
  ${m.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
593
- `);}catch(n){throw r.fail(`Failed to create ${o} project`),n}}async function xe(t,i,e){let o=await promises.readdir(t,{withFileTypes:true});for(let r of o){let n=w.join(t,r.name),a=r.name.replace(/\.j2$/,""),s=w.join(i,a);if(r.isDirectory())await promises.mkdir(s,{recursive:true}),await xe(n,s,e);else {let c=await promises.readFile(n,"utf-8");r.name.endsWith(".j2")&&(c=vi(c,e)),await promises.writeFile(s,c),(a==="rapidkit"||a==="activate"||a.endsWith(".py")&&s.includes(".rapidkit"))&&await promises.chmod(s,493);}}}function vi(t,i){let e=t;for(let[o,r]of Object.entries(i)){let n=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");e=e.replace(n,String(r));let a=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");e=e.replace(a,(l,p,d)=>String(r).replace(new RegExp(p,"g"),d));let s=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");e=e.replace(s,String(r).toLowerCase());let c=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");e=e.replace(c,(l,p,d)=>String(r).replace(new RegExp(p,"g"),d).toLowerCase());}return e}async function xi(){let t=process.env.XDG_CONFIG_HOME||process.env.APPDATA||w.join(z__default.homedir(),".config"),i=process.platform==="win32"?w.join(t,"rapidkit"):w.join(z__default.homedir(),".rapidkit"),e=w.join(i,"workspaces.json");if(!await promises.stat(e).catch(()=>null)){console.log(m.yellow(`
599
+ `);}catch(n){throw r.fail(`Failed to create ${o} project`),n}}async function Ee(t,i,e){let o=await promises.readdir(t,{withFileTypes:true});for(let r of o){let n=k.join(t,r.name),a=r.name.replace(/\.j2$/,""),s=k.join(i,a);if(r.isDirectory())await promises.mkdir(s,{recursive:true}),await Ee(n,s,e);else {let c=await promises.readFile(n,"utf-8");r.name.endsWith(".j2")&&(c=Ti(c,e)),await promises.writeFile(s,c),(a==="rapidkit"||a==="activate"||a.endsWith(".py")&&s.includes(".rapidkit"))&&await promises.chmod(s,493);}}}function Ti(t,i){let e=t;for(let[o,r]of Object.entries(i)){let n=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");e=e.replace(n,String(r));let a=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");e=e.replace(a,(l,p,d)=>String(r).replace(new RegExp(p,"g"),d));let s=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");e=e.replace(s,String(r).toLowerCase());let c=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");e=e.replace(c,(l,p,d)=>String(r).replace(new RegExp(p,"g"),d).toLowerCase());}return e}async function Fi(){let t=process.env.XDG_CONFIG_HOME||process.env.APPDATA||k.join(Q__default.homedir(),".config"),i=process.platform==="win32"?k.join(t,"rapidkit"):k.join(Q__default.homedir(),".rapidkit"),e=k.join(i,"workspaces.json");if(!await promises.stat(e).catch(()=>null)){console.log(m.yellow(`
594
600
  \u26A0\uFE0F No workspaces registered yet.
595
601
  `)),console.log(m.gray(`Create a workspace with: npx rapidkit <workspace-name>
596
602
  `));return}try{let o=await promises.readFile(e,"utf8"),r=JSON.parse(o);if(!r.workspaces||r.workspaces.length===0){console.log(m.yellow(`
@@ -599,28 +605,28 @@ ${m.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx
599
605
  \u{1F4E6} Registered RapidKit Workspaces:
600
606
  `));for(let n of r.workspaces)console.log(m.cyan(` ${n.name}`)),console.log(m.gray(` Path: ${n.path}`)),console.log(m.gray(` Projects: ${n.projects?.length||0}`)),await promises.stat(n.path).catch(()=>null)||console.log(m.red(" \u26A0\uFE0F Path not found")),console.log();console.log(m.gray(`Total: ${r.workspaces.length} workspace(s)
601
607
  `));}catch(o){console.error(m.red(`
602
- \u274C Failed to read workspace registry`)),console.error(m.gray(String(o)));}}var Q=st(()=>{R();gt();});R();ct();gt();R();ct();var qe=".rapidkitrc.json",Qe=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function ht(){let t=w.join(z__default.homedir(),qe);try{let i=await promises.readFile(t,"utf-8"),e=JSON.parse(i);return f.debug(`Loaded config from ${t}`),e}catch{return f.debug("No user config found, using defaults"),{}}}async function oe(t=process.cwd()){let i=t,e=w.parse(i).root;for(;i!==e;){for(let o of Qe){let r=w.join(i,o);try{await promises.access(r),f.debug(`Found config file: ${r}`);let a=await import(pathToFileURL(r).href),s=a.default||a;return f.debug(`Loaded RapidKit config from ${o}`),s}catch{continue}}i=w.dirname(i);}return f.debug("No RapidKit config file found, using defaults"),{}}function ne(t,i,e){return {author:e.author||i.workspace?.defaultAuthor||t.author,pythonVersion:i.workspace?.pythonVersion||t.pythonVersion,defaultInstallMethod:e.defaultInstallMethod||i.workspace?.installMethod||t.defaultInstallMethod,defaultKit:e.defaultKit||i.projects?.defaultKit||t.defaultKit,skipGit:e.skipGit??i.projects?.skipGit??t.skipGit,license:e.license||t.license,testRapidKitPath:e.testRapidKitPath||t.testRapidKitPath}}function jt(t){return process.env.RAPIDKIT_DEV_PATH||t.testRapidKitPath||void 0}R();R();var G=class extends Error{constructor(e,o,r){super(e);this.code=o;this.details=r;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},lt=class extends G{constructor(i,e){let o=e?`Python ${i}+ required, found ${e}`:`Python ${i}+ not found`;super(o,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},yt=class extends G{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},wt=class extends G{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},bt=class extends G{constructor(i){super(`Directory "${i}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},Y=class extends G{constructor(i,e){super(`Invalid project name: "${i}"`,"INVALID_PROJECT_NAME",e);}},M=class extends G{constructor(i,e){let o=`Installation failed at: ${i}`,r=`${e.message}
608
+ \u274C Failed to read workspace registry`)),console.error(m.gray(String(o)));}}var Z=ot(()=>{E();ht();});E();lt();ht();E();lt();var ri=".rapidkitrc.json",ai=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function yt(){let t=k.join(Q__default.homedir(),ri);try{let i=await promises.readFile(t,"utf-8"),e=JSON.parse(i);return y.debug(`Loaded config from ${t}`),e}catch{return y.debug("No user config found, using defaults"),{}}}async function se(t=process.cwd()){let i=t,e=k.parse(i).root;for(;i!==e;){for(let o of ai){let r=k.join(i,o);try{await promises.access(r),y.debug(`Found config file: ${r}`);let a=await import(pathToFileURL(r).href),s=a.default||a;return y.debug(`Loaded RapidKit config from ${o}`),s}catch{continue}}i=k.dirname(i);}return y.debug("No RapidKit config file found, using defaults"),{}}function ce(t,i,e){return {author:e.author||i.workspace?.defaultAuthor||t.author,pythonVersion:i.workspace?.pythonVersion||t.pythonVersion,defaultInstallMethod:e.defaultInstallMethod||i.workspace?.installMethod||t.defaultInstallMethod,defaultKit:e.defaultKit||i.projects?.defaultKit||t.defaultKit,skipGit:e.skipGit??i.projects?.skipGit??t.skipGit,license:e.license||t.license,testRapidKitPath:e.testRapidKitPath||t.testRapidKitPath}}function $t(t){return process.env.RAPIDKIT_DEV_PATH||t.testRapidKitPath||void 0}E();E();var U=class extends Error{constructor(e,o,r){super(e);this.code=o;this.details=r;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},pt=class extends U{constructor(i,e){let o=e?`Python ${i}+ required, found ${e}`:`Python ${i}+ not found`;super(o,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},wt=class extends U{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},kt=class extends U{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},Pt=class extends U{constructor(i){super(`Directory "${i}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},q=class extends U{constructor(i,e){super(`Invalid project name: "${i}"`,"INVALID_PROJECT_NAME",e);}},M=class extends U{constructor(i,e){let o=`Installation failed at: ${i}`,r=`${e.message}
603
609
 
604
610
  Troubleshooting:
605
611
  - Check your internet connection
606
612
  - Verify Python/Poetry installation
607
- - Try running with --debug flag for more details`;super(o,"INSTALLATION_ERROR",r);}},pt=class extends G{constructor(){super("RapidKit Python package is not yet available on PyPI","RAPIDKIT_NOT_AVAILABLE",`Available options:
613
+ - Try running with --debug flag for more details`;super(o,"INSTALLATION_ERROR",r);}},dt=class extends U{constructor(){super("RapidKit Python package is not yet available on PyPI","RAPIDKIT_NOT_AVAILABLE",`Available options:
608
614
  1. Install Python 3.10+ and retry the same command
609
615
  2. Use the core workflow: npx rapidkit create workspace <name>
610
616
  3. Offline fallback (limited): npx rapidkit create project fastapi.standard <name> --output .
611
617
 
612
- Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function re(t){let i=Xe(t);if(!i.validForNewPackages){let o=i.errors||[],r=i.warnings||[],n=[...o,...r];throw new Y(t,`NPM validation failed: ${n.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(t))throw new Y(t,"Must start with a lowercase letter and contain only lowercase letters, numbers, hyphens, and underscores");if(["test","tests","src","dist","build","lib","python","pip","poetry","node","npm","rapidkit","rapidkit"].includes(t.toLowerCase()))throw new Y(t,`"${t}" is a reserved name. Please choose a different name.`);if(t.length<2)throw new Y(t,"Name must be at least 2 characters long");if(t.length>214)throw new Y(t,"Name must be less than 214 characters");return true}R();function ti(t){return typeof t=="object"&&t!==null}async function ei(t,i,e,o=8e3){try{let r=await execa(t,i,{cwd:e,timeout:o,reject:!1,stdio:"pipe"});return {ok:r.exitCode===0,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch(r){return {ok:false,exitCode:void 0,stdout:"",stderr:r instanceof Error?r.message:String(r)}}}async function ii(t,i){let e=["-m","rapidkit",...t],o=["python3","python"];for(let r of o){let n=await ei(r,e,i?.cwd,i?.timeoutMs);if(!n.ok)continue;let a=(n.stdout??"").trim();try{let s=JSON.parse(a);return ti(s)?{ok:!0,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr,data:s}:{ok:!1,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}catch{return {ok:false,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}}return {ok:false}}async function ae(t,i){let e=await ii(["project","detect","--path",t,"--json"],i);return !e.ok||!e.data||e.data.schema_version!==1?{ok:false,command:e.command,exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr}:e}Pt();R();var pi=["version","project","create","init","dev","start","build","test","lint","format","add","list","info","upgrade","diff","doctor","license","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],ye=new Set(pi);R();ct();gt();R();function Rt(){return process.platform==="win32"?"python":"python3"}Ht();async function $e(t,i,e,o){let r=Ut(i,H(),e);o&&(r.metadata||(r.metadata={}),r.metadata.python={version:o}),await Ct(t,r);}async function Pe(t){await k.outputFile(w.join(t,".gitignore"),`.venv/
618
+ Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function le(t){let i=si(t);if(!i.validForNewPackages){let o=i.errors||[],r=i.warnings||[],n=[...o,...r];throw new q(t,`NPM validation failed: ${n.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(t))throw new q(t,"Must start with a lowercase letter and contain only lowercase letters, numbers, hyphens, and underscores");if(["test","tests","src","dist","build","lib","python","pip","poetry","node","npm","rapidkit","rapidkit"].includes(t.toLowerCase()))throw new q(t,`"${t}" is a reserved name. Please choose a different name.`);if(t.length<2)throw new q(t,"Name must be at least 2 characters long");if(t.length>214)throw new q(t,"Name must be less than 214 characters");return true}E();function li(t){return typeof t=="object"&&t!==null}async function pi(t,i,e,o=8e3){try{let r=await execa(t,i,{cwd:e,timeout:o,reject:!1,stdio:"pipe"});return {ok:r.exitCode===0,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch(r){return {ok:false,exitCode:void 0,stdout:"",stderr:r instanceof Error?r.message:String(r)}}}async function di(t,i){let e=["-m","rapidkit",...t],o=["python3","python"];for(let r of o){let n=await pi(r,e,i?.cwd,i?.timeoutMs);if(!n.ok)continue;let a=(n.stdout??"").trim();try{let s=JSON.parse(a);return li(s)?{ok:!0,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr,data:s}:{ok:!1,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}catch{return {ok:false,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}}return {ok:false}}async function pe(t,i){let e=await di(["project","detect","--path",t,"--json"],i);return !e.ok||!e.data||e.data.schema_version!==1?{ok:false,command:e.command,exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr}:e}Ct();Lt();E();lt();ht();E();function Et(){return process.platform==="win32"?"python":"python3"}Yt();async function Ae(t,i,e,o){let r=Jt(i,H(),e);o&&(r.metadata||(r.metadata={}),r.metadata.python={version:o}),await It(t,r);}async function De(t){await v.outputFile(k.join(t,".gitignore"),`.venv/
613
619
  __pycache__/
614
620
  *.pyc
615
621
  .env
616
622
  .rapidkit-workspace/
617
623
 
618
- `,"utf-8");}async function je(t){try{let{stdout:i}=await execa(t,["--version"],{timeout:3e3}),e=i.match(/Python (\d+\.\d+\.\d+)/);if(e)return e[1]}catch{}return null}async function ji(t,i){try{await promises.writeFile(w.join(t,".python-version"),`${i}
619
- `,"utf-8"),f.debug(`Created .python-version with ${i}`);}catch(e){f.warn(`Failed to create .python-version: ${e}`);}}function vt(){let t=w.join(z.homedir(),".local","bin"),e=(process.env.PATH||"").split(w.delimiter).filter(Boolean);e.includes(t)||(process.env.PATH=[t,...e].join(w.delimiter));}async function _t(t,i){vt(),t.start("Checking pipx installation");try{return await execa("pipx",["--version"]),t.succeed("pipx found"),{kind:"binary"}}catch{}let e=Rt();try{return await execa(e,["-m","pipx","--version"]),t.succeed("pipx found"),{kind:"python-module",pythonCmd:e}}catch{}if(i)throw new wt;let{installPipx:o}=await Jt.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!o)throw new wt;t.start("Installing pipx (user install)");try{try{await execa(e,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(e,["-m","pip","install","--user","--upgrade","pipx"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"");throw new M("Install pipx with python -m pip",r instanceof Error?r:new Error(a))}t.succeed("pipx installed"),vt();try{return await execa(e,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:e}}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"pipx not runnable after install");throw new M("Verify pipx after install",new Error(`${a}
624
+ `,"utf-8");}async function Ie(t){try{let{stdout:i}=await execa(t,["--version"],{timeout:3e3}),e=i.match(/Python (\d+\.\d+\.\d+)/);if(e)return e[1]}catch{}return null}async function Oi(t,i){try{await promises.writeFile(k.join(t,".python-version"),`${i}
625
+ `,"utf-8"),y.debug(`Created .python-version with ${i}`);}catch(e){y.warn(`Failed to create .python-version: ${e}`);}}function bt(){let t=k.join(Q.homedir(),".local","bin"),e=(process.env.PATH||"").split(k.delimiter).filter(Boolean);e.includes(t)||(process.env.PATH=[t,...e].join(k.delimiter));}async function St(t,i){bt(),t.start("Checking pipx installation");try{return await execa("pipx",["--version"]),t.succeed("pipx found"),{kind:"binary"}}catch{}let e=Et();try{return await execa(e,["-m","pipx","--version"]),t.succeed("pipx found"),{kind:"python-module",pythonCmd:e}}catch{}if(i)throw new kt;let{installPipx:o}=await qt.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!o)throw new kt;t.start("Installing pipx (user install)");try{try{await execa(e,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(e,["-m","pip","install","--user","--upgrade","pipx"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"");throw new M("Install pipx with python -m pip",r instanceof Error?r:new Error(a))}t.succeed("pipx installed"),bt();try{return await execa(e,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:e}}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"pipx not runnable after install");throw new M("Verify pipx after install",new Error(`${a}
620
626
 
621
- Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function ft(t,i){return t.kind==="binary"?execa("pipx",i):execa(t.pythonCmd,["-m","pipx",...i])}async function bi(t,i){vt(),t.start("Checking Poetry installation");try{await execa("poetry",["--version"]),t.succeed("Poetry found");return}catch{}if(i)throw new yt;let{installPoetry:e}=await Jt.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!e)throw new yt;let o=await _t(t,i);t.start("Installing Poetry with pipx");try{await ft(o,["install","poetry"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(a))try{await ft(o,["upgrade","poetry"]);}catch{}else throw new M("Install Poetry with pipx",r instanceof Error?r:new Error(a))}t.succeed("Poetry installed"),vt();try{await execa("poetry",["--version"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"Poetry not found on PATH");throw new M("Verify Poetry after pipx install",new Error(`${a}
627
+ Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function gt(t,i){return t.kind==="binary"?execa("pipx",i):execa(t.pythonCmd,["-m","pipx",...i])}async function Mi(t,i){bt(),t.start("Checking Poetry installation");try{await execa("poetry",["--version"]),t.succeed("Poetry found");return}catch{}if(i)throw new wt;let{installPoetry:e}=await qt.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!e)throw new wt;let o=await St(t,i);t.start("Installing Poetry with pipx");try{await gt(o,["install","poetry"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(a))try{await gt(o,["upgrade","poetry"]);}catch{}else throw new M("Install Poetry with pipx",r instanceof Error?r:new Error(a))}t.succeed("Poetry installed"),bt();try{await execa("poetry",["--version"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"Poetry not found on PATH");throw new M("Verify Poetry after pipx install",new Error(`${a}
622
628
 
623
- Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function $i(t){let i=t==="poetry";return `#!/usr/bin/env sh
629
+ Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function Ki(t){let i=t==="poetry";return `#!/usr/bin/env sh
624
630
  set -eu
625
631
 
626
632
  SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
@@ -639,7 +645,7 @@ echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
639
645
  ${i?`echo "- If you used Poetry: run 'poetry install' and retry, or activate the env." 1>&2
640
646
  `:""}echo "Tip: you can also run: ./.venv/bin/rapidkit --help" 1>&2
641
647
  exit 1
642
- `}function Pi(t){return `@echo off
648
+ `}function Li(t){return `@echo off
643
649
  setlocal
644
650
 
645
651
  set "SCRIPT_DIR=%~dp0"
@@ -658,14 +664,14 @@ if %ERRORLEVEL%==0 if exist "%SCRIPT_DIR%\\pyproject.toml" (
658
664
  `:""}echo RapidKit launcher could not find a local Python CLI. 1>&2
659
665
  echo Tip: run .venv\\Scripts\\rapidkit.exe --help 1>&2
660
666
  exit /b 1
661
- `}async function Re(t,i){await k.outputFile(w.join(t,"rapidkit"),$i(i),{encoding:"utf-8",mode:493}),await k.outputFile(w.join(t,"rapidkit.cmd"),Pi(i),"utf-8");}async function Ce(t,i){let{skipGit:e=false,testMode:o=false,demoMode:r=false,dryRun:n=false,yes:a=false,userConfig:s={},installMethod:c}=i,l=t||"rapidkit",p=w.resolve(process.cwd(),l);if(await k.pathExists(p))throw new bt(l);if(n){await Ci(p,l,r,s);return}if(r){await Ri(p,l,e);return}let d=a?{pythonVersion:s.pythonVersion||"3.10",installMethod:c||s.defaultInstallMethod||"poetry"}:await Jt.prompt([{type:"list",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:["3.10","3.11","3.12"],default:s.pythonVersion||"3.10"},{type:"list",name:"installMethod",message:"How would you like to install RapidKit?",choices:[{name:"\u{1F3AF} Poetry (Recommended - includes virtual env)",value:"poetry"},{name:"\u{1F4E6} pip with venv (Standard)",value:"venv"},{name:"\u{1F527} pipx (Global isolated install)",value:"pipx"}],default:s.defaultInstallMethod||"poetry"}]);f.step(1,3,"Setting up RapidKit environment");let u=kt("Creating directory").start();try{await k.ensureDir(p),u.succeed("Directory created"),u.start("Detecting Python version");let h=null,y=await _e(d.pythonVersion);if(y)h=await je(y),h?(f.info(`Detected Python ${h}`),u.succeed(`Python ${h} detected`)):u.warn("Could not detect exact Python version");else {let x=Rt();h=await je(x),h?u.succeed(`Python ${h} detected`):u.warn("Could not detect Python version, proceeding with defaults");}if(await $e(p,l,d.installMethod,h||void 0),h&&await ji(p,h),await Pe(p),d.installMethod==="poetry")try{await Ee(p,d.pythonVersion,u,o,s,a);}catch(x){let A=x?.details||x?.message||String(x);if(A.includes("pyenv")||A.includes("exit status 127")||A.includes("returned non-zero exit status 127")){u.warn("Poetry encountered Python discovery issues, trying venv method"),f.debug(`Poetry error (attempting venv fallback): ${A}`);try{await Bt(p,d.pythonVersion,u,o,s),d.installMethod="venv";}catch(O){throw O}}else throw x}else d.installMethod==="venv"?await Bt(p,d.pythonVersion,u,o,s):await Ie(p,u,o,s,a);if(await Re(p,d.installMethod),await Se(p,d.installMethod),u.succeed("RapidKit environment ready!"),!i.skipGit){u.start("Initializing git repository");try{await execa("git",["init"],{cwd:p}),await execa("git",["add","."],{cwd:p}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:p}),u.succeed("Git repository initialized");}catch{u.warn("Could not initialize git repository");}}try{let{registerWorkspace:x}=await Promise.resolve().then(()=>(Q(),q));await x(p,l);}catch{console.warn(m.gray("Note: Could not register workspace in shared registry"));}if(console.log(m.green(`
667
+ `}async function Ne(t,i){await v.outputFile(k.join(t,"rapidkit"),Ki(i),{encoding:"utf-8",mode:493}),await v.outputFile(k.join(t,"rapidkit.cmd"),Li(i),"utf-8");}async function Te(t,i){let{skipGit:e=false,testMode:o=false,demoMode:r=false,dryRun:n=false,yes:a=false,userConfig:s={},installMethod:c}=i,l=t||"rapidkit",p=k.resolve(process.cwd(),l);if(await v.pathExists(p))throw new Pt(l);if(n){await Wi(p,l,r,s);return}if(r){await Gi(p,l,e);return}let d=a?{pythonVersion:s.pythonVersion||"3.10",installMethod:c||s.defaultInstallMethod||"poetry"}:await qt.prompt([{type:"list",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:["3.10","3.11","3.12"],default:s.pythonVersion||"3.10"},{type:"list",name:"installMethod",message:"How would you like to install RapidKit?",choices:[{name:"\u{1F3AF} Poetry (Recommended - includes virtual env)",value:"poetry"},{name:"\u{1F4E6} pip with venv (Standard)",value:"venv"},{name:"\u{1F527} pipx (Global isolated install)",value:"pipx"}],default:s.defaultInstallMethod||"poetry"}]);y.step(1,3,"Setting up RapidKit environment");let u=xt("Creating directory").start();try{await v.ensureDir(p),u.succeed("Directory created"),u.start("Detecting Python version");let f=null,g=await Fe(d.pythonVersion);if(g)f=await Ie(g),f?(y.info(`Detected Python ${f}`),u.succeed(`Python ${f} detected`)):u.warn("Could not detect exact Python version");else {let h=Et();f=await Ie(h),f?u.succeed(`Python ${f} detected`):u.warn("Could not detect Python version, proceeding with defaults");}if(await Ae(p,l,d.installMethod,f||void 0),f&&await Oi(p,f),await De(p),d.installMethod==="poetry")try{await Oe(p,d.pythonVersion,u,o,s,a);}catch(h){let j=h?.details||h?.message||String(h);if(j.includes("pyenv")||j.includes("exit status 127")||j.includes("returned non-zero exit status 127")){u.warn("Poetry encountered Python discovery issues, trying venv method"),y.debug(`Poetry error (attempting venv fallback): ${j}`);try{await zt(p,d.pythonVersion,u,o,s),d.installMethod="venv";}catch(T){throw T}}else throw h}else d.installMethod==="venv"?await zt(p,d.pythonVersion,u,o,s):await Me(p,u,o,s,a);if(await Ne(p,d.installMethod),await Ke(p,d.installMethod),u.succeed("RapidKit environment ready!"),!i.skipGit){u.start("Initializing git repository");try{await execa("git",["init"],{cwd:p}),await execa("git",["add","."],{cwd:p}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:p}),u.succeed("Git repository initialized");}catch{u.warn("Could not initialize git repository");}}try{let{registerWorkspace:h}=await Promise.resolve().then(()=>(Z(),X));await h(p,l);}catch{console.warn(m.gray("Note: Could not register workspace in shared registry"));}if(console.log(m.green(`
662
668
  \u2728 RapidKit environment created successfully!
663
669
  `)),console.log(m.cyan("\u{1F4C2} Location:"),m.white(p)),console.log(m.cyan(`\u{1F680} Get started:
664
- `)),console.log(m.white(` cd ${l}`)),d.installMethod==="poetry"){let x="source $(poetry env info --path)/bin/activate";try{vt();let{stdout:A}=await execa("poetry",["--version"]),D=A.match(/Poetry.*?(\d+)\.(\d+)/);D&&(parseInt(D[1])>=2?x="source $(poetry env info --path)/bin/activate":x="poetry shell");}catch{}console.log(m.white(` ${x} # Or: poetry run rapidkit`)),console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev"));}else d.installMethod==="venv"?(console.log(m.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev"))):(console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev")));console.log(m.white(`
670
+ `)),console.log(m.white(` cd ${l}`)),d.installMethod==="poetry"){let h="source $(poetry env info --path)/bin/activate";try{bt();let{stdout:j}=await execa("poetry",["--version"]),N=j.match(/Poetry.*?(\d+)\.(\d+)/);N&&(parseInt(N[1])>=2?h="source $(poetry env info --path)/bin/activate":h="poetry shell");}catch{}console.log(m.white(` ${h} # Or: poetry run rapidkit`)),console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev"));}else d.installMethod==="venv"?(console.log(m.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev"))):(console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev")));console.log(m.white(`
665
671
  \u{1F4A1} For more information, check the README.md file.`)),console.log(m.cyan(`
666
672
  \u{1F4DA} RapidKit commands:`)),console.log(m.white(" rapidkit create - Create a new project (interactive)")),console.log(m.white(" rapidkit dev - Run development server")),console.log(m.white(" rapidkit add module <name> - Add a module (e.g., settings)")),console.log(m.white(" rapidkit list - List available kits")),console.log(m.white(" rapidkit modules - List available modules")),console.log(m.white(` rapidkit --help - Show all commands
667
- `));}catch(h){u.fail("Failed to create RapidKit environment"),console.error(m.red(`
668
- \u274C Error:`),h);try{await k.remove(p);}catch{}throw h}}async function _e(t){let i=[];try{let{stdout:e}=await execa("pyenv",["root"]),o=e.trim();i.push(w.join(o,"versions",`${t}.*`,"bin","python"));let[r,n]=t.split(".");i.push(w.join(o,"versions",`${r}.${n}.*`,"bin","python"));}catch{}i.push(`python${t}`,`python3.${t.split(".")[1]}`,"python3","python"),i.push(`/usr/bin/python${t}`,"/usr/bin/python3",`/usr/local/bin/python${t}`,"/usr/local/bin/python3");for(let e of i)try{let o=e;if(e.includes("*")){if(o=(await execa("sh",["-c",`ls -d ${e} 2>/dev/null | head -1`])).stdout.trim(),!o)continue;o=w.join(o.split("/").slice(0,-1).join("/"),"../bin/python");}let{stdout:r}=await execa(o,["--version"],{timeout:2e3}),n=r.match(/Python (\d+\.\d+)/)?.[1];if(n&&parseFloat(n)>=parseFloat(t))return await execa(o,["-c","import sys; sys.exit(0)"],{timeout:2e3}),o}catch{continue}return null}async function Ee(t,i,e,o,r,n=false){await bi(e,n),e.start("Finding Python interpreter");let a=await _e(i);a?(f.debug(`Found working Python: ${a}`),e.succeed("Python found")):e.warn("Could not verify Python path, proceeding with default"),e.start("Initializing Poetry project"),await execa("poetry",["init","--no-interaction","--python",`^${i}`],{cwd:t}),e.succeed("Poetry project initialized");let s=w.join(t,"pyproject.toml"),l=await promises.readFile(s,"utf-8");l.includes("[tool.poetry]")?l=l.replace("[tool.poetry]",`[tool.poetry]
673
+ `));}catch(f){u.fail("Failed to create RapidKit environment"),console.error(m.red(`
674
+ \u274C Error:`),f);try{await v.remove(p);}catch{}throw f}}async function Fe(t){let i=[];try{let{stdout:e}=await execa("pyenv",["root"]),o=e.trim();i.push(k.join(o,"versions",`${t}.*`,"bin","python"));let[r,n]=t.split(".");i.push(k.join(o,"versions",`${r}.${n}.*`,"bin","python"));}catch{}i.push(`python${t}`,`python3.${t.split(".")[1]}`,"python3","python"),i.push(`/usr/bin/python${t}`,"/usr/bin/python3",`/usr/local/bin/python${t}`,"/usr/local/bin/python3");for(let e of i)try{let o=e;if(e.includes("*")){if(o=(await execa("sh",["-c",`ls -d ${e} 2>/dev/null | head -1`])).stdout.trim(),!o)continue;o=k.join(o.split("/").slice(0,-1).join("/"),"../bin/python");}let{stdout:r}=await execa(o,["--version"],{timeout:2e3}),n=r.match(/Python (\d+\.\d+)/)?.[1];if(n&&parseFloat(n)>=parseFloat(t))return await execa(o,["-c","import sys; sys.exit(0)"],{timeout:2e3}),o}catch{continue}return null}async function Oe(t,i,e,o,r,n=false){await Mi(e,n),e.start("Finding Python interpreter");let a=await Fe(i);a?(y.debug(`Found working Python: ${a}`),e.succeed("Python found")):e.warn("Could not verify Python path, proceeding with default"),e.start("Initializing Poetry project"),await execa("poetry",["init","--no-interaction","--python",`^${i}`],{cwd:t}),e.succeed("Poetry project initialized");let s=k.join(t,"pyproject.toml"),l=await promises.readFile(s,"utf-8");l.includes("[tool.poetry]")?l=l.replace("[tool.poetry]",`[tool.poetry]
669
675
  package-mode = false`):l.includes("[project]")&&(l.includes("[build-system]")?l=l.replace("[build-system]",`
670
676
  [tool.poetry]
671
677
  package-mode = false
@@ -674,26 +680,26 @@ package-mode = false
674
680
 
675
681
  [tool.poetry]
676
682
  package-mode = false
677
- `),await promises.writeFile(s,l,"utf-8"),e.start("Configuring Poetry");try{if(await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:t}),a)try{await execa("poetry",["env","use",a],{cwd:t}),f.debug(`Poetry configured to use: ${a}`);}catch(p){f.debug(`Could not set Poetry env to ${a}: ${p}`);}e.succeed("Poetry configured");}catch{e.warn("Could not configure Poetry virtualenvs.in-project");}e.start("Creating virtualenv");try{await execa("poetry",["install","--no-root"],{cwd:t,timeout:3e4}),e.succeed("Virtualenv created");}catch(p){f.debug(`Failed to create virtualenv: ${p}`),e.warn("Could not create virtualenv, proceeding with add command");}if(e.start("Installing RapidKit"),o){let p=jt(r||{});if(!p)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));f.debug(`Installing from local path: ${p}`),e.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",p],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let p=false,d=null;for(let u=1;u<=3;u++)try{await execa("poetry",["add","rapidkit-core"],{cwd:t,timeout:6e4*u}),p=!0;break}catch(h){d=h,f.debug(`Poetry add attempt ${u} failed: ${h}`),u<3&&(e.text=`Retrying installation (attempt ${u+1}/3)`,await new Promise(y=>setTimeout(y,2e3)));}if(!p){let u=d?.stderr||d?.message||"Unknown error";throw f.debug(`All Poetry install attempts failed. Last error: ${u}`),u.includes("Could not find")||u.includes("No matching distribution")?new pt:new M("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
683
+ `),await promises.writeFile(s,l,"utf-8"),e.start("Configuring Poetry");try{if(await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:t}),a)try{await execa("poetry",["env","use",a],{cwd:t}),y.debug(`Poetry configured to use: ${a}`);}catch(p){y.debug(`Could not set Poetry env to ${a}: ${p}`);}e.succeed("Poetry configured");}catch{e.warn("Could not configure Poetry virtualenvs.in-project");}e.start("Creating virtualenv");try{await execa("poetry",["install","--no-root"],{cwd:t,timeout:3e4}),e.succeed("Virtualenv created");}catch(p){y.debug(`Failed to create virtualenv: ${p}`),e.warn("Could not create virtualenv, proceeding with add command");}if(e.start("Installing RapidKit"),o){let p=$t(r||{});if(!p)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));y.debug(`Installing from local path: ${p}`),e.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",p],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let p=false,d=null;for(let u=1;u<=3;u++)try{await execa("poetry",["add","rapidkit-core"],{cwd:t,timeout:6e4*u}),p=!0;break}catch(f){d=f,y.debug(`Poetry add attempt ${u} failed: ${f}`),u<3&&(e.text=`Retrying installation (attempt ${u+1}/3)`,await new Promise(g=>setTimeout(g,2e3)));}if(!p){let u=d?.stderr||d?.message||"Unknown error";throw y.debug(`All Poetry install attempts failed. Last error: ${u}`),u.includes("Could not find")||u.includes("No matching distribution")?new dt:new M("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
678
684
  Error: ${u}
679
685
 
680
686
  Possible solutions:
681
687
  1. Check your internet connection
682
- 2. Try installing manually: cd ${w.basename(t)} && poetry add rapidkit-core
683
- 3. Use venv method instead: npx rapidkit ${w.basename(t)} --install-method=venv`))}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:p}=await Promise.resolve().then(()=>(Pt(),Lt));if(!await p()&&!o){e.start("Installing RapidKit globally with pipx for CLI access");let u=await _t(e,n);try{await ft(u,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(h){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),f.debug(`pipx install failed: ${h}`);}}}catch(p){f.debug(`Global install check skipped: ${p}`);}}async function Bt(t,i,e,o,r,n=false){e.start(`Checking Python ${i}`);let a=Rt();try{let{stdout:c}=await execa(a,["--version"]),l=c.match(/Python (\d+\.\d+)/)?.[1];if(l&&parseFloat(l)<parseFloat(i))throw new lt(i,l);e.succeed(`Python ${l} found`);}catch(c){throw c instanceof lt?c:new lt(i)}e.start("Creating virtual environment");try{await execa(a,["-m","venv",".venv"],{cwd:t}),e.succeed("Virtual environment created");}catch(c){if(e.fail("Failed to create virtual environment"),(p=>typeof p=="object"&&p!==null&&"stdout"in p&&typeof p.stdout=="string")(c)&&c.stdout.includes("ensurepip is not")){let p=c.stdout.match(/apt install (python[\d.]+-venv)/),d=p?p[1]:"python3-venv";throw new M("Python venv module not available",new Error(`Virtual environment creation failed.
688
+ 2. Try installing manually: cd ${k.basename(t)} && poetry add rapidkit-core
689
+ 3. Use venv method instead: npx rapidkit ${k.basename(t)} --install-method=venv`))}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:p}=await Promise.resolve().then(()=>(Ct(),Bt));if(!await p()&&!o){e.start("Installing RapidKit globally with pipx for CLI access");let u=await St(e,n);try{await gt(u,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(f){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),y.debug(`pipx install failed: ${f}`);}}}catch(p){y.debug(`Global install check skipped: ${p}`);}}async function zt(t,i,e,o,r,n=false){e.start(`Checking Python ${i}`);let a=Et();try{let{stdout:c}=await execa(a,["--version"]),l=c.match(/Python (\d+\.\d+)/)?.[1];if(l&&parseFloat(l)<parseFloat(i))throw new pt(i,l);e.succeed(`Python ${l} found`);}catch(c){throw c instanceof pt?c:new pt(i)}e.start("Creating virtual environment");try{await execa(a,["-m","venv",".venv"],{cwd:t}),e.succeed("Virtual environment created");}catch(c){if(e.fail("Failed to create virtual environment"),(p=>typeof p=="object"&&p!==null&&"stdout"in p&&typeof p.stdout=="string")(c)&&c.stdout.includes("ensurepip is not")){let p=c.stdout.match(/apt install (python[\d.]+-venv)/),d=p?p[1]:"python3-venv";throw new M("Python venv module not available",new Error(`Virtual environment creation failed.
684
690
 
685
691
  On Debian/Ubuntu systems, install the venv package:
686
692
  sudo apt install ${d}
687
693
 
688
694
  Or use Poetry instead (recommended):
689
- npx rapidkit ${w.basename(t)} --yes`))}throw new M("Virtual environment creation",c instanceof Error?c:new Error(String(c)))}e.start("Installing RapidKit");let s=w.join(t,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python");if(await execa(s,["-m","pip","install","--upgrade","pip"],{cwd:t}),o){let c=jt(r||{});if(!c)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));f.debug(`Installing from local path: ${c}`),e.text="Installing RapidKit from local path (test mode)",await execa(s,["-m","pip","install","-e",c],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let c=false,l=null;for(let p=1;p<=3;p++)try{await execa(s,["-m","pip","install","rapidkit-core"],{cwd:t,timeout:6e4*p}),c=!0;break}catch(d){l=d,f.debug(`pip install attempt ${p} failed: ${d}`),p<3&&(e.text=`Retrying installation (attempt ${p+1}/3)`,await new Promise(u=>setTimeout(u,2e3)));}if(!c){let p=l?.stderr||l?.message||"Unknown error";throw f.debug(`All pip install attempts failed. Last error: ${p}`),p.includes("Could not find")||p.includes("No matching distribution")?new pt:new M("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
695
+ npx rapidkit ${k.basename(t)} --yes`))}throw new M("Virtual environment creation",c instanceof Error?c:new Error(String(c)))}e.start("Installing RapidKit");let s=k.join(t,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python");if(await execa(s,["-m","pip","install","--upgrade","pip"],{cwd:t}),o){let c=$t(r||{});if(!c)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));y.debug(`Installing from local path: ${c}`),e.text="Installing RapidKit from local path (test mode)",await execa(s,["-m","pip","install","-e",c],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let c=false,l=null;for(let p=1;p<=3;p++)try{await execa(s,["-m","pip","install","rapidkit-core"],{cwd:t,timeout:6e4*p}),c=!0;break}catch(d){l=d,y.debug(`pip install attempt ${p} failed: ${d}`),p<3&&(e.text=`Retrying installation (attempt ${p+1}/3)`,await new Promise(u=>setTimeout(u,2e3)));}if(!c){let p=l?.stderr||l?.message||"Unknown error";throw y.debug(`All pip install attempts failed. Last error: ${p}`),p.includes("Could not find")||p.includes("No matching distribution")?new dt:new M("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
690
696
  Error: ${p}
691
697
 
692
698
  Possible solutions:
693
699
  1. Check your internet connection
694
- 2. Try installing manually: cd ${w.basename(t)} && .venv/bin/python -m pip install rapidkit-core
695
- 3. Use Poetry instead: npx rapidkit ${w.basename(t)} --install-method=poetry`))}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await Promise.resolve().then(()=>(Pt(),Lt));if(!await c()&&!o){e.start("Installing RapidKit globally with pipx for CLI access");let p=await _t(e,n);try{await ft(p,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(d){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),f.debug(`pipx install failed: ${d}`);}}}catch(c){f.debug(`Global install check skipped: ${c}`);}}async function Ie(t,i,e,o,r=false){let n=await _t(i,r);if(i.start("Installing RapidKit globally with pipx"),e){let a=jt(o||{});if(!a)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));f.debug(`Installing from local path: ${a}`),i.text="Installing RapidKit from local path (test mode)",await ft(n,["install","-e",a]);}else {i.text="Installing RapidKit from PyPI";try{await ft(n,["install","rapidkit-core"]);}catch{throw new pt}}i.succeed("RapidKit installed globally"),await k.outputFile(w.join(t,".rapidkit-global"),`RapidKit installed globally with pipx
696
- `,"utf-8");}async function rt(t,i){let{skipGit:e=false,testMode:o=false,userConfig:r={},yes:n=false,installMethod:a,pythonVersion:s="3.10"}=i||{},c=a||r.defaultInstallMethod||"poetry";await $e(t,w.basename(t),c),await Pe(t);let l=kt("Registering workspace").start();try{c==="poetry"?await Ee(t,s,l,o,r,n):c==="venv"?await Bt(t,s,l,o,r):await Ie(t,l,o,r,n),await Re(t,c),await Se(t,c),l.succeed("Workspace registered");try{let{registerWorkspace:p}=await Promise.resolve().then(()=>(Q(),q));await p(t,w.basename(t));}catch{}if(!e){l.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:t}),l.succeed("Git repository initialized");}catch{l.warn("Could not initialize git repository");}}}catch(p){throw l.fail("Failed to register workspace"),p}}async function Se(t,i){let r=`# RapidKit Workspace
700
+ 2. Try installing manually: cd ${k.basename(t)} && .venv/bin/python -m pip install rapidkit-core
701
+ 3. Use Poetry instead: npx rapidkit ${k.basename(t)} --install-method=poetry`))}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await Promise.resolve().then(()=>(Ct(),Bt));if(!await c()&&!o){e.start("Installing RapidKit globally with pipx for CLI access");let p=await St(e,n);try{await gt(p,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(d){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),y.debug(`pipx install failed: ${d}`);}}}catch(c){y.debug(`Global install check skipped: ${c}`);}}async function Me(t,i,e,o,r=false){let n=await St(i,r);if(i.start("Installing RapidKit globally with pipx"),e){let a=$t(o||{});if(!a)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));y.debug(`Installing from local path: ${a}`),i.text="Installing RapidKit from local path (test mode)",await gt(n,["install","-e",a]);}else {i.text="Installing RapidKit from PyPI";try{await gt(n,["install","rapidkit-core"]);}catch{throw new dt}}i.succeed("RapidKit installed globally"),await v.outputFile(k.join(t,".rapidkit-global"),`RapidKit installed globally with pipx
702
+ `,"utf-8");}async function st(t,i){let{skipGit:e=false,testMode:o=false,userConfig:r={},yes:n=false,installMethod:a,pythonVersion:s="3.10"}=i||{},c=a||r.defaultInstallMethod||"poetry";await Ae(t,k.basename(t),c),await De(t);let l=xt("Registering workspace").start();try{c==="poetry"?await Oe(t,s,l,o,r,n):c==="venv"?await zt(t,s,l,o,r):await Me(t,l,o,r,n),await Ne(t,c),await Ke(t,c),l.succeed("Workspace registered");try{let{registerWorkspace:p}=await Promise.resolve().then(()=>(Z(),X));await p(t,k.basename(t));}catch{}if(!e){l.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:t}),l.succeed("Git repository initialized");}catch{l.warn("Could not initialize git repository");}}}catch(p){throw l.fail("Failed to register workspace"),p}}async function Ke(t,i){let r=`# RapidKit Workspace
697
703
 
698
704
  This directory contains a RapidKit development environment.
699
705
 
@@ -804,7 +810,7 @@ If you encounter issues:
804
810
  2. Check RapidKit installation: \`rapidkit --version\`
805
811
  3. Run diagnostics: \`rapidkit doctor\`
806
812
  4. Visit RapidKit documentation or GitHub issues
807
- `;await promises.writeFile(w.join(t,"README.md"),r,"utf-8");}async function Ri(t,i,e){let o=kt("Creating demo workspace").start();try{await k.ensureDir(t),o.succeed("Directory created"),o.start("Setting up demo kit generator");let r=JSON.stringify({name:`${i}-workspace`,version:"1.0.0",private:!0,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(w.join(t,"package.json"),r,"utf-8"),await promises.writeFile(w.join(t,"generate-demo.js"),`#!/usr/bin/env node
813
+ `;await promises.writeFile(k.join(t,"README.md"),r,"utf-8");}async function Gi(t,i,e){let o=xt("Creating demo workspace").start();try{await v.ensureDir(t),o.succeed("Directory created"),o.start("Setting up demo kit generator");let r=JSON.stringify({name:`${i}-workspace`,version:"1.0.0",private:!0,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(k.join(t,"package.json"),r,"utf-8"),await promises.writeFile(k.join(t,"generate-demo.js"),`#!/usr/bin/env node
808
814
  /**
809
815
  * Demo Kit Generator - Create FastAPI demo projects
810
816
  *
@@ -1200,7 +1206,7 @@ venv/
1200
1206
  }
1201
1207
 
1202
1208
  main().catch(console.error);
1203
- `,"utf-8");try{await execa("chmod",["+x",w.join(t,"generate-demo.js")]);}catch{}let a=`# RapidKit Demo Workspace
1209
+ `,"utf-8");try{await execa("chmod",["+x",k.join(t,"generate-demo.js")]);}catch{}let a=`# RapidKit Demo Workspace
1204
1210
 
1205
1211
  Welcome to your RapidKit demo workspace! This environment lets you generate FastAPI demo projects using bundled RapidKit templates, without needing to install Python RapidKit.
1206
1212
 
@@ -1287,7 +1293,7 @@ ${i}/
1287
1293
  ---
1288
1294
 
1289
1295
  **Generated with RapidKit** | [GitHub](https://github.com/getrapidkit/rapidkit-npm)
1290
- `;if(await promises.writeFile(w.join(t,"README.md"),a,"utf-8"),o.succeed("Demo workspace setup complete"),!e){o.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await k.outputFile(w.join(t,".gitignore"),`# Dependencies
1296
+ `;if(await promises.writeFile(k.join(t,"README.md"),a,"utf-8"),o.succeed("Demo workspace setup complete"),!e){o.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await v.outputFile(k.join(t,".gitignore"),`# Dependencies
1291
1297
  node_modules/
1292
1298
 
1293
1299
  # Generated projects
@@ -1303,7 +1309,7 @@ __pycache__/
1303
1309
  `,"utf-8"),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: Demo workspace"],{cwd:t}),o.succeed("Git repository initialized");}catch{o.warn("Could not initialize git repository");}}console.log(m.green(`
1304
1310
  \u2728 Demo workspace created successfully!
1305
1311
  `)),console.log(m.cyan("\u{1F4C2} Location:"),m.white(t)),console.log(m.cyan(`\u{1F680} Get started:
1306
- `)),console.log(m.white(` cd ${i}`)),console.log(m.white(" node generate-demo.js my-api")),console.log(m.white(" cd my-api")),console.log(m.white(" rapidkit init")),console.log(m.white(" rapidkit dev")),console.log(),console.log(m.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(m.cyan(" pipx install rapidkit")),console.log();}catch(r){throw o.fail("Failed to create demo workspace"),r}}async function Ci(t,i,e,o){console.log(m.cyan(`
1312
+ `)),console.log(m.white(` cd ${i}`)),console.log(m.white(" node generate-demo.js my-api")),console.log(m.white(" cd my-api")),console.log(m.white(" rapidkit init")),console.log(m.white(" rapidkit dev")),console.log(),console.log(m.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(m.cyan(" pipx install rapidkit")),console.log();}catch(r){throw o.fail("Failed to create demo workspace"),r}}async function Wi(t,i,e,o){console.log(m.cyan(`
1307
1313
  \u{1F50D} Dry-run mode - showing what would be created:
1308
1314
  `)),console.log(m.white("\u{1F4C2} Project path:"),t),console.log(m.white("\u{1F4E6} Project type:"),e?"Demo workspace":"Full RapidKit environment"),e?(console.log(m.white(`
1309
1315
  \u{1F4DD} Files to create:`)),console.log(m.gray(" - package.json")),console.log(m.gray(" - generate-demo.js (project generator)")),console.log(m.gray(" - README.md")),console.log(m.gray(" - .gitignore")),console.log(m.white(`
@@ -1312,7 +1318,7 @@ __pycache__/
1312
1318
  \u{1F4DD} Files to create:`)),console.log(m.gray(" - pyproject.toml (Poetry) or .venv/ (venv)")),console.log(m.gray(" - README.md")),console.log(m.gray(" - .gitignore")),console.log(m.white(`
1313
1319
  \u{1F3AF} Next steps after creation:`)),console.log(m.gray(" 1. Install RapidKit Python package")),console.log(m.gray(" 2. Create projects with rapidkit CLI")),console.log(m.gray(" 3. Add modules and customize"))),console.log(m.white(`
1314
1320
  \u{1F4A1} To proceed with actual creation, run without --dry-run flag
1315
- `));}R();gt();var Si=fileURLToPath(import.meta.url),Ai=w.dirname(Si);function Ni(t=32){let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Ii.randomBytes(t),o="";for(let r=0;r<t;r++)o+=i[e[r]%i.length];return o}async function Ae(t,i){let o=(i.template||"fastapi")==="fastapi",r=o?"FastAPI":"NestJS",n=kt(`Generating ${r} project...`).start();try{let a=w.resolve(Ai,".."),s=o?"fastapi-standard":"nestjs-standard",c=w.join(a,"templates","kits",s),l=_i.configure(c,{autoescape:!1,trimBlocks:!0,lstripBlocks:!0});l.addFilter("generate_secret",function(y,x=32){return Ni(x)});let p={project_name:i.project_name,author:i.author||"RapidKit User",description:i.description||(o?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:i.app_version||"0.1.0",license:i.license||"MIT",package_manager:i.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:H()},d;o?d=["src/main.py.j2","src/__init__.py.j2","src/cli.py.j2","src/routing/__init__.py.j2","src/routing/health.py.j2","src/modules/__init__.py.j2","tests/__init__.py.j2","README.md.j2","pyproject.toml.j2","Makefile.j2",".rapidkit/__init__.py.j2",".rapidkit/project.json.j2",".rapidkit/cli.py.j2",".rapidkit/rapidkit.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"]:d=["src/main.ts.j2","src/app.module.ts.j2","src/app.controller.ts.j2","src/app.service.ts.j2","src/config/configuration.ts.j2","src/config/validation.ts.j2","src/config/index.ts.j2","src/modules/index.ts.j2","src/examples/examples.module.ts.j2","src/examples/examples.controller.ts.j2","src/examples/examples.service.ts.j2","src/examples/dto/create-note.dto.ts.j2","test/app.controller.spec.ts.j2","test/examples.controller.spec.ts.j2","test/app.e2e-spec.ts.j2","test/jest-e2e.json.j2","package.json.j2","tsconfig.json.j2","tsconfig.build.json.j2","nest-cli.json.j2","jest.config.ts.j2","eslint.config.cjs.j2",".env.example.j2","docker-compose.yml.j2","Dockerfile.j2","README.md.j2",".rapidkit/project.json.j2",".rapidkit/rapidkit.j2",".rapidkit/rapidkit.cmd.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"];for(let y of d){let x=w.join(c,y);try{await promises.access(x);}catch{continue}let A=await promises.readFile(x,"utf-8"),D=l.renderString(A,p),O=y.replace(/\.j2$/,""),et=w.join(t,O);await promises.mkdir(w.dirname(et),{recursive:!0}),await promises.writeFile(et,D),(O.endsWith(".rapidkit/rapidkit")||O.endsWith(".rapidkit/cli.py")||O.endsWith(".rapidkit/activate")||O==="rapidkit")&&await promises.chmod(et,493);}if(o){let y=w.join(c,".rapidkit","context.json"),x=w.join(t,".rapidkit","context.json");try{await promises.mkdir(w.join(t,".rapidkit"),{recursive:!0}),await promises.copyFile(y,x);}catch{await promises.mkdir(w.join(t,".rapidkit"),{recursive:!0});let D=i.engine||"pip";await promises.writeFile(x,JSON.stringify({engine:D,created_by:"rapidkit-npm-fallback"},null,2));}}let u=o?`# Python
1321
+ `));}E();ht();var Hi=fileURLToPath(import.meta.url),Ji=k.dirname(Hi);function Yi(t=32){let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=mi.randomBytes(t),o="";for(let r=0;r<t;r++)o+=i[e[r]%i.length];return o}async function Le(t,i){let o=(i.template||"fastapi")==="fastapi",r=o?"FastAPI":"NestJS",n=xt(`Generating ${r} project...`).start();try{let a=k.resolve(Ji,".."),s=o?"fastapi-standard":"nestjs-standard",c=k.join(a,"templates","kits",s),l=Vi.configure(c,{autoescape:!1,trimBlocks:!0,lstripBlocks:!0});l.addFilter("generate_secret",function(g,h=32){return Yi(h)});let p={project_name:i.project_name,author:i.author||"RapidKit User",description:i.description||(o?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:i.app_version||"0.1.0",license:i.license||"MIT",package_manager:i.package_manager||"npm",node_version:i.node_version||"20.0.0",database_type:i.database_type||"postgresql",include_caching:i.include_caching||!1,created_at:new Date().toISOString(),rapidkit_version:H()},d;o?d=["src/main.py.j2","src/__init__.py.j2","src/cli.py.j2","src/routing/__init__.py.j2","src/routing/health.py.j2","src/modules/__init__.py.j2","tests/__init__.py.j2","README.md.j2","pyproject.toml.j2","Makefile.j2",".rapidkit/__init__.py.j2",".rapidkit/project.json.j2",".rapidkit/cli.py.j2",".rapidkit/rapidkit.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"]:d=["src/main.ts.j2","src/app.module.ts.j2","src/app.controller.ts.j2","src/app.service.ts.j2","src/config/configuration.ts.j2","src/config/validation.ts.j2","src/config/index.ts.j2","src/modules/index.ts.j2","src/examples/examples.module.ts.j2","src/examples/examples.controller.ts.j2","src/examples/examples.service.ts.j2","src/examples/dto/create-note.dto.ts.j2","test/app.controller.spec.ts.j2","test/examples.controller.spec.ts.j2","test/app.e2e-spec.ts.j2","test/jest-e2e.json.j2","package.json.j2","tsconfig.json.j2","tsconfig.build.json.j2","nest-cli.json.j2","jest.config.ts.j2","eslint.config.cjs.j2",".env.example.j2","docker-compose.yml.j2","Dockerfile.j2","README.md.j2",".rapidkit/project.json.j2",".rapidkit/rapidkit.j2",".rapidkit/rapidkit.cmd.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"];for(let g of d){let h=k.join(c,g);try{await promises.access(h);}catch{continue}let j=await promises.readFile(h,"utf-8"),N;try{N=l.renderString(j,p);}catch(Ft){throw console.error(`Failed to render template: ${g}`),Ft}let T=g.replace(/\.j2$/,""),V=k.join(t,T);await promises.mkdir(k.dirname(V),{recursive:!0}),await promises.writeFile(V,N),(T.endsWith(".rapidkit/rapidkit")||T.endsWith(".rapidkit/cli.py")||T.endsWith(".rapidkit/activate")||T==="rapidkit")&&await promises.chmod(V,493);}if(o){let g=k.join(c,".rapidkit","context.json"),h=k.join(t,".rapidkit","context.json");try{await promises.mkdir(k.join(t,".rapidkit"),{recursive:!0}),await promises.copyFile(g,h);}catch{await promises.mkdir(k.join(t,".rapidkit"),{recursive:!0});let N=i.engine||"pip";await promises.writeFile(h,JSON.stringify({engine:N,created_by:"rapidkit-npm-fallback"},null,2));}}let u=o?`# Python
1316
1322
  __pycache__/
1317
1323
  *.py[cod]
1318
1324
  *$py.class
@@ -1380,7 +1386,7 @@ Thumbs.db
1380
1386
 
1381
1387
  # Coverage
1382
1388
  coverage/
1383
- `;if(await promises.writeFile(w.join(t,".gitignore"),u),n.succeed(`${r} project generated!`),!i.skipGit){let y=kt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m",`Initial commit: ${r} project via RapidKit`],{cwd:t}),y.succeed("Git repository initialized");}catch{y.warn("Could not initialize git repository");}}if(!o&&!i.skipInstall){let y=i.package_manager||"npm",x=kt(`Installing dependencies with ${y}...`).start();try{await execa(y,y==="yarn"?["install"]:y==="pnpm"?["install"]:["install"],{cwd:t}),x.succeed("Dependencies installed");}catch{x.warn(`Could not install dependencies. Run '${y} install' manually.`);}}let h=w.basename(t);console.log(`
1389
+ `;if(await promises.writeFile(k.join(t,".gitignore"),u),n.succeed(`${r} project generated!`),!i.skipGit){let g=xt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m",`Initial commit: ${r} project via RapidKit`],{cwd:t}),g.succeed("Git repository initialized");}catch{g.warn("Could not initialize git repository");}}if(!o&&!i.skipInstall){let g=i.package_manager||"npm",h=xt(`Installing dependencies with ${g}...`).start();try{await execa(g,g==="yarn"?["install"]:g==="pnpm"?["install"]:["install"],{cwd:t}),h.succeed("Dependencies installed");}catch{h.warn(`Could not install dependencies. Run '${g} install' manually.`);}}let f=k.basename(t);console.log(`
1384
1390
  ${m.yellow("\u26A0\uFE0F Limited offline mode:")} This project was created using basic templates.
1385
1391
  ${m.gray("For full kit features, install Python 3.10+ and rapidkit-core:")}
1386
1392
  ${m.cyan(" sudo apt install python3 python3-pip python3-venv")}
@@ -1401,7 +1407,7 @@ ${t}/
1401
1407
  \u2514\u2500\u2500 README.md
1402
1408
 
1403
1409
  ${m.bold("\u{1F680} Get started:")}
1404
- ${m.cyan(`cd ${h}`)}
1410
+ ${m.cyan(`cd ${f}`)}
1405
1411
  ${m.cyan("npx rapidkit init")} ${m.gray("# Install dependencies")}
1406
1412
  ${m.cyan("npx rapidkit dev")} ${m.gray("# Start dev server")}
1407
1413
 
@@ -1431,7 +1437,7 @@ ${t}/
1431
1437
  \u2514\u2500\u2500 README.md
1432
1438
 
1433
1439
  ${m.bold("\u{1F680} Get started:")}
1434
- ${m.cyan(`cd ${h}`)}
1440
+ ${m.cyan(`cd ${f}`)}
1435
1441
  ${m.cyan("npx rapidkit init")} ${m.gray("# Install dependencies")}
1436
1442
  ${m.cyan("cp .env.example .env")}
1437
1443
  ${m.cyan("npx rapidkit dev")} ${m.gray("# Start dev server")}
@@ -1452,50 +1458,50 @@ ${m.bold("\u{1F310} API endpoints:")}
1452
1458
 
1453
1459
  ${m.gray("Alternative: npm run start:dev, ./rapidkit dev")}
1454
1460
  ${m.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
1455
- `);}catch(a){throw n.fail(`Failed to generate ${r} project`),a}}R();ct();async function De(){let t=process.platform==="win32"?["python","python3"]:["python3","python"];for(let i of t)try{let{stdout:e}=await execa(i,["--version"],{timeout:3e3}),o=e.match(/Python (\d+\.\d+\.\d+)/);if(o){let r=o[1],[n,a]=r.split(".").map(Number);return n<3||n===3&&a<10?{status:"warn",message:`Python ${r} (requires 3.10+)`,details:`${i} found but version is below minimum requirement`}:{status:"ok",message:`Python ${r}`,details:`Using ${i}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function Te(){try{let{stdout:t}=await execa("poetry",["--version"],{timeout:3e3}),i=t.match(/Poetry .*version ([\d.]+)/);return i?{status:"ok",message:`Poetry ${i[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function Fe(){try{let{stdout:t}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${t.trim()}`,details:"Available for global tool installation"}}catch{return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function Oe(){let t=process.platform==="win32"?["python","python3"]:["python3","python"],i=process.env.HOME||process.env.USERPROFILE||"",e=[w.join(i,".local","bin","rapidkit"),w.join(i,"AppData","Roaming","Python","Scripts","rapidkit.exe"),w.join(i,".pyenv","shims","rapidkit"),"/usr/local/bin/rapidkit","/usr/bin/rapidkit"];try{let{stdout:o,exitCode:r}=await execa("rapidkit",["--version"],{timeout:3e3,reject:!1});if(r===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let n=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(n)return {status:"ok",message:`RapidKit Core ${n[1]}`,details:"Available via PATH"}}}catch{}for(let o of e)try{if(await k__default.pathExists(o)){let{stdout:r,exitCode:n}=await execa(o,["--version"],{timeout:3e3,reject:!1});if(n===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let a=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(a)return {status:"ok",message:`RapidKit Core ${a[1]}`,details:`Installed at ${o}`}}}}catch{continue}try{let o=w.join(process.cwd(),".venv","bin","rapidkit");if(await k__default.pathExists(o)){let{stdout:r,exitCode:n}=await execa(o,["--version"],{timeout:3e3,reject:!1});if(n===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let a=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(a)return {status:"ok",message:`RapidKit Core ${a[1]}`,details:"Installed in workspace virtualenv"}}}}catch{}try{let{stdout:o,exitCode:r}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:!1});if(r===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let n=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(n)return {status:"ok",message:`RapidKit Core ${n[1]}`,details:"Available via Poetry"}}}catch{}for(let o of t)try{let{stdout:r,exitCode:n}=await execa(o,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:!1});if(n===0&&r&&!r.includes("Traceback")&&!r.includes("ModuleNotFoundError")){let a=r.trim();if(a)return {status:"ok",message:`RapidKit Core ${a}`,details:`Available in ${o} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function qt(t,i){let e=w.join(t,"Dockerfile");i.hasDocker=await k__default.pathExists(e);let o=w.join(t,"tests"),r=w.join(t,"test");if(i.hasTests=await k__default.pathExists(o)||await k__default.pathExists(r),i.framework==="NestJS"){let n=w.join(t,".eslintrc.js"),a=w.join(t,".eslintrc.json");i.hasCodeQuality=await k__default.pathExists(n)||await k__default.pathExists(a);}else if(i.framework==="FastAPI"){let n=w.join(t,"ruff.toml"),a=w.join(t,"pyproject.toml");if(await k__default.pathExists(a))try{let s=await k__default.readFile(a,"utf8");i.hasCodeQuality=s.includes("[tool.ruff]")||await k__default.pathExists(n);}catch{i.hasCodeQuality=await k__default.pathExists(n);}}try{if(i.framework==="NestJS"){let{stdout:n}=await execa("npm",["audit","--json"],{cwd:t,reject:!1});if(n)try{let s=JSON.parse(n).metadata?.vulnerabilities;s&&(i.vulnerabilities=(s.high||0)+(s.critical||0)+(s.moderate||0));}catch{}}else if(i.framework==="FastAPI"){let n=w.join(t,".venv"),a=process.platform==="win32"?w.join(n,"Scripts","python.exe"):w.join(n,"bin","python");if(await k__default.pathExists(a))try{let{stdout:s}=await execa(a,["-m","pip","list","--format=json"],{timeout:5e3,reject:!1});if(s){let c=JSON.parse(s);i.vulnerabilities=0;}}catch{}}}catch{}}async function Ti(t){let e={name:w.basename(t),path:t,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},o=w.join(t,".rapidkit");if(!await k__default.pathExists(o))return e.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),e;try{let c=w.join(t,"registry.json");if(await k__default.pathExists(c)){let l=await k__default.readJson(c);l.installed_modules&&(e.stats={modules:l.installed_modules.length});}}catch{}try{let c=w.join(o,"project.json");if(await k__default.pathExists(c)){let l=await k__default.readJson(c);l.kit&&(e.kit=l.kit);}}catch{}try{let c=w.join(t,".git");if(await k__default.pathExists(c)){let{stdout:l}=await execa("git",["log","-1","--format=%cr"],{cwd:t,reject:!1});l&&(e.lastModified=l.trim());}else {let l=await k__default.stat(t),d=Date.now()-l.mtime.getTime(),u=Math.floor(d/(1e3*60*60*24));e.lastModified=u===0?"today":`${u} day${u>1?"s":""} ago`;}}catch{}let r=w.join(t,"package.json"),n=w.join(t,"pyproject.toml"),a=await k__default.pathExists(r),s=await k__default.pathExists(n);if(a){e.framework="NestJS",e.venvActive=true;let c=w.join(t,"node_modules");if(await k__default.pathExists(c))try{let u=(await k__default.readdir(c)).filter(h=>!h.startsWith(".")&&!h.startsWith("_"));e.depsInstalled=u.length>0;}catch{e.depsInstalled=false;}e.depsInstalled||(e.issues.push("Dependencies not installed (node_modules empty or missing)"),e.fixCommands?.push(`cd ${t} && rapidkit init`)),e.coreInstalled=false;let l=w.join(t,".env");if(e.hasEnvFile=await k__default.pathExists(l),!e.hasEnvFile){let d=w.join(t,".env.example");await k__default.pathExists(d)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(`cd ${t} && cp .env.example .env`));}let p=w.join(t,"src");if(e.modulesHealthy=true,e.missingModules=[],await k__default.pathExists(p))try{let d=await k__default.readdir(p);e.modulesHealthy=d.length>0;}catch{e.modulesHealthy=false;}return await qt(t,e),e}if(s){e.framework="FastAPI";let c=w.join(t,".venv");if(await k__default.pathExists(c)){e.venvActive=true;let u=process.platform==="win32"?w.join(c,"Scripts","python.exe"):w.join(c,"bin","python");if(await k__default.pathExists(u)){try{let{stdout:h}=await execa(u,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});e.coreInstalled=!0,e.coreVersion=h.trim();}catch{e.coreInstalled=false;}try{await execa(u,["-c","import fastapi"],{timeout:2e3}),e.depsInstalled=!0;}catch{try{let h=w.join(c,"lib");if(await k__default.pathExists(h)){let x=(await k__default.readdir(h)).find(A=>A.startsWith("python"));if(x){let A=w.join(h,x,"site-packages");if(await k__default.pathExists(A)){let O=(await k__default.readdir(A)).filter(et=>!et.startsWith("_")&&!et.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(et));e.depsInstalled=O.length>0;}}}e.depsInstalled||(e.issues.push("Dependencies not installed"),e.fixCommands?.push(`cd ${t} && rapidkit init`));}catch{e.issues.push("Could not verify dependency installation");}}}else e.issues.push("Virtual environment exists but Python executable not found");}else e.issues.push("Virtual environment not created"),e.fixCommands?.push(`cd ${t} && rapidkit init`);let l=w.join(t,".env");if(e.hasEnvFile=await k__default.pathExists(l),!e.hasEnvFile){let u=w.join(t,".env.example");await k__default.pathExists(u)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(`cd ${t} && cp .env.example .env`));}let p=w.join(t,"src"),d=w.join(t,"modules");if(e.modulesHealthy=true,e.missingModules=[],await k__default.pathExists(p)){let u=w.join(p,"__init__.py");await k__default.pathExists(u)||(e.modulesHealthy=false,e.missingModules.push("src/__init__.py"));}if(await k__default.pathExists(d))try{let u=await Me(d);for(let h of u){let y=w.join(d,h,"__init__.py");await k__default.pathExists(y)||(e.modulesHealthy=!1,e.missingModules.push(`modules/${h}/__init__.py`));}}catch{}return !e.modulesHealthy&&e.missingModules.length>0&&e.issues.push(`Missing module init files: ${e.missingModules.join(", ")}`),await qt(t,e),e}return e.issues.push("Unknown project type (no package.json or pyproject.toml)"),await qt(t,e),e}async function Me(t){try{return (await k__default.readdir(t,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch{try{let i=await k__default.readdir(t),e=[];for(let o of i)try{(await k__default.stat(w.join(t,o))).isDirectory()&&e.push(o);}catch{continue}return e}catch{return []}}}async function Fi(t,i,e){let o=new Set,r=[{dir:t,depth:0}];for(;r.length>0;){let n=r.shift();if(!n)break;try{let a=await k__default.readdir(n.dir);for(let s of a){if(e.has(s))continue;let c=w.join(n.dir,s),l;try{l=await k__default.stat(c);}catch{continue}if(!l.isDirectory())continue;let p=w.join(c,".rapidkit");if(await k__default.pathExists(p)){o.add(c);continue}n.depth<i&&r.push({dir:c,depth:n.depth+1});}}catch{continue}}return Array.from(o)}async function Oi(t){let i=t,e=w.parse(i).root;for(;i!==e;){let o=[w.join(i,".rapidkit-workspace"),w.join(i,".rapidkit","workspace-marker.json"),w.join(i,".rapidkit","config.json")];for(let r of o)if(await k__default.pathExists(r))return i;i=w.dirname(i);}return null}function Mi(t,i){let e=0,o=0,r=0;return t.forEach(a=>{a.status==="ok"?e++:a.status==="warn"?o++:a.status==="error"&&r++;}),i.forEach(a=>{a.issues.length===0&&a.venvActive&&a.depsInstalled?e++:a.issues.length>0&&o++;}),{total:e+o+r,passed:e,warnings:o,errors:r}}async function Ki(t){let i=w.basename(t);try{let r=w.join(t,".rapidkit-workspace");await k__default.pathExists(r)&&(i=(await k__default.readJSON(r)).name||i);}catch{try{let r=w.join(t,".rapidkit","config.json");i=(await k__default.readJSON(r)).workspace_name||i;}catch{}}let e={workspacePath:t,workspaceName:i,python:await De(),poetry:await Te(),pipx:await Fe(),rapidkitCore:await Oe(),projects:[]};try{let r=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),n=new Set,a=w.join(t,".rapidkit");await k__default.pathExists(a)&&n.add(t);let s=async(c,l)=>{if(l<0)return;let p=await Me(c);for(let d of p){if(r.has(d))continue;let u=w.join(c,d),h=w.join(u,".rapidkit");if(await k__default.pathExists(h)){n.add(u);continue}l>0&&await s(u,l-1);}};if(await s(t,1),f.debug(`Workspace scan (shallow) found ${n.size} project(s)`),n.size===0){let c=await Fi(t,3,r);c.forEach(l=>n.add(l)),f.debug(`Workspace scan (deep fallback) found ${c.length} project(s)`);}n.size>0&&f.debug(`Workspace projects detected: ${Array.from(n).join(", ")}`);for(let c of n){let l=await Ti(c);e.projects.push(l);}}catch(r){f.debug(`Failed to scan workspace projects: ${r}`);}let o=[e.python,e.poetry,e.pipx,e.rapidkitCore];if(e.healthScore=Mi(o,e.projects),e.rapidkitCore.status==="ok"){let r=e.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);r&&(e.coreVersion=r[1]);}return e}function X(t,i){let e=t.status==="ok"?"\u2705":t.status==="warn"?"\u26A0\uFE0F":"\u274C",o=t.status==="ok"?m.green:t.status==="warn"?m.yellow:m.red;console.log(`${e} ${m.bold(i)}: ${o(t.message)}`),t.details&&console.log(` ${m.gray(t.details)}`);}function Wi(t){let i=t.issues.length>0,e=i?"\u26A0\uFE0F":"\u2705",o=i?m.yellow:m.green;if(console.log(`
1461
+ `);}catch(a){throw n.fail(`Failed to generate ${r} project`),a}}E();lt();async function We(){let t=process.platform==="win32"?["python","python3"]:["python3","python"];for(let i of t)try{let{stdout:e}=await execa(i,["--version"],{timeout:3e3}),o=e.match(/Python (\d+\.\d+\.\d+)/);if(o){let r=o[1],[n,a]=r.split(".").map(Number);return n<3||n===3&&a<10?{status:"warn",message:`Python ${r} (requires 3.10+)`,details:`${i} found but version is below minimum requirement`}:{status:"ok",message:`Python ${r}`,details:`Using ${i}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function Ve(){try{let{stdout:t}=await execa("poetry",["--version"],{timeout:3e3}),i=t.match(/Poetry .*version ([\d.]+)/);return i?{status:"ok",message:`Poetry ${i[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function Ue(){try{let{stdout:t}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${t.trim()}`,details:"Available for global tool installation"}}catch{return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function Be(){let t=process.env.HOME||process.env.USERPROFILE||"",i=[],e=[{location:"Global (pipx)",path:k.join(t,".local","bin","rapidkit")},{location:"Global (pipx)",path:k.join(t,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:k.join(t,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],o=[{location:"Workspace (.venv)",path:k.join(process.cwd(),".venv","bin","rapidkit")},{location:"Workspace (.venv)",path:k.join(process.cwd(),".venv","Scripts","rapidkit.exe")}];for(let{location:n,path:a}of [...e,...o])try{if(await v__default.pathExists(a)){let{stdout:s,exitCode:c}=await execa(a,["--version"],{timeout:3e3,reject:!1});if(c===0&&(s.includes("RapidKit Version")||s.includes("RapidKit"))){let l=s.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);l&&i.push({location:n,path:a,version:l[1]});}}}catch{continue}if(i.length>0)return {status:"ok",message:`RapidKit Core ${i[0].version}`,paths:i.map(a=>({location:a.location,path:a.path,version:a.version}))};try{let{stdout:n,exitCode:a}=await execa("rapidkit",["--version"],{timeout:3e3,reject:!1});if(a===0&&(n.includes("RapidKit Version")||n.includes("RapidKit"))){let s=n.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:n,exitCode:a}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:!1});if(a===0&&(n.includes("RapidKit Version")||n.includes("RapidKit"))){let s=n.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via Poetry"}}}catch{}let r=process.platform==="win32"?["python","python3"]:["python3","python"];for(let n of r)try{let{stdout:a,exitCode:s}=await execa(n,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:!1});if(s===0&&a&&!a.includes("Traceback")&&!a.includes("ModuleNotFoundError")){let c=a.trim();if(c)return {status:"ok",message:`RapidKit Core ${c}`,details:`Available in ${n} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function Zt(t,i){let e=k.join(t,"Dockerfile");i.hasDocker=await v__default.pathExists(e);let o=k.join(t,"tests"),r=k.join(t,"test");if(i.hasTests=await v__default.pathExists(o)||await v__default.pathExists(r),i.framework==="NestJS"){let n=k.join(t,".eslintrc.js"),a=k.join(t,".eslintrc.json");i.hasCodeQuality=await v__default.pathExists(n)||await v__default.pathExists(a);}else if(i.framework==="FastAPI"){let n=k.join(t,"ruff.toml"),a=k.join(t,"pyproject.toml");if(await v__default.pathExists(a))try{let s=await v__default.readFile(a,"utf8");i.hasCodeQuality=s.includes("[tool.ruff]")||await v__default.pathExists(n);}catch{i.hasCodeQuality=await v__default.pathExists(n);}}try{if(i.framework==="NestJS"){let{stdout:n}=await execa("npm",["audit","--json"],{cwd:t,reject:!1});if(n)try{let s=JSON.parse(n).metadata?.vulnerabilities;s&&(i.vulnerabilities=(s.high||0)+(s.critical||0)+(s.moderate||0));}catch{}}else if(i.framework==="FastAPI"){let n=k.join(t,".venv"),a=process.platform==="win32"?k.join(n,"Scripts","python.exe"):k.join(n,"bin","python");if(await v__default.pathExists(a))try{let{stdout:s}=await execa(a,["-m","pip","list","--format=json"],{timeout:5e3,reject:!1});if(s){let c=JSON.parse(s);i.vulnerabilities=0;}}catch{}}}catch{}}async function qi(t){let e={name:k.basename(t),path:t,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},o=k.join(t,".rapidkit");if(!await v__default.pathExists(o))return e.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),e;try{let c=k.join(t,"registry.json");if(await v__default.pathExists(c)){let l=await v__default.readJson(c);l.installed_modules&&(e.stats={modules:l.installed_modules.length});}}catch{}try{let c=k.join(o,"project.json");if(await v__default.pathExists(c)){let l=await v__default.readJson(c);l.kit&&(e.kit=l.kit);}}catch{}try{let c=k.join(t,".git");if(await v__default.pathExists(c)){let{stdout:l}=await execa("git",["log","-1","--format=%cr"],{cwd:t,reject:!1});l&&(e.lastModified=l.trim());}else {let l=await v__default.stat(t),d=Date.now()-l.mtime.getTime(),u=Math.floor(d/(1e3*60*60*24));e.lastModified=u===0?"today":`${u} day${u>1?"s":""} ago`;}}catch{}let r=k.join(t,"package.json"),n=k.join(t,"pyproject.toml"),a=await v__default.pathExists(r),s=await v__default.pathExists(n);if(a){e.framework="NestJS",e.venvActive=true;let c=k.join(t,"node_modules");if(await v__default.pathExists(c))try{let u=(await v__default.readdir(c)).filter(f=>!f.startsWith(".")&&!f.startsWith("_"));e.depsInstalled=u.length>0;}catch{e.depsInstalled=false;}e.depsInstalled||(e.issues.push("Dependencies not installed (node_modules empty or missing)"),e.fixCommands?.push(`cd ${t} && rapidkit init`)),e.coreInstalled=false;let l=k.join(t,".env");if(e.hasEnvFile=await v__default.pathExists(l),!e.hasEnvFile){let d=k.join(t,".env.example");await v__default.pathExists(d)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(`cd ${t} && cp .env.example .env`));}let p=k.join(t,"src");if(e.modulesHealthy=true,e.missingModules=[],await v__default.pathExists(p))try{let d=await v__default.readdir(p);e.modulesHealthy=d.length>0;}catch{e.modulesHealthy=false;}return await Zt(t,e),e}if(s){e.framework="FastAPI";let c=k.join(t,".venv");if(await v__default.pathExists(c)){e.venvActive=true;let u=process.platform==="win32"?k.join(c,"Scripts","python.exe"):k.join(c,"bin","python");if(await v__default.pathExists(u)){try{let{stdout:f}=await execa(u,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});e.coreInstalled=!0,e.coreVersion=f.trim();}catch{e.coreInstalled=false;}try{await execa(u,["-c","import fastapi"],{timeout:2e3}),e.depsInstalled=!0;}catch{try{let f=k.join(c,"lib");if(await v__default.pathExists(f)){let h=(await v__default.readdir(f)).find(j=>j.startsWith("python"));if(h){let j=k.join(f,h,"site-packages");if(await v__default.pathExists(j)){let T=(await v__default.readdir(j)).filter(V=>!V.startsWith("_")&&!V.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(V));e.depsInstalled=T.length>0;}}}e.depsInstalled||(e.issues.push("Dependencies not installed"),e.fixCommands?.push(`cd ${t} && rapidkit init`));}catch{e.issues.push("Could not verify dependency installation");}}}else e.issues.push("Virtual environment exists but Python executable not found");}else e.issues.push("Virtual environment not created"),e.fixCommands?.push(`cd ${t} && rapidkit init`);let l=k.join(t,".env");if(e.hasEnvFile=await v__default.pathExists(l),!e.hasEnvFile){let u=k.join(t,".env.example");await v__default.pathExists(u)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(`cd ${t} && cp .env.example .env`));}let p=k.join(t,"src"),d=k.join(t,"modules");if(e.modulesHealthy=true,e.missingModules=[],await v__default.pathExists(p)){let u=k.join(p,"__init__.py");await v__default.pathExists(u)||(e.modulesHealthy=false,e.missingModules.push("src/__init__.py"));}if(await v__default.pathExists(d))try{let u=await He(d);for(let f of u){let g=k.join(d,f,"__init__.py");await v__default.pathExists(g)||(e.modulesHealthy=!1,e.missingModules.push(`modules/${f}/__init__.py`));}}catch{}return !e.modulesHealthy&&e.missingModules.length>0&&e.issues.push(`Missing module init files: ${e.missingModules.join(", ")}`),await Zt(t,e),e}return e.issues.push("Unknown project type (no package.json or pyproject.toml)"),await Zt(t,e),e}async function He(t){try{return (await v__default.readdir(t,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch{try{let i=await v__default.readdir(t),e=[];for(let o of i)try{(await v__default.stat(k.join(t,o))).isDirectory()&&e.push(o);}catch{continue}return e}catch{return []}}}async function Qi(t,i,e){let o=new Set,r=[{dir:t,depth:0}];for(;r.length>0;){let n=r.shift();if(!n)break;try{let a=await v__default.readdir(n.dir);for(let s of a){if(e.has(s))continue;let c=k.join(n.dir,s),l;try{l=await v__default.stat(c);}catch{continue}if(!l.isDirectory())continue;let p=k.join(c,".rapidkit");if(await v__default.pathExists(p)){o.add(c);continue}n.depth<i&&r.push({dir:c,depth:n.depth+1});}}catch{continue}}return Array.from(o)}async function Xi(t){let i=t,e=k.parse(i).root;for(;i!==e;){let o=[k.join(i,".rapidkit-workspace"),k.join(i,".rapidkit","workspace-marker.json"),k.join(i,".rapidkit","config.json")];for(let r of o)if(await v__default.pathExists(r))return i;i=k.dirname(i);}return null}function Zi(t,i){let e=0,o=0,r=0;return t.forEach(a=>{a.status==="ok"?e++:a.status==="warn"?o++:a.status==="error"&&r++;}),i.forEach(a=>{a.issues.length===0&&a.venvActive&&a.depsInstalled?e++:a.issues.length>0&&o++;}),{total:e+o+r,passed:e,warnings:o,errors:r}}async function to(t){let i=k.basename(t);try{let r=k.join(t,".rapidkit-workspace");await v__default.pathExists(r)&&(i=(await v__default.readJSON(r)).name||i);}catch{try{let r=k.join(t,".rapidkit","config.json");i=(await v__default.readJSON(r)).workspace_name||i;}catch{}}let e={workspacePath:t,workspaceName:i,python:await We(),poetry:await Ve(),pipx:await Ue(),rapidkitCore:await Be(),projects:[]};try{let r=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),n=new Set,a=k.join(t,".rapidkit");await v__default.pathExists(a)&&n.add(t);let s=async(c,l)=>{if(l<0)return;let p=await He(c);for(let d of p){if(r.has(d))continue;let u=k.join(c,d),f=k.join(u,".rapidkit");if(await v__default.pathExists(f)){n.add(u);continue}l>0&&await s(u,l-1);}};if(await s(t,1),y.debug(`Workspace scan (shallow) found ${n.size} project(s)`),n.size===0){let c=await Qi(t,3,r);c.forEach(l=>n.add(l)),y.debug(`Workspace scan (deep fallback) found ${c.length} project(s)`);}n.size>0&&y.debug(`Workspace projects detected: ${Array.from(n).join(", ")}`);for(let c of n){let l=await qi(c);e.projects.push(l);}}catch(r){y.debug(`Failed to scan workspace projects: ${r}`);}let o=[e.python,e.poetry,e.pipx,e.rapidkitCore];if(e.healthScore=Zi(o,e.projects),e.rapidkitCore.status==="ok"){let r=e.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);r&&(e.coreVersion=r[1]);}return e}function tt(t,i){let e=t.status==="ok"?"\u2705":t.status==="warn"?"\u26A0\uFE0F":"\u274C",o=t.status==="ok"?m.green:t.status==="warn"?m.yellow:m.red;console.log(`${e} ${m.bold(i)}: ${o(t.message)}`),t.paths&&t.paths.length>0?t.paths.forEach(r=>{let n=r.version?m.cyan(` -> ${r.version}`):"";console.log(` ${m.cyan("\u2022")} ${m.gray(r.location)}: ${m.dim(r.path)}${n}`);}):t.details&&console.log(` ${m.gray(t.details)}`);}function eo(t){let i=t.issues.length>0,e=i?"\u26A0\uFE0F":"\u2705",o=i?m.yellow:m.green;if(console.log(`
1456
1462
  ${e} ${m.bold("Project")}: ${o(t.name)}`),t.framework){let s=t.framework==="FastAPI"?"\u{1F40D}":t.framework==="NestJS"?"\u{1F985}":"\u{1F4E6}";console.log(` ${s} Framework: ${m.cyan(t.framework)}${t.kit?m.gray(` (${t.kit})`):""}`);}if(console.log(` ${m.gray(`Path: ${t.path}`)}`),!(t.venvActive&&!t.coreInstalled)&&(t.venvActive?console.log(` \u2705 Virtual environment: ${m.green("Active")}`):console.log(` \u274C Virtual environment: ${m.red("Not found")}`),t.coreInstalled?console.log(` ${m.dim("\u2139")} RapidKit Core: ${m.gray(t.coreVersion||"In venv")} ${m.dim("(optional)")}`):console.log(` ${m.dim("\u2139")} RapidKit Core: ${m.gray("Using global installation")} ${m.dim("(recommended)")}`)),t.depsInstalled?console.log(` \u2705 Dependencies: ${m.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${m.yellow("Not installed")}`),t.hasEnvFile!==void 0&&(t.hasEnvFile?console.log(` \u2705 Environment: ${m.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${m.yellow(".env missing")}`)),t.modulesHealthy!==void 0&&(t.modulesHealthy?console.log(` \u2705 Modules: ${m.green("Healthy")}`):t.missingModules&&t.missingModules.length>0&&console.log(` \u26A0\uFE0F Modules: ${m.yellow(`Missing ${t.missingModules.length} init file(s)`)}`)),t.stats){let s=[];t.stats.modules!==void 0&&s.push(`${t.stats.modules} module${t.stats.modules!==1?"s":""}`),s.length>0&&console.log(` \u{1F4CA} Stats: ${m.cyan(s.join(" \u2022 "))}`);}t.lastModified&&console.log(` \u{1F552} Last Modified: ${m.gray(t.lastModified)}`);let a=[];if(t.hasTests!==void 0&&a.push(t.hasTests?"\u2705 Tests":m.dim("\u2298 No tests")),t.hasDocker!==void 0&&a.push(t.hasDocker?"\u2705 Docker":m.dim("\u2298 No Docker")),t.hasCodeQuality!==void 0){let s=t.framework==="NestJS"?"ESLint":"Ruff";a.push(t.hasCodeQuality?`\u2705 ${s}`:m.dim(`\u2298 No ${s}`));}a.length>0&&console.log(` ${a.join(" \u2022 ")}`),t.vulnerabilities!==void 0&&t.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${m.yellow(`${t.vulnerabilities} vulnerability(ies) found`)}`),t.issues.length>0&&(console.log(` ${m.bold("Issues:")}`),t.issues.forEach(s=>{console.log(` \u2022 ${m.yellow(s)}`);}),t.fixCommands&&t.fixCommands.length>0&&(console.log(`
1457
- ${m.bold.cyan("\u{1F527} Quick Fix:")}`),t.fixCommands.forEach(s=>{console.log(` ${m.cyan("$")} ${m.white(s)}`);})));}async function Ne(t,i=false){let e=t.filter(r=>r.fixCommands&&r.fixCommands.length>0);if(e.length===0){console.log(m.green(`
1463
+ ${m.bold.cyan("\u{1F527} Quick Fix:")}`),t.fixCommands.forEach(s=>{console.log(` ${m.cyan("$")} ${m.white(s)}`);})));}async function Ge(t,i=false){let e=t.filter(r=>r.fixCommands&&r.fixCommands.length>0);if(e.length===0){console.log(m.green(`
1458
1464
  \u2705 No fixes needed - all projects are healthy!`));return}console.log(m.bold.cyan(`
1459
1465
  \u{1F527} Available Fixes:
1460
- `));for(let r of e)console.log(m.bold(`Project: ${m.yellow(r.name)}`)),r.fixCommands.forEach((n,a)=>{console.log(` ${a+1}. ${m.cyan(n)}`);}),console.log();if(!i){console.log(m.gray("\u{1F4A1} Run with --fix flag to apply fixes automatically"));return}let{confirm:o}=await Jt.prompt([{type:"confirm",name:"confirm",message:`Apply ${e.reduce((r,n)=>r+n.fixCommands.length,0)} fix(es)?`,default:false}]);if(!o){console.log(m.yellow(`
1466
+ `));for(let r of e)console.log(m.bold(`Project: ${m.yellow(r.name)}`)),r.fixCommands.forEach((n,a)=>{console.log(` ${a+1}. ${m.cyan(n)}`);}),console.log();if(!i){console.log(m.gray("\u{1F4A1} Run with --fix flag to apply fixes automatically"));return}let{confirm:o}=await qt.prompt([{type:"confirm",name:"confirm",message:`Apply ${e.reduce((r,n)=>r+n.fixCommands.length,0)} fix(es)?`,default:false}]);if(!o){console.log(m.yellow(`
1461
1467
  \u26A0\uFE0F Fixes cancelled by user`));return}console.log(m.bold.cyan(`
1462
1468
  \u{1F680} Applying fixes...
1463
1469
  `));for(let r of e){console.log(m.bold(`Fixing ${m.cyan(r.name)}...`));for(let n of r.fixCommands)try{console.log(m.gray(` $ ${n}`)),await execa(n,{shell:!0,stdio:"inherit"}),console.log(m.green(` \u2705 Success
1464
1470
  `));}catch(a){console.log(m.red(` \u274C Failed: ${a instanceof Error?a.message:String(a)}
1465
1471
  `));}}console.log(m.bold.green(`
1466
- \u2705 Fix process completed!`));}async function Ke(t={}){if(t.json||console.log(m.bold.cyan(`
1472
+ \u2705 Fix process completed!`));}async function Je(t={}){if(t.json||console.log(m.bold.cyan(`
1467
1473
  \u{1FA7A} RapidKit Health Check
1468
- `)),t.workspace){let i=await Oi(process.cwd());i||(f.error("No RapidKit workspace found in current directory or parents"),f.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),t.json||(console.log(m.bold(`Workspace: ${m.cyan(w.basename(i))}`)),console.log(m.gray(`Path: ${i}`)));let e=await Ki(i);if(t.json){let n={workspace:{name:w.basename(i),path:i},healthScore:e.healthScore,system:{python:e.python,poetry:e.poetry,pipx:e.pipx,rapidkitCore:e.rapidkitCore,versions:{core:e.coreVersion,npm:e.npmVersion}},projects:e.projects.map(a=>({name:a.name,path:a.path,venvActive:a.venvActive,depsInstalled:a.depsInstalled,coreInstalled:a.coreInstalled,coreVersion:a.coreVersion,issues:a.issues,fixCommands:a.fixCommands})),summary:{totalProjects:e.projects.length,totalIssues:e.projects.reduce((a,s)=>a+s.issues.length,0),hasSystemErrors:[e.python,e.rapidkitCore].some(a=>a.status==="error")}};console.log(JSON.stringify(n,null,2));return}if(e.healthScore){let n=e.healthScore,a=Math.round(n.passed/n.total*100),s=a>=80?m.green:a>=50?m.yellow:m.red,c="\u2588".repeat(Math.floor(a/5))+"\u2591".repeat(20-Math.floor(a/5));console.log(m.bold(`
1474
+ `)),t.workspace){let i=await Xi(process.cwd());i||(y.error("No RapidKit workspace found in current directory or parents"),y.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),t.json||(console.log(m.bold(`Workspace: ${m.cyan(k.basename(i))}`)),console.log(m.gray(`Path: ${i}`)));let e=await to(i);if(t.json){let n={workspace:{name:k.basename(i),path:i},healthScore:e.healthScore,system:{python:e.python,poetry:e.poetry,pipx:e.pipx,rapidkitCore:e.rapidkitCore,versions:{core:e.coreVersion,npm:e.npmVersion}},projects:e.projects.map(a=>({name:a.name,path:a.path,venvActive:a.venvActive,depsInstalled:a.depsInstalled,coreInstalled:a.coreInstalled,coreVersion:a.coreVersion,issues:a.issues,fixCommands:a.fixCommands})),summary:{totalProjects:e.projects.length,totalIssues:e.projects.reduce((a,s)=>a+s.issues.length,0),hasSystemErrors:[e.python,e.rapidkitCore].some(a=>a.status==="error")}};console.log(JSON.stringify(n,null,2));return}if(e.healthScore){let n=e.healthScore,a=Math.round(n.passed/n.total*100),s=a>=80?m.green:a>=50?m.yellow:m.red,c="\u2588".repeat(Math.floor(a/5))+"\u2591".repeat(20-Math.floor(a/5));console.log(m.bold(`
1469
1475
  \u{1F4CA} Health Score:`)),console.log(` ${s(`${a}%`)} ${m.gray(c)}`),console.log(` ${m.green(`\u2705 ${n.passed} passed`)} ${m.gray("|")} ${m.yellow(`\u26A0\uFE0F ${n.warnings} warnings`)} ${m.gray("|")} ${m.red(`\u274C ${n.errors} errors`)}`);}if(console.log(m.bold(`
1470
1476
 
1471
1477
  System Tools:
1472
- `)),X(e.python,"Python"),X(e.poetry,"Poetry"),X(e.pipx,"pipx"),X(e.rapidkitCore,"RapidKit Core"),e.coreVersion&&e.npmVersion){let n=e.coreVersion.split(".")[1],a=e.npmVersion.split(".")[1];n!==a&&(console.log(m.yellow(`
1478
+ `)),tt(e.python,"Python"),tt(e.poetry,"Poetry"),tt(e.pipx,"pipx"),tt(e.rapidkitCore,"RapidKit Core"),e.coreVersion&&e.npmVersion){let n=e.coreVersion.split(".")[1],a=e.npmVersion.split(".")[1];n!==a&&(console.log(m.yellow(`
1473
1479
  \u26A0\uFE0F Version mismatch: Core ${e.coreVersion} / CLI ${e.npmVersion}`)),console.log(m.gray(" Consider updating to matching versions for best compatibility")));}e.projects.length>0?(console.log(m.bold(`
1474
- \u{1F4E6} Projects (${e.projects.length}):`)),e.projects.forEach(n=>Wi(n))):(console.log(m.bold(`
1480
+ \u{1F4E6} Projects (${e.projects.length}):`)),e.projects.forEach(n=>eo(n))):(console.log(m.bold(`
1475
1481
  \u{1F4E6} Projects:`)),console.log(m.gray(" No RapidKit projects found in workspace")));let o=e.projects.reduce((n,a)=>n+a.issues.length,0),r=[e.python,e.rapidkitCore].some(n=>n.status==="error");r||o>0?(console.log(m.bold.yellow(`
1476
- \u26A0\uFE0F Found ${o} project issue(s)`)),r&&console.log(m.bold.red("\u274C System requirements not met")),t.fix?await Ne(e.projects,true):o>0&&await Ne(e.projects,false)):console.log(m.bold.green(`
1482
+ \u26A0\uFE0F Found ${o} project issue(s)`)),r&&console.log(m.bold.red("\u274C System requirements not met")),t.fix?await Ge(e.projects,true):o>0&&await Ge(e.projects,false)):console.log(m.bold.green(`
1477
1483
  \u2705 All checks passed! Workspace is healthy.`));}else {console.log(m.bold(`System Tools:
1478
- `));let i=await De(),e=await Te(),o=await Fe(),r=await Oe();X(i,"Python"),X(e,"Poetry"),X(o,"pipx"),X(r,"RapidKit Core"),[i,r].some(a=>a.status==="error")?(console.log(m.bold.red(`
1484
+ `));let i=await We(),e=await Ve(),o=await Ue(),r=await Be();tt(i,"Python"),tt(e,"Poetry"),tt(o,"pipx"),tt(r,"RapidKit Core"),[i,r].some(a=>a.status==="error")?(console.log(m.bold.red(`
1479
1485
  \u274C Some required tools are missing`)),console.log(m.gray(`
1480
1486
  Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`))):(console.log(m.bold.green(`
1481
1487
  \u2705 All required tools are installed!`)),console.log(m.gray(`
1482
- Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`)));}console.log("");}function Qt(t){if(!t||typeof t!="object")return null;let i=t.code;return i==="PYTHON_NOT_FOUND"||i==="BRIDGE_VENV_BOOTSTRAP_FAILED"?i:null}function Li(t){let i=t.trim().toLowerCase();return i?i.startsWith("fastapi")?"fastapi":i.startsWith("nestjs")?"nestjs":null:null}function Gi(t,i){let e=t.indexOf(i);if(e>=0&&e+1<t.length)return t[e+1];let o=t.find(r=>r.startsWith(`${i}=`));if(o)return o.slice(i.length+1)}async function Xt(t,i){if(t.includes("--json"))return process.stderr.write("RapidKit (npm) offline fallback does not support --json for `create` commands.\nInstall Python 3.10+ and retry the same command.\n"),1;if(t[0]!=="create")return 1;if(t[1]!=="project")return process.stderr.write(`RapidKit (npm) could not run the Python core engine for \`create\`.
1488
+ Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`)));}console.log("");}function te(t){if(!t||typeof t!="object")return null;let i=t.code;return i==="PYTHON_NOT_FOUND"||i==="BRIDGE_VENV_BOOTSTRAP_FAILED"?i:null}function oo(t){let i=t.trim().toLowerCase();return i?i.startsWith("fastapi")?"fastapi":i.startsWith("nestjs")?"nestjs":null:null}function no(t,i){let e=t.indexOf(i);if(e>=0&&e+1<t.length)return t[e+1];let o=t.find(r=>r.startsWith(`${i}=`));if(o)return o.slice(i.length+1)}async function ee(t,i){if(t.includes("--json"))return process.stderr.write("RapidKit (npm) offline fallback does not support --json for `create` commands.\nInstall Python 3.10+ and retry the same command.\n"),1;if(t[0]!=="create")return 1;if(t[1]!=="project")return process.stderr.write(`RapidKit (npm) could not run the Python core engine for \`create\`.
1483
1489
  Reason: ${i}.
1484
1490
  Install Python 3.10+ to use the interactive wizard and full kit catalog.
1485
1491
  `),1;let r=t[2],n=t[3];if(!r||!n)return process.stderr.write(`Usage: rapidkit create project <kit> <name> [--output <dir>]
1486
1492
  Tip: offline fallback supports only fastapi* and nestjs* kits.
1487
- `),1;let a=Li(r);if(!a)return process.stderr.write(`RapidKit (npm) could not run the Python core engine to create this kit.
1493
+ `),1;let a=oo(r);if(!a)return process.stderr.write(`RapidKit (npm) could not run the Python core engine to create this kit.
1488
1494
  Reason: ${i}.
1489
1495
  Requested kit: ${r}
1490
1496
  Offline fallback only supports: fastapi.standard, nestjs.standard (and their shorthands).
1491
1497
  Install Python 3.10+ to access all kits.
1492
- `),1;let s=Gi(t,"--output")||process.cwd(),c=w.resolve(s,n),l=t.includes("--skip-git")||t.includes("--no-git"),p=t.includes("--skip-install");try{if(await k.ensureDir(w.dirname(c)),await k.pathExists(c))return process.stderr.write(`\u274C Directory "${c}" already exists
1493
- `),1;let d="pip",u=St(process.cwd());if(u)try{let{readWorkspaceMarker:h}=await Promise.resolve().then(()=>(Ht(),ke)),y=await h(u);y?.metadata?.npm?.installMethod&&(d=y.metadata.npm.installMethod,console.log(`[DEBUG] Detected workspace engine: ${d}`));}catch(h){console.log("[DEBUG] Failed to read workspace marker:",h);}else console.log("[DEBUG] No workspace found, using default engine: pip");if(await k.ensureDir(c),await Ae(c,{project_name:n,template:a,skipGit:l,skipInstall:p,engine:d}),u){let{syncWorkspaceProjects:h}=await Promise.resolve().then(()=>(Q(),q));await h(u,!0);}return 0}catch(d){return process.stderr.write(`RapidKit (npm) offline fallback failed: ${d?.message??d}
1494
- `),1}}async function Ui(t){let i=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);try{if(t[0]==="create"&&t[1]==="project"){let e=t.includes("--create-workspace"),o=t.includes("--no-workspace"),r=t.includes("--yes")||t.includes("-y"),n=t.includes("--skip-git")||t.includes("--no-git");if(!!!It(process.cwd())){if(e)await rt(process.cwd(),{skipGit:n,yes:r,userConfig:await ht()});else if(!o)if(r)await rt(process.cwd(),{skipGit:n,yes:!0,userConfig:await ht()});else {let{createWs:c}=await Jt.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:!0}]);c&&await rt(process.cwd(),{skipGit:n,yes:!1,userConfig:await ht()});}}let s=t.filter(c=>{let l=c.split("=")[0];return !i.has(c)&&!i.has(l)});try{await ut();let c=await B(s,{cwd:process.cwd()});if(c===0){let l=St(process.cwd());if(l){try{let d=t[3];if(d){let u=t.indexOf("--output"),h=u>=0?t[u+1]:".",y=w.resolve(process.cwd(),h,d),x=w.join(l,".python-version"),A=w.join(y,".python-version");if(F.existsSync(x)&&F.existsSync(y)){let D=F.readFileSync(x,"utf-8");F.writeFileSync(A,D.trim()+`
1495
- `),f.debug(`Synced Python version ${D.trim()} from workspace to ${d}`);}}}catch(d){f.debug("Could not sync Python version from workspace:",d);}let{syncWorkspaceProjects:p}=await Promise.resolve().then(()=>(Q(),q));await p(l,!0);}}return c}catch(c){let l=Qt(c);return l?await Xt(s,l):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${c?.message??c}
1496
- `),1)}}if(t[0]==="create"&&t[1]!=="project")try{await ut();let e=await B(t,{cwd:process.cwd()});if(e===0){let o=St(process.cwd());if(o){let{syncWorkspaceProjects:r}=await Promise.resolve().then(()=>(Q(),q));await r(o,!0);}}return e}catch(e){let o=Qt(e);return o?await Xt(t,o):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${e?.message??e}
1497
- `),1)}return await ut(),await B(t,{cwd:process.cwd()})}catch(e){let o=Qt(e);return o?await Xt(t,o):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${e?.message??e}
1498
- `),1)}}var Ve=["init","dev","start","build","test","lint","format","create","help","--help","-h"];function Hi(t){let i=t;for(;;){let e=w.join(i,".rapidkit","context.json");if(F.existsSync(e))return e;let o=w.dirname(i);if(o===i)break;i=o;}return null}function It(t){let i=t;for(;;){let e=w.join(i,".rapidkit-workspace");if(F.existsSync(e))return e;let o=w.dirname(i);if(o===i)break;i=o;}return null}function St(t){let i=t;for(;;){let e=w.join(i,".rapidkit-workspace");if(F.existsSync(e))return i;let o=w.dirname(i);if(o===i)break;i=o;}return null}async function Bi(){let t=process.cwd(),i=process.argv.slice(2);if(i[0]==="create")return false;try{let c=i[0],l=!c||c==="--help"||c==="-h"||c==="help";if(It(t)&&l){let d=await B(c?["--help"]:[],{cwd:t});process.exit(d);}}catch{}try{let c=i[0],l=c==="shell"&&i[1]==="activate",p=c==="create",d=await ae(t,{cwd:t,timeoutMs:1200});if(d.ok&&d.data?.isRapidkitProject&&d.data.engine==="python"&&!l&&!p){let u=await B(process.argv.slice(2),{cwd:t});process.exit(u);}}catch{}let e=Hi(t),o=process.platform==="win32",r=o?[w.join(t,"rapidkit.cmd"),w.join(t,"rapidkit"),w.join(t,".rapidkit","rapidkit.cmd"),w.join(t,".rapidkit","rapidkit")]:[w.join(t,"rapidkit"),w.join(t,".rapidkit","rapidkit")],n=null;for(let c of r)if(await k.pathExists(c)){n=c;break}let a=i[0],s=a==="create";if(n&&a&&Ve.includes(a)&&!s){f.debug(`Delegating to local CLI: ${n} ${i.join(" ")}`);let c=spawn(n,i,{stdio:"inherit",cwd:t,shell:o});return c.on("close",l=>{process.exit(l??0);}),c.on("error",l=>{f.error(`Failed to run local rapidkit: ${l.message}`),process.exit(1);}),true}if(e&&await k.pathExists(e))try{if((await k.readJson(e)).engine==="pip"){let l=i[0],d=process.platform==="win32"?[w.join(t,"rapidkit.cmd"),w.join(t,"rapidkit"),w.join(t,".rapidkit","rapidkit.cmd"),w.join(t,".rapidkit","rapidkit")]:[w.join(t,"rapidkit"),w.join(t,".rapidkit","rapidkit")],u=null;for(let y of d)if(await k.pathExists(y)){u=y;break}if(u&&l&&Ve.includes(l)){f.debug(`Delegating to local CLI (early detection): ${u} ${i.join(" ")}`);let y=spawn(u,i,{stdio:"inherit",cwd:t});return y.on("close",x=>process.exit(x??0)),y.on("error",x=>{f.error(`Failed to run local rapidkit: ${x.message}`),process.exit(1);}),!0}if(l==="shell"&&i[1]==="activate"){let y=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
1498
+ `),1;let s=no(t,"--output")||process.cwd(),c=k.resolve(s,n),l=t.includes("--skip-git")||t.includes("--no-git"),p=t.includes("--skip-install");try{if(await v.ensureDir(k.dirname(c)),await v.pathExists(c))return process.stderr.write(`\u274C Directory "${c}" already exists
1499
+ `),1;let d="pip",u=Nt(process.cwd());if(u)try{let{readWorkspaceMarker:f}=await Promise.resolve().then(()=>(Yt(),Re)),g=await f(u);g?.metadata?.npm?.installMethod&&(d=g.metadata.npm.installMethod,console.log(`[DEBUG] Detected workspace engine: ${d}`));}catch(f){console.log("[DEBUG] Failed to read workspace marker:",f);}else console.log("[DEBUG] No workspace found, using default engine: pip");if(await v.ensureDir(c),await Le(c,{project_name:n,template:a,skipGit:l,skipInstall:p,engine:d}),u){let{syncWorkspaceProjects:f}=await Promise.resolve().then(()=>(Z(),X));await f(u,!0);}return 0}catch(d){return process.stderr.write(`RapidKit (npm) offline fallback failed: ${d?.message??d}
1500
+ `),1}}async function ro(t){let i=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);try{if(t[0]==="create"&&t[1]==="project"){let e=t.includes("--create-workspace"),o=t.includes("--no-workspace"),r=t.includes("--yes")||t.includes("-y"),n=t.includes("--skip-git")||t.includes("--no-git");if(!!!Dt(process.cwd())){if(e)await st(process.cwd(),{skipGit:n,yes:r,userConfig:await yt()});else if(!o)if(r)await st(process.cwd(),{skipGit:n,yes:!0,userConfig:await yt()});else {let{createWs:c}=await qt.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:!0}]);c&&await st(process.cwd(),{skipGit:n,yes:!1,userConfig:await yt()});}}let s=t.filter(c=>{let l=c.split("=")[0];return !i.has(c)&&!i.has(l)});try{await mt();let c=await Y(s,{cwd:process.cwd()});if(c===0){let l=Nt(process.cwd());if(l){try{let d=t[3];if(d){let u=t.indexOf("--output"),f=u>=0?t[u+1]:".",g=k.resolve(process.cwd(),f,d),h=k.join(l,".python-version"),j=k.join(g,".python-version");if(O.existsSync(h)&&O.existsSync(g)){let N=O.readFileSync(h,"utf-8");O.writeFileSync(j,N.trim()+`
1501
+ `),y.debug(`Synced Python version ${N.trim()} from workspace to ${d}`);}}}catch(d){y.debug("Could not sync Python version from workspace:",d);}let{syncWorkspaceProjects:p}=await Promise.resolve().then(()=>(Z(),X));await p(l,!0);}}return c}catch(c){let l=te(c);return l?await ee(s,l):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${c?.message??c}
1502
+ `),1)}}if(t[0]==="create"&&t[1]!=="project")try{await mt();let e=await Y(t,{cwd:process.cwd()});if(e===0){let o=Nt(process.cwd());if(o){let{syncWorkspaceProjects:r}=await Promise.resolve().then(()=>(Z(),X));await r(o,!0);}}return e}catch(e){let o=te(e);return o?await ee(t,o):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${e?.message??e}
1503
+ `),1)}return await mt(),await Y(t,{cwd:process.cwd()})}catch(e){let o=te(e);return o?await ee(t,o):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${e?.message??e}
1504
+ `),1)}}var ze=["init","dev","start","build","test","lint","format","create","help","--help","-h"];function ao(t){let i=t;for(;;){let e=k.join(i,".rapidkit","context.json");if(O.existsSync(e))return e;let o=k.dirname(i);if(o===i)break;i=o;}return null}function Dt(t){let i=t;for(;;){let e=k.join(i,".rapidkit-workspace");if(O.existsSync(e))return e;let o=k.dirname(i);if(o===i)break;i=o;}return null}function Nt(t){let i=t;for(;;){let e=k.join(i,".rapidkit-workspace");if(O.existsSync(e))return i;let o=k.dirname(i);if(o===i)break;i=o;}return null}async function so(){let t=process.cwd(),i=process.argv.slice(2);if(i[0]==="create")return false;try{let c=i[0],l=!c||c==="--help"||c==="-h"||c==="help";if(Dt(t)&&l){let d=await Y(c?["--help"]:[],{cwd:t});process.exit(d);}}catch{}try{let c=i[0],l=c==="shell"&&i[1]==="activate",p=c==="create",d=await pe(t,{cwd:t,timeoutMs:1200});if(d.ok&&d.data?.isRapidkitProject&&d.data.engine==="python"&&!l&&!p){let u=await Y(process.argv.slice(2),{cwd:t});process.exit(u);}}catch{}let e=ao(t),o=process.platform==="win32",r=o?[k.join(t,"rapidkit.cmd"),k.join(t,"rapidkit"),k.join(t,".rapidkit","rapidkit.cmd"),k.join(t,".rapidkit","rapidkit")]:[k.join(t,"rapidkit"),k.join(t,".rapidkit","rapidkit")],n=null;for(let c of r)if(await v.pathExists(c)){n=c;break}let a=i[0],s=a==="create";if(n&&a&&ze.includes(a)&&!s){y.debug(`Delegating to local CLI: ${n} ${i.join(" ")}`);let c=spawn(n,i,{stdio:"inherit",cwd:t,shell:o});return c.on("close",l=>{process.exit(l??0);}),c.on("error",l=>{y.error(`Failed to run local rapidkit: ${l.message}`),process.exit(1);}),true}if(e&&await v.pathExists(e))try{if((await v.readJson(e)).engine==="pip"){let l=i[0],d=process.platform==="win32"?[k.join(t,"rapidkit.cmd"),k.join(t,"rapidkit"),k.join(t,".rapidkit","rapidkit.cmd"),k.join(t,".rapidkit","rapidkit")]:[k.join(t,"rapidkit"),k.join(t,".rapidkit","rapidkit")],u=null;for(let g of d)if(await v.pathExists(g)){u=g;break}if(u&&l&&ze.includes(l)){y.debug(`Delegating to local CLI (early detection): ${u} ${i.join(" ")}`);let g=spawn(u,i,{stdio:"inherit",cwd:t});return g.on("close",h=>process.exit(h??0)),g.on("error",h=>{y.error(`Failed to run local rapidkit: ${h.message}`),process.exit(1);}),!0}if(l==="shell"&&i[1]==="activate"){let g=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
1499
1505
  VENV='.venv'
1500
1506
  if [ -f "$VENV/bin/activate" ]; then
1501
1507
  . "$VENV/bin/activate"
@@ -1506,43 +1512,43 @@ export RAPIDKIT_PROJECT_ROOT="$(pwd)"
1506
1512
  export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
1507
1513
  `;console.log(m.green.bold(`
1508
1514
  \u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
1509
- `)),console.log(y),console.log(m.gray(`
1515
+ `)),console.log(g),console.log(m.gray(`
1510
1516
  \u{1F4A1} After activation you can run: rapidkit dev
1511
- `)),process.exit(0);}let h=await B(i,{cwd:t});process.exit(h);}}catch{}return false}var Z=null,At=false,tt=new Command;async function Yi(t){if(t.length===0)return false;let i=t[0],e=t[1];if(i==="shell"&&e==="activate"||i==="workspace"||i==="doctor")return false;if(t.includes("--tui"))return true;if(i==="--help"||i==="-h"||i==="help"||i==="--version"||i==="-V"||t.includes("--template")||t.includes("-t"))return false;let o=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(t.some(n=>o.has(n)))return false;let r=await Vt();return r?r.has(i):!!(ye.has(i)||t.length>1)}tt.name("rapidkit").description("Create RapidKit workspaces and projects").version(H());tt.addHelpText("beforeAll",`RapidKit
1517
+ `)),process.exit(0);}let f=await Y(i,{cwd:t});process.exit(f);}}catch{}return false}var et=null,Tt=false,it=new Command;async function lo(t){if(t.length===0)return false;let i=t[0],e=t[1];if(i==="shell"&&e==="activate"||i==="workspace"||i==="doctor")return false;if(t.includes("--tui"))return true;if(i==="--help"||i==="-h"||i==="help"||i==="--version"||i==="-V"||t.includes("--template")||t.includes("-t"))return false;let o=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(t.some(n=>o.has(n)))return false;let r=await Ut();return r?r.has(i):!!(vt.has(i)||t.length>1)}it.name("rapidkit").description("Create RapidKit workspaces and projects").version(H());it.addHelpText("beforeAll",`RapidKit
1512
1518
 
1513
1519
  Global CLI
1514
1520
  Create RapidKit workspaces and projects
1515
1521
 
1516
1522
  Global Engine Commands
1517
1523
  Access engine-level commands when inside a RapidKit workspace or via the core bridge
1518
- `);tt.addHelpText("afterAll",`
1524
+ `);it.addHelpText("afterAll",`
1519
1525
  Project Commands
1520
1526
  rapidkit create
1521
1527
  rapidkit init
1522
1528
  rapidkit dev
1523
1529
 
1524
1530
  Use "rapidkit help <command>" for more information.
1525
- `);tt.argument("[name]","Name of the workspace or project directory").addOption(new Option("-t, --template <template>","Legacy: create a project with template (fastapi, nestjs) instead of a workspace").hideHelp()).option("-y, --yes","Skip prompts and use defaults").addOption(new Option("--skip-git","Skip git initialization").hideHelp()).addOption(new Option("--skip-install","Legacy: skip installing dependencies (template mode)").hideHelp()).option("--debug","Enable debug logging").addOption(new Option("--dry-run","Show what would be created without creating it").hideHelp()).addOption(new Option("--install-method <method>","Installation method: poetry, venv, or pipx").choices(["poetry","venv","pipx"]).hideHelp()).addOption(new Option("--create-workspace","When creating a project outside a workspace: create and register a workspace in the current directory").hideHelp()).addOption(new Option("--no-workspace","When creating a project outside a workspace: do not create a workspace").hideHelp()).option("--no-update-check","Skip checking for updates").action(async(t,i)=>{try{i.debug&&(f.setDebug(!0),f.debug("Debug mode enabled"));let e=await ht();f.debug("User config loaded",e);let o=await oe();f.debug("RapidKit config loaded",o);let r=ne(e,o,{author:i.author,pythonVersion:void 0,skipGit:i.skipGit});f.debug("Merged config",r),i.updateCheck!==!1&&await ee(),console.log(m.blue.bold(`
1531
+ `);it.argument("[name]","Name of the workspace or project directory").addOption(new Option("-t, --template <template>","Legacy: create a project with template (fastapi, nestjs) instead of a workspace").hideHelp()).option("-y, --yes","Skip prompts and use defaults").addOption(new Option("--skip-git","Skip git initialization").hideHelp()).addOption(new Option("--skip-install","Legacy: skip installing dependencies (template mode)").hideHelp()).option("--debug","Enable debug logging").addOption(new Option("--dry-run","Show what would be created without creating it").hideHelp()).addOption(new Option("--install-method <method>","Installation method: poetry, venv, or pipx").choices(["poetry","venv","pipx"]).hideHelp()).addOption(new Option("--create-workspace","When creating a project outside a workspace: create and register a workspace in the current directory").hideHelp()).addOption(new Option("--no-workspace","When creating a project outside a workspace: do not create a workspace").hideHelp()).option("--no-update-check","Skip checking for updates").action(async(t,i)=>{try{i.debug&&(y.setDebug(!0),y.debug("Debug mode enabled"));let e=await yt();y.debug("User config loaded",e);let o=await se();y.debug("RapidKit config loaded",o);let r=ce(e,o,{author:i.author,pythonVersion:void 0,skipGit:i.skipGit});y.debug("Merged config",r),i.updateCheck!==!1&&await re(),console.log(m.blue.bold(`
1526
1532
  \u{1F680} Welcome to RapidKit!
1527
- `)),t||(zi(),process.exit(0));try{re(t);}catch(s){throw s instanceof G&&(f.error(`
1528
- \u274C ${s.message}`),s.details&&f.warn(`\u{1F4A1} ${s.details}
1529
- `),process.exit(1)),s}let n=w.resolve(process.cwd(),t);Z=n,await k.pathExists(n)&&(f.error(`
1533
+ `)),t||(po(),process.exit(0));try{le(t);}catch(s){throw s instanceof U&&(y.error(`
1534
+ \u274C ${s.message}`),s.details&&y.warn(`\u{1F4A1} ${s.details}
1535
+ `),process.exit(1)),s}let n=k.resolve(process.cwd(),t);et=n,await v.pathExists(n)&&(y.error(`
1530
1536
  \u274C Directory "${t}" already exists`),console.log(m.cyan(`
1531
1537
  \u{1F4A1} Choose a different name or delete the existing directory.
1532
1538
  `)),process.exit(1));let a=!!i.template;if(i.dryRun){console.log(m.cyan(`
1533
1539
  \u{1F50D} Dry-run mode - showing what would be created:
1534
- `)),console.log(m.white("\u{1F4C2} Path:"),n),console.log(m.white("\u{1F4E6} Type:"),a?`Project (${i.template})`:"Workspace"),console.log();return}if(!i.yes&&!a?await Jt.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"}]):i.yes&&console.log(m.gray(`Using default values (--yes flag)
1535
- `)),a){let s=String(i.template||"").trim(),c=s.toLowerCase(),l=c==="fastapi"?"fastapi.standard":c==="nestjs"?"nestjs.standard":s;if(!!!It(process.cwd())){if(i.createWorkspace)await rt(process.cwd(),{skipGit:i.skipGit,yes:i.yes,userConfig:e});else if(!i.noWorkspace)if(i.yes)await rt(process.cwd(),{skipGit:i.skipGit,yes:!0,userConfig:e});else {let{createWs:y}=await Jt.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:!0}]);y&&await rt(process.cwd(),{skipGit:i.skipGit,yes:!1,userConfig:e});}}let d=["create","project",l,t,"--output",process.cwd(),"--install-essentials"],u=await B(d,{cwd:process.cwd()});u!==0&&process.exit(u);let h=It(process.cwd());if(h){let y=w.dirname(h),x=w.join(y,".python-version"),A=w.join(n,".python-version");try{if(await k.pathExists(x)){let D=F.readFileSync(x,"utf-8");F.writeFileSync(A,D.trim()+`
1536
- `),f.debug(`Synced Python version ${D.trim()} from workspace to project`);}}catch(D){f.debug("Could not sync Python version from workspace:",D);}}if(!i.skipInstall){let y=await B(["init",n],{cwd:process.cwd()});if(y!==0&&process.exit(y),h){let x=w.dirname(h),A=w.join(x,".python-version"),D=w.join(n,".python-version");try{if(await k.pathExists(A)){let O=F.readFileSync(A,"utf-8");F.writeFileSync(D,O.trim()+`
1537
- `),f.debug(`Re-synced Python version ${O.trim()} after init`);}}catch(O){f.debug("Could not re-sync Python version after init:",O);}}}}else await Ce(t,{skipGit:i.skipGit,dryRun:i.dryRun,yes:i.yes,userConfig:r,installMethod:i.installMethod});}catch(e){e instanceof G?(f.error(`
1538
- \u274C ${e.message}`),e.details&&f.warn(`\u{1F4A1} ${e.details}`),f.debug("Error code:",e.code)):(f.error(`
1539
- \u274C An unexpected error occurred:`),console.error(e)),process.exit(1);}finally{Z=null;}});tt.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async t=>{t!=="activate"&&(console.log(m.red(`Unknown shell command: ${t}`)),process.exit(1));let i=process.cwd();function e(c){let l=c;for(;;){let p=w.join(l,".rapidkit","context.json");if(F.existsSync(p))return p;let d=w.dirname(l);if(d===l)break;l=d;}return null}let o=e(i);function r(c){let l=c;for(;;){let p=w.join(l,".venv"),d=w.join(l,".rapidkit","activate");if(F.existsSync(d)||F.existsSync(p))return {venv:p,activateFile:d};let u=w.dirname(l);if(u===l)break;l=u;}return null}let n=r(i);!o&&!n&&(console.log(m.yellow("No RapidKit project found in this directory")),process.exit(1));let a;n&&F.existsSync(n.activateFile)?a=n.activateFile:n&&F.existsSync(n.venv)?a=process.platform==="win32"?w.join(n.venv,"Scripts","activate"):w.join(n.venv,"bin","activate"):(console.log(m.yellow("No virtual environment found")),process.exit(1));let s=process.platform==="win32";console.log(s?`call "${a}"`:`. "${a}"`);});tt.command("doctor").description("\u{1FA7A} Check RapidKit environment health").option("--workspace","Check entire workspace (including all projects)").option("--json","Output results in JSON format (for CI/CD pipelines)").option("--fix","Automatically fix common issues (with confirmation)").action(async t=>{await Ke(t);});tt.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async t=>{if(t==="list"){let{listWorkspaces:i}=await Promise.resolve().then(()=>(Q(),q));await i();}else if(t==="sync"){let i=St(process.cwd());i||(console.log(m.red("\u274C Not inside a RapidKit workspace")),console.log(m.gray("\u{1F4A1} Run this command from within a workspace directory")),process.exit(1));let{syncWorkspaceProjects:e}=await Promise.resolve().then(()=>(Q(),q));console.log(m.cyan(`\u{1F4C2} Scanning workspace: ${w.basename(i)}`)),await e(i);}else console.log(m.red(`Unknown workspace action: ${t}`)),console.log(m.gray("Available: list, sync")),process.exit(1);});function zi(){console.log(m.white(`Usage:
1540
+ `)),console.log(m.white("\u{1F4C2} Path:"),n),console.log(m.white("\u{1F4E6} Type:"),a?`Project (${i.template})`:"Workspace"),console.log();return}if(!i.yes&&!a?await qt.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"}]):i.yes&&console.log(m.gray(`Using default values (--yes flag)
1541
+ `)),a){let s=String(i.template||"").trim(),c=s.toLowerCase(),l=c==="fastapi"?"fastapi.standard":c==="nestjs"?"nestjs.standard":s;if(!!!Dt(process.cwd())){if(i.createWorkspace)await st(process.cwd(),{skipGit:i.skipGit,yes:i.yes,userConfig:e});else if(!i.noWorkspace)if(i.yes)await st(process.cwd(),{skipGit:i.skipGit,yes:!0,userConfig:e});else {let{createWs:g}=await qt.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:!0}]);g&&await st(process.cwd(),{skipGit:i.skipGit,yes:!1,userConfig:e});}}let d=["create","project",l,t,"--output",process.cwd(),"--install-essentials"],u=await Y(d,{cwd:process.cwd()});u!==0&&process.exit(u);let f=Dt(process.cwd());if(f){let g=k.dirname(f),h=k.join(g,".python-version"),j=k.join(n,".python-version");try{if(await v.pathExists(h)){let N=O.readFileSync(h,"utf-8");O.writeFileSync(j,N.trim()+`
1542
+ `),y.debug(`Synced Python version ${N.trim()} from workspace to project`);}}catch(N){y.debug("Could not sync Python version from workspace:",N);}}if(!i.skipInstall){let g=await Y(["init",n],{cwd:process.cwd()});if(g!==0&&process.exit(g),f){let h=k.dirname(f),j=k.join(h,".python-version"),N=k.join(n,".python-version");try{if(await v.pathExists(j)){let T=O.readFileSync(j,"utf-8");O.writeFileSync(N,T.trim()+`
1543
+ `),y.debug(`Re-synced Python version ${T.trim()} after init`);}}catch(T){y.debug("Could not re-sync Python version after init:",T);}}}}else await Te(t,{skipGit:i.skipGit,dryRun:i.dryRun,yes:i.yes,userConfig:r,installMethod:i.installMethod});}catch(e){e instanceof U?(y.error(`
1544
+ \u274C ${e.message}`),e.details&&y.warn(`\u{1F4A1} ${e.details}`),y.debug("Error code:",e.code)):(y.error(`
1545
+ \u274C An unexpected error occurred:`),console.error(e)),process.exit(1);}finally{et=null;}});it.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async t=>{t!=="activate"&&(console.log(m.red(`Unknown shell command: ${t}`)),process.exit(1));let i=process.cwd();function e(c){let l=c;for(;;){let p=k.join(l,".rapidkit","context.json");if(O.existsSync(p))return p;let d=k.dirname(l);if(d===l)break;l=d;}return null}let o=e(i);function r(c){let l=c;for(;;){let p=k.join(l,".venv"),d=k.join(l,".rapidkit","activate");if(O.existsSync(d)||O.existsSync(p))return {venv:p,activateFile:d};let u=k.dirname(l);if(u===l)break;l=u;}return null}let n=r(i);!o&&!n&&(console.log(m.yellow("No RapidKit project found in this directory")),process.exit(1));let a;n&&O.existsSync(n.activateFile)?a=n.activateFile:n&&O.existsSync(n.venv)?a=process.platform==="win32"?k.join(n.venv,"Scripts","activate"):k.join(n.venv,"bin","activate"):(console.log(m.yellow("No virtual environment found")),process.exit(1));let s=process.platform==="win32";console.log(s?`call "${a}"`:`. "${a}"`);});it.command("doctor").description("\u{1FA7A} Check RapidKit environment health").option("--workspace","Check entire workspace (including all projects)").option("--json","Output results in JSON format (for CI/CD pipelines)").option("--fix","Automatically fix common issues (with confirmation)").action(async t=>{await Je(t);});it.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async t=>{if(t==="list"){let{listWorkspaces:i}=await Promise.resolve().then(()=>(Z(),X));await i();}else if(t==="sync"){let i=Nt(process.cwd());i||(console.log(m.red("\u274C Not inside a RapidKit workspace")),console.log(m.gray("\u{1F4A1} Run this command from within a workspace directory")),process.exit(1));let{syncWorkspaceProjects:e}=await Promise.resolve().then(()=>(Z(),X));console.log(m.cyan(`\u{1F4C2} Scanning workspace: ${k.basename(i)}`)),await e(i);}else console.log(m.red(`Unknown workspace action: ${t}`)),console.log(m.gray("Available: list, sync")),process.exit(1);});function po(){console.log(m.white(`Usage:
1540
1546
  `)),console.log(m.cyan(" npx rapidkit <workspace-name> [options]")),console.log(m.cyan(` npx rapidkit create <...>
1541
1547
  `)),console.log(m.bold("Recommended workflow:")),console.log(m.cyan(" npx rapidkit my-workspace")),console.log(m.cyan(" cd my-workspace")),console.log(m.cyan(" npx rapidkit create project fastapi.standard my-api --output .")),console.log(m.cyan(" cd my-api")),console.log(m.cyan(` npx rapidkit init && npx rapidkit dev
1542
1548
  `)),console.log(m.bold("Options (workspace creation):")),console.log(m.gray(" -y, --yes Skip prompts and use defaults")),console.log(m.gray(" --skip-git Skip git initialization")),console.log(m.gray(" --debug Enable debug logging")),console.log(m.gray(" --dry-run Show what would be created")),console.log(m.gray(" --create-workspace When creating a project outside a workspace: create and register a workspace in the current directory")),console.log(m.gray(" --no-workspace When creating a project outside a workspace: do not create a workspace")),console.log(m.gray(` --no-update-check Skip checking for updates
1543
1549
  `)),console.log(m.gray(`Tip: set RAPIDKIT_SHOW_LEGACY=1 to show legacy template flags in help.
1544
- `));}process.on("SIGINT",async()=>{if(!At){if(At=true,console.log(m.yellow(`
1550
+ `));}process.on("SIGINT",async()=>{if(!Tt){if(Tt=true,console.log(m.yellow(`
1545
1551
 
1546
- \u26A0\uFE0F Interrupted by user`)),Z&&await k.pathExists(Z)){console.log(m.gray("Cleaning up partial installation..."));try{await k.remove(Z),console.log(m.green("\u2713 Cleanup complete"));}catch(t){f.debug("Cleanup failed:",t);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!At){if(At=true,f.debug("Received SIGTERM"),Z&&await k.pathExists(Z))try{await k.remove(Z);}catch(t){f.debug("Cleanup failed:",t);}process.exit(143);}});Bi().then(async t=>{if(!t){let i=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(i)}
1547
- `),i[0]==="create"){let o=await Ui(i);process.exit(o);}let e=await Yi(i);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${e}
1548
- `),e){let o=await B(i,{cwd:process.cwd()});process.exit(o);}tt.parse();}});export{Ui as handleCreateOrFallback};
1552
+ \u26A0\uFE0F Interrupted by user`)),et&&await v.pathExists(et)){console.log(m.gray("Cleaning up partial installation..."));try{await v.remove(et),console.log(m.green("\u2713 Cleanup complete"));}catch(t){y.debug("Cleanup failed:",t);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!Tt){if(Tt=true,y.debug("Received SIGTERM"),et&&await v.pathExists(et))try{await v.remove(et);}catch(t){y.debug("Cleanup failed:",t);}process.exit(143);}});so().then(async t=>{if(!t){let i=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(i)}
1553
+ `),i[0]==="create"){let o=await ro(i);process.exit(o);}let e=await lo(i);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${e}
1554
+ `),e){let o=await Y(i,{cwd:process.cwd()});process.exit(o);}it.parse();}});export{ro as handleCreateOrFallback};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
6
6
  "keywords": [
@@ -54,6 +54,8 @@
54
54
  "security": "npm audit --audit-level=moderate",
55
55
  "security:fix": "npm audit fix",
56
56
  "metrics": "npx tsx scripts/metrics.ts",
57
+ "sync:contracts": "node scripts/sync-contracts.mjs",
58
+ "check:contracts": "node scripts/sync-contracts.mjs --check",
57
59
  "bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
58
60
  "quality": "npm run validate && npm run security && npm run metrics",
59
61
  "act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
6
6
  "keywords": [
@@ -54,6 +54,8 @@
54
54
  "security": "npm audit --audit-level=moderate",
55
55
  "security:fix": "npm audit fix",
56
56
  "metrics": "npx tsx scripts/metrics.ts",
57
+ "sync:contracts": "node scripts/sync-contracts.mjs",
58
+ "check:contracts": "node scripts/sync-contracts.mjs --check",
57
59
  "bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
58
60
  "quality": "npm run validate && npm run security && npm run metrics",
59
61
  "act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix"